Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
determineIfBalanceUpdated(
{ [token.symbol]: token.balance },
soundEnabled,
networkHasChanged,
adressHasChanged,
)
inMemoryBalances[token.symbol] = token.balance
parsedTokenBalances.push({
[token.scriptHash]: {
...token,
},
})
})
// asset balances
const assetBalances = await api
.getBalanceFrom({ net, address }, api.neoscan)
.catch(e => console.error(e))
const assets = get(assetBalances, 'balance.assets', {})
// The API doesn't always return NEO or GAS keys if, for example, the address only has one asset
const neoBalance = assets.NEO ? assets.NEO.balance.toString() : '0'
const gasBalance = assets.GAS
? assets.GAS.balance.round(COIN_DECIMAL_LENGTH).toString()
: '0'
const parsedAssets = [
{ [ASSETS.NEO]: neoBalance },
{ [ASSETS.GAS]: gasBalance },
]
determineIfBalanceUpdated(
{ [ASSETS.NEO]: neoBalance },
soundEnabled,
const config = {
net,
tokensBalanceMap,
address: fromAddress,
publicKey,
privateKey: new wallet.Account(wif).privateKey,
signingFunction: isHardwareSend ? signingFunction : null,
fees,
url,
balance: undefined,
tx: undefined,
intents: undefined,
script: undefined,
gas: undefined,
}
const balanceResults = await api
.getBalanceFrom({ net, address: fromAddress }, api.neoscan)
.catch(e => {
// indicates that neo scan is down and that api.sendAsset and api.doInvoke
// will fail unless balances are supplied
console.error(e)
config.balance = generateBalanceInfo(tokensBalanceMap, fromAddress, net)
})
if (balanceResults) config.balance = balanceResults.balance
try {
const script = buildTransferScript(
config.net,
sendEntries,
config.address,
// $FlowFixMe
config.tokensBalanceMap,
promises.push((async () => {
const assetBalances = await api.getBalanceFrom({ net, address }, api.neoscan);
const { assets } = assetBalances.balance;
// The API doesn't always return NEO or GAS keys if, for example, the address only has one asset
const neoBalance = assets.NEO ? assets.NEO.balance.toString() : '0';
const gasBalance = assets.GAS ? assets.GAS.balance.round(8).toString() : '0';
return {
[NEO]: { scriptHash: NEO, balance: neoBalance, decimals: 0 },
[GAS]: { scriptHash: GAS, balance: gasBalance, decimals: 8 }
};
})());
async function fetchBalance({ net, address }) {
const response = await api.getBalanceFrom({ net, address }, api.neoscan);
const { NEO } = response.balance.assets;
return NEO ? NEO.balance : new BigNumber(0);
}