tx · 7GwfEHQ37WfsNB7QZi1QFpLFnvB4RrC7fekWsta2BZ6s 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy: -0.01000000 Waves 2022.11.05 21:03 [2304142] smart account 3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy > SELF 0.00000000 Waves
{ "type": 13, "id": "7GwfEHQ37WfsNB7QZi1QFpLFnvB4RrC7fekWsta2BZ6s", "fee": 1000000, "feeAssetId": null, "timestamp": 1667671445124, "version": 2, "chainId": 84, "sender": "3N1JYSyNP7mn7f1YTZ2aRdi6ThpKw23j9Sy", "senderPublicKey": "65hdh3BQVcB4NhB1URp1RBWMK7AWDhrCSVjwbFjS64jo", "proofs": [ "5pTk4oqmhGYTbVeYQXUqMSP5ezqi9gGi1KRKVmHy3DkzWW8EWmYigbB1pfev2JMLrWmx2Ce5JMbpXcKy3yGdiWko" ], "script": "base64:AAIFAAAAAAAAAAsIAhIDCgEIEgASAAAAAAUAAAAACXByZWNpc2lvbgAN4Lazp2QAAAEAAAATa2V5TWFuYWdlclB1YmxpY0tleQAAAAAJAAQiAAAAAQIAAAAQbWFuYWdlclB1YmxpY0tleQEAAAAWbWFuYWdlclB1YmxpY0tleU9yVW5pdAAAAAAEAAAAByRtYXRjaDAJAQAAABNrZXlNYW5hZ2VyUHVibGljS2V5AAAAAAMJAAABAAAAAgUAAAAHJG1hdGNoMAIAAAAGU3RyaW5nBAAAAAFzBQAAAAckbWF0Y2gwCQACWQAAAAEFAAAAAXMDCQAAAQAAAAIFAAAAByRtYXRjaDACAAAABFVuaXQFAAAABHVuaXQJAAACAAAAAQIAAAALTWF0Y2ggZXJyb3IBAAAAC211c3RNYW5hZ2VyAAAAAQAAAAFpBAAAAAJwZAkAAAIAAAABAgAAABFwZXJtaXNzaW9uIGRlbmllZAQAAAAHJG1hdGNoMAkBAAAAFm1hbmFnZXJQdWJsaWNLZXlPclVuaXQAAAAAAwkAAAEAAAACBQAAAAckbWF0Y2gwAgAAAApC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W50BQAAAAluZXdBbW91bnQFAAAAA25pbAkABEwAAAACCQEAAAALRGVsZXRlRW50cnkAAAABAgAAAAdsZWFzZUlkCQAETAAAAAIJAQAAAAxJbnRlZ2VyRW50cnkAAAACAgAAAAxsZWFzZWRBbW91bnQAAAAAAAAAAAAFAAAAA25pbAQAAAAHcmVzdWx0cwkABEwAAAACCQEAAAALTGVhc2VDYW5jZWwAAAABBQAAAAdsZWFzZUlkCQAETAAAAAIJAQAAAARCdXJuAAAAAgUAAAANc1dhdmVzQXNzZXRJZAgFAAAAB3BheW1lbnQAAAAGYW1vdW50CQAETAAAAAIJAQAAAA5TY3JpcHRUcmFuc2ZlcgAAAAMIBQAAAAFpAAAABmNhbGxlcgUAAAAKdG9UcmFuc2ZlcgUAAAAEdW5pdAUAAAADbmlsCQAETgAAAAIFAAAAB3Jlc3VsdHMFAAAADGxlYXNlUmVzdWx0cwAAAAEAAAACdHgBAAAABnZlcmlmeQAAAAAJAAH0AAAAAwgFAAAAAnR4AAAACWJvZHlCeXRlcwkAAZEAAAACCAUAAAACdHgAAAAGcHJvb2ZzAAAAAAAAAAAACAUAAAACdHgAAAAPc2VuZGVyUHVibGljS2V56caKiQ==", "height": 2304142, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 5q2uHhyUo3db3yprrkoeKnrfNFvbNodv1wPBrzq33FeB Next: Bp5Yuxvbn25WXotYiA4aVECsXpPCo2Na21rbRjCsGrN4 Diff:
Old | New | Differences | |
---|---|---|---|
111 | 111 | let newLeaseId = calculateLeaseId(lease) | |
112 | 112 | [lease, BinaryEntry("leaseId", newLeaseId), IntegerEntry("leasedAmount", newAmount)] | |
113 | 113 | } | |
114 | - | else [DeleteEntry("leaseId")] | |
114 | + | else [DeleteEntry("leaseId"), IntegerEntry("leasedAmount", 0)] | |
115 | 115 | let results = [LeaseCancel(leaseId), Burn(sWavesAssetId, payment.amount), ScriptTransfer(i.caller, toTransfer, unit)] | |
116 | 116 | (results ++ leaseResults) | |
117 | 117 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let precision = 1000000000000000000 | |
5 | 5 | ||
6 | 6 | func keyManagerPublicKey () = getString("managerPublicKey") | |
7 | 7 | ||
8 | 8 | ||
9 | 9 | func managerPublicKeyOrUnit () = match keyManagerPublicKey() { | |
10 | 10 | case s: String => | |
11 | 11 | fromBase58String(s) | |
12 | 12 | case _: Unit => | |
13 | 13 | unit | |
14 | 14 | case _ => | |
15 | 15 | throw("Match error") | |
16 | 16 | } | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | func mustManager (i) = { | |
20 | 20 | let pd = throw("permission denied") | |
21 | 21 | match managerPublicKeyOrUnit() { | |
22 | 22 | case pk: ByteVector => | |
23 | 23 | if ((i.callerPublicKey == pk)) | |
24 | 24 | then true | |
25 | 25 | else pd | |
26 | 26 | case _: Unit => | |
27 | 27 | if ((i.caller == this)) | |
28 | 28 | then true | |
29 | 29 | else pd | |
30 | 30 | case _ => | |
31 | 31 | throw("Match error") | |
32 | 32 | } | |
33 | 33 | } | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func mustNotInited () = match getBoolean("inited") { | |
37 | 37 | case inited: Boolean => | |
38 | 38 | if ((inited == false)) | |
39 | 39 | then true | |
40 | 40 | else throw("Already inited") | |
41 | 41 | case _: Unit => | |
42 | 42 | false | |
43 | 43 | case _ => | |
44 | 44 | throw("Match error") | |
45 | 45 | } | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | @Callable(i) | |
49 | 49 | func init (leaserAddress) = { | |
50 | 50 | let checks = [mustManager(i), mustNotInited()] | |
51 | 51 | if ((checks == checks)) | |
52 | 52 | then { | |
53 | 53 | let sWaves = Issue("sWaves", "", 0, 8, true, unit, 0) | |
54 | 54 | let sWavesAssetId = calculateAssetId(sWaves) | |
55 | 55 | [BooleanEntry("inited", true), StringEntry("sWavesAssetId", toBase58String(sWavesAssetId)), StringEntry("leaserAddress", leaserAddress), IntegerEntry("ratio", precision), IntegerEntry("leasedAmount", 0), sWaves] | |
56 | 56 | } | |
57 | 57 | else throw("Strict value is not equal to itself.") | |
58 | 58 | } | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | ||
62 | 62 | @Callable(i) | |
63 | 63 | func stake () = { | |
64 | 64 | let payment = i.payments[0] | |
65 | 65 | if ((payment.assetId != unit)) | |
66 | 66 | then throw("Only WAVES supported") | |
67 | 67 | else if ((size(i.payments) != 1)) | |
68 | 68 | then throw("Wrong payments amount") | |
69 | 69 | else { | |
70 | 70 | let ratio = getIntegerValue("ratio") | |
71 | 71 | let toReissue = fraction(payment.amount, precision, ratio) | |
72 | 72 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
73 | 73 | let leasedAmount = getIntegerValue("leasedAmount") | |
74 | 74 | let newAmount = (leasedAmount + payment.amount) | |
75 | 75 | let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress"))) | |
76 | 76 | let lease = Lease(leaserAddress, newAmount) | |
77 | 77 | let newLeaseId = calculateLeaseId(lease) | |
78 | 78 | let results = [BinaryEntry("leaseId", newLeaseId), lease, IntegerEntry("leasedAmount", newAmount), Reissue(sWavesAssetId, toReissue, true), ScriptTransfer(i.caller, toReissue, sWavesAssetId)] | |
79 | 79 | match getBinary("leaseId") { | |
80 | 80 | case leaseId: ByteVector => | |
81 | 81 | LeaseCancel(leaseId) :: results | |
82 | 82 | case _: Unit => | |
83 | 83 | results | |
84 | 84 | case _ => | |
85 | 85 | throw("Match error") | |
86 | 86 | } | |
87 | 87 | } | |
88 | 88 | } | |
89 | 89 | ||
90 | 90 | ||
91 | 91 | ||
92 | 92 | @Callable(i) | |
93 | 93 | func unstake () = { | |
94 | 94 | let payment = i.payments[0] | |
95 | 95 | let sWavesAssetId = fromBase58String(getStringValue("sWavesAssetId")) | |
96 | 96 | if ((payment.assetId != sWavesAssetId)) | |
97 | 97 | then throw("Only sWAVES supported") | |
98 | 98 | else if ((size(i.payments) != 1)) | |
99 | 99 | then throw("Wrong payments amount") | |
100 | 100 | else { | |
101 | 101 | let ratio = getIntegerValue("ratio") | |
102 | 102 | let toTransfer = fraction(payment.amount, ratio, precision) | |
103 | 103 | let assetId = getStringValue("internalAssetId") | |
104 | 104 | let leasedAmount = getIntegerValue("leasedAmount") | |
105 | 105 | let newAmount = (leasedAmount - toTransfer) | |
106 | 106 | let leaseId = getBinaryValue("leaseId") | |
107 | 107 | let leaseResults = if ((newAmount > 0)) | |
108 | 108 | then { | |
109 | 109 | let leaserAddress = Address(fromBase58String(getStringValue("leaserAddress"))) | |
110 | 110 | let lease = Lease(leaserAddress, newAmount) | |
111 | 111 | let newLeaseId = calculateLeaseId(lease) | |
112 | 112 | [lease, BinaryEntry("leaseId", newLeaseId), IntegerEntry("leasedAmount", newAmount)] | |
113 | 113 | } | |
114 | - | else [DeleteEntry("leaseId")] | |
114 | + | else [DeleteEntry("leaseId"), IntegerEntry("leasedAmount", 0)] | |
115 | 115 | let results = [LeaseCancel(leaseId), Burn(sWavesAssetId, payment.amount), ScriptTransfer(i.caller, toTransfer, unit)] | |
116 | 116 | (results ++ leaseResults) | |
117 | 117 | } | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | @Verifier(tx) | |
122 | 122 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
123 | 123 |
github/deemru/w8io/03bedc9 85.56 ms ◑![]()