tx · 5cJnTKBDzs5fhCL2eGwJmkX13PP7armMZbX8sEDaafL3 3MxsZUkxjngrsHn7WNd2xEbwWkUfKdmzP6u: -0.01400000 Waves 2019.10.26 17:00 [737191] smart account 3MxsZUkxjngrsHn7WNd2xEbwWkUfKdmzP6u > SELF 0.00000000 Waves
{ "type": 13, "id": "5cJnTKBDzs5fhCL2eGwJmkX13PP7armMZbX8sEDaafL3", "fee": 1400000, "feeAssetId": null, "timestamp": 1572098438486, "version": 1, "sender": "3MxsZUkxjngrsHn7WNd2xEbwWkUfKdmzP6u", "senderPublicKey": "BFgvNhTxuzThVrRXLX7LfTfCHVeCPDsF6JEpadKJPvox", "proofs": [ "3JTUXzhHLYKMM84TjF75aVHwekg8qMm7E9t4YK2TUtP6kpk9QCV8ke9Z9btFkj25aL8NDJDh39YWDmjpGuKM9tag" ], "script": "base64:AAIDAAAAAAAAAAcIARIDCgEIAAAAFAAAAAAJUlNBUFVCTElDCQACWwAAAAECAAABj2Jhc2U2NDpNSUlCSWpBTkJna3Foa2lHOXcwQkFRRUZBQU9DQVE4QU1JSUJDZ0tDQVFFQW1PbFJCVFlFTzNIN1k5ckJtb0ZRRm40MzkyUHgwUXcxM0RzZEVobnpNSDJjajZZNXltUHVDT0xNTmU1cXJVelFsOG9STHpJQnpGVk1abHdVWWwyYm9zck9JeFFiWUY3V1ZRV3ZvVnhFVDFZSWdEbTNOenpPTEE1dUg3Q0tPMHNuc2htTUZDRE9aRWV3NDFHaktoM1BneCtuYkFndVA5WlFQZnFTYWZFbUMzQ04vNHlEc0pyS3JpUm5pWkpvOWpTLzRMTHNSS3dCN0hBWkh6b0Y5TEw3dFNaSDNodGFOR3RiZFRreFoxVHpTVDNNYjJWUFN6c1p2UURvY1hVVk9tSk91MG8yOWFPWStHa0cvRzRSQ0swRkJXUUhFVXZDNTFUUkRTNWs4amFkME8xTW9ialFjNmIxOGQrZnVvVkZkTmZad0dIK3VGdWR0UEczVUpUZjJta3paUUlEQVFBQgAAAAAPR0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fsSjXURhLJ5Q6JXYpfJCyGHv Next: ENfjAzGmH4i6dPzUVAStdu8gS6SvyAqVE6nvxsTWJryG Diff:
Old | New | Differences | |
---|---|---|---|
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | - | func ValidateBetAndDefineWinAmt (amount) = if (if (( | |
43 | + | func ValidateBetAndDefineWinAmt (playerCoin,amount) = if (if ((playerCoin == "RED")) | |
44 | 44 | then true | |
45 | - | else (amount > BETMAX)) | |
46 | - | then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / 100000000))) + " maxBet=") + toString((BETMAX / 100000000)))) | |
47 | - | else ((((amount * 2) / 100000) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
45 | + | else (playerCoin == "BLUE")) | |
46 | + | then throw("Invalid play, change your play to RED or BLUE.") | |
47 | + | else if (if ((BETMIN > amount)) | |
48 | + | then true | |
49 | + | else (amount > BETMAX)) | |
50 | + | then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / 100000000))) + " maxBet=") + toString((BETMAX / 100000000)))) | |
51 | + | else ((((amount * 2) / 100000) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
48 | 52 | ||
49 | 53 | ||
50 | 54 | func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) { | |
90 | 94 | let payment = extract(i.payment) | |
91 | 95 | let feeAssetId = isDefined(i.feeAssetId) | |
92 | 96 | let gameIdUsed = isDefined(getString(this, gameId)) | |
93 | - | let winAmt = ValidateBetAndDefineWinAmt(payment.amount) | |
97 | + | let winAmt = ValidateBetAndDefineWinAmt(paCoin, payment.amount) | |
94 | 98 | if (if ((payment.assetId != assetInfo(base58'WAVES'))) | |
95 | 99 | then (payment.assetId != WBET) | |
96 | 100 | else false) | |
99 | 103 | then throw("Transaction's fee must be in Waves. Game aborted.") | |
100 | 104 | else if (gameIdUsed) | |
101 | 105 | then throw("Passed gameId had been used before. Game aborted.") | |
102 | - | else if (gameIdUsed) | |
103 | - | then throw("Passed gameId had been used before. Game aborted.") | |
104 | - | else { | |
105 | - | let newGameNum = IncrementGameNum() | |
106 | - | let playerAPubKey58 = toBase58String(i.callerPublicKey) | |
107 | - | let gameDataStr = FormatGameDataStr(STATESUBMITTED, paCoin, playerAPubKey58, "", "", winAmt, "") | |
108 | - | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETWAVESBET, ((payment.amount * FEEWAVESBET) / 100), WBET), ScriptTransfer(this, 500000, unit)])) | |
109 | - | } | |
106 | + | else { | |
107 | + | let newGameNum = IncrementGameNum() | |
108 | + | let playerAPubKey58 = toBase58String(i.callerPublicKey) | |
109 | + | let gameDataStr = FormatGameDataStr(STATESUBMITTED, paCoin, playerAPubKey58, "", "", winAmt, "") | |
110 | + | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETWAVESBET, ((payment.amount * FEEWAVESBET) / 100), WBET), ScriptTransfer(this, 500000, unit)])) | |
111 | + | } | |
110 | 112 | } | |
111 | 113 | ||
112 | 114 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let RSAPUBLIC = fromBase64String("base64:MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmOlRBTYEO3H7Y9rBmoFQFn4392Px0Qw13DsdEhnzMH2cj6Y5ymPuCOLMNe5qrUzQl8oRLzIBzFVMZlwUYl2bosrOIxQbYF7WVQWvoVxET1YIgDm3NzzOLA5uH7CKO0snshmMFCDOZEew41GjKh3Pgx+nbAguP9ZQPfqSafEmC3CN/4yDsJrKriRniZJo9jS/4LLsRKwB7HAZHzoF9LL7tSZH3htaNGtbdTkxZ1TzST3Mb2VPSzsZvQDocXUVOmJOu0o29aOY+GkG/G4RCK0FBWQHEUvC51TRDS5k8jad0O1MobjQc6b18d+fuoVFdNfZwGH+uFudtPG3UJTf2mkzZQIDAQAB") | |
5 | 5 | ||
6 | 6 | let GAMESCOUNTERKEY = "$GAME_NUM" | |
7 | 7 | ||
8 | 8 | let RESERVATIONKEY = "$RESERVED_AMOUNT" | |
9 | 9 | ||
10 | 10 | let WBET = base58'23vgV9p9pD83A7CFbsDEc4zjanep7UeFo4ZRS6oGorhv' | |
11 | 11 | ||
12 | 12 | let WALLETWAVESBET = Address(base58'3N2tusqAtDctK8iSTXS6F9rimmftmSuwLUX') | |
13 | 13 | ||
14 | 14 | let WALLETMCAFFE = Address(base58'') | |
15 | 15 | ||
16 | 16 | let STATESUBMITTED = "SUBMITTED" | |
17 | 17 | ||
18 | 18 | let STATEFINISHED = "FINISHED" | |
19 | 19 | ||
20 | 20 | let STATECANCELED = "CANCELED" | |
21 | 21 | ||
22 | 22 | let WAVELET = ((100 * 1000) * 1000) | |
23 | 23 | ||
24 | 24 | let FEEWAVESBET = 4 | |
25 | 25 | ||
26 | 26 | let FEEMCAFEE = 2 | |
27 | 27 | ||
28 | 28 | let BETMIN = (1 * WAVELET) | |
29 | 29 | ||
30 | 30 | let BETMAX = ((1000 * 100) * WAVELET) | |
31 | 31 | ||
32 | 32 | func IncrementGameNum () = { | |
33 | 33 | let gameNum = match getInteger(this, GAMESCOUNTERKEY) { | |
34 | 34 | case num: Int => | |
35 | 35 | num | |
36 | 36 | case _ => | |
37 | 37 | 0 | |
38 | 38 | } | |
39 | 39 | (gameNum + 1) | |
40 | 40 | } | |
41 | 41 | ||
42 | 42 | ||
43 | - | func ValidateBetAndDefineWinAmt (amount) = if (if (( | |
43 | + | func ValidateBetAndDefineWinAmt (playerCoin,amount) = if (if ((playerCoin == "RED")) | |
44 | 44 | then true | |
45 | - | else (amount > BETMAX)) | |
46 | - | then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / 100000000))) + " maxBet=") + toString((BETMAX / 100000000)))) | |
47 | - | else ((((amount * 2) / 100000) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
45 | + | else (playerCoin == "BLUE")) | |
46 | + | then throw("Invalid play, change your play to RED or BLUE.") | |
47 | + | else if (if ((BETMIN > amount)) | |
48 | + | then true | |
49 | + | else (amount > BETMAX)) | |
50 | + | then throw(((("Bet amount is not in range: minBet=" + toString((BETMIN / 100000000))) + " maxBet=") + toString((BETMAX / 100000000)))) | |
51 | + | else ((((amount * 2) / 100000) * (100 - (FEEWAVESBET + FEEMCAFEE))) / 100) | |
48 | 52 | ||
49 | 53 | ||
50 | 54 | func ExtractReservedAmt () = match getInteger(this, RESERVATIONKEY) { | |
51 | 55 | case a: Int => | |
52 | 56 | a | |
53 | 57 | case _ => | |
54 | 58 | 0 | |
55 | 59 | } | |
56 | 60 | ||
57 | 61 | ||
58 | 62 | func ValidateAndIncreaseReservedAmt (winAmt) = { | |
59 | 63 | let newReservedAmount = (ExtractReservedAmt() + winAmt) | |
60 | 64 | let balance = assetBalance(this, WBET) | |
61 | 65 | if ((newReservedAmount > balance)) | |
62 | 66 | then throw("Insufficient funds on Waves Rider account. Transaction was rejected for your safety.") | |
63 | 67 | else newReservedAmount | |
64 | 68 | } | |
65 | 69 | ||
66 | 70 | ||
67 | 71 | func FormatGameDataParam (p) = { | |
68 | 72 | let s = size(p) | |
69 | 73 | if ((s == 0)) | |
70 | 74 | then throw("Parameter size must be greater then 0") | |
71 | 75 | else if ((s > 99)) | |
72 | 76 | then throw("Parameter size must be less then 100") | |
73 | 77 | else if ((10 > s)) | |
74 | 78 | then (("0" + toString(s)) + p) | |
75 | 79 | else (toString(s) + p) | |
76 | 80 | } | |
77 | 81 | ||
78 | 82 | ||
79 | 83 | func FormatGameDataStr (gameState,playerACoin,playerAPubKey58,playerBCoin,playerBPubKey58,winAmt,randOrEmpty) = { | |
80 | 84 | let fullStateStr = ((((((((((FormatGameDataParam(gameState) + "_") + FormatGameDataParam(playerACoin)) + "_") + FormatGameDataParam(playerAPubKey58)) + "_") + FormatGameDataParam(playerBCoin)) + "_") + FormatGameDataParam(playerBPubKey58)) + "_") + FormatGameDataParam(toString(winAmt))) | |
81 | 85 | if ((randOrEmpty == "")) | |
82 | 86 | then fullStateStr | |
83 | 87 | else ((fullStateStr + "_") + FormatGameDataParam(randOrEmpty)) | |
84 | 88 | } | |
85 | 89 | ||
86 | 90 | ||
87 | 91 | @Callable(i) | |
88 | 92 | func playDice (paCoin) = { | |
89 | 93 | let gameId = toBase58String(i.transactionId) | |
90 | 94 | let payment = extract(i.payment) | |
91 | 95 | let feeAssetId = isDefined(i.feeAssetId) | |
92 | 96 | let gameIdUsed = isDefined(getString(this, gameId)) | |
93 | - | let winAmt = ValidateBetAndDefineWinAmt(payment.amount) | |
97 | + | let winAmt = ValidateBetAndDefineWinAmt(paCoin, payment.amount) | |
94 | 98 | if (if ((payment.assetId != assetInfo(base58'WAVES'))) | |
95 | 99 | then (payment.assetId != WBET) | |
96 | 100 | else false) | |
97 | 101 | then throw("Payment should be in Wavesbet or Waves") | |
98 | 102 | else if (feeAssetId) | |
99 | 103 | then throw("Transaction's fee must be in Waves. Game aborted.") | |
100 | 104 | else if (gameIdUsed) | |
101 | 105 | then throw("Passed gameId had been used before. Game aborted.") | |
102 | - | else if (gameIdUsed) | |
103 | - | then throw("Passed gameId had been used before. Game aborted.") | |
104 | - | else { | |
105 | - | let newGameNum = IncrementGameNum() | |
106 | - | let playerAPubKey58 = toBase58String(i.callerPublicKey) | |
107 | - | let gameDataStr = FormatGameDataStr(STATESUBMITTED, paCoin, playerAPubKey58, "", "", winAmt, "") | |
108 | - | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETWAVESBET, ((payment.amount * FEEWAVESBET) / 100), WBET), ScriptTransfer(this, 500000, unit)])) | |
109 | - | } | |
106 | + | else { | |
107 | + | let newGameNum = IncrementGameNum() | |
108 | + | let playerAPubKey58 = toBase58String(i.callerPublicKey) | |
109 | + | let gameDataStr = FormatGameDataStr(STATESUBMITTED, paCoin, playerAPubKey58, "", "", winAmt, "") | |
110 | + | ScriptResult(WriteSet([DataEntry(RESERVATIONKEY, ValidateAndIncreaseReservedAmt(winAmt)), DataEntry(GAMESCOUNTERKEY, newGameNum), DataEntry(gameId, gameDataStr)]), TransferSet([ScriptTransfer(WALLETWAVESBET, ((payment.amount * FEEWAVESBET) / 100), WBET), ScriptTransfer(this, 500000, unit)])) | |
111 | + | } | |
110 | 112 | } | |
111 | 113 | ||
112 | 114 |
github/deemru/w8io/169f3d6 100.85 ms ◑