How to use the web3-core-helpers.formatters.inputDefaultBlockNumberFormatter function in web3-core-helpers

To help you get started, we’ve selected a few web3-core-helpers 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 ninabreznik / voting-ethereum-contract / node_modules / web3-core-method / src / index.js View on Github external
// add custom send Methods
    var _ethereumCalls = [
        new Method({
            name: 'getTransactionReceipt',
            call: 'eth_getTransactionReceipt',
            params: 1,
            inputFormatter: [null],
            outputFormatter: formatters.outputTransactionReceiptFormatter
        }),
        new Method({
            name: 'getCode',
            call: 'eth_getCode',
            params: 2,
            inputFormatter: [formatters.inputAddressFormatter, formatters.inputDefaultBlockNumberFormatter]
        }),
        new Subscriptions({
            name: 'subscribe',
            type: 'eth',
            subscriptions: {
                'newBlockHeaders': {
                    subscriptionName: 'newHeads', // replace subscription with this name
                    params: 0,
                    outputFormatter: formatters.outputBlockFormatter
                }
            }
        })
    ];
    // attach methods to this._ethereumCall
    var _ethereumCall = {};
    _.each(_ethereumCalls, function (mthd) {
github ethereum / web3.js / packages / web3-eth-contract / src / index.js View on Github external
accounts: ethAccounts, // is eth.accounts (necessary for wallet signing)
                    defaultAccount: _this._parent.defaultAccount,
                    defaultBlock: _this._parent.defaultBlock
                })).createFunction();

                return estimateGas(args.options, args.callback);

            case 'call':

                // TODO check errors: missing "from" should give error on deploy and send, call ?

                var call = (new Method({
                    name: 'call',
                    call: 'eth_call',
                    params: 2,
                    inputFormatter: [formatters.inputCallFormatter, formatters.inputDefaultBlockNumberFormatter],
                    // add output formatter for decoding
                    outputFormatter: function (result) {
                        return _this._parent._decodeMethodReturn(_this._method.outputs, result);
                    },
                    requestManager: _this._parent._requestManager,
                    accounts: ethAccounts, // is eth.accounts (necessary for wallet signing)
                    defaultAccount: _this._parent.defaultAccount,
                    defaultBlock: _this._parent.defaultBlock
                })).createFunction();

                return call(args.options, args.defaultBlock, args.callback);

            case 'send':

                // return error, if no "from" is specified
                if(!utils.isAddress(args.options.from)) {
github citahub / cita-sdk-js / packages / nervos-chain / src / contract / index.js View on Github external
}
              })

              delete receipt.logs
            }
            return receipt
          },
          contractDeployFormatter: function (receipt) {
            var newContract = _this._parent.clone()
            newContract.options.address = receipt.contractAddress
            return newContract
          },
        }

        var call = args.options.quota ? 'sendTransaction' : 'eth_sendTransaction'
        var signer = args.options.quota ? sign : formatters.inputDefaultBlockNumberFormatter


        var sendTransaction = new Method({
          name: 'sendTransaction',
          call,
          params: 1,
          inputFormatter: [signer],
          requestManager: _this._parent._requestManager,
          accounts: _this.constructor._ethAccounts || _this._ethAccounts, // is eth.accounts (necessary for wallet signing)
          defaultAccount: _this._parent.defaultAccount,
          defaultBlock: _this._parent.defaultBlock,
          extraFormatters: extraFormatters,
        }).createFunction()

        return sendTransaction(args.options, args.callback)
    }
github citahub / cita-sdk-js / packages / cita-sdk / src / base / rpc.ts View on Github external
formatters.inputAddressFormatter
    // signer
  ],
  transformPayload: function(payload: any) {
    payload.params.reverse()
    return payload
  }
}

export const call = {
  name: 'call',
  call: 'call',
  params: 2,
  inputFormatter: [
    formatters.inputCallFormatter,
    formatters.inputDefaultBlockNumberFormatter
  ]
}

export const getLogs = {
  name: 'getLogs',
  call: 'getLogs',
  params: 1
}

// new coming in v0.23.0

