How to use the @ethersproject/abi.Interface function in @ethersproject/abi

To help you get started, we’ve selected a few @ethersproject/abi 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 cgewecke / eth-gas-reporter / lib / gasData.js View on Github external
gasData: []
          };
          this.deployments.push(contractInfo);

          // Report gas used during pre-test deployments (ex: truffle migrate)
          if (contract.deployed && contract.deployed.transactionHash) {
            this.trackNameByAddress(name, contract.deployed.address);
            const receipt = this.sync.getTransactionReceipt(
              contract.deployed.transactionHash
            );
            contractInfo.gasData.push(utils.gas(receipt.gasUsed));
          }

          // Decode, getMethodIDs
          const methodIDs = {};
          const methods = new ethersABI.Interface(contract.abi).functions;

          // Generate sighashes and remap ethers to something similar
          // to abiDecoder.getMethodIDs
          Object.keys(methods).forEach(key => {
            const raw = ejsUtil.keccak256(key);
            const sighash = ejsUtil.bufferToHex(raw).slice(2, 10);
            methodIDs[sighash] = methods[key];
          });

          // Create Method Map;
          Object.keys(methodIDs).forEach(key => {
            const isInterface = contract.bytecode === "0x";
            const isCall = methodIDs[key].type === "call";
            const methodHasName = methodIDs[key].name !== undefined;

            if (methodHasName && !isCall && !isInterface) {
github ethers-io / ethers.js / packages / contracts / lib / index.js View on Github external
Contract.getInterface = function (contractInterface) {
        if (abi_1.Interface.isInterface(contractInterface)) {
            return contractInterface;
        }
        return new abi_1.Interface(contractInterface);
    };
    // @TODO: Allow timeout?
github ethers-io / ethers.js / packages / contracts / lib.esm / index.js View on Github external
static getInterface(contractInterface) {
        if (Interface.isInterface(contractInterface)) {
            return contractInterface;
        }
        return new Interface(contractInterface);
    }
    // @TODO: Allow timeout?