tx · GYXQczvH1CfNSCrKX3ND8uQw8fa8hfrSQQgtwaedr75D 3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc: -0.01400000 Waves 2019.09.20 20:56 [684975] smart account 3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc > SELF 0.00000000 Waves
{ "type": 13, "id": "GYXQczvH1CfNSCrKX3ND8uQw8fa8hfrSQQgtwaedr75D", "fee": 1400000, "feeAssetId": null, "timestamp": 1569002209431, "version": 1, "sender": "3N3Y2QKUaFrVBoStGQpoVoRJJTeCeKwDGbc", "senderPublicKey": "Ammb6PN8K5Hi2inMgHsjhkqxAgRm1kkPjjvWXsndQ4sY", "proofs": [ "2b6jh5nCFiofyZ3TLiTQvRXTe2V1EneVyZH1NgLRBKbFp8m2WtLxkXyiebea2WuQKF4AsuYqK5Xo9yGc5QUWe21t" ], "script": "base64:AAIDAAAAAAAAAAAAAAAOAAAAAA5vd25lclB1YmxpY0tleQEAAAAgkTEnTdeol7uGSzlcY9XCaZJBCT/vNHbkSFPcfsdd2lcAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAAZTdHJpbmcEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEFAAAABE5PTkUFAAAAA3N0cgEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQAAAARpdGVtCQABLAAAAAIFAAAABGl0ZW0CAAAABl9wcmljZQEAAAARZ2V0VmFsdWVJd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TY3JpcHRUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAD0RhdGFUcmFuc2FjdGlvbgQAAAABZAUAAAAHJG1hdGNoMAYH54S5Qg==", "chainId": 84, "height": 684975, "spentComplexity": 0 } View: original | compacted Prev: 6XkCH9rCqkHCUYdsyF1iUrKjekwvD2A3Mqr7u26oRBMB Next: 8LRZ6K7PXv6j2UbdQ6762bpRuawVzpw75eWQypVtYrfV Diff:
Old | New | Differences | |
---|---|---|---|
93 | 93 | @Verifier(tx) | |
94 | 94 | func verify () = match tx { | |
95 | 95 | case d: SetScriptTransaction => | |
96 | - | | |
96 | + | true | |
97 | 97 | case d: DataTransaction => | |
98 | 98 | true | |
99 | 99 | case _ => |
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 | 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 | @Callable(i) | |
61 | 61 | func addItem (title,price,data) = { | |
62 | 62 | let supplierAddress = toBase58String(i.caller.bytes) | |
63 | 63 | let item = getKeyItem(supplierAddress, title) | |
64 | 64 | if ((0 >= price)) | |
65 | 65 | then throw("purchase amount cannot be less than item price") | |
66 | 66 | else if ((getValueItemSupplier(item) != NONE)) | |
67 | 67 | then throw("an item is already exist") | |
68 | 68 | else WriteSet([DataEntry(getKeyItemSupplier(item), supplierAddress), DataEntry(getKeyItemPrice(item), price), DataEntry(getKeyItemData(item), data)]) | |
69 | 69 | } | |
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
73 | 73 | @Callable(i) | |
74 | 74 | func purchase (item) = { | |
75 | 75 | let pmt = extract(i.payment) | |
76 | 76 | if (isDefined(pmt.assetId)) | |
77 | 77 | then throw("can use WAVES only at the moment") | |
78 | 78 | else { | |
79 | 79 | let userAddress = toBase58String(i.caller.bytes) | |
80 | 80 | let price = getValueItemPrice(item) | |
81 | 81 | let supplierAddress = getValueItemSupplier(item) | |
82 | 82 | if ((price > pmt.amount)) | |
83 | 83 | then throw("pruchase amount cannot be less tahn item price") | |
84 | 84 | else if ((pmt.amount > price)) | |
85 | 85 | then throw("pruchase amount cannot be higher tahn item price") | |
86 | 86 | else if ((supplierAddress == NONE)) | |
87 | 87 | then throw("supplier does not exist") | |
88 | 88 | else WriteSet([DataEntry(getKeyUserItemCounter(userAddress, item), (getValueUserItemCounter(userAddress, item) + 1)), DataEntry(getKeyBalanceSupplier(supplierAddress), (getValueBalanceSupplier(supplierAddress) + pmt.amount))]) | |
89 | 89 | } | |
90 | 90 | } | |
91 | 91 | ||
92 | 92 | ||
93 | 93 | @Verifier(tx) | |
94 | 94 | func verify () = match tx { | |
95 | 95 | case d: SetScriptTransaction => | |
96 | - | | |
96 | + | true | |
97 | 97 | case d: DataTransaction => | |
98 | 98 | true | |
99 | 99 | case _ => | |
100 | 100 | false | |
101 | 101 | } | |
102 | 102 |
github/deemru/w8io/026f985 32.71 ms ◑