tx · C5oyaBp1iehmgGE7G72THfrhpKjSYgMGcSgxmVkzJSCk 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY: -0.01000000 Waves 2022.11.23 00:10 [2328853] smart account 3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY > SELF 0.00000000 Waves
{ "type": 13, "id": "C5oyaBp1iehmgGE7G72THfrhpKjSYgMGcSgxmVkzJSCk", "fee": 1000000, "feeAssetId": null, "timestamp": 1669151452644, "version": 2, "chainId": 84, "sender": "3N5TDZHiXyXByfTA47imbhEqAbzAupJR5xY", "senderPublicKey": "9rkQ1ChfNZ585cJFqVhjLk1mTNMXT93CZidHoYERtHML", "proofs": [ "5WuzC6Qy5qGExrVHeQpMDEbtijxVa21rV9erp5MTXJm7Bdhg4HnGMCE2JAVEBc9ddyiHoQZxQsLduV32ULFt1rut" ], "script": "base64:BgIXCAISBAoCCAgSAwoBCBIGCgQICAEBEgAYAANTRVACAl9fAAVFTVBUWQIAAAlQUkVDSVNJT04AgICQu7rWrfANAAhERUNJTUFMUwCAwtcvAAlXRVNUX1BBUlQJAGkCBQlQUkVDSVNJT04ABQAQSWR4QXNzZXRDb250cmFjdAABABRJZHhBc3NldEJhY2tpbmdSYXRpbwACAQtrZXlBc3NldENmZwEMYmFzZUFzc2V0U3RyCQC5CQIJAMwIAgIGJXMlcyVzCQDMCAICBmNvbmZpZwkAzAgCAgVhc3NldAkAzAgCBQxiYXNlQXNzZXRTdHIFA25pbAUDU0VQAQ5rZXlJbml0aWFsaXplZAAJALkJAgkAzAgCAgIlcwkAzAgCAgtpbml0aWFsaXplZAUDbmlsBQNTRVABCGtleUFkbWluAAkAuQkCCQDMCAICAiVzCQDMCAICBWFkbWluBQNuaWwFA1NFUAEMa2V5RWFzdEFzc2V0AAkAuQkCCQDMCAICAiVzCQDMCAICCWVhc3RBc3NldAUDbmlsBQNTRVABDGtleVdlc3RBc3NldAAJALkJAgkAzAgCAgIlcwkAzAgCAgl3ZXN0QXNzZXQFA25pbA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A25pbAkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAgECJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgFpAQRtaW50AAQHcGF5bWVudAkAkQMCCAUBaQhwYXltZW50cwAAAwkBAiE9AgkAkAMBCAUBaQhwYXltZW50cwABCQACAQIVV3JvbmcgcGF5bWVudHMgYW1vdW50BAdhc3NldElkBAckbWF0Y2gwCAUHcGF5bWVudAdhc3NldElkAwkAAQIFByRtYXRjaDACCkJ5dGVWZWN0b3IEAmlkBQckbWF0Y2gwCQDYBAEFAmlkAwkAAQIFByRtYXRjaDACBFVuaXQEBXdhdmVzBQckbWF0Y2gwAgVXQVZFUwkAAgECC01hdGNoIGVycm9yBAhhc3NldENmZwkAtQkCCQETdmFsdWVPckVycm9yTWVzc2FnZQIJAKIIAQkBC2tleUFzc2V0Q2ZnAQUHYXNzZXRJZAINVW5rbm93biBhc3NldAUDU0VQBApjb250cmFjdElkCQCRAwIFCGFzc2V0Q2ZnBRBJZHhBc3NldENvbnRyYWN0BAxiYWNraW5nUmF0aW8JAJEDAgUIYXNzZXRDZmcFFElkeEFzc2V0QmFja2luZ1JhdGlvBAF4CQACAQkArAICBQpjb250cmFjdElkBQxiYWNraW5nUmF0aW8FA25pbAECdHgBBnZlcmlmeQAJAPQDAwgFAnR4CWJvZHlCeXRlcwkAkQMCCAUCdHgGcHJvb2ZzAAAIBQJ0eA9zZW5kZXJQdWJsaWNLZXkOcuac", "height": 2328853, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: BHv9ZgHxzBHTkXFoZnTLUvbeBZPRYcVjfMRvBfdJAAjD Next: 4TgRwQ2rZ6jxcA7u1rDp4SHVvoGxomJ7qENhAs5dt3Wo 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 ((assetId != _assetId)) | |
84 | + | if (if ((assetId != "WAVES")) | |
85 | + | then (assetId != _assetId) | |
86 | + | else false) | |
85 | 87 | then throw("Wrong asset id") | |
86 | 88 | else nil | |
87 | 89 | } |
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 ((assetId != _assetId)) | |
84 | + | if (if ((assetId != "WAVES")) | |
85 | + | then (assetId != _assetId) | |
86 | + | else false) | |
85 | 87 | then throw("Wrong asset id") | |
86 | 88 | else nil | |
87 | 89 | } | |
88 | 90 | ||
89 | 91 | ||
90 | 92 | func checkAddress (_address) = match addressFromString(_address) { | |
91 | 93 | case address: Address => | |
92 | 94 | true | |
93 | 95 | case _: Unit => | |
94 | 96 | throw("Invalid address") | |
95 | 97 | case _ => | |
96 | 98 | throw("Match error") | |
97 | 99 | } | |
98 | 100 | ||
99 | 101 | ||
100 | 102 | func checkRanges (value) = if (if ((value > 0)) | |
101 | 103 | then (300 > value) | |
102 | 104 | else false) | |
103 | 105 | then true | |
104 | 106 | else throw("Out of range") | |
105 | 107 | ||
106 | 108 | ||
107 | 109 | @Callable(i) | |
108 | 110 | func initialize (_assetStoreAddress,_westAssetId) = if (if (initialized()) | |
109 | 111 | then isOwner(i) | |
110 | 112 | else false) | |
111 | 113 | then throw("Not allowed") | |
112 | 114 | else { | |
113 | 115 | let east = Issue("East", "", 0, 8, true, unit, 0) | |
114 | 116 | let _eastAssetId = calculateAssetId(east) | |
115 | 117 | [StringEntry(keyEastAsset(), toBase58String(_eastAssetId)), StringEntry(keyWestAsset(), _westAssetId), BooleanEntry(keyInitialized(), true)] | |
116 | 118 | } | |
117 | 119 | ||
118 | 120 | ||
119 | 121 | ||
120 | 122 | @Callable(i) | |
121 | 123 | func setAdmin (_address) = { | |
122 | 124 | let check = if (if (initialized()) | |
123 | 125 | then mustAdmin(i) | |
124 | 126 | else false) | |
125 | 127 | then checkAddress(_address) | |
126 | 128 | else false | |
127 | 129 | if ((check == check)) | |
128 | 130 | then if (!(check)) | |
129 | 131 | then throw("Not allowed") | |
130 | 132 | else [StringEntry(keyAdmin(), _address)] | |
131 | 133 | else throw("Strict value is not equal to itself.") | |
132 | 134 | } | |
133 | 135 | ||
134 | 136 | ||
135 | 137 | ||
136 | 138 | @Callable(i) | |
137 | 139 | func adminSetAsset (_assetId,_contractId,_backingRatio,_liquidationCollateral) = { | |
138 | 140 | let inited = if (initialized()) | |
139 | 141 | then mustAdmin(i) | |
140 | 142 | else false | |
141 | 143 | if ((inited == inited)) | |
142 | 144 | then if (!(inited)) | |
143 | 145 | then throw("Not allowed") | |
144 | 146 | else { | |
145 | 147 | let westAssetId = getStringValue(keyWestAsset()) | |
146 | 148 | if ((westAssetId == _assetId)) | |
147 | 149 | then throw("West asset is not allowed") | |
148 | 150 | else { | |
149 | 151 | let checks = [checkContractAndAsset(_assetId, _contractId), checkRanges(_backingRatio), checkRanges(_liquidationCollateral)] | |
150 | 152 | if ((checks == checks)) | |
151 | 153 | then { | |
152 | 154 | let assetCfg = dataAssetCfg(_assetId, _contractId, _backingRatio, _liquidationCollateral) | |
153 | 155 | [StringEntry(keyAssetCfg(_assetId), assetCfg)] | |
154 | 156 | } | |
155 | 157 | else throw("Strict value is not equal to itself.") | |
156 | 158 | } | |
157 | 159 | } | |
158 | 160 | else throw("Strict value is not equal to itself.") | |
159 | 161 | } | |
160 | 162 | ||
161 | 163 | ||
162 | 164 | ||
163 | 165 | @Callable(i) | |
164 | 166 | func mint () = { | |
165 | 167 | let payment = i.payments[0] | |
166 | 168 | if ((size(i.payments) != 1)) | |
167 | 169 | then throw("Wrong payments amount") | |
168 | 170 | else { | |
169 | 171 | let assetId = match payment.assetId { | |
170 | 172 | case id: ByteVector => | |
171 | 173 | toBase58String(id) | |
172 | 174 | case waves: Unit => | |
173 | 175 | "WAVES" | |
174 | 176 | case _ => | |
175 | 177 | throw("Match error") | |
176 | 178 | } | |
177 | 179 | let assetCfg = split(valueOrErrorMessage(getString(keyAssetCfg(assetId)), "Unknown asset"), SEP) | |
178 | 180 | let contractId = assetCfg[IdxAssetContract] | |
179 | 181 | let backingRatio = assetCfg[IdxAssetBackingRatio] | |
180 | 182 | let x = throw((contractId + backingRatio)) | |
181 | 183 | nil | |
182 | 184 | } | |
183 | 185 | } | |
184 | 186 | ||
185 | 187 | ||
186 | 188 | @Verifier(tx) | |
187 | 189 | func verify () = sigVerify(tx.bodyBytes, tx.proofs[0], tx.senderPublicKey) | |
188 | 190 |
github/deemru/w8io/026f985 27.57 ms ◑