tx · 4JPsC7Kje7M9sYHWjWprUpjLTNaX9PJ6LdhydPv7fYHR 3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn: -0.00700000 Waves 2023.03.21 19:49 [2500027] smart account 3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn > SELF 0.00000000 Waves
{ "type": 13, "id": "4JPsC7Kje7M9sYHWjWprUpjLTNaX9PJ6LdhydPv7fYHR", "fee": 700000, "feeAssetId": null, "timestamp": 1679417428224, "version": 2, "chainId": 84, "sender": "3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn", "senderPublicKey": "CZeucjRLCKrkiP9zuj9KbLe23Wv9DywFzHBqNDnte51B", "proofs": [ "T7muYGagwfwH7CRg5tWshgY67ooD8AsFv8KjV83VkTiPw2TPztfratg2CMYLEz9izAn1otQUKNs1SvViBSXfYfZ" ], "script": "base64:BgJACAISBAoCCAgSBAoCCAESAwoBCBIGCgQICAgIEgUKAwgICBIDCgECEgMKAQgSBgoECAEBARIECgIBARIECgIBARMADmNvbGxlY3Rpb25OYW1lCQERQGV4dHJOYXRpdmUoMTA1OCkBAg5jb2xsZWN0aW9uTmFtZQAGc3ltYm9sCQERQGV4dHJOYXRpdmUoMTA1OCkBAgZzeW1ib2wAC2Rlc2NyaXB0aW9uCQERQGV4dHJOYXRpdmUoMTA1OCkBAgtkZXNjcmlwdGlvbgALdG90YWxBbW91bnQJARFAZXh0ck5hdGl2ZSgxMDU1KQECC3RvdGFsQW1vdW50AAdiYXNlVVJJCQERQGV4dHJOYXRpdmUoMTA1OCkBAgdiYXNlVVJJAAhkQXBwSnNvbgkBB0FkZHJlc3MBCQDZBAECIzNNckdhWlZSaGtuRUdmSEoxOXR0VVBObkRSb0ZxY0hoVk43AAx0b2tlblBheW1lbnQJARFAZXh0ck5hdGl2ZSgxMDU3KQECDHRva2VuUGF5bWVudAARdG9rZW5QYXltZW50QXNzZXQJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkA7AcBCQERQGV4dHJOYXRp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QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQd0ZXN0UGF5AgZsZW5kSWQNdGltZVVuaXRDb3VudAkAzAgCCQEMSW50ZWdlckVudHJ5AgIFRGVidWcJAQxjYWxjTGVuZENvc3QCBQZsZW5kSWQFDXRpbWVVbml0Q291bnQFA25pbABnQU+z", "height": 2500027, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7CoBaP6zFgq7v4hoGhprmJR7asRrEEWKuJGkPHkSAwhr Next: 3vJB9f5KnJk2zbprDxK34u54vXixwrdBe2ARKpuSQ4Ev Diff:
Old | New | Differences | |
---|---|---|---|
209 | 209 | }) | |
210 | 210 | ||
211 | 211 | ||
212 | + | ||
213 | + | @Callable(i) | |
214 | + | func testPay (lendId,timeUnitCount) = [IntegerEntry("Debug", calcLendCost(lendId, timeUnitCount))] | |
215 | + | ||
216 | + |
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 | 27 | func onlyInternal (caller) = if ((caller == this)) | |
28 | 28 | then unit | |
29 | 29 | else throw("Only internal call") | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func transferOrNot (to,assetId) = if ((to == this)) | |
33 | 33 | then StringEntry("smth", "smth") | |
34 | 34 | else ScriptTransfer(to, 1, assetId) | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1)) | |
38 | 38 | then unit | |
39 | 39 | else throw("Only asset owner") | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func checkPayment (payments,amount) = if ((payments[0].amount >= amount)) | |
43 | 43 | then unit | |
44 | 44 | else throw("amount less then need") | |
45 | 45 | ||
46 | 46 | ||
47 | 47 | func getLendJson (lendId) = { | |
48 | 48 | let lendIdString = toString(lendId) | |
49 | 49 | getStringValue(("lend-" + lendIdString)) | |
50 | 50 | } | |
51 | 51 | ||
52 | 52 | ||
53 | 53 | func getKey (lendJson,key) = { | |
54 | 54 | let timeUnitSeconds = { | |
55 | 55 | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil) | |
56 | 56 | if ($isInstanceOf(@, "String")) | |
57 | 57 | then @ | |
58 | 58 | else throw(($getType(@) + " couldn't be cast to String")) | |
59 | 59 | } | |
60 | 60 | if ((timeUnitSeconds == timeUnitSeconds)) | |
61 | 61 | then timeUnitSeconds | |
62 | 62 | else throw("Strict value is not equal to itself.") | |
63 | 63 | } | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getRentCount (lendId) = { | |
67 | 67 | let lendIdString = toString(lendId) | |
68 | 68 | getIntegerValue(("lend-rentCount-" + lendIdString)) | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func calcLendCost (lendId,timeUnitSeconds) = { | |
73 | 73 | let lendJson = getLendJson(lendId) | |
74 | 74 | let timeUnitPriceString = getKey(lendJson, "timeUnitPrice") | |
75 | 75 | if ((timeUnitPriceString == timeUnitPriceString)) | |
76 | 76 | then { | |
77 | 77 | let timeUnitPrice = parseIntValue(timeUnitPriceString) | |
78 | 78 | (timeUnitSeconds * timeUnitPrice) | |
79 | 79 | } | |
80 | 80 | else throw("Strict value is not equal to itself.") | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | @Callable(i) | |
85 | 85 | func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)]) | |
86 | 86 | ||
87 | 87 | ||
88 | 88 | ||
89 | 89 | @Callable(i) | |
90 | 90 | func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)]) | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | ||
94 | 94 | @Callable(i) | |
95 | 95 | func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)]) | |
96 | 96 | ||
97 | 97 | ||
98 | 98 | ||
99 | 99 | @Callable(i) | |
100 | 100 | 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)]) | |
101 | 101 | ||
102 | 102 | ||
103 | 103 | ||
104 | 104 | @Callable(i) | |
105 | 105 | func setUser (assetId,user,expires) = { | |
106 | 106 | let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil) | |
107 | 107 | if ((res == res)) | |
108 | 108 | then $Tuple2([StringEntry(("userOf-" + assetId), { | |
109 | 109 | let @ = res | |
110 | 110 | if ($isInstanceOf(@, "String")) | |
111 | 111 | then @ | |
112 | 112 | else throw(($getType(@) + " couldn't be cast to String")) | |
113 | 113 | })], res) | |
114 | 114 | else throw("Strict value is not equal to itself.") | |
115 | 115 | } | |
116 | 116 | ||
117 | 117 | ||
118 | 118 | ||
119 | 119 | @Callable(i) | |
120 | 120 | func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)]) | |
121 | 121 | ||
122 | 122 | ||
123 | 123 | ||
124 | 124 | @Callable(i) | |
125 | 125 | func mint (to) = { | |
126 | 126 | let tokenId = (totalAmount + 1) | |
127 | 127 | let tokenIdString = toString(tokenId) | |
128 | 128 | let preName = ((symbol + "#") + tokenIdString) | |
129 | 129 | let name = if ((16 >= size(preName))) | |
130 | 130 | then preName | |
131 | 131 | else tokenIdString | |
132 | 132 | let tokenURI = (baseURI + tokenIdString) | |
133 | 133 | let json = { | |
134 | 134 | let @ = invoke(dAppJson, "makeJSON", [["tokenURI"], [tokenURI]], nil) | |
135 | 135 | if ($isInstanceOf(@, "String")) | |
136 | 136 | then @ | |
137 | 137 | else throw(($getType(@) + " couldn't be cast to String")) | |
138 | 138 | } | |
139 | 139 | let asset = Issue(name, json, 1, 0, false, unit, height) | |
140 | 140 | let assetId = calculateAssetId(asset) | |
141 | 141 | let toAddress = Address(fromBase58String(to)) | |
142 | 142 | let transfer = transferOrNot(toAddress, assetId) | |
143 | 143 | if ((transfer == transfer)) | |
144 | 144 | then [asset, transfer, IntegerEntry("totalAmount", tokenId), StringEntry(name, tokenURI)] | |
145 | 145 | else throw("Strict value is not equal to itself.") | |
146 | 146 | } | |
147 | 147 | ||
148 | 148 | ||
149 | 149 | ||
150 | 150 | @Callable(i) | |
151 | 151 | func initLend (assetId,timeUnitSeconds,timeUnitPrice,timeUnitCount) = valueOrElse(checkAssetOwner(i.caller, assetId), { | |
152 | 152 | let asset = parseIdtoAsset(assetId) | |
153 | 153 | let tokenURI = { | |
154 | 154 | let @ = invoke(dAppJson, "readByJSONKey", [asset.description, "tokenURI"], nil) | |
155 | 155 | if ($isInstanceOf(@, "String")) | |
156 | 156 | then @ | |
157 | 157 | else throw(($getType(@) + " couldn't be cast to String")) | |
158 | 158 | } | |
159 | 159 | if ((tokenURI == tokenURI)) | |
160 | 160 | then { | |
161 | 161 | let lendJson = { | |
162 | 162 | 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) | |
163 | 163 | if ($isInstanceOf(@, "String")) | |
164 | 164 | then @ | |
165 | 165 | else throw(($getType(@) + " couldn't be cast to String")) | |
166 | 166 | } | |
167 | 167 | if ((lendJson == lendJson)) | |
168 | 168 | then { | |
169 | 169 | let lendIdString = toString(lendCount) | |
170 | 170 | [IntegerEntry("lendCount", (lendCount + 1)), IntegerEntry("lendCurrentCount", (lendCurrentCount + 1)), IntegerEntry(("lend-rentCount-" + lendIdString), 0), StringEntry(("lend-" + lendIdString), lendJson)] | |
171 | 171 | } | |
172 | 172 | else throw("Strict value is not equal to itself.") | |
173 | 173 | } | |
174 | 174 | else throw("Strict value is not equal to itself.") | |
175 | 175 | }) | |
176 | 176 | ||
177 | 177 | ||
178 | 178 | ||
179 | 179 | @Callable(i) | |
180 | 180 | func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), { | |
181 | 181 | let lendIdString = toString(lendId) | |
182 | 182 | let lendJson = getStringValue(("lend-" + lendIdString)) | |
183 | 183 | let rentId = getRentCount(lendId) | |
184 | 184 | let rentIdString = toString(rentId) | |
185 | 185 | let timeUnitSeconds = { | |
186 | 186 | let @ = invoke(dAppJson, "readByJSONKey", [lendJson, "timeUnitSeconds"], nil) | |
187 | 187 | if ($isInstanceOf(@, "String")) | |
188 | 188 | then @ | |
189 | 189 | else throw(($getType(@) + " couldn't be cast to String")) | |
190 | 190 | } | |
191 | 191 | if ((timeUnitSeconds == timeUnitSeconds)) | |
192 | 192 | then { | |
193 | 193 | let timeUnitSecondsInt = parseIntValue(timeUnitSeconds) | |
194 | 194 | if ((timeUnitSecondsInt == timeUnitSecondsInt)) | |
195 | 195 | then { | |
196 | 196 | let rentJson = { | |
197 | 197 | let @ = invoke(dAppJson, "makeJSON", [["customer", "timeUnitCount", "startTimestamp", "endTimestamp", "closed"], [toString(i.caller), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSecondsInt * timeUnitCount))), "0"]], nil) | |
198 | 198 | if ($isInstanceOf(@, "String")) | |
199 | 199 | then @ | |
200 | 200 | else throw(($getType(@) + " couldn't be cast to String")) | |
201 | 201 | } | |
202 | 202 | if ((rentJson == rentJson)) | |
203 | 203 | then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson)] | |
204 | 204 | else throw("Strict value is not equal to itself.") | |
205 | 205 | } | |
206 | 206 | else throw("Strict value is not equal to itself.") | |
207 | 207 | } | |
208 | 208 | else throw("Strict value is not equal to itself.") | |
209 | 209 | }) | |
210 | 210 | ||
211 | 211 | ||
212 | + | ||
213 | + | @Callable(i) | |
214 | + | func testPay (lendId,timeUnitCount) = [IntegerEntry("Debug", calcLendCost(lendId, timeUnitCount))] | |
215 | + | ||
216 | + |
github/deemru/w8io/026f985 35.57 ms ◑