ethjs-contract
Advanced tools
Comparing version
@@ -0,1 +1,5 @@ | ||
# 0.1.8 -- handles decode of empty addrs nicely | ||
1. Handles decode of empty addrs nicely | ||
# 0.1.6 -- BN formatting update | ||
@@ -2,0 +6,0 @@ |
@@ -34,2 +34,12 @@ 'use strict'; | ||
return function ContractFactory(contractABI, contractBytecode, contractDefaultTxObject) { | ||
if (!Array.isArray(contractABI)) { | ||
throw new Error('[ethjs-contract] Contract ABI must be type Array, got type ' + typeof contractABI); | ||
} | ||
if (typeof contractBytecode !== 'undefined' && typeof contractBytecode !== 'string') { | ||
throw new Error('[ethjs-contract] Contract bytecode must be type String, got type ' + typeof contractBytecode); | ||
} | ||
if (typeof contractDefaultTxObject !== 'undefined' && typeof contractDefaultTxObject !== 'object') { | ||
throw new Error('[ethjs-contract] Contract default tx object must be type Object, got type ' + typeof contractABI); | ||
} | ||
var output = {}; | ||
@@ -94,15 +104,22 @@ output.at = function atContract(address) { | ||
} else if (methodObject.type === 'event') { | ||
var filterInputTypes = getKeys(methodObject.inputs, 'type', false); | ||
var filterTopic = '0x' + keccak256(methodObject.name + '(' + filterInputTypes.join(',') + ')'); | ||
var argsObject = Object.assign({}, methodArgs[0]) || {}; | ||
var _ret = function () { | ||
var filterInputTypes = getKeys(methodObject.inputs, 'type', false); | ||
var filterTopic = '0x' + keccak256(methodObject.name + '(' + filterInputTypes.join(',') + ')'); | ||
var filterTopcis = [filterTopic]; | ||
var argsObject = Object.assign({}, methodArgs[0]) || {}; | ||
return new self.filters.Filter(Object.assign({}, argsObject, { | ||
decoder: function decoder(logData) { | ||
return abi.decodeEvent(methodObject, logData); | ||
}, | ||
defaultFilterObject: Object.assign({}, methodArgs[0] || {}, { | ||
to: self.address, | ||
topics: [filterTopic] | ||
}) | ||
})); | ||
return { | ||
v: new self.filters.Filter(Object.assign({}, argsObject, { | ||
decoder: function decoder(logData) { | ||
return abi.decodeEvent(methodObject, logData, filterTopcis); | ||
}, | ||
defaultFilterObject: Object.assign({}, methodArgs[0] || {}, { | ||
to: self.address, | ||
topics: filterTopcis | ||
}) | ||
})) | ||
}; | ||
}(); | ||
if (typeof _ret === "object") return _ret.v; | ||
} | ||
@@ -109,0 +126,0 @@ }; |
{ | ||
"name": "ethjs-contract", | ||
"version": "0.1.7", | ||
"version": "0.1.9", | ||
"description": "A simple contract object for the Ethereum RPC.", | ||
@@ -69,3 +69,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"ethjs-abi": "0.1.7", | ||
"ethjs-abi": "0.2.0", | ||
"ethjs-filter": "0.1.5", | ||
@@ -72,0 +72,0 @@ "js-sha3": "0.5.5", |
@@ -75,4 +75,4 @@ ## ethjs-contract | ||
const filter = simpleStore.SetComplete() | ||
.new({ toBlock: 'latest' }, (error, result) => { | ||
const filter = simpleStore.SetComplete(); | ||
filter.new({ toBlock: 'latest' }, (error, result) => { | ||
// result null <BigNumber ...> filterId | ||
@@ -79,0 +79,0 @@ }); |
@@ -30,2 +30,6 @@ const abi = require('ethjs-abi'); // eslint-disable-line | ||
return function ContractFactory(contractABI, contractBytecode, contractDefaultTxObject) { | ||
if (!Array.isArray(contractABI)) { throw new Error(`[ethjs-contract] Contract ABI must be type Array, got type ${typeof contractABI}`); } | ||
if (typeof contractBytecode !== 'undefined' && typeof contractBytecode !== 'string') { throw new Error(`[ethjs-contract] Contract bytecode must be type String, got type ${typeof contractBytecode}`); } | ||
if (typeof contractDefaultTxObject !== 'undefined' && typeof contractDefaultTxObject !== 'object') { throw new Error(`[ethjs-contract] Contract default tx object must be type Object, got type ${typeof contractABI}`); } | ||
const output = {}; | ||
@@ -93,9 +97,10 @@ output.at = function atContract(address) { | ||
const filterTopic = `0x${keccak256(`${methodObject.name}(${filterInputTypes.join(',')})`)}`; | ||
const filterTopcis = [filterTopic]; | ||
const argsObject = Object.assign({}, methodArgs[0]) || {}; | ||
return new self.filters.Filter(Object.assign({}, argsObject, { | ||
decoder: (logData) => abi.decodeEvent(methodObject, logData), | ||
decoder: (logData) => abi.decodeEvent(methodObject, logData, filterTopcis), | ||
defaultFilterObject: Object.assign({}, (methodArgs[0] || {}), { | ||
to: self.address, | ||
topics: [filterTopic], | ||
topics: filterTopcis, | ||
}), | ||
@@ -102,0 +107,0 @@ })); |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
714579
1.4%9053
0.98%+ Added
- Removed
Updated