tx · 9zkvzo8pJgcQaSPVWyMXXr2y8BDei9NygdLaKajvQJLN 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR: -0.01400000 Waves 2019.07.14 02:55 [584665] smart account 3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR > SELF 0.00000000 Waves
{ "type": 13, "id": "9zkvzo8pJgcQaSPVWyMXXr2y8BDei9NygdLaKajvQJLN", "fee": 1400000, "feeAssetId": null, "timestamp": 1563062168261, "version": 1, "sender": "3N7MT5t1Gmyb9tcpdoUrd47pxXtTkAcgLsR", "senderPublicKey": "Adn8NfJZ8ZXuWNMXb9VaY6X6kh6k6G3KMb1WQUesFUV", "proofs": [ "4dQ42jEWFxpdt3yNkX7Nvxxh7FfDHwHvwjroSzvDAFi53K1FDY1oixoKDsoqSaQVCdYYtPYaEJU3GMWV6yKrhAxy" ], "script": "base64:AAIDAAAAAAAAAAAAAAAXAAAAAA5vd25lclB1YmxpY0tleQEAAAAgAnfP9tCFuj2k2BUY5PW9DVGxrCHBHKJwugv8WyiaGXIAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWV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"chainId": 84, "height": 584665, "spentComplexity": 0 } View: original | compacted Prev: J1o7LrnUANvJGJ2T5vatrjaWpWzJQ5irT2Q3dhDQP2rd Next: AQgjFY4Fjpu7ridNAuiCcX3ZMyRYn4q5U9dv192pwRuA Diff:
Old | New | Differences | |
---|---|---|---|
91 | 91 | then throw("can use WAVES only at the moment") | |
92 | 92 | else { | |
93 | 93 | let customerAddress = toBase58String(i.caller.bytes) | |
94 | - | let price = match getInteger(this, "item_A_coupon_price") { | |
95 | - | case a: Int => | |
96 | - | a | |
97 | - | case _ => | |
98 | - | 0 | |
99 | - | } | |
94 | + | let price = getValueItemPrice(item) | |
95 | + | let supplierAddress = getValueItemSupplier(item) | |
100 | 96 | if ((price > pmt.amount)) | |
101 | 97 | then throw("purchase amount cannot be less than item price") | |
102 | 98 | else if ((pmt.amount > price)) |
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 | 7 | ||
8 | 8 | func getNumberByKey (key) = { | |
9 | 9 | let num = match getInteger(this, key) { | |
10 | 10 | case a: Int => | |
11 | 11 | a | |
12 | 12 | case _ => | |
13 | 13 | 0 | |
14 | 14 | } | |
15 | 15 | num | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func getStrByKey (key) = { | |
20 | 20 | let str = match getString(this, key) { | |
21 | 21 | case a: String => | |
22 | 22 | a | |
23 | 23 | case _ => | |
24 | 24 | NONE | |
25 | 25 | } | |
26 | 26 | str | |
27 | 27 | } | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func getKeyItemPrice (item) = (item + "_price") | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func getKeyItemData (item) = (item + "_data") | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func getKeyItemSupplier (item) = (item + "_owner") | |
49 | 49 | ||
50 | 50 | ||
51 | 51 | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func getKeyBalanceSupplier (account) = (account + "_balance") | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | 58 | ||
59 | 59 | ||
60 | 60 | func getKeyCommit (item,user) = (((item + "_") + user) + "_commit") | |
61 | 61 | ||
62 | 62 | ||
63 | 63 | func getValueCommit (item,user) = getStrByKey(getKeyCommit(item, user)) | |
64 | 64 | ||
65 | 65 | ||
66 | 66 | func getKeyCommitsCount (item) = (item + "_comcnt") | |
67 | 67 | ||
68 | 68 | ||
69 | 69 | func getValueCommitsCount (item) = getNumberByKey(getKeyCommitsCount(item)) | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | func getKeyReveal (item,user) = (((item + "_") + user) + "_reveal") | |
73 | 73 | ||
74 | 74 | ||
75 | 75 | func getValueReveal (item,user) = getStrByKey(getKeyReveal(item, user)) | |
76 | 76 | ||
77 | 77 | ||
78 | 78 | func getKeyItemStatus (item) = (item + "_status") | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func getValueItemStatus (item) = getStrByKey(getKeyItemStatus(item)) | |
82 | 82 | ||
83 | 83 | ||
84 | 84 | func getKeyVoteCount (item,vote) = ((item + "_res:") + vote) | |
85 | 85 | ||
86 | 86 | ||
87 | 87 | @Callable(i) | |
88 | 88 | func purchase (item) = { | |
89 | 89 | let pmt = extract(i.payment) | |
90 | 90 | if (isDefined(pmt.assetId)) | |
91 | 91 | then throw("can use WAVES only at the moment") | |
92 | 92 | else { | |
93 | 93 | let customerAddress = toBase58String(i.caller.bytes) | |
94 | - | let price = match getInteger(this, "item_A_coupon_price") { | |
95 | - | case a: Int => | |
96 | - | a | |
97 | - | case _ => | |
98 | - | 0 | |
99 | - | } | |
94 | + | let price = getValueItemPrice(item) | |
95 | + | let supplierAddress = getValueItemSupplier(item) | |
100 | 96 | if ((price > pmt.amount)) | |
101 | 97 | then throw("purchase amount cannot be less than item price") | |
102 | 98 | else if ((pmt.amount > price)) | |
103 | 99 | then throw("purchase amount cannot be higher than item price") | |
104 | 100 | else WriteSet([DataEntry(("status:purchase_item_A_customer_" + customerAddress), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + customerAddress), price)]) | |
105 | 101 | } | |
106 | 102 | } | |
107 | 103 | ||
108 | 104 | ||
109 | 105 | ||
110 | 106 | @Callable(i) | |
111 | 107 | func addItem (title,price,data) = { | |
112 | 108 | let supplierAddress = toBase58String(i.caller.bytes) | |
113 | 109 | let item = getKeyItem(supplierAddress, title) | |
114 | 110 | if ((0 >= price)) | |
115 | 111 | then throw("purchase amount cannot be less than item price") | |
116 | 112 | else if ((getValueItemSupplier(item) != NONE)) | |
117 | 113 | then throw("an item is already exist") | |
118 | 114 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
119 | 115 | } | |
120 | 116 | ||
121 | 117 | ||
122 | 118 | @Verifier(tx) | |
123 | 119 | func verify () = match tx { | |
124 | 120 | case d: SetScriptTransaction => | |
125 | 121 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
126 | 122 | case d: DataTransaction => | |
127 | 123 | true | |
128 | 124 | case _ => | |
129 | 125 | false | |
130 | 126 | } | |
131 | 127 |
github/deemru/w8io/026f985 25.81 ms ◑