web3-eth-contract
Advanced tools
Comparing version 1.0.0-beta.46 to 1.0.0-beta.47
@@ -161,4 +161,7 @@ 'use strict'; | ||
value: function encode(abiItemModel, deployData) { | ||
var encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters).replace('0x', ''); | ||
if (abiItemModel.signature === 'constructor') { | ||
var encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters); | ||
if (encodedParameters.startsWith('0x')) { | ||
encodedParameters = encodedParameters.slice(2); | ||
} | ||
if (abiItemModel.isOfType('constructor')) { | ||
if (!deployData) { | ||
@@ -241,3 +244,3 @@ throw new Error('The contract has no contract data option set. This is necessary to append the constructor parameters.'); | ||
var argTopics = response.topics; | ||
if (abiItemModel.anonymous) { | ||
if (!abiItemModel.anonymous) { | ||
argTopics = response.topics.slice(1); | ||
@@ -273,3 +276,12 @@ } | ||
value: function decode(abiModel, response) { | ||
return _get(_getPrototypeOf(AllEventsLogDecoder.prototype), "decode", this).call(this, abiModel.getEventBySignature(response.topics[0]), response); | ||
var abiItemModel = abiModel.getEventBySignature(response.topics[0]); | ||
if (abiItemModel) { | ||
return _get(_getPrototypeOf(AllEventsLogDecoder.prototype), "decode", this).call(this, abiItemModel, response); | ||
} | ||
return { | ||
raw: { | ||
data: response.data, | ||
topics: response.topics | ||
} | ||
}; | ||
} | ||
@@ -287,2 +299,3 @@ }]); | ||
this.contractModuleFactory = contractModuleFactory; | ||
this.hasConstructor = false; | ||
} | ||
@@ -332,4 +345,13 @@ _createClass(AbiMapper, [{ | ||
mappedAbiItems.methods['contractConstructor'] = _this.contractModuleFactory.createAbiItemModel(abiItem); | ||
_this.hasConstructor = true; | ||
} | ||
}); | ||
if (!this.hasConstructor) { | ||
mappedAbiItems.methods['contractConstructor'] = this.contractModuleFactory.createAbiItemModel({ | ||
inputs: [], | ||
payable: false, | ||
constant: false, | ||
type: 'constructor' | ||
}); | ||
} | ||
return this.contractModuleFactory.createAbiModel(mappedAbiItems); | ||
@@ -451,7 +473,6 @@ } | ||
function () { | ||
function MethodsProxy(contract, abiModel, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper, PromiEvent) { | ||
function MethodsProxy(contract, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper) { | ||
var _this = this; | ||
_classCallCheck(this, MethodsProxy); | ||
this.contract = contract; | ||
this.abiModel = abiModel; | ||
this.methodFactory = methodFactory; | ||
@@ -461,15 +482,18 @@ this.methodEncoder = methodEncoder; | ||
this.methodOptionsMapper = methodOptionsMapper; | ||
this.PromiEvent = PromiEvent; | ||
return new Proxy(this, { | ||
get: function get(target, name) { | ||
if (_this.abiModel.hasMethod(name)) { | ||
if (_this.contract.abiModel.hasMethod(name)) { | ||
var anonymousFunction = function anonymousFunction() { | ||
var methodArguments = Array.prototype.slice.call(arguments); | ||
if (!isArray(abiItemModel) && abiItemModel.isOfType('constructor')) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
if (name === 'contractConstructor') { | ||
if (methodArguments[0]) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
return anonymousFunction; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
abiItemModel.contractMethodParameters = []; | ||
return anonymousFunction; | ||
@@ -496,3 +520,3 @@ } | ||
}; | ||
var abiItemModel = _this.abiModel.getMethod(name); | ||
var abiItemModel = _this.contract.abiModel.getMethod(name); | ||
var requestType = abiItemModel.requestType; | ||
@@ -532,3 +556,3 @@ if (isArray(abiItemModel)) { | ||
} catch (error) { | ||
var promiEvent = new this.PromiEvent(); | ||
var promiEvent = new web3CorePromievent.PromiEvent(); | ||
method = this.methodFactory.createMethodByRequestType(abiItemModel, this.contract, requestType); | ||
@@ -546,3 +570,3 @@ method.arguments = methodArguments; | ||
} | ||
return method.execute(this.contract, new this.PromiEvent()); | ||
return method.execute(this.contract, new web3CorePromievent.PromiEvent()); | ||
} | ||
@@ -569,3 +593,3 @@ }, { | ||
function () { | ||
function EventSubscriptionsProxy(contract, abiModel, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper, PromiEvent) { | ||
function EventSubscriptionsProxy(contract, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper) { | ||
var _this = this; | ||
@@ -575,3 +599,2 @@ _classCallCheck(this, EventSubscriptionsProxy); | ||
this.eventSubscriptionFactory = eventSubscriptionFactory; | ||
this.abiModel = abiModel; | ||
this.eventOptionsMapper = eventOptionsMapper; | ||
@@ -581,8 +604,7 @@ this.eventLogDecoder = eventLogDecoder; | ||
this.allEventsOptionsMapper = allEventsOptionsMapper; | ||
this.PromiEvent = PromiEvent; | ||
return new Proxy(this, { | ||
get: function get(target, name) { | ||
if (_this.abiModel.hasEvent(name)) { | ||
if (_this.contract.abiModel.hasEvent(name)) { | ||
return function (options, callback) { | ||
return target.subscribe(target.abiModel.getEvent(name), cloneDeep(options), callback); | ||
return target.subscribe(target.contract.abiModel.getEvent(name), cloneDeep(options), callback); | ||
}; | ||
@@ -615,3 +637,3 @@ } | ||
} | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.abiModel, this.contract, options)).subscribe(callback); | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.contract.abiModel, this.contract, options)).subscribe(callback); | ||
} | ||
@@ -634,6 +656,6 @@ }, { | ||
_inherits(SendContractMethod, _SendTransactionMetho); | ||
function SendContractMethod(utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner, allEventsLogDecoder, abiModel) { | ||
function SendContractMethod(utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) { | ||
var _this; | ||
_classCallCheck(this, SendContractMethod); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod)); | ||
_this.allEventsLogDecoder = allEventsLogDecoder; | ||
@@ -696,3 +718,3 @@ _this.abiModel = abiModel; | ||
value: function isToSet(abiItemModel, method) { | ||
if (abiItemModel.signature === 'constructor') { | ||
if (abiItemModel.isOfType('constructor')) { | ||
return true; | ||
@@ -710,3 +732,3 @@ } | ||
value: function isValueValid(abiItemModel, method) { | ||
return !(!abiItemModel.payable && method.parameters[0].value && method.parameters[0].value > 0); | ||
return !abiItemModel.payable && !method.parameters[0].value > 0 || abiItemModel.payable && method.parameters[0].value > 0; | ||
} | ||
@@ -734,10 +756,8 @@ }]); | ||
} | ||
if (response.length >= 2) { | ||
response = response.slice(2); | ||
var outputs = this.abiItemModel.getOutputs(); | ||
response = this.abiCoder.decodeParameters(outputs, response); | ||
if (outputs.length === 1) { | ||
return response[0]; | ||
} | ||
var result = this.abiCoder.decodeParameters(this.abiItemModel.getOutputs(), response); | ||
if (Object.keys(result).length === 1) { | ||
return result[0]; | ||
} | ||
return result; | ||
return response; | ||
} | ||
@@ -751,6 +771,6 @@ }]); | ||
_inherits(ContractDeployMethod, _SendTransactionMetho); | ||
function ContractDeployMethod(utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner, contract) { | ||
function ContractDeployMethod(utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, contract) { | ||
var _this; | ||
_classCallCheck(this, ContractDeployMethod); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod)); | ||
_this.contract = contract; | ||
@@ -769,3 +789,3 @@ return _this; | ||
var clonedContract = this.contract.clone(); | ||
clonedContract.options.address = response.contractAddress; | ||
clonedContract.address = response.contractAddress; | ||
return clonedContract; | ||
@@ -841,5 +861,4 @@ } | ||
function () { | ||
function MethodFactory(accounts, utils, formatters, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
function MethodFactory(utils, formatters, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
_classCallCheck(this, MethodFactory); | ||
this.accounts = accounts; | ||
this.utils = utils; | ||
@@ -892,3 +911,4 @@ this.formatters = formatters; | ||
value: function createSendContractMethod(abiItem, abiModel) { | ||
return new SendContractMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
var transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new SendContractMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
} | ||
@@ -898,3 +918,4 @@ }, { | ||
value: function createContractDeployMethod(contract) { | ||
return new ContractDeployMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), contract); | ||
var transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new ContractDeployMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters), contract); | ||
} | ||
@@ -974,6 +995,6 @@ }, { | ||
_inherits(AbstractContract, _AbstractWeb3Module); | ||
function AbstractContract(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, PromiEvent, abiCoder, utils, formatters) { | ||
function AbstractContract(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, accounts, abiCoder, utils, formatters) { | ||
var _this; | ||
var abi = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : web3Core.AbstractWeb3Module.throwIfMissing('abi'); | ||
var address = arguments.length > 9 ? arguments[9] : undefined; | ||
var abi = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : []; | ||
var address = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : ''; | ||
var options = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : {}; | ||
@@ -988,11 +1009,11 @@ _classCallCheck(this, AbstractContract); | ||
_this.options = options; | ||
_this.PromiEvent = PromiEvent; | ||
_this.accounts = accounts; | ||
_this.methodFactory = _this.contractModuleFactory.createMethodFactory(); | ||
_this.abiModel = _this.abiMapper.map(abi); | ||
_this.options = options; | ||
_this.transactionSigner = options.transactionSigner; | ||
_this.methods = _this.contractModuleFactory.createMethodsProxy(_assertThisInitialized(_assertThisInitialized(_this))); | ||
_this.events = _this.contractModuleFactory.createEventSubscriptionsProxy(_assertThisInitialized(_assertThisInitialized(_this))); | ||
if (address) { | ||
_this.address = address; | ||
} | ||
_this.methods = _this.contractModuleFactory.createMethodsProxy(_assertThisInitialized(_assertThisInitialized(_this)), _this.abiModel, _this.PromiEvent); | ||
_this.events = _this.contractModuleFactory.createEventSubscriptionsProxy(_assertThisInitialized(_assertThisInitialized(_this)), _this.abiModel, _this.PromiEvent); | ||
return _this; | ||
@@ -1066,7 +1087,5 @@ } | ||
value: function clone() { | ||
var contract = new this.constructor(this.currentProvider, this.providersModuleFactory, this.methodModuleFactory, this.contractModuleFactory, this.PromiEvent, this.abiCoder, this.utils, this.formatters, [], this.address, this.options); | ||
contract.abiModel = this.abiModel; | ||
contract.methods.abiModel = this.abiModel; | ||
contract.events.abiModel = this.abiModel; | ||
return contract; | ||
var clone = this.contractModuleFactory.createContract(this.currentProvider, this.providersModuleFactory, this.accounts, [], '', this.options); | ||
clone.abiModel = this.abiModel; | ||
return clone; | ||
} | ||
@@ -1109,4 +1128,4 @@ }, { | ||
key: "createContract", | ||
value: function createContract(provider, providersModuleFactory, PromiEvent, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, PromiEvent, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
value: function createContract(provider, providersModuleFactory, accounts, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, accounts, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
} | ||
@@ -1176,13 +1195,13 @@ }, { | ||
value: function createMethodFactory() { | ||
return new MethodFactory(this.accounts, this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
return new MethodFactory(this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
} | ||
}, { | ||
key: "createMethodsProxy", | ||
value: function createMethodsProxy(target, abiModel, PromiEvent) { | ||
return new MethodsProxy(target, abiModel, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper(), PromiEvent); | ||
value: function createMethodsProxy(contract) { | ||
return new MethodsProxy(contract, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper()); | ||
} | ||
}, { | ||
key: "createEventSubscriptionsProxy", | ||
value: function createEventSubscriptionsProxy(contract, abiModel, PromiEvent) { | ||
return new EventSubscriptionsProxy(contract, abiModel, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper(), PromiEvent); | ||
value: function createEventSubscriptionsProxy(contract) { | ||
return new EventSubscriptionsProxy(contract, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper()); | ||
} | ||
@@ -1198,4 +1217,4 @@ }, { | ||
var Contract = function Contract(provider, accounts, abi, address, options) { | ||
return new ContractModuleFactory(Utils, web3CoreHelpers.formatters, new web3EthAbi.AbiCoder(), accounts, new web3CoreMethod.MethodModuleFactory(accounts)).createContract(provider, new web3Providers.ProvidersModuleFactory(), web3CorePromievent.PromiEvent, abi, address, options); | ||
var Contract = function Contract(provider, abi, accounts, address, options) { | ||
return new ContractModuleFactory(Utils, web3CoreHelpers.formatters, new web3EthAbi.AbiCoder(), accounts, new web3CoreMethod.MethodModuleFactory()).createContract(provider, new web3Providers.ProvidersModuleFactory(), accounts, abi, address, options); | ||
}; | ||
@@ -1202,0 +1221,0 @@ |
@@ -10,3 +10,3 @@ import * as Utils from 'web3-utils'; | ||
import isArray from 'lodash/isArray'; | ||
import { SendTransactionMethod, CallMethod, GetPastLogsMethod, EstimateGasMethod, MethodModuleFactory } from 'web3-core-method'; | ||
import { SendTransactionMethod, CallMethod, GetPastLogsMethod, EstimateGasMethod, SendRawTransactionMethod, ChainIdMethod, GetTransactionCountMethod, MethodModuleFactory } from 'web3-core-method'; | ||
import { LogSubscription } from 'web3-core-subscriptions'; | ||
@@ -108,4 +108,7 @@ import { AbstractWeb3Module } from 'web3-core'; | ||
encode(abiItemModel, deployData) { | ||
let encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters).replace('0x', ''); | ||
if (abiItemModel.signature === 'constructor') { | ||
let encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters); | ||
if (encodedParameters.startsWith('0x')) { | ||
encodedParameters = encodedParameters.slice(2); | ||
} | ||
if (abiItemModel.isOfType('constructor')) { | ||
if (!deployData) { | ||
@@ -164,3 +167,3 @@ throw new Error('The contract has no contract data option set. This is necessary to append the constructor parameters.'); | ||
let argTopics = response.topics; | ||
if (abiItemModel.anonymous) { | ||
if (!abiItemModel.anonymous) { | ||
argTopics = response.topics.slice(1); | ||
@@ -189,3 +192,12 @@ } | ||
decode(abiModel, response) { | ||
return super.decode(abiModel.getEventBySignature(response.topics[0]), response); | ||
const abiItemModel = abiModel.getEventBySignature(response.topics[0]); | ||
if (abiItemModel) { | ||
return super.decode(abiItemModel, response); | ||
} | ||
return { | ||
raw: { | ||
data: response.data, | ||
topics: response.topics | ||
} | ||
}; | ||
} | ||
@@ -199,2 +211,3 @@ } | ||
this.contractModuleFactory = contractModuleFactory; | ||
this.hasConstructor = false; | ||
} | ||
@@ -241,4 +254,13 @@ map(abi) { | ||
mappedAbiItems.methods['contractConstructor'] = this.contractModuleFactory.createAbiItemModel(abiItem); | ||
this.hasConstructor = true; | ||
} | ||
}); | ||
if (!this.hasConstructor) { | ||
mappedAbiItems.methods['contractConstructor'] = this.contractModuleFactory.createAbiItemModel({ | ||
inputs: [], | ||
payable: false, | ||
constant: false, | ||
type: 'constructor' | ||
}); | ||
} | ||
return this.contractModuleFactory.createAbiModel(mappedAbiItems); | ||
@@ -335,5 +357,4 @@ } | ||
class MethodsProxy { | ||
constructor(contract, abiModel, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper, PromiEvent$$1) { | ||
constructor(contract, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper) { | ||
this.contract = contract; | ||
this.abiModel = abiModel; | ||
this.methodFactory = methodFactory; | ||
@@ -343,7 +364,6 @@ this.methodEncoder = methodEncoder; | ||
this.methodOptionsMapper = methodOptionsMapper; | ||
this.PromiEvent = PromiEvent$$1; | ||
return new Proxy(this, { | ||
get: (target, name) => { | ||
if (this.abiModel.hasMethod(name)) { | ||
let abiItemModel = this.abiModel.getMethod(name); | ||
if (this.contract.abiModel.hasMethod(name)) { | ||
let abiItemModel = this.contract.abiModel.getMethod(name); | ||
let requestType = abiItemModel.requestType; | ||
@@ -355,9 +375,13 @@ if (isArray(abiItemModel)) { | ||
let methodArguments = [...arguments]; | ||
if (!isArray(abiItemModel) && abiItemModel.isOfType('constructor')) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
if (name === 'contractConstructor') { | ||
if (methodArguments[0]) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
return anonymousFunction; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
abiItemModel.contractMethodParameters = []; | ||
return anonymousFunction; | ||
@@ -412,3 +436,3 @@ } | ||
} catch (error) { | ||
const promiEvent = new this.PromiEvent(); | ||
const promiEvent = new PromiEvent(); | ||
method = this.methodFactory.createMethodByRequestType(abiItemModel, this.contract, requestType); | ||
@@ -426,3 +450,3 @@ method.arguments = methodArguments; | ||
} | ||
return method.execute(this.contract, new this.PromiEvent()); | ||
return method.execute(this.contract, new PromiEvent()); | ||
} | ||
@@ -444,6 +468,5 @@ createMethod(abiItemModel, methodArguments, requestType) { | ||
class EventSubscriptionsProxy { | ||
constructor(contract, abiModel, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper, PromiEvent$$1) { | ||
constructor(contract, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper) { | ||
this.contract = contract; | ||
this.eventSubscriptionFactory = eventSubscriptionFactory; | ||
this.abiModel = abiModel; | ||
this.eventOptionsMapper = eventOptionsMapper; | ||
@@ -453,8 +476,7 @@ this.eventLogDecoder = eventLogDecoder; | ||
this.allEventsOptionsMapper = allEventsOptionsMapper; | ||
this.PromiEvent = PromiEvent$$1; | ||
return new Proxy(this, { | ||
get: (target, name) => { | ||
if (this.abiModel.hasEvent(name)) { | ||
if (this.contract.abiModel.hasEvent(name)) { | ||
return (options, callback) => { | ||
return target.subscribe(target.abiModel.getEvent(name), cloneDeep(options), callback); | ||
return target.subscribe(target.contract.abiModel.getEvent(name), cloneDeep(options), callback); | ||
}; | ||
@@ -483,3 +505,3 @@ } | ||
} | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.abiModel, this.contract, options)).subscribe(callback); | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.contract.abiModel, this.contract, options)).subscribe(callback); | ||
} | ||
@@ -496,4 +518,4 @@ handleValidationError(errorMessage, callback) { | ||
class SendContractMethod extends SendTransactionMethod { | ||
constructor(utils, formatters$$1, transactionConfirmationWorkflow, accounts, transactionSigner, allEventsLogDecoder, abiModel) { | ||
super(utils, formatters$$1, transactionConfirmationWorkflow, accounts, transactionSigner); | ||
constructor(utils, formatters$$1, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) { | ||
super(utils, formatters$$1, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod); | ||
this.allEventsLogDecoder = allEventsLogDecoder; | ||
@@ -544,3 +566,3 @@ this.abiModel = abiModel; | ||
isToSet(abiItemModel, method) { | ||
if (abiItemModel.signature === 'constructor') { | ||
if (abiItemModel.isOfType('constructor')) { | ||
return true; | ||
@@ -554,3 +576,3 @@ } | ||
isValueValid(abiItemModel, method) { | ||
return !(!abiItemModel.payable && method.parameters[0].value && method.parameters[0].value > 0); | ||
return !abiItemModel.payable && !method.parameters[0].value > 0 || abiItemModel.payable && method.parameters[0].value > 0; | ||
} | ||
@@ -569,10 +591,8 @@ } | ||
} | ||
if (response.length >= 2) { | ||
response = response.slice(2); | ||
const outputs = this.abiItemModel.getOutputs(); | ||
response = this.abiCoder.decodeParameters(outputs, response); | ||
if (outputs.length === 1) { | ||
return response[0]; | ||
} | ||
const result = this.abiCoder.decodeParameters(this.abiItemModel.getOutputs(), response); | ||
if (Object.keys(result).length === 1) { | ||
return result[0]; | ||
} | ||
return result; | ||
return response; | ||
} | ||
@@ -582,4 +602,4 @@ } | ||
class ContractDeployMethod extends SendTransactionMethod { | ||
constructor(utils, formatters$$1, transactionConfirmationWorkflow, accounts, transactionSigner, contract) { | ||
super(utils, formatters$$1, transactionConfirmationWorkflow, accounts, transactionSigner); | ||
constructor(utils, formatters$$1, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, contract) { | ||
super(utils, formatters$$1, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod); | ||
this.contract = contract; | ||
@@ -593,3 +613,3 @@ } | ||
const clonedContract = this.contract.clone(); | ||
clonedContract.options.address = response.contractAddress; | ||
clonedContract.address = response.contractAddress; | ||
return clonedContract; | ||
@@ -638,4 +658,3 @@ } | ||
class MethodFactory { | ||
constructor(accounts, utils, formatters$$1, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
this.accounts = accounts; | ||
constructor(utils, formatters$$1, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
this.utils = utils; | ||
@@ -678,6 +697,8 @@ this.formatters = formatters$$1; | ||
createSendContractMethod(abiItem, abiModel) { | ||
return new SendContractMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
const transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new SendContractMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new ChainIdMethod(this.utils, this.formatters), new GetTransactionCountMethod(this.utils, this.formatters), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
} | ||
createContractDeployMethod(contract) { | ||
return new ContractDeployMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), contract); | ||
const transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new ContractDeployMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new ChainIdMethod(this.utils, this.formatters), new GetTransactionCountMethod(this.utils, this.formatters), contract); | ||
} | ||
@@ -725,3 +746,3 @@ createEstimateGasMethod() { | ||
class AbstractContract extends AbstractWeb3Module { | ||
constructor(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, PromiEvent$$1, abiCoder, utils, formatters$$1, abi = AbstractWeb3Module.throwIfMissing('abi'), address, options = {}) { | ||
constructor(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, accounts, abiCoder, utils, formatters$$1, abi = [], address = '', options = {}) { | ||
super(provider, providersModuleFactory, methodModuleFactory, null, options); | ||
@@ -734,11 +755,11 @@ this.contractModuleFactory = contractModuleFactory; | ||
this.options = options; | ||
this.PromiEvent = PromiEvent$$1; | ||
this.accounts = accounts; | ||
this.methodFactory = this.contractModuleFactory.createMethodFactory(); | ||
this.abiModel = this.abiMapper.map(abi); | ||
this.options = options; | ||
this.transactionSigner = options.transactionSigner; | ||
this.methods = this.contractModuleFactory.createMethodsProxy(this); | ||
this.events = this.contractModuleFactory.createEventSubscriptionsProxy(this); | ||
if (address) { | ||
this.address = address; | ||
} | ||
this.methods = this.contractModuleFactory.createMethodsProxy(this, this.abiModel, this.PromiEvent); | ||
this.events = this.contractModuleFactory.createEventSubscriptionsProxy(this, this.abiModel, this.PromiEvent); | ||
} | ||
@@ -790,7 +811,5 @@ get jsonInterface() { | ||
clone() { | ||
const contract = new this.constructor(this.currentProvider, this.providersModuleFactory, this.methodModuleFactory, this.contractModuleFactory, this.PromiEvent, this.abiCoder, this.utils, this.formatters, [], this.address, this.options); | ||
contract.abiModel = this.abiModel; | ||
contract.methods.abiModel = this.abiModel; | ||
contract.events.abiModel = this.abiModel; | ||
return contract; | ||
const clone = this.contractModuleFactory.createContract(this.currentProvider, this.providersModuleFactory, this.accounts, [], '', this.options); | ||
clone.abiModel = this.abiModel; | ||
return clone; | ||
} | ||
@@ -807,4 +826,4 @@ } | ||
} | ||
createContract(provider, providersModuleFactory, PromiEvent$$1, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, PromiEvent$$1, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
createContract(provider, providersModuleFactory, accounts, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, accounts, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
} | ||
@@ -848,9 +867,9 @@ createAbiModel(mappedAbi) { | ||
createMethodFactory() { | ||
return new MethodFactory(this.accounts, this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
return new MethodFactory(this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
} | ||
createMethodsProxy(target, abiModel, PromiEvent$$1) { | ||
return new MethodsProxy(target, abiModel, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper(), PromiEvent$$1); | ||
createMethodsProxy(contract) { | ||
return new MethodsProxy(contract, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper()); | ||
} | ||
createEventSubscriptionsProxy(contract, abiModel, PromiEvent$$1) { | ||
return new EventSubscriptionsProxy(contract, abiModel, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper(), PromiEvent$$1); | ||
createEventSubscriptionsProxy(contract) { | ||
return new EventSubscriptionsProxy(contract, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper()); | ||
} | ||
@@ -862,6 +881,6 @@ createEventSubscriptionFactory() { | ||
const Contract = (provider, accounts, abi, address, options) => { | ||
return new ContractModuleFactory(Utils, formatters, new AbiCoder(), accounts, new MethodModuleFactory(accounts)).createContract(provider, new ProvidersModuleFactory(), PromiEvent, abi, address, options); | ||
const Contract = (provider, abi, accounts, address, options) => { | ||
return new ContractModuleFactory(Utils, formatters, new AbiCoder(), accounts, new MethodModuleFactory()).createContract(provider, new ProvidersModuleFactory(), accounts, abi, address, options); | ||
}; | ||
export { AbstractContract, ContractModuleFactory, Contract }; |
@@ -153,4 +153,7 @@ (function (global, factory) { | ||
value: function encode(abiItemModel, deployData) { | ||
var encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters).replace('0x', ''); | ||
if (abiItemModel.signature === 'constructor') { | ||
var encodedParameters = this.abiCoder.encodeParameters(abiItemModel.getInputs(), abiItemModel.contractMethodParameters); | ||
if (encodedParameters.startsWith('0x')) { | ||
encodedParameters = encodedParameters.slice(2); | ||
} | ||
if (abiItemModel.isOfType('constructor')) { | ||
if (!deployData) { | ||
@@ -233,3 +236,3 @@ throw new Error('The contract has no contract data option set. This is necessary to append the constructor parameters.'); | ||
var argTopics = response.topics; | ||
if (abiItemModel.anonymous) { | ||
if (!abiItemModel.anonymous) { | ||
argTopics = response.topics.slice(1); | ||
@@ -265,3 +268,12 @@ } | ||
value: function decode(abiModel, response) { | ||
return _get(_getPrototypeOf(AllEventsLogDecoder.prototype), "decode", this).call(this, abiModel.getEventBySignature(response.topics[0]), response); | ||
var abiItemModel = abiModel.getEventBySignature(response.topics[0]); | ||
if (abiItemModel) { | ||
return _get(_getPrototypeOf(AllEventsLogDecoder.prototype), "decode", this).call(this, abiItemModel, response); | ||
} | ||
return { | ||
raw: { | ||
data: response.data, | ||
topics: response.topics | ||
} | ||
}; | ||
} | ||
@@ -279,2 +291,3 @@ }]); | ||
this.contractModuleFactory = contractModuleFactory; | ||
this.hasConstructor = false; | ||
} | ||
@@ -324,4 +337,13 @@ _createClass(AbiMapper, [{ | ||
mappedAbiItems.methods['contractConstructor'] = _this.contractModuleFactory.createAbiItemModel(abiItem); | ||
_this.hasConstructor = true; | ||
} | ||
}); | ||
if (!this.hasConstructor) { | ||
mappedAbiItems.methods['contractConstructor'] = this.contractModuleFactory.createAbiItemModel({ | ||
inputs: [], | ||
payable: false, | ||
constant: false, | ||
type: 'constructor' | ||
}); | ||
} | ||
return this.contractModuleFactory.createAbiModel(mappedAbiItems); | ||
@@ -443,7 +465,6 @@ } | ||
function () { | ||
function MethodsProxy(contract, abiModel, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper, PromiEvent) { | ||
function MethodsProxy(contract, methodFactory, methodEncoder, methodOptionsValidator, methodOptionsMapper) { | ||
var _this = this; | ||
_classCallCheck(this, MethodsProxy); | ||
this.contract = contract; | ||
this.abiModel = abiModel; | ||
this.methodFactory = methodFactory; | ||
@@ -453,15 +474,18 @@ this.methodEncoder = methodEncoder; | ||
this.methodOptionsMapper = methodOptionsMapper; | ||
this.PromiEvent = PromiEvent; | ||
return new Proxy(this, { | ||
get: function get(target, name) { | ||
if (_this.abiModel.hasMethod(name)) { | ||
if (_this.contract.abiModel.hasMethod(name)) { | ||
var anonymousFunction = function anonymousFunction() { | ||
var methodArguments = Array.prototype.slice.call(arguments); | ||
if (!isArray(abiItemModel) && abiItemModel.isOfType('constructor')) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
if (name === 'contractConstructor') { | ||
if (methodArguments[0]) { | ||
if (methodArguments[0]['data']) { | ||
target.contract.options.data = methodArguments[0]['data']; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
return anonymousFunction; | ||
} | ||
if (methodArguments[0]['arguments']) { | ||
abiItemModel.contractMethodParameters = methodArguments[0]['arguments']; | ||
} | ||
abiItemModel.contractMethodParameters = []; | ||
return anonymousFunction; | ||
@@ -488,3 +512,3 @@ } | ||
}; | ||
var abiItemModel = _this.abiModel.getMethod(name); | ||
var abiItemModel = _this.contract.abiModel.getMethod(name); | ||
var requestType = abiItemModel.requestType; | ||
@@ -524,3 +548,3 @@ if (isArray(abiItemModel)) { | ||
} catch (error) { | ||
var promiEvent = new this.PromiEvent(); | ||
var promiEvent = new web3CorePromievent.PromiEvent(); | ||
method = this.methodFactory.createMethodByRequestType(abiItemModel, this.contract, requestType); | ||
@@ -538,3 +562,3 @@ method.arguments = methodArguments; | ||
} | ||
return method.execute(this.contract, new this.PromiEvent()); | ||
return method.execute(this.contract, new web3CorePromievent.PromiEvent()); | ||
} | ||
@@ -561,3 +585,3 @@ }, { | ||
function () { | ||
function EventSubscriptionsProxy(contract, abiModel, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper, PromiEvent) { | ||
function EventSubscriptionsProxy(contract, eventSubscriptionFactory, eventOptionsMapper, eventLogDecoder, allEventsLogDecoder, allEventsOptionsMapper) { | ||
var _this = this; | ||
@@ -567,3 +591,2 @@ _classCallCheck(this, EventSubscriptionsProxy); | ||
this.eventSubscriptionFactory = eventSubscriptionFactory; | ||
this.abiModel = abiModel; | ||
this.eventOptionsMapper = eventOptionsMapper; | ||
@@ -573,8 +596,7 @@ this.eventLogDecoder = eventLogDecoder; | ||
this.allEventsOptionsMapper = allEventsOptionsMapper; | ||
this.PromiEvent = PromiEvent; | ||
return new Proxy(this, { | ||
get: function get(target, name) { | ||
if (_this.abiModel.hasEvent(name)) { | ||
if (_this.contract.abiModel.hasEvent(name)) { | ||
return function (options, callback) { | ||
return target.subscribe(target.abiModel.getEvent(name), cloneDeep(options), callback); | ||
return target.subscribe(target.contract.abiModel.getEvent(name), cloneDeep(options), callback); | ||
}; | ||
@@ -607,3 +629,3 @@ } | ||
} | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.abiModel, this.contract, options)).subscribe(callback); | ||
return this.eventSubscriptionFactory.createAllEventsLogSubscription(this.allEventsLogDecoder, this.contract, this.allEventsOptionsMapper.map(this.contract.abiModel, this.contract, options)).subscribe(callback); | ||
} | ||
@@ -626,6 +648,6 @@ }, { | ||
_inherits(SendContractMethod, _SendTransactionMetho); | ||
function SendContractMethod(utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner, allEventsLogDecoder, abiModel) { | ||
function SendContractMethod(utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, allEventsLogDecoder, abiModel) { | ||
var _this; | ||
_classCallCheck(this, SendContractMethod); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(SendContractMethod).call(this, utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod)); | ||
_this.allEventsLogDecoder = allEventsLogDecoder; | ||
@@ -688,3 +710,3 @@ _this.abiModel = abiModel; | ||
value: function isToSet(abiItemModel, method) { | ||
if (abiItemModel.signature === 'constructor') { | ||
if (abiItemModel.isOfType('constructor')) { | ||
return true; | ||
@@ -702,3 +724,3 @@ } | ||
value: function isValueValid(abiItemModel, method) { | ||
return !(!abiItemModel.payable && method.parameters[0].value && method.parameters[0].value > 0); | ||
return !abiItemModel.payable && !method.parameters[0].value > 0 || abiItemModel.payable && method.parameters[0].value > 0; | ||
} | ||
@@ -726,10 +748,8 @@ }]); | ||
} | ||
if (response.length >= 2) { | ||
response = response.slice(2); | ||
var outputs = this.abiItemModel.getOutputs(); | ||
response = this.abiCoder.decodeParameters(outputs, response); | ||
if (outputs.length === 1) { | ||
return response[0]; | ||
} | ||
var result = this.abiCoder.decodeParameters(this.abiItemModel.getOutputs(), response); | ||
if (Object.keys(result).length === 1) { | ||
return result[0]; | ||
} | ||
return result; | ||
return response; | ||
} | ||
@@ -743,6 +763,6 @@ }]); | ||
_inherits(ContractDeployMethod, _SendTransactionMetho); | ||
function ContractDeployMethod(utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner, contract) { | ||
function ContractDeployMethod(utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod, contract) { | ||
var _this; | ||
_classCallCheck(this, ContractDeployMethod); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, transactionConfirmationWorkflow, accounts, transactionSigner)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(ContractDeployMethod).call(this, utils, formatters, transactionConfirmationWorkflow, sendRawTransactionMethod, chainIdMethod, getTransactionCountMethod)); | ||
_this.contract = contract; | ||
@@ -761,3 +781,3 @@ return _this; | ||
var clonedContract = this.contract.clone(); | ||
clonedContract.options.address = response.contractAddress; | ||
clonedContract.address = response.contractAddress; | ||
return clonedContract; | ||
@@ -833,5 +853,4 @@ } | ||
function () { | ||
function MethodFactory(accounts, utils, formatters, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
function MethodFactory(utils, formatters, contractModuleFactory, methodModuleFactory, abiCoder) { | ||
_classCallCheck(this, MethodFactory); | ||
this.accounts = accounts; | ||
this.utils = utils; | ||
@@ -884,3 +903,4 @@ this.formatters = formatters; | ||
value: function createSendContractMethod(abiItem, abiModel) { | ||
return new SendContractMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
var transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new SendContractMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters), this.contractModuleFactory.createAllEventsLogDecoder(), abiModel); | ||
} | ||
@@ -890,3 +910,4 @@ }, { | ||
value: function createContractDeployMethod(contract) { | ||
return new ContractDeployMethod(this.utils, this.formatters, this.methodModuleFactory.createTransactionConfirmationWorkflow(), this.accounts, this.methodModuleFactory.createTransactionSigner(), contract); | ||
var transactionConfirmationWorkflow = this.methodModuleFactory.createTransactionConfirmationWorkflow(); | ||
return new ContractDeployMethod(this.utils, this.formatters, transactionConfirmationWorkflow, new web3CoreMethod.SendRawTransactionMethod(this.utils, this.formatters, transactionConfirmationWorkflow), new web3CoreMethod.ChainIdMethod(this.utils, this.formatters), new web3CoreMethod.GetTransactionCountMethod(this.utils, this.formatters), contract); | ||
} | ||
@@ -966,6 +987,6 @@ }, { | ||
_inherits(AbstractContract, _AbstractWeb3Module); | ||
function AbstractContract(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, PromiEvent, abiCoder, utils, formatters) { | ||
function AbstractContract(provider, providersModuleFactory, methodModuleFactory, contractModuleFactory, accounts, abiCoder, utils, formatters) { | ||
var _this; | ||
var abi = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : web3Core.AbstractWeb3Module.throwIfMissing('abi'); | ||
var address = arguments.length > 9 ? arguments[9] : undefined; | ||
var abi = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : []; | ||
var address = arguments.length > 9 && arguments[9] !== undefined ? arguments[9] : ''; | ||
var options = arguments.length > 10 && arguments[10] !== undefined ? arguments[10] : {}; | ||
@@ -980,11 +1001,11 @@ _classCallCheck(this, AbstractContract); | ||
_this.options = options; | ||
_this.PromiEvent = PromiEvent; | ||
_this.accounts = accounts; | ||
_this.methodFactory = _this.contractModuleFactory.createMethodFactory(); | ||
_this.abiModel = _this.abiMapper.map(abi); | ||
_this.options = options; | ||
_this.transactionSigner = options.transactionSigner; | ||
_this.methods = _this.contractModuleFactory.createMethodsProxy(_assertThisInitialized(_assertThisInitialized(_this))); | ||
_this.events = _this.contractModuleFactory.createEventSubscriptionsProxy(_assertThisInitialized(_assertThisInitialized(_this))); | ||
if (address) { | ||
_this.address = address; | ||
} | ||
_this.methods = _this.contractModuleFactory.createMethodsProxy(_assertThisInitialized(_assertThisInitialized(_this)), _this.abiModel, _this.PromiEvent); | ||
_this.events = _this.contractModuleFactory.createEventSubscriptionsProxy(_assertThisInitialized(_assertThisInitialized(_this)), _this.abiModel, _this.PromiEvent); | ||
return _this; | ||
@@ -1058,7 +1079,5 @@ } | ||
value: function clone() { | ||
var contract = new this.constructor(this.currentProvider, this.providersModuleFactory, this.methodModuleFactory, this.contractModuleFactory, this.PromiEvent, this.abiCoder, this.utils, this.formatters, [], this.address, this.options); | ||
contract.abiModel = this.abiModel; | ||
contract.methods.abiModel = this.abiModel; | ||
contract.events.abiModel = this.abiModel; | ||
return contract; | ||
var clone = this.contractModuleFactory.createContract(this.currentProvider, this.providersModuleFactory, this.accounts, [], '', this.options); | ||
clone.abiModel = this.abiModel; | ||
return clone; | ||
} | ||
@@ -1101,4 +1120,4 @@ }, { | ||
key: "createContract", | ||
value: function createContract(provider, providersModuleFactory, PromiEvent, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, PromiEvent, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
value: function createContract(provider, providersModuleFactory, accounts, abi, address, options) { | ||
return new AbstractContract(provider, providersModuleFactory, this.methodModuleFactory, this, accounts, this.abiCoder, this.utils, this.formatters, abi, address, options); | ||
} | ||
@@ -1168,13 +1187,13 @@ }, { | ||
value: function createMethodFactory() { | ||
return new MethodFactory(this.accounts, this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
return new MethodFactory(this.utils, this.formatters, this, this.methodModuleFactory, this.abiCoder); | ||
} | ||
}, { | ||
key: "createMethodsProxy", | ||
value: function createMethodsProxy(target, abiModel, PromiEvent) { | ||
return new MethodsProxy(target, abiModel, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper(), PromiEvent); | ||
value: function createMethodsProxy(contract) { | ||
return new MethodsProxy(contract, this.createMethodFactory(), this.createMethodEncoder(), this.createMethodOptionsValidator(), this.createMethodOptionsMapper()); | ||
} | ||
}, { | ||
key: "createEventSubscriptionsProxy", | ||
value: function createEventSubscriptionsProxy(contract, abiModel, PromiEvent) { | ||
return new EventSubscriptionsProxy(contract, abiModel, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper(), PromiEvent); | ||
value: function createEventSubscriptionsProxy(contract) { | ||
return new EventSubscriptionsProxy(contract, this.createEventSubscriptionFactory(), this.createEventOptionsMapper(), this.createEventLogDecoder(), this.createAllEventsLogDecoder(), this.createAllEventsOptionsMapper()); | ||
} | ||
@@ -1190,4 +1209,4 @@ }, { | ||
var Contract = function Contract(provider, accounts, abi, address, options) { | ||
return new ContractModuleFactory(Utils, web3CoreHelpers.formatters, new web3EthAbi.AbiCoder(), accounts, new web3CoreMethod.MethodModuleFactory(accounts)).createContract(provider, new web3Providers.ProvidersModuleFactory(), web3CorePromievent.PromiEvent, abi, address, options); | ||
var Contract = function Contract(provider, abi, accounts, address, options) { | ||
return new ContractModuleFactory(Utils, web3CoreHelpers.formatters, new web3EthAbi.AbiCoder(), accounts, new web3CoreMethod.MethodModuleFactory()).createContract(provider, new web3Providers.ProvidersModuleFactory(), accounts, abi, address, options); | ||
}; | ||
@@ -1194,0 +1213,0 @@ |
{ | ||
"name": "web3-eth-contract", | ||
"namespace": "ethereum", | ||
"version": "1.0.0-beta.46", | ||
"version": "1.0.0-beta.47", | ||
"description": "Web3 module to interact with Ethereum smart contracts.", | ||
@@ -21,11 +21,11 @@ "repository": "https://github.com/ethereum/web3.js/tree/1.0/packages/web3-eth-contract", | ||
"lodash": "^4.17.11", | ||
"web3-core": "1.0.0-beta.46", | ||
"web3-core-helpers": "1.0.0-beta.46", | ||
"web3-core-method": "1.0.0-beta.46", | ||
"web3-core-promievent": "1.0.0-beta.46", | ||
"web3-core-subscriptions": "1.0.0-beta.46", | ||
"web3-eth-abi": "1.0.0-beta.46", | ||
"web3-eth-accounts": "1.0.0-beta.46", | ||
"web3-providers": "1.0.0-beta.46", | ||
"web3-utils": "1.0.0-beta.46" | ||
"web3-core": "1.0.0-beta.47", | ||
"web3-core-helpers": "1.0.0-beta.47", | ||
"web3-core-method": "1.0.0-beta.47", | ||
"web3-core-promievent": "1.0.0-beta.47", | ||
"web3-core-subscriptions": "1.0.0-beta.47", | ||
"web3-eth-abi": "1.0.0-beta.47", | ||
"web3-eth-accounts": "1.0.0-beta.47", | ||
"web3-providers": "1.0.0-beta.47", | ||
"web3-utils": "1.0.0-beta.47" | ||
}, | ||
@@ -32,0 +32,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
261435
3271
+ Addedweb3-core@1.0.0-beta.47(transitive)
+ Addedweb3-core-helpers@1.0.0-beta.47(transitive)
+ Addedweb3-core-method@1.0.0-beta.47(transitive)
+ Addedweb3-core-promievent@1.0.0-beta.47(transitive)
+ Addedweb3-core-subscriptions@1.0.0-beta.47(transitive)
+ Addedweb3-eth-abi@1.0.0-beta.47(transitive)
+ Addedweb3-eth-accounts@1.0.0-beta.47(transitive)
+ Addedweb3-eth-iban@1.0.0-beta.47(transitive)
+ Addedweb3-providers@1.0.0-beta.47(transitive)
+ Addedweb3-utils@1.0.0-beta.47(transitive)
- Removedweb3-core@1.0.0-beta.46(transitive)
- Removedweb3-core-helpers@1.0.0-beta.46(transitive)
- Removedweb3-core-method@1.0.0-beta.46(transitive)
- Removedweb3-core-promievent@1.0.0-beta.46(transitive)
- Removedweb3-core-subscriptions@1.0.0-beta.46(transitive)
- Removedweb3-eth-abi@1.0.0-beta.46(transitive)
- Removedweb3-eth-accounts@1.0.0-beta.46(transitive)
- Removedweb3-eth-iban@1.0.0-beta.46(transitive)
- Removedweb3-providers@1.0.0-beta.46(transitive)
- Removedweb3-utils@1.0.0-beta.46(transitive)
Updatedweb3-core@1.0.0-beta.47
Updatedweb3-eth-abi@1.0.0-beta.47
Updatedweb3-providers@1.0.0-beta.47
Updatedweb3-utils@1.0.0-beta.47