22const AElf = require ( '../../../dist/aelf.cjs' ) ;
33
44const Wallet = AElf . wallet ;
5- const {
6- sha256
7- } = AElf . utils ;
5+ const { sha256 } = AElf . utils ;
86
97// address: 2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX
108const defaultPrivateKey = 'bdb3b39ef4cd18c2697a920eb6d9e8c3cf1a930570beb37d04fb52400092c42b' ;
@@ -41,29 +39,35 @@ const lotteryContract = aelf.chain.contractAt(lotteryContractAddress, wallet, {
4139 sync : true
4240} ) ;
4341
44- const initialize = lotteryContract . Initialize ( {
45- sponsor : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
46- startPeriod : 0 ,
47- startTimestamp : {
48- seconds : ( new Date ( ) ) . getTime ( ) / 1000
42+ const initialize = lotteryContract . Initialize (
43+ {
44+ sponsor : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
45+ startPeriod : 0 ,
46+ startTimestamp : {
47+ seconds : new Date ( ) . getTime ( ) / 1000
48+ } ,
49+ tokenSymbol : 'ELF' ,
50+ ready : true
4951 } ,
50- tokenSymbol : 'ELF' ,
51- ready : true ,
52- } , {
53- sync : true
54- } ) ;
52+ {
53+ sync : true
54+ }
55+ ) ;
5556
5657console . log ( 'initialInfo' , initialize ) ;
5758
5859try {
59- "Error" : "\nAElf.Sdk.CSharp.AssertionException: No record now.\n'
60- let records = lotteryContract . GetRecord . call ( {
61- offset : 0 ,
62- limit : 10
63- } , {
64- sync : true
65- } ) ;
66- } catch ( e ) {
60+ // "Error": "\nAElf.Sdk.CSharp.AssertionException: No record now.\n'
61+ let records = lotteryContract . GetRecord . call (
62+ {
63+ offset : 0 ,
64+ limit : 10
65+ } ,
66+ {
67+ sync : true
68+ }
69+ ) ;
70+ } catch ( e ) {
6771 // 错误返回不合适
6872 // { Code: '20008',
6973 // Message: 'Invalid transaction information',
@@ -74,33 +78,42 @@ try {
7478
7579// init: bf1fca5468599d2e04b24848fb498e2976fa6c976cfcb31540409df40bddd01c
7680// noRecord: bc196d94ed41890886534ba824a325728eeb5f818b328db3079a94b3ea79d555
77- lotteryContract . GetRecord ( {
78- offset : 0 ,
79- limit : 10
80- } , {
81- sync : true
82- } ) ;
81+ lotteryContract . GetRecord (
82+ {
83+ offset : 0 ,
84+ limit : 10
85+ } ,
86+ {
87+ sync : true
88+ }
89+ ) ;
8390
84- var record = lotteryContract . GetRecord . call ( {
85- offset : 0 ,
86- limit : 10
87- } , {
88- sync : true
89- } ) ;
91+ var record = lotteryContract . GetRecord . call (
92+ {
93+ offset : 0 ,
94+ limit : 10
95+ } ,
96+ {
97+ sync : true
98+ }
99+ ) ;
90100console . log ( JSON . stringify ( record ) ) ;
91101
92102// 开启新的一轮
93- let peroid = lotteryContract . NewPeriod ( {
94- periodNumber : 1 ,
95- // bc6672baf5e4984f4f1e0fbe698d170e07ebe8a29320cce17a899495dcd391d0
96- randomNumberToken : '7e55bbc211171e48131d8ff7c8c2b38def7923ab717011066658b90219c1cae6' // 0
97- } , {
98- sync : true
99- } ) ;
103+ let peroid = lotteryContract . NewPeriod (
104+ {
105+ periodNumber : 1 ,
106+ // bc6672baf5e4984f4f1e0fbe698d170e07ebe8a29320cce17a899495dcd391d0
107+ randomNumberToken : '7e55bbc211171e48131d8ff7c8c2b38def7923ab717011066658b90219c1cae6' // 0
108+ } ,
109+ {
110+ sync : true
111+ }
112+ ) ;
100113
101- lotteryContract . GetLuckyNumber ( { sync : true } ) ;
114+ lotteryContract . GetLuckyNumber ( { sync : true } ) ;
102115
103- lotteryContract . GetState . call ( { sync : true } ) ;
116+ lotteryContract . GetState . call ( { sync : true } ) ;
104117
105118// message Lotteries {
106119// repeated Lottery lottery = 1;
@@ -123,33 +136,42 @@ for (let i = 0; i <= 9; i++) {
123136 } ) ;
124137}
125138
126- lotteryContract . Bet ( {
127- salerAddress : '2C2Acy4saYsnkRYEf54VawvmvUTAvrrWHKbLSwLg33b26woJVu' ,
128- proportionSale : 5 ,
129- proportionBonus : 5 ,
130- targetPeriod : 0 ,
131- senderAddress : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
132- lottery
133- } , { sync : true } ) ;
134-
135- lotteryContract . Bet ( {
136- salerAddress : '2C2Acy4saYsnkRYEf54VawvmvUTAvrrWHKbLSwLg33b26woJVu' ,
137- proportionSale : 5 ,
138- proportionBonus : 5 ,
139- targetPeriod : 1 ,
140- senderAddress : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
141- lottery : [
142- { type : 1 , value : [ 0 , 0 , 0 , 0 , 3 ] } ,
143- { type : 1 , value : [ 0 , 0 , 0 , 0 , 4 ] } ,
144- { type : 1 , value : [ 0 , 0 , 0 , 0 , 5 ] } ,
145- ]
146- } , { sync : true } ) ;
139+ lotteryContract . Bet (
140+ {
141+ salerAddress : '2C2Acy4saYsnkRYEf54VawvmvUTAvrrWHKbLSwLg33b26woJVu' ,
142+ proportionSale : 5 ,
143+ proportionBonus : 5 ,
144+ targetPeriod : 0 ,
145+ senderAddress : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
146+ lottery
147+ } ,
148+ { sync : true }
149+ ) ;
150+
151+ lotteryContract . Bet (
152+ {
153+ salerAddress : '2C2Acy4saYsnkRYEf54VawvmvUTAvrrWHKbLSwLg33b26woJVu' ,
154+ proportionSale : 5 ,
155+ proportionBonus : 5 ,
156+ targetPeriod : 1 ,
157+ senderAddress : '2hxkDg6Pd2d4yU1A16PTZVMMrEDYEPR8oQojMDwWdax5LsBaxX' ,
158+ lottery : [
159+ { type : 1 , value : [ 0 , 0 , 0 , 0 , 3 ] } ,
160+ { type : 1 , value : [ 0 , 0 , 0 , 0 , 4 ] } ,
161+ { type : 1 , value : [ 0 , 0 , 0 , 0 , 5 ] }
162+ ]
163+ } ,
164+ { sync : true }
165+ ) ;
147166
148167lotteryContract . TakeReward ( 'a24fec480944c16f0ed250cb3412e2b27312afc59adad6941adb20eb08b1a3c9' , {
149168 sync : true
150169} ) ;
151170
152- console . log ( 'tx' , aelf . chain . getTxResult ( '4c12bd187803fa1b63ac5794f614496154454725aa6c6747c890cdab39708e02' , {
153- sync : true
154- } ) ) ;
171+ console . log (
172+ 'tx' ,
173+ aelf . chain . getTxResult ( '4c12bd187803fa1b63ac5794f614496154454725aa6c6747c890cdab39708e02' , {
174+ sync : true
175+ } )
176+ ) ;
155177console . log ( 'RandomToken' , RandomToken ) ;
0 commit comments