tx · BA8AULfhgW1nv4c5pdyScPwqMnybGt3UbdN3TYoN9jH4

3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx:  -0.00600000 Waves

2024.12.08 18:03 [3405806] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves

{ "type": 13, "id": "BA8AULfhgW1nv4c5pdyScPwqMnybGt3UbdN3TYoN9jH4", "fee": 600000, "feeAssetId": null, "timestamp": 1733670204548, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "3UzEEELgkLTxpBm9dLTJ8E95mxDMp7xHATowQenFSZXpr2vxyU7PQvk1npJqePcGQ2NPB6b2jJoJwRCdzfVpZ5P9" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgMKAQgSAwoBCBcAA1NFUAICX18ABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABZkZWZhdWx0UmVzdDJBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUEZ3WXRhOGJpRXozMXpwZUZlNURKSzh3RTV0clNwUVZGOAMJAAACAQFUBQckbWF0Y2gwAiMzTjdVdVlhcjYyNjRQNThGQmhWV0tQUUFoNFl1YTJoZ25ndgkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAABBJZHhDZmdBY3JlczJEYXBwAAEADUlkeENmZ1dsZ0RhcHAAAgEKa2V5UmVzdENmZwAC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CQDMCAIJAQtEZWxldGVFbnRyeQEJARFrZXlQcmljZUJ5QXNzZXRJZAEFCmFzc2V0SWRTdHIJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwkBEUBleHRyTmF0aXZlKDEwNjIpAQUGc2VsbGVyBQVwcmljZQUKd2xnQXNzZXRJZAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQERQGV4dHJOYXRpdmUoMTA2MikBCQERQGV4dHJOYXRpdmUoMTA1MykCBQt3bGdDb250cmFjdAULdGVhbUFkZHJLZXkFB2ZvclRlYW0FCndsZ0Fzc2V0SWQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyAAEJANkEAQUKYXNzZXRJZFN0cgUDbmlsBQ1jaGFuZ2VBY3Rpb25zBQxwcm9sb2dSZXN1bHQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4ApokeOw==", "height": 3405806, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GMDENNUJ4RGF6CpPjrJ5Zr3c85fBWe3acXFGVD6m8PL1 Next: 8gHkNkGLT1BJLFhdMqDk2sNaz4oEQ82wuM8K85ewycDE Diff:
OldNewDifferences
7373 let teamAddrKey = "teamAddr"
7474
7575 func prolog2 () = asInt(reentrantInvoke(acres2Contract, "saveLastTx", nil, nil))
76+
77+
78+@Callable(i)
79+func constructorV1 (rest2Addr) = if ((i.caller != this))
80+ then throw("Permission denied")
81+ else [StringEntry(keyRest2Address(), rest2Addr)]
82+
7683
7784
7885 @Callable(i)
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 6 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let SEP = "__"
55
66 let chain = take(drop(this.bytes, 1), 1)
77
88 let defaultRest2AddressStr = match chain {
99 case _ =>
1010 if ((base58'2W' == $match0))
1111 then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8"
1212 else if ((base58'2T' == $match0))
1313 then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv"
1414 else throw("Unknown chain")
1515 }
1616
1717 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], ""))
1818
1919
2020 let IdxCfgAcres2Dapp = 1
2121
2222 let IdxCfgWlgDapp = 2
2323
2424 func keyRestCfg () = "%s__restConfig"
2525
2626
2727 func keyRest2Address () = "%s__rest2Addr"
2828
2929
3030 func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP)
3131
3232
3333 func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx)))
3434
3535
3636 let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr))
3737
3838 let rest2Cfg = readRestCfgOrFail(rest2Contract)
3939
4040 let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp)
4141
4242 let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp)
4343
4444 let wlgAssetIdKey = "wlg_assetId"
4545
4646 let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "WLGOLD is not issued yet")
4747
4848 func keySellerByAssetId (assetId) = ("seller_" + assetId)
4949
5050
5151 func keyPriceByAssetId (assetId) = ("price_" + assetId)
5252
5353
5454 func keyAssetIdsBySeller (addr) = ("assetIds_" + addr)
5555
5656
5757 func asInt (v) = match v {
5858 case n: Int =>
5959 n
6060 case _ =>
6161 throw("fail to cast into Int")
6262 }
6363
6464
6565 func fixedPoint (val,decimals) = {
6666 let tenPow = pow(10, 0, decimals, 0, 0, DOWN)
6767 let lowPart = toString((val % tenPow))
6868 let zeroes = drop(toString(tenPow), (1 + size(lowPart)))
6969 (((toString((val / tenPow)) + ".") + zeroes) + lowPart)
7070 }
7171
7272
7373 let teamAddrKey = "teamAddr"
7474
7575 func prolog2 () = asInt(reentrantInvoke(acres2Contract, "saveLastTx", nil, nil))
76+
77+
78+@Callable(i)
79+func constructorV1 (rest2Addr) = if ((i.caller != this))
80+ then throw("Permission denied")
81+ else [StringEntry(keyRest2Address(), rest2Addr)]
82+
7683
7784
7885 @Callable(i)
7986 func placeSellOrder (price) = {
8087 let prologResult = prolog2()
8188 if ((prologResult == prologResult))
8289 then if ((0 >= price))
8390 then throw("Price should be positive")
8491 else if ((size(i.payments) != 2))
8592 then throw("Exactly 2 payments required: NFT and 5% fee in WLGOLD")
8693 else {
8794 let pmt = value(i.payments[0])
8895 if ((pmt.amount != 1))
8996 then throw("NFT token should be attached as 1st payment")
9097 else {
9198 let pmt1 = value(i.payments[1])
9299 let wAssetId = valueOrErrorMessage(pmt1.assetId, "No WAVES payments allowed")
93100 if ((wAssetId != wlgAssetId))
94101 then throw("Only WLGOLD payments are accepted as 2nd payment")
95102 else {
96103 let change = (pmt1.amount - (price / 20))
97104 if ((0 > change))
98105 then throw("5% fee should be attached as 2nd payment")
99106 else {
100107 let changeActions = if ((change > 0))
101108 then [ScriptTransfer(i.caller, change, wlgAssetId)]
102109 else nil
103110 let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
104111 let asset = value(assetInfo(assetId))
105112 let assetIdStr = toBase58String(assetId)
106113 let addr = toString(i.caller)
107114 if ((asset.issuer != acres2Contract))
108115 then throw("Only WavesLands NFT tokens are accepted")
109116 else {
110117 let nftsKey = keyAssetIdsBySeller(addr)
111118 let nftsStr = valueOrElse(getString(nftsKey), "")
112119 let nfts = if ((nftsStr != ""))
113120 then split_51C(value(nftsStr), "_")
114121 else nil
115122 $Tuple2(([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))] ++ changeActions), prologResult)
116123 }
117124 }
118125 }
119126 }
120127 }
121128 else throw("Strict value is not equal to itself.")
122129 }
123130
124131
125132
126133 @Callable(i)
127134 func cancelSellOrder (assetIdStr) = {
128135 let prologResult = prolog2()
129136 if ((prologResult == prologResult))
130137 then {
131138 let addr = toString(i.caller)
132139 let nftsKey = keyAssetIdsBySeller(addr)
133140 let nftsStr = valueOrElse(getString(nftsKey), "")
134141 let nfts = if ((nftsStr != ""))
135142 then split_51C(value(nftsStr), "_")
136143 else nil
137144 let idx = indexOf(nfts, assetIdStr)
138145 if (!(isDefined(idx)))
139146 then throw(("Your don't have sell order for " + assetIdStr))
140147 else {
141148 let listAction = if ((size(nfts) > 1))
142149 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
143150 else DeleteEntry(nftsKey)
144151 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), ("You don't have sell order for " + assetIdStr))
145152 $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, (price / 20), wlgAssetId)], prologResult)
146153 }
147154 }
148155 else throw("Strict value is not equal to itself.")
149156 }
150157
151158
152159
153160 @Callable(i)
154161 func acceptSellOrder (assetIdStr) = {
155162 let prologResult = prolog2()
156163 if ((prologResult == prologResult))
157164 then if ((size(i.payments) != 1))
158165 then throw("exactly 1 payment must be attached")
159166 else {
160167 let pmt = i.payments[0]
161168 if (if (!(isDefined(pmt.assetId)))
162169 then true
163170 else (value(pmt.assetId) != wlgAssetId))
164171 then throw("WLGOLD payments only!")
165172 else {
166173 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
167174 let change = (pmt.amount - price)
168175 if ((0 > change))
169176 then throw((("Payment attached doesn't cover sell price of " + fixedPoint(price, 8)) + " WLGOLD"))
170177 else {
171178 let changeActions = if ((change > 0))
172179 then [ScriptTransfer(i.caller, change, wlgAssetId)]
173180 else nil
174181 let seller = valueOrErrorMessage(getString(keySellerByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
175182 let nftsKey = keyAssetIdsBySeller(seller)
176183 let nftsStr = valueOrElse(getString(nftsKey), "")
177184 let nfts = if ((nftsStr != ""))
178185 then split_51C(value(nftsStr), "_")
179186 else nil
180187 let idx = indexOf(nfts, assetIdStr)
181188 if (!(isDefined(idx)))
182189 then throw(("Seller don't have sell order for " + assetIdStr))
183190 else {
184191 let listAction = if ((size(nfts) > 1))
185192 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
186193 else DeleteEntry(nftsKey)
187194 let fee = (price / 20)
188195 let forTeam = (fee / 2)
189196 let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil))
190197 $Tuple2(([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(addressFromStringValue(seller), price, wlgAssetId), ScriptTransfer(addressFromStringValue(getStringValue(wlgContract, teamAddrKey)), forTeam, wlgAssetId), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))] ++ changeActions), prologResult)
191198 }
192199 }
193200 }
194201 }
195202 else throw("Strict value is not equal to itself.")
196203 }
197204
198205

github/deemru/w8io/169f3d6 
35.57 ms