tx · CDrGp3tfVNxyYV3JPZk3cWUZU7FpeWnWjrgYBsifJ947 3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc: -0.01400000 Waves 2019.09.19 18:58 [683383] smart account 3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc > SELF 0.00000000 Waves
{ "type": 13, "id": "CDrGp3tfVNxyYV3JPZk3cWUZU7FpeWnWjrgYBsifJ947", "fee": 1400000, "feeAssetId": null, "timestamp": 1568908725404, "version": 1, "sender": "3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc", "senderPublicKey": "Ammb6PN8K5Hi2inMgHsjhkqxAgRm1kkPjjvWXsndQ4sY", "proofs": [ "5Xk2gmpjV57qEwowDnUE46mpMdbLMrJ5qqEYDWiVJuASbQ5np6kzMCVG6mjLv24Tugie6KcZ4JgyFKTW3D7Rwb5e" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAA5vd25lclB1YmxpY0tleQEAAAAgkTEnTdeol7uGSzlcY9XCaZJBCT/vNHbkSFPcfsdd2lcAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdW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HgAAAAGcHJvb2ZzAAAAAAAAAAAABQAAAA5vd25lclB1YmxpY0tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAPRGF0YVRyYW5zYWN0aW9uBAAAAAFkBQAAAAckbWF0Y2gwBgZk2h5V", "chainId": 84, "height": 683383, "spentComplexity": 0 } View: original | compacted Prev: 6cqELvDuNMW7h4VrTaZ6wDRvL2oMAgBdH9CUjj1Bt2pq Next: GHZBcozPb7Ne2atSBsj79fYhzJmAZ1b64DUjrDvc2B9j Diff:
Old | New | Differences | |
---|---|---|---|
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'Ammb6PN8K5Hi2inMgHsjhkqxAgRm1kkPjjvWXsndQ4sY' | |
5 | + | ||
6 | + | let NONE = "none" | |
7 | + | ||
8 | + | func getNumberByKey (key) = { | |
9 | + | let num = match getInteger(this, key) { | |
10 | + | case a: Int => | |
11 | + | a | |
12 | + | case _ => | |
13 | + | 0 | |
14 | + | } | |
15 | + | num | |
16 | + | } | |
17 | + | ||
18 | + | ||
19 | + | func getStrByKey (key) = { | |
20 | + | let str = match getString(this, key) { | |
21 | + | case a: String => | |
22 | + | a | |
23 | + | case _ => | |
24 | + | NONE | |
25 | + | } | |
26 | + | str | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func getKeyItemPrice (item) = (item + "_price") | |
31 | + | ||
32 | + | ||
33 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
34 | + | ||
35 | + | ||
36 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
37 | + | ||
38 | + | ||
39 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
40 | + | ||
41 | + | ||
42 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | + | ||
44 | + | ||
45 | + | func getKeyItemData (item) = (item + "_data") | |
46 | + | ||
47 | + | ||
48 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
49 | + | ||
50 | + | ||
51 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
52 | + | ||
53 | + | ||
54 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
55 | + | ||
56 | + | ||
57 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func addItem (title,price,data) = { | |
62 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
63 | + | let item = getKeyItem(supplierAddress, title) | |
64 | + | if ((0 >= price)) | |
65 | + | then throw("purchase amount cannot be less than item price") | |
66 | + | else if ((getValueItemSupplier(item) != NONE)) | |
67 | + | then throw("an item is already exist") | |
68 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
69 | + | } | |
70 | + | ||
71 | + | ||
5 | 72 | ||
6 | 73 | @Callable(i) | |
7 | 74 | func purchase (item) = { |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 3 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let ownerPublicKey = base58'Ammb6PN8K5Hi2inMgHsjhkqxAgRm1kkPjjvWXsndQ4sY' | |
5 | + | ||
6 | + | let NONE = "none" | |
7 | + | ||
8 | + | func getNumberByKey (key) = { | |
9 | + | let num = match getInteger(this, key) { | |
10 | + | case a: Int => | |
11 | + | a | |
12 | + | case _ => | |
13 | + | 0 | |
14 | + | } | |
15 | + | num | |
16 | + | } | |
17 | + | ||
18 | + | ||
19 | + | func getStrByKey (key) = { | |
20 | + | let str = match getString(this, key) { | |
21 | + | case a: String => | |
22 | + | a | |
23 | + | case _ => | |
24 | + | NONE | |
25 | + | } | |
26 | + | str | |
27 | + | } | |
28 | + | ||
29 | + | ||
30 | + | func getKeyItemPrice (item) = (item + "_price") | |
31 | + | ||
32 | + | ||
33 | + | func getValueItemPrice (item) = getNumberByKey(getKeyItemPrice(item)) | |
34 | + | ||
35 | + | ||
36 | + | func getKeyUserItemCounter (user,item) = (((item + "_") + user) + "_cnt") | |
37 | + | ||
38 | + | ||
39 | + | func getValueUserItemCounter (user,item) = getNumberByKey(getKeyUserItemCounter(user, item)) | |
40 | + | ||
41 | + | ||
42 | + | func getKeyItem (supplier,title) = ("item_" + toBase58String(sha256(toBytes((supplier + title))))) | |
43 | + | ||
44 | + | ||
45 | + | func getKeyItemData (item) = (item + "_data") | |
46 | + | ||
47 | + | ||
48 | + | func getKeyItemSupplier (item) = (item + "_owner") | |
49 | + | ||
50 | + | ||
51 | + | func getValueItemSupplier (item) = getStrByKey(getKeyItemSupplier(item)) | |
52 | + | ||
53 | + | ||
54 | + | func getKeyBalanceSupplier (account) = (account + "_balance") | |
55 | + | ||
56 | + | ||
57 | + | func getValueBalanceSupplier (account) = getNumberByKey(getKeyBalanceSupplier(account)) | |
58 | + | ||
59 | + | ||
60 | + | @Callable(i) | |
61 | + | func addItem (title,price,data) = { | |
62 | + | let supplierAddress = toBase58String(i.caller.bytes) | |
63 | + | let item = getKeyItem(supplierAddress, title) | |
64 | + | if ((0 >= price)) | |
65 | + | then throw("purchase amount cannot be less than item price") | |
66 | + | else if ((getValueItemSupplier(item) != NONE)) | |
67 | + | then throw("an item is already exist") | |
68 | + | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
69 | + | } | |
70 | + | ||
71 | + | ||
5 | 72 | ||
6 | 73 | @Callable(i) | |
7 | 74 | func purchase (item) = { | |
8 | 75 | let pmt = extract(i.payment) | |
9 | 76 | if (isDefined(pmt.assetId)) | |
10 | 77 | then throw("can use WAVES only at the moment") | |
11 | 78 | else { | |
12 | 79 | let customerAddress = toBase58String(i.caller.bytes) | |
13 | 80 | let price = match getInteger(this, (("item_" + item) + "_coupon_price")) { | |
14 | 81 | case a: Int => | |
15 | 82 | a | |
16 | 83 | case _ => | |
17 | 84 | 0 | |
18 | 85 | } | |
19 | 86 | if ((price > pmt.amount)) | |
20 | 87 | then throw("purchase amount cannot be less than item price") | |
21 | 88 | else if ((pmt.amount > price)) | |
22 | 89 | then throw("purchase amount cannot be higher than item price") | |
23 | 90 | else WriteSet([DataEntry(((("status:purchase_item_" + item) + "_customer") + customerAddress), "confirmed"), DataEntry(((("price:purchase_item_" + item) + "_customer") + customerAddress), price)]) | |
24 | 91 | } | |
25 | 92 | } | |
26 | 93 | ||
27 | 94 | ||
28 | 95 | @Verifier(tx) | |
29 | 96 | func verify () = match tx { | |
30 | 97 | case d: SetScriptTransaction => | |
31 | 98 | sigVerify(tx.bodyBytes, tx.proofs[0], ownerPublicKey) | |
32 | 99 | case d: DataTransaction => | |
33 | 100 | true | |
34 | 101 | case _ => | |
35 | 102 | true | |
36 | 103 | } | |
37 | 104 |
github/deemru/w8io/026f985 22.28 ms ◑