tx · AZhF2jY54pgJgrUdu24hiP4zztaXNJUmQ4o5wDigMGDd

3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr:  -0.05000000 Waves

2019.10.31 20:11 [744631] smart account 3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr > SELF 0.00000000 Waves

{ "type": 13, "id": "AZhF2jY54pgJgrUdu24hiP4zztaXNJUmQ4o5wDigMGDd", "fee": 5000000, "feeAssetId": null, "timestamp": 1572541891883, "version": 1, "sender": "3N9hj5xjfQdmxFKgztzxsQY9FSGSRM2RNTr", "senderPublicKey": "456duGZMs5yvsHurjiNQi2JtHjKtMj4WyRRRcVHzKWrb", "proofs": [ "64JKQrK7rDSJ4VVMY5kua9TGA8UYDh7jE98PkgN67umdotiGnRTZ45qT1Vd1eUHGfffvDwuyxtC58bdV7VDfL1jm" ], "script": "base64:AAIDAAAAAAAAAA0IARIDCgEIEgQKAggIAAAAEgAAAAAEWUVBUgAAAAAHWPDfwAAAAAAFTU9OVEgJAABpAAAAAgUAAAAEWUVBUgAAAAAAAAAADAAAAAAFQURNSU4CAAAAIzNOQkRnUjhoVTZXODZTc3RuM0VHaWQ4azl1eGtxaUpqeFQ2AAAAAAVUT0tFTgEAAAAgxYrQlOWMQVAQFV8+63OMRt4C+0j9Xrs6Q7YHkRdAWuYAAAAABHdFVVIBAAAAIOwWYQRfe5EhQQY7N/Pn19T489PGDqqAl/OQv9D6FbqZAAAAAANXVlMAAAAAAAX14QAAAAAAC1BSSUNFeEJBU0lDAAAAAAAAAAA8AAAAAA5QUklDRXhBRFZBTkNFRAAAAAAAAAAAMgAAAAAFQkFTSUMCAAAABWJhc2ljAAAAAAhBRFZBTkNFRAIAAAAIYWR2YW5jZWQAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAA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ABAkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAt1c2VyQWRkcmVzcwUAAAAGcGVyaW9kBQAAAARwbGFuBQAAAAlpc1JlbmV3YWwAAAAAYy/nkQ==", "chainId": 84, "height": 744631, "spentComplexity": 0 } View: original | compacted Prev: C95vdanRioqn1eMLPV3xAoQHhZeRieH4qCdwde9ArHFy Next: JRvRTDej6F7KyG8o5X7MbSVggiGFQxfpH4Ct4FqLyNA Diff:
OldNewDifferences
9898 else if ((plan == ADVANCED))
9999 then MONTH
100100 else throw(("subscription to an unknown plan: " + plan))
101- getResult(i.caller, period, plan, isRenewal)
101+ getResult(addressFromStringValue(userAddress), period, plan, isRenewal)
102102 }
103103 }
104104
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let YEAR = 31556952000
55
66 let MONTH = (YEAR / 12)
77
88 let ADMIN = "3NBDgR8hU6W86Sstn3EGid8k9uxkqiJjxT6"
99
1010 let TOKEN = base58'EJ85vmBXWEtV4yHLPRTxex4q4s9mC8jKUhheyjZxwnPw'
1111
1212 let wEUR = base58'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU'
1313
1414 let WVS = 100000000
1515
1616 let PRICExBASIC = 60
1717
1818 let PRICExADVANCED = 50
1919
2020 let BASIC = "basic"
2121
2222 let ADVANCED = "advanced"
2323
2424 let NONE = "none"
2525
2626 func getNumberByKey (key) = match getInteger(this, key) {
2727 case n: Int =>
2828 n
2929 case _ =>
3030 0
3131 }
3232
3333
3434 func getStrByKey (key) = match getString(this, key) {
3535 case s: String =>
3636 s
3737 case _ =>
3838 NONE
3939 }
4040
4141
4242 func getKeySubscriptionEnd (addr) = (("member_" + addr) + "_subscription_end")
4343
4444
4545 func getKeyPlan (addr) = (("member_" + addr) + "_plan")
4646
4747
4848 func getTransferSet (account) = TransferSet([ScriptTransfer(account, 1, TOKEN)])
4949
5050
5151 func getWriteSet (account,period,plan) = WriteSet([DataEntry(getKeySubscriptionEnd(account), (lastBlock.timestamp + period)), DataEntry(getKeyPlan(account), plan)])
5252
5353
5454 func getResult (address,period,plan,isRenewal) = {
5555 let account = toBase58String(address.bytes)
5656 if (isRenewal)
5757 then getWriteSet(account, period, plan)
5858 else ScriptResult(getWriteSet(account, period, plan), getTransferSet(address))
5959 }
6060
6161
6262 @Callable(i)
6363 func subscribe (plan) = {
6464 let payment = extract(i.payment)
6565 if ((payment.assetId != wEUR))
6666 then throw("can use only wEUR token at the moment")
6767 else {
6868 let account = toBase58String(i.caller.bytes)
6969 let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(account))
7070 let isRenewal = (subscriptionEnd != 0)
7171 if ((plan == BASIC))
7272 then if ((PRICExBASIC > payment.amount))
7373 then throw("unsufficient payment amount for basic plan")
7474 else getResult(i.caller, YEAR, plan, isRenewal)
7575 else if ((plan == ADVANCED))
7676 then if ((PRICExADVANCED > payment.amount))
7777 then throw("unsufficient payment amount for advanced plan")
7878 else getResult(i.caller, MONTH, plan, isRenewal)
7979 else throw(("subscription to an unknown plan: " + plan))
8080 }
8181 }
8282
8383
8484
8585 @Callable(i)
8686 func subscribeUser (userAddress,plan) = {
8787 let account = toBase58String(i.caller.bytes)
8888 let dAppAccount = toBase58String(this.bytes)
8989 if (if ((account != ADMIN))
9090 then (account != dAppAccount)
9191 else false)
9292 then throw("only admins can do that")
9393 else {
9494 let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(userAddress))
9595 let isRenewal = (subscriptionEnd != 0)
9696 let period = if ((plan == BASIC))
9797 then YEAR
9898 else if ((plan == ADVANCED))
9999 then MONTH
100100 else throw(("subscription to an unknown plan: " + plan))
101- getResult(i.caller, period, plan, isRenewal)
101+ getResult(addressFromStringValue(userAddress), period, plan, isRenewal)
102102 }
103103 }
104104
105105

github/deemru/w8io/169f3d6 
37.45 ms