From a67305ed72930cfb733f6c0ed7ae4c0a128b3f2c Mon Sep 17 00:00:00 2001 From: d11e9 Date: Wed, 7 Oct 2015 18:51:46 +0100 Subject: [PATCH 1/4] updating to match new EthVm apis --- libs/universal-dapp.js | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libs/universal-dapp.js b/libs/universal-dapp.js index b052635e81..2a15fdb8c2 100644 --- a/libs/universal-dapp.js +++ b/libs/universal-dapp.js @@ -7,12 +7,11 @@ function UniversalDApp (contracts, options) { if (!options.vm && web3.currentProvider) { } else if (options.vm) { - this.stateTrie = new EthVm.Trie(); - this.vm = new EthVm.VM(this.stateTrie); + this.vm = new EthVm(); //@todo this does not calculate the gas costs correctly but gets the job done. this.identityCode = 'return { gasUsed: 1, return: opts.data, exception: 1 };'; this.identityAddr = ethUtil.pad(new Buffer('04', 'hex'), 20) - this.vm.loadPrecompiled(this.identityAddr, this.identityCode); + this.vm.loadCompiled(this.identityAddr, this.identityCode); this.secretKey = '3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511' this.publicKey = '0406cc661590d48ee972944b35ad13ff03c7876eae3fd191e8a2f77311b0a3c6613407b5005e63d7d8d76b89d5f900cde691497688bb281e07a5052ff61edebdc0' this.address = ethUtil.pubToAddress(new Buffer(this.publicKey, 'hex')); From 477b766071537ddd7c29f423e9a59979a4d20ced Mon Sep 17 00:00:00 2001 From: d11e9 Date: Thu, 8 Oct 2015 17:36:26 +0100 Subject: [PATCH 2/4] args non exposed constructors --- index.html | 2 ++ libs/universal-dapp.js | 11 +++++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index c65304973c..0f61f9db4e 100644 --- a/index.html +++ b/index.html @@ -42,6 +42,8 @@ THE SOFTWARE. + + diff --git a/libs/universal-dapp.js b/libs/universal-dapp.js index 2a15fdb8c2..5289117940 100644 --- a/libs/universal-dapp.js +++ b/libs/universal-dapp.js @@ -15,10 +15,10 @@ function UniversalDApp (contracts, options) { this.secretKey = '3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511' this.publicKey = '0406cc661590d48ee972944b35ad13ff03c7876eae3fd191e8a2f77311b0a3c6613407b5005e63d7d8d76b89d5f900cde691497688bb281e07a5052ff61edebdc0' this.address = ethUtil.pubToAddress(new Buffer(this.publicKey, 'hex')); - this.account = new EthVm.Account(); + this.account = new EthAccount(); this.account.balance = 'f00000000000000001'; this.nonce = 0; - this.stateTrie.put(this.address, this.account.serialize()); + this.vm.stateManager.trie.put(this.address, this.account.serialize()); } else { var host = options.host || "localhost"; var port = options.port || "8545"; @@ -133,7 +133,10 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar }); $events = $('
'); - if (!self.options.vm){ + if (self.options.vm){ + self.vm.on('step', function(){console.log("step: ", arguments )}) + self.vm.on('afterTx', function(){ console.log("afterTx: ", arguments )}) + } else { var jsInterface = web3.eth.contract(abi).at(address) var eventFilter = jsInterface.allEvents(); eventFilter.watch(function(err,response){ @@ -403,7 +406,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { } } else { try { - var tx = new EthVm.Transaction({ + var tx = new EthTx({ nonce: new Buffer([this.nonce++]), //@todo count beyond 255 gasPrice: '01', gasLimit: '3000000000', //plenty From b0d2e867a7c1549546d8a22d23c0a8de0ddc0e1b Mon Sep 17 00:00:00 2001 From: d11e9 Date: Thu, 8 Oct 2015 17:59:19 +0100 Subject: [PATCH 3/4] arg trying to get vm to work --- index.html | 2 -- libs/universal-dapp.js | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/index.html b/index.html index 0f61f9db4e..c65304973c 100644 --- a/index.html +++ b/index.html @@ -42,8 +42,6 @@ THE SOFTWARE. - - diff --git a/libs/universal-dapp.js b/libs/universal-dapp.js index 5289117940..88eed92c0e 100644 --- a/libs/universal-dapp.js +++ b/libs/universal-dapp.js @@ -15,7 +15,7 @@ function UniversalDApp (contracts, options) { this.secretKey = '3cd7232cd6f3fc66a57a6bedc1a8ed6c228fff0a327e169c2bcc5e869ed49511' this.publicKey = '0406cc661590d48ee972944b35ad13ff03c7876eae3fd191e8a2f77311b0a3c6613407b5005e63d7d8d76b89d5f900cde691497688bb281e07a5052ff61edebdc0' this.address = ethUtil.pubToAddress(new Buffer(this.publicKey, 'hex')); - this.account = new EthAccount(); + this.account = new Account(); this.account.balance = 'f00000000000000001'; this.nonce = 0; this.vm.stateManager.trie.put(this.address, this.account.serialize()); @@ -406,7 +406,7 @@ UniversalDApp.prototype.runTx = function( data, args, cb) { } } else { try { - var tx = new EthTx({ + var tx = new Tx({ nonce: new Buffer([this.nonce++]), //@todo count beyond 255 gasPrice: '01', gasLimit: '3000000000', //plenty From 9fdaa698523e5ec1e0342d68353bb3ce2cc1e557 Mon Sep 17 00:00:00 2001 From: d11e9 Date: Fri, 9 Oct 2015 09:57:05 +0100 Subject: [PATCH 4/4] woop getting vm logs --- libs/universal-dapp.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libs/universal-dapp.js b/libs/universal-dapp.js index 88eed92c0e..f866c10ca8 100644 --- a/libs/universal-dapp.js +++ b/libs/universal-dapp.js @@ -134,8 +134,9 @@ UniversalDApp.prototype.getInstanceInterface = function (contract, address, $tar $events = $('
'); if (self.options.vm){ - self.vm.on('step', function(){console.log("step: ", arguments )}) - self.vm.on('afterTx', function(){ console.log("afterTx: ", arguments )}) + self.vm.on('afterTx', function(response){ + // TODO: parse/use reponse.vm.logs + }); } else { var jsInterface = web3.eth.contract(abi).at(address) var eventFilter = jsInterface.allEvents();