How to use the iotex-antenna/lib/contract/abi-to-byte.getArgTypes function in iotex-antenna

To help you get started, we’ve selected a few iotex-antenna 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 iotexproject / iotex-explorer / src / erc20 / erc20.ts View on Github external
erc20.address = address;
    erc20.provider = provider;
    erc20.contract = new Contract(abi, address, {
      provider: provider
    });

    const methods = {};
    // @ts-ignore
    for (const fnName of Object.keys(erc20.contract.getABI())) {
      // @ts-ignore
      const fnAbi = erc20.contract.getABI()[fnName];
      if (fnAbi.type === "constructor") {
        continue;
      }

      const args = getArgTypes(fnAbi);
      const header = getHeaderHash(fnAbi, args);

      // @ts-ignore
      methods[header] = {
        name: fnName,
        inputsNames: args.map(i => {
          return `${i.name}`;
        }),
        inputsTypes: args.map(i => {
          return `${i.type}`;
        })
      };
    }
    erc20.methods = methods;
    return erc20;
  }
github iotexproject / iotex-explorer / src / erc20 / vita.ts View on Github external
vita.address = address;
    vita.provider = provider;
    vita.contract = new Contract(ABI, address, {
      provider: provider
    });

    const methods = {};
    // @ts-ignore
    for (const fnName of Object.keys(vita.contract.getABI())) {
      // @ts-ignore
      const fnAbi = vita.contract.getABI()[fnName];
      if (fnAbi.type === "constructor") {
        continue;
      }

      const args = getArgTypes(fnAbi);
      const header = getHeaderHash(fnAbi, args);

      // @ts-ignore
      methods[header] = {
        name: fnName,
        inputsNames: args.map(i => {
          return `${i.name}`;
        }),
        inputsTypes: args.map(i => {
          return `${i.type}`;
        })
      };
    }
    vita.methods = methods;

    return vita;
github iotexproject / iotex-explorer / src / shared / wallet / decode-contract-data.ts View on Github external
if (data.length < 8) {
    window.console.warn("input data error");
    return { method: data, data: {} };
  }
  const method = data.substr(0, 8);

  const ABI = JSON.parse(abi);
  const erc20: ERC20 = ERC20.create(contractAddress, getAntenna().iotx, ABI);

  const contractAbi = erc20.contract.getABI() as AbiByFunc;
  for (const fnName of Object.keys(contractAbi)) {
    const fnAbi = contractAbi[fnName];
    if (fnAbi.type === "constructor") {
      continue;
    }
    const args = getArgTypes(fnAbi);
    const header = getHeaderHash(fnAbi, args);

    if (method === header) {
      const methodDef = {
        name: fnName,
        inputsNames: args.map(i => {
          return `${i.name}`;
        }),
        inputsTypes: args.map(i => {
          return `${i.type}`;
        })
      };

      const params = ethereumjs.rawDecode(
        methodDef.inputsTypes,
        Buffer.from(data.substring(8), "hex")