tx · BBcE14RcP2V15Ck5JEdWuT4NGASCJzuaSzvJRgQ9TFPM 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc: -0.01400000 Waves 2019.09.08 15:41 [667114] smart account 3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc > SELF 0.00000000 Waves
{ "type": 13, "id": "BBcE14RcP2V15Ck5JEdWuT4NGASCJzuaSzvJRgQ9TFPM", "fee": 1400000, "feeAssetId": null, "timestamp": 1567946527494, "version": 1, "sender": "3N18S8xfWJYHVuGfJcpcPVh7LsnqR9hKTcc", "senderPublicKey": "9cETBksYN8YMHGvDB6BEqmH9HScpCMBRZwnjCviRQ9aA", "proofs": [ "4sj6hjt6i9dhAcHSmzKSEYuBoRBeK8HSNEoeuKjHKbgcghvXaaij3gRsjTZqGorTHCbJNoJwh7m7EdLhq8dftUCi" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAAVQUklDRQAAAAAABfXhAAAAAAALUEFURU5UUFJJQ0UAAAAAAAvrwgAAAAAABk9SQUNMRQIAAAAjM012aXNEZkE2dk5nNGk2aUtZV1o4Yld2eVA0aW1mQmI5ZXEAAAAAA1dJTgIAAAADV0lOAAAAAARMT1NFAgAAAARMT1NFAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAE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Jlc3MJAABkAAAAAgkBAAAAFmdldFZhbHVlSW5zdXJhbmNlQ291bnQAAAABBQAAAAt1c2VyQWRkcmVzcwAAAAAAAAAAAQUAAAADbmlsAAAAANArdxk=", "chainId": 84, "height": 667114, "spentComplexity": 0 } View: original | compacted Prev: CJBoNBF5kKKjWqhLQ2E123KMaCxZM2rei8qyxka2jjKs Next: none Diff:
Old | New | Differences | |
---|---|---|---|
109 | 109 | then throw("invalid coordinates order") | |
110 | 110 | else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE)) | |
111 | 111 | then throw("this patent is already exists") | |
112 | - | else if ((getValueUserPatentCount(userAddress) >= | |
112 | + | else if ((getValueUserPatentCount(userAddress) >= 5)) | |
113 | 113 | then throw("you cannot have more than 2 patents") | |
114 | 114 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1))]) | |
115 | 115 | } | |
133 | 133 | then throw("there is no such patent") | |
134 | 134 | else if ((patentOwnerAddress == userAddress)) | |
135 | 135 | then throw("you cannot buy your own patent") | |
136 | - | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))]) | |
136 | + | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount)), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1)), DataEntry(getKeyUserPatentCount(patentOwnerAddress), (getValueUserPatentCount(userAddress) - 1))]) | |
137 | 137 | } | |
138 | 138 | } | |
139 | 139 |
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) = ((((((((((((((((((((((("patent:" + 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 | func getKeyGame (game) = ("game_" + game) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getValueGame (game) = getStrByKey(getKeyGame(game)) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | func getKeyInsuranceCount (user) = (user + "_insurance_cnt") | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | func getValueInsuranceCount (user) = getNumberByKey(getKeyInsuranceCount(user)) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | func getKeyUserPatentCount (user) = (user + "_patent_cnt") | |
94 | 94 | ||
95 | 95 | ||
96 | 96 | func getValueUserPatentCount (user) = getNumberByKey(getKeyUserPatentCount(user)) | |
97 | 97 | ||
98 | 98 | ||
99 | 99 | @Callable(i) | |
100 | 100 | func patent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
101 | 101 | let pmt = extract(i.payment) | |
102 | 102 | if (isDefined(pmt.assetId)) | |
103 | 103 | then throw("can use WAVES only at the moment") | |
104 | 104 | else { | |
105 | 105 | let userAddress = toBase58String(i.caller.bytes) | |
106 | 106 | if ((pmt.amount != PRICE)) | |
107 | 107 | then throw("purchase amount cannot be not equal to the price") | |
108 | 108 | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
109 | 109 | then throw("invalid coordinates order") | |
110 | 110 | else if ((getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) != NONE)) | |
111 | 111 | then throw("this patent is already exists") | |
112 | - | else if ((getValueUserPatentCount(userAddress) >= | |
112 | + | else if ((getValueUserPatentCount(userAddress) >= 5)) | |
113 | 113 | then throw("you cannot have more than 2 patents") | |
114 | 114 | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1))]) | |
115 | 115 | } | |
116 | 116 | } | |
117 | 117 | ||
118 | 118 | ||
119 | 119 | ||
120 | 120 | @Callable(i) | |
121 | 121 | func buyPatent (x1,y1,x2,y2,x3,y3,x4,y4,x5,y5,x6,y6) = { | |
122 | 122 | let pmt = extract(i.payment) | |
123 | 123 | if (isDefined(pmt.assetId)) | |
124 | 124 | then throw("can use WAVES only at the moment") | |
125 | 125 | else { | |
126 | 126 | let userAddress = toBase58String(i.caller.bytes) | |
127 | 127 | let patentOwnerAddress = getStrByKey(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6)) | |
128 | 128 | if ((pmt.amount != PATENTPRICE)) | |
129 | 129 | then throw("purchase amount cannot be not equal to the price") | |
130 | 130 | else if (!(validateCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6))) | |
131 | 131 | then throw("invalid coordinates order") | |
132 | 132 | else if ((patentOwnerAddress == NONE)) | |
133 | 133 | then throw("there is no such patent") | |
134 | 134 | else if ((patentOwnerAddress == userAddress)) | |
135 | 135 | then throw("you cannot buy your own patent") | |
136 | - | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount))]) | |
136 | + | else WriteSet([DataEntry(genKeyFromCoords(x1, y1, x2, y2, x3, y3, x4, y4, x5, y5, x6, y6), userAddress), DataEntry(getKeyBalanceUser(patentOwnerAddress), (getValueBalanceUser(patentOwnerAddress) + pmt.amount)), DataEntry(getKeyUserPatentCount(userAddress), (getValueUserPatentCount(userAddress) + 1)), DataEntry(getKeyUserPatentCount(patentOwnerAddress), (getValueUserPatentCount(userAddress) - 1))]) | |
137 | 137 | } | |
138 | 138 | } | |
139 | 139 | ||
140 | 140 | ||
141 | 141 | ||
142 | 142 | @Callable(i) | |
143 | 143 | func withdraw () = { | |
144 | 144 | let userAddress = toBase58String(i.caller.bytes) | |
145 | 145 | let balance = getValueBalanceUser(userAddress) | |
146 | 146 | if ((0 >= balance)) | |
147 | 147 | then throw("insufficient balance") | |
148 | 148 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceUser(userAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(userAddress), balance, unit)])) | |
149 | 149 | } | |
150 | 150 | ||
151 | 151 | ||
152 | 152 | ||
153 | 153 | @Callable(i) | |
154 | 154 | func gameReport (game,winner,loser) = { | |
155 | 155 | let oracleAddres = toBase58String(i.caller.bytes) | |
156 | 156 | if ((oracleAddres != ORACLE)) | |
157 | 157 | then throw("only oracle can inform about games results") | |
158 | 158 | else if ((winner == loser)) | |
159 | 159 | then throw("winner and loser must be different") | |
160 | 160 | else if ((getValueGame(game) != NONE)) | |
161 | 161 | then throw("this game has already been played") | |
162 | 162 | else WriteSet([DataEntry(getKeyGame(game), (((winner + "-WIN;") + loser) + "-LOSE")), DataEntry(getKeyWinCount(winner), (getValueWinCount(winner) + 1)), DataEntry(getKeyLoseCount(loser), (getValueLoseCount(loser) + 1))]) | |
163 | 163 | } | |
164 | 164 | ||
165 | 165 | ||
166 | 166 | ||
167 | 167 | @Callable(i) | |
168 | 168 | func insure () = { | |
169 | 169 | let pmt = extract(i.payment) | |
170 | 170 | let insurancePrice = fraction(PRICE, 7, 100) | |
171 | 171 | if (isDefined(pmt.assetId)) | |
172 | 172 | then throw("can use WAVES only at the moment") | |
173 | 173 | else { | |
174 | 174 | let userAddress = toBase58String(i.caller.bytes) | |
175 | 175 | if ((pmt.amount != insurancePrice)) | |
176 | 176 | then throw("insurance payment amount cannot be not equal to the insurance price") | |
177 | 177 | else WriteSet([DataEntry(getKeyInsuranceCount(userAddress), (getValueInsuranceCount(userAddress) + 1))]) | |
178 | 178 | } | |
179 | 179 | } | |
180 | 180 | ||
181 | 181 |
github/deemru/w8io/169f3d6 35.65 ms ◑