tx · B6DXvYGgchaGZba71Hnk4BbYteXe2SD8pduXMomVqvvV 3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB: -0.01000000 Waves 2021.11.01 15:27 [1771932] smart account 3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB > SELF 0.00000000 Waves
{ "type": 13, "id": "B6DXvYGgchaGZba71Hnk4BbYteXe2SD8pduXMomVqvvV", "fee": 1000000, "feeAssetId": null, "timestamp": 1635769674804, "version": 1, "sender": "3MvhbvSm4f3m7BHS2YsKVPPpRZCB5qBPWrB", "senderPublicKey": "8apL73EWyKeioNcFF9zCGNMBVmtx2muqJZEF34QDGEU7", "proofs": [ "28JP1zpxGN9kG7q4PF4EaZK3tHvM2iiy7nNoTGFwQqRgorhpUNKisHkaqqZSGTiv9hkYtQ2V4CpVuuWYcmdF9GbK" ], "script": "base64:AAIFAAAAAAAAABAIAhIFCgMBAQgSABIDCgECAAAADAAAAAAJc2VwYXJhdG9yAgAAAAJfXwEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcnkgCQAEJQAAAAEFAAAAB2FkZHJlc3MCAAAAAS4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAAAAAAhrZXlTdGFydAkABLkAAAACCQAETAAAAAICAAAAAiVzCQAETAAAAAICAAAABXN0YXJ0BQAAAANuaWwFAAAACXNlcGFyYXRvcgAAAAALa2V5RHVyYXRpb24JAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAAhkdXJhdGlvbgUAAAADbmlsBQAAAAlzZXBhcmF0b3IAAAAACGtleUFzc2V0CQAEuQAAAAIJAARMAAAAAgIAAAACJXMJAARMAAAAAgIAAAAF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ldFVzZXJSZXdhcmRzAAAAAQkBAAAAB0FkZHJlc3MAAAABBQAAAAxhZGRyZXNzQnl0ZXMEAAAABXRvdGFsCAUAAAALJHQwMzA1NTMxMjcAAAACXzEEAAAAB2NsYWltZWQIBQAAAAskdDAzMDU1MzEyNwAAAAJfMgQAAAAJYXZhaWxhYmxlCAUAAAALJHQwMzA1NTMxMjcAAAACXzMJAAUUAAAAAgUAAAADbmlsCQAEuQAAAAIJAARMAAAAAgIAAAAGJWQlZCVkCQAETAAAAAIJAAGkAAAAAQUAAAAFdG90YWwJAARMAAAAAgkAAaQAAAABBQAAAAdjbGFpbWVkCQAETAAAAAIJAAGkAAAAAQUAAAAJYXZhaWxhYmxlBQAAAANuaWwFAAAACXNlcGFyYXRvcgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4AAAAAxzcm7g==", "chainId": 84, "height": 1771932, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: CutsjVuimjekvJ7npM7QPqHSJjHB95NwNxDJ7zNohXtn Next: G8sQzgYWyEutXuA2UYuJG7gWdHwHN7YBTpZf5k4F35GS Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | + | ||
6 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
7 | + | ||
5 | 8 | ||
6 | 9 | let keyStart = makeString(["%s", "start"], separator) | |
7 | 10 | ||
43 | 46 | ||
44 | 47 | ||
45 | 48 | @Callable(i) | |
46 | - | func constructor (start,duration) = { | |
49 | + | func constructor (start,duration,assetId) = { | |
47 | 50 | let targetPaymentsSize = 1 | |
48 | 51 | let checks = [if ((i.caller == this)) | |
49 | 52 | then true | |
50 | - | else throw("Access denied"), if ((size(i.payments) == targetPaymentsSize)) | |
51 | - | then true | |
52 | - | else throw("Exactly 1 payment must be attached")] | |
53 | + | else throw("Access denied")] | |
53 | 54 | if ((checks == checks)) | |
54 | - | then { | |
55 | - | let assetId = valueOrErrorMessage(value(i.payments[0]).assetId, "WAVES can't be used") | |
56 | - | [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), BinaryEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)] | |
57 | - | } | |
55 | + | then [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), StringEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)] | |
58 | 56 | else throw("Strict value is not equal to itself.") | |
59 | 57 | } | |
60 | 58 | ||
62 | 60 | ||
63 | 61 | @Callable(i) | |
64 | 62 | func claim () = { | |
65 | - | let $ | |
66 | - | let total = $ | |
67 | - | let claimed = $ | |
68 | - | let available = $ | |
69 | - | let asset = | |
63 | + | let $t023312390 = getUserRewards(i.caller) | |
64 | + | let total = $t023312390._1 | |
65 | + | let claimed = $t023312390._2 | |
66 | + | let available = $t023312390._3 | |
67 | + | let asset = fromBase58String(getStringOrFail(this, keyAsset)) | |
70 | 68 | let balance = assetBalance(this, asset) | |
71 | 69 | let checks = [checkIfDataIsReady(), if ((available > 0)) | |
72 | 70 | then true | |
85 | 83 | let checks = [checkIfDataIsReady()] | |
86 | 84 | if ((checks == checks)) | |
87 | 85 | then { | |
88 | - | let $ | |
89 | - | let total = $ | |
90 | - | let claimed = $ | |
91 | - | let available = $ | |
86 | + | let $t030553127 = getUserRewards(Address(addressBytes)) | |
87 | + | let total = $t030553127._1 | |
88 | + | let claimed = $t030553127._2 | |
89 | + | let available = $t030553127._3 | |
92 | 90 | $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator)) | |
93 | 91 | } | |
94 | 92 | else throw("Strict value is not equal to itself.") |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let separator = "__" | |
5 | + | ||
6 | + | func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined")) | |
7 | + | ||
5 | 8 | ||
6 | 9 | let keyStart = makeString(["%s", "start"], separator) | |
7 | 10 | ||
8 | 11 | let keyDuration = makeString(["%s", "duration"], separator) | |
9 | 12 | ||
10 | 13 | let keyAsset = makeString(["%s", "asset"], separator) | |
11 | 14 | ||
12 | 15 | let keyIsDataReady = makeString(["%s", "isDataReady"], separator) | |
13 | 16 | ||
14 | 17 | func keyUserRewardTotal (address) = makeString(["%s%s", "userRewardTotal", toString(address)], separator) | |
15 | 18 | ||
16 | 19 | ||
17 | 20 | func keyUserRewardClaimed (address) = makeString(["%s%s", "userRewardClaimed", toString(address)], separator) | |
18 | 21 | ||
19 | 22 | ||
20 | 23 | func keyClaimHistoryRecord (address,txId) = makeString(["%s%s%s", "claimHistoryRecord", toString(address), toBase58String(txId)], separator) | |
21 | 24 | ||
22 | 25 | ||
23 | 26 | func formatHistoryRecord (amount) = makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(amount)], separator) | |
24 | 27 | ||
25 | 28 | ||
26 | 29 | func checkIfDataIsReady () = { | |
27 | 30 | let isDataReady = valueOrElse(getBoolean(this, keyIsDataReady), false) | |
28 | 31 | if (isDataReady) | |
29 | 32 | then true | |
30 | 33 | else throw("Data is not ready") | |
31 | 34 | } | |
32 | 35 | ||
33 | 36 | ||
34 | 37 | func getUserRewards (address) = { | |
35 | 38 | let start = valueOrErrorMessage(getInteger(this, keyStart), "Start block is not specified") | |
36 | 39 | let duration = valueOrErrorMessage(getInteger(this, keyDuration), "Duration is not specified") | |
37 | 40 | let total = valueOrElse(getInteger(this, keyUserRewardTotal(address)), 0) | |
38 | 41 | let claimed = valueOrElse(getInteger(this, keyUserRewardClaimed(address)), 0) | |
39 | 42 | let availableTotal = fraction(total, min([duration, max([0, (height - start)])]), duration) | |
40 | 43 | let available = max([0, (availableTotal - claimed)]) | |
41 | 44 | $Tuple3(total, claimed, available) | |
42 | 45 | } | |
43 | 46 | ||
44 | 47 | ||
45 | 48 | @Callable(i) | |
46 | - | func constructor (start,duration) = { | |
49 | + | func constructor (start,duration,assetId) = { | |
47 | 50 | let targetPaymentsSize = 1 | |
48 | 51 | let checks = [if ((i.caller == this)) | |
49 | 52 | then true | |
50 | - | else throw("Access denied"), if ((size(i.payments) == targetPaymentsSize)) | |
51 | - | then true | |
52 | - | else throw("Exactly 1 payment must be attached")] | |
53 | + | else throw("Access denied")] | |
53 | 54 | if ((checks == checks)) | |
54 | - | then { | |
55 | - | let assetId = valueOrErrorMessage(value(i.payments[0]).assetId, "WAVES can't be used") | |
56 | - | [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), BinaryEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)] | |
57 | - | } | |
55 | + | then [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), StringEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)] | |
58 | 56 | else throw("Strict value is not equal to itself.") | |
59 | 57 | } | |
60 | 58 | ||
61 | 59 | ||
62 | 60 | ||
63 | 61 | @Callable(i) | |
64 | 62 | func claim () = { | |
65 | - | let $ | |
66 | - | let total = $ | |
67 | - | let claimed = $ | |
68 | - | let available = $ | |
69 | - | let asset = | |
63 | + | let $t023312390 = getUserRewards(i.caller) | |
64 | + | let total = $t023312390._1 | |
65 | + | let claimed = $t023312390._2 | |
66 | + | let available = $t023312390._3 | |
67 | + | let asset = fromBase58String(getStringOrFail(this, keyAsset)) | |
70 | 68 | let balance = assetBalance(this, asset) | |
71 | 69 | let checks = [checkIfDataIsReady(), if ((available > 0)) | |
72 | 70 | then true | |
73 | 71 | else throw("No reward available"), if ((balance >= available)) | |
74 | 72 | then true | |
75 | 73 | else throw("Insufficient funds. Contact support")] | |
76 | 74 | if ((checks == checks)) | |
77 | 75 | then [ScriptTransfer(i.caller, available, asset), IntegerEntry(keyUserRewardClaimed(i.caller), (claimed + available)), StringEntry(keyClaimHistoryRecord(i.caller, i.transactionId), formatHistoryRecord(available))] | |
78 | 76 | else throw("Strict value is not equal to itself.") | |
79 | 77 | } | |
80 | 78 | ||
81 | 79 | ||
82 | 80 | ||
83 | 81 | @Callable(i) | |
84 | 82 | func getUserRewardsREADONLY (addressBytes) = { | |
85 | 83 | let checks = [checkIfDataIsReady()] | |
86 | 84 | if ((checks == checks)) | |
87 | 85 | then { | |
88 | - | let $ | |
89 | - | let total = $ | |
90 | - | let claimed = $ | |
91 | - | let available = $ | |
86 | + | let $t030553127 = getUserRewards(Address(addressBytes)) | |
87 | + | let total = $t030553127._1 | |
88 | + | let claimed = $t030553127._2 | |
89 | + | let available = $t030553127._3 | |
92 | 90 | $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator)) | |
93 | 91 | } | |
94 | 92 | else throw("Strict value is not equal to itself.") | |
95 | 93 | } | |
96 | 94 | ||
97 | 95 |
github/deemru/w8io/026f985 43.89 ms ◑