tx · CoNoGc5tYou5wyNidthq7xWBYWrexFK9j4ycoPCS6e7w 3Mr5sE9j8pwf1XwKEa5Dus9xJ3CvJLtwkh9: -0.01400000 Waves 2019.07.03 12:59 [569081] smart account 3Mr5sE9j8pwf1XwKEa5Dus9xJ3CvJLtwkh9 > SELF 0.00000000 Waves
{ "type": 13, "id": "CoNoGc5tYou5wyNidthq7xWBYWrexFK9j4ycoPCS6e7w", "fee": 1400000, "feeAssetId": null, "timestamp": 1562148002517, "version": 1, "sender": "3Mr5sE9j8pwf1XwKEa5Dus9xJ3CvJLtwkh9", "senderPublicKey": "Ewpv1KbhV86nMYKE13YqKqELTq7YedxV1tPEGeftmMYN", "proofs": [ "76SqpuR1ZhdidtLVJtRvhng72gT1dEmqqr7ByoL37usnb2Bv7uw5s9fckBVJpAwUX2mJSZuPbT8tJVhERF2nToS" ], "script": "base64:AAIDAAAAAAAAAAAAAAAEAQAAAB5nZXRFeHRWYWx1ZUl0ZW1XaGl0ZUxpc3RTdGF0dXMAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAQX3ZlcmlmaWVyX3N0YXR1cwAAAAAIdmVyaWZpZXICAAAAIzNNdDljNWs4N3g3UDNiTXdTZjVxU2tqZkZRUXBMM2hTa0FNAAAAAAhWRVJJRklFRAIAAAAIdmVyaWZpZWQAAAAAC0JMQUNLTElTVEVEAgAAAAlibGFja2xpc3QAAAABAAAAAWkBAAAACXNldFN0YXR1cwAAAAIAAAAIc3VwcGxpZXIAAAAGc3RhdHVzBAAAAAdhY2NvdW50CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAACIT0AAAACBQAAAAdhY2NvdW50BQAAAAh2ZXJpZmllcgkAAAIAAAABAgAAADFvbmx5IG9yYWNsZSB2ZXJpZmllciBhcmUgYWJsZSB0byBtYW5hZ2Ugd2hpdGVsaXN0AwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAIVkVSSUZJRUQJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAALQkxBQ0tMSVNURUQHCQAAAgAAAAECAAAADHdyb25nIHN0YXR1cwkBAAAACFdyaXRlU2V0AAAAAQkABEwAAAACCQEAAAAJRGF0YUVudHJ5AAAAAgkBAAAAHmdldEV4dFZhbHVlSXRlbVdoaXRlTGlzdFN0YXR1cwAAAAEFAAAACHN1cHBsaWVyBQAAAAZzdGF0dXMFAAAAA25pbAAAAACtBXNz", "chainId": 84, "height": 569081, "spentComplexity": 0 } View: original | compacted Prev: C6wCXd7da5YEwT3be9XCnYgvQ72QEBPA46y8U2ZHuqte Next: none Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let NONE = "none" | |
5 | - | ||
6 | - | func getNumberByKey (key) = { | |
7 | - | let num = match getInteger(this, key) { | |
8 | - | case a: Int => | |
9 | - | a | |
10 | - | case _ => | |
11 | - | 0 | |
12 | - | } | |
13 | - | num | |
14 | - | } | |
15 | - | ||
16 | - | ||
17 | - | func getStrByKey (key) = { | |
18 | - | let str = match getString(this, key) { | |
19 | - | case a: String => | |
20 | - | a | |
21 | - | case _ => | |
22 | - | NONE | |
23 | - | } | |
24 | - | str | |
25 | - | } | |
26 | - | ||
27 | - | ||
28 | - | func getKeyItemPrice (item) = (item + "_price") | |
29 | - | ||
30 | - | ||
31 | - | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | - | ||
33 | - | ||
34 | - | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | - | ||
36 | - | ||
37 | - | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(item, item)) | |
38 | - | ||
39 | - | ||
40 | - | func getKeyItem (supplier,titlle) = ("item_" + toBase58String(sha256(toBytes((supplier + titlle))))) | |
41 | - | ||
42 | - | ||
43 | - | func getKeyItemData (item) = (item + "_data") | |
44 | - | ||
45 | - | ||
46 | - | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | - | ||
48 | - | ||
49 | - | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | - | ||
51 | - | ||
52 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | - | ||
54 | - | ||
55 | - | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | - | ||
57 | - | ||
58 | - | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
59 | - | ||
60 | - | ||
61 | - | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
62 | - | ||
63 | - | ||
64 | - | func getKeyCommitsCount (item) = (item + "_comcnt") | |
65 | - | ||
66 | - | ||
67 | - | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
68 | - | ||
69 | - | ||
70 | - | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
71 | - | ||
72 | - | ||
73 | - | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
74 | - | ||
75 | - | ||
76 | - | func getKeyItemStatus (item) = (item + "_status") | |
77 | - | ||
78 | - | ||
79 | - | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
80 | - | ||
81 | - | ||
82 | - | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
83 | - | ||
84 | - | ||
85 | - | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
86 | - | ||
87 | - | ||
88 | - | func getExtAddressOracle () = extract(addressFromString("3Mt9c5k87x7P3bMwSf5qSkjfFQQpL3hSkAM")) | |
89 | - | ||
90 | - | ||
91 | - | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
92 | - | ||
93 | - | ||
94 | - | func getExtValueItemWhiteListStatus (oracle,account) = { | |
95 | - | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
96 | - | case a: String => | |
97 | - | a | |
98 | - | case _ => | |
99 | - | NONE | |
100 | - | } | |
101 | - | str | |
102 | - | } | |
4 | + | func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status") | |
103 | 5 | ||
104 | 6 | ||
105 | 7 | let verifier = "3Mt9c5k87x7P3bMwSf5qSkjfFQQpL3hSkAM" | |
109 | 11 | let BLACKLISTED = "blacklist" | |
110 | 12 | ||
111 | 13 | @Callable(i) | |
112 | - | func addItem (title,price,data) = { | |
113 | - | let supplierAddress = toBase58String(i.caller.bytes) | |
114 | - | let item = getKeyItem(supplierAddress, title) | |
115 | - | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
116 | - | if ((0 >= price)) | |
117 | - | then throw("purchase amount cannot be lett than item price") | |
118 | - | else if ((getValueItemSupplier(item) != NONE)) | |
119 | - | then throw("an item is already exist") | |
120 | - | else if ((supplierWhiteList == BLACKLISTED)) | |
121 | - | then throw("supplier's account has been blacklisted") | |
122 | - | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]) | |
14 | + | func setStatus (supplier,status) = { | |
15 | + | let account = toBase58String(i.caller.bytes) | |
16 | + | if ((account != verifier)) | |
17 | + | then throw("only oracle verifier are able to manage whitelist") | |
18 | + | else if (if ((status != VERIFIED)) | |
19 | + | then (status != BLACKLISTED) | |
20 | + | else false) | |
21 | + | then throw("wrong status") | |
22 | + | else WriteSet([DataEntry(getExtValueItemWhiteListStatus(supplier), status)]) | |
123 | 23 | } | |
124 | 24 | ||
125 | 25 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let NONE = "none" | |
5 | - | ||
6 | - | func getNumberByKey (key) = { | |
7 | - | let num = match getInteger(this, key) { | |
8 | - | case a: Int => | |
9 | - | a | |
10 | - | case _ => | |
11 | - | 0 | |
12 | - | } | |
13 | - | num | |
14 | - | } | |
15 | - | ||
16 | - | ||
17 | - | func getStrByKey (key) = { | |
18 | - | let str = match getString(this, key) { | |
19 | - | case a: String => | |
20 | - | a | |
21 | - | case _ => | |
22 | - | NONE | |
23 | - | } | |
24 | - | str | |
25 | - | } | |
26 | - | ||
27 | - | ||
28 | - | func getKeyItemPrice (item) = (item + "_price") | |
29 | - | ||
30 | - | ||
31 | - | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | - | ||
33 | - | ||
34 | - | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | - | ||
36 | - | ||
37 | - | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(item, item)) | |
38 | - | ||
39 | - | ||
40 | - | func getKeyItem (supplier,titlle) = ("item_" + toBase58String(sha256(toBytes((supplier + titlle))))) | |
41 | - | ||
42 | - | ||
43 | - | func getKeyItemData (item) = (item + "_data") | |
44 | - | ||
45 | - | ||
46 | - | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | - | ||
48 | - | ||
49 | - | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | - | ||
51 | - | ||
52 | - | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | - | ||
54 | - | ||
55 | - | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | - | ||
57 | - | ||
58 | - | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
59 | - | ||
60 | - | ||
61 | - | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
62 | - | ||
63 | - | ||
64 | - | func getKeyCommitsCount (item) = (item + "_comcnt") | |
65 | - | ||
66 | - | ||
67 | - | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
68 | - | ||
69 | - | ||
70 | - | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
71 | - | ||
72 | - | ||
73 | - | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
74 | - | ||
75 | - | ||
76 | - | func getKeyItemStatus (item) = (item + "_status") | |
77 | - | ||
78 | - | ||
79 | - | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
80 | - | ||
81 | - | ||
82 | - | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
83 | - | ||
84 | - | ||
85 | - | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
86 | - | ||
87 | - | ||
88 | - | func getExtAddressOracle () = extract(addressFromString("3Mt9c5k87x7P3bMwSf5qSkjfFQQpL3hSkAM")) | |
89 | - | ||
90 | - | ||
91 | - | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
92 | - | ||
93 | - | ||
94 | - | func getExtValueItemWhiteListStatus (oracle,account) = { | |
95 | - | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
96 | - | case a: String => | |
97 | - | a | |
98 | - | case _ => | |
99 | - | NONE | |
100 | - | } | |
101 | - | str | |
102 | - | } | |
4 | + | func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status") | |
103 | 5 | ||
104 | 6 | ||
105 | 7 | let verifier = "3Mt9c5k87x7P3bMwSf5qSkjfFQQpL3hSkAM" | |
106 | 8 | ||
107 | 9 | let VERIFIED = "verified" | |
108 | 10 | ||
109 | 11 | let BLACKLISTED = "blacklist" | |
110 | 12 | ||
111 | 13 | @Callable(i) | |
112 | - | func addItem (title,price,data) = { | |
113 | - | let supplierAddress = toBase58String(i.caller.bytes) | |
114 | - | let item = getKeyItem(supplierAddress, title) | |
115 | - | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
116 | - | if ((0 >= price)) | |
117 | - | then throw("purchase amount cannot be lett than item price") | |
118 | - | else if ((getValueItemSupplier(item) != NONE)) | |
119 | - | then throw("an item is already exist") | |
120 | - | else if ((supplierWhiteList == BLACKLISTED)) | |
121 | - | then throw("supplier's account has been blacklisted") | |
122 | - | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)]) | |
14 | + | func setStatus (supplier,status) = { | |
15 | + | let account = toBase58String(i.caller.bytes) | |
16 | + | if ((account != verifier)) | |
17 | + | then throw("only oracle verifier are able to manage whitelist") | |
18 | + | else if (if ((status != VERIFIED)) | |
19 | + | then (status != BLACKLISTED) | |
20 | + | else false) | |
21 | + | then throw("wrong status") | |
22 | + | else WriteSet([DataEntry(getExtValueItemWhiteListStatus(supplier), status)]) | |
123 | 23 | } | |
124 | 24 | ||
125 | 25 |
github/deemru/w8io/026f985 36.87 ms ◑