github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/test/contract_accept_func_with_args_2.js (about) 1 2 "use strict"; 3 4 var DepositeContent = function (text) { 5 if (text) { 6 var o = JSON.parse(text); 7 this.balance = new BigNumber(o.balance); 8 this.expiryHeight = new BigNumber(o.expiryHeight); 9 } else { 10 this.balance = new BigNumber(0); 11 this.expiryHeight = new BigNumber(0); 12 } 13 }; 14 15 DepositeContent.prototype = { 16 toString: function () { 17 return JSON.stringify(this); 18 } 19 }; 20 21 var BankVaultContract = function () { 22 LocalContractStorage.defineMapProperty(this, "bankVault", { 23 parse: function (text) { 24 return new DepositeContent(text); 25 }, 26 stringify: function (o) { 27 return o.toString(); 28 } 29 }); 30 }; 31 32 // save value to contract, only after height of block, users can takeout 33 BankVaultContract.prototype = { 34 init: function () { 35 //TODO: 36 }, 37 38 // enables accepting NAS via 'binary' 39 accept: function (height) { 40 var from = Blockchain.transaction.from; 41 var value = Blockchain.transaction.value; 42 var bk_height = new BigNumber(Blockchain.block.height); 43 44 console.log("accept height: " + height); 45 46 return { 47 height: height, 48 from: from, 49 value: value, 50 bk_height: bk_height 51 }; 52 } 53 }; 54 55 module.exports = BankVaultContract; 56