tx · GcaULHuNRe2S2SRyivvLZCwcrKPzCnCd3uVzNxvHFxhF
3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY: -0.01400000 Waves
2020.10.06 19:18 [1208939] smart account 3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY > SELF 0.00000000 Waves
{
"type": 13,
"id": "GcaULHuNRe2S2SRyivvLZCwcrKPzCnCd3uVzNxvHFxhF",
"fee": 1400000,
"feeAssetId": null,
"timestamp": 1602001141027,
"version": 2,
"chainId": 84,
"sender": "3N8XBzcbxt5snTdkqVSobDjtDGbTns27DdY",
"senderPublicKey": "HhWoKsFPjXVx9nYfPydpV9BwLmuUdJyJ8ydtyVJVxg9Z",
"proofs": [
"5JpEZhUtBEeWMfAuY81MyHFQhyknY3jWG9LDy5pR8g1y9sBfaUmgCZyxMafCdnGuokQpJG6JVmtW7CJqXjcRiLEf"
],
"script": "base64:AAIDAAAAAAAAAAkIARIAEgMKAQEAAAAAAAAAAgAAAAFpAQAAAAdkZXBvc2l0AAAAAAQAAAADcG10CQEAAAAHZXh0cmFjdAAAAAEIBQAAAAFpAAAAB3BheW1lbnQEAAAAC2Jsb2NrSGVpZ2h0CAUAAAAJbGFzdEJsb2NrAAAABmhlaWdodAMJAQAAAAlpc0RlZmluZWQAAAABCAUAAAADcG10AAAAB2Fzc2V0SWQJAAACAAAAAQIAAAAhY2FuIGhvZGwgd2F2ZXMgb25seSBhdCB0aGUgbW9tZW50BAAAAApjdXJyZW50S2V5CQACWAAAAAEICAUAAAABaQAAAAZjYWxsZXIAAAAFYnl0ZXMDCQEAAAABIQAAAAEJAQAAAAlpc0RlZmluZWQAAAABCQAEHQAAAAIFAAAABHRoaXMFAAAACmN1cnJlbnRLZXkJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQkAAGgAAAACCQAAaQAAAAIIBQA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Jlc3VsdAAAAAIJAQAAAAhXcml0ZVNldAAAAAEJAARMAAAAAgkBAAAACURhdGFFbnRyeQAAAAIFAAAACmN1cnJlbnRLZXkJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAEsAAAAAgkAASwAAAACCQABLAAAAAIJAAGkAAAAAQUAAAAJbmV3QW1vdW50AgAAAAFfCQABkQAAAAIFAAAAB29sZERhdGEAAAAAAAAAAAECAAAAAV8JAAGkAAAAAQUAAAALc3VtV2l0aGRyYXcCAAAAGF9mcm9tLXRlc3QobWF4V2l0aGRyYXcpOgkAAaQAAAABBQAAAAttYXhXaXRoZHJhdwIAAAATX2Zyb20tdGVzdChhbW91bnQpOgkAAaQAAAABBQAAAAZhbW91bnQCAAAAIF9mcm9tLXRlc3QoYmxvY2stYWZ0ZXItZGVwb3NpdCk6CQABpAAAAAEJAABlAAAAAgUAAAAPZnJvc3RCbG9ja0NvdW50CQAAZQAAAAIFAAAAEmRlZnJvc3RCbG9ja0hlaWdodAUAAAALYmxvY2tIZWlnaHQCAAAAGl9mcm9tLXRlc3Qoc3VtLWZvci1ibG9jayk6CQABpAAAAAEJAABpAAAAAgUAAAAJb2xkQW1vdW50BQAAAA9mcm9zdEJsb2NrQ291bnQFAAAAA25pbAkBAAAAC1RyYW5zZmVyU2V0AAAAAQkABEwAAAACCQEAAAAOU2NyaXB0VHJhbnNmZXIAAAADCAUAAAABaQAAAAZjYWxsZXIFAAAABmFtb3VudAUAAAAEdW5pdAUAAAADbmlsAAAAALKZ3Gc=",
"height": 1208939,
"applicationStatus": "succeeded",
"spentComplexity": 0
}
View: original | compacted
Prev: 2peHnw1Uu6CSYcctNdJx5KTFqtAE1xVuH3LZ5M6TY5nw
Next: BCFdp41PNuLxpN8ysjKYA3fMmMkYx1gaZdonzi5JYnWc
Diff:
Old | New | | Differences |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | @Callable(i) |
---|
32 | | - | func withdraw () = { |
---|
| 32 | + | func withdraw (amount) = { |
---|
33 | 33 | | let frostBlockCount = 100 |
---|
34 | | - | let pmt = extract(i.payment) |
---|
35 | | - | let amount = pmt.amount |
---|
36 | 34 | | let currentKey = toBase58String(i.caller.bytes) |
---|
37 | 35 | | let oldData = split( match getString(this, currentKey) { |
---|
38 | 36 | | case str: String => |
---|
|
52 | 50 | | if ((0 > amount)) |
---|
53 | 51 | | then throw("Can't withdraw negative amount") |
---|
54 | 52 | | else if ((amount > maxWithdraw)) |
---|
55 | | - | then throw((("Max sum: " + toString((maxWithdraw / 100000000))) + " Waves")) |
---|
| 53 | + | then throw(("Max sum: " + toString(maxWithdraw))) |
---|
56 | 54 | | else if ((0 > newAmount)) |
---|
57 | 55 | | then throw("Not enough balance") |
---|
58 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_") + toString(maxWithdraw)) + "_") + toString(amount)))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 56 | + | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_from-test(maxWithdraw):") + toString(maxWithdraw)) + "_from-test(amount):") + toString(amount)) + "_from-test(block-after-deposit):") + toString((frostBlockCount - (defrostBlockHeight - blockHeight)))) + "_from-test(sum-for-block):") + toString((oldAmount / frostBlockCount))))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
59 | 57 | | } |
---|
60 | 58 | | |
---|
61 | 59 | | |
---|
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 pmt = extract(i.payment) |
---|
9 | 9 | | let blockHeight = lastBlock.height |
---|
10 | 10 | | if (isDefined(pmt.assetId)) |
---|
11 | 11 | | then throw("can hodl waves only at the moment") |
---|
12 | 12 | | else { |
---|
13 | 13 | | let currentKey = toBase58String(i.caller.bytes) |
---|
14 | 14 | | if (!(isDefined(getString(this, currentKey)))) |
---|
15 | 15 | | then WriteSet([DataEntry(currentKey, (((toString(((pmt.amount / 100) * 120)) + "_") + toString(blockHeight)) + "_0"))]) |
---|
16 | 16 | | else { |
---|
17 | 17 | | let oldData = split( match getString(this, currentKey) { |
---|
18 | 18 | | case str: String => |
---|
19 | 19 | | str |
---|
20 | 20 | | case _ => |
---|
21 | 21 | | throw("error") |
---|
22 | 22 | | }, "_") |
---|
23 | 23 | | let currentAmount = parseIntValue(oldData[0]) |
---|
24 | 24 | | WriteSet([DataEntry(currentKey, ((((toString((currentAmount + ((pmt.amount / 100) * 120))) + "_") + toString(blockHeight)) + "_") + oldData[2]))]) |
---|
25 | 25 | | } |
---|
26 | 26 | | } |
---|
27 | 27 | | } |
---|
28 | 28 | | |
---|
29 | 29 | | |
---|
30 | 30 | | |
---|
31 | 31 | | @Callable(i) |
---|
32 | | - | func withdraw () = { |
---|
| 32 | + | func withdraw (amount) = { |
---|
33 | 33 | | let frostBlockCount = 100 |
---|
34 | | - | let pmt = extract(i.payment) |
---|
35 | | - | let amount = pmt.amount |
---|
36 | 34 | | let currentKey = toBase58String(i.caller.bytes) |
---|
37 | 35 | | let oldData = split( match getString(this, currentKey) { |
---|
38 | 36 | | case str: String => |
---|
39 | 37 | | str |
---|
40 | 38 | | case _ => |
---|
41 | 39 | | throw("error") |
---|
42 | 40 | | }, "_") |
---|
43 | 41 | | let oldAmount = parseIntValue(oldData[0]) |
---|
44 | 42 | | let newAmount = (oldAmount - amount) |
---|
45 | 43 | | let blockHeight = lastBlock.height |
---|
46 | 44 | | let frostBlockHeight = parseIntValue(oldData[1]) |
---|
47 | 45 | | let defrostBlockHeight = (frostBlockHeight + frostBlockCount) |
---|
48 | 46 | | let sumWithdraw = (parseIntValue(oldData[2]) + amount) |
---|
49 | 47 | | let maxWithdraw = if ((blockHeight >= defrostBlockHeight)) |
---|
50 | 48 | | then oldAmount |
---|
51 | 49 | | else ((frostBlockCount - (defrostBlockHeight - blockHeight)) * (oldAmount / frostBlockCount)) |
---|
52 | 50 | | if ((0 > amount)) |
---|
53 | 51 | | then throw("Can't withdraw negative amount") |
---|
54 | 52 | | else if ((amount > maxWithdraw)) |
---|
55 | | - | then throw((("Max sum: " + toString((maxWithdraw / 100000000))) + " Waves")) |
---|
| 53 | + | then throw(("Max sum: " + toString(maxWithdraw))) |
---|
56 | 54 | | else if ((0 > newAmount)) |
---|
57 | 55 | | then throw("Not enough balance") |
---|
58 | | - | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_") + toString(maxWithdraw)) + "_") + toString(amount)))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
| 56 | + | else ScriptResult(WriteSet([DataEntry(currentKey, ((((((((((((toString(newAmount) + "_") + oldData[1]) + "_") + toString(sumWithdraw)) + "_from-test(maxWithdraw):") + toString(maxWithdraw)) + "_from-test(amount):") + toString(amount)) + "_from-test(block-after-deposit):") + toString((frostBlockCount - (defrostBlockHeight - blockHeight)))) + "_from-test(sum-for-block):") + toString((oldAmount / frostBlockCount))))]), TransferSet([ScriptTransfer(i.caller, amount, unit)])) |
---|
59 | 57 | | } |
---|
60 | 58 | | |
---|
61 | 59 | | |
---|