Merge pull request #47 from status-im/extend_contract_events
feat: extend contract events to include tracking
This commit is contained in:
commit
87c84e49c9
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue