tx · HFz1cVTuPoARbUvRmhmZuSxWvz5e6xCWwY6GSwUC4qkz 3N7NSGttZdtSoZanmmvFbtbKy81aH3qmCr1: -0.01000000 Waves 2022.10.27 08:33 [2290419] smart account 3N7NSGttZdtSoZanmmvFbtbKy81aH3qmCr1 > SELF 0.00000000 Waves
{ "type": 13, "id": "HFz1cVTuPoARbUvRmhmZuSxWvz5e6xCWwY6GSwUC4qkz", "fee": 1000000, "feeAssetId": null, "timestamp": 1666848780811, "version": 2, "chainId": 84, "sender": "3N7NSGttZdtSoZanmmvFbtbKy81aH3qmCr1", "senderPublicKey": "DnHWpL2JmrKWWVJgbwq4czBSA7NpfK3MyfsKzKLJbcro", "proofs": [ "2K9XuSf6eCN2NEJGMroNad2YshJdGdq3uNpH7n6ZvEX6iL5z8ieXMStfdS9f4dH7EFawmdUkNNqUjrbmUqknyQ6y" ], "script": "base64:AAIFAAAAAAAAABYIAhIFCgMICAESBAoCCAISAwoBCBIAAAAADQEAAAAQZ2V0U3RyaW5nT3JUaHJvdwAAAAIAAAAHYWRkcmVzcwAAAANrZXkJAQAAABN2YWx1ZU9yRXJyb3JNZXNzYWdlAAAAAgkABB0AAAACBQAAAAdhZGRyZXNzBQAAAANrZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAICAAAADENhbid0IHJlYWQgJwUAAAADa2V5AgAAAA0nIGF0IGFkZHJlc3MgCQAEJQAAAAEFAAAAB2FkZHJlc3MBAAAAEWdldEludGVnZXJPclRocm93AAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEGgAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgIAAAAMQ2FuJ3QgcmVhZCAnBQAAAANrZXkCAAAADScgYXQgYWRkcmVzcyAJAAQlAAAAAQUAAAAHYWRkcmVzcwEAAAATcGFyc2VBZGRyZXNzT3JUaHJvdwAAAAEAAAAMbWF5YmV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QQAAAAFdG9rZW4JAAGbAAAAAQUAAAAIdG9rZW5TdHIEAAAACHRyYW5zZmVyCQAD/AAAAAQFAAAABHRoaXMCAAAACHRyYW5zZmVyCQAETAAAAAIFAAAACWNhbGxlclN0cgkABEwAAAACBQAAAAVhc3NldAUAAAADbmlsBQAAAANuaWwDCQAAAAAAAAIFAAAACHRyYW5zZmVyBQAAAAh0cmFuc2ZlcgQAAAAMcmVnaXN0cmF0aW9uCQAD/AAAAAQFAAAACXJlZ2lzdHJhcgIAAAAHcmVjbGFpbQkABEwAAAACCAUAAAAFYXNzZXQAAAAEbmFtZQUAAAADbmlsBQAAAANuaWwDCQAAAAAAAAIFAAAADHJlZ2lzdHJhdGlvbgUAAAAMcmVnaXN0cmF0aW9uBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAADmEoHI", "height": 2290419, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 7GGXH3syx5ANdEU857ZrWNcyTJzF3Viqdk7vEPpxNnk9 Next: HLZ34NGRBEP2Wt9KR1fyCNrhBHU7V3NoZ6PcQdNYPDuf Diff:
Old | New | Differences | |
---|---|---|---|
32 | 32 | ||
33 | 33 | let meedusInitTimestamp = getIntegerOrThrow(this, key_meedusInitTimestamp) | |
34 | 34 | ||
35 | - | func isNFT (asset) = if (if (if ((asset.quantity != 1)) | |
36 | - | then true | |
37 | - | else (asset.issuer != meedus)) | |
38 | - | then true | |
39 | - | else (asset.decimals != 0)) | |
40 | - | then true | |
41 | - | else (asset.reissuable != false) | |
42 | - | ||
43 | - | ||
44 | - | func makeTransfer (address,asset) = match invoke(this, "transfer", [address, asset], nil) { | |
45 | - | case b: Boolean => | |
46 | - | b | |
47 | - | case _ => | |
48 | - | throw("Invalid result for transfer") | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | 35 | @Callable(inv) | |
53 | 36 | func init (meedusAddress,registrarAddress,meedusInitTimestamp) = [StringEntry(key_meedusAddress, meedusAddress), StringEntry(key_registrarAddress, registrarAddress), IntegerEntry(key_meedusInitTimestamp, meedusInitTimestamp)] | |
54 | 37 | ||
57 | 40 | @Callable(inv) | |
58 | 41 | func transfer (addressStr,asset) = { | |
59 | 42 | let address = parseAddressOrThrow(addressStr) | |
60 | - | ||
43 | + | [ScriptTransfer(address, 1, asset)] | |
61 | 44 | } | |
62 | 45 | ||
63 | 46 | ||
85 | 68 | let pmt = inv.payments[0] | |
86 | 69 | let assetId = valueOrErrorMessage(pmt.assetId, "Asset cannot be WAVES") | |
87 | 70 | let asset = valueOrErrorMessage(assetInfo(assetId), "Invalid asset") | |
88 | - | if ((pmt.amount != 1)) | |
89 | - | then throw("Incorrect amount of asset") | |
90 | - | else if (isNFT(asset)) | |
91 | - | then throw("Asset in payment is not NFT") | |
92 | - | else { | |
93 | - | let tokenStr = getStringOrThrow(registrar, key_Name_token(asset.name)) | |
94 | - | let token = toBytes(tokenStr) | |
95 | - | let transfer = makeTransfer(caller, token) | |
96 | - | if ((transfer == transfer)) | |
97 | - | then { | |
98 | - | let registration = invoke(registrar, "reclaim", [asset.name], nil) | |
99 | - | if ((registration == registration)) | |
100 | - | then nil | |
101 | - | else throw("Strict value is not equal to itself.") | |
102 | - | } | |
103 | - | else throw("Strict value is not equal to itself.") | |
104 | - | } | |
71 | + | let isMeedusNFT = if (if (if ((asset.issuer == meedus)) | |
72 | + | then (asset.quantity == 1) | |
73 | + | else false) | |
74 | + | then (asset.decimals == 0) | |
75 | + | else false) | |
76 | + | then (asset.reissuable == false) | |
77 | + | else false | |
78 | + | if (if ((pmt.amount != 1)) | |
79 | + | then true | |
80 | + | else !(isMeedusNFT)) | |
81 | + | then throw("Payment should contain Meedus NFT") | |
82 | + | else { | |
83 | + | let tokenStr = getStringOrThrow(registrar, key_Name_token(asset.name)) | |
84 | + | let token = toBytes(tokenStr) | |
85 | + | let transfer = invoke(this, "transfer", [callerStr, asset], nil) | |
86 | + | if ((transfer == transfer)) | |
87 | + | then { | |
88 | + | let registration = invoke(registrar, "reclaim", [asset.name], nil) | |
89 | + | if ((registration == registration)) | |
90 | + | then nil | |
91 | + | else throw("Strict value is not equal to itself.") | |
92 | + | } | |
93 | + | else throw("Strict value is not equal to itself.") | |
94 | + | } | |
105 | 95 | } | |
106 | 96 | ||
107 | 97 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | func getStringOrThrow (address,key) = valueOrErrorMessage(getString(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
5 | 5 | ||
6 | 6 | ||
7 | 7 | func getIntegerOrThrow (address,key) = valueOrErrorMessage(getInteger(address, key), ((("Can't read '" + key) + "' at address ") + toString(address))) | |
8 | 8 | ||
9 | 9 | ||
10 | 10 | func parseAddressOrThrow (maybeAddress) = valueOrErrorMessage(addressFromString(maybeAddress), (("Can't parse address from '" + maybeAddress) + "'")) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func key_entity (name,pk,property) = ((((name + "_") + pk) + "_") + property) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func key_Name_token (name) = key_entity("Name", name, "token") | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | let key_meedusAddress = "meedusAddress" | |
20 | 20 | ||
21 | 21 | let key_registrarAddress = "registrarAddress" | |
22 | 22 | ||
23 | 23 | let key_meedusInitTimestamp = "meedusInitTimestamp" | |
24 | 24 | ||
25 | 25 | let meedusAddress = getStringOrThrow(this, key_meedusAddress) | |
26 | 26 | ||
27 | 27 | let meedus = parseAddressOrThrow(meedusAddress) | |
28 | 28 | ||
29 | 29 | let registrarAddress = getStringOrThrow(this, key_registrarAddress) | |
30 | 30 | ||
31 | 31 | let registrar = parseAddressOrThrow(registrarAddress) | |
32 | 32 | ||
33 | 33 | let meedusInitTimestamp = getIntegerOrThrow(this, key_meedusInitTimestamp) | |
34 | 34 | ||
35 | - | func isNFT (asset) = if (if (if ((asset.quantity != 1)) | |
36 | - | then true | |
37 | - | else (asset.issuer != meedus)) | |
38 | - | then true | |
39 | - | else (asset.decimals != 0)) | |
40 | - | then true | |
41 | - | else (asset.reissuable != false) | |
42 | - | ||
43 | - | ||
44 | - | func makeTransfer (address,asset) = match invoke(this, "transfer", [address, asset], nil) { | |
45 | - | case b: Boolean => | |
46 | - | b | |
47 | - | case _ => | |
48 | - | throw("Invalid result for transfer") | |
49 | - | } | |
50 | - | ||
51 | - | ||
52 | 35 | @Callable(inv) | |
53 | 36 | func init (meedusAddress,registrarAddress,meedusInitTimestamp) = [StringEntry(key_meedusAddress, meedusAddress), StringEntry(key_registrarAddress, registrarAddress), IntegerEntry(key_meedusInitTimestamp, meedusInitTimestamp)] | |
54 | 37 | ||
55 | 38 | ||
56 | 39 | ||
57 | 40 | @Callable(inv) | |
58 | 41 | func transfer (addressStr,asset) = { | |
59 | 42 | let address = parseAddressOrThrow(addressStr) | |
60 | - | ||
43 | + | [ScriptTransfer(address, 1, asset)] | |
61 | 44 | } | |
62 | 45 | ||
63 | 46 | ||
64 | 47 | ||
65 | 48 | @Callable(inv) | |
66 | 49 | func reserve (name) = { | |
67 | 50 | let caller = inv.caller | |
68 | 51 | let callerStr = toString(caller) | |
69 | 52 | if ((this != caller)) | |
70 | 53 | then throw("Only self call are allowed") | |
71 | 54 | else { | |
72 | 55 | let reservation = invoke(registrar, "register", [name, callerStr, meedusInitTimestamp], nil) | |
73 | 56 | if ((reservation == reservation)) | |
74 | 57 | then nil | |
75 | 58 | else throw("Strict value is not equal to itself.") | |
76 | 59 | } | |
77 | 60 | } | |
78 | 61 | ||
79 | 62 | ||
80 | 63 | ||
81 | 64 | @Callable(inv) | |
82 | 65 | func exchange () = { | |
83 | 66 | let caller = inv.caller | |
84 | 67 | let callerStr = toString(caller) | |
85 | 68 | let pmt = inv.payments[0] | |
86 | 69 | let assetId = valueOrErrorMessage(pmt.assetId, "Asset cannot be WAVES") | |
87 | 70 | let asset = valueOrErrorMessage(assetInfo(assetId), "Invalid asset") | |
88 | - | if ((pmt.amount != 1)) | |
89 | - | then throw("Incorrect amount of asset") | |
90 | - | else if (isNFT(asset)) | |
91 | - | then throw("Asset in payment is not NFT") | |
92 | - | else { | |
93 | - | let tokenStr = getStringOrThrow(registrar, key_Name_token(asset.name)) | |
94 | - | let token = toBytes(tokenStr) | |
95 | - | let transfer = makeTransfer(caller, token) | |
96 | - | if ((transfer == transfer)) | |
97 | - | then { | |
98 | - | let registration = invoke(registrar, "reclaim", [asset.name], nil) | |
99 | - | if ((registration == registration)) | |
100 | - | then nil | |
101 | - | else throw("Strict value is not equal to itself.") | |
102 | - | } | |
103 | - | else throw("Strict value is not equal to itself.") | |
104 | - | } | |
71 | + | let isMeedusNFT = if (if (if ((asset.issuer == meedus)) | |
72 | + | then (asset.quantity == 1) | |
73 | + | else false) | |
74 | + | then (asset.decimals == 0) | |
75 | + | else false) | |
76 | + | then (asset.reissuable == false) | |
77 | + | else false | |
78 | + | if (if ((pmt.amount != 1)) | |
79 | + | then true | |
80 | + | else !(isMeedusNFT)) | |
81 | + | then throw("Payment should contain Meedus NFT") | |
82 | + | else { | |
83 | + | let tokenStr = getStringOrThrow(registrar, key_Name_token(asset.name)) | |
84 | + | let token = toBytes(tokenStr) | |
85 | + | let transfer = invoke(this, "transfer", [callerStr, asset], nil) | |
86 | + | if ((transfer == transfer)) | |
87 | + | then { | |
88 | + | let registration = invoke(registrar, "reclaim", [asset.name], nil) | |
89 | + | if ((registration == registration)) | |
90 | + | then nil | |
91 | + | else throw("Strict value is not equal to itself.") | |
92 | + | } | |
93 | + | else throw("Strict value is not equal to itself.") | |
94 | + | } | |
105 | 95 | } | |
106 | 96 | ||
107 | 97 |
github/deemru/w8io/026f985 33.11 ms ◑