Socket
Socket
Sign inDemoInstall

web3-eth-contract

Package Overview
Dependencies
Maintainers
2
Versions
440
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

web3-eth-contract - npm Package Compare versions

Comparing version 1.0.0-beta.51 to 1.0.0-beta.52

114

dist/web3-eth-contract.cjs.js

@@ -10,15 +10,15 @@ 'use strict';

var web3EthAbi = require('web3-eth-abi');
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
var isArray = _interopDefault(require('lodash/isArray'));
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
var _get = _interopDefault(require('@babel/runtime/helpers/get'));
var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
var web3CoreMethod = require('web3-core-method');
var isFunction = _interopDefault(require('lodash/isFunction'));
var isUndefined = _interopDefault(require('lodash/isUndefined'));
var cloneDeep = _interopDefault(require('lodash/cloneDeep'));
var isArray = _interopDefault(require('lodash/isArray'));
var _get = _interopDefault(require('@babel/runtime/helpers/get'));
var web3CoreMethod = require('web3-core-method');
var web3CoreSubscriptions = require('web3-core-subscriptions');
var _classCallCheck = _interopDefault(require('@babel/runtime/helpers/classCallCheck'));
var _createClass = _interopDefault(require('@babel/runtime/helpers/createClass'));
var _possibleConstructorReturn = _interopDefault(require('@babel/runtime/helpers/possibleConstructorReturn'));
var _getPrototypeOf = _interopDefault(require('@babel/runtime/helpers/getPrototypeOf'));
var _assertThisInitialized = _interopDefault(require('@babel/runtime/helpers/assertThisInitialized'));
var _inherits = _interopDefault(require('@babel/runtime/helpers/inherits'));
var web3Core = require('web3-core');

@@ -41,2 +41,7 @@

}, {
key: "getMethods",
value: function getMethods() {
return this.abi.methods;
}
}, {
key: "getEvent",

@@ -127,12 +132,2 @@ value: function getEvent(name) {

}
}, {
key: "requestType",
get: function get() {
if (this.abiItem.type === 'function' || this.abiItem.type === 'constructor') {
if (this.abiItem.constant === true) {
return 'call';
}
return 'send';
}
}
}]);

@@ -233,5 +228,5 @@ return AbiItemModel;

value: function decode(abiItemModel, response) {
var argTopics = response.topics;
var argumentTopics = response.topics;
if (!abiItemModel.anonymous) {
argTopics = response.topics.slice(1);
argumentTopics = response.topics.slice(1);
}

@@ -241,3 +236,3 @@ if (response.data === '0x') {

}
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argTopics);
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argumentTopics);
response.event = abiItemModel.name;

@@ -479,3 +474,3 @@ response.signature = abiItemModel.signature;

if (_this.contract.abiModel.hasMethod(name)) {
var anonymousFunction = function anonymousFunction() {
var ContractMethod = function ContractMethod() {
var methodArguments = Array.prototype.slice.call(arguments);

@@ -490,6 +485,6 @@ if (name === 'contractConstructor') {

}
return anonymousFunction;
return ContractMethod;
}
abiItemModel.contractMethodParameters = [];
return anonymousFunction;
return ContractMethod;
}

@@ -509,25 +504,27 @@ if (isArray(abiItemModel)) {

abiItemModel.contractMethodParameters = methodArguments;
return anonymousFunction;
return ContractMethod;
};
var abiItemModel = _this.contract.abiModel.getMethod(name);
var requestType = abiItemModel.requestType;
if (isArray(abiItemModel)) {
requestType = abiItemModel[0].requestType;
}
anonymousFunction[requestType] = function () {
ContractMethod.call = function () {
return target.executeMethod(abiItemModel, arguments, 'call');
};
ContractMethod.send = function () {
if (abiItemModel.isOfType('constructor')) {
return target.executeMethod(abiItemModel, arguments, 'contract-deployment');
}
return target.executeMethod(abiItemModel, arguments, requestType);
return target.executeMethod(abiItemModel, arguments, 'send');
};
anonymousFunction[requestType].request = function () {
return target.createMethod(abiItemModel, arguments, requestType);
ContractMethod.call.request = function () {
return target.createMethod(abiItemModel, arguments, 'call');
};
anonymousFunction.estimateGas = function () {
ContractMethod.send.request = function () {
return target.createMethod(abiItemModel, arguments, 'send');
};
ContractMethod.estimateGas = function () {
return target.executeMethod(abiItemModel, arguments, 'estimate');
};
anonymousFunction.encodeABI = function () {
ContractMethod.encodeABI = function () {
return target.methodEncoder.encode(abiItemModel, target.contract.data);
};
return anonymousFunction;
return ContractMethod;
}

@@ -637,6 +634,6 @@ if (target[name]) {

_inherits(SendContractMethod, _EthSendTransactionMe);
function SendContractMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod, allEventsLogDecoder, abiModel) {
function SendContractMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) {
var _this;
_classCallCheck(this, SendContractMethod);
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod));
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod));
_this.allEventsLogDecoder = allEventsLogDecoder;

@@ -732,3 +729,3 @@ _this.abiModel = abiModel;

value: function afterExecution(response) {
if (!response) {
if (!response || response === '0x') {
return null;

@@ -740,3 +737,3 @@ }

}
return this.abiCoder.decodeParameter(outputs[0].type, response);
return this.abiCoder.decodeParameter(outputs[0], response);
}

@@ -750,5 +747,5 @@ }]);