export const peersInfo = {
  name: 'peersInfo',
  call: 'peersInfo',
  params: 0
}
github citahub / cita-sdk-js / packages / nervos-chain / src / contract / index.js View on Github external
Array.prototype.slice.call(arguments),
      defer,
    ),
    defer = promiEvent(args.type !== 'send'),
    ethAccounts = _this.constructor._ethAccounts || _this._ethAccounts

  // simple return request for batch requests
  if (args.generateRequest) {
    var payload = {
      params: [formatters.inputCallFormatter.call(this._parent, args.options)],
      callback: args.callback,
    }

    if (args.type === 'call') {
      payload.params.push(
        formatters.inputDefaultBlockNumberFormatter.call(
          this._parent,
          args.defaultBlock,
        ),
      )
      payload.method = 'call'
      payload.format = this._parent._decodeMethodReturn.bind(
        null,
        this._method.outputs,
      )
    } else {
      payload.method = 'sendTransaction'
    }

    return payload
  } else {
    switch (args.type) {
github citahub / cita-sdk-js / packages / cita-sdk / src / contract / index.ts View on Github external
)
  var defer: any = promiEvent(args.type !== 'send')
  const ethAccounts = ctx.constructor._ethAccounts || ctx._ethAccounts

  // simple return request for batch requests
  if (args.generateRequest) {
    const payload = {
      params: [formatters.inputCallFormatter.call(this._parent, args.options)],
      callback: args.callback,
      method: '',
      format: null
    }

    if (args.type === Action.CALL) {
      payload.params.push(
        formatters.inputDefaultBlockNumberFormatter.call(
          this._parent,
          args.defaultBlock
        )
      )
      payload.method = Action.CALL
      payload.format = this._parent._decodeMethodReturn.bind(
        null,
        this._method.outputs
      )
    } else {
      payload.method = Action.SEND_TRANSACTION
    }

    return payload
  } else {
    switch (args.type) {
github citahub / cita-sdk-js / packages / cita-sdk / lib / base / rpc.js View on Github external
inputFormatter: [
        formatters.inputSignFormatter,
        formatters.inputAddressFormatter
    ],
    transformPayload: function (payload) {
        payload.params.reverse();
        return payload;
    }
};
exports.call = {
    name: 'call',
    call: 'call',
    params: 2,
    inputFormatter: [
        formatters.inputCallFormatter,
        formatters.inputDefaultBlockNumberFormatter
    ]
};
exports.getLogs = {
    name: 'getLogs',
    call: 'getLogs',
    params: 1
};
exports.peersInfo = {
    name: 'peersInfo',
    call: 'peersInfo',
    params: 0
};
exports.getVersion = {
    name: 'getVersion',
    call: 'getVersion',
    params: 0
github citahub / cita-sdk-js / packages / cita-sdk / lib / contract / index.js View on Github external
Contract.prototype._executeMethod = function _executeMethod() {
    const ctx = this;
    let args = this._parent._processExecuteArguments.call(this, Array.prototype.slice.call(arguments), defer);
    var defer = promiEvent(args.type !== 'send');
    const ethAccounts = ctx.constructor._ethAccounts || ctx._ethAccounts;
    if (args.generateRequest) {
        const payload = {
            params: [formatters.inputCallFormatter.call(this._parent, args.options)],
            callback: args.callback,
            method: '',
            format: null
        };
        if (args.type === Action.CALL) {
            payload.params.push(formatters.inputDefaultBlockNumberFormatter.call(this._parent, args.defaultBlock));
            payload.method = Action.CALL;
            payload.format = this._parent._decodeMethodReturn.bind(null, this._method.outputs);
        }
        else {
            payload.method = Action.SEND_TRANSACTION;
        }
        return payload;
    }
    else {
        switch (args.type) {
            case Action.CALL:
                const call = new Method({
                    name: 'call',
                    call: Action.CALL,
                    params: 2,
                    inputFormatter: [
github wanchain / wanx / src / lib / wan-attach-rpc.js View on Github external
params: 2,
        inputFormatter: [formatters.inputAddressFormatter, null]
    });

    const generateOneTimeAddress = new Method({
        name: 'generateOneTimeAddress',
        call: 'wan_generateOneTimeAddress',
        params: 1,
        inputFormatter: [null]
    });

    const getOTABalance = new Method({
        name: 'getOTABalance',
        call: 'wan_getOTABalance',
        params: 2,
        inputFormatter: [null, formatters.inputDefaultBlockNumberFormatter],
        outputFormatter: formatters.outputBigNumberFormatter
    });

    const getOTAMixSet = new Method({
        name: 'getOTAMixSet',
        call: 'wan_getOTAMixSet',
        params: 2
    });

    const getSupportStampOTABalances = new Method({
        name: 'getSupportStampOTABalances',
        call: 'wan_getSupportStampOTABalances',
        params: 0,
    });

    const getSupportWanCoinOTABalances = new Method({