tx · 7JJMK1nGdpBvFcuxXei8sPgYNkKKuu6kPRee34BTkSuu 3MtzQ5QnGrLiPjPkfGhGpZWZ9Sjbbt4ZRp6: -0.01400000 Waves 2019.11.07 10:17 [754191] smart account 3MtzQ5QnGrLiPjPkfGhGpZWZ9Sjbbt4ZRp6 > SELF 0.00000000 Waves
{ "type": 13, "id": "7JJMK1nGdpBvFcuxXei8sPgYNkKKuu6kPRee34BTkSuu", "fee": 1400000, "feeAssetId": null, "timestamp": 1573111049286, "version": 1, "sender": "3MtzQ5QnGrLiPjPkfGhGpZWZ9Sjbbt4ZRp6", "senderPublicKey": "9GQ8vyLFPqkQN3L5B35JPny3E277ZeDdBL6V9cid7JdT", "proofs": [ "HWRUbhyLzzBtSbHjY4fKfFswt4gRFe5rBeGujmqQgh4z67Bwen4FMrvDD6uSzGBfepzCTz9yrY8VBP2D9ugpar4" ], "script": "base64:AAIDAAAAAAAAABwIARIDCgEIEgMKAQgSAwoBCBIECgIICBIDCgEIAAAACAAAAAANZEFwcFB1YmxpY0tleQEAAAAgyJqrWr9pFYiDLi/zauAJxqEvmfTmD23mN9fhnOqW4BkAAAAAEndoaXRlbGlzdGluZ1N1ZmZpeAIAAAAMX3doaXRlbGlzdGVkAAAAABJibGFja2xpc3RpbmdTdWZmaXgCAAAADF9ibGFja2xpc3RlZAAAAAARYmlydGhSZWNvcmRTdWZmaXgCAAAABl9hbGl2ZQAAAAARZGVhdGhSZWNvcmRTdWZmaXgCAAAACV9kZWNlYXNlZAEAAAAPZ2V0TGlzdEZyb21EYXRhAAAAAQAAAANrZXkEAAAADWdldERhdGFTdHJpbmcJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5BAAAAAlwdWJsaWNLZXkEAAAAByRtYXRjaDAFAAAADWdldERhdGFTdHJpbmcDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAAJcHVibGljS2V5BQAAAAckbWF0Y2gwBQAAAAlwdWJsaWNLZXkJAAACAAAAAQIAAAAR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50IHRoYXQgY3JlYXRlZCB0aGlzIHJlY29yZCBjYW4gbWFrZSBpdCBkZWNlYXNlZAAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAEAAAAByRtYXRjaDAFAAAAAnR4AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABRTZXRTY3JpcHRUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRBcHBQdWJsaWNLZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAF0ludm9rZVNjcmlwdFRyYW5zYWN0aW9uBAAAAAFlBQAAAAckbWF0Y2gwAwkBAAAADWlzV2hpdGVsaXN0ZWQAAAABCQACWAAAAAEIBQAAAAJ0eAAAAA9zZW5kZXJQdWJsaWNLZXkGCQAB9AAAAAMIBQAAAAJ0eAAAAAlib2R5Qnl0ZXMJAAGRAAAAAggFAAAAAnR4AAAABnByb29mcwAAAAAAAAAAAAUAAAANZEFwcFB1YmxpY0tleQdfmBsb", "chainId": 84, "height": 754191, "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 3 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | + | {-# CONTENT_TYPE DAPP #-} | |
4 | + | let dAppPublicKey = base58'EW5L8pthNV1jLZqSb1XAsbWZWfikCDkfsp15mCGiuhHA' | |
5 | + | ||
6 | + | let whitelistingSuffix = "_whitelisted" | |
7 | + | ||
8 | + | let blacklistingSuffix = "_blacklisted" | |
9 | + | ||
10 | + | let birthRecordSuffix = "_alive" | |
11 | + | ||
12 | + | let deathRecordSuffix = "_deceased" | |
13 | + | ||
14 | + | func getListFromData (key) = { | |
15 | + | let getDataString = getString(this, key) | |
16 | + | let publicKey = match getDataString { | |
17 | + | case publicKey: String => | |
18 | + | publicKey | |
19 | + | case _ => | |
20 | + | throw("Account not found") | |
21 | + | } | |
22 | + | split(publicKey, "_") | |
23 | + | } | |
24 | + | ||
25 | + | ||
26 | + | func isWhitelisted (publicKey) = { | |
27 | + | let whitelistedKey = getString(this, publicKey) | |
28 | + | if (isDefined(whitelistedKey)) | |
29 | + | then { | |
30 | + | let whitelistedDataList = getListFromData(publicKey) | |
31 | + | if ((whitelistedDataList[1] == "whitelisted")) | |
32 | + | then true | |
33 | + | else false | |
34 | + | } | |
35 | + | else false | |
36 | + | } | |
37 | + | ||
38 | + | ||
39 | + | func isBlacklisted (publicKey) = { | |
40 | + | let blacklistedKey = getString(this, publicKey) | |
41 | + | if (isDefined(blacklistedKey)) | |
42 | + | then { | |
43 | + | let blacklistedDataList = getListFromData(publicKey) | |
44 | + | if ((blacklistedDataList[1] == "blacklisted")) | |
45 | + | then true | |
46 | + | else false | |
47 | + | } | |
48 | + | else false | |
49 | + | } | |
50 | + | ||
51 | + | ||
52 | + | @Callable(i) | |
53 | + | func whitelist (publicKey) = if ((i.callerPublicKey == dAppPublicKey)) | |
54 | + | then if (isWhitelisted(publicKey)) | |
55 | + | then throw("This account has already been whitelisted") | |
56 | + | else { | |
57 | + | let whitelistedValue = (publicKey + whitelistingSuffix) | |
58 | + | WriteSet([DataEntry(publicKey, whitelistedValue)]) | |
59 | + | } | |
60 | + | else throw("You are not authorized to whitelist accounts. Contact dApp Owner") | |
61 | + | ||
62 | + | ||
63 | + | ||
64 | + | @Callable(i) | |
65 | + | func blacklist (publicKey) = if ((i.callerPublicKey == dAppPublicKey)) | |
66 | + | then if (isWhitelisted(publicKey)) | |
67 | + | then { | |
68 | + | let blacklistedValue = (publicKey + blacklistingSuffix) | |
69 | + | WriteSet([DataEntry(publicKey, blacklistedValue)]) | |
70 | + | } | |
71 | + | else throw("This account was never whitelisted. Do verify") | |
72 | + | else throw("You are not authorized to blacklist accounts. Contact dApp Owner") | |
73 | + | ||
74 | + | ||
75 | + | ||
76 | + | @Callable(i) | |
77 | + | func addBirthRecord (record) = { | |
78 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
79 | + | if (isWhitelisted(callerPublicKey)) | |
80 | + | then { | |
81 | + | let birthRecordKey = toString(toInt(i.transactionId)) | |
82 | + | let birthRecordValue = (((record + "_") + toBase58String(i.callerPublicKey)) + birthRecordSuffix) | |
83 | + | WriteSet([DataEntry(birthRecordKey, birthRecordValue)]) | |
84 | + | } | |
85 | + | else if (isBlacklisted(callerPublicKey)) | |
86 | + | then throw("This account has been blacklisted") | |
87 | + | else throw("Only authorized accounts can add birth records to the blockchain") | |
88 | + | } | |
89 | + | ||
90 | + | ||
91 | + | ||
92 | + | @Callable(i) | |
93 | + | func updateRecord (recordId,newRecord) = { | |
94 | + | let id = match getString(this, recordId) { | |
95 | + | case a: String => | |
96 | + | a | |
97 | + | case _ => | |
98 | + | throw("Record not found") | |
99 | + | } | |
100 | + | let record = getStringValue(this, id) | |
101 | + | let recordList = split(record, "_") | |
102 | + | if ((recordList[1] == toBase58String(i.callerPublicKey))) | |
103 | + | then { | |
104 | + | let newRecordValue = ((((newRecord + "_") + toBase58String(i.callerPublicKey)) + "_") + birthRecordSuffix) | |
105 | + | WriteSet([DataEntry(id, newRecord)]) | |
106 | + | } | |
107 | + | else throw("Access denied. Only the account that created this record can update it.") | |
108 | + | } | |
109 | + | ||
110 | + | ||
111 | + | ||
112 | + | @Callable(i) | |
113 | + | func makeDeceased (recordId) = { | |
114 | + | let id = match getString(this, recordId) { | |
115 | + | case a: String => | |
116 | + | a | |
117 | + | case _ => | |
118 | + | throw("Record not found") | |
119 | + | } | |
120 | + | let record = getStringValue(this, id) | |
121 | + | let recordList = split(record, "_") | |
122 | + | if ((recordList[1] == toBase58String(i.callerPublicKey))) | |
123 | + | then { | |
124 | + | let newRecord = ((((recordList[0] + "_") + toBase58String(i.callerPublicKey)) + "_") + recordList[2]) | |
125 | + | WriteSet([DataEntry(id, newRecord)]) | |
126 | + | } | |
127 | + | else throw("Access denied. Only the account that created this record can make it deceased") | |
128 | + | } | |
129 | + | ||
130 | + | ||
131 | + | @Verifier(tx) | |
132 | + | func verify () = match tx { | |
133 | + | case d: SetScriptTransaction => | |
134 | + | sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
135 | + | case e: InvokeScriptTransaction => | |
136 | + | if (isWhitelisted(toBase58String(tx.senderPublicKey))) | |
137 | + | then true | |
138 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
139 | + | case _ => | |
140 | + | false | |
141 | + | } | |
142 | + |
github/deemru/w8io/026f985 19.90 ms ◑