github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/test/inner_call_tests/test_inner_transaction.js (about) 1 "use strict"; 2 3 4 var ProxyBankContract = function () { 5 6 }; 7 8 // save value to contract, only after height of block, users can takeout 9 ProxyBankContract.prototype = { 10 init: function () { 11 // 12 }, 13 getRandom: function(address, to) { 14 15 var rand = _native_math.random(); 16 console.log("rand:", rand); 17 18 var c = new Blockchain.Contract(address); 19 c.value(0).call("getRandom", to, rand); 20 return rand; 21 }, 22 getRandomSingle: function(address, to) { 23 var rand = _native_math.random(); 24 console.log("rand:", rand); 25 return rand; 26 }, 27 getSource: function(address) { 28 var funcs = { 29 save: function() { 30 31 } 32 } 33 var c = new Blockchain.Contract(address, funcs); 34 }, 35 save: function (address, to, height) { 36 37 console.log("enter inner transaction begin create inner client"); 38 var c = new Blockchain.Contract(address); 39 console.log("exit inner transaction"); 40 c.value(5).call("save", to, height); 41 this.transferEvent(true, address, height); 42 }, 43 saveMem: function (address, to, mem) { 44 console.log("saveMem:", mem); 45 var m = new ArrayBuffer(mem); 46 var c = new Blockchain.Contract(address); 47 48 c.value(0).call("saveMem", to, mem); 49 this.transferEvent(true, address, 0, mem); 50 }, 51 saveErr: function(address, to, flag) { 52 if (flag == 0) { 53 throw("saveErr in test_inner_transaction"); 54 return; 55 } 56 var c = new Blockchain.Contract(address); 57 c.value(5).call("saveErr", to, flag); 58 // this.transferEvent(true, address, 0, mem); 59 }, 60 saveValue: function(address, to, val) { 61 console.log("+++++++saveValue,address:", address, val); 62 var c = new Blockchain.Contract(address); 63 c.value(val).call("saveValue", to, val); 64 }, 65 saveToLoop: function (address, to, height) { 66 var c = new Blockchain.Contract(address); 67 68 c.value(5).call("saveToLoop", address, to, height); 69 this.transferEvent(true, address, height); 70 }, 71 saveTimeOut: function(address, to, flag) { 72 if (flag == 0) { 73 while(1) { 74 75 } 76 } 77 var c = new Blockchain.Contract(address); 78 c.value(0).call("saveTimeOut", to, flag); 79 }, 80 transferEvent: function (status, address, height, mem) { 81 Event.Trigger("test_inner_transaction", { 82 Status: status, 83 Transfer: { 84 address: address, 85 height: height, 86 mem: mem, 87 magic: "main" 88 } 89 }); 90 }, 91 92 }; 93 94 module.exports = ProxyBankContract;