tx · 6TN2UzpqopB3uUh2yy3JFYP8b1zyZEENLuwLShTAgsfL 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX: -0.05000000 Waves 2019.10.28 06:57 [739439] smart account 3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX > SELF 0.00000000 Waves
{ "type": 13, "id": "6TN2UzpqopB3uUh2yy3JFYP8b1zyZEENLuwLShTAgsfL", "fee": 5000000, "feeAssetId": null, "timestamp": 1572235133276, "version": 1, "sender": "3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX", "senderPublicKey": "ACfUG5PwG2GssMuyEwVEhkYAbbbP1geSHR8XoNxLyu6V", "proofs": [ "QCoooMUFjLDr2N92cvKkdWwApjT2hqtiKbpuHTbvrCvqx3dX8h6gzH7PaJb83XiQjRKPB8HigNH1zG9DC1DeQP7" ], "script": "base64:AAIDAAAAAAAAAAkIARIFCgMIAQIAAAAUAAAAAAlSU0FQVUJMSUMJAAJbAAAAAQIAAAGPYmFzZTY0Ok1JSUJJakFOQmdrcWhraUc5dzBCQVFFRkFBT0NBUThBTUlJQkNnS0NBUUVBZzRkQVI2WGJCREFTOWhyL0VqM2RKdjZGZmM0NjZ4L21PR01XVTNsckFCczNxYThCSG11Skdua2ZicEVmMnZBd1lUT1dQdnZ6Zk0xME9CYmZsb1N5cTNjOU1LdnlUZTFsdUJMR3FXNHZaVVhJeXZTZ3oxbGl5VVZlZklReTNkeUY5amJlVFpiQzBiYmNULzdPM0RFTCswMXo2QStyRENhY1NaMGxHb2xTUTZBbmhMeHpJa1ZwT1FKYnJCbUMreCtadVpQQ01Xekp5bmQ1YWVPbjdqYWovbWtSVnl4ZTZnLzBPaFd6NE5paVpYZXVNUkIrOG1LeTBmV0QvVWxJbFpXSHNBUzJabXJrWEtxakxxMC8wd3I4SUxKa3pualNxZG5JNUliamczdVFyai80QU4raTlyMjhhUTczL1prUHRZNVNidzBBT2lBQkJ1N2dIbXE5YXlWeFpRSURBUUFCAAAAAA9HQU1FU0NPV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5cGUAAAAAAAAAAAAEAAAACm5ld0dhbWVOdW0JAQAAABBJbmNyZW1lbnRHYW1lTnVtAAAAAAQAAAAHYmV0RGF0YQkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgUAAAAGZ2FtZUlkAwUAAAAGcmVzdWx0BQAAAAhTVEFURVdPTgUAAAAJU1RBVEVMT1NUCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAA9HQU1FU0NPVU5URVJLRVkFAAAACm5ld0dhbWVOdW0JAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAICAAAABnJhbmRvbQUAAAAEcmFuZAkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgIAAAAHcGF5bWVudAgFAAAAB3BheW1lbnQAAAAGYW1vdW50CQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACAgAAAAZwYXlvdXQFAAAABndpbkFtdAUAAAADbmlsAwUAAAAGcmVzdWx0CQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAAHYmV0RGF0YQkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABndpbkFtdAUAAAAEV0JFVAUAAAADbmlsCQEAAAAMU2NyaXB0UmVzdWx0AAAAAgUAAAAHYmV0RGF0YQkBAAAAC1RyYW5zZmVyU2V0AAAAAQUAAAADbmlsAAAAABC9Bis=", "chainId": 84, "height": 739439, "spentComplexity": 0 } View: original | compacted Prev: cMaULSV56FZE8qkZt5n5f6sF3hnKaXj2gD6UZCWzwwJ Next: C7EMUrbJvfo1YZd8n7fR7Lkr2Pw1skyDk2qsFFN93Kwz Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
7 | 7 | ||
8 | - | let RESERVATIONKEY = "$RESERVED_AMOUNT" | |
9 | - | ||
10 | 8 | let WBET = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
11 | - | ||
12 | - | let WAVELET = ((100 * 1000) * 1000) | |
13 | 9 | ||
14 | 10 | let FEEWAVESBET = 4 | |
15 | 11 | ||
16 | 12 | let FEEMCAFEE = 2 | |
17 | 13 | ||
18 | - | let | |
14 | + | let WAVELET = 100000000 | |
19 | 15 | ||
20 | 16 | let STATEWON = "WON" | |
21 | 17 | ||
33 | 29 | ||
34 | 30 | let PREDICTIONMAX = 99 | |
35 | 31 | ||
36 | - | let IdxGameState = 0 | |
37 | - | ||
38 | - | let IdxPrediction = 1 | |
39 | - | ||
40 | - | let IdxType = 2 | |
41 | - | ||
42 | - | let IdxPlayerPubKey58 = 3 | |
43 | - | ||
44 | - | let IdxWinAmt = 4 | |
45 | - | ||
46 | - | let IdxRandOrEmpty = 5 | |
47 | - | ||
48 | 32 | func IncrementGameNum () = { | |
49 | 33 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
50 | 34 | case num: Int => | |
53 | 37 | 0 | |
54 | 38 | } | |
55 | 39 | (gameNum + 1) | |
56 | - | } | |
57 | - | ||
58 | - | ||
59 | - | func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) { | |
60 | - | case a: Int => | |
61 | - | a | |
62 | - | case _ => | |
63 | - | 0 | |
64 | - | } | |
65 | - | ||
66 | - | ||
67 | - | func ValidateAndIncreaseReservedAmt (winAmt) = { | |
68 | - | let newReservedAmount = (ExtractReservedAmt() + winAmt) | |
69 | - | let balance = assetBalance(this, WBET) | |
70 | - | if ((newReservedAmount > balance)) | |
71 | - | then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.") | |
72 | - | else newReservedAmount | |
73 | - | } | |
74 | - | ||
75 | - | ||
76 | - | func FormatGameDataParam (p) = { | |
77 | - | let s = size(p) | |
78 | - | if ((s == 0)) | |
79 | - | then throw("Parameter size must be greater then 0") | |
80 | - | else if ((s > 99)) | |
81 | - | then throw("Parameter size must be less then 100") | |
82 | - | else if ((10 > s)) | |
83 | - | then (("0" + toString(s)) + p) | |
84 | - | else (toString(s) + p) | |
85 | - | } | |
86 | - | ||
87 | - | ||
88 | - | func FormatGameDataStr (gameState,prediction,typeRoll,playerPubKey58,winAmt,randOrEmpty) = { | |
89 | - | let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(toString(prediction))) + "_") + FormatGameDataParam(typeRoll)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(winAmt))) | |
90 | - | if ((randOrEmpty == "")) | |
91 | - | then fullStateStr | |
92 | - | else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty)) | |
93 | - | } | |
94 | - | ||
95 | - | ||
96 | - | func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0)) | |
97 | - | then drop(remaining, 1) | |
98 | - | else remaining | |
99 | - | ||
100 | - | ||
101 | - | func ParseNextAttribute (remaining) = { | |
102 | - | let s = size(remaining) | |
103 | - | if ((s > 0)) | |
104 | - | then { | |
105 | - | let nn = parseIntValue(take(remaining, 2)) | |
106 | - | let v = take(drop(remaining, 2), nn) | |
107 | - | let tmpRemaining = drop(remaining, (nn + 2)) | |
108 | - | let remainingState = RemoveUnderscoreIfPresent(tmpRemaining) | |
109 | - | [v, remainingState] | |
110 | - | } | |
111 | - | else throw("Empty string was passed into parseNextAttribute func") | |
112 | - | } | |
113 | - | ||
114 | - | ||
115 | - | func ParseGameRawDataStr (rawStateStr) = { | |
116 | - | let gameState = ParseNextAttribute(rawStateStr) | |
117 | - | let prediction = ParseNextAttribute(gameState[1]) | |
118 | - | let rollType = ParseNextAttribute(prediction[1]) | |
119 | - | let playerPubKey58 = ParseNextAttribute(rollType[1]) | |
120 | - | let winAmt = ParseNextAttribute(playerPubKey58[1]) | |
121 | - | [gameState[0], prediction[0], rollType[0], playerPubKey58[0], winAmt[0]] | |
122 | - | } | |
123 | - | ||
124 | - | ||
125 | - | func ExtractGameDataList (gameId) = { | |
126 | - | let rawDataStr = match getString(this, gameId) { | |
127 | - | case str: String => | |
128 | - | str | |
129 | - | case _ => | |
130 | - | throw(("Couldn't find game by " + gameId)) | |
131 | - | } | |
132 | - | ParseGameRawDataStr(rawDataStr) | |
133 | - | } | |
134 | - | ||
135 | - | ||
136 | - | func DecreaseReservedAmt (gameId,winAmt) = { | |
137 | - | let newReservedAmount = (ExtractReservedAmt() - winAmt) | |
138 | - | if ((0 > newReservedAmount)) | |
139 | - | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
140 | - | else DataEntry(RESERVATIONKEY, newReservedAmount) | |
141 | 40 | } | |
142 | 41 | ||
143 | 42 | ||
159 | 58 | else false) | |
160 | 59 | then toString(r) | |
161 | 60 | else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(r))) | |
162 | - | ||
163 | - | ||
164 | - | func WinScriptSet (gameId,playerAddress,winAmt,newGameDataStr,decreasedReserves) = { | |
165 | - | let wSetCommonData = [decreasedReserves] | |
166 | - | let tSetCommonData = [ScriptTransfer(playerAddress, winAmt, WBET)] | |
167 | - | let gameData = DataEntry(gameId, newGameDataStr) | |
168 | - | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
169 | - | } | |
170 | 61 | ||
171 | 62 | ||
172 | 63 | func Multiplier (prediction,rollType) = if ((rollType == ROLLUNDER)) | |
560 | 451 | else 100000 | |
561 | 452 | ||
562 | 453 | ||
563 | - | func diceWin (type,prediction, | |
564 | - | then if ((prediction >= | |
454 | + | func diceWin (type,prediction,rand) = if ((type == ROLLUNDER)) | |
455 | + | then if ((prediction >= rand)) | |
565 | 456 | then true | |
566 | 457 | else false | |
567 | 458 | else if ((type == ROLLOVER)) | |
568 | - | then if (( | |
459 | + | then if ((rand >= prediction)) | |
569 | 460 | then true | |
570 | 461 | else false | |
571 | 462 | else false | |
590 | 481 | ||
591 | 482 | ||
592 | 483 | @Callable(i) | |
593 | - | func playDice (rollType,prediction) = { | |
484 | + | func playDice (rollType,prediction,rsaSig) = { | |
594 | 485 | let gameId = toBase58String(i.transactionId) | |
595 | 486 | let payment = extract(i.payment) | |
596 | 487 | let feeAssetId = isDefined(i.feeAssetId) | |
597 | - | let multi = Multiplier(prediction, rollType) | |
598 | - | let winAmt = ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType) | |
599 | 488 | let playerBalance = wavesBalance(i.caller) | |
600 | 489 | let gameIdUsed = isDefined(getString(this, gameId)) | |
601 | 490 | if ((payment.assetId != WBET)) | |
602 | - | then throw("Payment should be in Wavesbet") | |
603 | - | else if (( | |
604 | - | then throw("There are not enough waves, it takes 0. | |
491 | + | then throw("Payment should be in Wavesbet. Game aborted.") | |
492 | + | else if ((500000 > playerBalance)) | |
493 | + | then throw("There are not enough waves, it takes 0.005 Waves to bet. Game aborted.") | |
605 | 494 | else if (feeAssetId) | |
606 | 495 | then throw("Transaction's fee must be in Waves. Game aborted.") | |
607 | 496 | else if (gameIdUsed) | |
608 | 497 | then throw("Passed gameId had been used before. Game aborted.") | |
609 | 498 | else { | |
499 | + | let rand = GenerateRandInt(gameId, rsaSig) | |
500 | + | let randStr = RandToStr(rand) | |
501 | + | let result = diceWin(rollType, prediction, rand) | |
502 | + | let winAmt = if (result) | |
503 | + | then ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType) | |
504 | + | else 0 | |
610 | 505 | let newGameNum = IncrementGameNum() | |
611 | - | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
612 | - | let gameDataStr = FormatGameDataStr(STATESUBMITTED, prediction, rollType, playerPubKey58, winAmt, "") | |
613 | - | ScriptResult(WriteSet([DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet(nil)) | |
506 | + | let betData = WriteSet([DataEntry(gameId, if (result) | |
507 | + | then STATEWON | |
508 | + | else STATELOST), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry("random", rand), DataEntry("payment", payment.amount), DataEntry("payout", winAmt)]) | |
509 | + | if (result) | |
510 | + | then ScriptResult(betData, TransferSet([ScriptTransfer(i.caller, winAmt, WBET)])) | |
511 | + | else ScriptResult(betData, TransferSet(nil)) | |
614 | 512 | } | |
615 | 513 | } | |
616 | 514 | ||
617 | - | ||
618 | - | ||
619 | - | @Callable(i) | |
620 | - | func withdraw (gameId,rsaSig) = { | |
621 | - | let gameDataList = ExtractGameDataList(gameId) | |
622 | - | let gameState = gameDataList[IdxGameState] | |
623 | - | let prediction = parseIntValue(gameDataList[IdxPrediction]) | |
624 | - | let rollType = gameDataList[IdxType] | |
625 | - | let winAmt = parseIntValue(gameDataList[IdxWinAmt]) | |
626 | - | let playerPubKey58 = gameDataList[IdxPlayerPubKey58] | |
627 | - | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
628 | - | let decreasedReserves = DecreaseReservedAmt(gameId, winAmt) | |
629 | - | if ((gameState != STATESUBMITTED)) | |
630 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
631 | - | else { | |
632 | - | let rand = GenerateRandInt(gameId, rsaSig) | |
633 | - | let randStr = RandToStr(rand) | |
634 | - | if (diceWin(rollType, prediction, rand)) | |
635 | - | then { | |
636 | - | let newGameDataStr = FormatGameDataStr(STATEWON, prediction, rollType, playerPubKey58, winAmt, randStr) | |
637 | - | WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, decreasedReserves) | |
638 | - | } | |
639 | - | else { | |
640 | - | let newGameDataStr = FormatGameDataStr(STATELOST, prediction, rollType, playerPubKey58, winAmt, randStr) | |
641 | - | WriteSet([DataEntry(gameId, newGameDataStr), decreasedReserves]) | |
642 | - | } | |
643 | - | } | |
644 | - | } | |
645 | - | ||
646 | - | ||
647 | - | @Verifier(tx) | |
648 | - | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
649 | - | then match tx { | |
650 | - | case ttx: TransferTransaction => | |
651 | - | ((assetBalance(this, WBET) - ttx.amount) >= ExtractReservedAmt()) | |
652 | - | case stx: SetScriptTransaction => | |
653 | - | true | |
654 | - | case itx: InvokeScriptTransaction => | |
655 | - | if ((itx.function == "withdraw")) | |
656 | - | then true | |
657 | - | else false | |
658 | - | case _ => | |
659 | - | false | |
660 | - | } | |
661 | - | else false | |
662 | 515 |
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 | - | let RESERVATIONKEY = "$RESERVED_AMOUNT" | |
9 | - | ||
10 | 8 | let WBET = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
11 | - | ||
12 | - | let WAVELET = ((100 * 1000) * 1000) | |
13 | 9 | ||
14 | 10 | let FEEWAVESBET = 4 | |
15 | 11 | ||
16 | 12 | let FEEMCAFEE = 2 | |
17 | 13 | ||
18 | - | let | |
14 | + | let WAVELET = 100000000 | |
19 | 15 | ||
20 | 16 | let STATEWON = "WON" | |
21 | 17 | ||
22 | 18 | let STATELOST = "LOST" | |
23 | 19 | ||
24 | 20 | let ROLLUNDER = "UNDER" | |
25 | 21 | ||
26 | 22 | let ROLLOVER = "OVER" | |
27 | 23 | ||
28 | 24 | let BETMIN = (100 * WAVELET) | |
29 | 25 | ||
30 | 26 | let BETMAX = (20000000 * WAVELET) | |
31 | 27 | ||
32 | 28 | let PREDICTIONMIN = 1 | |
33 | 29 | ||
34 | 30 | let PREDICTIONMAX = 99 | |
35 | 31 | ||
36 | - | let IdxGameState = 0 | |
37 | - | ||
38 | - | let IdxPrediction = 1 | |
39 | - | ||
40 | - | let IdxType = 2 | |
41 | - | ||
42 | - | let IdxPlayerPubKey58 = 3 | |
43 | - | ||
44 | - | let IdxWinAmt = 4 | |
45 | - | ||
46 | - | let IdxRandOrEmpty = 5 | |
47 | - | ||
48 | 32 | func IncrementGameNum () = { | |
49 | 33 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
50 | 34 | case num: Int => | |
51 | 35 | num | |
52 | 36 | case _ => | |
53 | 37 | 0 | |
54 | 38 | } | |
55 | 39 | (gameNum + 1) | |
56 | - | } | |
57 | - | ||
58 | - | ||
59 | - | func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) { | |
60 | - | case a: Int => | |
61 | - | a | |
62 | - | case _ => | |
63 | - | 0 | |
64 | - | } | |
65 | - | ||
66 | - | ||
67 | - | func ValidateAndIncreaseReservedAmt (winAmt) = { | |
68 | - | let newReservedAmount = (ExtractReservedAmt() + winAmt) | |
69 | - | let balance = assetBalance(this, WBET) | |
70 | - | if ((newReservedAmount > balance)) | |
71 | - | then throw("Insufficient funds on Wavesbet Dice account. Transaction was rejected for your safety.") | |
72 | - | else newReservedAmount | |
73 | - | } | |
74 | - | ||
75 | - | ||
76 | - | func FormatGameDataParam (p) = { | |
77 | - | let s = size(p) | |
78 | - | if ((s == 0)) | |
79 | - | then throw("Parameter size must be greater then 0") | |
80 | - | else if ((s > 99)) | |
81 | - | then throw("Parameter size must be less then 100") | |
82 | - | else if ((10 > s)) | |
83 | - | then (("0" + toString(s)) + p) | |
84 | - | else (toString(s) + p) | |
85 | - | } | |
86 | - | ||
87 | - | ||
88 | - | func FormatGameDataStr (gameState,prediction,typeRoll,playerPubKey58,winAmt,randOrEmpty) = { | |
89 | - | let fullStateStr = ((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(toString(prediction))) + "_") + FormatGameDataParam(typeRoll)) + "_") + FormatGameDataParam(playerPubKey58)) + "_") + FormatGameDataParam(toString(winAmt))) | |
90 | - | if ((randOrEmpty == "")) | |
91 | - | then fullStateStr | |
92 | - | else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty)) | |
93 | - | } | |
94 | - | ||
95 | - | ||
96 | - | func RemoveUnderscoreIfPresent (remaining) = if ((size(remaining) > 0)) | |
97 | - | then drop(remaining, 1) | |
98 | - | else remaining | |
99 | - | ||
100 | - | ||
101 | - | func ParseNextAttribute (remaining) = { | |
102 | - | let s = size(remaining) | |
103 | - | if ((s > 0)) | |
104 | - | then { | |
105 | - | let nn = parseIntValue(take(remaining, 2)) | |
106 | - | let v = take(drop(remaining, 2), nn) | |
107 | - | let tmpRemaining = drop(remaining, (nn + 2)) | |
108 | - | let remainingState = RemoveUnderscoreIfPresent(tmpRemaining) | |
109 | - | [v, remainingState] | |
110 | - | } | |
111 | - | else throw("Empty string was passed into parseNextAttribute func") | |
112 | - | } | |
113 | - | ||
114 | - | ||
115 | - | func ParseGameRawDataStr (rawStateStr) = { | |
116 | - | let gameState = ParseNextAttribute(rawStateStr) | |
117 | - | let prediction = ParseNextAttribute(gameState[1]) | |
118 | - | let rollType = ParseNextAttribute(prediction[1]) | |
119 | - | let playerPubKey58 = ParseNextAttribute(rollType[1]) | |
120 | - | let winAmt = ParseNextAttribute(playerPubKey58[1]) | |
121 | - | [gameState[0], prediction[0], rollType[0], playerPubKey58[0], winAmt[0]] | |
122 | - | } | |
123 | - | ||
124 | - | ||
125 | - | func ExtractGameDataList (gameId) = { | |
126 | - | let rawDataStr = match getString(this, gameId) { | |
127 | - | case str: String => | |
128 | - | str | |
129 | - | case _ => | |
130 | - | throw(("Couldn't find game by " + gameId)) | |
131 | - | } | |
132 | - | ParseGameRawDataStr(rawDataStr) | |
133 | - | } | |
134 | - | ||
135 | - | ||
136 | - | func DecreaseReservedAmt (gameId,winAmt) = { | |
137 | - | let newReservedAmount = (ExtractReservedAmt() - winAmt) | |
138 | - | if ((0 > newReservedAmount)) | |
139 | - | then throw("Invalid Dice Roller account state - reserved amount is less than 0") | |
140 | - | else DataEntry(RESERVATIONKEY, newReservedAmount) | |
141 | 40 | } | |
142 | 41 | ||
143 | 42 | ||
144 | 43 | func GenerateRandInt (gameId,rsaSign) = { | |
145 | 44 | let rsaSigValid = rsaVerify(SHA256, toBytes(gameId), rsaSign, RSAPUBLIC) | |
146 | 45 | if (rsaSigValid) | |
147 | 46 | then { | |
148 | 47 | let rand = (toInt(sha256(rsaSign)) % 100) | |
149 | 48 | if ((0 > rand)) | |
150 | 49 | then ((-1 * rand) + 1) | |
151 | 50 | else (rand + 1) | |
152 | 51 | } | |
153 | 52 | else throw("Invalid RSA signature") | |
154 | 53 | } | |
155 | 54 | ||
156 | 55 | ||
157 | 56 | func RandToStr (r) = if (if ((r >= 1)) | |
158 | 57 | then (100 >= r) | |
159 | 58 | else false) | |
160 | 59 | then toString(r) | |
161 | 60 | else throw(("Unsupported r parameter passed: expected=[1,...,100] actual=" + toString(r))) | |
162 | - | ||
163 | - | ||
164 | - | func WinScriptSet (gameId,playerAddress,winAmt,newGameDataStr,decreasedReserves) = { | |
165 | - | let wSetCommonData = [decreasedReserves] | |
166 | - | let tSetCommonData = [ScriptTransfer(playerAddress, winAmt, WBET)] | |
167 | - | let gameData = DataEntry(gameId, newGameDataStr) | |
168 | - | ScriptResult(WriteSet(gameData :: wSetCommonData), TransferSet(tSetCommonData)) | |
169 | - | } | |
170 | 61 | ||
171 | 62 | ||
172 | 63 | func Multiplier (prediction,rollType) = if ((rollType == ROLLUNDER)) | |
173 | 64 | then if ((prediction == 1)) | |
174 | 65 | then 9850000 | |
175 | 66 | else if ((prediction == 2)) | |
176 | 67 | then 4925000 | |
177 | 68 | else if ((prediction == 3)) | |
178 | 69 | then 3283330 | |
179 | 70 | else if ((prediction == 4)) | |
180 | 71 | then 2462500 | |
181 | 72 | else if ((prediction == 5)) | |
182 | 73 | then 1970000 | |
183 | 74 | else if ((prediction == 6)) | |
184 | 75 | then 1641660 | |
185 | 76 | else if ((prediction == 7)) | |
186 | 77 | then 1407140 | |
187 | 78 | else if ((prediction == 8)) | |
188 | 79 | then 1231250 | |
189 | 80 | else if ((prediction == 9)) | |
190 | 81 | then 1094440 | |
191 | 82 | else if ((prediction == 10)) | |
192 | 83 | then 985000 | |
193 | 84 | else if ((prediction == 11)) | |
194 | 85 | then 895450 | |
195 | 86 | else if ((prediction == 12)) | |
196 | 87 | then 820830 | |
197 | 88 | else if ((prediction == 13)) | |
198 | 89 | then 757690 | |
199 | 90 | else if ((prediction == 14)) | |
200 | 91 | then 703570 | |
201 | 92 | else if ((prediction == 15)) | |
202 | 93 | then 656660 | |
203 | 94 | else if ((prediction == 16)) | |
204 | 95 | then 615620 | |
205 | 96 | else if ((prediction == 17)) | |
206 | 97 | then 579410 | |
207 | 98 | else if ((prediction == 18)) | |
208 | 99 | then 547220 | |
209 | 100 | else if ((prediction == 19)) | |
210 | 101 | then 518420 | |
211 | 102 | else if ((prediction == 20)) | |
212 | 103 | then 492500 | |
213 | 104 | else if ((prediction == 21)) | |
214 | 105 | then 469040 | |
215 | 106 | else if ((prediction == 22)) | |
216 | 107 | then 447720 | |
217 | 108 | else if ((prediction == 23)) | |
218 | 109 | then 428260 | |
219 | 110 | else if ((prediction == 24)) | |
220 | 111 | then 410410 | |
221 | 112 | else if ((prediction == 25)) | |
222 | 113 | then 394000 | |
223 | 114 | else if ((prediction == 26)) | |
224 | 115 | then 378840 | |
225 | 116 | else if ((prediction == 27)) | |
226 | 117 | then 364810 | |
227 | 118 | else if ((prediction == 28)) | |
228 | 119 | then 351780 | |
229 | 120 | else if ((prediction == 29)) | |
230 | 121 | then 339650 | |
231 | 122 | else if ((prediction == 30)) | |
232 | 123 | then 328330 | |
233 | 124 | else if ((prediction == 31)) | |
234 | 125 | then 317740 | |
235 | 126 | else if ((prediction == 32)) | |
236 | 127 | then 307810 | |
237 | 128 | else if ((prediction == 33)) | |
238 | 129 | then 298480 | |
239 | 130 | else if ((prediction == 34)) | |
240 | 131 | then 289700 | |
241 | 132 | else if ((prediction == 35)) | |
242 | 133 | then 281420 | |
243 | 134 | else if ((prediction == 36)) | |
244 | 135 | then 273610 | |
245 | 136 | else if ((prediction == 37)) | |
246 | 137 | then 259210 | |
247 | 138 | else if ((prediction == 38)) | |
248 | 139 | then 259210 | |
249 | 140 | else if ((prediction == 39)) | |
250 | 141 | then 252560 | |
251 | 142 | else if ((prediction == 40)) | |
252 | 143 | then 246250 | |
253 | 144 | else if ((prediction == 41)) | |
254 | 145 | then 240240 | |
255 | 146 | else if ((prediction == 42)) | |
256 | 147 | then 234520 | |
257 | 148 | else if ((prediction == 43)) | |
258 | 149 | then 229060 | |
259 | 150 | else if ((prediction == 44)) | |
260 | 151 | then 223860 | |
261 | 152 | else if ((prediction == 45)) | |
262 | 153 | then 218880 | |
263 | 154 | else if ((prediction == 46)) | |
264 | 155 | then 214130 | |
265 | 156 | else if ((prediction == 47)) | |
266 | 157 | then 209570 | |
267 | 158 | else if ((prediction == 48)) | |
268 | 159 | then 205200 | |
269 | 160 | else if ((prediction == 49)) | |
270 | 161 | then 201020 | |
271 | 162 | else if ((prediction == 50)) | |
272 | 163 | then 197000 | |
273 | 164 | else if ((prediction == 51)) | |
274 | 165 | then 193130 | |
275 | 166 | else if ((prediction == 52)) | |
276 | 167 | then 189420 | |
277 | 168 | else if ((prediction == 53)) | |
278 | 169 | then 185840 | |
279 | 170 | else if ((prediction == 54)) | |
280 | 171 | then 182400 | |
281 | 172 | else if ((prediction == 55)) | |
282 | 173 | then 179090 | |
283 | 174 | else if ((prediction == 56)) | |
284 | 175 | then 175890 | |
285 | 176 | else if ((prediction == 57)) | |
286 | 177 | then 172800 | |
287 | 178 | else if ((prediction == 58)) | |
288 | 179 | then 169820 | |
289 | 180 | else if ((prediction == 59)) | |
290 | 181 | then 166940 | |
291 | 182 | else if ((prediction == 60)) | |
292 | 183 | then 164160 | |
293 | 184 | else if ((prediction == 61)) | |
294 | 185 | then 161470 | |
295 | 186 | else if ((prediction == 62)) | |
296 | 187 | then 158870 | |
297 | 188 | else if ((prediction == 63)) | |
298 | 189 | then 156340 | |
299 | 190 | else if ((prediction == 64)) | |
300 | 191 | then 153900 | |
301 | 192 | else if ((prediction == 65)) | |
302 | 193 | then 151530 | |
303 | 194 | else if ((prediction == 66)) | |
304 | 195 | then 149240 | |
305 | 196 | else if ((prediction == 67)) | |
306 | 197 | then 147010 | |
307 | 198 | else if ((prediction == 68)) | |
308 | 199 | then 144850 | |
309 | 200 | else if ((prediction == 69)) | |
310 | 201 | then 142750 | |
311 | 202 | else if ((prediction == 70)) | |
312 | 203 | then 140710 | |
313 | 204 | else if ((prediction == 71)) | |
314 | 205 | then 138730 | |
315 | 206 | else if ((prediction == 72)) | |
316 | 207 | then 136800 | |
317 | 208 | else if ((prediction == 73)) | |
318 | 209 | then 134930 | |
319 | 210 | else if ((prediction == 74)) | |
320 | 211 | then 133100 | |
321 | 212 | else if ((prediction == 75)) | |
322 | 213 | then 131330 | |
323 | 214 | else if ((prediction == 76)) | |
324 | 215 | then 129600 | |
325 | 216 | else if ((prediction == 77)) | |
326 | 217 | then 127920 | |
327 | 218 | else if ((prediction == 78)) | |
328 | 219 | then 126280 | |
329 | 220 | else if ((prediction == 79)) | |
330 | 221 | then 124680 | |
331 | 222 | else if ((prediction == 80)) | |
332 | 223 | then 123120 | |
333 | 224 | else if ((prediction == 81)) | |
334 | 225 | then 121600 | |
335 | 226 | else if ((prediction == 82)) | |
336 | 227 | then 120120 | |
337 | 228 | else if ((prediction == 83)) | |
338 | 229 | then 118670 | |
339 | 230 | else if ((prediction == 84)) | |
340 | 231 | then 117260 | |
341 | 232 | else if ((prediction == 85)) | |
342 | 233 | then 115880 | |
343 | 234 | else if ((prediction == 86)) | |
344 | 235 | then 114530 | |
345 | 236 | else if ((prediction == 87)) | |
346 | 237 | then 113210 | |
347 | 238 | else if ((prediction == 88)) | |
348 | 239 | then 111930 | |
349 | 240 | else if ((prediction == 89)) | |
350 | 241 | then 110670 | |
351 | 242 | else if ((prediction == 90)) | |
352 | 243 | then 109440 | |
353 | 244 | else if ((prediction == 91)) | |
354 | 245 | then 108240 | |
355 | 246 | else if ((prediction == 92)) | |
356 | 247 | then 107060 | |
357 | 248 | else if ((prediction == 93)) | |
358 | 249 | then 105910 | |
359 | 250 | else if ((prediction == 94)) | |
360 | 251 | then 104780 | |
361 | 252 | else if ((prediction == 95)) | |
362 | 253 | then 103680 | |
363 | 254 | else if ((prediction == 96)) | |
364 | 255 | then 103680 | |
365 | 256 | else 100000 | |
366 | 257 | else if ((rollType == ROLLOVER)) | |
367 | 258 | then if ((prediction == 4)) | |
368 | 259 | then 103680 | |
369 | 260 | else if ((prediction == 5)) | |
370 | 261 | then 103680 | |
371 | 262 | else if ((prediction == 6)) | |
372 | 263 | then 104780 | |
373 | 264 | else if ((prediction == 7)) | |
374 | 265 | then 105910 | |
375 | 266 | else if ((prediction == 8)) | |
376 | 267 | then 107060 | |
377 | 268 | else if ((prediction == 9)) | |
378 | 269 | then 108240 | |
379 | 270 | else if ((prediction == 10)) | |
380 | 271 | then 109440 | |
381 | 272 | else if ((prediction == 11)) | |
382 | 273 | then 110670 | |
383 | 274 | else if ((prediction == 12)) | |
384 | 275 | then 111930 | |
385 | 276 | else if ((prediction == 13)) | |
386 | 277 | then 113210 | |
387 | 278 | else if ((prediction == 14)) | |
388 | 279 | then 114530 | |
389 | 280 | else if ((prediction == 15)) | |
390 | 281 | then 115880 | |
391 | 282 | else if ((prediction == 16)) | |
392 | 283 | then 117260 | |
393 | 284 | else if ((prediction == 17)) | |
394 | 285 | then 118670 | |
395 | 286 | else if ((prediction == 18)) | |
396 | 287 | then 120120 | |
397 | 288 | else if ((prediction == 19)) | |
398 | 289 | then 121600 | |
399 | 290 | else if ((prediction == 20)) | |
400 | 291 | then 123120 | |
401 | 292 | else if ((prediction == 21)) | |
402 | 293 | then 124680 | |
403 | 294 | else if ((prediction == 22)) | |
404 | 295 | then 126280 | |
405 | 296 | else if ((prediction == 23)) | |
406 | 297 | then 127920 | |
407 | 298 | else if ((prediction == 24)) | |
408 | 299 | then 129600 | |
409 | 300 | else if ((prediction == 25)) | |
410 | 301 | then 131330 | |
411 | 302 | else if ((prediction == 26)) | |
412 | 303 | then 133100 | |
413 | 304 | else if ((prediction == 27)) | |
414 | 305 | then 134930 | |
415 | 306 | else if ((prediction == 28)) | |
416 | 307 | then 136800 | |
417 | 308 | else if ((prediction == 29)) | |
418 | 309 | then 138730 | |
419 | 310 | else if ((prediction == 30)) | |
420 | 311 | then 140710 | |
421 | 312 | else if ((prediction == 31)) | |
422 | 313 | then 142750 | |
423 | 314 | else if ((prediction == 32)) | |
424 | 315 | then 144850 | |
425 | 316 | else if ((prediction == 33)) | |
426 | 317 | then 147010 | |
427 | 318 | else if ((prediction == 34)) | |
428 | 319 | then 149240 | |
429 | 320 | else if ((prediction == 35)) | |
430 | 321 | then 151530 | |
431 | 322 | else if ((prediction == 36)) | |
432 | 323 | then 153900 | |
433 | 324 | else if ((prediction == 37)) | |
434 | 325 | then 156340 | |
435 | 326 | else if ((prediction == 38)) | |
436 | 327 | then 158870 | |
437 | 328 | else if ((prediction == 39)) | |
438 | 329 | then 161470 | |
439 | 330 | else if ((prediction == 40)) | |
440 | 331 | then 164160 | |
441 | 332 | else if ((prediction == 41)) | |
442 | 333 | then 166940 | |
443 | 334 | else if ((prediction == 42)) | |
444 | 335 | then 169820 | |
445 | 336 | else if ((prediction == 43)) | |
446 | 337 | then 172800 | |
447 | 338 | else if ((prediction == 44)) | |
448 | 339 | then 175890 | |
449 | 340 | else if ((prediction == 45)) | |
450 | 341 | then 179090 | |
451 | 342 | else if ((prediction == 46)) | |
452 | 343 | then 185840 | |
453 | 344 | else if ((prediction == 47)) | |
454 | 345 | then 185840 | |
455 | 346 | else if ((prediction == 48)) | |
456 | 347 | then 189420 | |
457 | 348 | else if ((prediction == 49)) | |
458 | 349 | then 193130 | |
459 | 350 | else if ((prediction == 50)) | |
460 | 351 | then 197000 | |
461 | 352 | else if ((prediction == 51)) | |
462 | 353 | then 201020 | |
463 | 354 | else if ((prediction == 52)) | |
464 | 355 | then 205200 | |
465 | 356 | else if ((prediction == 53)) | |
466 | 357 | then 209570 | |
467 | 358 | else if ((prediction == 54)) | |
468 | 359 | then 214130 | |
469 | 360 | else if ((prediction == 55)) | |
470 | 361 | then 218880 | |
471 | 362 | else if ((prediction == 56)) | |
472 | 363 | then 223860 | |
473 | 364 | else if ((prediction == 57)) | |
474 | 365 | then 229060 | |
475 | 366 | else if ((prediction == 58)) | |
476 | 367 | then 234520 | |
477 | 368 | else if ((prediction == 59)) | |
478 | 369 | then 240240 | |
479 | 370 | else if ((prediction == 60)) | |
480 | 371 | then 246250 | |
481 | 372 | else if ((prediction == 61)) | |
482 | 373 | then 252560 | |
483 | 374 | else if ((prediction == 62)) | |
484 | 375 | then 259210 | |
485 | 376 | else if ((prediction == 63)) | |
486 | 377 | then 259210 | |
487 | 378 | else if ((prediction == 64)) | |
488 | 379 | then 273610 | |
489 | 380 | else if ((prediction == 65)) | |
490 | 381 | then 281420 | |
491 | 382 | else if ((prediction == 66)) | |
492 | 383 | then 289700 | |
493 | 384 | else if ((prediction == 67)) | |
494 | 385 | then 298480 | |
495 | 386 | else if ((prediction == 68)) | |
496 | 387 | then 307810 | |
497 | 388 | else if ((prediction == 69)) | |
498 | 389 | then 317740 | |
499 | 390 | else if ((prediction == 70)) | |
500 | 391 | then 328330 | |
501 | 392 | else if ((prediction == 71)) | |
502 | 393 | then 339650 | |
503 | 394 | else if ((prediction == 72)) | |
504 | 395 | then 351780 | |
505 | 396 | else if ((prediction == 73)) | |
506 | 397 | then 364810 | |
507 | 398 | else if ((prediction == 74)) | |
508 | 399 | then 378840 | |
509 | 400 | else if ((prediction == 75)) | |
510 | 401 | then 394000 | |
511 | 402 | else if ((prediction == 76)) | |
512 | 403 | then 410410 | |
513 | 404 | else if ((prediction == 77)) | |
514 | 405 | then 428260 | |
515 | 406 | else if ((prediction == 78)) | |
516 | 407 | then 447720 | |
517 | 408 | else if ((prediction == 79)) | |
518 | 409 | then 469040 | |
519 | 410 | else if ((prediction == 80)) | |
520 | 411 | then 492500 | |
521 | 412 | else if ((prediction == 81)) | |
522 | 413 | then 518420 | |
523 | 414 | else if ((prediction == 82)) | |
524 | 415 | then 547220 | |
525 | 416 | else if ((prediction == 83)) | |
526 | 417 | then 579410 | |
527 | 418 | else if ((prediction == 84)) | |
528 | 419 | then 615620 | |
529 | 420 | else if ((prediction == 85)) | |
530 | 421 | then 656660 | |
531 | 422 | else if ((prediction == 86)) | |
532 | 423 | then 703570 | |
533 | 424 | else if ((prediction == 87)) | |
534 | 425 | then 757690 | |
535 | 426 | else if ((prediction == 88)) | |
536 | 427 | then 820830 | |
537 | 428 | else if ((prediction == 89)) | |
538 | 429 | then 895450 | |
539 | 430 | else if ((prediction == 90)) | |
540 | 431 | then 985000 | |
541 | 432 | else if ((prediction == 91)) | |
542 | 433 | then 1094440 | |
543 | 434 | else if ((prediction == 92)) | |
544 | 435 | then 1231250 | |
545 | 436 | else if ((prediction == 93)) | |
546 | 437 | then 1407140 | |
547 | 438 | else if ((prediction == 94)) | |
548 | 439 | then 1641660 | |
549 | 440 | else if ((prediction == 95)) | |
550 | 441 | then 1970000 | |
551 | 442 | else if ((prediction == 96)) | |
552 | 443 | then 2462500 | |
553 | 444 | else if ((prediction == 97)) | |
554 | 445 | then 3283330 | |
555 | 446 | else if ((prediction == 98)) | |
556 | 447 | then 4925000 | |
557 | 448 | else if ((prediction == 99)) | |
558 | 449 | then 9850000 | |
559 | 450 | else 100000 | |
560 | 451 | else 100000 | |
561 | 452 | ||
562 | 453 | ||
563 | - | func diceWin (type,prediction, | |
564 | - | then if ((prediction >= | |
454 | + | func diceWin (type,prediction,rand) = if ((type == ROLLUNDER)) | |
455 | + | then if ((prediction >= rand)) | |
565 | 456 | then true | |
566 | 457 | else false | |
567 | 458 | else if ((type == ROLLOVER)) | |
568 | - | then if (( | |
459 | + | then if ((rand >= prediction)) | |
569 | 460 | then true | |
570 | 461 | else false | |
571 | 462 | else false | |
572 | 463 | ||
573 | 464 | ||
574 | 465 | func ValidateBetAndDefineWinAmt (amount,prediction,rollType) = if (if ((BETMIN > amount)) | |
575 | 466 | then true | |
576 | 467 | else (amount > BETMAX)) | |
577 | 468 | then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / WAVELET))) + " maxBet=") + toString((BETMAX / WAVELET)))) | |
578 | 469 | else if (if ((rollType != ROLLUNDER)) | |
579 | 470 | then (rollType != ROLLOVER) | |
580 | 471 | else false) | |
581 | 472 | then throw("Invalid Roll type, try with OVER or UNDER") | |
582 | 473 | else if (if ((PREDICTIONMIN > prediction)) | |
583 | 474 | then true | |
584 | 475 | else (prediction > PREDICTIONMAX)) | |
585 | 476 | then throw(((("Prediction is out of the range: " + toString(PREDICTIONMIN)) + " <= prediction <= ") + toString(PREDICTIONMAX))) | |
586 | 477 | else { | |
587 | 478 | let multi = Multiplier(prediction, rollType) | |
588 | 479 | ((((amount * multi) / 100000) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
589 | 480 | } | |
590 | 481 | ||
591 | 482 | ||
592 | 483 | @Callable(i) | |
593 | - | func playDice (rollType,prediction) = { | |
484 | + | func playDice (rollType,prediction,rsaSig) = { | |
594 | 485 | let gameId = toBase58String(i.transactionId) | |
595 | 486 | let payment = extract(i.payment) | |
596 | 487 | let feeAssetId = isDefined(i.feeAssetId) | |
597 | - | let multi = Multiplier(prediction, rollType) | |
598 | - | let winAmt = ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType) | |
599 | 488 | let playerBalance = wavesBalance(i.caller) | |
600 | 489 | let gameIdUsed = isDefined(getString(this, gameId)) | |
601 | 490 | if ((payment.assetId != WBET)) | |
602 | - | then throw("Payment should be in Wavesbet") | |
603 | - | else if (( | |
604 | - | then throw("There are not enough waves, it takes 0. | |
491 | + | then throw("Payment should be in Wavesbet. Game aborted.") | |
492 | + | else if ((500000 > playerBalance)) | |
493 | + | then throw("There are not enough waves, it takes 0.005 Waves to bet. Game aborted.") | |
605 | 494 | else if (feeAssetId) | |
606 | 495 | then throw("Transaction's fee must be in Waves. Game aborted.") | |
607 | 496 | else if (gameIdUsed) | |
608 | 497 | then throw("Passed gameId had been used before. Game aborted.") | |
609 | 498 | else { | |
499 | + | let rand = GenerateRandInt(gameId, rsaSig) | |
500 | + | let randStr = RandToStr(rand) | |
501 | + | let result = diceWin(rollType, prediction, rand) | |
502 | + | let winAmt = if (result) | |
503 | + | then ValidateBetAndDefineWinAmt(payment.amount, prediction, rollType) | |
504 | + | else 0 | |
610 | 505 | let newGameNum = IncrementGameNum() | |
611 | - | let playerPubKey58 = toBase58String(i.callerPublicKey) | |
612 | - | let gameDataStr = FormatGameDataStr(STATESUBMITTED, prediction, rollType, playerPubKey58, winAmt, "") | |
613 | - | ScriptResult(WriteSet([DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet(nil)) | |
506 | + | let betData = WriteSet([DataEntry(gameId, if (result) | |
507 | + | then STATEWON | |
508 | + | else STATELOST), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry("random", rand), DataEntry("payment", payment.amount), DataEntry("payout", winAmt)]) | |
509 | + | if (result) | |
510 | + | then ScriptResult(betData, TransferSet([ScriptTransfer(i.caller, winAmt, WBET)])) | |
511 | + | else ScriptResult(betData, TransferSet(nil)) | |
614 | 512 | } | |
615 | 513 | } | |
616 | 514 | ||
617 | - | ||
618 | - | ||
619 | - | @Callable(i) | |
620 | - | func withdraw (gameId,rsaSig) = { | |
621 | - | let gameDataList = ExtractGameDataList(gameId) | |
622 | - | let gameState = gameDataList[IdxGameState] | |
623 | - | let prediction = parseIntValue(gameDataList[IdxPrediction]) | |
624 | - | let rollType = gameDataList[IdxType] | |
625 | - | let winAmt = parseIntValue(gameDataList[IdxWinAmt]) | |
626 | - | let playerPubKey58 = gameDataList[IdxPlayerPubKey58] | |
627 | - | let playerAddress = addressFromPublicKey(fromBase58String(playerPubKey58)) | |
628 | - | let decreasedReserves = DecreaseReservedAmt(gameId, winAmt) | |
629 | - | if ((gameState != STATESUBMITTED)) | |
630 | - | then throw("Invalid game state for passed gameId. Game aborted.") | |
631 | - | else { | |
632 | - | let rand = GenerateRandInt(gameId, rsaSig) | |
633 | - | let randStr = RandToStr(rand) | |
634 | - | if (diceWin(rollType, prediction, rand)) | |
635 | - | then { | |
636 | - | let newGameDataStr = FormatGameDataStr(STATEWON, prediction, rollType, playerPubKey58, winAmt, randStr) | |
637 | - | WinScriptSet(gameId, playerAddress, winAmt, newGameDataStr, decreasedReserves) | |
638 | - | } | |
639 | - | else { | |
640 | - | let newGameDataStr = FormatGameDataStr(STATELOST, prediction, rollType, playerPubKey58, winAmt, randStr) | |
641 | - | WriteSet([DataEntry(gameId, newGameDataStr), decreasedReserves]) | |
642 | - | } | |
643 | - | } | |
644 | - | } | |
645 | - | ||
646 | - | ||
647 | - | @Verifier(tx) | |
648 | - | func verify () = if (sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey)) | |
649 | - | then match tx { | |
650 | - | case ttx: TransferTransaction => | |
651 | - | ((assetBalance(this, WBET) - ttx.amount) >= ExtractReservedAmt()) | |
652 | - | case stx: SetScriptTransaction => | |
653 | - | true | |
654 | - | case itx: InvokeScriptTransaction => | |
655 | - | if ((itx.function == "withdraw")) | |
656 | - | then true | |
657 | - | else false | |
658 | - | case _ => | |
659 | - | false | |
660 | - | } | |
661 | - | else false | |
662 | 515 |
github/deemru/w8io/169f3d6 98.62 ms ◑