tx · 9fZKAZMJLyTURLbyvdJWT3Br8rzswsYW7emxNiQ4YGwi 3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn: -0.00700000 Waves 2023.03.21 21:55 [2500163] smart account 3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn > SELF 0.00000000 Waves
{ "type": 13, "id": "9fZKAZMJLyTURLbyvdJWT3Br8rzswsYW7emxNiQ4YGwi", "fee": 700000, "feeAssetId": null, "timestamp": 1679424976687, "version": 2, "chainId": 84, "sender": "3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn", "senderPublicKey": "CZeucjRLCKrkiP9zuj9KbLe23Wv9DywFzHBqNDnte51B", "proofs": [ "sDJ7fpF6iooHk55Tz7TDjPUN8qAY6JVB5zU384zkzV8F9ARZBWD4ZasPDeDWC4q3uJQQXQvku7Lbk5JVfs5ogHv" ], "script": "base64:BgJECAISBAoCCAgSBAoCCAESAwoBCBIGCgQICAgIEgUKAwgICBIDCgECEgMKAQgSBgoECAEBARIECgIBARIDCgEBEgMKAQEWAA5jb2xsZWN0aW9uTmFtZQkBEUBleHRyTmF0aXZlKDEwNTgpAQIOY29sbGVjdGlvbk5hbWUABnN5bWJvbAkBEUBleHRyTmF0aXZlKDEwNTgpAQIGc3ltYm9sAAtkZXNjcmlwdGlvbgkBEUBleHRyTmF0aXZlKDEwNTgpAQILZGVzY3JpcHRpb24AC3RvdGFsQW1vdW50CQERQGV4dHJOYXRpdmUoMTA1NSkBAgt0b3RhbEFtb3VudAAHYmFzZVVSSQkBEUBleHRyTmF0aXZlKDEwNTgpAQIHYmFzZVVSSQAIZEFwcEpzb24JAQdBZGRyZXNzAQkA2QQBAiMzTXJHYVpWUmhrbkVHZkhKMTl0dFVQTm5EUm9GcWNIaFZONwAMdG9rZW5QYXltZW50CQERQGV4dHJOYXRpdmUoMTA1NykBAgx0b2tlblBheW1lbnQAEXRva2VuUGF5bWVudEFzc2V0CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAOwHAQkBEUB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kAZQIFEGxlbmRDdXJyZW50Q291bnQAAQkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCAUBaQZjYWxsZXIJAQtnZXRMZW5kQ29zdAEFBmxlbmRJZAUMdG9rZW5QYXltZW50BQNuaWwBaQEEdGVzdAEGbGVuZElkCQDMCAIJAQtTdHJpbmdFbnRyeQICBURlYnVnCQEGZ2V0S2V5AgkBC2dldExlbmRKc29uAQUGbGVuZElkAgVvd25lcgUDbmlsAMXPoNY=", "height": 2500163, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 2yDSbohKjDR9Eok1ngCVzy8CvuzKxNiGBhcCXiX9ZY6e Next: Hoj3MygE6WA8z5r5zCeE5Agm1KMYykuCbKaT8kGP3jpN Diff:
Old | New | Differences | |
---|---|---|---|
24 | 24 | func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id") | |
25 | 25 | ||
26 | 26 | ||
27 | - | func onlyInternal (caller) = if ((caller == this)) | |
28 | - | then unit | |
29 | - | else throw("Only internal call") | |
30 | - | ||
31 | - | ||
32 | 27 | func transferOrNot (to,assetId) = if ((to == this)) | |
33 | 28 | then StringEntry("smth", "smth") | |
34 | 29 | else ScriptTransfer(to, 1, assetId) | |
35 | - | ||
36 | - | ||
37 | - | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
38 | - | then unit | |
39 | - | else throw("Only asset owner") | |
40 | - | ||
41 | - | ||
42 | - | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
43 | - | then unit | |
44 | - | else throw("amount less then need") | |
45 | - | ||
46 | - | ||
47 | - | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
48 | - | then throw("this token already use") | |
49 | - | else unit | |
50 | 30 | ||
51 | 31 | ||
52 | 32 | func getLendJson (lendId) = { | |
84 | 64 | } | |
85 | 65 | else throw("Strict value is not equal to itself.") | |
86 | 66 | } | |
67 | + | ||
68 | + | ||
69 | + | func getLendCost (lendId) = valueOrElse(parseInt(getKey(getLendJson(lendId), "owner")), 0) | |
70 | + | ||
71 | + | ||
72 | + | func onlyInternal (caller) = if ((caller == this)) | |
73 | + | then unit | |
74 | + | else throw("Only internal call") | |
75 | + | ||
76 | + | ||
77 | + | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
78 | + | then unit | |
79 | + | else throw("Only asset owner") | |
80 | + | ||
81 | + | ||
82 | + | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
83 | + | then unit | |
84 | + | else throw("amount less then need") | |
85 | + | ||
86 | + | ||
87 | + | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
88 | + | then throw("this token already use") | |
89 | + | else unit | |
90 | + | ||
91 | + | ||
92 | + | func checkLendOwner (caller,lendId) = if ((getKey(getLendJson(lendId), "owner") != toString(caller))) | |
93 | + | then throw("you haven't perms") | |
94 | + | else unit | |
87 | 95 | ||
88 | 96 | ||
89 | 97 | @Callable(i) | |
205 | 213 | else throw(($getType(@) + " couldn't be cast to String")) | |
206 | 214 | } | |
207 | 215 | if ((rentJson == rentJson)) | |
208 | - | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson)] | |
216 | + | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson), IntegerEntry(("lend-cost-" + lendIdString), (calcLendCost(lendId, timeUnitCount) + getLendCost(lendId)))] | |
209 | 217 | else throw("Strict value is not equal to itself.") | |
210 | 218 | } | |
211 | 219 | else throw("Strict value is not equal to itself.") | |
214 | 222 | }) | |
215 | 223 | ||
216 | 224 | ||
225 | + | ||
226 | + | @Callable(i) | |
227 | + | func closeLend (lendId) = valueOrElse(checkLendOwner(i.caller, lendId), { | |
228 | + | let lendIdString = toString(lendId) | |
229 | + | [DeleteEntry(("lend-" + lendIdString)), DeleteEntry(("lend-rentCount" + lendIdString)), IntegerEntry("lendCurrentCount", (lendCurrentCount - 1)), ScriptTransfer(i.caller, getLendCost(lendId), tokenPayment)] | |
230 | + | }) | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(i) | |
235 | + | func test (lendId) = [StringEntry("Debug", getKey(getLendJson(lendId), "owner"))] | |
236 | + | ||
237 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let collectionName = getStringValue("collectionName") | |
5 | 5 | ||
6 | 6 | let symbol = getStringValue("symbol") | |
7 | 7 | ||
8 | 8 | let description = getStringValue("description") | |
9 | 9 | ||
10 | 10 | let totalAmount = getIntegerValue("totalAmount") | |
11 | 11 | ||
12 | 12 | let baseURI = getStringValue("baseURI") | |
13 | 13 | ||
14 | 14 | let dAppJson = Address(fromBase58String("3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7")) | |
15 | 15 | ||
16 | 16 | let tokenPayment = getBinaryValue("tokenPayment") | |
17 | 17 | ||
18 | 18 | let tokenPaymentAsset = valueOrErrorMessage(assetInfo(getBinaryValue("tokenPayment")), "token payment asset doesn't connect") | |
19 | 19 | ||
20 | 20 | let lendCount = getIntegerValue("lendCount") | |
21 | 21 | ||
22 | 22 | let lendCurrentCount = getIntegerValue("lendCurrentCount") | |
23 | 23 | ||
24 | 24 | func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id") | |
25 | 25 | ||
26 | 26 | ||
27 | - | func onlyInternal (caller) = if ((caller == this)) | |
28 | - | then unit | |
29 | - | else throw("Only internal call") | |
30 | - | ||
31 | - | ||
32 | 27 | func transferOrNot (to,assetId) = if ((to == this)) | |
33 | 28 | then StringEntry("smth", "smth") | |
34 | 29 | else ScriptTransfer(to, 1, assetId) | |
35 | - | ||
36 | - | ||
37 | - | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
38 | - | then unit | |
39 | - | else throw("Only asset owner") | |
40 | - | ||
41 | - | ||
42 | - | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
43 | - | then unit | |
44 | - | else throw("amount less then need") | |
45 | - | ||
46 | - | ||
47 | - | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
48 | - | then throw("this token already use") | |
49 | - | else unit | |
50 | 30 | ||
51 | 31 | ||
52 | 32 | func getLendJson (lendId) = { | |
53 | 33 | let lendIdString = toString(lendId) | |
54 | 34 | getStringValue(("lend-" + lendIdString)) | |
55 | 35 | } | |
56 | 36 | ||
57 | 37 | ||
58 | 38 | func getKey (lendJson,key) = { | |
59 | 39 | let timeUnitSeconds = { | |
60 | 40 | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil) | |
61 | 41 | if ($isInstanceOf(@, "String")) | |
62 | 42 | then @ | |
63 | 43 | else throw(($getType(@) + " couldn't be cast to String")) | |
64 | 44 | } | |
65 | 45 | if ((timeUnitSeconds == timeUnitSeconds)) | |
66 | 46 | then timeUnitSeconds | |
67 | 47 | else throw("Strict value is not equal to itself.") | |
68 | 48 | } | |
69 | 49 | ||
70 | 50 | ||
71 | 51 | func getRentCount (lendId) = { | |
72 | 52 | let lendIdString = toString(lendId) | |
73 | 53 | getIntegerValue(("lend-rentCount-" + lendIdString)) | |
74 | 54 | } | |
75 | 55 | ||
76 | 56 | ||
77 | 57 | func calcLendCost (lendId,timeUnitSeconds) = { | |
78 | 58 | let lendJson = getLendJson(lendId) | |
79 | 59 | let timeUnitPriceString = getKey(lendJson, "timeUnitPrice") | |
80 | 60 | if ((timeUnitPriceString == timeUnitPriceString)) | |
81 | 61 | then { | |
82 | 62 | let timeUnitPrice = parseIntValue(timeUnitPriceString) | |
83 | 63 | (timeUnitSeconds * timeUnitPrice) | |
84 | 64 | } | |
85 | 65 | else throw("Strict value is not equal to itself.") | |
86 | 66 | } | |
67 | + | ||
68 | + | ||
69 | + | func getLendCost (lendId) = valueOrElse(parseInt(getKey(getLendJson(lendId), "owner")), 0) | |
70 | + | ||
71 | + | ||
72 | + | func onlyInternal (caller) = if ((caller == this)) | |
73 | + | then unit | |
74 | + | else throw("Only internal call") | |
75 | + | ||
76 | + | ||
77 | + | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
78 | + | then unit | |
79 | + | else throw("Only asset owner") | |
80 | + | ||
81 | + | ||
82 | + | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
83 | + | then unit | |
84 | + | else throw("amount less then need") | |
85 | + | ||
86 | + | ||
87 | + | func checkAssetExists (assetId) = if (valueOrElse(getBoolean(assetId), false)) | |
88 | + | then throw("this token already use") | |
89 | + | else unit | |
90 | + | ||
91 | + | ||
92 | + | func checkLendOwner (caller,lendId) = if ((getKey(getLendJson(lendId), "owner") != toString(caller))) | |
93 | + | then throw("you haven't perms") | |
94 | + | else unit | |
87 | 95 | ||
88 | 96 | ||
89 | 97 | @Callable(i) | |
90 | 98 | func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)]) | |
91 | 99 | ||
92 | 100 | ||
93 | 101 | ||
94 | 102 | @Callable(i) | |
95 | 103 | func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)]) | |
96 | 104 | ||
97 | 105 | ||
98 | 106 | ||
99 | 107 | @Callable(i) | |
100 | 108 | func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)]) | |
101 | 109 | ||
102 | 110 | ||
103 | 111 | ||
104 | 112 | @Callable(i) | |
105 | 113 | func init (_collectionName,_symbol,_description,_baseURI) = valueOrElse(onlyInternal(i.caller), [StringEntry("collectionName", _collectionName), StringEntry("symbol", _symbol), StringEntry("description", _description), IntegerEntry("totalAmount", 0), StringEntry("baseURI", _baseURI)]) | |
106 | 114 | ||
107 | 115 | ||
108 | 116 | ||
109 | 117 | @Callable(i) | |
110 | 118 | func setUser (assetId,user,expires) = { | |
111 | 119 | let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil) | |
112 | 120 | if ((res == res)) | |
113 | 121 | then $Tuple2([StringEntry(("userOf-" + assetId), { | |
114 | 122 | let @ = res | |
115 | 123 | if ($isInstanceOf(@, "String")) | |
116 | 124 | then @ | |
117 | 125 | else throw(($getType(@) + " couldn't be cast to String")) | |
118 | 126 | })], res) | |
119 | 127 | else throw("Strict value is not equal to itself.") | |
120 | 128 | } | |
121 | 129 | ||
122 | 130 | ||
123 | 131 | ||
124 | 132 | @Callable(i) | |
125 | 133 | func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)]) | |
126 | 134 | ||
127 | 135 | ||
128 | 136 | ||
129 | 137 | @Callable(i) | |
130 | 138 | func mint (to) = { | |
131 | 139 | let tokenId = (totalAmount + 1) | |
132 | 140 | let tokenIdString = toString(tokenId) | |
133 | 141 | let preName = ((symbol + "#") + tokenIdString) | |
134 | 142 | let name = if ((16 >= size(preName))) | |
135 | 143 | then preName | |
136 | 144 | else tokenIdString | |
137 | 145 | let tokenURI = (baseURI + tokenIdString) | |
138 | 146 | let json = { | |
139 | 147 | let @ = invoke(dAppJson, "makeJSON", [["tokenURI"], [tokenURI]], nil) | |
140 | 148 | if ($isInstanceOf(@, "String")) | |
141 | 149 | then @ | |
142 | 150 | else throw(($getType(@) + " couldn't be cast to String")) | |
143 | 151 | } | |
144 | 152 | let asset = Issue(name, json, 1, 0, false, unit, height) | |
145 | 153 | let assetId = calculateAssetId(asset) | |
146 | 154 | let toAddress = Address(fromBase58String(to)) | |
147 | 155 | let transfer = transferOrNot(toAddress, assetId) | |
148 | 156 | if ((transfer == transfer)) | |
149 | 157 | then [asset, transfer, IntegerEntry("totalAmount", tokenId), StringEntry(name, tokenURI)] | |
150 | 158 | else throw("Strict value is not equal to itself.") | |
151 | 159 | } | |
152 | 160 | ||
153 | 161 | ||
154 | 162 | ||
155 | 163 | @Callable(i) | |
156 | 164 | func initLend (assetId,timeUnitSeconds,timeUnitPrice,timeUnitCount) = valueOrElse(checkAssetOwner(i.caller, assetId), valueOrElse(checkAssetExists(assetId), { | |
157 | 165 | let asset = parseIdtoAsset(assetId) | |
158 | 166 | let tokenURI = { | |
159 | 167 | let @ = invoke(dAppJson, "readByJSONKey", [asset.description, "tokenURI"], nil) | |
160 | 168 | if ($isInstanceOf(@, "String")) | |
161 | 169 | then @ | |
162 | 170 | else throw(($getType(@) + " couldn't be cast to String")) | |
163 | 171 | } | |
164 | 172 | if ((tokenURI == tokenURI)) | |
165 | 173 | then { | |
166 | 174 | let lendJson = { | |
167 | 175 | let @ = invoke(dAppJson, "makeJSON", [["supportedInterface", "assetdId", "tokenURI", "owner", "timeUnitSeconds", "timeUnitPrice", "timeUnitCount", "startTimestamp", "endTimestamp", "deposit", "claimed"], ["0", assetId, tokenURI, toString(i.caller), toString(timeUnitSeconds), toString(timeUnitPrice), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSeconds * timeUnitCount))), "0", "0"]], nil) | |
168 | 176 | if ($isInstanceOf(@, "String")) | |
169 | 177 | then @ | |
170 | 178 | else throw(($getType(@) + " couldn't be cast to String")) | |
171 | 179 | } | |
172 | 180 | if ((lendJson == lendJson)) | |
173 | 181 | then { | |
174 | 182 | let lendIdString = toString(lendCount) | |
175 | 183 | [IntegerEntry("lendCount", (lendCount + 1)), IntegerEntry("lendCurrentCount", (lendCurrentCount + 1)), IntegerEntry(("lend-rentCount-" + lendIdString), 0), StringEntry(("lend-" + lendIdString), lendJson), BooleanEntry(assetId, true)] | |
176 | 184 | } | |
177 | 185 | else throw("Strict value is not equal to itself.") | |
178 | 186 | } | |
179 | 187 | else throw("Strict value is not equal to itself.") | |
180 | 188 | })) | |
181 | 189 | ||
182 | 190 | ||
183 | 191 | ||
184 | 192 | @Callable(i) | |
185 | 193 | func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), { | |
186 | 194 | let lendIdString = toString(lendId) | |
187 | 195 | let lendJson = getStringValue(("lend-" + lendIdString)) | |
188 | 196 | let rentId = getRentCount(lendId) | |
189 | 197 | let rentIdString = toString(rentId) | |
190 | 198 | let timeUnitSeconds = { | |
191 | 199 | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, "timeUnitSeconds"], nil) | |
192 | 200 | if ($isInstanceOf(@, "String")) | |
193 | 201 | then @ | |
194 | 202 | else throw(($getType(@) + " couldn't be cast to String")) | |
195 | 203 | } | |
196 | 204 | if ((timeUnitSeconds == timeUnitSeconds)) | |
197 | 205 | then { | |
198 | 206 | let timeUnitSecondsInt = parseIntValue(timeUnitSeconds) | |
199 | 207 | if ((timeUnitSecondsInt == timeUnitSecondsInt)) | |
200 | 208 | then { | |
201 | 209 | let rentJson = { | |
202 | 210 | let @ = invoke(dAppJson, "makeJSON", [["customer", "timeUnitCount", "startTimestamp", "endTimestamp", "closed"], [toString(i.caller), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSecondsInt * timeUnitCount))), "0"]], nil) | |
203 | 211 | if ($isInstanceOf(@, "String")) | |
204 | 212 | then @ | |
205 | 213 | else throw(($getType(@) + " couldn't be cast to String")) | |
206 | 214 | } | |
207 | 215 | if ((rentJson == rentJson)) | |
208 | - | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson)] | |
216 | + | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson), IntegerEntry(("lend-cost-" + lendIdString), (calcLendCost(lendId, timeUnitCount) + getLendCost(lendId)))] | |
209 | 217 | else throw("Strict value is not equal to itself.") | |
210 | 218 | } | |
211 | 219 | else throw("Strict value is not equal to itself.") | |
212 | 220 | } | |
213 | 221 | else throw("Strict value is not equal to itself.") | |
214 | 222 | }) | |
215 | 223 | ||
216 | 224 | ||
225 | + | ||
226 | + | @Callable(i) | |
227 | + | func closeLend (lendId) = valueOrElse(checkLendOwner(i.caller, lendId), { | |
228 | + | let lendIdString = toString(lendId) | |
229 | + | [DeleteEntry(("lend-" + lendIdString)), DeleteEntry(("lend-rentCount" + lendIdString)), IntegerEntry("lendCurrentCount", (lendCurrentCount - 1)), ScriptTransfer(i.caller, getLendCost(lendId), tokenPayment)] | |
230 | + | }) | |
231 | + | ||
232 | + | ||
233 | + | ||
234 | + | @Callable(i) | |
235 | + | func test (lendId) = [StringEntry("Debug", getKey(getLendJson(lendId), "owner"))] | |
236 | + | ||
237 | + |
github/deemru/w8io/169f3d6 36.98 ms ◑