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/OQv9D6FbqZAAAAAANXVlMAAAAAAAX14QAAAAAAC1BSSUNFeEJBU0lDAAAAAAAAAAA8AAAAAA5QUklDRXhBRFZBTkNFRAAAAAAAAAAAMgAAAAAFQkFTSUMCAAAABWJhc2ljAAAAAAhBRFZBTkNFRAIAAAAIYWR2YW5jZWQAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAN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AkBAAAAHEBleHRyVXNlcihhZGRyZXNzRnJvbVN0cmluZykAAAABBQAAAAt1c2VyQWRkcmVzcwUAAAAGcGVyaW9kBQAAAARwbGFuBQAAAAlpc1JlbmV3YWwAAAAAYy/nkQ==", "chainId": 84, "height": 744631, "spentComplexity": 0 } View: original | compacted Prev: C95vdanRioqn1eMLPV3xAoQHhZeRieH4qCdwde9ArHFy Next: JRvRTDej6F7KyG8o5X7MbSVggiGFQxfpH4Ct4FqLyNA Diff:
Old | New | Differences | |
---|---|---|---|
98 | 98 | else if ((plan == ADVANCED)) | |
99 | 99 | then MONTH | |
100 | 100 | else throw(("subscription to an unknown plan: " + plan)) | |
101 | - | getResult( | |
101 | + | getResult(addressFromStringValue(userAddress), period, plan, isRenewal) | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let YEAR = 31556952000 | |
5 | 5 | ||
6 | 6 | let MONTH = (YEAR / 12) | |
7 | 7 | ||
8 | 8 | let ADMIN = "3NBDgR8hU6W86Sstn3EGid8k9uxkqiJjxT6" | |
9 | 9 | ||
10 | 10 | let TOKEN = base58'EJ85vmBXWEtV4yHLPRTxex4q4s9mC8jKUhheyjZxwnPw' | |
11 | 11 | ||
12 | 12 | let wEUR = base58'Gtb1WRznfchDnTh37ezoDTJ4wcoKaRsKqKjJjy7nm2zU' | |
13 | 13 | ||
14 | 14 | let WVS = 100000000 | |
15 | 15 | ||
16 | 16 | let PRICExBASIC = 60 | |
17 | 17 | ||
18 | 18 | let PRICExADVANCED = 50 | |
19 | 19 | ||
20 | 20 | let BASIC = "basic" | |
21 | 21 | ||
22 | 22 | let ADVANCED = "advanced" | |
23 | 23 | ||
24 | 24 | let NONE = "none" | |
25 | 25 | ||
26 | 26 | func getNumberByKey (key) = match getInteger(this, key) { | |
27 | 27 | case n: Int => | |
28 | 28 | n | |
29 | 29 | case _ => | |
30 | 30 | 0 | |
31 | 31 | } | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getStrByKey (key) = match getString(this, key) { | |
35 | 35 | case s: String => | |
36 | 36 | s | |
37 | 37 | case _ => | |
38 | 38 | NONE | |
39 | 39 | } | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getKeySubscriptionEnd (addr) = (("member_" + addr) + "_subscription_end") | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getKeyPlan (addr) = (("member_" + addr) + "_plan") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getTransferSet (account) = TransferSet([ScriptTransfer(account, 1, TOKEN)]) | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getWriteSet (account,period,plan) = WriteSet([DataEntry(getKeySubscriptionEnd(account), (lastBlock.timestamp + period)), DataEntry(getKeyPlan(account), plan)]) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getResult (address,period,plan,isRenewal) = { | |
55 | 55 | let account = toBase58String(address.bytes) | |
56 | 56 | if (isRenewal) | |
57 | 57 | then getWriteSet(account, period, plan) | |
58 | 58 | else ScriptResult(getWriteSet(account, period, plan), getTransferSet(address)) | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(i) | |
63 | 63 | func subscribe (plan) = { | |
64 | 64 | let payment = extract(i.payment) | |
65 | 65 | if ((payment.assetId != wEUR)) | |
66 | 66 | then throw("can use only wEUR token at the moment") | |
67 | 67 | else { | |
68 | 68 | let account = toBase58String(i.caller.bytes) | |
69 | 69 | let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(account)) | |
70 | 70 | let isRenewal = (subscriptionEnd != 0) | |
71 | 71 | if ((plan == BASIC)) | |
72 | 72 | then if ((PRICExBASIC > payment.amount)) | |
73 | 73 | then throw("unsufficient payment amount for basic plan") | |
74 | 74 | else getResult(i.caller, YEAR, plan, isRenewal) | |
75 | 75 | else if ((plan == ADVANCED)) | |
76 | 76 | then if ((PRICExADVANCED > payment.amount)) | |
77 | 77 | then throw("unsufficient payment amount for advanced plan") | |
78 | 78 | else getResult(i.caller, MONTH, plan, isRenewal) | |
79 | 79 | else throw(("subscription to an unknown plan: " + plan)) | |
80 | 80 | } | |
81 | 81 | } | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | ||
85 | 85 | @Callable(i) | |
86 | 86 | func subscribeUser (userAddress,plan) = { | |
87 | 87 | let account = toBase58String(i.caller.bytes) | |
88 | 88 | let dAppAccount = toBase58String(this.bytes) | |
89 | 89 | if (if ((account != ADMIN)) | |
90 | 90 | then (account != dAppAccount) | |
91 | 91 | else false) | |
92 | 92 | then throw("only admins can do that") | |
93 | 93 | else { | |
94 | 94 | let subscriptionEnd = getNumberByKey(getKeySubscriptionEnd(userAddress)) | |
95 | 95 | let isRenewal = (subscriptionEnd != 0) | |
96 | 96 | let period = if ((plan == BASIC)) | |
97 | 97 | then YEAR | |
98 | 98 | else if ((plan == ADVANCED)) | |
99 | 99 | then MONTH | |
100 | 100 | else throw(("subscription to an unknown plan: " + plan)) | |
101 | - | getResult( | |
101 | + | getResult(addressFromStringValue(userAddress), period, plan, isRenewal) | |
102 | 102 | } | |
103 | 103 | } | |
104 | 104 | ||
105 | 105 |
github/deemru/w8io/169f3d6 37.45 ms ◑