tx · A112PUstuUFk6AZBXzvqiAPqYjPdJdosZ63qvimexPF7 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR: -0.01400000 Waves 2019.07.14 04:09 [584737] smart account 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR > SELF 0.00000000 Waves
{ "type": 13, "id": "A112PUstuUFk6AZBXzvqiAPqYjPdJdosZ63qvimexPF7", "fee": 1400000, "feeAssetId": null, "timestamp": 1563066654089, "version": 1, "sender": "3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR", "senderPublicKey": "Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV", "proofs": [ "JDgqSGAEK9pb78gN1cDhPZHGSf2uWPYpp5jx6GaU3WuSA4hAYnjqvhLgCHW5uautyUzptmkiD1SPSXsde9RS6H5" ], "script": "base64:AAIDAAAAAAAAAAAAAAAeAAAAAA5vd25lclB1YmxpY0tleQEAAAAgAnfP9tCFuj2k2BUY5PW9DVGxrCHBHKJwugv8WyiaGXIAAAAABE5PTkUCAAAABG5vbmUAAAAABlZPVEVSUwAAAAAAAAAAAwAAAAAGUVVPUlVNAAAAAAAAAAACAAAAAAZWT1RJTkcCAAAABnZvdGluZwAAAAAGUkVWRUFMAgAAAAZyZXZlYWwAAAAACEZFQVRVUkVEAgAAAAhmZWF0dXJlZAAAAAAIREVMSVNURUQCAAAACGRlbGlzdGVkAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hd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m9vZnMAAAAAAAAAAAAFAAAADm93bmVyUHVibGljS2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAA9EYXRhVHJhbnNhY3Rpb24EAAAAAWQFAAAAByRtYXRjaDAGAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAABNUcmFuc2ZlclRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgeYrMVo", "chainId": 84, "height": 584737, "spentComplexity": 0 } View: original | compacted Prev: 894iPjxFqLcpYsmtd9R8mtGehzij8DQbRaKRQFUjnSr2 Next: GYnxM71YvMp6wtjcJX9KgVWNT4jdQUBBf6zVSZ5XRAsT Diff:
Old | New | Differences | |
---|---|---|---|
4 | 4 | let ownerPublicKey = base58'Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV' | |
5 | 5 | ||
6 | 6 | let NONE = "none" | |
7 | + | ||
8 | + | let VOTERS = 3 | |
9 | + | ||
10 | + | let QUORUM = 2 | |
11 | + | ||
12 | + | let VOTING = "voting" | |
13 | + | ||
14 | + | let REVEAL = "reveal" | |
15 | + | ||
16 | + | let FEATURED = "featured" | |
17 | + | ||
18 | + | let DELISTED = "delisted" | |
7 | 19 | ||
8 | 20 | func getNumberByKey (key) = { | |
9 | 21 | let num = match getInteger(this, key) { | |
25 | 37 | } | |
26 | 38 | str | |
27 | 39 | } | |
40 | + | ||
41 | + | ||
42 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
43 | + | ||
44 | + | ||
45 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
46 | + | ||
47 | + | ||
48 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
49 | + | ||
50 | + | ||
51 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
52 | + | ||
53 | + | ||
54 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
55 | + | ||
56 | + | ||
57 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
58 | + | ||
59 | + | ||
60 | + | func getKeyItemStatus (item) = (item + "_status") | |
61 | + | ||
62 | + | ||
63 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
64 | + | ||
65 | + | ||
66 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
67 | + | ||
68 | + | ||
69 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
28 | 70 | ||
29 | 71 | ||
30 | 72 | func getKeyItemPrice (item) = (item + "_price") | |
55 | 97 | ||
56 | 98 | ||
57 | 99 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | - | ||
59 | - | ||
60 | - | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
61 | - | ||
62 | - | ||
63 | - | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
64 | - | ||
65 | - | ||
66 | - | func getKeyCommitsCount (item) = (item + "_comcnt") | |
67 | - | ||
68 | - | ||
69 | - | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
70 | - | ||
71 | - | ||
72 | - | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
73 | - | ||
74 | - | ||
75 | - | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
76 | - | ||
77 | - | ||
78 | - | func getKeyItemStatus (item) = (item + "_status") | |
79 | - | ||
80 | - | ||
81 | - | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
82 | - | ||
83 | - | ||
84 | - | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
85 | 100 | ||
86 | 101 | ||
87 | 102 | @Callable(i) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV' | |
5 | 5 | ||
6 | 6 | let NONE = "none" | |
7 | + | ||
8 | + | let VOTERS = 3 | |
9 | + | ||
10 | + | let QUORUM = 2 | |
11 | + | ||
12 | + | let VOTING = "voting" | |
13 | + | ||
14 | + | let REVEAL = "reveal" | |
15 | + | ||
16 | + | let FEATURED = "featured" | |
17 | + | ||
18 | + | let DELISTED = "delisted" | |
7 | 19 | ||
8 | 20 | func getNumberByKey (key) = { | |
9 | 21 | let num = match getInteger(this, key) { | |
10 | 22 | case a: Int => | |
11 | 23 | a | |
12 | 24 | case _ => | |
13 | 25 | 0 | |
14 | 26 | } | |
15 | 27 | num | |
16 | 28 | } | |
17 | 29 | ||
18 | 30 | ||
19 | 31 | func getStrByKey (key) = { | |
20 | 32 | let str = match getString(this, key) { | |
21 | 33 | case a: String => | |
22 | 34 | a | |
23 | 35 | case _ => | |
24 | 36 | NONE | |
25 | 37 | } | |
26 | 38 | str | |
27 | 39 | } | |
40 | + | ||
41 | + | ||
42 | + | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
43 | + | ||
44 | + | ||
45 | + | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
46 | + | ||
47 | + | ||
48 | + | func getKeyCommitsCount (item) = (item + "_comcnt") | |
49 | + | ||
50 | + | ||
51 | + | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
52 | + | ||
53 | + | ||
54 | + | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
55 | + | ||
56 | + | ||
57 | + | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
58 | + | ||
59 | + | ||
60 | + | func getKeyItemStatus (item) = (item + "_status") | |
61 | + | ||
62 | + | ||
63 | + | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
64 | + | ||
65 | + | ||
66 | + | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
67 | + | ||
68 | + | ||
69 | + | func getValueVoteCount (item,vote) = getNumberByKey(getKeyVoteCount(item, vote)) | |
28 | 70 | ||
29 | 71 | ||
30 | 72 | func getKeyItemPrice (item) = (item + "_price") | |
31 | 73 | ||
32 | 74 | ||
33 | 75 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
34 | 76 | ||
35 | 77 | ||
36 | 78 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
37 | 79 | ||
38 | 80 | ||
39 | 81 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
40 | 82 | ||
41 | 83 | ||
42 | 84 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 85 | ||
44 | 86 | ||
45 | 87 | func getKeyItemData (item) = (item + "_data") | |
46 | 88 | ||
47 | 89 | ||
48 | 90 | func getKeyItemSupplier (item) = (item + "_owner") | |
49 | 91 | ||
50 | 92 | ||
51 | 93 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
52 | 94 | ||
53 | 95 | ||
54 | 96 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
55 | 97 | ||
56 | 98 | ||
57 | 99 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | - | ||
59 | - | ||
60 | - | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
61 | - | ||
62 | - | ||
63 | - | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
64 | - | ||
65 | - | ||
66 | - | func getKeyCommitsCount (item) = (item + "_comcnt") | |
67 | - | ||
68 | - | ||
69 | - | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
70 | - | ||
71 | - | ||
72 | - | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
73 | - | ||
74 | - | ||
75 | - | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
76 | - | ||
77 | - | ||
78 | - | func getKeyItemStatus (item) = (item + "_status") | |
79 | - | ||
80 | - | ||
81 | - | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
82 | - | ||
83 | - | ||
84 | - | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
85 | 100 | ||
86 | 101 | ||
87 | 102 | @Callable(i) | |
88 | 103 | func purchase (item) = { | |
89 | 104 | let pmt = extract(i.payment) | |
90 | 105 | if (isDefined(pmt.assetId)) | |
91 | 106 | then throw("can use WAVES only at the moment") | |
92 | 107 | else { | |
93 | 108 | let userAddress = toBase58String(i.caller.bytes) | |
94 | 109 | let price = getValueItemPrice(item) | |
95 | 110 | let supplierAddress = getValueItemSupplier(item) | |
96 | 111 | if ((price > pmt.amount)) | |
97 | 112 | then throw("purchase amount cannot be less than item price") | |
98 | 113 | else if ((pmt.amount > price)) | |
99 | 114 | then throw("purchase amount cannot be higher than item price") | |
100 | 115 | else if ((supplierAddress == NONE)) | |
101 | 116 | then throw("supplier does not exist") | |
102 | 117 | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
103 | 118 | } | |
104 | 119 | } | |
105 | 120 | ||
106 | 121 | ||
107 | 122 | ||
108 | 123 | @Callable(i) | |
109 | 124 | func withdraw () = { | |
110 | 125 | let supplierAddress = toBase58String(i.caller.bytes) | |
111 | 126 | let balance = getValueBalanceSupplier(supplierAddress) | |
112 | 127 | if ((0 >= balance)) | |
113 | 128 | then throw("insufficient balance") | |
114 | 129 | else ScriptResult(WriteSet([DataEntry(getKeyBalanceSupplier(supplierAddress), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(supplierAddress), balance, unit)])) | |
115 | 130 | } | |
116 | 131 | ||
117 | 132 | ||
118 | 133 | ||
119 | 134 | @Callable(i) | |
120 | 135 | func addItem (title,price,data) = { | |
121 | 136 | let supplierAddress = toBase58String(i.caller.bytes) | |
122 | 137 | let item = getKeyItem(supplierAddress, title) | |
123 | 138 | if ((0 >= price)) | |
124 | 139 | then throw("purchase amount cannot be less than item price") | |
125 | 140 | else if ((getValueItemSupplier(item) != NONE)) | |
126 | 141 | then throw("an item is already exist") | |
127 | 142 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
128 | 143 | } | |
129 | 144 | ||
130 | 145 | ||
131 | 146 | @Verifier(tx) | |
132 | 147 | func verify () = match tx { | |
133 | 148 | case d: SetScriptTransaction => | |
134 | 149 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
135 | 150 | case d: DataTransaction => | |
136 | 151 | true | |
137 | 152 | case d: TransferTransaction => | |
138 | 153 | true | |
139 | 154 | case _ => | |
140 | 155 | false | |
141 | 156 | } | |
142 | 157 |
github/deemru/w8io/169f3d6 42.36 ms ◑