How to use the iotex-antenna/lib/crypto/address.fromBytes 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 / shared / wallet / decode-contract-data.ts View on Github external
return `${i.name}`;
        }),
        inputsTypes: args.map(i => {
          return `${i.type}`;
        })
      };

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

      for (let i = 0; i < methodDef.inputsTypes.length; i++) {
        if (methodDef.inputsTypes[i] === "address") {
          params[i] = fromBytes(
            Buffer.from(params[i].toString(), "hex")
          ).string();
        }
        // @ts-ignore
        values[method.inputsNames[i]] = params[i];
      }

      return {
        method: methodDef.name,
        data: values
      };
    }
  }

  window.console.warn("can not found method");
  return { method: data, data: {} };
github iotexproject / iotex-explorer / src / erc20 / erc20.ts View on Github external
throw new Error("input data error");
    }
    const methodKey = data.substr(0, 8);
    const method = this.methods[methodKey];
    if (!method) {
      throw new Error(`method ${methodKey} is not erc20 method`);
    }
    const params = ethereumjs.rawDecode(
      method.inputsTypes,
      Buffer.from(data.substring(8), "hex")
    );
    const values = {};

    for (let i = 0; i < method.inputsTypes.length; i++) {
      if (method.inputsTypes[i] === "address") {
        params[i] = fromBytes(
          Buffer.from(params[i].toString(), "hex")
        ).string();
      }
      // @ts-ignore
      values[method.inputsNames[i]] = params[i];
    }

    return {
      method: method.name,
      data: values
    };
  }
}