How to use web3-core-method - 10 common examples

To help you get started, we’ve selected a few web3-core-method 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 ethereum / web3.js / packages / web3-eth-contract / src / models / ContractSendMethodModel.js View on Github external
this.funcName = '';
    this.signature = '';
    this.requestOptions = null;
    this.parameters = null;
    this.abiItem = abiItem;
}

ContractSendMethodModel.prototype.beforeExecution = function (web3Package) {
    // extend SendTransactionMethodModel beforeExecution (encoding and creation of tx object)
};

ContractSendMethodModel.prototype.afterExecution = function (web3Package) {
    // extend SendTransactionMethodModel afterExecution (decoding)
};

ContractSendMethodModel.prototype = Object.create(SendTransactionMethodModel.prototype);
ContractSendMethodModel.prototype.constructor = ContractSendMethodModel;
github ethereum / web3.js / packages / web3-eth-contract / src / models / SendMethodModel.js View on Github external
if (options.from) {
        from = this.utils.toChecksumAddress(formatters.inputAddressFormatter(options.from));
    }

    options.from = from || web3Package.contractOptions.from;
    options.gasPrice = gasPrice || web3Package.contractOptions.gasPrice;
    options.gas = options.gas || options.gasLimit || web3Package.contractOptions.gas;
    options.to = web3Package.contractOptions.address;

    // TODO replace with only gasLimit?
    delete options.gasLimit;

    return options;
};

SendMethodModel.prototype = Object.create(SendTransactionMethodModel.prototype);
SendMethodModel.prototype.constructor = SendMethodModel;

module.exports = SendMethodModel;
github ethereum / web3.js / packages / web3-eth-contract / src / models / EstimateGasOfContractMethodModel.js View on Github external
if (options.from) {
        from = this.utils.toChecksumAddress(formatters.inputAddressFormatter(options.from));
    }

    options.from = from || web3Package.contractOptions.from;
    options.gasPrice = gasPrice || web3Package.contractOptions.gasPrice;
    options.gas = options.gas || options.gasLimit || web3Package.contractOptions.gas;

    // TODO replace with only gasLimit?
    delete options.gasLimit;

    return options;
};

EstimateGasOfContractMethodModel.prototype = Object.create(EstimateGasMethodModel.prototype);
EstimateGasOfContractMethodModel.prototype.constructor = EstimateGasOfContractMethodModel;

module.exports = EstimateGasOfContractMethodModel;
github ethereum / web3.js / lib / module / AbstractWeb3Module.js View on Github external
this._currentProvider = this.providerResolver.resolve(provider, nodeNet);
        this._defaultAccount = options.defaultAccount ? toChecksumAddress(options.defaultAccount) : undefined;
        this._defaultBlock = options.defaultBlock || 'latest';
        this._transactionBlockTimeout = options.transactionBlockTimeout || 50;
        this._transactionConfirmationBlocks = options.transactionConfirmationBlocks || 0;
        this._transactionPollingTimeout = options.transactionPollingTimeout || 750;
        this._defaultGasPrice = options.defaultGasPrice;
        this._defaultGas = options.defaultGas;

        this.BatchRequest = () => {
            return new BatchRequest(this);
        };

        // TODO: Remove the MethodProxy after refactoring of the BatchRequest object
        if (methodFactory) {
            return new MethodProxy(this, methodFactory);
        }
    }
github ethereum / web3.js / packages / web3-eth-contract / src / models / ContractSendMethodModel.js View on Github external
but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Lesser General Public License for more details.

 You should have received a copy of the GNU Lesser General Public License
 along with web3.js.  If not, see .
 */
/**
 * @file ContractCallMethodModel.js
 * @author Samuel Furter 
 * @date 2018
 */

"use strict";

var SendTransactionMethodModel = require('web3-core-method').SendTransactionMethodModel;

function ContractSendMethodModel(abiItem, utils, formatters) {
    SendTransactionMethodModel.call(this, utils, formatters);
    this.contractMethodName = '';
    this.funcName = '';
    this.signature = '';
    this.requestOptions = null;
    this.parameters = null;
    this.abiItem = abiItem;
}

ContractSendMethodModel.prototype.beforeExecution = function (web3Package) {
    // extend SendTransactionMethodModel beforeExecution (encoding and creation of tx object)
};

ContractSendMethodModel.prototype.afterExecution = function (web3Package) {
github ethereum / web3.js / packages / web3-eth-contract / src / proxies / MethodsProxy.js View on Github external
executeMethod(abiItemModel, methodArguments, requestType) {
        let method;

        try {
            method = this.createMethod(abiItemModel, methodArguments, requestType);
        } catch (error) {
            const promiEvent = new PromiEvent();

            method = this.methodFactory.createMethodByRequestType(abiItemModel, this.contract, requestType);
            method.setArguments(methodArguments);

            if (isFunction(method.callback)) {
                method.callback(error, null);
            }

            promiEvent.reject(error);
            promiEvent.emit('error', error);

            return promiEvent;
        }

        return method.execute();
    }
github ethereum / web3.js / modules / ethereum / src / contract / proxies / MethodsProxy.js View on Github external
executeMethod(abiItemModel, methodArguments, requestType) {
        let method;

        try {
            method = this.createMethod(abiItemModel, methodArguments, requestType);
        } catch (error) {
            const promiEvent = new PromiEvent();
            promiEvent.reject(error);
            promiEvent.emit('error', error);

            return promiEvent;
        }

        return method.execute();
    }
github ethereum / web3.js / packages / web3-eth-contract / src / factories / MethodFactory.js View on Github external
createTransactionObserver(moduleInstance) {
        if (moduleInstance.currentProvider.supportsSubscriptions()) {
            return new SocketTransactionObserver(
                moduleInstance.currentProvider,
                this.getTimeout(moduleInstance),
                moduleInstance.transactionConfirmationBlocks,
                new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
                new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
            );
        }

        return new HttpTransactionObserver(
            moduleInstance.currentProvider,
            this.getTimeout(moduleInstance),
            moduleInstance.transactionConfirmationBlocks,
            new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
            new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
        );
    }
}
github ethereum / web3.js / modules / ethereum / src / contract / factories / MethodFactory.js View on Github external
createTransactionObserver(moduleInstance) {
        if (moduleInstance.currentProvider.supportsSubscriptions()) {
            return new SocketTransactionObserver(
                moduleInstance.currentProvider,
                this.getTimeout(moduleInstance),
                moduleInstance.transactionConfirmationBlocks,
                new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
                new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
            );
        }

        return new HttpTransactionObserver(
            moduleInstance.currentProvider,
            this.getTimeout(moduleInstance),
            moduleInstance.transactionConfirmationBlocks,
            new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
            new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
        );
    }
}
github ethereum / web3.js / packages / web3-eth-contract / src / factories / MethodFactory.js View on Github external
createTransactionObserver(moduleInstance) {
        if (moduleInstance.currentProvider.supportsSubscriptions()) {
            return new SocketTransactionObserver(
                moduleInstance.currentProvider,
                this.getTimeout(moduleInstance),
                moduleInstance.transactionConfirmationBlocks,
                new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
                new NewHeadsSubscription(this.utils, this.formatters, moduleInstance)
            );
        }

        return new HttpTransactionObserver(
            moduleInstance.currentProvider,
            this.getTimeout(moduleInstance),
            moduleInstance.transactionConfirmationBlocks,
            new GetTransactionReceiptMethod(this.utils, this.formatters, moduleInstance),
            new GetBlockByNumberMethod(this.utils, this.formatters, moduleInstance)
        );
    }
}