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:BgIWCAISAwoBCBIDCgEBEgMKAQgSAwoBCBcAA1NFUAICX18ABWNoYWluCQDJAQIJAMoBAggFBHRoaXMFYnl0ZXMAAQABABZkZWZhdWx0UmVzdDJBZGRyZXNzU3RyBAckbWF0Y2gwBQVjaGFpbgMJAAACAQFXBQckbWF0Y2gwAiMzUEZ3WXRhOGJpRXozMXpwZUZlNURKSzh3RTV0clNwUVZGOAMJAAACAQFUBQckbWF0Y2gwAiMzTjdVdVlhcjYyNjRQNThGQmhWV0tQUUFoNFl1YTJoZ25ndgkAAgECDVVua25vd24gY2hhaW4BD2dldFN0cmluZ09yRmFpbAIHYWRkcmVzcwNrZXkJARN2YWx1ZU9yRXJyb3JNZXNzYWdlAgkAnQgCBQdhZGRyZXNzBQNrZXkJALkJAgkAzAgCAgptYW5kYXRvcnkgCQDMCAIJAKUIAQUHYWRkcmVzcwkAzAgCAgEuCQDMCAIFA2tleQkAzAgCAg8gaXMgbm90IGRlZmluZWQFA25pbAIAABBJZHhDZmdBY3JlczJEYXBwAAEADUlkeENmZ1dsZ0RhcHAAAgEKa2V5UmVzdENmZwACD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QDMCAIJAQtEZWxldGVFbnRyeQEJARFrZXlQcmljZUJ5QXNzZXRJZAEFCmFzc2V0SWRTdHIJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwkBEUBleHRyTmF0aXZlKDEwNjIpAQUGc2VsbGVyBQVwcmljZQUKd2xnQXNzZXRJZAkAzAgCCQEOU2NyaXB0VHJhbnNmZXIDCQERQGV4dHJOYXRpdmUoMTA2MikBCQERQGV4dHJOYXRpdmUoMTA1MykCBQt3bGdDb250cmFjdAULdGVhbUFkZHJLZXkFB2ZvclRlYW0FCndsZ0Fzc2V0SWQJAMwIAgkBDlNjcmlwdFRyYW5zZmVyAwgFAWkGY2FsbGVyAAEJANkEAQUKYXNzZXRJZFN0cgUDbmlsBQ1jaGFuZ2VBY3Rpb25zBQxwcm9sb2dSZXN1bHQJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4ApokeOw==", "height": 3405806, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: GMDENNUJ4RGF6CpPjrJ5Zr3c85fBWe3acXFGVD6m8PL1 Next: 8gHkNkGLT1BJLFhdMqDk2sNaz4oEQ82wuM8K85ewycDE Diff:
Old | New | Differences | |
---|---|---|---|
73 | 73 | let teamAddrKey = "teamAddr" | |
74 | 74 | ||
75 | 75 | 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 | + | ||
76 | 83 | ||
77 | 84 | ||
78 | 85 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let chain = take(drop(this.bytes, 1), 1) | |
7 | 7 | ||
8 | 8 | let defaultRest2AddressStr = match chain { | |
9 | 9 | case _ => | |
10 | 10 | if ((base58'2W' == $match0)) | |
11 | 11 | then "3PFwYta8biEz31zpeFe5DJK8wE5trSpQVF8" | |
12 | 12 | else if ((base58'2T' == $match0)) | |
13 | 13 | then "3N7UuYar6264P58FBhVWKPQAh4Yua2hgngv" | |
14 | 14 | else throw("Unknown chain") | |
15 | 15 | } | |
16 | 16 | ||
17 | 17 | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), makeString(["mandatory ", toString(address), ".", key, " is not defined"], "")) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | let IdxCfgAcres2Dapp = 1 | |
21 | 21 | ||
22 | 22 | let IdxCfgWlgDapp = 2 | |
23 | 23 | ||
24 | 24 | func keyRestCfg () = "%s__restConfig" | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func keyRest2Address () = "%s__rest2Addr" | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func readRestCfgOrFail (rest) = split_4C(getStringOrFail(rest, keyRestCfg()), SEP) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getContractAddressOrFail (rest2Cfg,idx) = valueOrErrorMessage(addressFromString(rest2Cfg[idx]), ("Rest cfg doesn't contain address at index " + toString(idx))) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | let rest2Contract = addressFromStringValue(valueOrElse(getString(this, keyRest2Address()), defaultRest2AddressStr)) | |
37 | 37 | ||
38 | 38 | let rest2Cfg = readRestCfgOrFail(rest2Contract) | |
39 | 39 | ||
40 | 40 | let acres2Contract = getContractAddressOrFail(rest2Cfg, IdxCfgAcres2Dapp) | |
41 | 41 | ||
42 | 42 | let wlgContract = getContractAddressOrFail(rest2Cfg, IdxCfgWlgDapp) | |
43 | 43 | ||
44 | 44 | let wlgAssetIdKey = "wlg_assetId" | |
45 | 45 | ||
46 | 46 | let wlgAssetId = valueOrErrorMessage(getBinary(wlgContract, wlgAssetIdKey), "WLGOLD is not issued yet") | |
47 | 47 | ||
48 | 48 | func keySellerByAssetId (assetId) = ("seller_" + assetId) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func keyPriceByAssetId (assetId) = ("price_" + assetId) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func keyAssetIdsBySeller (addr) = ("assetIds_" + addr) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func asInt (v) = match v { | |
58 | 58 | case n: Int => | |
59 | 59 | n | |
60 | 60 | case _ => | |
61 | 61 | throw("fail to cast into Int") | |
62 | 62 | } | |
63 | 63 | ||
64 | 64 | ||
65 | 65 | func fixedPoint (val,decimals) = { | |
66 | 66 | let tenPow = pow(10, 0, decimals, 0, 0, DOWN) | |
67 | 67 | let lowPart = toString((val % tenPow)) | |
68 | 68 | let zeroes = drop(toString(tenPow), (1 + size(lowPart))) | |
69 | 69 | (((toString((val / tenPow)) + ".") + zeroes) + lowPart) | |
70 | 70 | } | |
71 | 71 | ||
72 | 72 | ||
73 | 73 | let teamAddrKey = "teamAddr" | |
74 | 74 | ||
75 | 75 | 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 | + | ||
76 | 83 | ||
77 | 84 | ||
78 | 85 | @Callable(i) | |
79 | 86 | func placeSellOrder (price) = { | |
80 | 87 | let prologResult = prolog2() | |
81 | 88 | if ((prologResult == prologResult)) | |
82 | 89 | then if ((0 >= price)) | |
83 | 90 | then throw("Price should be positive") | |
84 | 91 | else if ((size(i.payments) != 2)) | |
85 | 92 | then throw("Exactly 2 payments required: NFT and 5% fee in WLGOLD") | |
86 | 93 | else { | |
87 | 94 | let pmt = value(i.payments[0]) | |
88 | 95 | if ((pmt.amount != 1)) | |
89 | 96 | then throw("NFT token should be attached as 1st payment") | |
90 | 97 | else { | |
91 | 98 | let pmt1 = value(i.payments[1]) | |
92 | 99 | let wAssetId = valueOrErrorMessage(pmt1.assetId, "No WAVES payments allowed") | |
93 | 100 | if ((wAssetId != wlgAssetId)) | |
94 | 101 | then throw("Only WLGOLD payments are accepted as 2nd payment") | |
95 | 102 | else { | |
96 | 103 | let change = (pmt1.amount - (price / 20)) | |
97 | 104 | if ((0 > change)) | |
98 | 105 | then throw("5% fee should be attached as 2nd payment") | |
99 | 106 | else { | |
100 | 107 | let changeActions = if ((change > 0)) | |
101 | 108 | then [ScriptTransfer(i.caller, change, wlgAssetId)] | |
102 | 109 | else nil | |
103 | 110 | let assetId = valueOrErrorMessage(pmt.assetId, "No WAVES payments allowed") | |
104 | 111 | let asset = value(assetInfo(assetId)) | |
105 | 112 | let assetIdStr = toBase58String(assetId) | |
106 | 113 | let addr = toString(i.caller) | |
107 | 114 | if ((asset.issuer != acres2Contract)) | |
108 | 115 | then throw("Only WavesLands NFT tokens are accepted") | |
109 | 116 | else { | |
110 | 117 | let nftsKey = keyAssetIdsBySeller(addr) | |
111 | 118 | let nftsStr = valueOrElse(getString(nftsKey), "") | |
112 | 119 | let nfts = if ((nftsStr != "")) | |
113 | 120 | then split_51C(value(nftsStr), "_") | |
114 | 121 | else nil | |
115 | 122 | $Tuple2(([IntegerEntry(keyPriceByAssetId(assetIdStr), price), StringEntry(keySellerByAssetId(assetIdStr), addr), StringEntry(nftsKey, makeString_11C((nfts :+ assetIdStr), "_"))] ++ changeActions), prologResult) | |
116 | 123 | } | |
117 | 124 | } | |
118 | 125 | } | |
119 | 126 | } | |
120 | 127 | } | |
121 | 128 | else throw("Strict value is not equal to itself.") | |
122 | 129 | } | |
123 | 130 | ||
124 | 131 | ||
125 | 132 | ||
126 | 133 | @Callable(i) | |
127 | 134 | func cancelSellOrder (assetIdStr) = { | |
128 | 135 | let prologResult = prolog2() | |
129 | 136 | if ((prologResult == prologResult)) | |
130 | 137 | then { | |
131 | 138 | let addr = toString(i.caller) | |
132 | 139 | let nftsKey = keyAssetIdsBySeller(addr) | |
133 | 140 | let nftsStr = valueOrElse(getString(nftsKey), "") | |
134 | 141 | let nfts = if ((nftsStr != "")) | |
135 | 142 | then split_51C(value(nftsStr), "_") | |
136 | 143 | else nil | |
137 | 144 | let idx = indexOf(nfts, assetIdStr) | |
138 | 145 | if (!(isDefined(idx))) | |
139 | 146 | then throw(("Your don't have sell order for " + assetIdStr)) | |
140 | 147 | else { | |
141 | 148 | let listAction = if ((size(nfts) > 1)) | |
142 | 149 | then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_")) | |
143 | 150 | else DeleteEntry(nftsKey) | |
144 | 151 | let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), ("You don't have sell order for " + assetIdStr)) | |
145 | 152 | $Tuple2([listAction, DeleteEntry(keySellerByAssetId(assetIdStr)), DeleteEntry(keyPriceByAssetId(assetIdStr)), ScriptTransfer(i.caller, (price / 20), wlgAssetId)], prologResult) | |
146 | 153 | } | |
147 | 154 | } | |
148 | 155 | else throw("Strict value is not equal to itself.") | |
149 | 156 | } | |
150 | 157 | ||
151 | 158 | ||
152 | 159 | ||
153 | 160 | @Callable(i) | |
154 | 161 | func acceptSellOrder (assetIdStr) = { | |
155 | 162 | let prologResult = prolog2() | |
156 | 163 | if ((prologResult == prologResult)) | |
157 | 164 | then if ((size(i.payments) != 1)) | |
158 | 165 | then throw("exactly 1 payment must be attached") | |
159 | 166 | else { | |
160 | 167 | let pmt = i.payments[0] | |
161 | 168 | if (if (!(isDefined(pmt.assetId))) | |
162 | 169 | then true | |
163 | 170 | else (value(pmt.assetId) != wlgAssetId)) | |
164 | 171 | then throw("WLGOLD payments only!") | |
165 | 172 | else { | |
166 | 173 | let price = valueOrErrorMessage(getInteger(keyPriceByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling")) | |
167 | 174 | let change = (pmt.amount - price) | |
168 | 175 | if ((0 > change)) | |
169 | 176 | then throw((("Payment attached doesn't cover sell price of " + fixedPoint(price, 8)) + " WLGOLD")) | |
170 | 177 | else { | |
171 | 178 | let changeActions = if ((change > 0)) | |
172 | 179 | then [ScriptTransfer(i.caller, change, wlgAssetId)] | |
173 | 180 | else nil | |
174 | 181 | let seller = valueOrErrorMessage(getString(keySellerByAssetId(assetIdStr)), (("NFT " + assetIdStr) + " is not selling")) | |
175 | 182 | let nftsKey = keyAssetIdsBySeller(seller) | |
176 | 183 | let nftsStr = valueOrElse(getString(nftsKey), "") | |
177 | 184 | let nfts = if ((nftsStr != "")) | |
178 | 185 | then split_51C(value(nftsStr), "_") | |
179 | 186 | else nil | |
180 | 187 | let idx = indexOf(nfts, assetIdStr) | |
181 | 188 | if (!(isDefined(idx))) | |
182 | 189 | then throw(("Seller don't have sell order for " + assetIdStr)) | |
183 | 190 | else { | |
184 | 191 | let listAction = if ((size(nfts) > 1)) | |
185 | 192 | then StringEntry(nftsKey, makeString_11C(removeByIndex(nfts, value(idx)), "_")) | |
186 | 193 | else DeleteEntry(nftsKey) | |
187 | 194 | let fee = (price / 20) | |
188 | 195 | let forTeam = (fee / 2) | |
189 | 196 | let wlgRemain = asInt(invoke(wlgContract, "burnWlgold", [(fee - forTeam)], nil)) | |
190 | 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) | |
191 | 198 | } | |
192 | 199 | } | |
193 | 200 | } | |
194 | 201 | } | |
195 | 202 | else throw("Strict value is not equal to itself.") | |
196 | 203 | } | |
197 | 204 | ||
198 | 205 |
github/deemru/w8io/169f3d6 35.57 ms ◑