Merge pull request #48 from status-im/extend_contract_events

feat: extend methods
This commit is contained in:
Iuri Matias 2019-10-03 16:17:24 -04:00 committed by GitHub
commit 4932b9c3bc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View File

@ -29,7 +29,7 @@ class App extends React.Component {
window.web3 = web3;
this.setState({
title: Product.trackProperty("products", 0).map('title'),
title: Product.methods.products(0).track().map('title'),
averageRating: rating$.pipe($average()),
minRating: rating$.pipe($min()),
maxRating: rating$.pipe($max()),

View File

@ -74,6 +74,19 @@ export default class Subspace {
return this.trackProperty(SubspaceContract, propName, methodArgs, callArgs);
}
Object.keys(SubspaceContract.methods).forEach(methodName => {
const oldFunc = SubspaceContract.methods[methodName];
const _this = this;
const newFunc = function(){
const txObject = oldFunc.apply(null, arguments);
txObject.track = (callArgs) => _this.trackProperty(SubspaceContract, methodName, txObject.arguments, callArgs);
return txObject;
}
SubspaceContract.methods[methodName] = newFunc;
});
SubspaceContract.trackBalance = (erc20Address) => {
return this.trackBalance(SubspaceContract.options.address, erc20Address);
}