tx · 8eoexJsEVTPAx34UofaN9UosyvNZkecXQGFSRo8RRQ5D 3MpHH6zrns5Yr1gp4bHYeBtEd9BBKsCTou6: -0.01400000 Waves 2019.11.07 08:17 [754069] smart account 3MpHH6zrns5Yr1gp4bHYeBtEd9BBKsCTou6 > SELF 0.00000000 Waves
{ "type": 13, "id": "8eoexJsEVTPAx34UofaN9UosyvNZkecXQGFSRo8RRQ5D", "fee": 1400000, "feeAssetId": null, "timestamp": 1573103947877, "version": 1, "sender": "3MpHH6zrns5Yr1gp4bHYeBtEd9BBKsCTou6", "senderPublicKey": "EW5L8pthNV1jLZqSb1XAsbWZWfikCDkfsp15mCGiuhHA", "proofs": [ "3NGa6R5R8J6VzLGvbruJmgBK1x83mcXF7x8huuhVZ7i8VSAZyruH5mYWvRAn7PGWCEc1wT2zxg2rpSi1SGriUcz3" ], "script": "base64:AAIDAAAAAAAAABEIARIDCgEIEgMKAQgSAwoBCAAAAAYAAAAADWRBcHBQdWJsaWNLZXkBAAAAIMiaq1q/aRWIgy4v82rgCcahL5n05g9t5jfX4ZzqluAZAAAAABJ3aGl0ZWxpc3RpbmdTdWZmaXgCAAAADF93aGl0ZWxpc3RlZAAAAAASYmxhY2tsaXN0aW5nU3VmZml4AgAAAAxfYmxhY2tsaXN0ZWQBAAAAD2dldExpc3RGcm9tRGF0YQAAAAEAAAADa2V5BAAAAA1nZXREYXRhU3RyaW5nCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQQAAAAJcHVibGljS2V5BAAAAAckbWF0Y2gwBQAAAA1nZXREYXRhU3RyaW5nAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAACXB1YmxpY0tleQUAAAAHJG1hdGNoMAUAAAAJcHVibGljS2V5CQAAAgAAAAECAAAAEUFjY291bnQgbm90IGZvdW5kCQAEtQAAAAIFAAAACXB1YmxpY0tleQIAAAABXwEAAAANaXNXaGl0ZWxpc3RlZAAAAAEAAAAJcHVibGljS2V5BAAAAA53aG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AAAA9jYWxsZXJQdWJsaWNLZXkJAAACAAAAAQIAAAAhVGhpcyBhY2NvdW50IGhhcyBiZWVuIGJsYWNrbGlzdGVkCQAAAgAAAAECAAAAQE9ubHkgYXV0aG9yaXplZCBhY2NvdW50cyBjYW4gYWRkIGJpcnRoIHJlY29yZHMgdG8gdGhlIGJsb2NrY2hhaW4AAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABAAAAAckbWF0Y2gwBQAAAAJ0eAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAUU2V0U2NyaXB0VHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA1kQXBwUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABdJbnZva2VTY3JpcHRUcmFuc2FjdGlvbgQAAAABZQUAAAAHJG1hdGNoMAMJAQAAAA1pc1doaXRlbGlzdGVkAAAAAQkAAlgAAAABCAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V5BgkAAfQAAAADCAUAAAACdHgAAAAJYm9keUJ5dGVzCQABkQAAAAIIBQAAAAJ0eAAAAAZwcm9vZnMAAAAAAAAAAAAFAAAADWRBcHBQdWJsaWNLZXkHM+tYOw==", "chainId": 84, "height": 754069, "spentComplexity": 0 } View: original | compacted Prev: 6pyZC5zSPCNV2FTws7GQYkmSLCmSCPBKBGotbBS3bA7J Next: none Diff:
Old | New | Differences | |
---|---|---|---|
5 | 5 | ||
6 | 6 | let whitelistingSuffix = "_whitelisted" | |
7 | 7 | ||
8 | + | let blacklistingSuffix = "_blacklisted" | |
9 | + | ||
10 | + | func getListFromData (key) = { | |
11 | + | let getDataString = getString(this, key) | |
12 | + | let publicKey = match getDataString { | |
13 | + | case publicKey: String => | |
14 | + | publicKey | |
15 | + | case _ => | |
16 | + | throw("Account not found") | |
17 | + | } | |
18 | + | split(publicKey, "_") | |
19 | + | } | |
20 | + | ||
21 | + | ||
8 | 22 | func isWhitelisted (publicKey) = { | |
9 | - | let keyOfWhitelistedAccount = (publicKey + whitelistingSuffix) | |
10 | - | let whitlistedKey = getString(this, keyOfWhitelistedAccount) | |
11 | - | if (isDefined(whitlistedKey)) | |
12 | - | then true | |
23 | + | let whitelistedKey = getString(this, publicKey) | |
24 | + | if (isDefined(whitelistedKey)) | |
25 | + | then { | |
26 | + | let whitelistedDataList = getListFromData(publicKey) | |
27 | + | if ((whitelistedDataList[1] == "whitelisted")) | |
28 | + | then true | |
29 | + | else false | |
30 | + | } | |
31 | + | else false | |
32 | + | } | |
33 | + | ||
34 | + | ||
35 | + | func isBlacklisted (publicKey) = { | |
36 | + | let blacklistedKey = getString(this, publicKey) | |
37 | + | if (isDefined(blacklistedKey)) | |
38 | + | then { | |
39 | + | let blacklistedDataList = getListFromData(publicKey) | |
40 | + | if ((blacklistedDataList[1] == "blacklisted")) | |
41 | + | then true | |
42 | + | else false | |
43 | + | } | |
13 | 44 | else false | |
14 | 45 | } | |
15 | 46 | ||
19 | 50 | then if (isWhitelisted(publicKey)) | |
20 | 51 | then throw("This account has already been whitelisted") | |
21 | 52 | else { | |
22 | - | let | |
23 | - | WriteSet([DataEntry( | |
53 | + | let whitelistedValue = (publicKey + whitelistingSuffix) | |
54 | + | WriteSet([DataEntry(publicKey, whitelistedValue)]) | |
24 | 55 | } | |
25 | - | else throw("You are not | |
56 | + | else throw("You are not authorized to whitelist accounts. Contact dApp Owner") | |
26 | 57 | ||
27 | 58 | ||
28 | 59 | ||
29 | 60 | @Callable(i) | |
30 | - | func addBirthRecord (info) = if (isWhitelisted(toBase58String(i.callerPublicKey))) | |
31 | - | then { | |
32 | - | let birthRecordKey = toString(toInt(i.transactionId)) | |
33 | - | WriteSet([DataEntry(birthRecordKey, info)]) | |
34 | - | } | |
35 | - | else throw("You are not allowed to create birth record on the blockchain") | |
61 | + | func blacklist (publicKey) = if ((i.callerPublicKey == dAppPublicKey)) | |
62 | + | then if (isWhitelisted(publicKey)) | |
63 | + | then { | |
64 | + | let blacklistedValue = (publicKey + blacklistingSuffix) | |
65 | + | WriteSet([DataEntry(publicKey, blacklistedValue)]) | |
66 | + | } | |
67 | + | else throw("This account was never whitelisted. Do verify") | |
68 | + | else throw("You are not authorized to blacklist accounts. Contact dApp Owner") | |
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | @Callable(i) | |
73 | + | func addBirthRecord (record) = { | |
74 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
75 | + | if (isWhitelisted(callerPublicKey)) | |
76 | + | then { | |
77 | + | let birthRecordKey = toString(toInt(i.transactionId)) | |
78 | + | WriteSet([DataEntry(birthRecordKey, record)]) | |
79 | + | } | |
80 | + | else if (isBlacklisted(callerPublicKey)) | |
81 | + | then throw("This account has been blacklisted") | |
82 | + | else throw("Only authorized accounts can add birth records to the blockchain") | |
83 | + | } | |
36 | 84 | ||
37 | 85 | ||
38 | 86 | @Verifier(tx) | |
39 | 87 | func verify () = match tx { | |
40 | 88 | case d: SetScriptTransaction => | |
41 | 89 | sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
90 | + | case e: InvokeScriptTransaction => | |
91 | + | if (isWhitelisted(toBase58String(tx.senderPublicKey))) | |
92 | + | then true | |
93 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
42 | 94 | case _ => | |
43 | - | | |
95 | + | false | |
44 | 96 | } | |
45 | 97 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let dAppPublicKey = base58'EW5L8pthNV1jLZqSb1XAsbWZWfikCDkfsp15mCGiuhHA' | |
5 | 5 | ||
6 | 6 | let whitelistingSuffix = "_whitelisted" | |
7 | 7 | ||
8 | + | let blacklistingSuffix = "_blacklisted" | |
9 | + | ||
10 | + | func getListFromData (key) = { | |
11 | + | let getDataString = getString(this, key) | |
12 | + | let publicKey = match getDataString { | |
13 | + | case publicKey: String => | |
14 | + | publicKey | |
15 | + | case _ => | |
16 | + | throw("Account not found") | |
17 | + | } | |
18 | + | split(publicKey, "_") | |
19 | + | } | |
20 | + | ||
21 | + | ||
8 | 22 | func isWhitelisted (publicKey) = { | |
9 | - | let keyOfWhitelistedAccount = (publicKey + whitelistingSuffix) | |
10 | - | let whitlistedKey = getString(this, keyOfWhitelistedAccount) | |
11 | - | if (isDefined(whitlistedKey)) | |
12 | - | then true | |
23 | + | let whitelistedKey = getString(this, publicKey) | |
24 | + | if (isDefined(whitelistedKey)) | |
25 | + | then { | |
26 | + | let whitelistedDataList = getListFromData(publicKey) | |
27 | + | if ((whitelistedDataList[1] == "whitelisted")) | |
28 | + | then true | |
29 | + | else false | |
30 | + | } | |
31 | + | else false | |
32 | + | } | |
33 | + | ||
34 | + | ||
35 | + | func isBlacklisted (publicKey) = { | |
36 | + | let blacklistedKey = getString(this, publicKey) | |
37 | + | if (isDefined(blacklistedKey)) | |
38 | + | then { | |
39 | + | let blacklistedDataList = getListFromData(publicKey) | |
40 | + | if ((blacklistedDataList[1] == "blacklisted")) | |
41 | + | then true | |
42 | + | else false | |
43 | + | } | |
13 | 44 | else false | |
14 | 45 | } | |
15 | 46 | ||
16 | 47 | ||
17 | 48 | @Callable(i) | |
18 | 49 | func whitelist (publicKey) = if ((i.callerPublicKey == dAppPublicKey)) | |
19 | 50 | then if (isWhitelisted(publicKey)) | |
20 | 51 | then throw("This account has already been whitelisted") | |
21 | 52 | else { | |
22 | - | let | |
23 | - | WriteSet([DataEntry( | |
53 | + | let whitelistedValue = (publicKey + whitelistingSuffix) | |
54 | + | WriteSet([DataEntry(publicKey, whitelistedValue)]) | |
24 | 55 | } | |
25 | - | else throw("You are not | |
56 | + | else throw("You are not authorized to whitelist accounts. Contact dApp Owner") | |
26 | 57 | ||
27 | 58 | ||
28 | 59 | ||
29 | 60 | @Callable(i) | |
30 | - | func addBirthRecord (info) = if (isWhitelisted(toBase58String(i.callerPublicKey))) | |
31 | - | then { | |
32 | - | let birthRecordKey = toString(toInt(i.transactionId)) | |
33 | - | WriteSet([DataEntry(birthRecordKey, info)]) | |
34 | - | } | |
35 | - | else throw("You are not allowed to create birth record on the blockchain") | |
61 | + | func blacklist (publicKey) = if ((i.callerPublicKey == dAppPublicKey)) | |
62 | + | then if (isWhitelisted(publicKey)) | |
63 | + | then { | |
64 | + | let blacklistedValue = (publicKey + blacklistingSuffix) | |
65 | + | WriteSet([DataEntry(publicKey, blacklistedValue)]) | |
66 | + | } | |
67 | + | else throw("This account was never whitelisted. Do verify") | |
68 | + | else throw("You are not authorized to blacklist accounts. Contact dApp Owner") | |
69 | + | ||
70 | + | ||
71 | + | ||
72 | + | @Callable(i) | |
73 | + | func addBirthRecord (record) = { | |
74 | + | let callerPublicKey = toBase58String(i.callerPublicKey) | |
75 | + | if (isWhitelisted(callerPublicKey)) | |
76 | + | then { | |
77 | + | let birthRecordKey = toString(toInt(i.transactionId)) | |
78 | + | WriteSet([DataEntry(birthRecordKey, record)]) | |
79 | + | } | |
80 | + | else if (isBlacklisted(callerPublicKey)) | |
81 | + | then throw("This account has been blacklisted") | |
82 | + | else throw("Only authorized accounts can add birth records to the blockchain") | |
83 | + | } | |
36 | 84 | ||
37 | 85 | ||
38 | 86 | @Verifier(tx) | |
39 | 87 | func verify () = match tx { | |
40 | 88 | case d: SetScriptTransaction => | |
41 | 89 | sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
90 | + | case e: InvokeScriptTransaction => | |
91 | + | if (isWhitelisted(toBase58String(tx.senderPublicKey))) | |
92 | + | then true | |
93 | + | else sigVerify(tx.bodyBytes, tx.proofs[0], dAppPublicKey) | |
42 | 94 | case _ => | |
43 | - | | |
95 | + | false | |
44 | 96 | } | |
45 | 97 |
github/deemru/w8io/026f985 26.75 ms ◑