tx · 5RyV7rb3i2oC27HBC9Zwh8vCFeLLQb85bpyJ2UgXuJvr 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3: -0.01400000 Waves 2020.11.20 17:48 [1273844] smart account 3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3 > SELF 0.00000000 Waves
{ "type": 13, "id": "5RyV7rb3i2oC27HBC9Zwh8vCFeLLQb85bpyJ2UgXuJvr", "fee": 1400000, "feeAssetId": null, "timestamp": 1605883763183, "version": 2, "chainId": 84, "sender": "3MtTheYx7F8GojnQXdBq5njwKSWwWDR8Yx3", "senderPublicKey": "24o2mnMP6y64dijDFoZKhDpV73e1gCFKxQcZ6X9q3z1B", "proofs": [ "41RSr3PatEQKHzWWNDHJj93ZSDUeMuihnJ7hxt53q6gejUmzjMRFd1VxVUAaaazgDfXrjshoJPjrVVWRs7JPZkiv" ], "script": "base64:AAIEAAAAAAAAAA4IAhIDCgEIEgUKAwgBCAAAABAAAAAAEWFjY291bnQxUHVibGljS2V5AQAAACD3jXgw7OE1lYUdW8zpPeJRbBzq2i/QfxUY9F31TI9ITgAAAAARYWNjb3VudDJQdWJsaWNLZXkBAAAAIBtXv2hMCq7TJHKvVsoiywB7SjyYC3f6AKFF3CrlAyIVAAAAAA5vdGhlclB1YmxpY0tleQEAAAAg525Riaa48RgJvYxM/FeTNEzhBum4Tb2zEKrgTa8dHVoAAAAABE5PTkUCAAAABG5vbmUBAAAADmdldE51bWJlckJ5S2V5AAAAAQAAAANrZXkEAAAAA251bQQAAAAHJG1hdGNoMAkABBoAAAACBQAAAAR0aGlzBQAAAANrZXkDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAAA0ludAQAAAABYQUAAAAHJG1hdGNoMAUAAAABYQAAAAAAAAAAAAUAAAADbnVtAQAAAAtnZXRTdHJCeUtleQAAAAEAAAADa2V5BAAAAANzdHIEAAAAByRtYXRjaDAJAAQdAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbW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nZXRLZXlJdGVtUHJpY2UAAAABBQAAAARpdGVtBQAAAAVwcmljZQkABEwAAAACCQEAAAALU3RyaW5nRW50cnkAAAACCQEAAAAOZ2V0S2V5SXRlbURhdGEAAAABBQAAAARpdGVtBQAAAARkYXRhBQAAAANuaWwAAAABAAAAAnR4AQAAAAZ2ZXJpZnkAAAAABosQwsA=", "height": 1273844, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9uKQMLdnuAgCjd1htTsbM3MMfrSNSo1RemvaDkhAVtwU Next: 55hNEsKebyqGS8vCw8oeiuQCqf4PRUB5yBvh7WwQxZQG Diff:
Old | New | Differences | |
---|---|---|---|
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(A) | |
71 | - | func purchase ( | |
72 | - | let | |
73 | - | if (isDefined( | |
74 | - | then throw("only | |
71 | + | func purchase (m) = { | |
72 | + | let B = value(A.payments) | |
73 | + | if (isDefined(B[0].assetId)) | |
74 | + | then throw("WAVES tokens only") | |
75 | 75 | else { | |
76 | - | let D = toBase58String(A.caller.bytes) | |
77 | - | let E = { | |
78 | - | let h = getInteger(this, (B + "_coupon_price")) | |
79 | - | if ($isInstanceOf(h, "Int")) | |
80 | - | then { | |
81 | - | let i = h | |
82 | - | i | |
83 | - | } | |
84 | - | else 0 | |
85 | - | } | |
86 | - | if ((E == 0)) | |
87 | - | then throw("coupon not found") | |
88 | - | else if ((E > C[0].amount)) | |
89 | - | then throw("moar moeny") | |
90 | - | else if ((C[0].amount > E)) | |
91 | - | then throw(toString(E)) | |
92 | - | else if ((size(C) > 1)) | |
93 | - | then throw("single item only") | |
94 | - | else [StringEntry(((("status:purchase_" + B) + "_customer_") + D), "confirmed"), IntegerEntry(((("price:purchase_" + B) + "_customer_") + D), E)] | |
76 | + | let C = toBase58String(A.caller.bytes) | |
77 | + | let D = n(m) | |
78 | + | let E = w(m) | |
79 | + | if ((D > B[0].amount)) | |
80 | + | then throw("purchase less than item price") | |
81 | + | else if ((B[0].amount > D)) | |
82 | + | then throw("purchase amount higher than item price") | |
83 | + | else if ((size(B) > 1)) | |
84 | + | then throw("single item only") | |
85 | + | else if ((E == d)) | |
86 | + | then throw("supplier doesn't exist") | |
87 | + | else [IntegerEntry(o(C, m), (q(C, m) + 1)), IntegerEntry(x(E), (z(E) + B[0].amount))] | |
95 | 88 | } | |
96 | 89 | } | |
97 | 90 | ||
98 | 91 | ||
99 | 92 | ||
100 | 93 | @Callable(A) | |
101 | - | func addItem (t, | |
102 | - | let | |
103 | - | let m = r( | |
104 | - | if ((0 >= | |
94 | + | func addItem (t,D,F) = { | |
95 | + | let E = toBase58String(A.caller.bytes) | |
96 | + | let m = r(E, t) | |
97 | + | if ((0 >= D)) | |
105 | 98 | then throw("purchase amount cannot be less than item price") | |
106 | 99 | else if ((w(m) != d)) | |
107 | 100 | then throw("an item already exist") | |
108 | - | else [StringEntry(v(m), | |
101 | + | else [StringEntry(v(m), E), IntegerEntry(l(m), D), StringEntry(u(m), F)] | |
109 | 102 | } | |
110 | 103 | ||
111 | 104 | ||
112 | - | @Verifier( | |
113 | - | func | |
105 | + | @Verifier(G) | |
106 | + | func H () = true | |
114 | 107 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 4 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let a = base58'HfLpRhXtnuCabRyNT6z7soaXcbUpwLUhjyBCVQ4szwzd' | |
5 | 5 | ||
6 | 6 | let b = base58'2qjcWuL7QitmuhkSTM7CnNxurCYXuqJ9ubswLBGmXfDv' | |
7 | 7 | ||
8 | 8 | let c = base58'GaQkBG6yLLAarb8wvPrEKnQhFqWomD2ZGT1T4vVx24qw' | |
9 | 9 | ||
10 | 10 | let d = "none" | |
11 | 11 | ||
12 | 12 | func e (f) = { | |
13 | 13 | let g = { | |
14 | 14 | let h = getInteger(this, f) | |
15 | 15 | if ($isInstanceOf(h, "Int")) | |
16 | 16 | then { | |
17 | 17 | let i = h | |
18 | 18 | i | |
19 | 19 | } | |
20 | 20 | else 0 | |
21 | 21 | } | |
22 | 22 | g | |
23 | 23 | } | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func j (f) = { | |
27 | 27 | let k = { | |
28 | 28 | let h = getString(this, f) | |
29 | 29 | if ($isInstanceOf(h, "String")) | |
30 | 30 | then { | |
31 | 31 | let i = h | |
32 | 32 | i | |
33 | 33 | } | |
34 | 34 | else d | |
35 | 35 | } | |
36 | 36 | k | |
37 | 37 | } | |
38 | 38 | ||
39 | 39 | ||
40 | 40 | func l (m) = (m + "_price") | |
41 | 41 | ||
42 | 42 | ||
43 | 43 | func n (m) = e(l(m)) | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func o (p,m) = (((m + "_") + p) + "_cnt") | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func q (p,m) = e(o(p, m)) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func r (s,t) = ("item_" + toBase58String(sha256(toBytes((s + t))))) | |
53 | 53 | ||
54 | 54 | ||
55 | 55 | func u (m) = (m + "_data") | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func v (m) = (m + "_owner") | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func w (m) = j(v(m)) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func x (y) = (y + "_balance") | |
65 | 65 | ||
66 | 66 | ||
67 | 67 | func z (y) = e(x(y)) | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(A) | |
71 | - | func purchase ( | |
72 | - | let | |
73 | - | if (isDefined( | |
74 | - | then throw("only | |
71 | + | func purchase (m) = { | |
72 | + | let B = value(A.payments) | |
73 | + | if (isDefined(B[0].assetId)) | |
74 | + | then throw("WAVES tokens only") | |
75 | 75 | else { | |
76 | - | let D = toBase58String(A.caller.bytes) | |
77 | - | let E = { | |
78 | - | let h = getInteger(this, (B + "_coupon_price")) | |
79 | - | if ($isInstanceOf(h, "Int")) | |
80 | - | then { | |
81 | - | let i = h | |
82 | - | i | |
83 | - | } | |
84 | - | else 0 | |
85 | - | } | |
86 | - | if ((E == 0)) | |
87 | - | then throw("coupon not found") | |
88 | - | else if ((E > C[0].amount)) | |
89 | - | then throw("moar moeny") | |
90 | - | else if ((C[0].amount > E)) | |
91 | - | then throw(toString(E)) | |
92 | - | else if ((size(C) > 1)) | |
93 | - | then throw("single item only") | |
94 | - | else [StringEntry(((("status:purchase_" + B) + "_customer_") + D), "confirmed"), IntegerEntry(((("price:purchase_" + B) + "_customer_") + D), E)] | |
76 | + | let C = toBase58String(A.caller.bytes) | |
77 | + | let D = n(m) | |
78 | + | let E = w(m) | |
79 | + | if ((D > B[0].amount)) | |
80 | + | then throw("purchase less than item price") | |
81 | + | else if ((B[0].amount > D)) | |
82 | + | then throw("purchase amount higher than item price") | |
83 | + | else if ((size(B) > 1)) | |
84 | + | then throw("single item only") | |
85 | + | else if ((E == d)) | |
86 | + | then throw("supplier doesn't exist") | |
87 | + | else [IntegerEntry(o(C, m), (q(C, m) + 1)), IntegerEntry(x(E), (z(E) + B[0].amount))] | |
95 | 88 | } | |
96 | 89 | } | |
97 | 90 | ||
98 | 91 | ||
99 | 92 | ||
100 | 93 | @Callable(A) | |
101 | - | func addItem (t, | |
102 | - | let | |
103 | - | let m = r( | |
104 | - | if ((0 >= | |
94 | + | func addItem (t,D,F) = { | |
95 | + | let E = toBase58String(A.caller.bytes) | |
96 | + | let m = r(E, t) | |
97 | + | if ((0 >= D)) | |
105 | 98 | then throw("purchase amount cannot be less than item price") | |
106 | 99 | else if ((w(m) != d)) | |
107 | 100 | then throw("an item already exist") | |
108 | - | else [StringEntry(v(m), | |
101 | + | else [StringEntry(v(m), E), IntegerEntry(l(m), D), StringEntry(u(m), F)] | |
109 | 102 | } | |
110 | 103 | ||
111 | 104 | ||
112 | - | @Verifier( | |
113 | - | func | |
105 | + | @Verifier(G) | |
106 | + | func H () = true | |
114 | 107 |
github/deemru/w8io/169f3d6 30.68 ms ◑