tx · HH7i8rSCfVRxS1EukEiTAzFgHjYnwwq43TegwfjHRJKH 3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8: -0.01400000 Waves 2022.02.21 18:52 [1933620] smart account 3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8 > SELF 0.00000000 Waves
{ "type": 13, "id": "HH7i8rSCfVRxS1EukEiTAzFgHjYnwwq43TegwfjHRJKH", "fee": 1400000, "feeAssetId": null, "timestamp": 1645458758176, "version": 2, "chainId": 84, "sender": "3N4bt53eU7kwBbhAkh2KFYajCc1kAtu9TY8", "senderPublicKey": "6so6qVTu5xitJ3xkhqQ3AiC1noyJFbQF84JTjfW1uZTr", "proofs": [ "4riddKsUCMpQ5cTipsNV1aXWNDUZzZroXFeYPqEMzufVtTkdbWt3TK1DHiUtx9AQKb9bRAGYnS3p4FyUjFEs9KJg" ], "script": "base64:AAIFAAAAAAAAAB4IAhIHCgUICAgEARIDCgEIEgUKAwgEARIFCgMIBAEAAAAJAAAAAAdmb3VuZGVyCQEAAAAHQWRkcmVzcwAAAAEBAAAAGgFU48Tc28jbioeqqpgFSKGY6wdEuVchU7umAAAAABFDb21taXNzaW9uUGVyY2VudAAAAAAAAAAABQAAAAAIU3RhdHVzTmECAAAADU5PVF9BVkFJTEFCTEUAAAAADlN0YXR1c1RyYWRhYmxlAgAAAAhUUkFEQUJMRQAAAAARU3RhdHVzTm90VHJhZGFibGUCAAAADE5PVF9UUkFEQUJMRQEAAAAQZ2V0VG9rZW5Pd25lcktleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAAMdG9rZW5fb3duZXJfCQACWAAAAAEFAAAABXRva2VuAQAAABFnZXRUb2tlblN0YXR1c0tleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAANdG9rZW5fc3RhdHVzXwkAAlgAAAABBQAAAAV0b2tlbgEAAAAQZ2V0VG9rZW5QcmljZUtleQAAAAEAAAAFdG9rZW4JAAEsAAAAAgIAAAAMdG9rZW5fcHJpY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AQZ2V0VG9rZW5Pd25lcktleQAAAAEFAAAAB2Fzc2V0SWQFAAAAE2NhbGxlckFkZHJlc3NTdHJpbmcJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAEWdldFRva2VuU3RhdHVzS2V5AAAAAQUAAAAHYXNzZXRJZAkBAAAADGJvb2xUb1N0YXR1cwAAAAEFAAAACmlzVHJhZGFibGUJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAABBnZXRUb2tlblByaWNlS2V5AAAAAQUAAAAHYXNzZXRJZAUAAAAIbmV3UHJpY2UFAAAAA25pbAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5B+3Muw==", "height": 1933620, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 79UmBhn3LHMrm3EUnCAnG4GHVN674EEKeNDvx7R56wAZ Next: ANv7UfhHbmnwXwBnAtiGcCm3iydUozn2Dx5vNzZ9Qvw3 Diff:
Old | New | Differences | |
---|---|---|---|
43 | 43 | let statusKey = getTokenStatusKey(assetId) | |
44 | 44 | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
45 | 45 | let status = getStringValue(statusKey) | |
46 | - | if (if (( | |
46 | + | if (if (if ((i.caller == founder)) | |
47 | 47 | then true | |
48 | - | else | |
49 | - | ||
50 | - | ||
51 | - | then [ScriptTransfer( | |
48 | + | else (i.caller == realOwner)) | |
49 | + | then (status != StatusNa) | |
50 | + | else false) | |
51 | + | then [ScriptTransfer(realOwner, 1, assetId), StringEntry(getTokenOwnerKey(assetId), ""), StringEntry(getTokenStatusKey(assetId), StatusNa), IntegerEntry(getTokenPriceKey(assetId), 0)] | |
52 | 52 | else throw("Only owner and founder can pick it up") | |
53 | 53 | } | |
54 | 54 | ||
61 | 61 | let statusKey = getTokenStatusKey(assetId) | |
62 | 62 | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
63 | 63 | let status = getStringValue(statusKey) | |
64 | - | if (if (( | |
64 | + | if (if ((i.caller == realOwner)) | |
65 | 65 | then (status != StatusNa) | |
66 | 66 | else false) | |
67 | - | then [ | |
67 | + | then [StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), price)] | |
68 | 68 | else throw("Only owner can set token trade info") | |
69 | 69 | } | |
70 | 70 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let founder = Address(base58'3NAgQzjC1xnhXV6cEp38eJ2vjYAjBUaaLQm') | |
5 | 5 | ||
6 | 6 | let CommissionPercent = 5 | |
7 | 7 | ||
8 | 8 | let StatusNa = "NOT_AVAILABLE" | |
9 | 9 | ||
10 | 10 | let StatusTradable = "TRADABLE" | |
11 | 11 | ||
12 | 12 | let StatusNotTradable = "NOT_TRADABLE" | |
13 | 13 | ||
14 | 14 | func getTokenOwnerKey (token) = ("token_owner_" + toBase58String(token)) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getTokenStatusKey (token) = ("token_status_" + toBase58String(token)) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func getTokenPriceKey (token) = ("token_price_" + toBase58String(token)) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func boolToStatus (value) = if ((value == true)) | |
24 | 24 | then StatusTradable | |
25 | 25 | else StatusNotTradable | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | @Callable(i) | |
29 | 29 | func mint (ownerAddress,name,description,isTradable,price) = if ((founder != i.caller)) | |
30 | 30 | then throw("Method only for founder") | |
31 | 31 | else { | |
32 | 32 | let asset = Issue(name, description, 1, 0, false) | |
33 | 33 | let assetId = calculateAssetId(asset) | |
34 | 34 | [StringEntry(getTokenOwnerKey(assetId), ownerAddress), StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), price), asset] | |
35 | 35 | } | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | 39 | @Callable(i) | |
40 | 40 | func pickUp (assetIdString) = { | |
41 | 41 | let assetId = fromBase58String(assetIdString) | |
42 | 42 | let ownerKey = getTokenOwnerKey(assetId) | |
43 | 43 | let statusKey = getTokenStatusKey(assetId) | |
44 | 44 | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
45 | 45 | let status = getStringValue(statusKey) | |
46 | - | if (if (( | |
46 | + | if (if (if ((i.caller == founder)) | |
47 | 47 | then true | |
48 | - | else | |
49 | - | ||
50 | - | ||
51 | - | then [ScriptTransfer( | |
48 | + | else (i.caller == realOwner)) | |
49 | + | then (status != StatusNa) | |
50 | + | else false) | |
51 | + | then [ScriptTransfer(realOwner, 1, assetId), StringEntry(getTokenOwnerKey(assetId), ""), StringEntry(getTokenStatusKey(assetId), StatusNa), IntegerEntry(getTokenPriceKey(assetId), 0)] | |
52 | 52 | else throw("Only owner and founder can pick it up") | |
53 | 53 | } | |
54 | 54 | ||
55 | 55 | ||
56 | 56 | ||
57 | 57 | @Callable(i) | |
58 | 58 | func setTokenInfo (assetIdString,isTradable,price) = { | |
59 | 59 | let assetId = fromBase58String(assetIdString) | |
60 | 60 | let ownerKey = getTokenOwnerKey(assetId) | |
61 | 61 | let statusKey = getTokenStatusKey(assetId) | |
62 | 62 | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
63 | 63 | let status = getStringValue(statusKey) | |
64 | - | if (if (( | |
64 | + | if (if ((i.caller == realOwner)) | |
65 | 65 | then (status != StatusNa) | |
66 | 66 | else false) | |
67 | - | then [ | |
67 | + | then [StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), price)] | |
68 | 68 | else throw("Only owner can set token trade info") | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
73 | 73 | @Callable(i) | |
74 | 74 | func buy (assetIdString,isTradable,newPrice) = { | |
75 | 75 | let assetId = i.caller.bytes | |
76 | 76 | let callerAddressString = toBase58String(i.caller.bytes) | |
77 | 77 | let callerAddress = Address(i.caller.bytes) | |
78 | 78 | let ownerKey = getTokenOwnerKey(assetId) | |
79 | 79 | let realOwner = Address(fromBase58String(getStringValue(ownerKey))) | |
80 | 80 | if (if ((size(i.payments) == 0)) | |
81 | 81 | then true | |
82 | 82 | else (i.caller == realOwner)) | |
83 | 83 | then throw("Payment must be attached and you should not be the asset owner") | |
84 | 84 | else { | |
85 | 85 | let pmt = i.payments[0] | |
86 | 86 | if (isDefined(pmt.assetId)) | |
87 | 87 | then throw("This function accepts WAVES tokens only") | |
88 | 88 | else { | |
89 | 89 | let currentPrice = getIntegerValue(getTokenPriceKey(assetId)) | |
90 | 90 | let onePercent = (currentPrice / 100) | |
91 | 91 | let totalSum = (onePercent * (100 + CommissionPercent)) | |
92 | 92 | let realCommission = (totalSum - currentPrice) | |
93 | 93 | if ((pmt.amount != totalSum)) | |
94 | 94 | then throw("Incorrect buy sum") | |
95 | 95 | else [ScriptTransfer(realOwner, currentPrice, unit), ScriptTransfer(founder, realCommission, unit), StringEntry(getTokenOwnerKey(assetId), callerAddressString), StringEntry(getTokenStatusKey(assetId), boolToStatus(isTradable)), IntegerEntry(getTokenPriceKey(assetId), newPrice)] | |
96 | 96 | } | |
97 | 97 | } | |
98 | 98 | } | |
99 | 99 | ||
100 | 100 | ||
101 | 101 | @Verifier(tx) | |
102 | 102 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
103 | 103 |
github/deemru/w8io/169f3d6 31.29 ms ◑