Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function* loadStagingBalances({ address }, network) {
if (network.provider._network.chainId === 1) {
yield put(actions.loadStagingBalancesSuccess(address, []));
return;
}
let supportedAssets = (yield select(makeSelectSupportedAssets())).toJS();
if (supportedAssets.loading) {
yield take(LOAD_SUPPORTED_TOKENS_SUCCESS);
supportedAssets = (yield select(makeSelectSupportedAssets())).toJS();
}
const { nahmiiProvider } = network;
const driipSettlementChallengeContract = new DriipSettlementChallengeContract(nahmiiProvider);
while (true) { // eslint-disable-line no-constant-condition
try {
const driipSettlementChallengeContractAddress = driipSettlementChallengeContract.address;
// derive function selector
const funcBytes = utils.solidityKeccak256(['string'], ['proposalStageAmount(address,address,uint256)']);
const funcSelector = funcBytes.slice(0, 10);
// send a batch of RPC requests asking for all staging balances
// https://www.jsonrpc.org/specification#batch
const currencyCtList = supportedAssets.assets.map((a) => a.currency);
const requestBatch = currencyCtList.map((ct) => {
// encode arguments, prepare them for being sent
const encodedArgs = utils.defaultAbiCoder.encode(['address', 'address', 'int256'], [address, ct, 0]);
const dataArr = utils.concat([funcSelector, encodedArgs]);