tx · CqurD1t5fXia3gNo2VhjzjyRjoRaN8qaoUJ9jmfq51eb 3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c: -0.01000000 Waves 2021.07.07 13:53 [1603094] smart account 3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c > SELF 0.00000000 Waves
{ "type": 13, "id": "CqurD1t5fXia3gNo2VhjzjyRjoRaN8qaoUJ9jmfq51eb", "fee": 1000000, "feeAssetId": null, "timestamp": 1625655211206, "version": 2, "chainId": 84, "sender": "3MxS2LBsPnEGA6AetWPqWTZjmQu8zUySd2c", "senderPublicKey": "9dJbLdKrkcPAEacPHvgivaqbGgimy4WN2MRrE6XXWFQu", "proofs": [ "WD5mbhucMz4nVnYFRaYyTWZZ9S2Yr5qiEnVxvGUHAoncJUBuT44KPnA4fccr3NQ2QsEDUAqwYVDLwpWcEwLfXYr" ], "script": "base64:AAIFAAAAAAAAAxkIAhIFCgMIAQgSAwoBCBIAEgQKAggIGgoKAmExEgROT05FGhQKAmEyEg5nZXROdW1iZXJCeUtleRoJCgJhMxIDa2V5GgkKAmE0EgNudW0aDQoCYTUSByRtYXRjaDAaBwoCYTYSAWEaEQoCYTcSC2dldFN0ckJ5S2V5GgkKAmE4EgNzdHIaFQoCYTkSD2dldEtleUl0ZW1QcmljZRoKCgJiMRIEaXRlbRoXCgJiMhIRZ2V0VmFsdWVJdGVtUHJpY2UaGwoCYjMSFWdldEtleVVzZXJJdGVtQ291bnRlchoKCgJiNBIEdXNlchodCgJiNRIXZ2V0VmFsdWVVc2VySXRlbUNvdW50ZXIaEAoCYjYSCmdldEtleUl0ZW0aDgoCYjcSCHN1cHBsaWVyGgsKAmI4EgV0aXRsZRoUCgJiORIOZ2V0S2V5SXRlbURhdGEaGAoCYzESEmdldEtleUl0ZW1TdXBwbGllchoaCgJjMhIUZ2V0VmFsdWVJdGVtU3VwcGxpZXIaGwoCYzMSFWdldEtleUJhbGFuY2VTdXBwbGllchoNCgJjNBIHYWNjb3VudBodCgJ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AQAAAAIhPQAAAAIFAAAAAmU2BQAAAAJjNwcJAAACAAAAAQIAAAACYjMJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAAmM5AAAAAgUAAAACYjEFAAAAAmI0BQAAAAJlNAkABEwAAAACCQEAAAAMSW50ZWdlckVudHJ5AAAAAgkBAAAAAmQyAAAAAQUAAAACYjEJAABkAAAAAgUAAAACZTUAAAAAAAAAAAEJAARMAAAAAgkBAAAAC1N0cmluZ0VudHJ5AAAAAgkBAAAAAmQ0AAAAAQUAAAACYjEDCQAAAAAAAAIFAAAAAmU1BQAAAAJjNgUAAAACYzgFAAAAAmM3BQAAAANuaWwAAAAAi5WyIQ==", "height": 1603094, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: DaK6zVzuZ5sb2buBKj1q6LgKmeJi5C8SGQSqF6UdE13a Next: 61U3aAp2SgVJPoUPDTmsTjZfoEQn8Y9ZzV1NCwxTWJoc Diff:
Old | New | Differences | |
---|---|---|---|
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | + | let VOTERS = 3 | |
59 | + | ||
60 | + | let VOTING = "voting" | |
61 | + | ||
62 | + | let REVEAL = "reveal" | |
63 | + | ||
64 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
65 | + | ||
66 | + | ||
67 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
71 | + | ||
72 | + | ||
73 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
74 | + | ||
75 | + | ||
76 | + | func getKeyItemStatus (item) = (item + "_status") | |
77 | + | ||
78 | + | ||
79 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
80 | + | ||
81 | + | ||
58 | 82 | @Callable(i) | |
59 | 83 | func addItem (title,price,data) = { | |
60 | 84 | let supplierAddress = toBase58String(i.caller.bytes) | |
97 | 121 | } | |
98 | 122 | ||
99 | 123 | ||
124 | + | ||
125 | + | @Callable(i) | |
126 | + | func voteCommit (item,hash) = { | |
127 | + | let user = toBase58String(i.caller.bytes) | |
128 | + | let commits = getValueCommitsCount(item) | |
129 | + | let status = getValueItemStatus(item) | |
130 | + | if ((commits >= VOTERS)) | |
131 | + | then throw("Reached max num of voters") | |
132 | + | else if ((getValueCommit(item, user) != NONE)) | |
133 | + | then throw("b1") | |
134 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
135 | + | then throw("b2") | |
136 | + | else if (if ((status != NONE)) | |
137 | + | then (status != VOTING) | |
138 | + | else false) | |
139 | + | then throw("b3") | |
140 | + | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
141 | + | then REVEAL | |
142 | + | else VOTING)] | |
143 | + | } | |
144 | + | ||
145 | + |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let NONE = "none" | |
5 | 5 | ||
6 | 6 | func getNumberByKey (key) = { | |
7 | 7 | let num = match getInteger(this, key) { | |
8 | 8 | case a: Int => | |
9 | 9 | a | |
10 | 10 | case _ => | |
11 | 11 | 0 | |
12 | 12 | } | |
13 | 13 | num | |
14 | 14 | } | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func getStrByKey (key) = { | |
18 | 18 | let str = match getString(this, key) { | |
19 | 19 | case a: String => | |
20 | 20 | a | |
21 | 21 | case _ => | |
22 | 22 | NONE | |
23 | 23 | } | |
24 | 24 | str | |
25 | 25 | } | |
26 | 26 | ||
27 | 27 | ||
28 | 28 | func getKeyItemPrice (item) = (item + "_price") | |
29 | 29 | ||
30 | 30 | ||
31 | 31 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
32 | 32 | ||
33 | 33 | ||
34 | 34 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
35 | 35 | ||
36 | 36 | ||
37 | 37 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func getKeyItemData (item) = (item + "_data") | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func getKeyItemSupplier (item) = (item + "_owner") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
56 | 56 | ||
57 | 57 | ||
58 | + | let VOTERS = 3 | |
59 | + | ||
60 | + | let VOTING = "voting" | |
61 | + | ||
62 | + | let REVEAL = "reveal" | |
63 | + | ||
64 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
65 | + | ||
66 | + | ||
67 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
68 | + | ||
69 | + | ||
70 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
71 | + | ||
72 | + | ||
73 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
74 | + | ||
75 | + | ||
76 | + | func getKeyItemStatus (item) = (item + "_status") | |
77 | + | ||
78 | + | ||
79 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
80 | + | ||
81 | + | ||
58 | 82 | @Callable(i) | |
59 | 83 | func addItem (title,price,data) = { | |
60 | 84 | let supplierAddress = toBase58String(i.caller.bytes) | |
61 | 85 | let item = getKeyItem(supplierAddress, title) | |
62 | 86 | if ((0 >= price)) | |
63 | 87 | then throw("Purchase amount cannot be less than item price") | |
64 | 88 | else if ((getValueItemSupplier(item) != NONE)) | |
65 | 89 | then throw("an item already exists") | |
66 | 90 | else [StringEntry(getKeyItemSupplier(item), supplierAddress), IntegerEntry(getKeyItemPrice(item), price), StringEntry(getKeyItemData(item), data)] | |
67 | 91 | } | |
68 | 92 | ||
69 | 93 | ||
70 | 94 | ||
71 | 95 | @Callable(i) | |
72 | 96 | func purchase (item) = { | |
73 | 97 | let pmt = i.payments[0] | |
74 | 98 | if (isDefined(pmt.assetId)) | |
75 | 99 | then throw("WAVES ONLY HHEUAWHEUAS") | |
76 | 100 | else { | |
77 | 101 | let userAddress = toBase58String(i.caller.bytes) | |
78 | 102 | let price = getValueItemPrice(item) | |
79 | 103 | let supplierAddress = getValueItemSupplier(item) | |
80 | 104 | if ((price > pmt.amount)) | |
81 | 105 | then throw("Purchase amount cannot be less than item price") | |
82 | 106 | else if ((supplierAddress == NONE)) | |
83 | 107 | then throw("Supplier does not exist") | |
84 | 108 | else [IntegerEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), IntegerEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))] | |
85 | 109 | } | |
86 | 110 | } | |
87 | 111 | ||
88 | 112 | ||
89 | 113 | ||
90 | 114 | @Callable(i) | |
91 | 115 | func withdraw () = { | |
92 | 116 | let supplierAddress = toBase58String(i.caller.bytes) | |
93 | 117 | let balance = getValueBalanceSupplier(supplierAddress) | |
94 | 118 | if ((0 >= balance)) | |
95 | 119 | then throw("insuficient balance") | |
96 | 120 | else [IntegerEntry(getKeyBalanceSupplier(supplierAddress), 0), ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)] | |
97 | 121 | } | |
98 | 122 | ||
99 | 123 | ||
124 | + | ||
125 | + | @Callable(i) | |
126 | + | func voteCommit (item,hash) = { | |
127 | + | let user = toBase58String(i.caller.bytes) | |
128 | + | let commits = getValueCommitsCount(item) | |
129 | + | let status = getValueItemStatus(item) | |
130 | + | if ((commits >= VOTERS)) | |
131 | + | then throw("Reached max num of voters") | |
132 | + | else if ((getValueCommit(item, user) != NONE)) | |
133 | + | then throw("b1") | |
134 | + | else if ((getKeyItemSupplier(item) == NONE)) | |
135 | + | then throw("b2") | |
136 | + | else if (if ((status != NONE)) | |
137 | + | then (status != VOTING) | |
138 | + | else false) | |
139 | + | then throw("b3") | |
140 | + | else [StringEntry(getKeyCommit(item, user), hash), IntegerEntry(getKeyCommitsCount(item), (commits + 1)), StringEntry(getKeyItemStatus(item), if ((commits == VOTERS)) | |
141 | + | then REVEAL | |
142 | + | else VOTING)] | |
143 | + | } | |
144 | + | ||
145 | + |
github/deemru/w8io/026f985 41.05 ms ◑