Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// limit number of claims for ledger devices due to memory constraints
const claimableClaims = publicKey ? claims.slice(0, 25) : claims;
// send claim request
const {
response: { result, txid }
} = await api.claimGas(
{
net,
address,
publicKey,
privateKey,
signingFunction,
claims: claimableClaims
},
api.neoscan
);
if (!result) {
throw new Error('Transaction rejected by blockchain');
}
return txid;
}
}: Props = {}) => async () => {
// If refresh action dispatched reset pagination
// to grab the most recent abstracts
if (!shouldIncrementPagination) {
page = 1
}
const endpoint = api.neoscan.getAPIEndpoint(net)
const { data } = await axios.get(
`${endpoint}/v1/get_address_abstracts/${address}/${page}`,
)
const parsedEntries = await parseAbstractData(data.entries, address, net)
page += 1
if (shouldIncrementPagination) {
if (page === 1) entries = []
entries.push(...parsedEntries)
return entries
}
entries = [...parsedEntries]
return entries
},
)
async componentDidMount(){
const mainNetNeoscan = new api.neoscan.instance("TestNet");
const neoscanBalance = await mainNetNeoscan.getBalance('AH4dqfuyaT1tGthQiQQ2RQ8c7Xksuphb7k');
console.log(neoscanBalance)
}
}) {
const url = await getRPCEndpoint(net);
const {
response: { result }
} = await api.sendAsset(
{
net,
url,
address,
publicKey,
privateKey,
signingFunction,
intents: api.makeIntent({ NEO: balance }, address)
},
api.neoscan
);
if (!result) {
throw new Error('Transaction rejected by blockchain');
}
return result.response;
}
} else if (Array.isArray(remark)) {
for (let i = 0; i < remark.length; i += 1) {
transaction.addAttribute(tx.TxAttrUsage.Remark + i, remark[i]);
}
}
return doSendAsset({ ...config, balance, tx: transaction }, api.neoscan);
} else {
const script = createScript(
asset,
'transfer',
[address, receiver, new u.Fixed8(amount)],
true
);
return doInvoke({ ...config, script, gas: 0 }, api.neoscan);
}
};
privateKey: wif,
publicKey,
signingFunction,
gas: 0,
fees: fee
};
if (assets) {
const scAddress = wallet.getAddressFromScriptHash(scriptHash);
const intentConfig = mapKeys(formatAssets(assets), (value, key) => ASSETS[key].symbol);
config.intents = api.makeIntent(intentConfig, scAddress);
}
const {
response: { result, txid }
} = await api.doInvoke(config, api.neoscan);
if (!result) {
throw new Error('Invocation failed.');
}
return txid;
}
if (amount <= 0) {
throw new Error(`Invalid amount: "${amount}"`);
}
const selectedAsset = ASSETS[asset];
const intents = await api.makeIntent({ [selectedAsset]: amount }, receiver);
const config = {
net,
address,
privateKey: new wallet.Account(wif).privateKey,
intents
};
const { response: { result, txid } } = await api.sendAsset(config, api.neoscan);
if (!result) {
throw new Error('Invocation failed.');
}
return txid;
}
fetchHistory = async () => {
const { showInfoNotification, net, address } = this.props
const infoNotification = showInfoNotification({
message: 'Fetching entire transaction history...',
})
const abstracts = []
const endpoint = api.neoscan.getAPIEndpoint(net)
let numberOfPages = 1
let currentPage = 1
let shouldFetchAdditionalPages = true
while (
(currentPage - 1 !== numberOfPages || currentPage === 1) &&
shouldFetchAdditionalPages
) {
const { data } = await axios.get(
`${endpoint}/v1/get_address_abstracts/${address}/${currentPage}`,
)
abstracts.push(...data.entries)
numberOfPages = data.total_pages
currentPage += 1
if (data.total_pages === 1 || data.total_pages === 0) {
({ networkId, address }: Props = {}) => async (state: Object) => {
const net = getNetworkById(networkId)
const endpoint = await api.getRPCEndpointFrom({ net }, api.neoscan)
const client = new rpc.RPCClient(endpoint)
const validators = await client.getValidators()
const accountState = await client.getAccountState(address)
return {
validators,
votes: accountState.votes,
}
},
)