_inherits(ContractDeployMethod, _EthSendTransactionMe);
function ContractDeployMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod) {
function ContractDeployMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod) {
_classCallCheck(this, ContractDeployMethod);
return _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod));
return _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod));
}

@@ -758,4 +755,6 @@ _createClass(ContractDeployMethod, [{

value: function beforeExecution(moduleInstance) {
_get(_getPrototypeOf(ContractDeployMethod.prototype), "beforeExecution", this).call(this, moduleInstance);
delete this.parameters[0].to;
if (this.rpcMethod !== 'eth_sendRawTransaction') {
_get(_getPrototypeOf(ContractDeployMethod.prototype), "beforeExecution", this).call(this, moduleInstance);
delete this.parameters[0].to;
}
}

@@ -767,2 +766,6 @@ }, {

clonedContract.address = response.contractAddress;
if (this.promiEvent.listenerCount('receipt') > 0) {
this.promiEvent.emit('receipt', response);
this.promiEvent.removeAllListeners('receipt');
}
return clonedContract;

@@ -886,4 +889,3 @@ }

value: function createSendContractMethod(contract) {
var transactionObserver = new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract));
return new SendContractMethod(this.utils, this.formatters, contract, transactionObserver, new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, contract, transactionObserver), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
return new SendContractMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
}

@@ -893,3 +895,3 @@ }, {

value: function createContractDeployMethod(contract) {
return new ContractDeployMethod(this.utils, this.formatters, contract, new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract)), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, contract));
return new ContractDeployMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract));
}

@@ -902,7 +904,6 @@ }, {

}, {
key: "getTransactionObserverTimeout",
value: function getTransactionObserverTimeout(contract) {
key: "getTimeout",
value: function getTimeout(contract) {
var timeout = contract.transactionBlockTimeout;
var providerName = contract.currentProvider.constructor.name;
if (providerName === 'HttpProvider' || providerName === 'CustomProvider') {
if (!contract.currentProvider.supportsSubscriptions()) {
timeout = contract.transactionPollingTimeout;

@@ -912,2 +913,7 @@ }

}
}, {
key: "createTransactionObserver",
value: function createTransactionObserver(contract) {
return new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract));
}
}]);

@@ -967,3 +973,3 @@ return MethodFactory;

value: function createEventLogSubscription(eventLogDecoder, contract, options, abiItemModel) {
return new EventLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters), eventLogDecoder, abiItemModel);
return new EventLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters, contract), eventLogDecoder, abiItemModel);
}

@@ -973,3 +979,3 @@ }, {

value: function createAllEventsLogSubscription(allEventsLogDecoder, contract, options) {
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters), allEventsLogDecoder, contract.abiModel);
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters, contract), allEventsLogDecoder, contract.abiModel);
}

@@ -1194,3 +1200,3 @@ }]);

exports.AbstractContract = AbstractContract;
exports.Contract = Contract;
exports.ContractModuleFactory = ContractModuleFactory;
exports.Contract = Contract;
import * as Utils from 'web3-utils';
import { formatters } from 'web3-core-helpers';
import { AbiCoder } from 'web3-eth-abi';
import isArray from 'lodash/isArray';
import { PromiEvent, EthSendTransactionMethod, CallMethod, GetPastLogsMethod, ChainIdMethod, GetTransactionCountMethod, EstimateGasMethod, TransactionObserver, GetTransactionReceiptMethod, GetBlockByNumberMethod } from 'web3-core-method';
import isFunction from 'lodash/isFunction';
import isUndefined from 'lodash/isUndefined';
import cloneDeep from 'lodash/cloneDeep';
import isArray from 'lodash/isArray';
import { PromiEvent, EthSendTransactionMethod, CallMethod, GetPastLogsMethod, EstimateGasMethod, ChainIdMethod, GetTransactionCountMethod, GetTransactionReceiptMethod, GetBlockByNumberMethod, SendRawTransactionMethod, TransactionObserver } from 'web3-core-method';
import { NewHeadsSubscription, LogSubscription } from 'web3-core-subscriptions';

