How to use the nahmii-sdk/lib/settlement/driip-settlement-challenge-contract function in nahmii-sdk

To help you get started, we’ve selected a few nahmii-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hubiinetwork / hubii-core / src / containers / NahmiiHoc / saga.js View on Github external
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]);