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