tx · 7CoBaP6zFgq7v4hoGhprmJR7asRrEEWKuJGkPHkSAwhr

3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn:  -0.00700000 Waves

2023.03.21 19:40 [2500019] smart account 3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn > SELF 0.00000000 Waves

{ "type": 13, "id": "7CoBaP6zFgq7v4hoGhprmJR7asRrEEWKuJGkPHkSAwhr", "fee": 700000, "feeAssetId": null, "timestamp": 1679416879769, "version": 2, "chainId": 84, "sender": "3MxVYj6ScMArhAamy7nB6b342kh1Pso1LTn", "senderPublicKey": "CZeucjRLCKrkiP9zuj9KbLe23Wv9DywFzHBqNDnte51B", "proofs": [ "3Fc6qQ4yeX6iJTLp5zhaR4ev1MzFM3xHCzDyaPSATsHnUVgAGTCvT9k4ovHDoE9HipTri7DN9p1cE9FFMGgf5BXs" ], "script": "base64:BgI6CAISBAoCCAgSBAoCCAESAwoBCBIGCgQICAgIEgUKAwgICBIDCgECEgMKAQgSBgoECAEBARIECgIBARMADmNvbGxlY3Rpb25OYW1lCQERQGV4dHJOYXRpdmUoMTA1OCkBAg5jb2xsZWN0aW9uTmFtZQAGc3ltYm9sCQERQGV4dHJOYXRpdmUoMTA1OCkBAgZzeW1ib2wAC2Rlc2NyaXB0aW9uCQERQGV4dHJOYXRpdmUoMTA1OCkBAgtkZXNjcmlwdGlvbgALdG90YWxBbW91bnQJARFAZXh0ck5hdGl2ZSgxMDU1KQECC3RvdGFsQW1vdW50AAdiYXNlVVJJCQERQGV4dHJOYXRpdmUoMTA1OCkBAgdiYXNlVVJJAAhkQXBwSnNvbgkBB0FkZHJlc3MBCQDZBAECIzNNckdhWlZSaGtuRUdmSEoxOXR0VVBObkRSb0ZxY0hoVk43AAx0b2tlblBheW1lbnQJARFAZXh0ck5hdGl2ZSgxMDU3KQECDHRva2VuUGF5bWVudAARdG9rZW5QYXltZW50QXNzZXQJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkA7AcBCQERQGV4dHJO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yBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgCefXkL", "height": 2500019, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 4LgSfj2daKsGaDic2KWV5ouEwGWbzKoNrmL7J7qUdFh7 Next: 4JPsC7Kje7M9sYHWjWprUpjLTNaX9PJ6LdhydPv7fYHR Diff:
OldNewDifferences
1313
1414 let dAppJson = Address(fromBase58String("3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7"))
1515
16+let tokenPayment = getBinaryValue("tokenPayment")
17+
18+let tokenPaymentAsset = valueOrErrorMessage(assetInfo(getBinaryValue("tokenPayment")), "token payment asset doesn't connect")
19+
1620 let lendCount = getIntegerValue("lendCount")
1721
1822 let lendCurrentCount = getIntegerValue("lendCurrentCount")
23+
24+func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id")
25+
1926
2027 func onlyInternal (caller) = if ((caller == this))
2128 then unit
2734 else ScriptTransfer(to, 1, assetId)
2835
2936
30-func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id")
31-
32-
3337 func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1))
3438 then unit
3539 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 getLendJson (lendId) = {
48+ let lendIdString = toString(lendId)
49+ getStringValue(("lend-" + lendIdString))
50+ }
51+
52+
53+func getKey (lendJson,key) = {
54+ let timeUnitSeconds = {
55+ let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil)
56+ if ($isInstanceOf(@, "String"))
57+ then @
58+ else throw(($getType(@) + " couldn't be cast to String"))
59+ }
60+ if ((timeUnitSeconds == timeUnitSeconds))
61+ then timeUnitSeconds
62+ else throw("Strict value is not equal to itself.")
63+ }
3664
3765
3866 func getRentCount (lendId) = {
4169 }
4270
4371
72+func calcLendCost (lendId,timeUnitSeconds) = {
73+ let lendJson = getLendJson(lendId)
74+ let timeUnitPriceString = getKey(lendJson, "timeUnitPrice")
75+ if ((timeUnitPriceString == timeUnitPriceString))
76+ then {
77+ let timeUnitPrice = parseIntValue(timeUnitPriceString)
78+ (timeUnitSeconds * timeUnitPrice)
79+ }
80+ else throw("Strict value is not equal to itself.")
81+ }
82+
83+
4484 @Callable(i)
45-func setString (_key,_value) = [StringEntry(_key, _value)]
85+func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)])
4686
4787
4888
4989 @Callable(i)
50-func setInt (_key,_value) = [IntegerEntry(_key, _value)]
90+func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)])
5191
5292
5393
5494 @Callable(i)
55-func deleteEntry (_key) = [DeleteEntry(_key)]
95+func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)])
5696
5797
5898
5999 @Callable(i)
60100 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+
102+
103+
104+@Callable(i)
105+func setUser (assetId,user,expires) = {
106+ let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil)
107+ if ((res == res))
108+ then $Tuple2([StringEntry(("userOf-" + assetId), {
109+ let @ = res
110+ if ($isInstanceOf(@, "String"))
111+ then @
112+ else throw(($getType(@) + " couldn't be cast to String"))
113+ })], res)
114+ else throw("Strict value is not equal to itself.")
115+ }
116+
117+
118+
119+@Callable(i)
120+func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)])
61121
62122
63123
117177
118178
119179 @Callable(i)
120-func initRent (lendId,timeUnitCount) = {
180+func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), {
121181 let lendIdString = toString(lendId)
122182 let lendJson = getStringValue(("lend-" + lendIdString))
123183 let rentId = getRentCount(lendId)
146206 else throw("Strict value is not equal to itself.")
147207 }
148208 else throw("Strict value is not equal to itself.")
149- }
209+ })
150210
151211
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let collectionName = getStringValue("collectionName")
55
66 let symbol = getStringValue("symbol")
77
88 let description = getStringValue("description")
99
1010 let totalAmount = getIntegerValue("totalAmount")
1111
1212 let baseURI = getStringValue("baseURI")
1313
1414 let dAppJson = Address(fromBase58String("3MrGaZVRhknEGfHJ19ttUPNnDRoFqcHhVN7"))
1515
16+let tokenPayment = getBinaryValue("tokenPayment")
17+
18+let tokenPaymentAsset = valueOrErrorMessage(assetInfo(getBinaryValue("tokenPayment")), "token payment asset doesn't connect")
19+
1620 let lendCount = getIntegerValue("lendCount")
1721
1822 let lendCurrentCount = getIntegerValue("lendCurrentCount")
23+
24+func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id")
25+
1926
2027 func onlyInternal (caller) = if ((caller == this))
2128 then unit
2229 else throw("Only internal call")
2330
2431
2532 func transferOrNot (to,assetId) = if ((to == this))
2633 then StringEntry("smth", "smth")
2734 else ScriptTransfer(to, 1, assetId)
2835
2936
30-func parseIdtoAsset (assetId) = valueOrErrorMessage(assetInfo(fromBase58String(assetId)), "Can't find asset by asset id")
31-
32-
3337 func checkAssetOwner (caller,assetId) = if ((assetBalance(caller, fromBase58String(assetId)) == 1))
3438 then unit
3539 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 getLendJson (lendId) = {
48+ let lendIdString = toString(lendId)
49+ getStringValue(("lend-" + lendIdString))
50+ }
51+
52+
53+func getKey (lendJson,key) = {
54+ let timeUnitSeconds = {
55+ let @ = invoke(dAppJson, "readByJSONKey", [lendJson, key], nil)
56+ if ($isInstanceOf(@, "String"))
57+ then @
58+ else throw(($getType(@) + " couldn't be cast to String"))
59+ }
60+ if ((timeUnitSeconds == timeUnitSeconds))
61+ then timeUnitSeconds
62+ else throw("Strict value is not equal to itself.")
63+ }
3664
3765
3866 func getRentCount (lendId) = {
3967 let lendIdString = toString(lendId)
4068 getIntegerValue(("lend-rentCount-" + lendIdString))
4169 }
4270
4371
72+func calcLendCost (lendId,timeUnitSeconds) = {
73+ let lendJson = getLendJson(lendId)
74+ let timeUnitPriceString = getKey(lendJson, "timeUnitPrice")
75+ if ((timeUnitPriceString == timeUnitPriceString))
76+ then {
77+ let timeUnitPrice = parseIntValue(timeUnitPriceString)
78+ (timeUnitSeconds * timeUnitPrice)
79+ }
80+ else throw("Strict value is not equal to itself.")
81+ }
82+
83+
4484 @Callable(i)
45-func setString (_key,_value) = [StringEntry(_key, _value)]
85+func setString (_key,_value) = valueOrElse(onlyInternal(i.caller), [StringEntry(_key, _value)])
4686
4787
4888
4989 @Callable(i)
50-func setInt (_key,_value) = [IntegerEntry(_key, _value)]
90+func setInt (_key,_value) = valueOrElse(onlyInternal(i.caller), [IntegerEntry(_key, _value)])
5191
5292
5393
5494 @Callable(i)
55-func deleteEntry (_key) = [DeleteEntry(_key)]
95+func deleteEntry (_key) = valueOrElse(onlyInternal(i.caller), [DeleteEntry(_key)])
5696
5797
5898
5999 @Callable(i)
60100 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+
102+
103+
104+@Callable(i)
105+func setUser (assetId,user,expires) = {
106+ let res = invoke(dAppJson, "makeJSON", [["user", "expires"], [user, expires]], nil)
107+ if ((res == res))
108+ then $Tuple2([StringEntry(("userOf-" + assetId), {
109+ let @ = res
110+ if ($isInstanceOf(@, "String"))
111+ then @
112+ else throw(($getType(@) + " couldn't be cast to String"))
113+ })], res)
114+ else throw("Strict value is not equal to itself.")
115+ }
116+
117+
118+
119+@Callable(i)
120+func setTokenPayment (assetBinary) = valueOrElse(onlyInternal(i.caller), [BinaryEntry("tokenPayment", assetBinary)])
61121
62122
63123
64124 @Callable(i)
65125 func mint (to) = {
66126 let tokenId = (totalAmount + 1)
67127 let tokenIdString = toString(tokenId)
68128 let preName = ((symbol + "#") + tokenIdString)
69129 let name = if ((16 >= size(preName)))
70130 then preName
71131 else tokenIdString
72132 let tokenURI = (baseURI + tokenIdString)
73133 let json = {
74134 let @ = invoke(dAppJson, "makeJSON", [["tokenURI"], [tokenURI]], nil)
75135 if ($isInstanceOf(@, "String"))
76136 then @
77137 else throw(($getType(@) + " couldn't be cast to String"))
78138 }
79139 let asset = Issue(name, json, 1, 0, false, unit, height)
80140 let assetId = calculateAssetId(asset)
81141 let toAddress = Address(fromBase58String(to))
82142 let transfer = transferOrNot(toAddress, assetId)
83143 if ((transfer == transfer))
84144 then [asset, transfer, IntegerEntry("totalAmount", tokenId), StringEntry(name, tokenURI)]
85145 else throw("Strict value is not equal to itself.")
86146 }
87147
88148
89149
90150 @Callable(i)
91151 func initLend (assetId,timeUnitSeconds,timeUnitPrice,timeUnitCount) = valueOrElse(checkAssetOwner(i.caller, assetId), {
92152 let asset = parseIdtoAsset(assetId)
93153 let tokenURI = {
94154 let @ = invoke(dAppJson, "readByJSONKey", [asset.description, "tokenURI"], nil)
95155 if ($isInstanceOf(@, "String"))
96156 then @
97157 else throw(($getType(@) + " couldn't be cast to String"))
98158 }
99159 if ((tokenURI == tokenURI))
100160 then {
101161 let lendJson = {
102162 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)
103163 if ($isInstanceOf(@, "String"))
104164 then @
105165 else throw(($getType(@) + " couldn't be cast to String"))
106166 }
107167 if ((lendJson == lendJson))
108168 then {
109169 let lendIdString = toString(lendCount)
110170 [IntegerEntry("lendCount", (lendCount + 1)), IntegerEntry("lendCurrentCount", (lendCurrentCount + 1)), IntegerEntry(("lend-rentCount-" + lendIdString), 0), StringEntry(("lend-" + lendIdString), lendJson)]
111171 }
112172 else throw("Strict value is not equal to itself.")
113173 }
114174 else throw("Strict value is not equal to itself.")
115175 })
116176
117177
118178
119179 @Callable(i)
120-func initRent (lendId,timeUnitCount) = {
180+func initRent (lendId,timeUnitCount) = valueOrElse(checkPayment(i.payments, calcLendCost(lendId, timeUnitCount)), {
121181 let lendIdString = toString(lendId)
122182 let lendJson = getStringValue(("lend-" + lendIdString))
123183 let rentId = getRentCount(lendId)
124184 let rentIdString = toString(rentId)
125185 let timeUnitSeconds = {
126186 let @ = invoke(dAppJson, "readByJSONKey", [lendJson, "timeUnitSeconds"], nil)
127187 if ($isInstanceOf(@, "String"))
128188 then @
129189 else throw(($getType(@) + " couldn't be cast to String"))
130190 }
131191 if ((timeUnitSeconds == timeUnitSeconds))
132192 then {
133193 let timeUnitSecondsInt = parseIntValue(timeUnitSeconds)
134194 if ((timeUnitSecondsInt == timeUnitSecondsInt))
135195 then {
136196 let rentJson = {
137197 let @ = invoke(dAppJson, "makeJSON", [["customer", "timeUnitCount", "startTimestamp", "endTimestamp", "closed"], [toString(i.caller), toString(timeUnitCount), toString(lastBlock.timestamp), toString((lastBlock.timestamp + (timeUnitSecondsInt * timeUnitCount))), "0"]], nil)
138198 if ($isInstanceOf(@, "String"))
139199 then @
140200 else throw(($getType(@) + " couldn't be cast to String"))
141201 }
142202 if ((rentJson == rentJson))
143203 then [IntegerEntry(("lend-rentCount-" + lendIdString), (rentId + 1)), StringEntry(((("lend-rent-" + lendIdString) + "-") + rentIdString), rentJson)]
144204 else throw("Strict value is not equal to itself.")
145205 }
146206 else throw("Strict value is not equal to itself.")
147207 }
148208 else throw("Strict value is not equal to itself.")
149- }
209+ })
150210
151211

github/deemru/w8io/026f985 
40.35 ms