tx · HwkvVKESTGvBf9KgrmBv1zMnRLmPJsJz8xuL868XZYJt 3N5CayN8CtoM2QuWDDDQFCPdiviGSt9GTpt: -0.01300000 Waves 2023.05.10 13:16 [2571656] smart account 3N5CayN8CtoM2QuWDDDQFCPdiviGSt9GTpt > SELF 0.00000000 Waves
{ "type": 13, "id": "HwkvVKESTGvBf9KgrmBv1zMnRLmPJsJz8xuL868XZYJt", "fee": 1300000, "feeAssetId": null, "timestamp": 1683713796949, "version": 2, "chainId": 84, "sender": "3N5CayN8CtoM2QuWDDDQFCPdiviGSt9GTpt", "senderPublicKey": "8z79nXR33yhmSzh8WGovFPyrSqSq4gYftBwUQBsc577Y", "proofs": [ "3MQKzYDWSjuu13tkgF4wbterGYeJ4NP9qbBjnKAjeFpVUfAWpyXmv4Xex2oHJok4Dp5YTnz9XEK1QUJxUoGtyHGF" ], "script": "base64:BgIICAISABIAEgAPAAxjb250cmFjdEZpbGUCD3Byb3h5X3BlcGUucmlkZQARa2V5c1dhdmVzQ29udHJhY3QCEiVzX19zV2F2ZXNDb250cmFjdAAQa2V5c1dhdmVzQXNzZXRJZAIRJXNfX3NXYXZlc0Fzc2V0SWQBD2dldFN0cmluZ09yRmFpbAEDa2V5CQETdmFsdWVPckVycm9yTWVzc2FnZQIJAJ0IAgUEdGhpcwUDa2V5CQCsAgICFU5vIGRhdGEgZm9yIHRoaXMua2V5PQUDa2V5ARNwZXBlQ29udHJhY3RBZGRyZXNzAAkBD2dldFN0cmluZ09yRmFpbAEFEWtleXNXYXZlc0NvbnRyYWN0AQ5zV2F2ZXNJZFN0cmluZwAJAQ9nZXRTdHJpbmdPckZhaWwBBRBrZXlzV2F2ZXNBc3NldElkAAxwZXBlQ29udHJhY3QJARFAZXh0ck5hdGl2ZSgxMDYyKQEJARNwZXBlQ29udHJhY3RBZGRyZXNzAAAGc1dhdmVzCQDZBAEJAQ5zV2F2ZXNJZFN0cmluZwABE2tleU1hbmFnZXJQdWJsaWNLZXkAAhQlc19fbWFuY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Y3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BAnR4AQZ2ZXJpZnkABA90YXJnZXRQdWJsaWNLZXkEByRtYXRjaDAJARZtYW5hZ2VyUHVibGljS2V5T3JVbml0AAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJwawUHJG1hdGNoMAUCcGsDCQABAgUHJG1hdGNoMAIEVW5pdAgFAnR4D3NlbmRlclB1YmxpY0tleQkAAgECC01hdGNoIGVycm9yCQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAABQ90YXJnZXRQdWJsaWNLZXmL8IHr", "height": 2571656, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 8KKaYQJyBhmR4Szt7XySQqXoPrzmEwNtyYRicDZPNp8x Next: none Diff:
Old | New | Differences | |
---|---|---|---|
26 | 26 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
27 | 27 | ||
28 | 28 | ||
29 | - | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
29 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
30 | + | case s: String => | |
31 | + | addressFromStringValue(s) | |
32 | + | case _ => | |
33 | + | this | |
34 | + | } | |
30 | 35 | ||
31 | 36 | ||
32 | 37 | func error (msg) = throw(((contractFile + ": ") + msg)) | |
33 | 38 | ||
34 | 39 | ||
35 | 40 | func managerPublicKeyOrUnit () = { | |
36 | - | let managerVaultAddress = | |
41 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
37 | 42 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
38 | 43 | case s: String => | |
39 | 44 | fromBase58String(s) |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let contractFile = "proxy_pepe.ride" | |
5 | 5 | ||
6 | 6 | let keysWavesContract = "%s__sWavesContract" | |
7 | 7 | ||
8 | 8 | let keysWavesAssetId = "%s__sWavesAssetId" | |
9 | 9 | ||
10 | 10 | func getStringOrFail (key) = valueOrErrorMessage(getString(this, key), ("No data for this.key=" + key)) | |
11 | 11 | ||
12 | 12 | ||
13 | 13 | func pepeContractAddress () = getStringOrFail(keysWavesContract) | |
14 | 14 | ||
15 | 15 | ||
16 | 16 | func sWavesIdString () = getStringOrFail(keysWavesAssetId) | |
17 | 17 | ||
18 | 18 | ||
19 | 19 | let pepeContract = addressFromStringValue(pepeContractAddress()) | |
20 | 20 | ||
21 | 21 | let sWaves = fromBase58String(sWavesIdString()) | |
22 | 22 | ||
23 | 23 | func keyManagerPublicKey () = "%s__managerPublicKey" | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyManagerVaultAddress () = "%s__managerVaultAddress" | |
27 | 27 | ||
28 | 28 | ||
29 | - | func getManagerAddressOrFail () = addressFromStringValue(getStringValue(keyManagerVaultAddress())) | |
29 | + | func getManagerVaultAddressOrThis () = match getString(keyManagerVaultAddress()) { | |
30 | + | case s: String => | |
31 | + | addressFromStringValue(s) | |
32 | + | case _ => | |
33 | + | this | |
34 | + | } | |
30 | 35 | ||
31 | 36 | ||
32 | 37 | func error (msg) = throw(((contractFile + ": ") + msg)) | |
33 | 38 | ||
34 | 39 | ||
35 | 40 | func managerPublicKeyOrUnit () = { | |
36 | - | let managerVaultAddress = | |
41 | + | let managerVaultAddress = getManagerVaultAddressOrThis() | |
37 | 42 | match getString(managerVaultAddress, keyManagerPublicKey()) { | |
38 | 43 | case s: String => | |
39 | 44 | fromBase58String(s) | |
40 | 45 | case _: Unit => | |
41 | 46 | unit | |
42 | 47 | case _ => | |
43 | 48 | throw("Match error") | |
44 | 49 | } | |
45 | 50 | } | |
46 | 51 | ||
47 | 52 | ||
48 | 53 | func isManager (i) = match managerPublicKeyOrUnit() { | |
49 | 54 | case pk: ByteVector => | |
50 | 55 | (i.callerPublicKey == pk) | |
51 | 56 | case _: Unit => | |
52 | 57 | (i.caller == this) | |
53 | 58 | case _ => | |
54 | 59 | throw("Match error") | |
55 | 60 | } | |
56 | 61 | ||
57 | 62 | ||
58 | 63 | func mustManager (i) = if (isManager(i)) | |
59 | 64 | then true | |
60 | 65 | else throw("permission denied") | |
61 | 66 | ||
62 | 67 | ||
63 | 68 | @Callable(i) | |
64 | 69 | func getRate () = { | |
65 | 70 | let results = invoke(pepeContract, "getRate", nil, nil) | |
66 | 71 | match results { | |
67 | 72 | case t: String => | |
68 | 73 | $Tuple2(nil, parseIntValue(t)) | |
69 | 74 | case _ => | |
70 | 75 | error("getRate(): unexpected return") | |
71 | 76 | } | |
72 | 77 | } | |
73 | 78 | ||
74 | 79 | ||
75 | 80 | ||
76 | 81 | @Callable(i) | |
77 | 82 | func deposit () = { | |
78 | 83 | let startBalance = assetBalance(this, sWaves) | |
79 | 84 | if ((startBalance == startBalance)) | |
80 | 85 | then { | |
81 | 86 | let results = invoke(pepeContract, "deposit", nil, i.payments) | |
82 | 87 | if ((results == results)) | |
83 | 88 | then { | |
84 | 89 | let newBalance = assetBalance(this, sWaves) | |
85 | 90 | let sendAmount = (newBalance - startBalance) | |
86 | 91 | $Tuple2([ScriptTransfer(i.caller, sendAmount, sWaves)], sendAmount) | |
87 | 92 | } | |
88 | 93 | else throw("Strict value is not equal to itself.") | |
89 | 94 | } | |
90 | 95 | else throw("Strict value is not equal to itself.") | |
91 | 96 | } | |
92 | 97 | ||
93 | 98 | ||
94 | 99 | ||
95 | 100 | @Callable(i) | |
96 | 101 | func withdraw () = { | |
97 | 102 | let startBalance = wavesBalance(this).available | |
98 | 103 | if ((startBalance == startBalance)) | |
99 | 104 | then { | |
100 | 105 | let results = invoke(pepeContract, "withdraw", nil, i.payments) | |
101 | 106 | if ((results == results)) | |
102 | 107 | then { | |
103 | 108 | let newBalance = wavesBalance(this).available | |
104 | 109 | let sendAmount = (newBalance - startBalance) | |
105 | 110 | $Tuple2([ScriptTransfer(i.caller, sendAmount, unit)], sendAmount) | |
106 | 111 | } | |
107 | 112 | else throw("Strict value is not equal to itself.") | |
108 | 113 | } | |
109 | 114 | else throw("Strict value is not equal to itself.") | |
110 | 115 | } | |
111 | 116 | ||
112 | 117 | ||
113 | 118 | @Verifier(tx) | |
114 | 119 | func verify () = { | |
115 | 120 | let targetPublicKey = match managerPublicKeyOrUnit() { | |
116 | 121 | case pk: ByteVector => | |
117 | 122 | pk | |
118 | 123 | case _: Unit => | |
119 | 124 | tx.senderPublicKey | |
120 | 125 | case _ => | |
121 | 126 | throw("Match error") | |
122 | 127 | } | |
123 | 128 | sigVerify(tx.bodyBytes, tx.proofs[0], targetPublicKey) | |
124 | 129 | } | |
125 | 130 |
github/deemru/w8io/026f985 21.17 ms ◑