tx · 4kgLm4Z8B3qDrdytaQSYq1e7KtpmWFaGGguBaUjxAWfJ
3N58U7hA1kzMTCUqHiJGdcPdjxAKspMgGNp: -0.01000000 Waves
2021.07.16 17:03 [1616258] smart account 3N58U7hA1kzMTCUqHiJGdcPdjxAKspMgGNp > SELF 0.00000000 Waves
{
"type": 13,
"id": "4kgLm4Z8B3qDrdytaQSYq1e7KtpmWFaGGguBaUjxAWfJ",
"fee": 1000000,
"feeAssetId": null,
"timestamp": 1626444235612,
"version": 2,
"chainId": 84,
"sender": "3N58U7hA1kzMTCUqHiJGdcPdjxAKspMgGNp",
"senderPublicKey": "85gydchvWB9gMPFCKM6kfLPWFSATbtGog2Y6rUjhtQKT",
"proofs": [
"2WoepbhTwjtmB44Pu7MMpehCWwuAHfXX73QDQmvWyvJLon3sJXoQoHF1RzX7FEERrWFZ9b77JoaVhcYkYSheGS3f"
],
"script": "base64:AAIDAAAAAAAAAAQIARIAAAAAAAAAAAEAAAABaQEAAAAHZGVwb3NpdAAAAAAEAAAACXN3YXBUb2tlbgEAAAAgb43vwMVF3NniH29QbTemn52wAqbd0CJjn9c5H5QYbCgEAAAAA3BtdAkBAAAAB2V4dHJhY3QAAAABCAUAAAABaQAAAAdwYXltZW50AwkBAAAACWlzRGVmaW5lZAAAAAEIBQAAAANwbXQAAAAHYXNzZXRJZAkAAAIAAAABAgAAACFjYW4gaG9kbCB3YXZlcyBvbmx5IGF0IHRoZSBtb21lbnQEAAAABmFtb3VudAgFAAAAA3BtdAAAAAZhbW91bnQJAQAAAAtUcmFuc2ZlclNldAAAAAEJAARMAAAAAgkBAAAADlNjcmlwdFRyYW5zZmVyAAAAAwgFAAAAAWkAAAAGY2FsbGVyBQAAAAZhbW91bnQFAAAACXN3YXBUb2tlbgUAAAADbmlsAAAAAPQdAc8=",
"height": 1616258,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 8bwq8FdCd7WLjzR7LavyAy8jvmsyZLq8jRBvQi9HGH9F
Next: E5KdkibjJL43e5yndhL8a1D1H5DxjMtiwr9rYtthRyMF
Diff:
Old | New | | Differences |
---|
10 | 10 | | if (isDefined(pmt.assetId)) |
---|
11 | 11 | | then throw("can hodl waves only at the moment") |
---|
12 | 12 | | else { |
---|
13 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
15 | | - | case a: Int => |
---|
16 | | - | a |
---|
17 | | - | case _ => |
---|
18 | | - | 0 |
---|
| 13 | + | let amount = pmt.amount |
---|
| 14 | + | TransferSet([ScriptTransfer(i.caller, amount, swapToken)]) |
---|
19 | 15 | | } |
---|
20 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
21 | | - | TransferSet([ScriptTransfer(i.caller, newAmount, swapToken)]) |
---|
22 | | - | } |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | @Callable(i) |
---|
28 | | - | func withdraw (amount) = { |
---|
29 | | - | let swapToken = base58'3N58U7hA1kzMTCUqHiJGdcPdjxAKspMgGNp' |
---|
30 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
31 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
32 | | - | case a: Int => |
---|
33 | | - | a |
---|
34 | | - | case _ => |
---|
35 | | - | 0 |
---|
36 | | - | } |
---|
37 | | - | let newAmount = (currentAmount - amount) |
---|
38 | | - | if ((0 > amount)) |
---|
39 | | - | then throw("Can't withdraw negative amount") |
---|
40 | | - | else if ((0 > newAmount)) |
---|
41 | | - | then throw("Not enough balance") |
---|
42 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)])) |
---|
43 | 16 | | } |
---|
44 | 17 | | |
---|
45 | 18 | | |
---|
Full:
Old | New | | Differences |
---|
1 | 1 | | {-# STDLIB_VERSION 3 #-} |
---|
2 | 2 | | {-# SCRIPT_TYPE ACCOUNT #-} |
---|
3 | 3 | | {-# CONTENT_TYPE DAPP #-} |
---|
4 | 4 | | |
---|
5 | 5 | | |
---|
6 | 6 | | @Callable(i) |
---|
7 | 7 | | func deposit () = { |
---|
8 | 8 | | let swapToken = base58'8WTnTr8QxFYKhMo7tkjLigfw2zAFFQYzjpoNdSFruTL3' |
---|
9 | 9 | | let pmt = extract(i.payment) |
---|
10 | 10 | | if (isDefined(pmt.assetId)) |
---|
11 | 11 | | then throw("can hodl waves only at the moment") |
---|
12 | 12 | | else { |
---|
13 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
15 | | - | case a: Int => |
---|
16 | | - | a |
---|
17 | | - | case _ => |
---|
18 | | - | 0 |
---|
| 13 | + | let amount = pmt.amount |
---|
| 14 | + | TransferSet([ScriptTransfer(i.caller, amount, swapToken)]) |
---|
19 | 15 | | } |
---|
20 | | - | let newAmount = (currentAmount + pmt.amount) |
---|
21 | | - | TransferSet([ScriptTransfer(i.caller, newAmount, swapToken)]) |
---|
22 | | - | } |
---|
23 | | - | } |
---|
24 | | - | |
---|
25 | | - | |
---|
26 | | - | |
---|
27 | | - | @Callable(i) |
---|
28 | | - | func withdraw (amount) = { |
---|
29 | | - | let swapToken = base58'3N58U7hA1kzMTCUqHiJGdcPdjxAKspMgGNp' |
---|
30 | | - | let currentKey = toBase58String(i.caller.bytes) |
---|
31 | | - | let currentAmount = match getInteger(this, currentKey) { |
---|
32 | | - | case a: Int => |
---|
33 | | - | a |
---|
34 | | - | case _ => |
---|
35 | | - | 0 |
---|
36 | | - | } |
---|
37 | | - | let newAmount = (currentAmount - amount) |
---|
38 | | - | if ((0 > amount)) |
---|
39 | | - | then throw("Can't withdraw negative amount") |
---|
40 | | - | else if ((0 > newAmount)) |
---|
41 | | - | then throw("Not enough balance") |
---|
42 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, newAmount)]), TransferSet([ScriptTransfer(i.caller, amount, swapToken)])) |
---|
43 | 16 | | } |
---|
44 | 17 | | |
---|
45 | 18 | | |
---|