tx · Vzswnt7gd2A5f1f7uwyfSoRmTwGhiLfkLkfqHH6kP2E 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc: -0.01400000 Waves 2019.09.08 12:30 [666918] smart account 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc > SELF 0.00000000 Waves
{ "type": 13, "id": "Vzswnt7gd2A5f1f7uwyfSoRmTwGhiLfkLkfqHH6kP2E", "fee": 1400000, "feeAssetId": null, "timestamp": 1567935022111, "version": 1, "sender": "3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc", "senderPublicKey": "9cETBksYN8YMHGvDB6BEqmH9HScpCMBRZwnjCviRQ9aA", "proofs": [ "2tFPz6YgYyXcV8XWe23ipw4BJL5VaE1ywNE586yd1eHTCG9v52KKt38combPhBf3MmjpYSpPYfgmQWHRF1Ea9PVb" ], "script": "base64:AAIDAAAAAAAAAAAAAAATAAAAAAVQUklDRQAAAAAABfXhAAAAAAALUEFURU5UUFJJQ0UAAAAAAAvrwgAAAAAABk9SQUNMRQIAAAAjM012aXNEZkE2dk5nNGk2aUtZV1o4Yld2eVA0aW1mQmI5ZXEAAAAAA1dJTgIAAAADV0lOAAAAAARMT1NFAgAAAARMT1NFAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAEXZhb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QAAAABBQAAAAZ3aW5uZXIJAABkAAAAAgkBAAAAEGdldFZhbHVlV2luQ291bnQAAAABBQAAAAZ3aW5uZXIAAAAAAAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA9nZXRLZXlMb3NlQ291bnQAAAABBQAAAAVsb3NlcgkAAGQAAAACCQEAAAARZ2V0VmFsdWVMb3NlQ291bnQAAAABBQAAAAVsb3NlcgAAAAAAAAAAAQUAAAADbmlsAAAAAPKxcdI=", "chainId": 84, "height": 666918, "spentComplexity": 0 } View: original | compacted Prev: 6SqBpdzyNuRDS4TWdbwA4nC4TLXyGre3hzDEQDrUepJv Next: 5kXvuNXuHnR48SPhf4ffSCSz5SDzhS1g8ehCzuPDv7fg Diff:
Old | New | Differences | |
---|---|---|---|
78 | 78 | func getValueLoseCount (user) = getNumberByKey(getKeyLoseCount(user)) | |
79 | 79 | ||
80 | 80 | ||
81 | + | func getKeyGame (game) = ("game_" + game) | |
82 | + | ||
83 | + | ||
84 | + | func getValueGame (game) = getStrByKey(getKeyGame(game)) | |
85 | + | ||
86 | + | ||
81 | 87 | @Callable(i) | |
82 | 88 | func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
83 | 89 | let pmt = extract(i.payment) | |
137 | 143 | then throw("only oracle can inform about games results") | |
138 | 144 | else if ((winner == loser)) | |
139 | 145 | then throw("winner and loser must be different") | |
140 | - | else if (( | |
146 | + | else if ((getValueGame(game) != NONE)) | |
141 | 147 | then throw("this game has already been played") | |
142 | - | else WriteSet([DataEntry(( | |
148 | + | else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))]) | |
143 | 149 | } | |
144 | 150 | ||
145 | 151 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let PRICE = 100000000 | |
5 | 5 | ||
6 | 6 | let PATENTPRICE = 200000000 | |
7 | 7 | ||
8 | 8 | let ORACLE = "3MvisDfA6vNg4i6iKYWZ8bWvyP4imfBb9eq" | |
9 | 9 | ||
10 | 10 | let WIN = "WIN" | |
11 | 11 | ||
12 | 12 | let LOSE = "LOSE" | |
13 | 13 | ||
14 | 14 | let NONE = "none" | |
15 | 15 | ||
16 | 16 | func getNumberByKey (key) = { | |
17 | 17 | let num = match getInteger(this, key) { | |
18 | 18 | case a: Int => | |
19 | 19 | a | |
20 | 20 | case _ => | |
21 | 21 | 0 | |
22 | 22 | } | |
23 | 23 | num | |
24 | 24 | } | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func getStrByKey (key) = { | |
28 | 28 | let str = match getString(this, key) { | |
29 | 29 | case a: String => | |
30 | 30 | a | |
31 | 31 | case _ => | |
32 | 32 | NONE | |
33 | 33 | } | |
34 | 34 | str | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func validateTwoCoords (x1,y1,x2,y2) = if ((x1 > x2)) | |
39 | 39 | then false | |
40 | 40 | else if (if ((x1 == x2)) | |
41 | 41 | then (y1 > y2) | |
42 | 42 | else false) | |
43 | 43 | then false | |
44 | 44 | else true | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func validateCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = if (!(validateTwoCoords(x1, y1, x2, y2))) | |
48 | 48 | then false | |
49 | 49 | else if (!(validateTwoCoords(x2, y2, x3, y3))) | |
50 | 50 | then false | |
51 | 51 | else if (!(validateTwoCoords(x3, y3, x4, y4))) | |
52 | 52 | then false | |
53 | 53 | else if (!(validateTwoCoords(x4, y4, x5, y5))) | |
54 | 54 | then false | |
55 | 55 | else if (!(validateTwoCoords(x5, y5, x6, y6))) | |
56 | 56 | then false | |
57 | 57 | else true | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func genKeyFromCoords (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = ((((((((((((((((((((((toString(x1) + ",") + toString(y1)) + ";") + toString(x2)) + ",") + toString(y2)) + ";") + toString(x3)) + ",") + toString(y3)) + ";") + toString(x4)) + ",") + toString(y4)) + ";") + toString(x5)) + ",") + toString(y5)) + ";") + toString(x6)) + ",") + toString(y6)) | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getKeyBalanceUser (account) = (account + "_balance") | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getValueBalanceUser (account) = getNumberByKey(getKeyBalanceUser(account)) | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func getKeyWinCount (user) = (user + "_wincnt") | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getValueWinCount (user) = getNumberByKey(getKeyWinCount(user)) | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func getKeyLoseCount (user) = (user + "_losecnt") | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getValueLoseCount (user) = getNumberByKey(getKeyLoseCount(user)) | |
79 | 79 | ||
80 | 80 | ||
81 | + | func getKeyGame (game) = ("game_" + game) | |
82 | + | ||
83 | + | ||
84 | + | func getValueGame (game) = getStrByKey(getKeyGame(game)) | |
85 | + | ||
86 | + | ||
81 | 87 | @Callable(i) | |
82 | 88 | func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
83 | 89 | let pmt = extract(i.payment) | |
84 | 90 | if (isDefined(pmt.assetId)) | |
85 | 91 | then throw("can use WAVES only at the moment") | |
86 | 92 | else { | |
87 | 93 | let userAddress = toBase58String(i.caller.bytes) | |
88 | 94 | if ((pmt.amount != PRICE)) | |
89 | 95 | then throw("purchase amount cannot be not equal to the price") | |
90 | 96 | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
91 | 97 | then throw("invalid coordinates order") | |
92 | 98 | else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE)) | |
93 | 99 | then throw("this patent is already exists") | |
94 | 100 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress)]) | |
95 | 101 | } | |
96 | 102 | } | |
97 | 103 | ||
98 | 104 | ||
99 | 105 | ||
100 | 106 | @Callable(i) | |
101 | 107 | func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
102 | 108 | let pmt = extract(i.payment) | |
103 | 109 | if (isDefined(pmt.assetId)) | |
104 | 110 | then throw("can use WAVES only at the moment") | |
105 | 111 | else { | |
106 | 112 | let userAddress = toBase58String(i.caller.bytes) | |
107 | 113 | let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
108 | 114 | if ((pmt.amount != PATENTPRICE)) | |
109 | 115 | then throw("purchase amount cannot be not equal to the price") | |
110 | 116 | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
111 | 117 | then throw("invalid coordinates order") | |
112 | 118 | else if ((patentOwnerAddress == NONE)) | |
113 | 119 | then throw("there is no such patent") | |
114 | 120 | else if ((patentOwnerAddress == userAddress)) | |
115 | 121 | then throw("you cannot buy your own patent") | |
116 | 122 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))]) | |
117 | 123 | } | |
118 | 124 | } | |
119 | 125 | ||
120 | 126 | ||
121 | 127 | ||
122 | 128 | @Callable(i) | |
123 | 129 | func withdraw () = { | |
124 | 130 | let userAddress = toBase58String(i.caller.bytes) | |
125 | 131 | let balance = getValueBalanceUser(userAddress) | |
126 | 132 | if ((0 >= balance)) | |
127 | 133 | then throw("insufficient balance") | |
128 | 134 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)])) | |
129 | 135 | } | |
130 | 136 | ||
131 | 137 | ||
132 | 138 | ||
133 | 139 | @Callable(i) | |
134 | 140 | func gameReport (game,winner,loser) = { | |
135 | 141 | let oracleAddres = toBase58String(i.caller.bytes) | |
136 | 142 | if ((oracleAddres != ORACLE)) | |
137 | 143 | then throw("only oracle can inform about games results") | |
138 | 144 | else if ((winner == loser)) | |
139 | 145 | then throw("winner and loser must be different") | |
140 | - | else if (( | |
146 | + | else if ((getValueGame(game) != NONE)) | |
141 | 147 | then throw("this game has already been played") | |
142 | - | else WriteSet([DataEntry(( | |
148 | + | else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))]) | |
143 | 149 | } | |
144 | 150 | ||
145 | 151 |
github/deemru/w8io/026f985 30.05 ms ◑