How to use the web3-eth-abi.AbiCoder function in web3-eth-abi

To help you get started, we’ve selected a few web3-eth-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 bodhiproject / bodhi-ui / src / stores / TransactionStore.js View on Github external
const SET_EVENT_FUNC_SIG = 'a6b4218b';
const VOTE_EVENT_FUNC_SIG = '1e00eb7f';

const CREATE_EVENT_FUNC_TYPES = [
  'string',
  'bytes32[3]',
  'uint256',
  'uint256',
  'address',
  'uint8',
  'uint256',
];
const PLAY_EVENT_FUNC_TYPES = [
  'uint8',
];
const web3EthAbi = new AbiCoder();

export default class TransactionStore {
  app = undefined;

  constructor(app) {
    this.app = app;
  }

  handleReqError = (err, reqName) => {
    const { globalDialog } = this.app;
    if (err.networkError
      && err.networkError.result.errors
      && err.networkError.result.errors.length > 0) {
      // Handles GraphQL error
      globalDialog.setError(
        `${err.message} : ${err.networkError.result.errors[0].message}`,
github jpmorganchase / anonymous-zether / packages / anonymous.js / src / prover / zether / anon.js View on Github external
constructor() {
        var abiCoder = new AbiCoder();

        var params = new GeneratorParams();

        this.generateProof = (statement, witness, salt) => {
            var size = statement['y'].length();
            if (params.size() < size) {
                params.extend(size);
            } // one-off cost when a "new record" size is used.

            var rP = bn128.randomScalar();
            var rQ = bn128.randomScalar();
            var rU = bn128.randomScalar();
            var rV = bn128.randomScalar();
            var rX = bn128.randomScalar();
            var rY = bn128.randomScalar();
            var p = Array.from({ length: 2 }).map(() => Array.from({ length: size - 1 }).map(bn128.randomScalar));
github theoephraim / ethdevtools / src / devtools / store.js View on Github external
/* eslint-disable no-param-reassign, prefer-destructuring */
import BigNumber from 'bignumber.js';
import _ from 'lodash';
import Vue from 'vue';
import Vuex from 'vuex';
// import { processMethod, processResult } from './assets/utils';
import { AbiCoder } from 'web3-eth-abi';
import AbiDecoder from 'abi-decoder';

window.AbiDecoder = AbiDecoder;

const abiCoder = new AbiCoder();

Vue.use(Vuex);

const EQ_PARAMS = ['method', 'params', 'result'];

const store = new Vuex.Store({
  state: {
    logs: {}, // will be keyed by ID,
    sends: [],
    results: {},
    contracts: {},
    accounts: {},
  },
  getters: {
    logs: (state) => _.orderBy(_.values(state.logs), 'time'),
    contracts: (state) => _.values(state.contracts),
github theoephraim / ethdevtools / src / devtools / assets / utils.js View on Github external
import BigNumber from 'bignumber.js';
import { AbiCoder } from 'web3-eth-abi';

const abiCoder = new AbiCoder();

const abiDecoder = require('abi-decoder');

export const processMethod = {
  eth_accounts: () => ({
    to: null,
    name: null,
    params: null,
  }),
  eth_call: (args, _, contracts) => {
    console.log('eth_call');
    console.log(args);
    const contractAddress = `${args[1][0].to.toLowerCase()}`;
    const methodSig = args[1][0].data.slice(0, 10);

    let decodedInput; let name; let
github sprusr / ethpollo / src / ContractQueryTransform.ts View on Github external
import { Request, Transform } from 'graphql-tools';
import { visit, Kind } from 'graphql';
import { AbiCoder } from 'web3-eth-abi';

import { Contracts } from "./types";
import { makeCallTree } from './ast';

const abiCoder = new AbiCoder();

export default class ContractQueryTransform implements Transform {
  public contracts: Contracts;

  constructor(contracts: any) {
    this.contracts = contracts;
  }

  public transformRequest(originalRequest: Request) {
    const document = originalRequest.document;
    const fieldPath = [];
    const newNodes = [];
    const newDocument = visit(document, {
      [Kind.FIELD]: {
        enter: node => {
          fieldPath.push(node.name.value);
github jpmorganchase / anonymous-zether / packages / anonymous.js / src / prover / burn / sigma.js View on Github external
constructor() {
        var abiCoder = new AbiCoder();

        var params = new GeneratorParams();

        this.generateProof = (statement, witness, salt) => {
            var z = statement['z'];
            var zs = [z.redPow(new BN(2))];
            for (var i = 1; i < 2; i++) {
                zs.push(zs[i - 1].redMul(z));
            }

            var kX = bn128.randomScalar();

            var Ay = params.getG().mul(kX);
            var Au = utils.gEpoch(statement['epoch']).mul(kX);
            var At = statement['CRn'].mul(zs[0]).add(statement['HR'].mul(zs[1])).mul(kX);
github AztecProtocol / AZTEC / packages / aztec.js / src / sign / eip712.js View on Github external
/**
 * Module to construct ECDSA messages for structured data,
 * following the [EIP712]{@link https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md} standard
 *
 * @module sign.eip712
 */

const { padLeft, sha3 } = require('web3-utils');
const { AbiCoder } = require('web3-eth-abi');

function padKeccak256(data) {
    return padLeft(sha3(data).slice(2), 64);
}

const abiCoder = new AbiCoder();

const eip712 = {};

/**
 * Create 'type' component of a struct
 *
 * @method encodeStruct
 * @param {string} primaryType the top-level type of the struct
 * @param {Object} types set of all types encompassed by struct
 * @param {string} types.name name
 * @param {string} types.type type
 * @returns {string} encoded type string
 */
eip712.encodeStruct = function encodeStruct(primaryType, types) {
    const findTypes = (type) =>
        [type].concat(
github jpmorganchase / anonymous-zether / packages / anonymous.js / src / prover / zether / sigma.js View on Github external
constructor() {
        var abiCoder = new AbiCoder();

        var params = new GeneratorParams();

        this.generateProof = (statement, witness, salt) => {
            var y = statement['y'][0].getVector()[0];
            var yBar = statement['y'][1].getVector()[0];
            var z = statement['z'];
            var zs = [z.redPow(new BN(2))];
            for (var i = 1; i < 3; i++) {
                zs.push(zs[i - 1].redMul(z));
            }

            var kR = bn128.randomScalar();
            var kX = bn128.randomScalar();

            var Ay = statement['gG'].mul(kX);
github sprusr / ethpollo / src / index.ts View on Github external
constructor(contractName: string, address: string, abi: AbiItem[]) {
    super();
    this.abi = abi;
    this.abiCoder = new AbiCoder();
    this.address = address;
    this.contractName = contractName;
    this.nodeInfo = {};
  }