tx · 4RVNdkzG28UGL3SwiGqBYrZa5S4U29cumRBA6mhp97zh 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY: -0.01000000 Waves 2022.11.22 21:42 [2328694] smart account 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY > SELF 0.00000000 Waves
{ "type": 13, "id": "4RVNdkzG28UGL3SwiGqBYrZa5S4U29cumRBA6mhp97zh", "fee": 1000000, "feeAssetId": null, "timestamp": 1669142619858, "version": 2, "chainId": 84, "sender": "3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY", "senderPublicKey": "9rkQ1ChfNZ585cJFqVhjLk1mTNMXT93CZidHoYERtHML", "proofs": [ "3yjUuudwEjnHFqGZupgKZDxng4HLKJy4Qw21N2mpgegvcJaLmDezTFKKMaQ1oYKsXWKfFqTeniTVqYY6N5yKkGGh" ], "script": "base64:BgIaCAISBAoCCAgSAwoBCBIDCgEIEgYKBAgIAQEUAANTRVACAl9fAAVFTVBUWQIAAAlQUkVDSVNJT04AgICQu7rWrfANAAhERUNJTUFMUwCAwtcvAAlXRVNUX1BBUlQJAGkCBQlQUkVDSVNJT04ABQELa2V5QXNzZXRDZmcBDGJhc2VBc3NldFN0cgkAuQkCCQDMCAICBiVzJXMlcwkAzAgCAgZjb25maWcJAMwIAgIFYXNzZXQJAMwIAgUMYmFzZUFzc2V0U3RyBQNuaWwFA1NFUAEOa2V5SW5pdGlhbGl6ZWQACQC5CQIJAMwIAgICJXMJAMwIAgILaW5pdGlhbGl6ZWQFA25pbAUDU0VQAQhrZXlBZG1pbgAJALkJAgkAzAgCAgIlcwkAzAgCAgVhZG1pbgUDbmlsBQNTRVABDGtleUVhc3RBc3NldAAJALkJAgkAzAgCAgIlcwkAzAgCAgllYXN0QXNzZXQFA25pbAUDU0VQAQxrZXlXZXN0QXNzZXQACQC5CQIJAMwIAgICJXMJAMwIAgIJd2VzdEFzc2V0BQNuaWwFA1NFUAEPa2V5QXNzZXRTdG9yYWdlAAkAuQkCCQDMCA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VlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAQJ0eAEGdmVyaWZ5AAkA9AMDCAUCdHgJYm9keUJ5dGVzCQCRAwIIBQJ0eAZwcm9vZnMAAAgFAnR4D3NlbmRlclB1YmxpY0tleaz0UT0=", "height": 2328694, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9PwexppAvEuzWqshMVjCXUg6mhJG49fn6UtqMGh2tYJo Next: BHv9ZgHxzBHTkXFoZnTLUvbeBZPRYcVjfMRvBfdJAAjD Diff:
Old | New | Differences | |
---|---|---|---|
102 | 102 | ||
103 | 103 | @Callable(i) | |
104 | 104 | func setAdmin (_address) = { | |
105 | - | let isAddressCorrect = | |
105 | + | let isAddressCorrect = addressFromStringValue(_address) | |
106 | 106 | if ((isAddressCorrect == isAddressCorrect)) | |
107 | 107 | then [StringEntry(keyAdmin(), _address)] | |
108 | 108 | else throw("Strict value is not equal to itself.") |
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 | 104 | func setAdmin (_address) = { | |
105 | - | let isAddressCorrect = | |
105 | + | let isAddressCorrect = addressFromStringValue(_address) | |
106 | 106 | if ((isAddressCorrect == isAddressCorrect)) | |
107 | 107 | then [StringEntry(keyAdmin(), _address)] | |
108 | 108 | else throw("Strict value is not equal to itself.") | |
109 | 109 | } | |
110 | 110 | ||
111 | 111 | ||
112 | 112 | ||
113 | 113 | @Callable(i) | |
114 | 114 | func adminSetAssetStorage (_address) = { | |
115 | 115 | let check = if (initialized()) | |
116 | 116 | then mustAdmin(i) | |
117 | 117 | else false | |
118 | 118 | if ((check == check)) | |
119 | 119 | then if (!(check)) | |
120 | 120 | then throw("Not allowed") | |
121 | 121 | else [StringEntry(keyAssetStorage(), _address)] | |
122 | 122 | else throw("Strict value is not equal to itself.") | |
123 | 123 | } | |
124 | 124 | ||
125 | 125 | ||
126 | 126 | ||
127 | 127 | @Callable(i) | |
128 | 128 | func adminSetAsset (_assetId,_contractId,_backingRatio,_liquidationCollateral) = { | |
129 | 129 | let inited = if (initialized()) | |
130 | 130 | then mustAdmin(i) | |
131 | 131 | else false | |
132 | 132 | if ((inited == inited)) | |
133 | 133 | then if (!(inited)) | |
134 | 134 | then throw("Not allowed") | |
135 | 135 | else { | |
136 | 136 | let westAssetId = getStringValue(keyWestAsset()) | |
137 | 137 | if ((westAssetId == _assetId)) | |
138 | 138 | then throw("West asset is not allowed") | |
139 | 139 | else { | |
140 | 140 | let checks = [checkContractAndAsset(_assetId, _contractId), checkRanges(_backingRatio), checkRanges(_liquidationCollateral)] | |
141 | 141 | if ((checks == checks)) | |
142 | 142 | then { | |
143 | 143 | let assetCfg = dataAssetCfg(_contractId, _assetId, _backingRatio, _liquidationCollateral) | |
144 | 144 | [StringEntry(keyAssetCfg(_assetId), assetCfg)] | |
145 | 145 | } | |
146 | 146 | else throw("Strict value is not equal to itself.") | |
147 | 147 | } | |
148 | 148 | } | |
149 | 149 | else throw("Strict value is not equal to itself.") | |
150 | 150 | } | |
151 | 151 | ||
152 | 152 | ||
153 | 153 | @Verifier(tx) | |
154 | 154 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
155 | 155 |
github/deemru/w8io/026f985 25.89 ms ◑