tx · CSpyis2m1gzLxCbRKSzgW1EJEvxW3DLPtwQZjNbDURjT 3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN: -0.01000000 Waves 2022.05.19 19:16 [2058781] smart account 3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN > SELF 0.00000000 Waves
{ "type": 13, "id": "CSpyis2m1gzLxCbRKSzgW1EJEvxW3DLPtwQZjNbDURjT", "fee": 1000000, "feeAssetId": null, "timestamp": 1652976998383, "version": 2, "chainId": 84, "sender": "3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN", "senderPublicKey": "HMwdLbwQuprhi3kaJNPXUEAtXSKEAA8DKYfsrmLYxaWW", "proofs": [ "48fYYxw3nQzx58sRkVp2dX8kxqzkkunx6x13eqnBifWxsWC22xyRqHZmNNeHdfULqZieZZ4gqdaoc2kMFPk1VGjp" ], "script": "base64:AAIFAAAAAAAAAFUIAhIHCgUCAgICARIFCgMCAgESBQoDCAgBEgQKAgICEgUKAwICAhIICgYCAgECAgISBAoCCAISAwoBAhIDCgECEgASABIECgICARIDCgEBEgQKAgIEAAAAKgAAAAAPa2V5QXNzZXRBZGRyZXNzAgAAAANfYWEAAAAADGtleUFzc2V0VHlwZQIAAAADX2F0AAAAABFrZXlBc3NldFByZWNpc2lvbgIAAAADX2FwAAAAAA5rZXlBc3NldE1pbkZlZQIAAAAEX2FtZgAAAAAQa2V5QXNzZXRJc0FjdGl2ZQIAAAAEX2FpYQAAAAAQa2V5QmFzZUZlZVJhdGVCUAIAAAAEX2JmcgAAAAAMa2V5VmFsaWRhdG9yAgAAAAJfdgAAAAAPa2V5RmVlQ29sbGVjdG9yAgAAAANfZmMAAAAAD2tleVVubG9ja1NpZ25lcgIAAAADX3VzAAAAAAtrZXlJc0FjdGl2ZQIAAAADX2lhAAAAAAprZXlNYW5hZ2VyAgAAAAJfbQAAAAAOQlJJREdFX01BTkFHRVICAAAADkJSSURHRV9NQU5BR0VSAAAAAA1BU1NFVF9NQU5BR0VSAgAAAA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ldElzQWN0aXZlBQAAAAVzdGF0ZQUAAAADbmlsCQAAAgAAAAECAAAAJFN0cmljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgAAAADxdaFr", "height": 2058781, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: Ackk3pwzabjaxB36jNgnzEzwBbLCRSLxVVg4KjpndFu6 Next: BJNUSgex7iHNY9YbzaHX9amrvkpAWMbXKLvBdiRuoAR7 Diff:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let keyAssetAddress = "_aa" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyAssetType = "_at" | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyAssetPrecision = "_ap" | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyAssetMinFee = "_amf" | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyAssetIsActive = "_aia" | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyBaseFeeRateBP = "_bfr" | |
15 | 15 | ||
16 | - | let | |
16 | + | let keyValidator = "_v" | |
17 | 17 | ||
18 | - | let | |
18 | + | let keyFeeCollector = "_fc" | |
19 | 19 | ||
20 | - | let keyUnlock = "_u" | |
20 | + | let keyUnlockSigner = "_us" | |
21 | + | ||
22 | + | let keyIsActive = "_ia" | |
23 | + | ||
24 | + | let keyManager = "_m" | |
25 | + | ||
26 | + | let BRIDGE_MANAGER = "BRIDGE_MANAGER" | |
27 | + | ||
28 | + | let ASSET_MANAGER = "ASSET_MANAGER" | |
29 | + | ||
30 | + | let STOP_MANAGER = "STOP_MANAGER" | |
31 | + | ||
32 | + | let baseAssetSourceAndAddress = base58'fRpRFUxiLXbzAaAT3sfi1oTFa8n4X8b9FUaQHyT5MkdXYpGZV' | |
33 | + | ||
34 | + | let baseAssetId = base58'6scFjhFGDfpmYySMKQ9vDbZuH8aMRWsUQJAHXzm1FsJo' | |
35 | + | ||
36 | + | let chainWaves = base58'3EMsPJ' | |
37 | + | ||
38 | + | let BP = 10000 | |
39 | + | ||
40 | + | let systemPrecision = 9 | |
21 | 41 | ||
22 | 42 | let errUnauthorized = "unauthorized" | |
23 | 43 | ||
24 | 44 | let errUninitialized = "uninitialized" | |
25 | 45 | ||
26 | - | let | |
46 | + | let errInitialized = "initialized" | |
27 | 47 | ||
28 | - | let | |
48 | + | let errAlreadyExists = "exists" | |
29 | 49 | ||
30 | - | let | |
50 | + | let errNotExists = "not exists" | |
31 | 51 | ||
32 | - | let | |
52 | + | let errInvalidValues = "invalid values" | |
33 | 53 | ||
34 | - | let | |
54 | + | let errNotOnePayment = "not one payment" | |
35 | 55 | ||
36 | - | func invalidCaller (i,key) = match getBinary(key) { | |
56 | + | let errAssetNotFound = "asset not found" | |
57 | + | ||
58 | + | let errNotEnoughBalance = "not enough balance" | |
59 | + | ||
60 | + | let errBigPowValue = "pow value too big" | |
61 | + | ||
62 | + | let errBridgeDisabled = "birdge is disabled" | |
63 | + | ||
64 | + | let errAssetDisabled = "asset is disabled" | |
65 | + | ||
66 | + | let errWrongDestinationChain = "wrong destination chain" | |
67 | + | ||
68 | + | let typeBase = 0 | |
69 | + | ||
70 | + | let typeNative = 1 | |
71 | + | ||
72 | + | let typeWrapped = 2 | |
73 | + | ||
74 | + | func assertCallerIsManager (i,managerType) = match getBinary((managerType + keyManager)) { | |
37 | 75 | case authority: ByteVector => | |
38 | - | (authority != i.caller.bytes) | |
76 | + | if ((authority != i.caller.bytes)) | |
77 | + | then throw(errUnauthorized) | |
78 | + | else unit | |
39 | 79 | case _ => | |
40 | - | | |
80 | + | throw(errUninitialized) | |
41 | 81 | } | |
42 | 82 | ||
43 | 83 | ||
44 | - | func | |
45 | - | then throw( | |
84 | + | func assertBridgeIsActive () = if (!(valueOrElse(getBoolean(keyIsActive), false))) | |
85 | + | then throw(errBridgeDisabled) | |
46 | 86 | else unit | |
47 | 87 | ||
48 | 88 | ||
49 | - | func assertValidLockId (lockId) = { | |
50 | - | let version = valueOrErrorMessage(getBinary(keyVersion), errUninitialized) | |
51 | - | if (if ((size(lockId) != 16)) | |
52 | - | then true | |
53 | - | else (take(lockId, 1) != version)) | |
54 | - | then throw(errInvalidLockId) | |
55 | - | else unit | |
89 | + | func assertAssetIsActive (assetIdStr) = match getBoolean((assetIdStr + keyAssetIsActive)) { | |
90 | + | case isActive: Boolean => | |
91 | + | if (isActive) | |
92 | + | then unit | |
93 | + | else throw(errAssetDisabled) | |
94 | + | case _ => | |
95 | + | throw(errAssetNotFound) | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | func getFee (amount,assetIdStr) = { | |
100 | + | let baseFeeRateBP = valueOrErrorMessage(getInteger(keyBaseFeeRateBP), errUninitialized) | |
101 | + | let minFee = valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound) | |
102 | + | let fee = ((amount * baseFeeRateBP) / BP) | |
103 | + | if ((minFee > fee)) | |
104 | + | then minFee | |
105 | + | else fee | |
56 | 106 | } | |
57 | 107 | ||
58 | 108 | ||
59 | - | func assertLockNotExists (lockRecipientKey) = match getBinary(lockRecipientKey) { | |
60 | - | case t: ByteVector => | |
61 | - | throw(errAlreadyLocked) | |
62 | - | case _ => | |
63 | - | unit | |
64 | - | } | |
109 | + | func pow10 (value,power) = { | |
110 | + | let absPow = if ((0 > power)) | |
111 | + | then -(power) | |
112 | + | else power | |
113 | + | let powerValue = if ((absPow == 0)) | |
114 | + | then 1 | |
115 | + | else if ((absPow == 1)) | |
116 | + | then 10 | |
117 | + | else if ((absPow == 2)) | |
118 | + | then 100 | |
119 | + | else if ((absPow == 3)) | |
120 | + | then 1000 | |
121 | + | else if ((absPow == 4)) | |
122 | + | then 10000 | |
123 | + | else if ((absPow == 5)) | |
124 | + | then 100000 | |
125 | + | else if ((absPow == 6)) | |
126 | + | then 1000000 | |
127 | + | else if ((absPow == 7)) | |
128 | + | then 10000000 | |
129 | + | else if ((absPow == 8)) | |
130 | + | then 100000000 | |
131 | + | else if ((absPow == 9)) | |
132 | + | then 1000000000 | |
133 | + | else throw(errBigPowValue) | |
134 | + | if ((0 > power)) | |
135 | + | then (value / powerValue) | |
136 | + | else (value * powerValue) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | func toSystemPrecision (amount,precision) = pow10(amount, (systemPrecision - precision)) | |
141 | + | ||
142 | + | ||
143 | + | func fromSystemPrecision (amount,precision) = pow10(amount, (precision - systemPrecision)) | |
65 | 144 | ||
66 | 145 | ||
67 | 146 | @Callable(i) | |
68 | - | func | |
69 | - | then throw( | |
70 | - | else [BinaryEntry( | |
147 | + | func init (admin,validatorAddress,feeCollector,unlockSigner,baseFeeRateBP) = if (isDefined(getBinary((BRIDGE_MANAGER + keyManager)))) | |
148 | + | then throw(errInitialized) | |
149 | + | else [BinaryEntry((BRIDGE_MANAGER + keyManager), admin), BinaryEntry(keyValidator, validatorAddress), BinaryEntry(keyFeeCollector, feeCollector), BinaryEntry(keyUnlockSigner, unlockSigner), IntegerEntry(keyBaseFeeRateBP, baseFeeRateBP), BooleanEntry(keyIsActive, true)] | |
71 | 150 | ||
72 | 151 | ||
73 | 152 | ||
74 | 153 | @Callable(i) | |
75 | - | func setConfig (version,bridge,oracle) = if (invalidCaller(i, keyAdmin)) | |
76 | - | then throw(errUnauthorized) | |
77 | - | else [BinaryEntry(keyVersion, version), BinaryEntry(keyBridge, bridge), BinaryEntry(keyOracle, oracle)] | |
154 | + | func addAsset (assetSourceAndAddress,assetId,minFee) = { | |
155 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
156 | + | if ((callerCheck == callerCheck)) | |
157 | + | then { | |
158 | + | let $t041684568 = if ((assetId == baseAssetId)) | |
159 | + | then if ((assetSourceAndAddress != baseAssetSourceAndAddress)) | |
160 | + | then throw(errInvalidValues) | |
161 | + | else $Tuple2(typeBase, 8) | |
162 | + | else { | |
163 | + | let asset = valueOrErrorMessage(assetInfo(assetId), errAssetNotFound) | |
164 | + | let type = if ((asset.issuer == this)) | |
165 | + | then typeWrapped | |
166 | + | else typeNative | |
167 | + | $Tuple2(type, asset.decimals) | |
168 | + | } | |
169 | + | let type = $t041684568._1 | |
170 | + | let precision = $t041684568._2 | |
171 | + | let assetIdStr = toBase64String(assetId) | |
172 | + | let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress) | |
173 | + | let keyNativeAddress = (assetIdStr + keyAssetAddress) | |
174 | + | if (if (isDefined(getBinary(keySourceAddress))) | |
175 | + | then true | |
176 | + | else isDefined(getBinary(keyNativeAddress))) | |
177 | + | then throw(errAlreadyExists) | |
178 | + | else [BinaryEntry(keySourceAddress, assetId), BinaryEntry(keyNativeAddress, assetSourceAndAddress), IntegerEntry((assetIdStr + keyAssetType), type), IntegerEntry((assetIdStr + keyAssetPrecision), precision), IntegerEntry((assetIdStr + keyAssetMinFee), minFee), BooleanEntry((assetIdStr + keyAssetIsActive), true)] | |
179 | + | } | |
180 | + | else throw("Strict value is not equal to itself.") | |
181 | + | } | |
78 | 182 | ||
79 | 183 | ||
80 | 184 | ||
81 | 185 | @Callable(i) | |
82 | - | func createUnlock (lockId,recipient,amount,lockSource,tokenSourceAndAddress,signature) = { | |
83 | - | let checkLockId = assertValidLockId(lockId) | |
84 | - | if ((checkLockId == checkLockId)) | |
186 | + | func issue (name,description,precision) = { | |
187 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
188 | + | if ((callerCheck == callerCheck)) | |
189 | + | then [Issue(name, description, 0, precision, true)] | |
190 | + | else throw("Strict value is not equal to itself.") | |
191 | + | } | |
192 | + | ||
193 | + | ||
194 | + | ||
195 | + | @Callable(i) | |
196 | + | func removeAsset (assetSourceAndAddress,newAuthority) = { | |
197 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
198 | + | if ((callerCheck == callerCheck)) | |
85 | 199 | then { | |
86 | - | let checkCaller = assertCallerIsBridge(i) | |
87 | - | if ((checkCaller == checkCaller)) | |
200 | + | let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress) | |
201 | + | let assetId = valueOrErrorMessage(getBinary(keySourceAddress), errNotExists) | |
202 | + | let assetIdStr = toBase64String(assetId) | |
203 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errNotExists) | |
204 | + | let actions = if ((type == typeBase)) | |
88 | 205 | then { | |
89 | - | let lockIdStr = toBase64String(lockId) | |
90 | - | let lockSourceStr = toBase64String(lockSource) | |
91 | - | let unlockKey = (((lockSourceStr + "_") + lockIdStr) + keyUnlock) | |
92 | - | if (isDefined(getBoolean(unlockKey))) | |
93 | - | then throw(errAlreadyClaimed) | |
206 | + | let balance = wavesBalance(this) | |
207 | + | if ((balance.available > 0)) | |
208 | + | then [ScriptTransfer(Address(newAuthority), balance.available, unit)] | |
209 | + | else nil | |
210 | + | } | |
211 | + | else if ((type == typeNative)) | |
212 | + | then { | |
213 | + | let balance = assetBalance(this, assetId) | |
214 | + | if ((balance > 0)) | |
215 | + | then [ScriptTransfer(Address(newAuthority), balance, assetId)] | |
216 | + | else nil | |
217 | + | } | |
218 | + | else if ((type == typeWrapped)) | |
219 | + | then nil | |
220 | + | else throw(errInvalidValues) | |
221 | + | (actions ++ [DeleteEntry(keySourceAddress), DeleteEntry((assetIdStr + keyAssetAddress)), DeleteEntry((assetIdStr + keyAssetType)), DeleteEntry((assetIdStr + keyAssetPrecision)), DeleteEntry((assetIdStr + keyAssetMinFee)), DeleteEntry((assetIdStr + keyAssetIsActive))]) | |
222 | + | } | |
223 | + | else throw("Strict value is not equal to itself.") | |
224 | + | } | |
225 | + | ||
226 | + | ||
227 | + | ||
228 | + | @Callable(i) | |
229 | + | func lock (lockId,recipient,destination) = { | |
230 | + | let birdgeCheck = assertBridgeIsActive() | |
231 | + | if ((birdgeCheck == birdgeCheck)) | |
232 | + | then if ((destination == chainWaves)) | |
233 | + | then throw(errWrongDestinationChain) | |
234 | + | else if ((size(i.payments) != 1)) | |
235 | + | then throw(errNotOnePayment) | |
236 | + | else { | |
237 | + | let assetId = valueOrElse(i.payments[0].assetId, baseAssetId) | |
238 | + | let assetIdStr = toBase64String(assetId) | |
239 | + | let assetCheck = assertAssetIsActive(assetIdStr) | |
240 | + | if ((assetCheck == assetCheck)) | |
241 | + | then { | |
242 | + | let amount = i.payments[0].amount | |
243 | + | let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized) | |
244 | + | let fee = getFee(amount, assetIdStr) | |
245 | + | let amountWithoutFee = (amount - fee) | |
246 | + | if ((0 >= amountWithoutFee)) | |
247 | + | then throw(errNotEnoughBalance) | |
248 | + | else { | |
249 | + | let assetSourceAndAddress = valueOrErrorMessage(getBinary((assetIdStr + keyAssetAddress)), errAssetNotFound) | |
250 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound) | |
251 | + | let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound) | |
252 | + | let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized) | |
253 | + | let createLock = invoke(Address(validatorAddress), "createLock", [lockId, recipient, toSystemPrecision(amountWithoutFee, precision), destination, assetSourceAndAddress], nil) | |
254 | + | if ((createLock == createLock)) | |
255 | + | then if ((type == typeBase)) | |
256 | + | then [ScriptTransfer(Address(feeCollector), fee, unit)] | |
257 | + | else if ((type == typeNative)) | |
258 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
259 | + | else if ((type == typeWrapped)) | |
260 | + | then [Burn(assetId, amountWithoutFee), ScriptTransfer(Address(feeCollector), fee, assetId)] | |
261 | + | else throw(errInvalidValues) | |
262 | + | else throw("Strict value is not equal to itself.") | |
263 | + | } | |
264 | + | } | |
265 | + | else throw("Strict value is not equal to itself.") | |
266 | + | } | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | ||
270 | + | ||
271 | + | ||
272 | + | @Callable(i) | |
273 | + | func unlock (lockId,recipient,amount,lockSource,assetSourceAndAddress,signature) = { | |
274 | + | let birdgeCheck = assertBridgeIsActive() | |
275 | + | if ((birdgeCheck == birdgeCheck)) | |
276 | + | then { | |
277 | + | let assetId = valueOrErrorMessage(getBinary((toBase64String(assetSourceAndAddress) + keyAssetAddress)), errAssetNotFound) | |
278 | + | let assetIdStr = toBase64String(assetId) | |
279 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound) | |
280 | + | let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound) | |
281 | + | let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized) | |
282 | + | let unlockSigner = valueOrErrorMessage(getBinary(keyUnlockSigner), errUninitialized) | |
283 | + | let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized) | |
284 | + | let createUnlock = invoke(Address(validatorAddress), "createUnlock", [lockId, recipient, amount, lockSource, assetSourceAndAddress, signature], nil) | |
285 | + | if ((createUnlock == createUnlock)) | |
286 | + | then { | |
287 | + | let isValid = match createUnlock { | |
288 | + | case v: Boolean => | |
289 | + | v | |
290 | + | case _ => | |
291 | + | false | |
292 | + | } | |
293 | + | if (!(isValid)) | |
294 | + | then throw(errInvalidValues) | |
94 | 295 | else { | |
95 | - | let message = makeString([toBase64String(lockId), toBase64String(recipient), toString(amount), toBase64String(lockSource), toBase64String(tokenSourceAndAddress)], "_") | |
96 | - | let hash = keccak256(toBytes(message)) | |
97 | - | let recoveredKey = ecrecover(hash, signature) | |
98 | - | if ((recoveredKey != getBinaryValue(keyOracle))) | |
99 | - | then throw(errInvalidSignature) | |
100 | - | else $Tuple2([BooleanEntry(unlockKey, true)], true) | |
296 | + | let fee = if ((unlockSigner == i.caller.bytes)) | |
297 | + | then valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound) | |
298 | + | else 0 | |
299 | + | let amountToSend = fromSystemPrecision(amount, precision) | |
300 | + | let amountToSendWithoutFee = (amountToSend - fee) | |
301 | + | if ((0 >= amountToSendWithoutFee)) | |
302 | + | then throw(errNotEnoughBalance) | |
303 | + | else if ((type == typeBase)) | |
304 | + | then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, unit)] ++ (if ((fee > 0)) | |
305 | + | then [ScriptTransfer(Address(feeCollector), fee, unit)] | |
306 | + | else nil)) | |
307 | + | else if ((type == typeNative)) | |
308 | + | then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0)) | |
309 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
310 | + | else nil)) | |
311 | + | else if ((type == typeWrapped)) | |
312 | + | then ([Reissue(assetId, amountToSend, true), ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0)) | |
313 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
314 | + | else nil)) | |
315 | + | else throw(errInvalidValues) | |
101 | 316 | } | |
102 | 317 | } | |
103 | 318 | else throw("Strict value is not equal to itself.") | |
108 | 323 | ||
109 | 324 | ||
110 | 325 | @Callable(i) | |
111 | - | func createLock (lockId,recipient,amount,lockDestination,tokenSourceAndAddress) = { | |
112 | - | let lockIdStr = toBase64String(lockId) | |
113 | - | let lockRecipientKey = (lockIdStr + keyLockRecipient) | |
114 | - | let checkCaller = assertCallerIsBridge(i) | |
115 | - | if ((checkCaller == checkCaller)) | |
326 | + | func setManager (managerType,manager) = { | |
327 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
328 | + | if ((callerCheck == callerCheck)) | |
329 | + | then [BinaryEntry((managerType + keyManager), manager)] | |
330 | + | else throw("Strict value is not equal to itself.") | |
331 | + | } | |
332 | + | ||
333 | + | ||
334 | + | ||
335 | + | @Callable(i) | |
336 | + | func setFeeCollector (feeCollector) = { | |
337 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
338 | + | if ((callerCheck == callerCheck)) | |
339 | + | then [BinaryEntry(keyFeeCollector, feeCollector)] | |
340 | + | else throw("Strict value is not equal to itself.") | |
341 | + | } | |
342 | + | ||
343 | + | ||
344 | + | ||
345 | + | @Callable(i) | |
346 | + | func setValidator (validator) = { | |
347 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
348 | + | if ((callerCheck == callerCheck)) | |
349 | + | then [BinaryEntry(keyValidator, validator)] | |
350 | + | else throw("Strict value is not equal to itself.") | |
351 | + | } | |
352 | + | ||
353 | + | ||
354 | + | ||
355 | + | @Callable(i) | |
356 | + | func startBridge () = { | |
357 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
358 | + | if ((callerCheck == callerCheck)) | |
359 | + | then [BooleanEntry(keyIsActive, true)] | |
360 | + | else throw("Strict value is not equal to itself.") | |
361 | + | } | |
362 | + | ||
363 | + | ||
364 | + | ||
365 | + | @Callable(i) | |
366 | + | func stopBridge () = { | |
367 | + | let callerCheck = assertCallerIsManager(i, STOP_MANAGER) | |
368 | + | if ((callerCheck == callerCheck)) | |
369 | + | then [BooleanEntry(keyIsActive, false)] | |
370 | + | else throw("Strict value is not equal to itself.") | |
371 | + | } | |
372 | + | ||
373 | + | ||
374 | + | ||
375 | + | @Callable(i) | |
376 | + | func setMinFee (assetId,minFee) = { | |
377 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
378 | + | if ((callerCheck == callerCheck)) | |
116 | 379 | then { | |
117 | - | let checkLockId = assertValidLockId(lockId) | |
118 | - | if ((checkLockId == checkLockId)) | |
119 | - | then { | |
120 | - | let checkLock = assertLockNotExists(lockRecipientKey) | |
121 | - | if ((checkLock == checkLock)) | |
122 | - | then [BinaryEntry((lockIdStr + keyLockRecipient), recipient), IntegerEntry((lockIdStr + keyLockAmount), amount), BinaryEntry((lockIdStr + keyLockDestination), lockDestination), BinaryEntry((lockIdStr + keyLockAssetSource), tokenSourceAndAddress)] | |
123 | - | else throw("Strict value is not equal to itself.") | |
124 | - | } | |
125 | - | else throw("Strict value is not equal to itself.") | |
380 | + | let assetIdStr = toBase64String(assetId) | |
381 | + | [IntegerEntry((assetIdStr + keyAssetMinFee), minFee)] | |
382 | + | } | |
383 | + | else throw("Strict value is not equal to itself.") | |
384 | + | } | |
385 | + | ||
386 | + | ||
387 | + | ||
388 | + | @Callable(i) | |
389 | + | func setBaseFeeRate (baseFeeRateBP) = { | |
390 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
391 | + | if ((callerCheck == callerCheck)) | |
392 | + | then [IntegerEntry(keyBaseFeeRateBP, baseFeeRateBP)] | |
393 | + | else throw("Strict value is not equal to itself.") | |
394 | + | } | |
395 | + | ||
396 | + | ||
397 | + | ||
398 | + | @Callable(i) | |
399 | + | func setAssetState (assetId,state) = { | |
400 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
401 | + | if ((callerCheck == callerCheck)) | |
402 | + | then { | |
403 | + | let assetIdStr = toBase64String(assetId) | |
404 | + | [BooleanEntry((assetIdStr + keyAssetIsActive), state)] | |
126 | 405 | } | |
127 | 406 | else throw("Strict value is not equal to itself.") | |
128 | 407 | } |
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | - | let | |
4 | + | let keyAssetAddress = "_aa" | |
5 | 5 | ||
6 | - | let | |
6 | + | let keyAssetType = "_at" | |
7 | 7 | ||
8 | - | let | |
8 | + | let keyAssetPrecision = "_ap" | |
9 | 9 | ||
10 | - | let | |
10 | + | let keyAssetMinFee = "_amf" | |
11 | 11 | ||
12 | - | let | |
12 | + | let keyAssetIsActive = "_aia" | |
13 | 13 | ||
14 | - | let | |
14 | + | let keyBaseFeeRateBP = "_bfr" | |
15 | 15 | ||
16 | - | let | |
16 | + | let keyValidator = "_v" | |
17 | 17 | ||
18 | - | let | |
18 | + | let keyFeeCollector = "_fc" | |
19 | 19 | ||
20 | - | let keyUnlock = "_u" | |
20 | + | let keyUnlockSigner = "_us" | |
21 | + | ||
22 | + | let keyIsActive = "_ia" | |
23 | + | ||
24 | + | let keyManager = "_m" | |
25 | + | ||
26 | + | let BRIDGE_MANAGER = "BRIDGE_MANAGER" | |
27 | + | ||
28 | + | let ASSET_MANAGER = "ASSET_MANAGER" | |
29 | + | ||
30 | + | let STOP_MANAGER = "STOP_MANAGER" | |
31 | + | ||
32 | + | let baseAssetSourceAndAddress = base58'fRpRFUxiLXbzAaAT3sfi1oTFa8n4X8b9FUaQHyT5MkdXYpGZV' | |
33 | + | ||
34 | + | let baseAssetId = base58'6scFjhFGDfpmYySMKQ9vDbZuH8aMRWsUQJAHXzm1FsJo' | |
35 | + | ||
36 | + | let chainWaves = base58'3EMsPJ' | |
37 | + | ||
38 | + | let BP = 10000 | |
39 | + | ||
40 | + | let systemPrecision = 9 | |
21 | 41 | ||
22 | 42 | let errUnauthorized = "unauthorized" | |
23 | 43 | ||
24 | 44 | let errUninitialized = "uninitialized" | |
25 | 45 | ||
26 | - | let | |
46 | + | let errInitialized = "initialized" | |
27 | 47 | ||
28 | - | let | |
48 | + | let errAlreadyExists = "exists" | |
29 | 49 | ||
30 | - | let | |
50 | + | let errNotExists = "not exists" | |
31 | 51 | ||
32 | - | let | |
52 | + | let errInvalidValues = "invalid values" | |
33 | 53 | ||
34 | - | let | |
54 | + | let errNotOnePayment = "not one payment" | |
35 | 55 | ||
36 | - | func invalidCaller (i,key) = match getBinary(key) { | |
56 | + | let errAssetNotFound = "asset not found" | |
57 | + | ||
58 | + | let errNotEnoughBalance = "not enough balance" | |
59 | + | ||
60 | + | let errBigPowValue = "pow value too big" | |
61 | + | ||
62 | + | let errBridgeDisabled = "birdge is disabled" | |
63 | + | ||
64 | + | let errAssetDisabled = "asset is disabled" | |
65 | + | ||
66 | + | let errWrongDestinationChain = "wrong destination chain" | |
67 | + | ||
68 | + | let typeBase = 0 | |
69 | + | ||
70 | + | let typeNative = 1 | |
71 | + | ||
72 | + | let typeWrapped = 2 | |
73 | + | ||
74 | + | func assertCallerIsManager (i,managerType) = match getBinary((managerType + keyManager)) { | |
37 | 75 | case authority: ByteVector => | |
38 | - | (authority != i.caller.bytes) | |
76 | + | if ((authority != i.caller.bytes)) | |
77 | + | then throw(errUnauthorized) | |
78 | + | else unit | |
39 | 79 | case _ => | |
40 | - | | |
80 | + | throw(errUninitialized) | |
41 | 81 | } | |
42 | 82 | ||
43 | 83 | ||
44 | - | func | |
45 | - | then throw( | |
84 | + | func assertBridgeIsActive () = if (!(valueOrElse(getBoolean(keyIsActive), false))) | |
85 | + | then throw(errBridgeDisabled) | |
46 | 86 | else unit | |
47 | 87 | ||
48 | 88 | ||
49 | - | func assertValidLockId (lockId) = { | |
50 | - | let version = valueOrErrorMessage(getBinary(keyVersion), errUninitialized) | |
51 | - | if (if ((size(lockId) != 16)) | |
52 | - | then true | |
53 | - | else (take(lockId, 1) != version)) | |
54 | - | then throw(errInvalidLockId) | |
55 | - | else unit | |
89 | + | func assertAssetIsActive (assetIdStr) = match getBoolean((assetIdStr + keyAssetIsActive)) { | |
90 | + | case isActive: Boolean => | |
91 | + | if (isActive) | |
92 | + | then unit | |
93 | + | else throw(errAssetDisabled) | |
94 | + | case _ => | |
95 | + | throw(errAssetNotFound) | |
96 | + | } | |
97 | + | ||
98 | + | ||
99 | + | func getFee (amount,assetIdStr) = { | |
100 | + | let baseFeeRateBP = valueOrErrorMessage(getInteger(keyBaseFeeRateBP), errUninitialized) | |
101 | + | let minFee = valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound) | |
102 | + | let fee = ((amount * baseFeeRateBP) / BP) | |
103 | + | if ((minFee > fee)) | |
104 | + | then minFee | |
105 | + | else fee | |
56 | 106 | } | |
57 | 107 | ||
58 | 108 | ||
59 | - | func assertLockNotExists (lockRecipientKey) = match getBinary(lockRecipientKey) { | |
60 | - | case t: ByteVector => | |
61 | - | throw(errAlreadyLocked) | |
62 | - | case _ => | |
63 | - | unit | |
64 | - | } | |
109 | + | func pow10 (value,power) = { | |
110 | + | let absPow = if ((0 > power)) | |
111 | + | then -(power) | |
112 | + | else power | |
113 | + | let powerValue = if ((absPow == 0)) | |
114 | + | then 1 | |
115 | + | else if ((absPow == 1)) | |
116 | + | then 10 | |
117 | + | else if ((absPow == 2)) | |
118 | + | then 100 | |
119 | + | else if ((absPow == 3)) | |
120 | + | then 1000 | |
121 | + | else if ((absPow == 4)) | |
122 | + | then 10000 | |
123 | + | else if ((absPow == 5)) | |
124 | + | then 100000 | |
125 | + | else if ((absPow == 6)) | |
126 | + | then 1000000 | |
127 | + | else if ((absPow == 7)) | |
128 | + | then 10000000 | |
129 | + | else if ((absPow == 8)) | |
130 | + | then 100000000 | |
131 | + | else if ((absPow == 9)) | |
132 | + | then 1000000000 | |
133 | + | else throw(errBigPowValue) | |
134 | + | if ((0 > power)) | |
135 | + | then (value / powerValue) | |
136 | + | else (value * powerValue) | |
137 | + | } | |
138 | + | ||
139 | + | ||
140 | + | func toSystemPrecision (amount,precision) = pow10(amount, (systemPrecision - precision)) | |
141 | + | ||
142 | + | ||
143 | + | func fromSystemPrecision (amount,precision) = pow10(amount, (precision - systemPrecision)) | |
65 | 144 | ||
66 | 145 | ||
67 | 146 | @Callable(i) | |
68 | - | func | |
69 | - | then throw( | |
70 | - | else [BinaryEntry( | |
147 | + | func init (admin,validatorAddress,feeCollector,unlockSigner,baseFeeRateBP) = if (isDefined(getBinary((BRIDGE_MANAGER + keyManager)))) | |
148 | + | then throw(errInitialized) | |
149 | + | else [BinaryEntry((BRIDGE_MANAGER + keyManager), admin), BinaryEntry(keyValidator, validatorAddress), BinaryEntry(keyFeeCollector, feeCollector), BinaryEntry(keyUnlockSigner, unlockSigner), IntegerEntry(keyBaseFeeRateBP, baseFeeRateBP), BooleanEntry(keyIsActive, true)] | |
71 | 150 | ||
72 | 151 | ||
73 | 152 | ||
74 | 153 | @Callable(i) | |
75 | - | func setConfig (version,bridge,oracle) = if (invalidCaller(i, keyAdmin)) | |
76 | - | then throw(errUnauthorized) | |
77 | - | else [BinaryEntry(keyVersion, version), BinaryEntry(keyBridge, bridge), BinaryEntry(keyOracle, oracle)] | |
154 | + | func addAsset (assetSourceAndAddress,assetId,minFee) = { | |
155 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
156 | + | if ((callerCheck == callerCheck)) | |
157 | + | then { | |
158 | + | let $t041684568 = if ((assetId == baseAssetId)) | |
159 | + | then if ((assetSourceAndAddress != baseAssetSourceAndAddress)) | |
160 | + | then throw(errInvalidValues) | |
161 | + | else $Tuple2(typeBase, 8) | |
162 | + | else { | |
163 | + | let asset = valueOrErrorMessage(assetInfo(assetId), errAssetNotFound) | |
164 | + | let type = if ((asset.issuer == this)) | |
165 | + | then typeWrapped | |
166 | + | else typeNative | |
167 | + | $Tuple2(type, asset.decimals) | |
168 | + | } | |
169 | + | let type = $t041684568._1 | |
170 | + | let precision = $t041684568._2 | |
171 | + | let assetIdStr = toBase64String(assetId) | |
172 | + | let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress) | |
173 | + | let keyNativeAddress = (assetIdStr + keyAssetAddress) | |
174 | + | if (if (isDefined(getBinary(keySourceAddress))) | |
175 | + | then true | |
176 | + | else isDefined(getBinary(keyNativeAddress))) | |
177 | + | then throw(errAlreadyExists) | |
178 | + | else [BinaryEntry(keySourceAddress, assetId), BinaryEntry(keyNativeAddress, assetSourceAndAddress), IntegerEntry((assetIdStr + keyAssetType), type), IntegerEntry((assetIdStr + keyAssetPrecision), precision), IntegerEntry((assetIdStr + keyAssetMinFee), minFee), BooleanEntry((assetIdStr + keyAssetIsActive), true)] | |
179 | + | } | |
180 | + | else throw("Strict value is not equal to itself.") | |
181 | + | } | |
78 | 182 | ||
79 | 183 | ||
80 | 184 | ||
81 | 185 | @Callable(i) | |
82 | - | func createUnlock (lockId,recipient,amount,lockSource,tokenSourceAndAddress,signature) = { | |
83 | - | let checkLockId = assertValidLockId(lockId) | |
84 | - | if ((checkLockId == checkLockId)) | |
186 | + | func issue (name,description,precision) = { | |
187 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
188 | + | if ((callerCheck == callerCheck)) | |
189 | + | then [Issue(name, description, 0, precision, true)] | |
190 | + | else throw("Strict value is not equal to itself.") | |
191 | + | } | |
192 | + | ||
193 | + | ||
194 | + | ||
195 | + | @Callable(i) | |
196 | + | func removeAsset (assetSourceAndAddress,newAuthority) = { | |
197 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
198 | + | if ((callerCheck == callerCheck)) | |
85 | 199 | then { | |
86 | - | let checkCaller = assertCallerIsBridge(i) | |
87 | - | if ((checkCaller == checkCaller)) | |
200 | + | let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress) | |
201 | + | let assetId = valueOrErrorMessage(getBinary(keySourceAddress), errNotExists) | |
202 | + | let assetIdStr = toBase64String(assetId) | |
203 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errNotExists) | |
204 | + | let actions = if ((type == typeBase)) | |
88 | 205 | then { | |
89 | - | let lockIdStr = toBase64String(lockId) | |
90 | - | let lockSourceStr = toBase64String(lockSource) | |
91 | - | let unlockKey = (((lockSourceStr + "_") + lockIdStr) + keyUnlock) | |
92 | - | if (isDefined(getBoolean(unlockKey))) | |
93 | - | then throw(errAlreadyClaimed) | |
206 | + | let balance = wavesBalance(this) | |
207 | + | if ((balance.available > 0)) | |
208 | + | then [ScriptTransfer(Address(newAuthority), balance.available, unit)] | |
209 | + | else nil | |
210 | + | } | |
211 | + | else if ((type == typeNative)) | |
212 | + | then { | |
213 | + | let balance = assetBalance(this, assetId) | |
214 | + | if ((balance > 0)) | |
215 | + | then [ScriptTransfer(Address(newAuthority), balance, assetId)] | |
216 | + | else nil | |
217 | + | } | |
218 | + | else if ((type == typeWrapped)) | |
219 | + | then nil | |
220 | + | else throw(errInvalidValues) | |
221 | + | (actions ++ [DeleteEntry(keySourceAddress), DeleteEntry((assetIdStr + keyAssetAddress)), DeleteEntry((assetIdStr + keyAssetType)), DeleteEntry((assetIdStr + keyAssetPrecision)), DeleteEntry((assetIdStr + keyAssetMinFee)), DeleteEntry((assetIdStr + keyAssetIsActive))]) | |
222 | + | } | |
223 | + | else throw("Strict value is not equal to itself.") | |
224 | + | } | |
225 | + | ||
226 | + | ||
227 | + | ||
228 | + | @Callable(i) | |
229 | + | func lock (lockId,recipient,destination) = { | |
230 | + | let birdgeCheck = assertBridgeIsActive() | |
231 | + | if ((birdgeCheck == birdgeCheck)) | |
232 | + | then if ((destination == chainWaves)) | |
233 | + | then throw(errWrongDestinationChain) | |
234 | + | else if ((size(i.payments) != 1)) | |
235 | + | then throw(errNotOnePayment) | |
236 | + | else { | |
237 | + | let assetId = valueOrElse(i.payments[0].assetId, baseAssetId) | |
238 | + | let assetIdStr = toBase64String(assetId) | |
239 | + | let assetCheck = assertAssetIsActive(assetIdStr) | |
240 | + | if ((assetCheck == assetCheck)) | |
241 | + | then { | |
242 | + | let amount = i.payments[0].amount | |
243 | + | let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized) | |
244 | + | let fee = getFee(amount, assetIdStr) | |
245 | + | let amountWithoutFee = (amount - fee) | |
246 | + | if ((0 >= amountWithoutFee)) | |
247 | + | then throw(errNotEnoughBalance) | |
248 | + | else { | |
249 | + | let assetSourceAndAddress = valueOrErrorMessage(getBinary((assetIdStr + keyAssetAddress)), errAssetNotFound) | |
250 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound) | |
251 | + | let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound) | |
252 | + | let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized) | |
253 | + | let createLock = invoke(Address(validatorAddress), "createLock", [lockId, recipient, toSystemPrecision(amountWithoutFee, precision), destination, assetSourceAndAddress], nil) | |
254 | + | if ((createLock == createLock)) | |
255 | + | then if ((type == typeBase)) | |
256 | + | then [ScriptTransfer(Address(feeCollector), fee, unit)] | |
257 | + | else if ((type == typeNative)) | |
258 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
259 | + | else if ((type == typeWrapped)) | |
260 | + | then [Burn(assetId, amountWithoutFee), ScriptTransfer(Address(feeCollector), fee, assetId)] | |
261 | + | else throw(errInvalidValues) | |
262 | + | else throw("Strict value is not equal to itself.") | |
263 | + | } | |
264 | + | } | |
265 | + | else throw("Strict value is not equal to itself.") | |
266 | + | } | |
267 | + | else throw("Strict value is not equal to itself.") | |
268 | + | } | |
269 | + | ||
270 | + | ||
271 | + | ||
272 | + | @Callable(i) | |
273 | + | func unlock (lockId,recipient,amount,lockSource,assetSourceAndAddress,signature) = { | |
274 | + | let birdgeCheck = assertBridgeIsActive() | |
275 | + | if ((birdgeCheck == birdgeCheck)) | |
276 | + | then { | |
277 | + | let assetId = valueOrErrorMessage(getBinary((toBase64String(assetSourceAndAddress) + keyAssetAddress)), errAssetNotFound) | |
278 | + | let assetIdStr = toBase64String(assetId) | |
279 | + | let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound) | |
280 | + | let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound) | |
281 | + | let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized) | |
282 | + | let unlockSigner = valueOrErrorMessage(getBinary(keyUnlockSigner), errUninitialized) | |
283 | + | let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized) | |
284 | + | let createUnlock = invoke(Address(validatorAddress), "createUnlock", [lockId, recipient, amount, lockSource, assetSourceAndAddress, signature], nil) | |
285 | + | if ((createUnlock == createUnlock)) | |
286 | + | then { | |
287 | + | let isValid = match createUnlock { | |
288 | + | case v: Boolean => | |
289 | + | v | |
290 | + | case _ => | |
291 | + | false | |
292 | + | } | |
293 | + | if (!(isValid)) | |
294 | + | then throw(errInvalidValues) | |
94 | 295 | else { | |
95 | - | let message = makeString([toBase64String(lockId), toBase64String(recipient), toString(amount), toBase64String(lockSource), toBase64String(tokenSourceAndAddress)], "_") | |
96 | - | let hash = keccak256(toBytes(message)) | |
97 | - | let recoveredKey = ecrecover(hash, signature) | |
98 | - | if ((recoveredKey != getBinaryValue(keyOracle))) | |
99 | - | then throw(errInvalidSignature) | |
100 | - | else $Tuple2([BooleanEntry(unlockKey, true)], true) | |
296 | + | let fee = if ((unlockSigner == i.caller.bytes)) | |
297 | + | then valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound) | |
298 | + | else 0 | |
299 | + | let amountToSend = fromSystemPrecision(amount, precision) | |
300 | + | let amountToSendWithoutFee = (amountToSend - fee) | |
301 | + | if ((0 >= amountToSendWithoutFee)) | |
302 | + | then throw(errNotEnoughBalance) | |
303 | + | else if ((type == typeBase)) | |
304 | + | then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, unit)] ++ (if ((fee > 0)) | |
305 | + | then [ScriptTransfer(Address(feeCollector), fee, unit)] | |
306 | + | else nil)) | |
307 | + | else if ((type == typeNative)) | |
308 | + | then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0)) | |
309 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
310 | + | else nil)) | |
311 | + | else if ((type == typeWrapped)) | |
312 | + | then ([Reissue(assetId, amountToSend, true), ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0)) | |
313 | + | then [ScriptTransfer(Address(feeCollector), fee, assetId)] | |
314 | + | else nil)) | |
315 | + | else throw(errInvalidValues) | |
101 | 316 | } | |
102 | 317 | } | |
103 | 318 | else throw("Strict value is not equal to itself.") | |
104 | 319 | } | |
105 | 320 | else throw("Strict value is not equal to itself.") | |
106 | 321 | } | |
107 | 322 | ||
108 | 323 | ||
109 | 324 | ||
110 | 325 | @Callable(i) | |
111 | - | func createLock (lockId,recipient,amount,lockDestination,tokenSourceAndAddress) = { | |
112 | - | let lockIdStr = toBase64String(lockId) | |
113 | - | let lockRecipientKey = (lockIdStr + keyLockRecipient) | |
114 | - | let checkCaller = assertCallerIsBridge(i) | |
115 | - | if ((checkCaller == checkCaller)) | |
326 | + | func setManager (managerType,manager) = { | |
327 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
328 | + | if ((callerCheck == callerCheck)) | |
329 | + | then [BinaryEntry((managerType + keyManager), manager)] | |
330 | + | else throw("Strict value is not equal to itself.") | |
331 | + | } | |
332 | + | ||
333 | + | ||
334 | + | ||
335 | + | @Callable(i) | |
336 | + | func setFeeCollector (feeCollector) = { | |
337 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
338 | + | if ((callerCheck == callerCheck)) | |
339 | + | then [BinaryEntry(keyFeeCollector, feeCollector)] | |
340 | + | else throw("Strict value is not equal to itself.") | |
341 | + | } | |
342 | + | ||
343 | + | ||
344 | + | ||
345 | + | @Callable(i) | |
346 | + | func setValidator (validator) = { | |
347 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
348 | + | if ((callerCheck == callerCheck)) | |
349 | + | then [BinaryEntry(keyValidator, validator)] | |
350 | + | else throw("Strict value is not equal to itself.") | |
351 | + | } | |
352 | + | ||
353 | + | ||
354 | + | ||
355 | + | @Callable(i) | |
356 | + | func startBridge () = { | |
357 | + | let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER) | |
358 | + | if ((callerCheck == callerCheck)) | |
359 | + | then [BooleanEntry(keyIsActive, true)] | |
360 | + | else throw("Strict value is not equal to itself.") | |
361 | + | } | |
362 | + | ||
363 | + | ||
364 | + | ||
365 | + | @Callable(i) | |
366 | + | func stopBridge () = { | |
367 | + | let callerCheck = assertCallerIsManager(i, STOP_MANAGER) | |
368 | + | if ((callerCheck == callerCheck)) | |
369 | + | then [BooleanEntry(keyIsActive, false)] | |
370 | + | else throw("Strict value is not equal to itself.") | |
371 | + | } | |
372 | + | ||
373 | + | ||
374 | + | ||
375 | + | @Callable(i) | |
376 | + | func setMinFee (assetId,minFee) = { | |
377 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
378 | + | if ((callerCheck == callerCheck)) | |
116 | 379 | then { | |
117 | - | let checkLockId = assertValidLockId(lockId) | |
118 | - | if ((checkLockId == checkLockId)) | |
119 | - | then { | |
120 | - | let checkLock = assertLockNotExists(lockRecipientKey) | |
121 | - | if ((checkLock == checkLock)) | |
122 | - | then [BinaryEntry((lockIdStr + keyLockRecipient), recipient), IntegerEntry((lockIdStr + keyLockAmount), amount), BinaryEntry((lockIdStr + keyLockDestination), lockDestination), BinaryEntry((lockIdStr + keyLockAssetSource), tokenSourceAndAddress)] | |
123 | - | else throw("Strict value is not equal to itself.") | |
124 | - | } | |
125 | - | else throw("Strict value is not equal to itself.") | |
380 | + | let assetIdStr = toBase64String(assetId) | |
381 | + | [IntegerEntry((assetIdStr + keyAssetMinFee), minFee)] | |
382 | + | } | |
383 | + | else throw("Strict value is not equal to itself.") | |
384 | + | } | |
385 | + | ||
386 | + | ||
387 | + | ||
388 | + | @Callable(i) | |
389 | + | func setBaseFeeRate (baseFeeRateBP) = { | |
390 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
391 | + | if ((callerCheck == callerCheck)) | |
392 | + | then [IntegerEntry(keyBaseFeeRateBP, baseFeeRateBP)] | |
393 | + | else throw("Strict value is not equal to itself.") | |
394 | + | } | |
395 | + | ||
396 | + | ||
397 | + | ||
398 | + | @Callable(i) | |
399 | + | func setAssetState (assetId,state) = { | |
400 | + | let callerCheck = assertCallerIsManager(i, ASSET_MANAGER) | |
401 | + | if ((callerCheck == callerCheck)) | |
402 | + | then { | |
403 | + | let assetIdStr = toBase64String(assetId) | |
404 | + | [BooleanEntry((assetIdStr + keyAssetIsActive), state)] | |
126 | 405 | } | |
127 | 406 | else throw("Strict value is not equal to itself.") | |
128 | 407 | } | |
129 | 408 | ||
130 | 409 |
github/deemru/w8io/169f3d6 43.00 ms ◑