tx · H6NfN9bZsGVCXMJn8hBXvdzgZYinMqJmm9qa68SH6Pg2 3Mw7eX6cZqiRKeRWEyiczJhppyCHqPEpbge: -0.01000000 Waves 2021.10.15 12:58 [1747248] smart account 3Mw7eX6cZqiRKeRWEyiczJhppyCHqPEpbge > SELF 0.00000000 Waves
{ "type": 13, "id": "H6NfN9bZsGVCXMJn8hBXvdzgZYinMqJmm9qa68SH6Pg2", "fee": 1000000, "feeAssetId": null, "timestamp": 1634291920025, "version": 1, "sender": "3Mw7eX6cZqiRKeRWEyiczJhppyCHqPEpbge", "senderPublicKey": "HN7vybobd8mKTW1U8bcuwQYkySwfwFUyAvB4CjbFhX7H", "proofs": [ "4sAFk1XGQZ5XCn2gcJJbPmBsVRt3yR1onKq3w6znFDfF9wtW2V7qYh7PSX4hgYjJ88uMxRRJnKEZpJPBs3HekzcM" ], "script": "base64:AAIFAAAAAAAAAAsIAhIFCgMBAQgSAAAAABYAAAAAA1NFUAIAAAACX18AAAAAFUlkeENmZ0NsYWltU3RhcnRCbG9jawAAAAAAAAAAAQAAAAAYSWR4Q2ZnQ2xhaW1WZXN0aW5nUGVyaW9kAAAAAAAAAAACAAAAABJJZHhDZmdDbGFpbUFzc2V0SWQAAAAAAAAAAAMAAAAAFElkeENmZ0NsYWltQXNzZXRNdWx0AAAAAAAAAAAEAAAAABVJZHhDZmdDbGFpbUFzc2V0T3duZXIAAAAAAAAAAAUAAAAAG0lkeENmZ0NsYWltQXNzZXRUb3RhbEFtb3VudAAAAAAAAAAABgAAAAAbSWR4VG90YWxzVG90YWxDbGFpbWVkQW1vdW50AAAAAAAAAAABAAAAABhJZHhUb3RhbHNSZW1haW5pbmdBbW91bnQAAAAAAAAAAAIAAAAAGklkeFRvdGFsc0xhc3RDbGFpbWVkSGVpZ2h0AAAAAAAAAAADAQAAAA9nZXRTdHJpbmdPckZhaWwAAAABAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEIgAAAAEFAAAAA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AAAADBQAAABhjZmdDbGFpbUFzc2V0VG90YWxBbW91bnQFAAAADmNsYWltaW5nQmxvY2tzBQAAABBjZmdDbGFpbUR1cmF0aW9uCQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMFAAAAC3VzZXJBZGRyZXNzBQAAABNjbGFpbWluZ0Fzc2V0QW1vdW50CQACWQAAAAEFAAAAEWNmZ0NsYWltQXNzZXRJZDU4CQAETAAAAAIJAQAAAAtUb3RhbHNFbnRyeQAAAAQJAQAAAAlrZXlUb3RhbHMAAAAACQEAAAAPcmVhZFRvdGFsc0FycmF5AAAAAAUAAAATY2xhaW1pbmdBc3NldEFtb3VudAUAAAATbGFzdENhbHVsYXRpb25CbG9jawkABEwAAAACCQEAAAAaQ2xhaW1PcGVyYXRpb25IaXN0b3J5RW50cnkAAAAGBQAAAA11c2VyQWRkcmVzczU4BQAAABNjbGFpbWluZ0Fzc2V0QW1vdW50BQAAAA5jbGFpbWluZ0Jsb2NrcwUAAAAUZmlyc3RDYWx1bGF0aW9uQmxvY2sFAAAAE2xhc3RDYWx1bGF0aW9uQmxvY2sIBQAAAAFpAAAADXRyYW5zYWN0aW9uSWQFAAAAA25pbAAAAAC2KxdV", "chainId": 84, "height": 1747248, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let SEP = "__" | |
5 | + | ||
6 | + | let IdxCfgClaimStartBlock = 1 | |
7 | + | ||
8 | + | let IdxCfgClaimVestingPeriod = 2 | |
9 | + | ||
10 | + | let IdxCfgClaimAssetId = 3 | |
11 | + | ||
12 | + | let IdxCfgClaimAssetMult = 4 | |
13 | + | ||
14 | + | let IdxCfgClaimAssetOwner = 5 | |
15 | + | ||
16 | + | let IdxCfgClaimAssetTotalAmount = 6 | |
17 | + | ||
18 | + | let IdxTotalsTotalClaimedAmount = 1 | |
19 | + | ||
20 | + | let IdxTotalsRemainingAmount = 2 | |
21 | + | ||
22 | + | let IdxTotalsLastClaimedHeight = 3 | |
23 | + | ||
24 | + | func getStringOrFail (key) = valueOrErrorMessage(getString(key), (("mandatory this." + key) + " is not defined")) | |
25 | + | ||
26 | + | ||
27 | + | func formatConfigString (claimStartBlock,vestingPeriod,assetIdBase58,assetMult,assetOwner,assetTotalAmt) = makeString(["%d%d%s%d%s%d%", claimStartBlock, vestingPeriod, assetIdBase58, assetMult, assetOwner, assetTotalAmt], SEP) | |
28 | + | ||
29 | + | ||
30 | + | func formatConfig (claimStartBlock,vestingPeriod,assetIdBase58,assetMult,claimAssetOwner,claimAssetTotalAmount) = formatConfigString(toString(claimStartBlock), toString(vestingPeriod), assetIdBase58, toString(assetMult), claimAssetOwner, toString(claimAssetTotalAmount)) | |
31 | + | ||
32 | + | ||
33 | + | func formatTotalsString (totalClaimedAmount,remainingAmountForClaim,lastClaimedHeight) = makeString(["%d%d%d", totalClaimedAmount, remainingAmountForClaim, lastClaimedHeight], SEP) | |
34 | + | ||
35 | + | ||
36 | + | func formatHistoryRecord (claimedAssetAmount,claimingBlocks,firstCalulationBlock,lastCalulationBlock) = makeString(["%d%d%d%d%d%d", toString(height), toString(lastBlock.timestamp), toString(claimedAssetAmount), toString(claimingBlocks), toString(firstCalulationBlock), toString(lastCalulationBlock)], SEP) | |
37 | + | ||
38 | + | ||
39 | + | func keyConfig () = "%s__config" | |
40 | + | ||
41 | + | ||
42 | + | func keyTotals () = "%s__totals" | |
43 | + | ||
44 | + | ||
45 | + | func keyOperationHistoryRecord (type,userAddress,txId58) = makeString(["%s%s%s%s__history", type, userAddress, txId58], SEP) | |
46 | + | ||
47 | + | ||
48 | + | func readConfigArray () = split(getStringOrFail(keyConfig()), SEP) | |
49 | + | ||
50 | + | ||
51 | + | func readTotalsArray () = split(getStringOrFail(keyTotals()), SEP) | |
52 | + | ||
53 | + | ||
54 | + | func TotalsEntry (key,origArray,claimedAmt,newLastClaimedHeight) = { | |
55 | + | let totalClaimedAmount = parseIntValue(origArray[IdxTotalsTotalClaimedAmount]) | |
56 | + | let remainingAmount = parseIntValue(origArray[IdxTotalsRemainingAmount]) | |
57 | + | let lastClaimedHeight = parseIntValue(origArray[IdxTotalsLastClaimedHeight]) | |
58 | + | let newTotalClaimedAmount = (totalClaimedAmount + claimedAmt) | |
59 | + | let newRemainingAmount = (remainingAmount - claimedAmt) | |
60 | + | if ((0 > newRemainingAmount)) | |
61 | + | then throw("invalid math") | |
62 | + | else StringEntry(key, formatTotalsString(toString(newTotalClaimedAmount), toString(newRemainingAmount), toString(newLastClaimedHeight))) | |
63 | + | } | |
64 | + | ||
65 | + | ||
66 | + | func ClaimOperationHistoryEntry (userAddress,claimedAssetAmount,claimingBlocks,firstCalculationBlock,lastCalculationBlock,txId) = StringEntry(keyOperationHistoryRecord("claim", userAddress, toBase58String(txId)), formatHistoryRecord(claimedAssetAmount, claimingBlocks, firstCalculationBlock, lastCalculationBlock)) | |
67 | + | ||
68 | + | ||
69 | + | @Callable(i) | |
70 | + | func constructor (claimStartBlock,vestingPeriodBlocks,beneficiaryAddress) = { | |
71 | + | let vestingEnd = (claimStartBlock + vestingPeriodBlocks) | |
72 | + | if (isDefined(getString(keyConfig()))) | |
73 | + | then throw("already initialized") | |
74 | + | else if ((size(i.payments) != 1)) | |
75 | + | then throw("exactly 1 payment must be attached") | |
76 | + | else if (("3N4Aib5iubWiGMzdTh6wWiVDVbo32oeVUmH" != toString(i.caller))) | |
77 | + | then throw("not authorized") | |
78 | + | else { | |
79 | + | let beneficiaryAddressParsed = valueOrErrorMessage(addressFromString(beneficiaryAddress), "Invalid beneficiarAddress passed") | |
80 | + | let pmt = value(i.payments[0]) | |
81 | + | let claimAssetId = value(pmt.assetId) | |
82 | + | let claimAssetInfo = valueOrErrorMessage(assetInfo(claimAssetId), "fail to load ido asset info") | |
83 | + | let claimAssetId58 = toBase58String(claimAssetId) | |
84 | + | let claimAssetMult = pow(10, 0, claimAssetInfo.decimals, 0, 0, DOWN) | |
85 | + | let claimAssetAmount = pmt.amount | |
86 | + | [StringEntry(keyConfig(), formatConfig(claimStartBlock, vestingPeriodBlocks, claimAssetId58, claimAssetMult, toString(beneficiaryAddressParsed), claimAssetAmount)), StringEntry(keyTotals(), formatTotalsString("0", toString(claimAssetAmount), "0"))] | |
87 | + | } | |
88 | + | } | |
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func claim () = { | |
94 | + | let cfgArray = readConfigArray() | |
95 | + | let cfgClaimStartHeight = parseIntValue(cfgArray[IdxCfgClaimStartBlock]) | |
96 | + | let cfgClaimDuration = parseIntValue(cfgArray[IdxCfgClaimVestingPeriod]) | |
97 | + | let cfgClaimEnd = (cfgClaimStartHeight + cfgClaimDuration) | |
98 | + | let cfgClaimAssetId58 = cfgArray[IdxCfgClaimAssetId] | |
99 | + | let cfgClaimAssetOwner = cfgArray[IdxCfgClaimAssetOwner] | |
100 | + | let cfgClaimAssetTotalAmount = parseIntValue(cfgArray[IdxCfgClaimAssetTotalAmount]) | |
101 | + | let userAddress = i.caller | |
102 | + | let userAddress58 = toString(userAddress) | |
103 | + | let origTotalsArray = readTotalsArray() | |
104 | + | let totalClaimedAmount = parseIntValue(origTotalsArray[IdxTotalsTotalClaimedAmount]) | |
105 | + | let totalRemainingAmount = parseIntValue(origTotalsArray[IdxTotalsRemainingAmount]) | |
106 | + | let lastClaimedHeight = parseIntValue(origTotalsArray[IdxTotalsLastClaimedHeight]) | |
107 | + | if ((userAddress58 != cfgClaimAssetOwner)) | |
108 | + | then throw("permissions denied") | |
109 | + | else if ((cfgClaimStartHeight > height)) | |
110 | + | then throw(("Wait claim start block: " + toString(cfgClaimStartHeight))) | |
111 | + | else { | |
112 | + | let lastCalulationBlock = if ((height > cfgClaimEnd)) | |
113 | + | then cfgClaimEnd | |
114 | + | else height | |
115 | + | let firstCalulationBlock = if ((lastClaimedHeight == 0)) | |
116 | + | then cfgClaimStartHeight | |
117 | + | else lastClaimedHeight | |
118 | + | let claimingBlocks = (lastCalulationBlock - firstCalulationBlock) | |
119 | + | let claimingAssetAmount = fraction(cfgClaimAssetTotalAmount, claimingBlocks, cfgClaimDuration) | |
120 | + | [ScriptTransfer(userAddress, claimingAssetAmount, fromBase58String(cfgClaimAssetId58)), TotalsEntry(keyTotals(), readTotalsArray(), claimingAssetAmount, lastCalulationBlock), ClaimOperationHistoryEntry(userAddress58, claimingAssetAmount, claimingBlocks, firstCalulationBlock, lastCalulationBlock, i.transactionId)] | |
121 | + | } | |
122 | + | } | |
123 | + | ||
124 | + |
github/deemru/w8io/026f985 31.87 ms ◑