tx · 83rqZjx8yJHwJrjtTTstVTCiw8DT5CcKAmajPTifAaCA

3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d:  -0.01400000 Waves

2019.08.30 16:37 [654059] smart account 3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d > SELF 0.00000000 Waves

{ "type": 13, "id": "83rqZjx8yJHwJrjtTTstVTCiw8DT5CcKAmajPTifAaCA", "fee": 1400000, "feeAssetId": null, "timestamp": 1567172234000, "version": 1, "sender": "3N5hvxB2quqLovdPCVjyXdJmJ73nmmYK35d", "senderPublicKey": "6E6ogeeCpxu9SkEFhggJqUD7fCCQrW8rmAaCLNKzNiXK", "proofs": [ "64HhfeEG443EngfGW7rChoRpRzBck2ESkbZmkjetnA1U4TofFZjjKCW5k7XpfDrf4kkFU9xfqH1H6ZYnac4gP9G4" ], "script": "base64:AAIDAAAAAAAAAAAAAAANAAAAAAROT05FAgAAAARub25lAQAAAA5nZXROdW1iZXJCeUtleQAAAAEAAAADa2V5BAAAAANudW0EAAAAByRtYXRjaDAJAAQaAAAAAgUAAAAEdGhpcwUAAAADa2V5AwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAANJbnQEAAAAAWEFAAAAByRtYXRjaDAFAAAAAWEAAAAAAAAAAAAFAAAAA251bQEAAAALZ2V0U3RyQnlLZXkAAAABAAAAA2tleQQAAAADc3RyBAAAAAckbWF0Y2gwCQAEHQAAAAIFAAAABHRoaXMFAAAAA2tleQMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFhBQAAAAckbWF0Y2gwBQAAAAFhBQAAAAROT05FBQAAAANzdHIBAAAAD2dldEtleUl0ZW1QcmljZQAAAAEAAAAEaXRlbQkAASwAAAACBQAAAARpdGVtAgAAAAZfcHJpY2UBAAAAEWdldFZhbHVlSXRlbVByaWNlAAAAAQAAAARpdGVtCQEAAAAOZ2V0TnVtYmVyQnlLZXkAAAABCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQ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IhPQAAAAIJAQAAABRnZXRWYWx1ZUl0ZW1TdXBwbGllcgAAAAEFAAAABGl0ZW0FAAAABE5PTkUJAAACAAAAAQIAAAAYYW4gaXRlbSBpcyBhbHJlYWR5IGV4aXN0CQEAAAAIV3JpdGVTZXQAAAABCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAASZ2V0S2V5SXRlbVN1cHBsaWVyAAAAAQUAAAAEaXRlbQUAAAAPc3VwcGxpZXJBZGRyZXNzCQAETAAAAAIJAQAAAAlEYXRhRW50cnkAAAACCQEAAAAPZ2V0S2V5SXRlbVByaWNlAAAAAQUAAAAEaXRlbQUAAAAFcHJpY2UJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIJAQAAAA5nZXRLZXlJdGVtRGF0YQAAAAEFAAAABGl0ZW0FAAAABGRhdGEFAAAAA25pbAAAAADTtFYR", "chainId": 84, "height": 654059, "spentComplexity": 0 } View: original | compacted Prev: ESWwA2eQLvmHAGEtUNvaDUM8Sztgt4VkNthKD558wRAn Next: CUTz7FtCymd35Mp9jfNT9NxA8a2T2A8WVDJdQgSa4nc1 Diff:
OldNewDifferences
6262
6363
6464 @Callable(x)
65-func addItem (q,y,z) = {
66- let A = toBase58String(x.caller.bytes)
67- let j = o(A, q)
68- if ((0 >= y))
69- then throw("purchase amount cannot be less than item price")
70- else if ((t(j) != a))
71- then throw("an item is already exist")
72- else WriteSet([DataEntry(s(j), A), DataEntry(i(j), y), DataEntry(r(j), z)])
65+func withdraw () = {
66+ let y = toBase58String(x.caller.bytes)
67+ let z = w(y)
68+ if ((0 >= z))
69+ then throw("insufficient balance")
70+ else ScriptResult(WriteSet([DataEntry(u(y), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(y), z, unit)]))
7371 }
7472
7573
7674
7775 @Callable(x)
78-func purchase () = {
79- let B = extract(x.payment)
80- if (isDefined(B.assetId))
81- then throw("can use Waves only at the moment")
76+func purchase (j) = {
77+ let A = extract(x.payment)
78+ if (isDefined(A.assetId))
79+ then throw("WAVES tokens only at the moment")
8280 else {
83- let C = toBase58String(x.caller.bytes)
84- let y = {
85- let e = getInteger(this, "item_A_coupon_price")
86- if ($isInstanceOf(e, "Int"))
87- then {
88- let f = e
89- f
90- }
91- else 0
92- }
93- if ((y > B.amount))
94- then throw("purchase amount connot be less than item price")
95- else if ((B.amount > y))
81+ let B = toBase58String(x.caller.bytes)
82+ let C = k(j)
83+ let y = t(j)
84+ if ((C > A.amount))
85+ then throw("purchase amount cannot be less than item price")
86+ else if ((A.amount > C))
9687 then throw("purchase amount cannot be higher than item price")
97- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + C), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + C), y)])
88+ else if ((y == a))
89+ then throw("supplier does not exist")
90+ else WriteSet([DataEntry(l(B, j), (n(B, j) + 1)), DataEntry(u(y), (w(y) + A.amount))])
9891 }
92+ }
93+
94+
95+
96+@Callable(x)
97+func addItem (q,C,D) = {
98+ let y = toBase58String(x.caller.bytes)
99+ let j = o(y, q)
100+ if ((0 >= C))
101+ then throw("purchase amount cannot be less than item price")
102+ else if ((t(j) != a))
103+ then throw("an item is already exist")
104+ else WriteSet([DataEntry(s(j), y), DataEntry(i(j), C), DataEntry(r(j), D)])
99105 }
100106
101107
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 3 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
44 let a = "none"
55
66 func b (c) = {
77 let d = {
88 let e = getInteger(this, c)
99 if ($isInstanceOf(e, "Int"))
1010 then {
1111 let f = e
1212 f
1313 }
1414 else 0
1515 }
1616 d
1717 }
1818
1919
2020 func g (c) = {
2121 let h = {
2222 let e = getString(this, c)
2323 if ($isInstanceOf(e, "String"))
2424 then {
2525 let f = e
2626 f
2727 }
2828 else a
2929 }
3030 h
3131 }
3232
3333
3434 func i (j) = (j + "_price")
3535
3636
3737 func k (j) = b(i(j))
3838
3939
4040 func l (m,j) = (((j + "_") + m) + "_cnt")
4141
4242
4343 func n (m,j) = b(l(m, j))
4444
4545
4646 func o (p,q) = ("item_" + toBase58String(sha256(toBytes((p + q)))))
4747
4848
4949 func r (j) = (j + "_data")
5050
5151
5252 func s (j) = (j + "_owner")
5353
5454
5555 func t (j) = g(s(j))
5656
5757
5858 func u (v) = (v + "_balance")
5959
6060
6161 func w (v) = b(u(v))
6262
6363
6464 @Callable(x)
65-func addItem (q,y,z) = {
66- let A = toBase58String(x.caller.bytes)
67- let j = o(A, q)
68- if ((0 >= y))
69- then throw("purchase amount cannot be less than item price")
70- else if ((t(j) != a))
71- then throw("an item is already exist")
72- else WriteSet([DataEntry(s(j), A), DataEntry(i(j), y), DataEntry(r(j), z)])
65+func withdraw () = {
66+ let y = toBase58String(x.caller.bytes)
67+ let z = w(y)
68+ if ((0 >= z))
69+ then throw("insufficient balance")
70+ else ScriptResult(WriteSet([DataEntry(u(y), 0)]), TransferSet([ScriptTransfer(addressFromStringValue(y), z, unit)]))
7371 }
7472
7573
7674
7775 @Callable(x)
78-func purchase () = {
79- let B = extract(x.payment)
80- if (isDefined(B.assetId))
81- then throw("can use Waves only at the moment")
76+func purchase (j) = {
77+ let A = extract(x.payment)
78+ if (isDefined(A.assetId))
79+ then throw("WAVES tokens only at the moment")
8280 else {
83- let C = toBase58String(x.caller.bytes)
84- let y = {
85- let e = getInteger(this, "item_A_coupon_price")
86- if ($isInstanceOf(e, "Int"))
87- then {
88- let f = e
89- f
90- }
91- else 0
92- }
93- if ((y > B.amount))
94- then throw("purchase amount connot be less than item price")
95- else if ((B.amount > y))
81+ let B = toBase58String(x.caller.bytes)
82+ let C = k(j)
83+ let y = t(j)
84+ if ((C > A.amount))
85+ then throw("purchase amount cannot be less than item price")
86+ else if ((A.amount > C))
9687 then throw("purchase amount cannot be higher than item price")
97- else WriteSet([DataEntry(("status:purchase_item_A_customer_" + C), "confirmed"), DataEntry(("price:purchase_item_A_customer_" + C), y)])
88+ else if ((y == a))
89+ then throw("supplier does not exist")
90+ else WriteSet([DataEntry(l(B, j), (n(B, j) + 1)), DataEntry(u(y), (w(y) + A.amount))])
9891 }
92+ }
93+
94+
95+
96+@Callable(x)
97+func addItem (q,C,D) = {
98+ let y = toBase58String(x.caller.bytes)
99+ let j = o(y, q)
100+ if ((0 >= C))
101+ then throw("purchase amount cannot be less than item price")
102+ else if ((t(j) != a))
103+ then throw("an item is already exist")
104+ else WriteSet([DataEntry(s(j), y), DataEntry(i(j), C), DataEntry(r(j), D)])
99105 }
100106
101107

github/deemru/w8io/026f985 
189.52 ms