@@ -22,2 +22,5 @@ import { AbstractWeb3Module } from 'web3-core';

}
getMethods() {
return this.abi.methods;
}
getEvent(name) {

@@ -58,10 +61,2 @@ if (this.hasEvent(name)) {

}
get requestType() {
if (this.abiItem.type === 'function' || this.abiItem.type === 'constructor') {
if (this.abiItem.constant === true) {
return 'call';
}
return 'send';
}
}
getInputLength() {

@@ -158,5 +153,5 @@ if (isArray(this.abiItem.inputs)) {

decode(abiItemModel, response) {
let argTopics = response.topics;
let argumentTopics = response.topics;
if (!abiItemModel.anonymous) {
argTopics = response.topics.slice(1);
argumentTopics = response.topics.slice(1);
}

@@ -166,3 +161,3 @@ if (response.data === '0x') {

}
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argTopics);
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argumentTopics);
response.event = abiItemModel.name;

@@ -270,5 +265,5 @@ response.signature = abiItemModel.signature;

class MethodOptionsMapper {
constructor(utils, formatters$$1) {
constructor(utils, formatters) {
this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
}

@@ -290,4 +285,4 @@ map(contract, options) {

class EventOptionsMapper {
constructor(formatters$$1, eventFilterEncoder) {
this.formatters = formatters$$1;
constructor(formatters, eventFilterEncoder) {
this.formatters = formatters;
this.eventFilterEncoder = eventFilterEncoder;

@@ -325,4 +320,4 @@ }

class AllEventsOptionsMapper {
constructor(formatters$$1, allEventsFilterEncoder) {
this.formatters = formatters$$1;
constructor(formatters, allEventsFilterEncoder) {
this.formatters = formatters;
this.allEventsFilterEncoder = allEventsFilterEncoder;

@@ -367,7 +362,3 @@ }

let abiItemModel = this.contract.abiModel.getMethod(name);
let requestType = abiItemModel.requestType;
if (isArray(abiItemModel)) {
requestType = abiItemModel[0].requestType;
}
function anonymousFunction() {
function ContractMethod() {
let methodArguments = [...arguments];

@@ -382,6 +373,6 @@ if (name === 'contractConstructor') {

}
return anonymousFunction;
return ContractMethod;
}
abiItemModel.contractMethodParameters = [];
return anonymousFunction;
return ContractMethod;
}

@@ -401,20 +392,26 @@ if (isArray(abiItemModel)) {

abiItemModel.contractMethodParameters = methodArguments;
return anonymousFunction;
return ContractMethod;
}
anonymousFunction[requestType] = function () {
ContractMethod.call = function () {
return target.executeMethod(abiItemModel, arguments, 'call');
};
ContractMethod.send = function () {
if (abiItemModel.isOfType('constructor')) {
return target.executeMethod(abiItemModel, arguments, 'contract-deployment');
}
return target.executeMethod(abiItemModel, arguments, requestType);
return target.executeMethod(abiItemModel, arguments, 'send');
};
anonymousFunction[requestType].request = function () {
return target.createMethod(abiItemModel, arguments, requestType);
ContractMethod.call.request = function () {
return target.createMethod(abiItemModel, arguments, 'call');
};
anonymousFunction.estimateGas = function () {
ContractMethod.send.request = function () {
return target.createMethod(abiItemModel, arguments, 'send');
};
ContractMethod.estimateGas = function () {
return target.executeMethod(abiItemModel, arguments, 'estimate');
};
anonymousFunction.encodeABI = function () {
ContractMethod.encodeABI = function () {
return target.methodEncoder.encode(abiItemModel, target.contract.data);
};
return anonymousFunction;
return ContractMethod;
}

@@ -505,4 +502,4 @@ if (target[name]) {

class SendContractMethod extends EthSendTransactionMethod {
constructor(utils, formatters$$1, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod, allEventsLogDecoder, abiModel) {
super(utils, formatters$$1, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod);
constructor(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) {
super(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod);
this.allEventsLogDecoder = allEventsLogDecoder;

@@ -567,4 +564,4 @@ this.abiModel = abiModel;

class CallContractMethod extends CallMethod {
constructor(utils, formatters$$1, moduleInstance, abiCoder, abiItemModel) {
super(utils, formatters$$1, moduleInstance);
constructor(utils, formatters, moduleInstance, abiCoder, abiItemModel) {
super(utils, formatters, moduleInstance);
this.abiCoder = abiCoder;

@@ -574,3 +571,3 @@ this.abiItemModel = abiItemModel;

afterExecution(response) {
if (!response) {
if (!response || response === '0x') {
return null;

@@ -582,3 +579,3 @@ }

}
return this.abiCoder.decodeParameter(outputs[0].type, response);
return this.abiCoder.decodeParameter(outputs[0], response);
}

@@ -588,8 +585,10 @@ }

class ContractDeployMethod extends EthSendTransactionMethod {
constructor(utils, formatters$$1, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod) {
super(utils, formatters$$1, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod);
constructor(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod) {
super(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod);
}
beforeExecution(moduleInstance) {
super.beforeExecution(moduleInstance);
delete this.parameters[0].to;
if (this.rpcMethod !== 'eth_sendRawTransaction') {
super.beforeExecution(moduleInstance);
delete this.parameters[0].to;
}
}

@@ -599,2 +598,6 @@ afterExecution(response) {

clonedContract.address = response.contractAddress;
if (this.promiEvent.listenerCount('receipt') > 0) {
this.promiEvent.emit('receipt', response);
this.promiEvent.removeAllListeners('receipt');
}
return clonedContract;

@@ -605,4 +608,4 @@ }

class PastEventLogsMethod extends GetPastLogsMethod {
constructor(utils, formatters$$1, moduleInstance, eventLogDecoder, abiItemModel, eventOptionsMapper) {
super(utils, formatters$$1, moduleInstance);
constructor(utils, formatters, moduleInstance, eventLogDecoder, abiItemModel, eventOptionsMapper) {
super(utils, formatters, moduleInstance);
this.abiItemModel = abiItemModel;

@@ -625,4 +628,4 @@ this.eventLogDecoder = eventLogDecoder;

class AllPastEventLogsMethod extends GetPastLogsMethod {
constructor(utils, formatters$$1, moduleInstance, allEventsLogDecoder, abiModel, allEventsOptionsMapper) {
super(utils, formatters$$1, moduleInstance);
constructor(utils, formatters, moduleInstance, allEventsLogDecoder, abiModel, allEventsOptionsMapper) {
super(utils, formatters, moduleInstance);
this.abiModel = abiModel;

@@ -645,5 +648,5 @@ this.allEventsLogDecoder = allEventsLogDecoder;

class MethodFactory {
constructor(utils, formatters$$1, contractModuleFactory, abiCoder) {
constructor(utils, formatters, contractModuleFactory, abiCoder) {
this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
this.contractModuleFactory = contractModuleFactory;

@@ -683,7 +686,6 @@ this.abiCoder = abiCoder;

createSendContractMethod(contract) {
const transactionObserver = new TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new GetTransactionReceiptMethod(this.utils, this.formatters, contract), new GetBlockByNumberMethod(this.utils, this.formatters, contract), new NewHeadsSubscription(this.utils, this.formatters, contract));
return new SendContractMethod(this.utils, this.formatters, contract, transactionObserver, new ChainIdMethod(this.utils, this.formatters, contract), new GetTransactionCountMethod(this.utils, this.formatters, contract), new SendRawTransactionMethod(this.utils, this.formatters, contract, transactionObserver), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
return new SendContractMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new ChainIdMethod(this.utils, this.formatters, contract), new GetTransactionCountMethod(this.utils, this.formatters, contract), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
}
createContractDeployMethod(contract) {
return new ContractDeployMethod(this.utils, this.formatters, contract, new TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new GetTransactionReceiptMethod(this.utils, this.formatters, contract), new GetBlockByNumberMethod(this.utils, this.formatters, contract), new NewHeadsSubscription(this.utils, this.formatters, contract)), new ChainIdMethod(this.utils, this.formatters, contract), new GetTransactionCountMethod(this.utils, this.formatters, contract), new SendRawTransactionMethod(this.utils, this.formatters, contract));
return new ContractDeployMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new ChainIdMethod(this.utils, this.formatters, contract), new GetTransactionCountMethod(this.utils, this.formatters, contract));
}

@@ -693,6 +695,5 @@ createEstimateGasMethod(contract) {

}
getTransactionObserverTimeout(contract) {
getTimeout(contract) {
let timeout = contract.transactionBlockTimeout;
const providerName = contract.currentProvider.constructor.name;
if (providerName === 'HttpProvider' || providerName === 'CustomProvider') {
if (!contract.currentProvider.supportsSubscriptions()) {
timeout = contract.transactionPollingTimeout;

@@ -702,7 +703,10 @@ }

}
createTransactionObserver(contract) {
return new TransactionObserver(contract.currentProvider, this.getTimeout(contract), contract.transactionConfirmationBlocks, new GetTransactionReceiptMethod(this.utils, this.formatters, contract), new GetBlockByNumberMethod(this.utils, this.formatters, contract), new NewHeadsSubscription(this.utils, this.formatters, contract));
}
}
class EventLogSubscription extends LogSubscription {
constructor(options, utils, formatters$$1, contract, getPastLogsMethod, eventLogDecoder, abiItemModel) {
super(options, utils, formatters$$1, contract, getPastLogsMethod);
constructor(options, utils, formatters, contract, getPastLogsMethod, eventLogDecoder, abiItemModel) {
super(options, utils, formatters, contract, getPastLogsMethod);
this.eventLogDecoder = eventLogDecoder;

@@ -717,4 +721,4 @@ this.abiItemModel = abiItemModel;

class AllEventsLogSubscription extends LogSubscription {
constructor(options, utils, formatters$$1, contract, getPastLogsMethod, allEventsLogDecoder, abiModel) {
super(options, utils, formatters$$1, contract, getPastLogsMethod);
constructor(options, utils, formatters, contract, getPastLogsMethod, allEventsLogDecoder, abiModel) {
super(options, utils, formatters, contract, getPastLogsMethod);
this.allEventsLogDecoder = allEventsLogDecoder;

@@ -729,11 +733,11 @@ this.abiModel = abiModel;

class EventSubscriptionFactory {
constructor(utils, formatters$$1) {
constructor(utils, formatters) {
this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
}
createEventLogSubscription(eventLogDecoder, contract, options, abiItemModel) {
return new EventLogSubscription(options, this.utils, this.formatters, contract, new GetPastLogsMethod(this.utils, this.formatters), eventLogDecoder, abiItemModel);
return new EventLogSubscription(options, this.utils, this.formatters, contract, new GetPastLogsMethod(this.utils, this.formatters, contract), eventLogDecoder, abiItemModel);
}
createAllEventsLogSubscription(allEventsLogDecoder, contract, options) {
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new GetPastLogsMethod(this.utils, this.formatters), allEventsLogDecoder, contract.abiModel);
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new GetPastLogsMethod(this.utils, this.formatters, contract), allEventsLogDecoder, contract.abiModel);
}

@@ -743,3 +747,3 @@ }

class AbstractContract extends AbstractWeb3Module {
constructor(provider, contractModuleFactory, accounts, abiCoder, utils, formatters$$1, abi = [], address = '', options = {}) {
constructor(provider, contractModuleFactory, accounts, abiCoder, utils, formatters, abi = [], address = '', options = {}) {
super(provider, options, null, null);

@@ -749,3 +753,3 @@ this.contractModuleFactory = contractModuleFactory;

this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
this.abiMapper = this.contractModuleFactory.createAbiMapper();

@@ -830,5 +834,5 @@ this.options = options;

class ContractModuleFactory {
constructor(utils, formatters$$1, abiCoder) {
constructor(utils, formatters, abiCoder) {
this.utils = utils;
this.formatters = formatters$$1;
this.formatters = formatters;
this.abiCoder = abiCoder;

@@ -893,2 +897,2 @@ }

export { AbstractContract, ContractModuleFactory, Contract };
export { AbstractContract, Contract, ContractModuleFactory };
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('web3-utils'), require('web3-core-helpers'), require('web3-eth-abi'), require('lodash/isFunction'), require('lodash/isUndefined'), require('lodash/cloneDeep'), require('lodash/isArray'), require('@babel/runtime/helpers/get'), require('web3-core-method'), require('web3-core-subscriptions'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/assertThisInitialized'), require('@babel/runtime/helpers/inherits'), require('web3-core')) :
typeof define === 'function' && define.amd ? define(['exports', 'web3-utils', 'web3-core-helpers', 'web3-eth-abi', 'lodash/isFunction', 'lodash/isUndefined', 'lodash/cloneDeep', 'lodash/isArray', '@babel/runtime/helpers/get', 'web3-core-method', 'web3-core-subscriptions', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/assertThisInitialized', '@babel/runtime/helpers/inherits', 'web3-core'], factory) :
(factory((global.Web3EthContract = {}),global.Utils,global.web3CoreHelpers,global.web3EthAbi,global.isFunction,global.isUndefined,global.cloneDeep,global.isArray,global._get,global.web3CoreMethod,global.web3CoreSubscriptions,global._classCallCheck,global._createClass,global._possibleConstructorReturn,global._getPrototypeOf,global._assertThisInitialized,global._inherits,global.web3Core));
}(this, (function (exports,Utils,web3CoreHelpers,web3EthAbi,isFunction,isUndefined,cloneDeep,isArray,_get,web3CoreMethod,web3CoreSubscriptions,_classCallCheck,_createClass,_possibleConstructorReturn,_getPrototypeOf,_assertThisInitialized,_inherits,web3Core) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('web3-utils'), require('web3-core-helpers'), require('web3-eth-abi'), require('@babel/runtime/helpers/classCallCheck'), require('@babel/runtime/helpers/createClass'), require('lodash/isArray'), require('@babel/runtime/helpers/possibleConstructorReturn'), require('@babel/runtime/helpers/getPrototypeOf'), require('@babel/runtime/helpers/get'), require('@babel/runtime/helpers/inherits'), require('web3-core-method'), require('lodash/isFunction'), require('lodash/isUndefined'), require('lodash/cloneDeep'), require('web3-core-subscriptions'), require('@babel/runtime/helpers/assertThisInitialized'), require('web3-core')) :
typeof define === 'function' && define.amd ? define(['exports', 'web3-utils', 'web3-core-helpers', 'web3-eth-abi', '@babel/runtime/helpers/classCallCheck', '@babel/runtime/helpers/createClass', 'lodash/isArray', '@babel/runtime/helpers/possibleConstructorReturn', '@babel/runtime/helpers/getPrototypeOf', '@babel/runtime/helpers/get', '@babel/runtime/helpers/inherits', 'web3-core-method', 'lodash/isFunction', 'lodash/isUndefined', 'lodash/cloneDeep', 'web3-core-subscriptions', '@babel/runtime/helpers/assertThisInitialized', 'web3-core'], factory) :
(global = global || self, factory(global.Web3EthContract = {}, global.Utils, global.web3CoreHelpers, global.web3EthAbi, global._classCallCheck, global._createClass, global.isArray, global._possibleConstructorReturn, global._getPrototypeOf, global._get, global._inherits, global.web3CoreMethod, global.isFunction, global.isUndefined, global.cloneDeep, global.web3CoreSubscriptions, global._assertThisInitialized, global.web3Core));
}(this, function (exports, Utils, web3CoreHelpers, web3EthAbi, _classCallCheck, _createClass, isArray, _possibleConstructorReturn, _getPrototypeOf, _get, _inherits, web3CoreMethod, isFunction, isUndefined, cloneDeep, web3CoreSubscriptions, _assertThisInitialized, web3Core) { 'use strict';
isFunction = isFunction && isFunction.hasOwnProperty('default') ? isFunction['default'] : isFunction;
isUndefined = isUndefined && isUndefined.hasOwnProperty('default') ? isUndefined['default'] : isUndefined;
cloneDeep = cloneDeep && cloneDeep.hasOwnProperty('default') ? cloneDeep['default'] : cloneDeep;
isArray = isArray && isArray.hasOwnProperty('default') ? isArray['default'] : isArray;
_get = _get && _get.hasOwnProperty('default') ? _get['default'] : _get;
_classCallCheck = _classCallCheck && _classCallCheck.hasOwnProperty('default') ? _classCallCheck['default'] : _classCallCheck;
_createClass = _createClass && _createClass.hasOwnProperty('default') ? _createClass['default'] : _createClass;
isArray = isArray && isArray.hasOwnProperty('default') ? isArray['default'] : isArray;
_possibleConstructorReturn = _possibleConstructorReturn && _possibleConstructorReturn.hasOwnProperty('default') ? _possibleConstructorReturn['default'] : _possibleConstructorReturn;
_getPrototypeOf = _getPrototypeOf && _getPrototypeOf.hasOwnProperty('default') ? _getPrototypeOf['default'] : _getPrototypeOf;
_get = _get && _get.hasOwnProperty('default') ? _get['default'] : _get;
_inherits = _inherits && _inherits.hasOwnProperty('default') ? _inherits['default'] : _inherits;
isFunction = isFunction && isFunction.hasOwnProperty('default') ? isFunction['default'] : isFunction;
isUndefined = isUndefined && isUndefined.hasOwnProperty('default') ? isUndefined['default'] : isUndefined;
cloneDeep = cloneDeep && cloneDeep.hasOwnProperty('default') ? cloneDeep['default'] : cloneDeep;
_assertThisInitialized = _assertThisInitialized && _assertThisInitialized.hasOwnProperty('default') ? _assertThisInitialized['default'] : _assertThisInitialized;
_inherits = _inherits && _inherits.hasOwnProperty('default') ? _inherits['default'] : _inherits;

@@ -34,2 +34,7 @@ var AbiModel =

}, {
key: "getMethods",
value: function getMethods() {
return this.abi.methods;
}
}, {
key: "getEvent",

@@ -120,12 +125,2 @@ value: function getEvent(name) {

}
}, {
key: "requestType",
get: function get() {
if (this.abiItem.type === 'function' || this.abiItem.type === 'constructor') {
if (this.abiItem.constant === true) {
return 'call';
}
return 'send';
}
}
}]);

@@ -226,5 +221,5 @@ return AbiItemModel;

value: function decode(abiItemModel, response) {
var argTopics = response.topics;
var argumentTopics = response.topics;
if (!abiItemModel.anonymous) {
argTopics = response.topics.slice(1);
argumentTopics = response.topics.slice(1);
}

@@ -234,3 +229,3 @@ if (response.data === '0x') {

}
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argTopics);
response.returnValues = this.abiCoder.decodeLog(abiItemModel.getInputs(), response.data, argumentTopics);
response.event = abiItemModel.name;

@@ -472,3 +467,3 @@ response.signature = abiItemModel.signature;

if (_this.contract.abiModel.hasMethod(name)) {
var anonymousFunction = function anonymousFunction() {
var ContractMethod = function ContractMethod() {
var methodArguments = Array.prototype.slice.call(arguments);

@@ -483,6 +478,6 @@ if (name === 'contractConstructor') {

}
return anonymousFunction;
return ContractMethod;
}
abiItemModel.contractMethodParameters = [];
return anonymousFunction;
return ContractMethod;
}

@@ -502,25 +497,27 @@ if (isArray(abiItemModel)) {

abiItemModel.contractMethodParameters = methodArguments;
return anonymousFunction;
return ContractMethod;
};
var abiItemModel = _this.contract.abiModel.getMethod(name);
var requestType = abiItemModel.requestType;
if (isArray(abiItemModel)) {
requestType = abiItemModel[0].requestType;
}
anonymousFunction[requestType] = function () {
ContractMethod.call = function () {
return target.executeMethod(abiItemModel, arguments, 'call');
};
ContractMethod.send = function () {
if (abiItemModel.isOfType('constructor')) {
return target.executeMethod(abiItemModel, arguments, 'contract-deployment');
}
return target.executeMethod(abiItemModel, arguments, requestType);
return target.executeMethod(abiItemModel, arguments, 'send');
};
anonymousFunction[requestType].request = function () {
return target.createMethod(abiItemModel, arguments, requestType);
ContractMethod.call.request = function () {
return target.createMethod(abiItemModel, arguments, 'call');
};
anonymousFunction.estimateGas = function () {
ContractMethod.send.request = function () {
return target.createMethod(abiItemModel, arguments, 'send');
};
ContractMethod.estimateGas = function () {
return target.executeMethod(abiItemModel, arguments, 'estimate');
};
anonymousFunction.encodeABI = function () {
ContractMethod.encodeABI = function () {
return target.methodEncoder.encode(abiItemModel, target.contract.data);
};
return anonymousFunction;
return ContractMethod;
}

@@ -630,6 +627,6 @@ if (target[name]) {

_inherits(SendContractMethod, _EthSendTransactionMe);
function SendContractMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod, allEventsLogDecoder, abiModel) {
function SendContractMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) {
var _this;
_classCallCheck(this, SendContractMethod);
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod));
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod));
_this.allEventsLogDecoder = allEventsLogDecoder;

@@ -725,3 +722,3 @@ _this.abiModel = abiModel;

value: function afterExecution(response) {
if (!response) {
if (!response || response === '0x') {
return null;

@@ -733,3 +730,3 @@ }

}
return this.abiCoder.decodeParameter(outputs[0].type, response);
return this.abiCoder.decodeParameter(outputs[0], response);
}

@@ -743,5 +740,5 @@ }]);

_inherits(ContractDeployMethod, _EthSendTransactionMe);
function ContractDeployMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod) {
function ContractDeployMethod(utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod) {
_classCallCheck(this, ContractDeployMethod);
return _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod, sendRawTransactionMethod));
return _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, moduleInstance, transactionObserver, chainIdMethod, getTransactionCountMethod));
}

@@ -751,4 +748,6 @@ _createClass(ContractDeployMethod, [{

value: function beforeExecution(moduleInstance) {
_get(_getPrototypeOf(ContractDeployMethod.prototype), "beforeExecution", this).call(this, moduleInstance);
delete this.parameters[0].to;
if (this.rpcMethod !== 'eth_sendRawTransaction') {
_get(_getPrototypeOf(ContractDeployMethod.prototype), "beforeExecution", this).call(this, moduleInstance);
delete this.parameters[0].to;
}
}

@@ -760,2 +759,6 @@ }, {

clonedContract.address = response.contractAddress;
if (this.promiEvent.listenerCount('receipt') > 0) {
this.promiEvent.emit('receipt', response);
this.promiEvent.removeAllListeners('receipt');
}
return clonedContract;

@@ -879,4 +882,3 @@ }

value: function createSendContractMethod(contract) {
var transactionObserver = new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract));
return new SendContractMethod(this.utils, this.formatters, contract, transactionObserver, new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, contract, transactionObserver), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
return new SendContractMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), this.contractModuleFactory.createAllEventsLogDecoder(), contract.abiModel);
}

@@ -886,3 +888,3 @@ }, {

value: function createContractDeployMethod(contract) {
return new ContractDeployMethod(this.utils, this.formatters, contract, new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTransactionObserverTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract)), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract), new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, contract));
return new ContractDeployMethod(this.utils, this.formatters, contract, this.createTransactionObserver(contract), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters, contract));
}

@@ -895,7 +897,6 @@ }, {

}, {
key: "getTransactionObserverTimeout",
value: function getTransactionObserverTimeout(contract) {
key: "getTimeout",
value: function getTimeout(contract) {
var timeout = contract.transactionBlockTimeout;
var providerName = contract.currentProvider.constructor.name;
if (providerName === 'HttpProvider' || providerName === 'CustomProvider') {
if (!contract.currentProvider.supportsSubscriptions()) {
timeout = contract.transactionPollingTimeout;

@@ -905,2 +906,7 @@ }

}
}, {
key: "createTransactionObserver",
value: function createTransactionObserver(contract) {
return new web3CoreMethod.TransactionObserver(contract.currentProvider, this.getTimeout(contract), contract.transactionConfirmationBlocks, new web3CoreMethod.GetTransactionReceiptMethod(this.utils, this.formatters, contract), new web3CoreMethod.GetBlockByNumberMethod(this.utils, this.formatters, contract), new web3CoreSubscriptions.NewHeadsSubscription(this.utils, this.formatters, contract));
}
}]);

@@ -960,3 +966,3 @@ return MethodFactory;

value: function createEventLogSubscription(eventLogDecoder, contract, options, abiItemModel) {
return new EventLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters), eventLogDecoder, abiItemModel);
return new EventLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters, contract), eventLogDecoder, abiItemModel);
}

@@ -966,3 +972,3 @@ }, {

value: function createAllEventsLogSubscription(allEventsLogDecoder, contract, options) {
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters), allEventsLogDecoder, contract.abiModel);
return new AllEventsLogSubscription(options, this.utils, this.formatters, contract, new web3CoreMethod.GetPastLogsMethod(this.utils, this.formatters, contract), allEventsLogDecoder, contract.abiModel);
}

@@ -1187,7 +1193,7 @@ }]);

exports.AbstractContract = AbstractContract;
exports.Contract = Contract;
exports.ContractModuleFactory = ContractModuleFactory;
exports.Contract = Contract;
Object.defineProperty(exports, '__esModule', { value: true });
})));
}));
{
"name": "web3-eth-contract",
"namespace": "ethereum",
"version": "1.0.0-beta.51",
"version": "1.0.0-beta.52",
"description": "Web3 module to interact with Ethereum smart contracts.",

@@ -11,3 +11,3 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.0/packages/web3-eth-contract",

"browser": "dist/web3-eth-contract.umd.js",
"types": "types",
"types": "types/index.d.ts",
"scripts": {

@@ -23,10 +23,10 @@ "build": "rollup -c",

"lodash": "^4.17.11",
"web3-core": "1.0.0-beta.51",
"web3-core-helpers": "1.0.0-beta.51",
"web3-core-method": "1.0.0-beta.51",
"web3-core-subscriptions": "1.0.0-beta.51",
"web3-eth-abi": "1.0.0-beta.51",
"web3-eth-accounts": "1.0.0-beta.51",
"web3-providers": "1.0.0-beta.51",
"web3-utils": "1.0.0-beta.51"
"web3-core": "1.0.0-beta.52",
"web3-core-helpers": "1.0.0-beta.52",
"web3-core-method": "1.0.0-beta.52",
"web3-core-subscriptions": "1.0.0-beta.52",
"web3-eth-abi": "1.0.0-beta.52",
"web3-eth-accounts": "1.0.0-beta.52",
"web3-providers": "1.0.0-beta.52",
"web3-utils": "1.0.0-beta.52"
},

@@ -41,3 +41,3 @@ "devDependencies": {

],
"gitHead": "67468b3f923d85839fc06ff4eedbe553ba60c185"
"gitHead": "1c89f503c90180598910d29892f6ebf92455cfe1"
}

@@ -22,3 +22,3 @@ /*

import {provider} from 'web3-providers';
import {AbiItem} from 'web3-utils';
import {AbiInput, AbiOutput, AbiItem} from 'web3-utils';
import {PromiEvent} from 'web3-core';

@@ -29,3 +29,3 @@

provider: provider,
jsonInterface: AbiItem[] | AbiItem,
abi: AbiItem[],
address?: string,

@@ -35,2 +35,5 @@ options?: ContractOptions

address: string;
jsonInterface: AbiModel;
options: Options;

@@ -55,11 +58,8 @@

export class ContractModuleFactory { } // TODO: Define methods
export class ContractModuleFactory {
} // TODO: Define methods
export interface Options {
address: string;
jsonInterface: AbiItem[];
data: string;
from: string;
gasPrice: string;
gas: number;
}

@@ -132,1 +132,34 @@

}
export interface AbiModel {
getMethod(name: string): AbiItemModel | false;
getMethods(): AbiItemModel[];
hasMethod(name: string): boolean;
getEvent(name: string): AbiItemModel | false;
getEvents(): AbiItemModel[];
getEventBySignature(signature: string): AbiItemModel;
hasEvent(name: string): boolean;
}
export interface AbiItemModel {
signature: string;
name: string;
payable: boolean;
anonymous: boolean;
getInputLength(): number;
getInputs(): AbiInput[];
getIndexedInputs(): AbiInput[];
getOutputs(): AbiOutput[];
isOfType(): boolean;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc