tx · 4TgRwQ2rZ6jxcA7u1rDp4SHVvoGxomJ7qENhAs5dt3Wo 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY: -0.01000000 Waves 2022.11.23 00:10 [2328853] smart account 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY > SELF 0.00000000 Waves
{ "type": 13, "id": "4TgRwQ2rZ6jxcA7u1rDp4SHVvoGxomJ7qENhAs5dt3Wo", "fee": 1000000, "feeAssetId": null, "timestamp": 1669151479999, "version": 2, "chainId": 84, "sender": "3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY", "senderPublicKey": "9rkQ1ChfNZ585cJFqVhjLk1mTNMXT93CZidHoYERtHML", "proofs": [ "4SW7PqPy5ZsJSEPeAVK94AwmyFxj4Xj1hWv7FbNbV3XBnnq7yqQCkRgQb1m89m4nXZ1JakozmECo8wQat924BELA" ], "script": "base64:BgIXCAISBAoCCAgSAwoBCBIGCgQICAEBEgAYAANTRVACAl9fAAVFTVBUWQIAAAlQUkVDSVNJT04AgICQu7rWrfANAAhERUNJTUFMUwCAwtcvAAlXRVNUX1BBUlQJAGkCBQlQUkVDSVNJT04ABQAQSWR4QXNzZXRDb250cmFjdAABABRJZHhBc3NldEJhY2tpbmdSYXRpbwACAQtrZXlBc3NldENmZwEMYmFzZUFzc2V0U3RyCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICBmNvbmZpZwkAzAgCAgVhc3NldAkAzAgCBQxiYXNlQXNzZXRTdHIFA25pbAUDU0VQAQ5rZXlJbml0aWFsaXplZAAJALkJAgkAzAgCAgIlcwkAzAgCAgtpbml0aWFsaXplZAUDbmlsBQNTRVABCGtleUFkbWluAAkAuQkCCQDMCAICAiVzCQDMCAICBWFkbWluBQNuaWwFA1NFUAEMa2V5RWFzdEFzc2V0AAkAuQkCCQDMCAICAiVzCQDMCAICCWVhc3RBc3NldAUDbmlsBQNTRVABDGtleVdlc3RBc3NldAAJALkJAgkAzAgCAgIlcwkAzAgCAgl3ZXN0QXN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q2ZnBQNuaWwJAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAIBAiRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4BaQEEbWludAAEB3BheW1lbnQJAJEDAggFAWkIcGF5bWVudHMAAAMJAQIhPQIJAJADAQgFAWkIcGF5bWVudHMAAQkAAgECFVdyb25nIHBheW1lbnRzIGFtb3VudAQHYXNzZXRJZAQHJG1hdGNoMAgFB3BheW1lbnQHYXNzZXRJZAMJAAECBQckbWF0Y2gwAgpCeXRlVmVjdG9yBAJpZAUHJG1hdGNoMAkA2AQBBQJpZAMJAAECBQckbWF0Y2gwAgRVbml0BAV3YXZlcwUHJG1hdGNoMAIFV0FWRVMJAAIBAgtNYXRjaCBlcnJvcgQIYXNzZXRDZmcJALUJAgkBE3ZhbHVlT3JFcnJvck1lc3NhZ2UCCQCiCAEJAQtrZXlBc3NldENmZwEFB2Fzc2V0SWQCDVVua25vd24gYXNzZXQFA1NFUAQKY29udHJhY3RJZAkAkQMCBQhhc3NldENmZwUQSWR4QXNzZXRDb250cmFjdAQMYmFja2luZ1JhdGlvCQCRAwIFCGFzc2V0Q2ZnBRRJZHhBc3NldEJhY2tpbmdSYXRpbwQBeAkAAgEJAKwCAgUKY29udHJhY3RJZAUMYmFja2luZ1JhdGlvBQNuaWwBAnR4AQZ2ZXJpZnkACQD0AwMIBQJ0eAlib2R5Qnl0ZXMJAJEDAggFAnR4BnByb29mcwAACAUCdHgPc2VuZGVyUHVibGljS2V5Xwznug==", "height": 2328853, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: C5oyaBp1iehmgGE7G72THfrhpKjSYgMGcSgxmVkzJSCk Next: Hj4M7iET1tsJWeQy8Le2kunqrVvPf9guYdjaXza1wSCT Diff:
Old | New | Differences | |
---|---|---|---|
81 | 81 | func checkContractAndAsset (_assetId,_contractId) = { | |
82 | 82 | let contractId = Address(fromBase58String(_contractId)) | |
83 | 83 | let assetId = valueOrErrorMessage(getString(contractId, keyBAssetId()), "Wrong contract id") | |
84 | - | if (if ((assetId != "WAVES")) | |
84 | + | if (if ((_assetId != "WAVES")) | |
85 | 85 | then (assetId != _assetId) | |
86 | 86 | else false) | |
87 | 87 | then throw("Wrong asset id") |
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 | let IdxAssetContract = 1 | |
15 | 15 | ||
16 | 16 | let IdxAssetBackingRatio = 2 | |
17 | 17 | ||
18 | 18 | func keyAssetCfg (baseAssetStr) = makeString(["%s%s%s", "config", "asset", baseAssetStr], SEP) | |
19 | 19 | ||
20 | 20 | ||
21 | 21 | func keyInitialized () = makeString(["%s", "initialized"], SEP) | |
22 | 22 | ||
23 | 23 | ||
24 | 24 | func keyAdmin () = makeString(["%s", "admin"], SEP) | |
25 | 25 | ||
26 | 26 | ||
27 | 27 | func keyEastAsset () = makeString(["%s", "eastAsset"], SEP) | |
28 | 28 | ||
29 | 29 | ||
30 | 30 | func keyWestAsset () = makeString(["%s", "westAsset"], SEP) | |
31 | 31 | ||
32 | 32 | ||
33 | 33 | func keyAssetStorage () = makeString(["%s", "assetStorage"], SEP) | |
34 | 34 | ||
35 | 35 | ||
36 | 36 | func keyBAssetId () = "B_asset_id" | |
37 | 37 | ||
38 | 38 | ||
39 | 39 | func dataAssetCfg (_assetId,_contractId,_backingRatio,_liquidationCollateral) = makeString(["%s%s%d%d", _assetId, _contractId, toString(_backingRatio), toString(_liquidationCollateral)], SEP) | |
40 | 40 | ||
41 | 41 | ||
42 | 42 | func initialized () = valueOrElse(getBoolean(this, keyInitialized()), false) | |
43 | 43 | ||
44 | 44 | ||
45 | 45 | func isOwner (i) = (this == i.caller) | |
46 | 46 | ||
47 | 47 | ||
48 | 48 | func adminAddressOrUnit () = match getString(this, keyAdmin()) { | |
49 | 49 | case s: String => | |
50 | 50 | Address(fromBase58String(s)) | |
51 | 51 | case _: Unit => | |
52 | 52 | unit | |
53 | 53 | case _ => | |
54 | 54 | throw("Match error") | |
55 | 55 | } | |
56 | 56 | ||
57 | 57 | ||
58 | 58 | func eastAsset () = getStringValue(this, keyEastAsset()) | |
59 | 59 | ||
60 | 60 | ||
61 | 61 | func int0 (k) = valueOrElse(getInteger(this, k), 0) | |
62 | 62 | ||
63 | 63 | ||
64 | 64 | func mustAdmin (i) = { | |
65 | 65 | let pd = throw("permission denied") | |
66 | 66 | match adminAddressOrUnit() { | |
67 | 67 | case address: Address => | |
68 | 68 | if ((i.caller == address)) | |
69 | 69 | then true | |
70 | 70 | else pd | |
71 | 71 | case _: Unit => | |
72 | 72 | if ((i.caller == this)) | |
73 | 73 | then true | |
74 | 74 | else pd | |
75 | 75 | case _ => | |
76 | 76 | throw("Match error") | |
77 | 77 | } | |
78 | 78 | } | |
79 | 79 | ||
80 | 80 | ||
81 | 81 | func checkContractAndAsset (_assetId,_contractId) = { | |
82 | 82 | let contractId = Address(fromBase58String(_contractId)) | |
83 | 83 | let assetId = valueOrErrorMessage(getString(contractId, keyBAssetId()), "Wrong contract id") | |
84 | - | if (if ((assetId != "WAVES")) | |
84 | + | if (if ((_assetId != "WAVES")) | |
85 | 85 | then (assetId != _assetId) | |
86 | 86 | else false) | |
87 | 87 | then throw("Wrong asset id") | |
88 | 88 | else nil | |
89 | 89 | } | |
90 | 90 | ||
91 | 91 | ||
92 | 92 | func checkAddress (_address) = match addressFromString(_address) { | |
93 | 93 | case address: Address => | |
94 | 94 | true | |
95 | 95 | case _: Unit => | |
96 | 96 | throw("Invalid address") | |
97 | 97 | case _ => | |
98 | 98 | throw("Match error") | |
99 | 99 | } | |
100 | 100 | ||
101 | 101 | ||
102 | 102 | func checkRanges (value) = if (if ((value > 0)) | |
103 | 103 | then (300 > value) | |
104 | 104 | else false) | |
105 | 105 | then true | |
106 | 106 | else throw("Out of range") | |
107 | 107 | ||
108 | 108 | ||
109 | 109 | @Callable(i) | |
110 | 110 | func initialize (_assetStoreAddress,_westAssetId) = if (if (initialized()) | |
111 | 111 | then isOwner(i) | |
112 | 112 | else false) | |
113 | 113 | then throw("Not allowed") | |
114 | 114 | else { | |
115 | 115 | let east = Issue("East", "", 0, 8, true, unit, 0) | |
116 | 116 | let _eastAssetId = calculateAssetId(east) | |
117 | 117 | [StringEntry(keyEastAsset(), toBase58String(_eastAssetId)), StringEntry(keyWestAsset(), _westAssetId), BooleanEntry(keyInitialized(), true)] | |
118 | 118 | } | |
119 | 119 | ||
120 | 120 | ||
121 | 121 | ||
122 | 122 | @Callable(i) | |
123 | 123 | func setAdmin (_address) = { | |
124 | 124 | let check = if (if (initialized()) | |
125 | 125 | then mustAdmin(i) | |
126 | 126 | else false) | |
127 | 127 | then checkAddress(_address) | |
128 | 128 | else false | |
129 | 129 | if ((check == check)) | |
130 | 130 | then if (!(check)) | |
131 | 131 | then throw("Not allowed") | |
132 | 132 | else [StringEntry(keyAdmin(), _address)] | |
133 | 133 | else throw("Strict value is not equal to itself.") | |
134 | 134 | } | |
135 | 135 | ||
136 | 136 | ||
137 | 137 | ||
138 | 138 | @Callable(i) | |
139 | 139 | func adminSetAsset (_assetId,_contractId,_backingRatio,_liquidationCollateral) = { | |
140 | 140 | let inited = if (initialized()) | |
141 | 141 | then mustAdmin(i) | |
142 | 142 | else false | |
143 | 143 | if ((inited == inited)) | |
144 | 144 | then if (!(inited)) | |
145 | 145 | then throw("Not allowed") | |
146 | 146 | else { | |
147 | 147 | let westAssetId = getStringValue(keyWestAsset()) | |
148 | 148 | if ((westAssetId == _assetId)) | |
149 | 149 | then throw("West asset is not allowed") | |
150 | 150 | else { | |
151 | 151 | let checks = [checkContractAndAsset(_assetId, _contractId), checkRanges(_backingRatio), checkRanges(_liquidationCollateral)] | |
152 | 152 | if ((checks == checks)) | |
153 | 153 | then { | |
154 | 154 | let assetCfg = dataAssetCfg(_assetId, _contractId, _backingRatio, _liquidationCollateral) | |
155 | 155 | [StringEntry(keyAssetCfg(_assetId), assetCfg)] | |
156 | 156 | } | |
157 | 157 | else throw("Strict value is not equal to itself.") | |
158 | 158 | } | |
159 | 159 | } | |
160 | 160 | else throw("Strict value is not equal to itself.") | |
161 | 161 | } | |
162 | 162 | ||
163 | 163 | ||
164 | 164 | ||
165 | 165 | @Callable(i) | |
166 | 166 | func mint () = { | |
167 | 167 | let payment = i.payments[0] | |
168 | 168 | if ((size(i.payments) != 1)) | |
169 | 169 | then throw("Wrong payments amount") | |
170 | 170 | else { | |
171 | 171 | let assetId = match payment.assetId { | |
172 | 172 | case id: ByteVector => | |
173 | 173 | toBase58String(id) | |
174 | 174 | case waves: Unit => | |
175 | 175 | "WAVES" | |
176 | 176 | case _ => | |
177 | 177 | throw("Match error") | |
178 | 178 | } | |
179 | 179 | let assetCfg = split(valueOrErrorMessage(getString(keyAssetCfg(assetId)), "Unknown asset"), SEP) | |
180 | 180 | let contractId = assetCfg[IdxAssetContract] | |
181 | 181 | let backingRatio = assetCfg[IdxAssetBackingRatio] | |
182 | 182 | let x = throw((contractId + backingRatio)) | |
183 | 183 | nil | |
184 | 184 | } | |
185 | 185 | } | |
186 | 186 | ||
187 | 187 | ||
188 | 188 | @Verifier(tx) | |
189 | 189 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
190 | 190 |
github/deemru/w8io/026f985 32.43 ms ◑