Merge pull request #47 from status-im/extend_contract_events

feat: extend contract events to include tracking
This commit is contained in:
Iuri Matias 2019-10-03 15:59:44 -04:00 committed by GitHub
commit 87c84e49c9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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;

View File

@ -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);
}