tx · E9K8M7KeZ2xZ9DLpZBrZHq5cygVAmtNXsJgVPkfNx88A 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX: -0.05000000 Waves 2019.10.29 15:37 [741438] smart account 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX > SELF 0.00000000 Waves
{ "type": 13, "id": "E9K8M7KeZ2xZ9DLpZBrZHq5cygVAmtNXsJgVPkfNx88A", "fee": 5000000, "feeAssetId": null, "timestamp": 1572352661583, "version": 1, "sender": "3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX", "senderPublicKey": "ACfUG5PwG2GssMuyEwVEhkYAbbbP1geSHR8XoNxLyu6V", "proofs": [ "3yPDDoWdpq7ePYfh3DRXqeA3aSQoxVjJb3FxMaAQbYQsAiR3SCrpNhLX1ykqrmFbPAQjwCThdsY7eUzdoE1NapdA" ], "script": "base64:AAIDAAAAAAAAAAwIARIDCgEIEgMKAQgAAAAiAAAAAAlSU0FQVUJMSUMJAAJbAAAAAQIAAAGPYmFzZTY0Ok1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBZzRkQVI2WGJCREFTOWhyL0VqM2RKdjZGZmM0NjZ4L21PR01XVTNsckFCczNxYThCSG11Skdua2ZicEVmMnZBd1lUT1dQdnZ6Zk0xME9CYmZsb1N5cTNjOU1LdnlUZTFsdUJMR3FXNHZaVVhJeXZTZ3oxbGl5VVZlZklReTNkeUY5amJlVFpiQzBiYmNULzdPM0RFTCswMXo2QStyRENhY1NaMGxHb2xTUTZBbmhMeHpJa1ZwT1FKYnJCbUMreCtadVpQQ01Xekp5bmQ1YWVPbjdqYWovbWtSVnl4ZTZnLzBPaFd6NE5paVpYZXVNUkIrOG1LeTBmV0QvVWxJbFpXSHNBUzJabXJrWEtxakxxMC8wd3I4SUxKa3pualNxZG5JNUliamczdVFyai80QU4raTlyMjhhUTczL1prUHRZNVNidzBBT2lBQkJ1N2dIbXE5YXlWeFpRSURBUUFCAAAA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JBQAAAA5TVEFURVNVQk1JVFRFRAUAAAAGcGFDb2luBQAAAA9wbGF5ZXJBUHViS2V5NTgFAAAAB3BheVR5cGUIBQAAAAdwYXltZW50AAAABmFtb3VudAUAAAAGd2luQW10AgAAAAACAAAAAAIAAAAACQEAAAAMU2NyaXB0UmVzdWx0AAAAAgkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAPR0FNRVNDT1VOVEVSS0VZBQAAAApuZXdHYW1lTnVtCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAAZnYW1lSWQFAAAAC2dhbWVEYXRhU3RyBQAAAANuaWwJAQAAAAtUcmFuc2ZlclNldAAAAAEFAAAAA25pbAAAAAFpAQAAABNjYW5jZWxDb2luQ2hhbGxlbmdlAAAAAQAAAAZnYW1lSWQEAAAADGdhbWVEYXRhTGlzdAkBAAAAE0V4dHJhY3RHYW1lRGF0YUxpc3QAAAABBQAAAAZnYW1lSWQJAAACAAAAAQIAAAAGYXNkYXNkAAAAAHY19PI=", "chainId": 84, "height": 741438, "spentComplexity": 0 } View: original | compacted Prev: HSXCuSBoqLK2amHT72gN7Lt2UARLmaLP1hiD74hHfEXW Next: CBf5MMqUGzr2W74fyEG1D7ERGR6V8RST6qRAejNtfMCb Diff:
Old | New | Differences | |
---|---|---|---|
137 | 137 | ||
138 | 138 | ||
139 | 139 | func ExtractGameDataList (gameId) = { | |
140 | - | let rawDataStr = match getString(this, gameId) { | |
141 | - | case str: String => | |
142 | - | str | |
143 | - | case _ => | |
144 | - | throw(("Couldn't find game by " + gameId)) | |
145 | - | } | |
146 | - | ParseGameRawDataStr(rawDataStr) | |
140 | + | let rawDataStr = getStringValue(this, gameId) | |
141 | + | throw(rawDataStr) | |
147 | 142 | } | |
148 | 143 | ||
149 | 144 | ||
189 | 184 | ||
190 | 185 | ||
191 | 186 | @Callable(i) | |
192 | - | func acceptCoinChallenge (gameId,rsaSig) = { | |
193 | - | let gameDataList = ExtractGameDataList(gameId) | |
194 | - | let gameState = gameDataList[IdxGameState] | |
195 | - | let paCoin = gameDataList[IdxPlayerACoin] | |
196 | - | let paPubKey58 = gameDataList[IdxPlayerAPubKey58] | |
197 | - | let payType = gameDataList[IdxPayType] | |
198 | - | let payAmt = parseIntValue(gameDataList[IdxPayAmt]) | |
199 | - | let winAmt = parseIntValue(gameDataList[IdxWinAmt]) | |
200 | - | let payment = extract(i.payment) | |
201 | - | let feeAssetId = isDefined(i.feeAssetId) | |
202 | - | let pbPubKey58 = toBase58String(i.callerPublicKey) | |
203 | - | let payTypeB = paymentType(payment) | |
204 | - | if (if ((payment.assetId != assetInfo(base58'WAVES'))) | |
205 | - | then (payment.assetId != WBET) | |
206 | - | else false) | |
207 | - | then throw("Payment should be in Wbet or Waves. Game aborted.") | |
208 | - | else if (feeAssetId) | |
209 | - | then throw("Transaction's fee must be in Waves. Game aborted.") | |
210 | - | else if ((paPubKey58 == pbPubKey58)) | |
211 | - | then throw("You can't accept a challenge created by yourself. Game aborted.") | |
212 | - | else if ((payType != payTypeB)) | |
213 | - | then throw("Payment must be made in the same currency token as the bet, WBET/WBET or WAVES/WAVES. Game aborted.") | |
214 | - | else if ((payAmt != payment.amount)) | |
215 | - | then throw("Payout must be equal to the challenger bet amount. Game aborted.") | |
216 | - | else if ((gameState != STATESUBMITTED)) | |
217 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
218 | - | else { | |
219 | - | let rand = generateNumber(i, 100, 0) | |
220 | - | let luckyCoin = if ((rand > 50)) | |
221 | - | then COINRED | |
222 | - | else COINBLUE | |
223 | - | let pbCoin = if ((paCoin == COINRED)) | |
224 | - | then COINBLUE | |
225 | - | else COINRED | |
226 | - | let newGameDataStr = FormatGameDataStr(STATEACCEPTED, paCoin, paPubKey58, payType, payAmt, winAmt, pbCoin, pbPubKey58, luckyCoin) | |
227 | - | ScriptResult(WriteSet([DataEntry(gameId, newGameDataStr)]), TransferSet(nil)) | |
228 | - | } | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | 187 | func cancelCoinChallenge (gameId) = { | |
235 | 188 | let gameDataList = ExtractGameDataList(gameId) | |
236 | 189 | throw("asdasd") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAg4dAR6XbBDAS9hr/Ej3dJv6Ffc466x/mOGMWU3lrABs3qa8BHmuJGnkfbpEf2vAwYTOWPvvzfM10OBbfloSyq3c9MKvyTe1luBLGqW4vZUXIyvSgz1liyUVefIQy3dyF9jbeTZbC0bbcT/7O3DEL+01z6A+rDCacSZ0lGolSQ6AnhLxzIkVpOQJbrBmC+x+ZuZPCMWzJynd5aeOn7jaj/mkRVyxe6g/0OhWz4NiiZXeuMRB+8mKy0fWD/UlIlZWHsAS2ZmrkXKqjLq0/0wr8ILJkznjSqdnI5Ibjg3uQrj/4AN+i9r28aQ73/ZkPtY5Sbw0AOiABBu7gHmq9ayVxZQIDAQAB") | |
5 | 5 | ||
6 | 6 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
7 | 7 | ||
8 | 8 | let WBET = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
9 | 9 | ||
10 | 10 | let FEEWAVESBET = 4 | |
11 | 11 | ||
12 | 12 | let FEEMCAFEE = 2 | |
13 | 13 | ||
14 | 14 | let WAVELET = 100000000 | |
15 | 15 | ||
16 | 16 | let STATESUBMITTED = "SUBMITTED" | |
17 | 17 | ||
18 | 18 | let STATEACCEPTED = "ACCEPTED" | |
19 | 19 | ||
20 | 20 | let STATEFINISHED = "FINISHED" | |
21 | 21 | ||
22 | 22 | let STATECANCELED = "CANCELED" | |
23 | 23 | ||
24 | 24 | let COINRED = "RED" | |
25 | 25 | ||
26 | 26 | let COINBLUE = "BLUE" | |
27 | 27 | ||
28 | 28 | let BETMINWAVES = ((1 * WAVELET) / 2) | |
29 | 29 | ||
30 | 30 | let BETMINWBET = (100 * WAVELET) | |
31 | 31 | ||
32 | 32 | let IdxGameState = 0 | |
33 | 33 | ||
34 | 34 | let IdxPlayerACoin = 1 | |
35 | 35 | ||
36 | 36 | let IdxPlayerAPubKey58 = 2 | |
37 | 37 | ||
38 | 38 | let IdxPayType = 3 | |
39 | 39 | ||
40 | 40 | let IdxPayAmt = 4 | |
41 | 41 | ||
42 | 42 | let IdxWinAmt = 5 | |
43 | 43 | ||
44 | 44 | let IdxPlayerBCoin = 6 | |
45 | 45 | ||
46 | 46 | let IdxPlayerBPubKey58 = 7 | |
47 | 47 | ||
48 | 48 | let IdxLuckyCoin = 8 | |
49 | 49 | ||
50 | 50 | func IncrementGameNum () = { | |
51 | 51 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
52 | 52 | case num: Int => | |
53 | 53 | num | |
54 | 54 | case _ => | |
55 | 55 | 0 | |
56 | 56 | } | |
57 | 57 | (gameNum + 1) | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func generateNumber (inv,max,min) = { | |
62 | 62 | let lastPlay = match getBinary(this, "lastPlay") { | |
63 | 63 | case s: ByteVector => | |
64 | 64 | s | |
65 | 65 | case a: Unit => | |
66 | 66 | base58'2ee4oFDYriWJ9EMeR' | |
67 | 67 | case _ => | |
68 | 68 | throw() | |
69 | 69 | } | |
70 | 70 | let rand = (((((lastPlay + inv.transactionId) + inv.callerPublicKey) + lastBlock.generationSignature) + toBytes(lastBlock.timestamp)) + toBytes(lastBlock.height)) | |
71 | 71 | (((toInt(sha256(rand)) % 1000) % ((max - min) + 1)) + 1) | |
72 | 72 | } | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func paymentType (payment) = if ((payment.assetId == WBET)) | |
76 | 76 | then "WBET" | |
77 | 77 | else "WAVES" | |
78 | 78 | ||
79 | 79 | ||
80 | 80 | func tokenType (token) = if ((token == "WBET")) | |
81 | 81 | then WBET | |
82 | 82 | else unit | |
83 | 83 | ||
84 | 84 | ||
85 | 85 | func FormatGameDataParam (p) = { | |
86 | 86 | let s = size(p) | |
87 | 87 | if ((s == 0)) | |
88 | 88 | then throw("Parameter size must be greater then 0") | |
89 | 89 | else if ((s > 99)) | |
90 | 90 | then throw("Parameter size must be less then 100") | |
91 | 91 | else if ((10 > s)) | |
92 | 92 | then (("0" + toString(s)) + p) | |
93 | 93 | else (toString(s) + p) | |
94 | 94 | } | |
95 | 95 | ||
96 | 96 | ||
97 | 97 | func FormatGameDataStr (gameState,playerACoin,playerAPubKey58,payType,payAmount,winAmt,playerBCoin,playerBPubKey58,luckyCoin) = { | |
98 | 98 | let fullStateStr = ((((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(playerACoin)) + "_") + FormatGameDataParam(playerAPubKey58)) + "_") + FormatGameDataParam(payType)) + "_") + FormatGameDataParam(toString(payAmount))) + "_") + FormatGameDataParam(toString(winAmt))) | |
99 | 99 | if (if (if ((playerBCoin == "")) | |
100 | 100 | then true | |
101 | 101 | else (playerBPubKey58 == "")) | |
102 | 102 | then true | |
103 | 103 | else (luckyCoin == "")) | |
104 | 104 | then fullStateStr | |
105 | 105 | else ((((((fullStateStr + "_") + FormatGameDataParam(playerBCoin)) + "_") + FormatGameDataParam(playerBPubKey58)) + "_") + FormatGameDataParam(luckyCoin)) | |
106 | 106 | } | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0)) | |
110 | 110 | then drop(remaining, 1) | |
111 | 111 | else remaining | |
112 | 112 | ||
113 | 113 | ||
114 | 114 | func ParseNextAttribute (remaining) = { | |
115 | 115 | let s = size(remaining) | |
116 | 116 | if ((s > 0)) | |
117 | 117 | then { | |
118 | 118 | let nn = parseIntValue(take(remaining, 2)) | |
119 | 119 | let v = take(drop(remaining, 2), nn) | |
120 | 120 | let tmpRemaining = drop(remaining, (nn + 2)) | |
121 | 121 | let remainingState = RemoveUnderscoreIfPresent(tmpRemaining) | |
122 | 122 | [v, remainingState] | |
123 | 123 | } | |
124 | 124 | else throw("Empty string was passed into parseNextAttribute func") | |
125 | 125 | } | |
126 | 126 | ||
127 | 127 | ||
128 | 128 | func ParseGameRawDataStr (rawStateStr) = { | |
129 | 129 | let gameState = ParseNextAttribute(rawStateStr) | |
130 | 130 | let paCoin = ParseNextAttribute(gameState[1]) | |
131 | 131 | let paPubKey58 = ParseNextAttribute(paCoin[1]) | |
132 | 132 | let payType = ParseNextAttribute(paPubKey58[1]) | |
133 | 133 | let payAmt = ParseNextAttribute(payType[1]) | |
134 | 134 | let winAmt = ParseNextAttribute(payAmt[1]) | |
135 | 135 | [gameState[0], paCoin[0], paPubKey58[0], payType[0], payAmt[0], winAmt[0]] | |
136 | 136 | } | |
137 | 137 | ||
138 | 138 | ||
139 | 139 | func ExtractGameDataList (gameId) = { | |
140 | - | let rawDataStr = match getString(this, gameId) { | |
141 | - | case str: String => | |
142 | - | str | |
143 | - | case _ => | |
144 | - | throw(("Couldn't find game by " + gameId)) | |
145 | - | } | |
146 | - | ParseGameRawDataStr(rawDataStr) | |
140 | + | let rawDataStr = getStringValue(this, gameId) | |
141 | + | throw(rawDataStr) | |
147 | 142 | } | |
148 | 143 | ||
149 | 144 | ||
150 | 145 | func ValidateBetAndDefineWinAmt (amount,playerCoin,paymentType) = if (if ((playerCoin != COINRED)) | |
151 | 146 | then (playerCoin != COINBLUE) | |
152 | 147 | else false) | |
153 | 148 | then throw("Invalid play, change your bet to RED or BLUE coin. Game aborted.") | |
154 | 149 | else if (if ((paymentType == "WBET")) | |
155 | 150 | then (BETMINWBET > amount) | |
156 | 151 | else false) | |
157 | 152 | then throw(("The minimum bet on Wbet is " + toString((BETMINWBET / WAVELET)))) | |
158 | 153 | else if (if ((paymentType == "WAVES")) | |
159 | 154 | then (BETMINWAVES > amount) | |
160 | 155 | else false) | |
161 | 156 | then throw(("The minimum bet on Waves is " + toString((BETMINWAVES / WAVELET)))) | |
162 | 157 | else (((amount * 2) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
163 | 158 | ||
164 | 159 | ||
165 | 160 | @Callable(i) | |
166 | 161 | func playCoin (paCoin) = { | |
167 | 162 | let gameId = toBase58String(i.transactionId) | |
168 | 163 | let gameIdUsed = isDefined(getString(this, gameId)) | |
169 | 164 | let payment = extract(i.payment) | |
170 | 165 | let feeAssetId = isDefined(i.feeAssetId) | |
171 | 166 | if (if ((payment.assetId != assetInfo(base58'WAVES'))) | |
172 | 167 | then (payment.assetId != WBET) | |
173 | 168 | else false) | |
174 | 169 | then throw("Payment should be in Wbet or Waves. Game aborted.") | |
175 | 170 | else if (feeAssetId) | |
176 | 171 | then throw("Transaction's fee must be in Waves. Game aborted.") | |
177 | 172 | else if (gameIdUsed) | |
178 | 173 | then throw("Passed gameId had been used before. Game aborted.") | |
179 | 174 | else { | |
180 | 175 | let newGameNum = IncrementGameNum() | |
181 | 176 | let playerAPubKey58 = toBase58String(i.callerPublicKey) | |
182 | 177 | let payType = paymentType(payment) | |
183 | 178 | let winAmt = ValidateBetAndDefineWinAmt(payment.amount, paCoin, payType) | |
184 | 179 | let gameDataStr = FormatGameDataStr(STATESUBMITTED, paCoin, playerAPubKey58, payType, payment.amount, winAmt, "", "", "") | |
185 | 180 | ScriptResult(WriteSet([DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet(nil)) | |
186 | 181 | } | |
187 | 182 | } | |
188 | 183 | ||
189 | 184 | ||
190 | 185 | ||
191 | 186 | @Callable(i) | |
192 | - | func acceptCoinChallenge (gameId,rsaSig) = { | |
193 | - | let gameDataList = ExtractGameDataList(gameId) | |
194 | - | let gameState = gameDataList[IdxGameState] | |
195 | - | let paCoin = gameDataList[IdxPlayerACoin] | |
196 | - | let paPubKey58 = gameDataList[IdxPlayerAPubKey58] | |
197 | - | let payType = gameDataList[IdxPayType] | |
198 | - | let payAmt = parseIntValue(gameDataList[IdxPayAmt]) | |
199 | - | let winAmt = parseIntValue(gameDataList[IdxWinAmt]) | |
200 | - | let payment = extract(i.payment) | |
201 | - | let feeAssetId = isDefined(i.feeAssetId) | |
202 | - | let pbPubKey58 = toBase58String(i.callerPublicKey) | |
203 | - | let payTypeB = paymentType(payment) | |
204 | - | if (if ((payment.assetId != assetInfo(base58'WAVES'))) | |
205 | - | then (payment.assetId != WBET) | |
206 | - | else false) | |
207 | - | then throw("Payment should be in Wbet or Waves. Game aborted.") | |
208 | - | else if (feeAssetId) | |
209 | - | then throw("Transaction's fee must be in Waves. Game aborted.") | |
210 | - | else if ((paPubKey58 == pbPubKey58)) | |
211 | - | then throw("You can't accept a challenge created by yourself. Game aborted.") | |
212 | - | else if ((payType != payTypeB)) | |
213 | - | then throw("Payment must be made in the same currency token as the bet, WBET/WBET or WAVES/WAVES. Game aborted.") | |
214 | - | else if ((payAmt != payment.amount)) | |
215 | - | then throw("Payout must be equal to the challenger bet amount. Game aborted.") | |
216 | - | else if ((gameState != STATESUBMITTED)) | |
217 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
218 | - | else { | |
219 | - | let rand = generateNumber(i, 100, 0) | |
220 | - | let luckyCoin = if ((rand > 50)) | |
221 | - | then COINRED | |
222 | - | else COINBLUE | |
223 | - | let pbCoin = if ((paCoin == COINRED)) | |
224 | - | then COINBLUE | |
225 | - | else COINRED | |
226 | - | let newGameDataStr = FormatGameDataStr(STATEACCEPTED, paCoin, paPubKey58, payType, payAmt, winAmt, pbCoin, pbPubKey58, luckyCoin) | |
227 | - | ScriptResult(WriteSet([DataEntry(gameId, newGameDataStr)]), TransferSet(nil)) | |
228 | - | } | |
229 | - | } | |
230 | - | ||
231 | - | ||
232 | - | ||
233 | - | @Callable(i) | |
234 | 187 | func cancelCoinChallenge (gameId) = { | |
235 | 188 | let gameDataList = ExtractGameDataList(gameId) | |
236 | 189 | throw("asdasd") | |
237 | 190 | } | |
238 | 191 | ||
239 | 192 |
github/deemru/w8io/026f985 34.68 ms ◑