tx · 6iyXwgRm5W8Gs5W3BMG8yfH3SB5zYN1eJgtsEDrzuz7 3MsnLmoWumwnF6A4KUTazQYhog3PHMFB1L4: -0.01000000 Waves 2021.07.21 14:11 [1623302] smart account 3MsnLmoWumwnF6A4KUTazQYhog3PHMFB1L4 > SELF 0.00000000 Waves
{ "type": 13, "id": "6iyXwgRm5W8Gs5W3BMG8yfH3SB5zYN1eJgtsEDrzuz7", "fee": 1000000, "feeAssetId": null, "timestamp": 1626865940634, "version": 2, "chainId": 84, "sender": "3MsnLmoWumwnF6A4KUTazQYhog3PHMFB1L4", "senderPublicKey": "G54GaYVNzziNELjk1bcshrmw9dsj7MuP7Y3vBkYhYfBV", "proofs": [ "LCTkumrpcD3SiqCvg4MQghM96Ja8Ko8oTxgrYe4UwCq9ye1QbMeWuzwXhNQ6A5N11w1WgravB47PxGKt7uDeuji" ], "script": "base64:AAIFAAAAAAAAABAIAhIFCgMIAQgSBQoDCAgIAAAAHAAAAAAETk9ORQIAAAAEbm9uZQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABAAAAA2tleQQAAAADbnVtBAAAAAckbWF0Y2gwCQAEGgAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAADSW50BAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhAAAAAAAAAAAABQAAAANudW0BAAAAC2dldFN0ckJ5S2V5AAAAAQAAAANrZXkEAAAAA3N0cgQAAAAHJG1hdGNoMAkABB0AAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABlN0cmluZwQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQUAAAAETk9ORQUAAAADc3RyAQAAAA9nZXRLZXlJdGVtUHJpY2UAAAABAAAABGl0ZW0JAAEsAAAAAgUAAAAEaXRlbQIAAAAGX3ByaWNlAQAAAApnZXRLZXlJdGVtAAAAAgAAAAhzdXBwbGllcgAAAAV0aXRsZQkAASwAAAACAgA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AAECAAAAHXVzZXIgaGFzIGFscmVhZHkgcGFydGljaXBhdGVkAwMJAQAAAAIhPQAAAAIFAAAABnN0YXR1cwUAAAAGVk9USU5HCQEAAAACIT0AAAACBQAAAAZzdGF0dXMFAAAABlJFVkVBTAcJAAACAAAAAQIAAAAMd3Jvbmcgc3RhdHVzAwMJAQAAAAIhPQAAAAIFAAAABHZvdGUFAAAACEZFQVRVUkVECQEAAAACIT0AAAACBQAAAAR2b3RlBQAAAAhERUxJU1RFRAcJAAACAAAAAQIAAAAKd3Jvbmcgdm90ZQMDCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIRkVBVFVSRUQGCQAAAAAAAAIFAAAABnN0YXR1cwUAAAAIREVMSVNURUQJAAACAAAAAQIAAAARdm90ZSBoYXMgZmluaXNoZWQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAADGdldEtleVJldmVhbAAAAAIFAAAABGl0ZW0FAAAABHVzZXIFAAAABHZvdGUJAARMAAAAAgkBAAAADEludGVnZXJFbnRyeQAAAAIJAQAAAA9nZXRLZXlWb3RlQ291bnQAAAACBQAAAARpdGVtBQAAAAR2b3RlBQAAAAxuZXdWb3RlQ291bnQJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAEGdldEtleUl0ZW1TdGF0dXMAAAABBQAAAARpdGVtAwkAAGcAAAACBQAAAAxuZXdWb3RlQ291bnQFAAAABlFVT1JVTQUAAAAEdm90ZQUAAAAGUkVWRUFMBQAAAANuaWwAAAAAFG0x2g==", "height": 1623302, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: none Next: none Full:
Old | New | Differences | |
---|---|---|---|
1 | - | # no script | |
1 | + | {-# STDLIB_VERSION 5 #-} | |
2 | + | {-# SCRIPT_TYPE ACCOUNT #-} | |
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 getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
32 | + | ||
33 | + | ||
34 | + | func getKeyItemData (item) = (item + "_data") | |
35 | + | ||
36 | + | ||
37 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
38 | + | ||
39 | + | ||
40 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
41 | + | ||
42 | + | ||
43 | + | let VOTERS = 3 | |
44 | + | ||
45 | + | let QUORUM = 2 | |
46 | + | ||
47 | + | let VOTING = "voting" | |
48 | + | ||
49 | + | let REVEAL = "reveal" | |
50 | + | ||
51 | + | let FEATURED = "featured" | |
52 | + | ||
53 | + | let DELISTED = "delisted" | |
54 | + | ||
55 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
56 | + | ||
57 | + | ||
58 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
59 | + | ||
60 | + | ||
61 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
62 | + | ||
63 | + | ||
64 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
65 | + | ||
66 | + | ||
67 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
68 | + | ||
69 | + | ||
70 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
71 | + | ||
72 | + | ||
73 | + | func getKeyItemStatus (item) = (item + "_status") | |
74 | + | ||
75 | + | ||
76 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
77 | + | ||
78 | + | ||
79 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
80 | + | ||
81 | + | ||
82 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
83 | + | ||
84 | + | ||
85 | + | func getExtAddressOracle () = value(addressFromString("3MsbiyFyy8B3aN3kF8ntda474SPn4YMVkiq")) | |
86 | + | ||
87 | + | ||
88 | + | let BLACKLISTED = "blacklist" | |
89 | + | ||
90 | + | func getExtKeyItemWhiteListStatus (account) = (account + "_verifier_status") | |
91 | + | ||
92 | + | ||
93 | + | func getExtValueItemWhiteListStatus (oracle,account) = { | |
94 | + | let str = match getString(oracle, getExtKeyItemWhiteListStatus(account)) { | |
95 | + | case a: String => | |
96 | + | a | |
97 | + | case _ => | |
98 | + | NONE | |
99 | + | } | |
100 | + | str | |
101 | + | } | |
102 | + | ||
103 | + | ||
104 | + | @Callable(i) | |
105 | + | func addItem (title,price,data) = { | |
106 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
107 | + | let item = getKeyItem(supplierAddress, title) | |
108 | + | let supplierWhiteList = getExtValueItemWhiteListStatus(getExtAddressOracle(), supplierAddress) | |
109 | + | if ((0 >= price)) | |
110 | + | then throw("Purchase amount cannot be less than item price") | |
111 | + | else if ((getValueItemSupplier(item) != NONE)) | |
112 | + | then throw("an item already exists") | |
113 | + | else if ((supplierWhiteList == BLACKLISTED)) | |
114 | + | then throw("supplier's account has been blacklisted") | |
115 | + | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data), StringEntry(getExtKeyItemWhiteListStatus(supplierAddress), supplierWhiteList)] | |
116 | + | } | |
117 | + | ||
118 | + | ||
119 | + | ||
120 | + | @Callable(i) | |
121 | + | func voteReveal (item,vote,salt) = { | |
122 | + | let user = toBase58String(i.caller.bytes) | |
123 | + | let status = getValueItemStatus(item) | |
124 | + | let newVoteCount = (getValueVoteCount(item, vote) + 1) | |
125 | + | if ((toBase58String(sha256(toBytes((vote + salt)))) != getValueCommit(item, user))) | |
126 | + | then throw("Reveal data is not valid") | |
127 | + | else if ((VOTERS > getValueCommitsCount(item))) | |
128 | + | then throw("max num of voters hasnt reached yet") | |
129 | + | else if ((getValueReveal(item, user) != NONE)) | |
130 | + | then throw("user has already participated") | |
131 | + | else if (if ((status != VOTING)) | |
132 | + | then (status != REVEAL) | |
133 | + | else false) | |
134 | + | then throw("wrong status") | |
135 | + | else if (if ((vote != FEATURED)) | |
136 | + | then (vote != DELISTED) | |
137 | + | else false) | |
138 | + | then throw("wrong vote") | |
139 | + | else if (if ((status == FEATURED)) | |
140 | + | then true | |
141 | + | else (status == DELISTED)) | |
142 | + | then throw("vote has finished") | |
143 | + | else [StringEntry(getKeyReveal(item, user), vote), IntegerEntry(getKeyVoteCount(item, vote), newVoteCount), StringEntry(getKeyItemStatus(item), if ((newVoteCount >= QUORUM)) | |
144 | + | then vote | |
145 | + | else REVEAL)] | |
146 | + | } | |
147 | + | ||
148 | + |
github/deemru/w8io/169f3d6 18.64 ms ◑