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