tx · 3v3mSXL11AzLcPvND97Fu21HynTi13rj5LPV7qngSAJy 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc: -0.01400000 Waves 2019.09.08 10:54 [666829] smart account 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc > SELF 0.00000000 Waves
{ "type": 13, "id": "3v3mSXL11AzLcPvND97Fu21HynTi13rj5LPV7qngSAJy", "fee": 1400000, "feeAssetId": null, "timestamp": 1567929220071, "version": 1, "sender": "3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc", "senderPublicKey": "9cETBksYN8YMHGvDB6BEqmH9HScpCMBRZwnjCviRQ9aA", "proofs": [ "5gYb4XcbVC8yUSxP9S8abtrm3k98xFaTT6MwJWfhRg2WWP6S6JhLXsPkzda1w7t32iEzN4SP9B2bgzHt9VRzWHCy" ], "script": "base64:AAIDAAAAAAAAAAAAAAARAAAAAAVQUklDRQAAAAAABfXhAAAAAAALUEFURU5UUFJJQ0UAAAAAAAvrwgAAAAAABk9SQUNMRQIAAAAGT1JBQ0xFAAAAAANXSU4CAAAAA1dJTgAAAAAETE9TRQIAAAAETE9TRQAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAABF2YWxpZGF0ZVR3b0Nvb3JkcwAAAAQAAAACeDEAAAACeTE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9zZXIJAAACAAAAAQIAAAAid2lubmVyIGFuZCBsb3NlciBtdXN0IGJlIGRpZmZlcmVudAMJAQAAAAIhPQAAAAIJAQAAAAtnZXRTdHJCeUtleQAAAAEFAAAABGdhbWUFAAAABE5PTkUJAAACAAAAAQIAAAAhdGhpcyBnYW1lIGhhcyBhbHJlYWR5IGJlZW4gcGxheWVkCQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACBQAAAARnYW1lCQABLAAAAAIJAAEsAAAAAgkAASwAAAACBQAAAAZ3aW5uZXICAAAABS1XSU47BQAAAAVsb3NlcgIAAAAFLUxPU0UJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA5nZXRLZXlXaW5Db3VudAAAAAEFAAAABndpbm5lcgkAAGQAAAACCQEAAAAQZ2V0VmFsdWVXaW5Db3VudAAAAAEFAAAABndpbm5lcgAAAAAAAAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAD2dldEtleUxvc2VDb3VudAAAAAEFAAAABWxvc2VyCQAAZAAAAAIJAQAAABFnZXRWYWx1ZUxvc2VDb3VudAAAAAEFAAAABWxvc2VyAAAAAAAAAAABBQAAAANuaWwAAAAA5h7f2g==", "chainId": 84, "height": 666829, "spentComplexity": 0 } View: original | compacted Prev: s1J5YMir3DTPfLVXYLGjYeatr3SK4QW9EeUEaeCa3f1 Next: CzUE9pe3z5M47mn3FPKvBJHdSrVUhmf9sGFZvCcsgGnz Diff:
Old | New | Differences | |
---|---|---|---|
87 | 87 | let userAddress = toBase58String(i.caller.bytes) | |
88 | 88 | if ((pmt.amount != PRICE)) | |
89 | 89 | then throw("purchase amount cannot be not equal to the price") | |
90 | - | else if (validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
90 | + | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
91 | 91 | then throw("invalid coordinates order") | |
92 | 92 | else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE)) | |
93 | 93 | then throw("this patent is already exists") |
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 = "ORACLE" | |
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 ((x2 > x1)) | |
39 | 39 | then false | |
40 | 40 | else if (if ((x1 == x2)) | |
41 | 41 | then (y2 > y1) | |
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, x2, y1, y2))) | |
48 | 48 | then false | |
49 | 49 | else if (!(validateTwoCoords(x2, x3, y2, y3))) | |
50 | 50 | then false | |
51 | 51 | else if (!(validateTwoCoords(x3, x4, y3, y4))) | |
52 | 52 | then false | |
53 | 53 | else if (!(validateTwoCoords(x4, x5, y4, y5))) | |
54 | 54 | then false | |
55 | 55 | else if (!(validateTwoCoords(x5, x6, y5, 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 | 81 | @Callable(i) | |
82 | 82 | func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
83 | 83 | let pmt = extract(i.payment) | |
84 | 84 | if (isDefined(pmt.assetId)) | |
85 | 85 | then throw("can use WAVES only at the moment") | |
86 | 86 | else { | |
87 | 87 | let userAddress = toBase58String(i.caller.bytes) | |
88 | 88 | if ((pmt.amount != PRICE)) | |
89 | 89 | then throw("purchase amount cannot be not equal to the price") | |
90 | - | else if (validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
90 | + | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
91 | 91 | then throw("invalid coordinates order") | |
92 | 92 | else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE)) | |
93 | 93 | then throw("this patent is already exists") | |
94 | 94 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress)]) | |
95 | 95 | } | |
96 | 96 | } | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | ||
100 | 100 | @Callable(i) | |
101 | 101 | func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
102 | 102 | let pmt = extract(i.payment) | |
103 | 103 | if (isDefined(pmt.assetId)) | |
104 | 104 | then throw("can use WAVES only at the moment") | |
105 | 105 | else { | |
106 | 106 | let userAddress = toBase58String(i.caller.bytes) | |
107 | 107 | let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
108 | 108 | if ((pmt.amount != PATENTPRICE)) | |
109 | 109 | then throw("purchase amount cannot be not equal to the price") | |
110 | 110 | else if (validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
111 | 111 | then throw("invalid coordinates order") | |
112 | 112 | else if ((patentOwnerAddress == NONE)) | |
113 | 113 | then throw("there is no such patent") | |
114 | 114 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))]) | |
115 | 115 | } | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | ||
120 | 120 | @Callable(i) | |
121 | 121 | func withdraw () = { | |
122 | 122 | let userAddress = toBase58String(i.caller.bytes) | |
123 | 123 | let balance = getValueBalanceUser(userAddress) | |
124 | 124 | if ((0 >= balance)) | |
125 | 125 | then throw("insufficient balance") | |
126 | 126 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)])) | |
127 | 127 | } | |
128 | 128 | ||
129 | 129 | ||
130 | 130 | ||
131 | 131 | @Callable(i) | |
132 | 132 | func endGame (game,winner,loser) = { | |
133 | 133 | let oracleAddres = toBase58String(i.caller.bytes) | |
134 | 134 | if ((oracleAddres != ORACLE)) | |
135 | 135 | then throw("only oracle can inform about games results") | |
136 | 136 | else if ((winner == loser)) | |
137 | 137 | then throw("winner and loser must be different") | |
138 | 138 | else if ((getStrByKey(game) != NONE)) | |
139 | 139 | then throw("this game has already been played") | |
140 | 140 | else WriteSet([DataEntry(game, (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))]) | |
141 | 141 | } | |
142 | 142 | ||
143 | 143 |
github/deemru/w8io/169f3d6 41.71 ms ◑