tx · 48XVExcKjyEnta9WhvfKiX5RwyyJ583gczQNW2weKXKo 3N9EXJ2Y7szbSfrxUwhWxnL3zK8wf3xosDE: -0.01400000 Waves 2019.12.17 09:40 [812562] smart account 3N9EXJ2Y7szbSfrxUwhWxnL3zK8wf3xosDE > SELF 0.00000000 Waves
{ "type": 13, "id": "48XVExcKjyEnta9WhvfKiX5RwyyJ583gczQNW2weKXKo", "fee": 1400000, "feeAssetId": null, "timestamp": 1576564840917, "version": 1, "sender": "3N9EXJ2Y7szbSfrxUwhWxnL3zK8wf3xosDE", "senderPublicKey": "9mENuoC82QFsBookiU4McsBPyUkyY7VNWe8nikxj47eh", "proofs": [ "2Th7iBgN3KUVjqfVAaDYodmhyqAQgQ2dd8c3nQ73JAtWF6a2WbNmbuDyp87XpTxAKDdNUrXxRu3d1cAMDYUE69AZ" ], "script": "base64:AAIDAAAAAAAAABIIARIECgIICBIDCgEIEgMKAQgAAAAKAAAAABRkQXBwQWNjb3VudFB1YmxpY0tleQEAAAAggjItYz1wDPYf7XYzYhDTkZ7oouxwtfQFF4TErvLkmhoAAAAACnVzZXJTdWZmaXgCAAAABl9fdXNlcgAAAAAUdW52ZXJpZmllZFVzZXJTdWZmaXgCAAAADF9fdW52ZXJpZmllZAAAAAASdmVyaWZpZWRVc2VyU3VmZml4AgAAAApfX3ZlcmlmaWVkAAAAAAljYXRlZ29yeTECAAAACmFtYmFzc2Fkb3IAAAAACWNhdGVnb3J5MgIAAAASYWN0aXZlIGNvbnRyaWJ1dG9yAAAAAAljYXRlZ29yeTMCAAAAFmNvbW11bml0eSBwYXJ0aWNpcGFudHMBAAAABmlzVXNlcgAAAAEAAAAPY2FsbGVyUHVibGljS2V5BAAAAAd1c2VyS2V5CQABLAAAAAIFAAAAD2NhbGxlclB1YmxpY0tleQUAAAAKdXNlclN1ZmZpeAMJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMFAAAAB3VzZXJLZXkGBwEAAAAPaXNWYWxpZEN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W50UHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgQAAAABaQUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAE1RyYW5zZmVyVHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDAGB4/GIOE=", "chainId": 84, "height": 812562, "spentComplexity": 0 } View: original | compacted Prev: 3fQX1QXWAdfNRcxGufRaDn7nGK61cq1VcyvqW2ahnuoR Next: 4cHqi8C96gnjY5FuhdgUUcCDxKgFBkXAEF1vqLUGq8bd Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let verifiedUserSuffix = "__verified" | |
11 | 11 | ||
12 | + | let category1 = "ambassador" | |
13 | + | ||
14 | + | let category2 = "active contributor" | |
15 | + | ||
16 | + | let category3 = "community participants" | |
17 | + | ||
12 | 18 | func isUser (callerPublicKey) = { | |
13 | 19 | let userKey = (callerPublicKey + userSuffix) | |
14 | 20 | if (isDefined(getString(this, userKey))) | |
15 | 21 | then true | |
16 | 22 | else false | |
17 | 23 | } | |
24 | + | ||
25 | + | ||
26 | + | func isValidCategory (category) = if (if (if ((category == category1)) | |
27 | + | then true | |
28 | + | else (category == category2)) | |
29 | + | then true | |
30 | + | else (category == category3)) | |
31 | + | then category | |
32 | + | else throw("Category is invalid") | |
18 | 33 | ||
19 | 34 | ||
20 | 35 | func isVerified (publicKey) = { | |
38 | 53 | ||
39 | 54 | ||
40 | 55 | @Callable(i) | |
41 | - | func signUp (info) = { | |
56 | + | func signUp (info,category) = { | |
42 | 57 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
43 | 58 | if (isUser(callerPublicKey)) | |
44 | 59 | then throw("You are already registered") | |
45 | 60 | else { | |
46 | 61 | let currentKey = callerPublicKey | |
62 | + | let userCategory = isValidCategory(category) | |
47 | 63 | let currentUserRegistrationValue = (info + unverifiedUserSuffix) | |
48 | 64 | WriteSet([DataEntry((currentKey + userSuffix), currentUserRegistrationValue)]) | |
49 | 65 | } | |
81 | 97 | let publicKey = fromBase58String(publicKeyOfUserToTip) | |
82 | 98 | if (isDefined(payment.assetId)) | |
83 | 99 | then throw("can hodl waves only at the moment") | |
84 | - | else if ((publicKey == i.callerPublicKey)) | |
85 | - | then throw("You shouldn't tip yourself") | |
86 | - | else TransferSet([ScriptTransfer(addressFromPublicKey(publicKey), payment.amount, unit)]) | |
100 | + | else TransferSet([ScriptTransfer(addressFromPublicKey(publicKey), payment.amount, unit)]) | |
87 | 101 | } | |
88 | 102 | else throw("You can't tip this user") | |
89 | 103 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let dAppAccountPublicKey = base58'9mENuoC82QFsBookiU4McsBPyUkyY7VNWe8nikxj47eh' | |
5 | 5 | ||
6 | 6 | let userSuffix = "__user" | |
7 | 7 | ||
8 | 8 | let unverifiedUserSuffix = "__unverified" | |
9 | 9 | ||
10 | 10 | let verifiedUserSuffix = "__verified" | |
11 | 11 | ||
12 | + | let category1 = "ambassador" | |
13 | + | ||
14 | + | let category2 = "active contributor" | |
15 | + | ||
16 | + | let category3 = "community participants" | |
17 | + | ||
12 | 18 | func isUser (callerPublicKey) = { | |
13 | 19 | let userKey = (callerPublicKey + userSuffix) | |
14 | 20 | if (isDefined(getString(this, userKey))) | |
15 | 21 | then true | |
16 | 22 | else false | |
17 | 23 | } | |
24 | + | ||
25 | + | ||
26 | + | func isValidCategory (category) = if (if (if ((category == category1)) | |
27 | + | then true | |
28 | + | else (category == category2)) | |
29 | + | then true | |
30 | + | else (category == category3)) | |
31 | + | then category | |
32 | + | else throw("Category is invalid") | |
18 | 33 | ||
19 | 34 | ||
20 | 35 | func isVerified (publicKey) = { | |
21 | 36 | let key = (publicKey + userSuffix) | |
22 | 37 | let userKey = getString(this, key) | |
23 | 38 | if (isDefined(userKey)) | |
24 | 39 | then { | |
25 | 40 | let userData = match getString(this, key) { | |
26 | 41 | case a: String => | |
27 | 42 | a | |
28 | 43 | case _ => | |
29 | 44 | throw("Record not found") | |
30 | 45 | } | |
31 | 46 | let userList = split(userData, "__") | |
32 | 47 | if ((userList[1] == "verified")) | |
33 | 48 | then true | |
34 | 49 | else false | |
35 | 50 | } | |
36 | 51 | else false | |
37 | 52 | } | |
38 | 53 | ||
39 | 54 | ||
40 | 55 | @Callable(i) | |
41 | - | func signUp (info) = { | |
56 | + | func signUp (info,category) = { | |
42 | 57 | let callerPublicKey = toBase58String(i.callerPublicKey) | |
43 | 58 | if (isUser(callerPublicKey)) | |
44 | 59 | then throw("You are already registered") | |
45 | 60 | else { | |
46 | 61 | let currentKey = callerPublicKey | |
62 | + | let userCategory = isValidCategory(category) | |
47 | 63 | let currentUserRegistrationValue = (info + unverifiedUserSuffix) | |
48 | 64 | WriteSet([DataEntry((currentKey + userSuffix), currentUserRegistrationValue)]) | |
49 | 65 | } | |
50 | 66 | } | |
51 | 67 | ||
52 | 68 | ||
53 | 69 | ||
54 | 70 | @Callable(i) | |
55 | 71 | func verifyUser (publicKey) = if ((i.callerPublicKey != dAppAccountPublicKey)) | |
56 | 72 | then throw("Only dApp account can verify a user") | |
57 | 73 | else if (isVerified(publicKey)) | |
58 | 74 | then throw("This user has already been verified") | |
59 | 75 | else if (isUser(publicKey)) | |
60 | 76 | then { | |
61 | 77 | let userData = match getString(this, (publicKey + userSuffix)) { | |
62 | 78 | case a: String => | |
63 | 79 | a | |
64 | 80 | case _ => | |
65 | 81 | throw("User not found") | |
66 | 82 | } | |
67 | 83 | let userList = split(userData, "__") | |
68 | 84 | let userInfo = userList[0] | |
69 | 85 | let updatedUserValue = (userInfo + verifiedUserSuffix) | |
70 | 86 | let userKey = (publicKey + userSuffix) | |
71 | 87 | WriteSet([DataEntry(userKey, updatedUserValue)]) | |
72 | 88 | } | |
73 | 89 | else throw("This is not a registered user") | |
74 | 90 | ||
75 | 91 | ||
76 | 92 | ||
77 | 93 | @Callable(i) | |
78 | 94 | func tip (publicKeyOfUserToTip) = if (isVerified(publicKeyOfUserToTip)) | |
79 | 95 | then { | |
80 | 96 | let payment = extract(i.payment) | |
81 | 97 | let publicKey = fromBase58String(publicKeyOfUserToTip) | |
82 | 98 | if (isDefined(payment.assetId)) | |
83 | 99 | then throw("can hodl waves only at the moment") | |
84 | - | else if ((publicKey == i.callerPublicKey)) | |
85 | - | then throw("You shouldn't tip yourself") | |
86 | - | else TransferSet([ScriptTransfer(addressFromPublicKey(publicKey), payment.amount, unit)]) | |
100 | + | else TransferSet([ScriptTransfer(addressFromPublicKey(publicKey), payment.amount, unit)]) | |
87 | 101 | } | |
88 | 102 | else throw("You can't tip this user") | |
89 | 103 | ||
90 | 104 | ||
91 | 105 | @Verifier(tx) | |
92 | 106 | func verify () = match tx { | |
93 | 107 | case s: SetScriptTransaction => | |
94 | 108 | sigVerify(tx.bodyBytes, tx.proofs[0], dAppAccountPublicKey) | |
95 | 109 | case i: InvokeScriptTransaction => | |
96 | 110 | true | |
97 | 111 | case t: TransferTransaction => | |
98 | 112 | true | |
99 | 113 | case _ => | |
100 | 114 | false | |
101 | 115 | } | |
102 | 116 |
github/deemru/w8io/169f3d6 47.52 ms ◑