tx · G7pT9pBJ4LG7FMkT6rUYr3ou9jvsUetXM27REm4w9iXW

3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx:  -0.00600000 Waves

2024.12.14 22:40 [3414697] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves

{ "type": 13, "id": "G7pT9pBJ4LG7FMkT6rUYr3ou9jvsUetXM27REm4w9iXW", "fee": 600000, "feeAssetId": null, "timestamp": 1734205235950, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "4kS2ZpNCcK9U6phkwEFbPijhRm6PexhN1KTMU65HqVL6TAfemoGsjoW6HFzLPxgvb7HzdLvCRztYnJxWocZGUzKF" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgMKAQgSAwoBCBcAA1NFUAICX18ABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABZkZWZhdWx0UmVzdDJBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUEZ3WXRhOGJpRXozMXpwZUZlNURKSzh3RTV0clNwUVZGOAMJAAACAQFUBQckbWF0Y2gwAiMzTjdVdVlhcjYyNjRQNThGQmhWV0tQUUFoNFl1YTJoZ25ndgkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAABBJZHhDZmdBY3JlczJEYXBwAAEADUlkeENmZ1dsZ0RhcHAAAgEKa2V5UmVzdENmZwAC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| compacted Prev: 8gHkNkGLT1BJLFhdMqDk2sNaz4oEQ82wuM8K85ewycDE Next: C3sLkjhp4nMZh5gCsKeL1pVwqYh25fQmjPwYx8CnUqKM Diff:
OldNewDifferences
8888 if ((prologResult == prologResult))
8989 then if ((0 >= price))
9090 then throw("Price should be positive")
91- else if ((size(i.payments) != 2))
92- then throw("Exactly 2 payments required: NFT and 5% fee in WLGOLD")
91+ else if ((size(i.payments) != 1))
92+ then throw("Exactly 1 payment required")
9393 else {
9494 let pmt = value(i.payments[0])
9595 if ((pmt.amount != 1))
9696 then throw("NFT token should be attached as 1st payment")
9797 else {
98- let pmt1 = value(i.payments[1])
99- let wAssetId = valueOrErrorMessage(pmt1.assetId, "No WAVES payments allowed")
100- if ((wAssetId != wlgAssetId))
101- then throw("Only WLGOLD payments are accepted as 2nd payment")
98+ let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
99+ let asset = value(assetInfo(assetId))
100+ let assetIdStr = toBase58String(assetId)
101+ let addr = toString(i.caller)
102+ if ((asset.issuer != acres2Contract))
103+ then throw("Only WavesLands NFT tokens are accepted")
102104 else {
103- let change = (pmt1.amount - (price / 20))
104- if ((0 > change))
105- then throw("5% fee should be attached as 2nd payment")
106- else {
107- let changeActions = if ((change > 0))
108- then [ScriptTransfer(i.caller, change, wlgAssetId)]
109- else nil
110- let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
111- let asset = value(assetInfo(assetId))
112- let assetIdStr = toBase58String(assetId)
113- let addr = toString(i.caller)
114- if ((asset.issuer != acres2Contract))
115- then throw("Only WavesLands NFT tokens are accepted")
116- else {
117- let nftsKey = keyAssetIdsBySeller(addr)
118- let nftsStr = valueOrElse(getString(nftsKey), "")
119- let nfts = if ((nftsStr != ""))
120- then split_51C(value(nftsStr), "_")
121- else nil
122- $Tuple2(([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))] ++ changeActions), prologResult)
123- }
124- }
105+ let nftsKey = keyAssetIdsBySeller(addr)
106+ let nftsStr = valueOrElse(getString(nftsKey), "")
107+ let nfts = if ((nftsStr != ""))
108+ then split_51C(value(nftsStr), "_")
109+ else nil
110+ $Tuple2([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))], prologResult)
125111 }
126112 }
127113 }
149135 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
150136 else DeleteEntry(nftsKey)
151137 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), ("You don't have sell order for " + assetIdStr))
152- $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr)), ScriptTransfer(i.caller, (price / 20), wlgAssetId)], prologResult)
138+ $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))], prologResult)
153139 }
154140 }
155141 else throw("Strict value is not equal to itself.")
194180 let fee = (price / 20)
195181 let forTeam = (fee / 2)
196182 let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil))
197- $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)
183+ $Tuple2(([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(addressFromStringValue(seller), (price - fee), wlgAssetId), ScriptTransfer(addressFromStringValue(getStringValue(wlgContract, teamAddrKey)), forTeam, wlgAssetId), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))] ++ changeActions), prologResult)
198184 }
199185 }
200186 }
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))
7676
7777
7878 @Callable(i)
7979 func constructorV1 (rest2Addr) = if ((i.caller != this))
8080 then throw("Permission denied")
8181 else [StringEntry(keyRest2Address(), rest2Addr)]
8282
8383
8484
8585 @Callable(i)
8686 func placeSellOrder (price) = {
8787 let prologResult = prolog2()
8888 if ((prologResult == prologResult))
8989 then if ((0 >= price))
9090 then throw("Price should be positive")
91- else if ((size(i.payments) != 2))
92- then throw("Exactly 2 payments required: NFT and 5% fee in WLGOLD")
91+ else if ((size(i.payments) != 1))
92+ then throw("Exactly 1 payment required")
9393 else {
9494 let pmt = value(i.payments[0])
9595 if ((pmt.amount != 1))
9696 then throw("NFT token should be attached as 1st payment")
9797 else {
98- let pmt1 = value(i.payments[1])
99- let wAssetId = valueOrErrorMessage(pmt1.assetId, "No WAVES payments allowed")
100- if ((wAssetId != wlgAssetId))
101- then throw("Only WLGOLD payments are accepted as 2nd payment")
98+ let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
99+ let asset = value(assetInfo(assetId))
100+ let assetIdStr = toBase58String(assetId)
101+ let addr = toString(i.caller)
102+ if ((asset.issuer != acres2Contract))
103+ then throw("Only WavesLands NFT tokens are accepted")
102104 else {
103- let change = (pmt1.amount - (price / 20))
104- if ((0 > change))
105- then throw("5% fee should be attached as 2nd payment")
106- else {
107- let changeActions = if ((change > 0))
108- then [ScriptTransfer(i.caller, change, wlgAssetId)]
109- else nil
110- let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
111- let asset = value(assetInfo(assetId))
112- let assetIdStr = toBase58String(assetId)
113- let addr = toString(i.caller)
114- if ((asset.issuer != acres2Contract))
115- then throw("Only WavesLands NFT tokens are accepted")
116- else {
117- let nftsKey = keyAssetIdsBySeller(addr)
118- let nftsStr = valueOrElse(getString(nftsKey), "")
119- let nfts = if ((nftsStr != ""))
120- then split_51C(value(nftsStr), "_")
121- else nil
122- $Tuple2(([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))] ++ changeActions), prologResult)
123- }
124- }
105+ let nftsKey = keyAssetIdsBySeller(addr)
106+ let nftsStr = valueOrElse(getString(nftsKey), "")
107+ let nfts = if ((nftsStr != ""))
108+ then split_51C(value(nftsStr), "_")
109+ else nil
110+ $Tuple2([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))], prologResult)
125111 }
126112 }
127113 }
128114 else throw("Strict value is not equal to itself.")
129115 }
130116
131117
132118
133119 @Callable(i)
134120 func cancelSellOrder (assetIdStr) = {
135121 let prologResult = prolog2()
136122 if ((prologResult == prologResult))
137123 then {
138124 let addr = toString(i.caller)
139125 let nftsKey = keyAssetIdsBySeller(addr)
140126 let nftsStr = valueOrElse(getString(nftsKey), "")
141127 let nfts = if ((nftsStr != ""))
142128 then split_51C(value(nftsStr), "_")
143129 else nil
144130 let idx = indexOf(nfts, assetIdStr)
145131 if (!(isDefined(idx)))
146132 then throw(("Your don't have sell order for " + assetIdStr))
147133 else {
148134 let listAction = if ((size(nfts) > 1))
149135 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
150136 else DeleteEntry(nftsKey)
151137 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), ("You don't have sell order for " + assetIdStr))
152- $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr)), ScriptTransfer(i.caller, (price / 20), wlgAssetId)], prologResult)
138+ $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))], prologResult)
153139 }
154140 }
155141 else throw("Strict value is not equal to itself.")
156142 }
157143
158144
159145
160146 @Callable(i)
161147 func acceptSellOrder (assetIdStr) = {
162148 let prologResult = prolog2()
163149 if ((prologResult == prologResult))
164150 then if ((size(i.payments) != 1))
165151 then throw("exactly 1 payment must be attached")
166152 else {
167153 let pmt = i.payments[0]
168154 if (if (!(isDefined(pmt.assetId)))
169155 then true
170156 else (value(pmt.assetId) != wlgAssetId))
171157 then throw("WLGOLD payments only!")
172158 else {
173159 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
174160 let change = (pmt.amount - price)
175161 if ((0 > change))
176162 then throw((("Payment attached doesn't cover sell price of " + fixedPoint(price, 8)) + " WLGOLD"))
177163 else {
178164 let changeActions = if ((change > 0))
179165 then [ScriptTransfer(i.caller, change, wlgAssetId)]
180166 else nil
181167 let seller = valueOrErrorMessage(getString(keySellerByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
182168 let nftsKey = keyAssetIdsBySeller(seller)
183169 let nftsStr = valueOrElse(getString(nftsKey), "")
184170 let nfts = if ((nftsStr != ""))
185171 then split_51C(value(nftsStr), "_")
186172 else nil
187173 let idx = indexOf(nfts, assetIdStr)
188174 if (!(isDefined(idx)))
189175 then throw(("Seller don't have sell order for " + assetIdStr))
190176 else {
191177 let listAction = if ((size(nfts) > 1))
192178 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
193179 else DeleteEntry(nftsKey)
194180 let fee = (price / 20)
195181 let forTeam = (fee / 2)
196182 let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil))
197- $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)
183+ $Tuple2(([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(addressFromStringValue(seller), (price - fee), wlgAssetId), ScriptTransfer(addressFromStringValue(getStringValue(wlgContract, teamAddrKey)), forTeam, wlgAssetId), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))] ++ changeActions), prologResult)
198184 }
199185 }
200186 }
201187 }
202188 else throw("Strict value is not equal to itself.")
203189 }
204190
205191

github/deemru/w8io/169f3d6 
61.25 ms