tx · 2pEjguuGxQdqBDVEechtoriexTA9GyxRicXcRvxfXDJt 3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP: -0.01400000 Waves 2019.07.12 08:30 [582083] smart account 3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP > SELF 0.00000000 Waves
{ "type": 13, "id": "2pEjguuGxQdqBDVEechtoriexTA9GyxRicXcRvxfXDJt", "fee": 1400000, "feeAssetId": null, "timestamp": 1562909408826, "version": 1, "sender": "3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP", "senderPublicKey": "EghK1ndUequAR8FfFYnK6itzJoz6XBXuBwJ9R2NBtRS4", "proofs": [ "47UR6XnC98e56rrAxHY4sAawz1NqbJ1sa5qNnTtM1emfZGhPtxptpcXBGZQGHAHB3BvYsrmPjKagxn3Pe3LREsxg" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAAthbGljZVB1YktleQEAAAAgOITRcCoKNTKqAsbsI7JcjEyc+1VR5mMOpsGoUi0JKjkAAAAACWJvYlB1YktleQEAAAAgOPBOW6N2bmWmpMd/LMXIwkA2OIUQhWJH019Pc7tgpSMAAAAADGNvb3BlclB1YktleQEAAAAgy1MpMZp8+4hN9rmZPzVtqBXPXqzIJa0q68vtAj5jLAUAAAAAC290aGVyUHViS2V5AQAAACCcUW8jVT9kpF19g4OlKJR98WVU6DO1nDSGe47M+HtjPwAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIF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cmFuc2FjdGlvbgQAAAABdAUAAAAHJG1hdGNoMAMDAwUAAAACQWwGBQAAAAJCbwYFAAAAAkNvBgUAAAACT3QDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAEElzc3VlVHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDADAwMFAAAAAkFsBgUAAAACQm8GBQAAAAJDbwYFAAAAAk90AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABJSZWlzc3VlVHJhbnNhY3Rpb24EAAAAAXQFAAAAByRtYXRjaDADAwMFAAAAAkFsBgUAAAACQm8GBQAAAAJDbwYFAAAAAk90AwMDAwMDBQAAAAJBbAUAAAACQm8HBgMFAAAAAkFsBQAAAAJDbwcGAwUAAAACQm8FAAAAAkNvBwYDBQAAAAJBbAUAAAACT3QHBgMFAAAAAkJvBQAAAAJPdAcGAwUAAAACQ28FAAAAAk90B/FkBEg=", "chainId": 84, "height": 582083, "spentComplexity": 0 } View: original | compacted Prev: CoQ8oyvoWHxTRqpaRUnTkkbJ9JwsVZQ28iC6v2r1HV2n Next: none Diff:
Old | New | Differences | |
---|---|---|---|
9 | 9 | ||
10 | 10 | let otherPubKey = base58'BXCd46i2Pdzu8csVsX2nknDP9D1phC4sa1anNpDHJAog' | |
11 | 11 | ||
12 | - | func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status") | |
12 | + | let NONE = "none" | |
13 | + | ||
14 | + | func getNumberByKey (key) = { | |
15 | + | let num = match getInteger(this, key) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | num | |
22 | + | } | |
13 | 23 | ||
14 | 24 | ||
15 | - | let verifier = base58'3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP' | |
25 | + | func getStrByKey (key) = { | |
26 | + | let str = match getString(this, key) { | |
27 | + | case a: String => | |
28 | + | a | |
29 | + | case _ => | |
30 | + | NONE | |
31 | + | } | |
32 | + | str | |
33 | + | } | |
34 | + | ||
35 | + | ||
36 | + | func getKeyItemPrice (item) = (item + "_price") | |
37 | + | ||
38 | + | ||
39 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
40 | + | ||
41 | + | ||
42 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
43 | + | ||
44 | + | ||
45 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
46 | + | ||
47 | + | ||
48 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
49 | + | ||
50 | + | ||
51 | + | func getKeyItemData (item) = (item + "_data") | |
52 | + | ||
53 | + | ||
54 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
55 | + | ||
56 | + | ||
57 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
58 | + | ||
59 | + | ||
60 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
61 | + | ||
62 | + | ||
63 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
64 | + | ||
65 | + | ||
66 | + | let verifier = "3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP" | |
16 | 67 | ||
17 | 68 | let VERIFIED = "verified" | |
18 | 69 | ||
19 | 70 | let BLACKLISTED = "blacklist" | |
20 | 71 | ||
72 | + | func getExtAddressOracle () = extract(addressFromString("3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP")) | |
73 | + | ||
74 | + | ||
75 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
76 | + | ||
77 | + | ||
78 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
79 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
80 | + | case a: String => | |
81 | + | account | |
82 | + | case _ => | |
83 | + | NONE | |
84 | + | } | |
85 | + | str | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | @Callable(i) | |
90 | + | func addItem (title,price,data) = { | |
91 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
92 | + | let item = getKeyItem(supplierAddress, title) | |
93 | + | let supplierwhitelist = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
94 | + | if ((0 >= price)) | |
95 | + | then throw("purchase amount cannot be less than item price") | |
96 | + | else if ((getValueItemSupplier(item) != NONE)) | |
97 | + | then throw("an item is already exist") | |
98 | + | else if ((supplierwhitelist == BLACKLISTED)) | |
99 | + | then throw("supplier's account has been blacklisted") | |
100 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierwhitelist)]) | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | ||
21 | 105 | @Callable(i) | |
22 | 106 | func setstatus (supplier,status) = { | |
23 | - | let account = i.caller.bytes | |
107 | + | let account = toBase58String(i.caller.bytes) | |
24 | 108 | if ((account != verifier)) | |
25 | 109 | then throw("only oracle veryfier are able to manage whitelist") | |
26 | 110 | else if (if ((status != VERIFIED)) | |
27 | 111 | then (status != BLACKLISTED) | |
28 | 112 | else false) | |
29 | 113 | then throw("wrong status") | |
30 | - | else WriteSet([DataEntry( | |
114 | + | else WriteSet([DataEntry(getExtKeyItemWhiteListStatus(supplier), status)]) | |
31 | 115 | } | |
32 | 116 | ||
33 | 117 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let alicePubKey = base58'4odJB3xcaswGibZ1oQ7C9VNoBjtXMsWKexoo35zjBWUx' | |
5 | 5 | ||
6 | 6 | let bobPubKey = base58'4qGMpfFhpc2L1VGrBe5tQFxCWsdYiYttdC9ZmHYJn2Lz' | |
7 | 7 | ||
8 | 8 | let cooperPubKey = base58'EghK1ndUequAR8FfFYnK6itzJoz6XBXuBwJ9R2NBtRS4' | |
9 | 9 | ||
10 | 10 | let otherPubKey = base58'BXCd46i2Pdzu8csVsX2nknDP9D1phC4sa1anNpDHJAog' | |
11 | 11 | ||
12 | - | func getExtValueItemWhiteListStatus (item) = (item + "_verifier_status") | |
12 | + | let NONE = "none" | |
13 | + | ||
14 | + | func getNumberByKey (key) = { | |
15 | + | let num = match getInteger(this, key) { | |
16 | + | case a: Int => | |
17 | + | a | |
18 | + | case _ => | |
19 | + | 0 | |
20 | + | } | |
21 | + | num | |
22 | + | } | |
13 | 23 | ||
14 | 24 | ||
15 | - | let verifier = base58'3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP' | |
25 | + | func getStrByKey (key) = { | |
26 | + | let str = match getString(this, key) { | |
27 | + | case a: String => | |
28 | + | a | |
29 | + | case _ => | |
30 | + | NONE | |
31 | + | } | |
32 | + | str | |
33 | + | } | |
34 | + | ||
35 | + | ||
36 | + | func getKeyItemPrice (item) = (item + "_price") | |
37 | + | ||
38 | + | ||
39 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
40 | + | ||
41 | + | ||
42 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
43 | + | ||
44 | + | ||
45 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
46 | + | ||
47 | + | ||
48 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
49 | + | ||
50 | + | ||
51 | + | func getKeyItemData (item) = (item + "_data") | |
52 | + | ||
53 | + | ||
54 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
55 | + | ||
56 | + | ||
57 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
58 | + | ||
59 | + | ||
60 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
61 | + | ||
62 | + | ||
63 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
64 | + | ||
65 | + | ||
66 | + | let verifier = "3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP" | |
16 | 67 | ||
17 | 68 | let VERIFIED = "verified" | |
18 | 69 | ||
19 | 70 | let BLACKLISTED = "blacklist" | |
20 | 71 | ||
72 | + | func getExtAddressOracle () = extract(addressFromString("3N2kYSm5NHgsVYByuqsHEuJj3B174iw7ikP")) | |
73 | + | ||
74 | + | ||
75 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
76 | + | ||
77 | + | ||
78 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
79 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
80 | + | case a: String => | |
81 | + | account | |
82 | + | case _ => | |
83 | + | NONE | |
84 | + | } | |
85 | + | str | |
86 | + | } | |
87 | + | ||
88 | + | ||
89 | + | @Callable(i) | |
90 | + | func addItem (title,price,data) = { | |
91 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
92 | + | let item = getKeyItem(supplierAddress, title) | |
93 | + | let supplierwhitelist = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
94 | + | if ((0 >= price)) | |
95 | + | then throw("purchase amount cannot be less than item price") | |
96 | + | else if ((getValueItemSupplier(item) != NONE)) | |
97 | + | then throw("an item is already exist") | |
98 | + | else if ((supplierwhitelist == BLACKLISTED)) | |
99 | + | then throw("supplier's account has been blacklisted") | |
100 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data), DataEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierwhitelist)]) | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | ||
21 | 105 | @Callable(i) | |
22 | 106 | func setstatus (supplier,status) = { | |
23 | - | let account = i.caller.bytes | |
107 | + | let account = toBase58String(i.caller.bytes) | |
24 | 108 | if ((account != verifier)) | |
25 | 109 | then throw("only oracle veryfier are able to manage whitelist") | |
26 | 110 | else if (if ((status != VERIFIED)) | |
27 | 111 | then (status != BLACKLISTED) | |
28 | 112 | else false) | |
29 | 113 | then throw("wrong status") | |
30 | - | else WriteSet([DataEntry( | |
114 | + | else WriteSet([DataEntry(getExtKeyItemWhiteListStatus(supplier), status)]) | |
31 | 115 | } | |
32 | 116 | ||
33 | 117 | ||
34 | 118 | @Verifier(tx) | |
35 | 119 | func verify () = { | |
36 | 120 | let Al = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], alicePubKey)) | |
37 | 121 | then true | |
38 | 122 | else sigVerify(tx.bodyBytes, tx.proofs[1], alicePubKey)) | |
39 | 123 | then true | |
40 | 124 | else sigVerify(tx.bodyBytes, tx.proofs[0], alicePubKey) | |
41 | 125 | let Bo = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], bobPubKey)) | |
42 | 126 | then true | |
43 | 127 | else sigVerify(tx.bodyBytes, tx.proofs[1], bobPubKey)) | |
44 | 128 | then true | |
45 | 129 | else sigVerify(tx.bodyBytes, tx.proofs[2], bobPubKey) | |
46 | 130 | let Co = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], cooperPubKey)) | |
47 | 131 | then true | |
48 | 132 | else sigVerify(tx.bodyBytes, tx.proofs[1], cooperPubKey)) | |
49 | 133 | then true | |
50 | 134 | else sigVerify(tx.bodyBytes, tx.proofs[2], cooperPubKey) | |
51 | 135 | let Ot = if (if (sigVerify(tx.bodyBytes, tx.proofs[0], otherPubKey)) | |
52 | 136 | then true | |
53 | 137 | else sigVerify(tx.bodyBytes, tx.proofs[1], otherPubKey)) | |
54 | 138 | then true | |
55 | 139 | else sigVerify(tx.bodyBytes, tx.proofs[2], otherPubKey) | |
56 | 140 | match tx { | |
57 | 141 | case t: SetScriptTransaction => | |
58 | 142 | if (if (Al) | |
59 | 143 | then true | |
60 | 144 | else Bo) | |
61 | 145 | then true | |
62 | 146 | else Co | |
63 | 147 | case t: InvokeScriptTransaction => | |
64 | 148 | if (if (if (Al) | |
65 | 149 | then true | |
66 | 150 | else Bo) | |
67 | 151 | then true | |
68 | 152 | else Co) | |
69 | 153 | then true | |
70 | 154 | else Ot | |
71 | 155 | case t: IssueTransaction => | |
72 | 156 | if (if (if (Al) | |
73 | 157 | then true | |
74 | 158 | else Bo) | |
75 | 159 | then true | |
76 | 160 | else Co) | |
77 | 161 | then true | |
78 | 162 | else Ot | |
79 | 163 | case t: ReissueTransaction => | |
80 | 164 | if (if (if (Al) | |
81 | 165 | then true | |
82 | 166 | else Bo) | |
83 | 167 | then true | |
84 | 168 | else Co) | |
85 | 169 | then true | |
86 | 170 | else Ot | |
87 | 171 | case _ => | |
88 | 172 | if (if (if (if (if (if (Al) | |
89 | 173 | then Bo | |
90 | 174 | else false) | |
91 | 175 | then true | |
92 | 176 | else if (Al) | |
93 | 177 | then Co | |
94 | 178 | else false) | |
95 | 179 | then true | |
96 | 180 | else if (Bo) | |
97 | 181 | then Co | |
98 | 182 | else false) | |
99 | 183 | then true | |
100 | 184 | else if (Al) | |
101 | 185 | then Ot | |
102 | 186 | else false) | |
103 | 187 | then true | |
104 | 188 | else if (Bo) | |
105 | 189 | then Ot | |
106 | 190 | else false) | |
107 | 191 | then true | |
108 | 192 | else if (Co) | |
109 | 193 | then Ot | |
110 | 194 | else false | |
111 | 195 | } | |
112 | 196 | } | |
113 | 197 |
github/deemru/w8io/026f985 23.63 ms ◑