tx · 9PwexppAvEuzWqshMVjCXUg6mhJG49fn6UtqMGh2tYJo 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY: -0.01000000 Waves 2022.11.22 21:42 [2328694] smart account 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY > SELF 0.00000000 Waves
{ "type": 13, "id": "9PwexppAvEuzWqshMVjCXUg6mhJG49fn6UtqMGh2tYJo", "fee": 1000000, "feeAssetId": null, "timestamp": 1669142546629, "version": 2, "chainId": 84, "sender": "3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY", "senderPublicKey": "9rkQ1ChfNZ585cJFqVhjLk1mTNMXT93CZidHoYERtHML", "proofs": [ "YViiGutBmSqCoh3QR2mqVL8LDTCztzMjD4Av7m448acG4xs3dKCn6gn6D8FwhDRT57gYPFdbjUJ6KBWwh1Yvavb" ], "script": "base64:BgIaCAISBAoCCAgSAwoBCBIDCgEIEgYKBAgIAQEUAANTRVACAl9fAAVFTVBUWQIAAAlQUkVDSVNJT04AgICQu7rWrfANAAhERUNJTUFMUwCAwtcvAAlXRVNUX1BBUlQJAGkCBQlQUkVDSVNJT04ABQELa2V5QXNzZXRDZmcBDGJhc2VBc3NldFN0cgkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgZjb25maWcJAMwIAgIFYXNzZXQJAMwIAgUMYmFzZUFzc2V0U3RyBQNuaWwFA1NFUAEOa2V5SW5pdGlhbGl6ZWQACQC5CQIJAMwIAgICJXMJAMwIAgILaW5pdGlhbGl6ZWQFA25pbAUDU0VQAQhrZXlBZG1pbgAJALkJAgkAzAgCAgIlcwkAzAgCAgVhZG1pbgUDbmlsBQNTRVABDGtleUVhc3RBc3NldAAJALkJAgkAzAgCAgIlcwkAzAgCAgllYXN0QXNzZXQFA25pbAUDU0VQAQxrZXlXZXN0QXNzZXQACQC5CQIJAMwIAgICJXMJAMwIAgIJd2VzdEFzc2V0BQNuaWwFA1NFUAEPa2V5QXNzZXRTdG9yYWdlAAkAuQkCCQDMCAICA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XF1YWwgdG8gaXRzZWxmLgECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkK0nU4", "height": 2328694, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6a7JYocrJow4W7uQF54hFEMez5X5kmbhosamSNeCSw5N Next: 4RVNdkzG28UGL3SwiGqBYrZa5S4U29cumRBA6mhp97zh Diff:
Old | New | Differences | |
---|---|---|---|
101 | 101 | ||
102 | 102 | ||
103 | 103 | @Callable(i) | |
104 | - | func setAdmin (_address) = [StringEntry(keyAdmin(), _address)] | |
104 | + | func setAdmin (_address) = { | |
105 | + | let isAddressCorrect = Address(fromBase58String(_address)) | |
106 | + | if ((isAddressCorrect == isAddressCorrect)) | |
107 | + | then [StringEntry(keyAdmin(), _address)] | |
108 | + | else throw("Strict value is not equal to itself.") | |
109 | + | } | |
105 | 110 | ||
106 | 111 | ||
107 | 112 |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 6 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let SEP = "__" | |
5 | 5 | ||
6 | 6 | let EMPTY = "" | |
7 | 7 | ||
8 | 8 | let PRECISION = 1000000000000000000 | |
9 | 9 | ||
10 | 10 | let DECIMALS = 100000000 | |
11 | 11 | ||
12 | 12 | let WEST_PART = (PRECISION / 5) | |
13 | 13 | ||
14 | 14 | func keyAssetCfg (baseAssetStr) = makeString(["%s%s%s", "config", "asset", baseAssetStr], SEP) | |
15 | 15 | ||
16 | 16 | ||
17 | 17 | func keyInitialized () = makeString(["%s", "initialized"], SEP) | |
18 | 18 | ||
19 | 19 | ||
20 | 20 | func keyAdmin () = makeString(["%s", "admin"], SEP) | |
21 | 21 | ||
22 | 22 | ||
23 | 23 | func keyEastAsset () = makeString(["%s", "eastAsset"], SEP) | |
24 | 24 | ||
25 | 25 | ||
26 | 26 | func keyWestAsset () = makeString(["%s", "westAsset"], SEP) | |
27 | 27 | ||
28 | 28 | ||
29 | 29 | func keyAssetStorage () = makeString(["%s", "assetStorage"], SEP) | |
30 | 30 | ||
31 | 31 | ||
32 | 32 | func keyBAssetId () = "B_asset_id" | |
33 | 33 | ||
34 | 34 | ||
35 | 35 | func dataAssetCfg (_contractId,_assetId,_backingRatio,_liquidationCollateral) = makeString(["%s%s%d%d", _contractId, _assetId, toString(_backingRatio), toString(_liquidationCollateral)], SEP) | |
36 | 36 | ||
37 | 37 | ||
38 | 38 | func initialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
39 | 39 | ||
40 | 40 | ||
41 | 41 | func isOwner (i) = (this == i.caller) | |
42 | 42 | ||
43 | 43 | ||
44 | 44 | func adminAddressOrUnit () = match getString(this, keyAdmin()) { | |
45 | 45 | case s: String => | |
46 | 46 | Address(fromBase58String(s)) | |
47 | 47 | case _: Unit => | |
48 | 48 | unit | |
49 | 49 | case _ => | |
50 | 50 | throw("Match error") | |
51 | 51 | } | |
52 | 52 | ||
53 | 53 | ||
54 | 54 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
55 | 55 | ||
56 | 56 | ||
57 | 57 | func mustAdmin (i) = { | |
58 | 58 | let pd = throw("permission denied") | |
59 | 59 | match adminAddressOrUnit() { | |
60 | 60 | case address: Address => | |
61 | 61 | if ((i.caller == address)) | |
62 | 62 | then true | |
63 | 63 | else pd | |
64 | 64 | case _: Unit => | |
65 | 65 | if ((i.caller == this)) | |
66 | 66 | then true | |
67 | 67 | else pd | |
68 | 68 | case _ => | |
69 | 69 | throw("Match error") | |
70 | 70 | } | |
71 | 71 | } | |
72 | 72 | ||
73 | 73 | ||
74 | 74 | func checkContractAndAsset (_assetId,_contractId) = { | |
75 | 75 | let contractId = Address(fromBase58String(_contractId)) | |
76 | 76 | let assetId = valueOrErrorMessage(getString(contractId, keyBAssetId()), "Wrong contract id") | |
77 | 77 | if ((assetId != _assetId)) | |
78 | 78 | then throw("Wrong asset id") | |
79 | 79 | else nil | |
80 | 80 | } | |
81 | 81 | ||
82 | 82 | ||
83 | 83 | func checkRanges (value) = if (if ((value > 0)) | |
84 | 84 | then (300 > value) | |
85 | 85 | else false) | |
86 | 86 | then true | |
87 | 87 | else throw("Out of range") | |
88 | 88 | ||
89 | 89 | ||
90 | 90 | @Callable(i) | |
91 | 91 | func initialize (_assetStoreAddress,_westAssetId) = if (if (initialized()) | |
92 | 92 | then isOwner(i) | |
93 | 93 | else false) | |
94 | 94 | then throw("Not allowed") | |
95 | 95 | else { | |
96 | 96 | let east = Issue("East", "", 0, 8, true, unit, 0) | |
97 | 97 | let _eastAssetId = calculateAssetId(east) | |
98 | 98 | [StringEntry(keyEastAsset(), toBase58String(_eastAssetId)), StringEntry(keyWestAsset(), _westAssetId), BooleanEntry(keyInitialized(), true)] | |
99 | 99 | } | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | ||
103 | 103 | @Callable(i) | |
104 | - | func setAdmin (_address) = [StringEntry(keyAdmin(), _address)] | |
104 | + | func setAdmin (_address) = { | |
105 | + | let isAddressCorrect = Address(fromBase58String(_address)) | |
106 | + | if ((isAddressCorrect == isAddressCorrect)) | |
107 | + | then [StringEntry(keyAdmin(), _address)] | |
108 | + | else throw("Strict value is not equal to itself.") | |
109 | + | } | |
105 | 110 | ||
106 | 111 | ||
107 | 112 | ||
108 | 113 | @Callable(i) | |
109 | 114 | func adminSetAssetStorage (_address) = { | |
110 | 115 | let check = if (initialized()) | |
111 | 116 | then mustAdmin(i) | |
112 | 117 | else false | |
113 | 118 | if ((check == check)) | |
114 | 119 | then if (!(check)) | |
115 | 120 | then throw("Not allowed") | |
116 | 121 | else [StringEntry(keyAssetStorage(), _address)] | |
117 | 122 | else throw("Strict value is not equal to itself.") | |
118 | 123 | } | |
119 | 124 | ||
120 | 125 | ||
121 | 126 | ||
122 | 127 | @Callable(i) | |
123 | 128 | func adminSetAsset (_assetId,_contractId,_backingRatio,_liquidationCollateral) = { | |
124 | 129 | let inited = if (initialized()) | |
125 | 130 | then mustAdmin(i) | |
126 | 131 | else false | |
127 | 132 | if ((inited == inited)) | |
128 | 133 | then if (!(inited)) | |
129 | 134 | then throw("Not allowed") | |
130 | 135 | else { | |
131 | 136 | let westAssetId = getStringValue(keyWestAsset()) | |
132 | 137 | if ((westAssetId == _assetId)) | |
133 | 138 | then throw("West asset is not allowed") | |
134 | 139 | else { | |
135 | 140 | let checks = [checkContractAndAsset(_assetId, _contractId), checkRanges(_backingRatio), checkRanges(_liquidationCollateral)] | |
136 | 141 | if ((checks == checks)) | |
137 | 142 | then { | |
138 | 143 | let assetCfg = dataAssetCfg(_contractId, _assetId, _backingRatio, _liquidationCollateral) | |
139 | 144 | [StringEntry(keyAssetCfg(_assetId), assetCfg)] | |
140 | 145 | } | |
141 | 146 | else throw("Strict value is not equal to itself.") | |
142 | 147 | } | |
143 | 148 | } | |
144 | 149 | else throw("Strict value is not equal to itself.") | |
145 | 150 | } | |
146 | 151 | ||
147 | 152 | ||
148 | 153 | @Verifier(tx) | |
149 | 154 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
150 | 155 |
github/deemru/w8io/026f985 22.91 ms ◑