tx · C3sLkjhp4nMZh5gCsKeL1pVwqYh25fQmjPwYx8CnUqKM

3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx:  -0.00600000 Waves

2024.12.15 00:41 [3414813] smart account 3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx > SELF 0.00000000 Waves

{ "type": 13, "id": "C3sLkjhp4nMZh5gCsKeL1pVwqYh25fQmjPwYx8CnUqKM", "fee": 600000, "feeAssetId": null, "timestamp": 1734212518635, "version": 2, "chainId": 84, "sender": "3N3nfqFcxXfd3T18V9icDdh58MJ9wQ2k2xx", "senderPublicKey": "UGqkWsCpv7xRVXkQRXyLd6pWPDtYGXmPip7FxSd1pAu", "proofs": [ "3k9X6zoG7NTeAQ6v47g31neLQC8PKhnVjiLJUiTwbz6ddhzPaWpubyYPMTCf7yYibSLMD7FNCi7f2Ez18W56XVpn" ], "script": "base64:BgIWCAISAwoBCBIDCgEBEgMKAQgSAwoBCBcAA1NFUAICX18ABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABZkZWZhdWx0UmVzdDJBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUEZ3WXRhOGJpRXozMXpwZUZlNURKSzh3RTV0clNwUVZGOAMJAAACAQFUBQckbWF0Y2gwAiMzTjdVdVlhcjYyNjRQNThGQmhWV0tQUUFoNFl1YTJoZ25ndgkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAABBJZHhDZmdBY3JlczJEYXBwAAEADUlkeENmZ1dsZ0RhcHAAAgEKa2V5UmVzdENm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atus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: G7pT9pBJ4LG7FMkT6rUYr3ou9jvsUetXM27REm4w9iXW Next: none Diff:
OldNewDifferences
180180 let fee = (price / 20)
181181 let forTeam = (fee / 2)
182182 let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil))
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)
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), $Tuple2(prologResult, wlgRemain))
184184 }
185185 }
186186 }
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")
9191 else if ((size(i.payments) != 1))
9292 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 {
9898 let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed")
9999 let asset = value(assetInfo(assetId))
100100 let assetIdStr = toBase58String(assetId)
101101 let addr = toString(i.caller)
102102 if ((asset.issuer != acres2Contract))
103103 then throw("Only WavesLands NFT tokens are accepted")
104104 else {
105105 let nftsKey = keyAssetIdsBySeller(addr)
106106 let nftsStr = valueOrElse(getString(nftsKey), "")
107107 let nfts = if ((nftsStr != ""))
108108 then split_51C(value(nftsStr), "_")
109109 else nil
110110 $Tuple2([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))], prologResult)
111111 }
112112 }
113113 }
114114 else throw("Strict value is not equal to itself.")
115115 }
116116
117117
118118
119119 @Callable(i)
120120 func cancelSellOrder (assetIdStr) = {
121121 let prologResult = prolog2()
122122 if ((prologResult == prologResult))
123123 then {
124124 let addr = toString(i.caller)
125125 let nftsKey = keyAssetIdsBySeller(addr)
126126 let nftsStr = valueOrElse(getString(nftsKey), "")
127127 let nfts = if ((nftsStr != ""))
128128 then split_51C(value(nftsStr), "_")
129129 else nil
130130 let idx = indexOf(nfts, assetIdStr)
131131 if (!(isDefined(idx)))
132132 then throw(("Your don't have sell order for " + assetIdStr))
133133 else {
134134 let listAction = if ((size(nfts) > 1))
135135 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
136136 else DeleteEntry(nftsKey)
137137 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), ("You don't have sell order for " + assetIdStr))
138138 $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, 1, fromBase58String(assetIdStr))], prologResult)
139139 }
140140 }
141141 else throw("Strict value is not equal to itself.")
142142 }
143143
144144
145145
146146 @Callable(i)
147147 func acceptSellOrder (assetIdStr) = {
148148 let prologResult = prolog2()
149149 if ((prologResult == prologResult))
150150 then if ((size(i.payments) != 1))
151151 then throw("exactly 1 payment must be attached")
152152 else {
153153 let pmt = i.payments[0]
154154 if (if (!(isDefined(pmt.assetId)))
155155 then true
156156 else (value(pmt.assetId) != wlgAssetId))
157157 then throw("WLGOLD payments only!")
158158 else {
159159 let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
160160 let change = (pmt.amount - price)
161161 if ((0 > change))
162162 then throw((("Payment attached doesn't cover sell price of " + fixedPoint(price, 8)) + " WLGOLD"))
163163 else {
164164 let changeActions = if ((change > 0))
165165 then [ScriptTransfer(i.caller, change, wlgAssetId)]
166166 else nil
167167 let seller = valueOrErrorMessage(getString(keySellerByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling"))
168168 let nftsKey = keyAssetIdsBySeller(seller)
169169 let nftsStr = valueOrElse(getString(nftsKey), "")
170170 let nfts = if ((nftsStr != ""))
171171 then split_51C(value(nftsStr), "_")
172172 else nil
173173 let idx = indexOf(nfts, assetIdStr)
174174 if (!(isDefined(idx)))
175175 then throw(("Seller don't have sell order for " + assetIdStr))
176176 else {
177177 let listAction = if ((size(nfts) > 1))
178178 then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_"))
179179 else DeleteEntry(nftsKey)
180180 let fee = (price / 20)
181181 let forTeam = (fee / 2)
182182 let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil))
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)
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), $Tuple2(prologResult, wlgRemain))
184184 }
185185 }
186186 }
187187 }
188188 else throw("Strict value is not equal to itself.")
189189 }
190190
191191

github/deemru/w8io/169f3d6 
34.15 ms