diff --git a/test/observables/src/App.js b/test/observables/src/App.js index 020e845..cb91dbd 100644 --- a/test/observables/src/App.js +++ b/test/observables/src/App.js @@ -9,7 +9,7 @@ const web3 = new Web3("ws://localhost:8545"); const Escrow = ({escrow}) => { console.log("Received new escrow property", escrow); - return ; + return ; //return }; @@ -24,20 +24,25 @@ class App extends React.Component { escrow: null } + constructor(props){ + super(props); + this.EscrowContract = null; + } + componentDidMount(){ (async () => { let accounts = await web3.eth.getAccounts(); - var EscrowContract = await deployContract(); + this.EscrowContract = await deployContract(); - await EscrowContract.methods.createEscrow(1, accounts[0], accounts[1]).send({from: accounts[0]}) - await EscrowContract.methods.createEscrow(1, accounts[1], accounts[2]).send({from: accounts[0]}) - await EscrowContract.methods.createEscrow(1, accounts[1], accounts[0]).send({from: accounts[0]}) - await EscrowContract.methods.createEscrow(1, accounts[0], accounts[2]).send({from: accounts[0]}) + await this.EscrowContract.methods.createEscrow(1, accounts[0], accounts[1]).send({from: accounts[0]}) + await this.EscrowContract.methods.createEscrow(1, accounts[1], accounts[2]).send({from: accounts[0]}) + await this.EscrowContract.methods.createEscrow(1, accounts[1], accounts[0]).send({from: accounts[0]}) + await this.EscrowContract.methods.createEscrow(1, accounts[0], accounts[2]).send({from: accounts[0]}) const eventSyncer = new Phoenix(web3); eventSyncer.init(() => { - const replayObj = eventSyncer.trackEvent(EscrowContract, 'Created', {filter: {buyer: accounts[0]}, fromBlock: 1}); + const replayObj = eventSyncer.trackEvent(this.EscrowContract, 'Created', {filter: {buyer: accounts[0]}, fromBlock: 1}); this.setState({ escrow: replayObj.asObservable() }); @@ -48,10 +53,17 @@ class App extends React.Component { } + createTrx = async () => { + let accounts = await web3.eth.getAccounts(); + await this.EscrowContract.methods.createEscrow(Date.now(), accounts[0], accounts[1]).send({from: accounts[0]}) + + } + render(){ if(!this.state.escrow) return null; return
+ {this.state.escrow && }
; }