diff --git a/examples/react-example1/src/App.js b/examples/react-example1/src/App.js index a4415ad..a5cdd8f 100644 --- a/examples/react-example1/src/App.js +++ b/examples/react-example1/src/App.js @@ -23,7 +23,7 @@ class App extends React.Component { Product = await ProductContract.getInstance(); Product = subspace.contract(Product) - const rating$ = Product.trackEvent("Rating").map("rating").pipe(map(x => parseInt(x))); + const rating$ = Product.events.Rating.track().map("rating").pipe(map(x => parseInt(x))); window.Product = Product; window.web3 = web3; diff --git a/src/subspace.js b/src/subspace.js index bb06ccc..faa914d 100644 --- a/src/subspace.js +++ b/src/subspace.js @@ -54,8 +54,6 @@ export default class Subspace { throw new Error("please pass a contract instance to Subspace.contract()") } - console.dir(contractInstance) - let address = (contractInstance.options && contractInstance.options.address) || contractInstance.address || contractInstance.deployedAddress; let abi = (contractInstance.options && contractInstance.options.jsonInterface) || contractInstance.abi || contractInstance.abiDefinition; let from = (contractInstance.options && contractInstance.options.from) || contractInstance.from || contractInstance.defaultAddress || this.web3.defaultAccount; @@ -68,6 +66,10 @@ export default class Subspace { return this.trackEvent(SubspaceContract, eventName, filterConditionsOrCb); } + Object.keys(SubspaceContract.events).forEach(ev => { + SubspaceContract.events[ev].track = (filterConditionsOrCb) => this.trackEvent(SubspaceContract, ev, filterConditionsOrCb); + }); + SubspaceContract.trackProperty = (propName, methodArgs, callArgs) => { return this.trackProperty(SubspaceContract, propName, methodArgs, callArgs); }