tx · 2FNUahHuoAQuiN6LWjDMwzSqxJP8w7SizZvaftMyVSJ6

3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg:  -0.01000000 Waves

2021.11.25 18:24 [1806744] smart account 3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg > SELF 0.00000000 Waves

{ "type": 13, "id": "2FNUahHuoAQuiN6LWjDMwzSqxJP8w7SizZvaftMyVSJ6", "fee": 1000000, "feeAssetId": null, "timestamp": 1637853887919, "version": 1, "sender": "3Mz7AZHqAeMecF7aaE9HVsK94XVQKf1QCKg", "senderPublicKey": "9o6mYaNcbcTi647J8XhDQg2VsHJCv5Jon1QFPCbFPoFh", "proofs": [ "365pEGFViRH9Gi1MwLio3HDruw1yGz3ZiFbqwVKjBv7fzcc6H2MSwYLp3rWhZpYrfWEaRibaNaXuyxp86CpGRStn" ], "script": "base64:AAIFAAAAAAAAABAIAhIFCgMBAQgSABIDCgEIAAAADQAAAAAJc2VwYXJhdG9yAgAAAAJfXwEAAAAPZ2V0U3RyaW5nT3JGYWlsAAAAAgAAAAdhZGRyZXNzAAAAA2tleQkBAAAAE3ZhbHVlT3JFcnJvck1lc3NhZ2UAAAACCQAEHQAAAAIFAAAAB2FkZHJlc3MFAAAAA2tleQkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACAgAAAAptYW5kYXRvcnkgCQAEJQAAAAEFAAAAB2FkZHJlc3MCAAAAAS4FAAAAA2tleQIAAAAPIGlzIG5vdCBkZWZpbmVkAAAAAAhrZXlTdGFydAkABLkAAAACCQAETAAAAAICAAAAAiVzCQAETAAAAAICAAAABXN0YXJ0BQAAAANuaWwFAAAACXNlcGFyYXRvcgAAAAALa2V5RHVyYXRpb24JAAS5AAAAAgkABEwAAAACAgAAAAIlcwkABEwAAAACAgAAAAhkdXJhdGlvbgUAAAADbmlsBQAAAAlzZXBhcmF0b3IAAAAACGtleUFzc2V0CQAEuQAAAAIJAARMAAAAAgIAAAACJXMJAARMAAAAAgI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ZnZXRVc2VyUmV3YXJkc1JFQURPTkxZAAAAAQAAAAdhZGRyZXNzBAAAAAZjaGVja3MJAARMAAAAAgkBAAAAEmNoZWNrSWZEYXRhSXNSZWFkeQAAAAAFAAAAA25pbAMJAAAAAAAAAgUAAAAGY2hlY2tzBQAAAAZjaGVja3MEAAAACyR0MDMxNzAzMjUzCQEAAAAOZ2V0VXNlclJld2FyZHMAAAABCQEAAAARQGV4dHJOYXRpdmUoMTA2MikAAAABBQAAAAdhZGRyZXNzBAAAAAV0b3RhbAgFAAAACyR0MDMxNzAzMjUzAAAAAl8xBAAAAAdjbGFpbWVkCAUAAAALJHQwMzE3MDMyNTMAAAACXzIEAAAACWF2YWlsYWJsZQgFAAAACyR0MDMxNzAzMjUzAAAAAl8zCQAFFAAAAAIFAAAAA25pbAkABLkAAAACCQAETAAAAAICAAAABiVkJWQlZAkABEwAAAACCQABpAAAAAEFAAAABXRvdGFsCQAETAAAAAIJAAGkAAAAAQUAAAAHY2xhaW1lZAkABEwAAAACCQABpAAAAAEFAAAACWF2YWlsYWJsZQUAAAADbmlsBQAAAAlzZXBhcmF0b3IJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAL8lGDU=", "chainId": 84, "height": 1806744, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 3cotESFcUeb2Yy27NwNa9sm6N13i8NCjWwteqrLcPUcm Next: CK9o4PhRGF5iconPTaUUY6SBcG2kVddDnv1MLjQ4VQhv Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let separator = "__"
55
66 func getStringOrFail (address,key) = valueOrErrorMessage(getString(address, key), (((("mandatory " + toString(address)) + ".") + key) + " is not defined"))
77
88
99 let keyStart = makeString(["%s", "start"], separator)
1010
1111 let keyDuration = makeString(["%s", "duration"], separator)
1212
1313 let keyAsset = makeString(["%s", "asset"], separator)
1414
1515 let keyIsDataReady = makeString(["%s", "isDataReady"], separator)
1616
1717 func keyUserRewardInfo (address) = makeString(["%s%s", "userRewardInfo", toString(address)], separator)
1818
1919
2020 func keyClaimHistoryRecord (address,txId) = makeString(["%s%s%s", "claimHistoryRecord", toString(address), toBase58String(txId)], separator)
2121
2222
2323 func formatHistoryRecord (amount) = makeString(["%d%d%d", toString(height), toString(lastBlock.timestamp), toString(amount)], separator)
2424
2525
2626 func dataUserRewardInfo (totalAmt,claimedAmt) = makeString(["%d%d", toString(totalAmt), toString(claimedAmt)], separator)
2727
2828
2929 func readUserRewardInfo (userAddr) = split(getStringOrFail(this, keyUserRewardInfo(userAddr)), separator)
3030
3131
3232 func checkIfDataIsReady () = {
3333 let isDataReady = valueOrElse(getBoolean(this, keyIsDataReady), false)
3434 if (isDataReady)
3535 then true
3636 else throw("Data is not ready")
3737 }
3838
3939
4040 func getUserRewards (address) = {
4141 let start = valueOrErrorMessage(getInteger(this, keyStart), "Start block is not specified")
4242 let duration = valueOrErrorMessage(getInteger(this, keyDuration), "Duration is not specified")
4343 let userRewardInfo = readUserRewardInfo(address)
4444 let total = parseIntValue(userRewardInfo[1])
4545 let claimed = parseIntValue(userRewardInfo[2])
4646 let availableTotal = fraction(total, min([duration, max([0, (height - start)])]), duration)
4747 let available = max([0, (availableTotal - claimed)])
4848 $Tuple3(total, claimed, available)
4949 }
5050
5151
5252 @Callable(i)
5353 func constructor (start,duration,assetId) = {
5454 let checks = [if ((i.caller == this))
5555 then true
5656 else throw("Access denied")]
5757 if ((checks == checks))
5858 then [IntegerEntry(keyStart, start), IntegerEntry(keyDuration, duration), StringEntry(keyAsset, assetId), BooleanEntry(keyIsDataReady, false)]
5959 else throw("Strict value is not equal to itself.")
6060 }
6161
6262
6363
6464 @Callable(i)
6565 func claim () = {
6666 let $t024322491 = getUserRewards(i.caller)
6767 let total = $t024322491._1
6868 let claimed = $t024322491._2
6969 let available = $t024322491._3
7070 let asset = fromBase58String(getStringOrFail(this, keyAsset))
7171 let balance = assetBalance(this, asset)
7272 let checks = [checkIfDataIsReady(), if ((available > 0))
7373 then true
7474 else throw("No reward available"), if ((balance >= available))
7575 then true
7676 else throw("Insufficient funds. Contact support")]
7777 if ((checks == checks))
7878 then [ScriptTransfer(i.caller, available, asset), StringEntry(keyUserRewardInfo(i.caller), dataUserRewardInfo(total, (claimed + available))), StringEntry(keyClaimHistoryRecord(i.caller, i.transactionId), formatHistoryRecord(available))]
7979 else throw("Strict value is not equal to itself.")
8080 }
8181
8282
8383
8484 @Callable(i)
8585 func getUserRewardsREADONLY (address) = {
8686 let checks = [checkIfDataIsReady()]
8787 if ((checks == checks))
8888 then {
8989 let $t031703253 = getUserRewards(addressFromStringValue(address))
9090 let total = $t031703253._1
9191 let claimed = $t031703253._2
9292 let available = $t031703253._3
9393 $Tuple2(nil, makeString(["%d%d%d", toString(total), toString(claimed), toString(available)], separator))
9494 }
9595 else throw("Strict value is not equal to itself.")
9696 }
9797
9898

github/deemru/w8io/169f3d6 
24.56 ms