tx · Ackk3pwzabjaxB36jNgnzEzwBbLCRSLxVVg4KjpndFu6

3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN:  -0.01000000 Waves

2022.05.09 18:19 [2044306] smart account 3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN > SELF 0.00000000 Waves

{ "type": 13, "id": "Ackk3pwzabjaxB36jNgnzEzwBbLCRSLxVVg4KjpndFu6", "fee": 1000000, "feeAssetId": null, "timestamp": 1652109608906, "version": 2, "chainId": 84, "sender": "3NBV6YavDsu2ProYhUqUac69N8RC8BBTCJN", "senderPublicKey": "HMwdLbwQuprhi3kaJNPXUEAtXSKEAA8DKYfsrmLYxaWW", "proofs": [ "4hiTjpXdMUfUHfpXbkXtnTcw9S9pkW9GwJvFVfWRc6PjWEGGqUy1uyzDZjAV2CYq1MHAU41PNmkXyKCBHTJ4D5tx" ], "script": "base64:AAIFAAAAAAAAACEIAhIDCgECEgUKAwICAhIICgYCAgECAgISBwoFAgIBAgIAAAAUAAAAABBrZXlMb2NrUmVjaXBpZW50AgAAAANfbHIAAAAADWtleUxvY2tBbW91bnQCAAAAA19sYQAAAAASa2V5TG9ja0Rlc3RpbmF0aW9uAgAAAANfbGQAAAAAEmtleUxvY2tBc3NldFNvdXJjZQIAAAAEX2xhcwAAAAAKa2V5VmVyc2lvbgIAAAACX3YAAAAACWtleUJyaWRnZQIAAAACX2IAAAAACWtleU9yYWNsZQIAAAACX28AAAAACGtleUFkbWluAgAAAAJfYQAAAAAJa2V5VW5sb2NrAgAAAAJfdQAAAAAPZXJyVW5hdXRob3JpemVkAgAAAAx1bmF1dGhvcml6ZWQAAAAAEGVyclVuaW5pdGlhbGl6ZWQCAAAADXVuaW5pdGlhbGl6ZWQAAAAAE2VyckludmFsaWRTaWduYXR1cmUCAAAAEWludmFsaWQgc2lnbmF0dXJlAAAAABFlcnJBbHJlYWR5Q2xhaW1lZAIAAAAHY2xhaW1lZAAAAAAQZXJyQWxyZWFkeUxvY2tlZAIAAAAGbG9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ljdCB2YWx1ZSBpcyBub3QgZXF1YWwgdG8gaXRzZWxmLgkAAAIAAAABAgAAACRTdHJpY3QgdmFsdWUgaXMgbm90IGVxdWFsIHRvIGl0c2VsZi4JAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAHI/5Wk=", "height": 2044306, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 6ErSoC9tfjpbNLCLLAwq9Ga9pwhBBG2SBu67Aq6NPigf Next: CSpyis2m1gzLxCbRKSzgW1EJEvxW3DLPtwQZjNbDURjT Diff:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let keyAssetAddress = "_aa"
4+let keyLockRecipient = "_lr"
55
6-let keyAssetType = "_at"
6+let keyLockAmount = "_la"
77
8-let keyAssetPrecision = "_ap"
8+let keyLockDestination = "_ld"
99
10-let keyAssetMinFee = "_amf"
10+let keyLockAssetSource = "_las"
1111
12-let keyAssetIsActive = "_aia"
12+let keyVersion = "_v"
1313
14-let ketBaseFeeRateBP = "_bfr"
14+let keyBridge = "_b"
1515
16-let keyValidator = "_v"
16+let keyOracle = "_o"
1717
18-let keyFeeCollector = "_fc"
18+let keyAdmin = "_a"
1919
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'FbV8QW7Jusz'
33-
34-let baseAssetId = base58'3EMsPJ'
35-
36-let chainWaves = base58'3EMsPJ'
37-
38-let BP = 10000
39-
40-let systemPrecision = 9
20+let keyUnlock = "_u"
4121
4222 let errUnauthorized = "unauthorized"
4323
4424 let errUninitialized = "uninitialized"
4525
46-let errInitialized = "initialized"
26+let errInvalidSignature = "invalid signature"
4727
48-let errAlreadyExists = "exists"
28+let errAlreadyClaimed = "claimed"
4929
50-let errNotExists = "not exists"
30+let errAlreadyLocked = "locked"
5131
52-let errInvalidValues = "invalid values"
32+let errBridgeOnly = "not bridge"
5333
54-let errNotOnePayment = "not one payment"
34+let errInvalidLockId = "invalid lockId"
5535
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 typeBase = 0
67-
68-let typeNative = 1
69-
70-let typeWrapped = 2
71-
72-func assertCallerIsManager (i,managerType) = match getBinary((managerType + keyManager)) {
36+func invalidCaller (i,key) = match getBinary(key) {
7337 case authority: ByteVector =>
74- if ((authority != i.caller.bytes))
75- then throw(errUnauthorized)
76- else unit
38+ (authority != i.caller.bytes)
7739 case _ =>
78- throw(errUninitialized)
40+ false
7941 }
8042
8143
82-func assertBridgeIsActive () = if (!(valueOrElse(getBoolean(keyIsActive), false)))
83- then throw(errBridgeDisabled)
44+func assertCallerIsBridge (i) = if (invalidCaller(i, keyBridge))
45+ then throw(errBridgeOnly)
8446 else unit
8547
8648
87-func assertAssetIsActive (assetIdStr) = match getBoolean((assetIdStr + keyAssetIsActive)) {
88- case isActive: Boolean =>
89- if (isActive)
90- then unit
91- else throw(errAssetDisabled)
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
56+ }
57+
58+
59+func assertLockNotExists (lockRecipientKey) = match getBinary(lockRecipientKey) {
60+ case t: ByteVector =>
61+ throw(errAlreadyLocked)
9262 case _ =>
93- throw(errAssetNotFound)
63+ unit
9464 }
9565
9666
97-func getFee (amount,assetIdStr) = {
98- let baseFeeRateBP = valueOrErrorMessage(getInteger(ketBaseFeeRateBP), errUninitialized)
99- let minFee = valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound)
100- let fee = ((amount * baseFeeRateBP) / BP)
101- if ((minFee > fee))
102- then minFee
103- else fee
104- }
105-
106-
107-func pow10 (value,power) = {
108- let absPow = if ((0 > power))
109- then -(power)
110- else power
111- let powerValue = if ((absPow == 0))
112- then 1
113- else if ((absPow == 1))
114- then 10
115- else if ((absPow == 2))
116- then 100
117- else if ((absPow == 3))
118- then 1000
119- else if ((absPow == 4))
120- then 10000
121- else if ((absPow == 5))
122- then 100000
123- else if ((absPow == 6))
124- then 1000000
125- else if ((absPow == 7))
126- then 10000000
127- else if ((absPow == 8))
128- then 100000000
129- else if ((absPow == 9))
130- then 1000000000
131- else throw(errBigPowValue)
132- if ((0 > power))
133- then (value / powerValue)
134- else (value * powerValue)
135- }
136-
137-
138-func toSystemPrecision (amount,precision) = pow10(amount, (systemPrecision - precision))
139-
140-
141-func fromSystemPrecision (amount,precision) = pow10(amount, (precision - systemPrecision))
142-
143-
14467 @Callable(i)
145-func setConfig (admin,validatorAddress,feeCollector,unlockSigner,baseFeeRateBP) = if (isDefined(getBinary((BRIDGE_MANAGER + keyManager))))
146- then throw(errInitialized)
147- else [BinaryEntry((BRIDGE_MANAGER + keyManager), admin), BinaryEntry(keyValidator, validatorAddress), BinaryEntry(keyFeeCollector, feeCollector), BinaryEntry(keyUnlockSigner, unlockSigner), IntegerEntry(ketBaseFeeRateBP, baseFeeRateBP), BooleanEntry(keyIsActive, true)]
68+func setAdmin (newAdmin) = if (invalidCaller(i, keyAdmin))
69+ then throw(errUnauthorized)
70+ else [BinaryEntry(keyAdmin, newAdmin)]
14871
14972
15073
15174 @Callable(i)
152-func addAsset (assetSourceAndAddress,assetIdArg,type,name,description,precision,minFee) = {
153- let callerCheck = assertCallerIsManager(i, ASSET_MANAGER)
154- if ((callerCheck == callerCheck))
155- then {
156- let $t040994858 = if ((type == typeBase))
157- then if (if (if ((assetSourceAndAddress != baseAssetSourceAndAddress))
158- then true
159- else (assetIdArg != baseAssetId))
160- then true
161- else (precision != 8))
162- then throw(errInvalidValues)
163- else $Tuple2(nil, assetIdArg)
164- else if ((type == typeNative))
165- then $Tuple2(nil, assetIdArg)
166- else if ((type == typeWrapped))
167- then if ((size(assetIdArg) == 0))
168- then {
169- let issue = Issue(name, description, 0, precision, true)
170- $Tuple2([issue], calculateAssetId(issue))
171- }
172- else $Tuple2(nil, assetIdArg)
173- else throw(errInvalidValues)
174- let actions = $t040994858._1
175- let assetId = $t040994858._2
176- let assetIdStr = toBase64String(assetId)
177- let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress)
178- let keyNativeAddress = (assetIdStr + keyAssetAddress)
179- if (if (isDefined(getBinary(keySourceAddress)))
180- then true
181- else isDefined(getBinary(keyNativeAddress)))
182- then throw(errAlreadyExists)
183- else (actions ++ [BinaryEntry(keySourceAddress, assetId), BinaryEntry(keyNativeAddress, assetSourceAndAddress), IntegerEntry((assetIdStr + keyAssetType), type), IntegerEntry((assetIdStr + keyAssetPrecision), precision), IntegerEntry((assetIdStr + keyAssetMinFee), minFee), BooleanEntry((assetIdStr + keyAssetIsActive), true)])
184- }
185- else throw("Strict value is not equal to itself.")
186- }
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)]
18778
18879
18980
19081 @Callable(i)
191-func removeAsset (assetSourceAndAddress,newAuthority) = {
192- let callerCheck = assertCallerIsManager(i, ASSET_MANAGER)
193- if ((callerCheck == callerCheck))
82+func createUnlock (lockId,recipient,amount,lockSource,tokenSourceAndAddress,signature) = {
83+ let checkLockId = assertValidLockId(lockId)
84+ if ((checkLockId == checkLockId))
19485 then {
195- let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress)
196- let assetId = valueOrErrorMessage(getBinary(keySourceAddress), errNotExists)
197- let assetIdStr = toBase64String(assetId)
198- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errNotExists)
199- let actions = if ((type == typeBase))
86+ let checkCaller = assertCallerIsBridge(i)
87+ if ((checkCaller == checkCaller))
20088 then {
201- let balance = wavesBalance(this)
202- if ((balance.available > 0))
203- then [ScriptTransfer(Address(newAuthority), balance.available, unit)]
204- else nil
205- }
206- else if ((type == typeNative))
207- then {
208- let balance = assetBalance(this, assetId)
209- if ((balance > 0))
210- then [ScriptTransfer(Address(newAuthority), balance, assetId)]
211- else nil
212- }
213- else if ((type == typeWrapped))
214- then nil
215- else throw(errInvalidValues)
216- (actions ++ [DeleteEntry(keySourceAddress), DeleteEntry((assetIdStr + keyAssetAddress)), DeleteEntry((assetIdStr + keyAssetType)), DeleteEntry((assetIdStr + keyAssetPrecision)), DeleteEntry((assetIdStr + keyAssetMinFee)), DeleteEntry((assetIdStr + keyAssetIsActive))])
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func lock (lockId,recipient,destination) = {
225- let birdgeCheck = assertBridgeIsActive()
226- if ((birdgeCheck == birdgeCheck))
227- then if ((size(i.payments) != 1))
228- then throw(errNotOnePayment)
229- else {
230- let assetId = valueOrElse(i.payments[0].assetId, baseAssetId)
231- let assetIdStr = toBase64String(assetId)
232- let assetCheck = assertAssetIsActive(assetIdStr)
233- if ((assetCheck == assetCheck))
234- then {
235- let amount = i.payments[0].amount
236- let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized)
237- let fee = getFee(amount, assetIdStr)
238- let amountWithoutFee = (amount - fee)
239- if ((0 >= amountWithoutFee))
240- then throw(errNotEnoughBalance)
241- else {
242- let assetSourceAndAddress = valueOrErrorMessage(getBinary((assetIdStr + keyAssetAddress)), errAssetNotFound)
243- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound)
244- let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound)
245- let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized)
246- let createLock = invoke(Address(validatorAddress), "createLock", [lockId, recipient, toSystemPrecision(amountWithoutFee, precision), destination, assetSourceAndAddress], nil)
247- if ((createLock == createLock))
248- then if ((type == typeBase))
249- then [ScriptTransfer(Address(feeCollector), fee, unit)]
250- else if ((type == typeNative))
251- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
252- else if ((type == typeWrapped))
253- then [Burn(assetId, amountWithoutFee), ScriptTransfer(Address(feeCollector), fee, assetId)]
254- else throw(errInvalidValues)
255- else throw("Strict value is not equal to itself.")
256- }
257- }
258- else throw("Strict value is not equal to itself.")
259- }
260- else throw("Strict value is not equal to itself.")
261- }
262-
263-
264-
265-@Callable(i)
266-func unlock (lockId,recipient,amount,lockSource,assetSourceAndAddress,signature) = {
267- let birdgeCheck = assertBridgeIsActive()
268- if ((birdgeCheck == birdgeCheck))
269- then {
270- let assetId = valueOrErrorMessage(getBinary((toBase64String(assetSourceAndAddress) + keyAssetAddress)), errAssetNotFound)
271- let assetIdStr = toBase64String(assetId)
272- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound)
273- let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound)
274- let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized)
275- let unlockSigner = valueOrErrorMessage(getBinary(keyUnlockSigner), errUninitialized)
276- let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized)
277- let createUnlock = invoke(Address(validatorAddress), "createUnlock", [lockId, recipient, amount, lockSource, assetSourceAndAddress, signature], nil)
278- if ((createUnlock == createUnlock))
279- then {
280- let isValid = match createUnlock {
281- case v: Boolean =>
282- v
283- case _ =>
284- false
285- }
286- if (!(isValid))
287- then throw(errInvalidValues)
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)
28894 else {
289- let fee = if ((unlockSigner == i.caller.bytes))
290- then valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound)
291- else 0
292- let amountToSend = fromSystemPrecision(amount, precision)
293- let amountToSendWithoutFee = (amountToSend - fee)
294- if ((0 >= amountToSendWithoutFee))
295- then throw(errNotEnoughBalance)
296- else if ((type == typeBase))
297- then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, unit)] ++ (if ((fee > 0))
298- then [ScriptTransfer(Address(feeCollector), fee, unit)]
299- else nil))
300- else if ((type == typeNative))
301- then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0))
302- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
303- else nil))
304- else if ((type == typeWrapped))
305- then ([Reissue(assetId, amountToSend, true), ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0))
306- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
307- else nil))
308- else throw(errInvalidValues)
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)
309101 }
310102 }
311103 else throw("Strict value is not equal to itself.")
316108
317109
318110 @Callable(i)
319-func setManager (managerType,manager) = {
320- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
321- if ((callerCheck == callerCheck))
322- then [BinaryEntry((managerType + keyManager), manager)]
323- else throw("Strict value is not equal to itself.")
324- }
325-
326-
327-
328-@Callable(i)
329-func setFeeCollector (feeCollector) = {
330- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
331- if ((callerCheck == callerCheck))
332- then [BinaryEntry(keyFeeCollector, feeCollector)]
333- else throw("Strict value is not equal to itself.")
334- }
335-
336-
337-
338-@Callable(i)
339-func setValidator (validator) = {
340- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
341- if ((callerCheck == callerCheck))
342- then [BinaryEntry(keyValidator, validator)]
343- else throw("Strict value is not equal to itself.")
344- }
345-
346-
347-
348-@Callable(i)
349-func startBridge () = {
350- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
351- if ((callerCheck == callerCheck))
352- then [BooleanEntry(keyIsActive, true)]
353- else throw("Strict value is not equal to itself.")
354- }
355-
356-
357-
358-@Callable(i)
359-func stopBridge () = {
360- let callerCheck = assertCallerIsManager(i, STOP_MANAGER)
361- if ((callerCheck == callerCheck))
362- then [BooleanEntry(keyIsActive, false)]
363- else throw("Strict value is not equal to itself.")
364- }
365-
366-
367-
368-@Callable(i)
369-func setMinFee (assetId,minFee) = {
370- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
371- if ((callerCheck == callerCheck))
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))
372116 then {
373- let assetIdStr = toBase64String(assetId)
374-[IntegerEntry((assetIdStr + keyAssetMinFee), minFee)]
375- }
376- else throw("Strict value is not equal to itself.")
377- }
378-
379-
380-
381-@Callable(i)
382-func setBaseFeeRate (baseFeeRateBP) = {
383- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
384- if ((callerCheck == callerCheck))
385- then [IntegerEntry(ketBaseFeeRateBP, baseFeeRateBP)]
386- else throw("Strict value is not equal to itself.")
387- }
388-
389-
390-
391-@Callable(i)
392-func setAssetState (assetId,state) = {
393- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
394- if ((callerCheck == callerCheck))
395- then {
396- let assetIdStr = toBase64String(assetId)
397-[BooleanEntry((assetIdStr + keyAssetIsActive), state)]
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.")
398126 }
399127 else throw("Strict value is not equal to itself.")
400128 }
Full:
OldNewDifferences
11 {-# STDLIB_VERSION 5 #-}
22 {-# SCRIPT_TYPE ACCOUNT #-}
33 {-# CONTENT_TYPE DAPP #-}
4-let keyAssetAddress = "_aa"
4+let keyLockRecipient = "_lr"
55
6-let keyAssetType = "_at"
6+let keyLockAmount = "_la"
77
8-let keyAssetPrecision = "_ap"
8+let keyLockDestination = "_ld"
99
10-let keyAssetMinFee = "_amf"
10+let keyLockAssetSource = "_las"
1111
12-let keyAssetIsActive = "_aia"
12+let keyVersion = "_v"
1313
14-let ketBaseFeeRateBP = "_bfr"
14+let keyBridge = "_b"
1515
16-let keyValidator = "_v"
16+let keyOracle = "_o"
1717
18-let keyFeeCollector = "_fc"
18+let keyAdmin = "_a"
1919
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'FbV8QW7Jusz'
33-
34-let baseAssetId = base58'3EMsPJ'
35-
36-let chainWaves = base58'3EMsPJ'
37-
38-let BP = 10000
39-
40-let systemPrecision = 9
20+let keyUnlock = "_u"
4121
4222 let errUnauthorized = "unauthorized"
4323
4424 let errUninitialized = "uninitialized"
4525
46-let errInitialized = "initialized"
26+let errInvalidSignature = "invalid signature"
4727
48-let errAlreadyExists = "exists"
28+let errAlreadyClaimed = "claimed"
4929
50-let errNotExists = "not exists"
30+let errAlreadyLocked = "locked"
5131
52-let errInvalidValues = "invalid values"
32+let errBridgeOnly = "not bridge"
5333
54-let errNotOnePayment = "not one payment"
34+let errInvalidLockId = "invalid lockId"
5535
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 typeBase = 0
67-
68-let typeNative = 1
69-
70-let typeWrapped = 2
71-
72-func assertCallerIsManager (i,managerType) = match getBinary((managerType + keyManager)) {
36+func invalidCaller (i,key) = match getBinary(key) {
7337 case authority: ByteVector =>
74- if ((authority != i.caller.bytes))
75- then throw(errUnauthorized)
76- else unit
38+ (authority != i.caller.bytes)
7739 case _ =>
78- throw(errUninitialized)
40+ false
7941 }
8042
8143
82-func assertBridgeIsActive () = if (!(valueOrElse(getBoolean(keyIsActive), false)))
83- then throw(errBridgeDisabled)
44+func assertCallerIsBridge (i) = if (invalidCaller(i, keyBridge))
45+ then throw(errBridgeOnly)
8446 else unit
8547
8648
87-func assertAssetIsActive (assetIdStr) = match getBoolean((assetIdStr + keyAssetIsActive)) {
88- case isActive: Boolean =>
89- if (isActive)
90- then unit
91- else throw(errAssetDisabled)
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
56+ }
57+
58+
59+func assertLockNotExists (lockRecipientKey) = match getBinary(lockRecipientKey) {
60+ case t: ByteVector =>
61+ throw(errAlreadyLocked)
9262 case _ =>
93- throw(errAssetNotFound)
63+ unit
9464 }
9565
9666
97-func getFee (amount,assetIdStr) = {
98- let baseFeeRateBP = valueOrErrorMessage(getInteger(ketBaseFeeRateBP), errUninitialized)
99- let minFee = valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound)
100- let fee = ((amount * baseFeeRateBP) / BP)
101- if ((minFee > fee))
102- then minFee
103- else fee
104- }
105-
106-
107-func pow10 (value,power) = {
108- let absPow = if ((0 > power))
109- then -(power)
110- else power
111- let powerValue = if ((absPow == 0))
112- then 1
113- else if ((absPow == 1))
114- then 10
115- else if ((absPow == 2))
116- then 100
117- else if ((absPow == 3))
118- then 1000
119- else if ((absPow == 4))
120- then 10000
121- else if ((absPow == 5))
122- then 100000
123- else if ((absPow == 6))
124- then 1000000
125- else if ((absPow == 7))
126- then 10000000
127- else if ((absPow == 8))
128- then 100000000
129- else if ((absPow == 9))
130- then 1000000000
131- else throw(errBigPowValue)
132- if ((0 > power))
133- then (value / powerValue)
134- else (value * powerValue)
135- }
136-
137-
138-func toSystemPrecision (amount,precision) = pow10(amount, (systemPrecision - precision))
139-
140-
141-func fromSystemPrecision (amount,precision) = pow10(amount, (precision - systemPrecision))
142-
143-
14467 @Callable(i)
145-func setConfig (admin,validatorAddress,feeCollector,unlockSigner,baseFeeRateBP) = if (isDefined(getBinary((BRIDGE_MANAGER + keyManager))))
146- then throw(errInitialized)
147- else [BinaryEntry((BRIDGE_MANAGER + keyManager), admin), BinaryEntry(keyValidator, validatorAddress), BinaryEntry(keyFeeCollector, feeCollector), BinaryEntry(keyUnlockSigner, unlockSigner), IntegerEntry(ketBaseFeeRateBP, baseFeeRateBP), BooleanEntry(keyIsActive, true)]
68+func setAdmin (newAdmin) = if (invalidCaller(i, keyAdmin))
69+ then throw(errUnauthorized)
70+ else [BinaryEntry(keyAdmin, newAdmin)]
14871
14972
15073
15174 @Callable(i)
152-func addAsset (assetSourceAndAddress,assetIdArg,type,name,description,precision,minFee) = {
153- let callerCheck = assertCallerIsManager(i, ASSET_MANAGER)
154- if ((callerCheck == callerCheck))
155- then {
156- let $t040994858 = if ((type == typeBase))
157- then if (if (if ((assetSourceAndAddress != baseAssetSourceAndAddress))
158- then true
159- else (assetIdArg != baseAssetId))
160- then true
161- else (precision != 8))
162- then throw(errInvalidValues)
163- else $Tuple2(nil, assetIdArg)
164- else if ((type == typeNative))
165- then $Tuple2(nil, assetIdArg)
166- else if ((type == typeWrapped))
167- then if ((size(assetIdArg) == 0))
168- then {
169- let issue = Issue(name, description, 0, precision, true)
170- $Tuple2([issue], calculateAssetId(issue))
171- }
172- else $Tuple2(nil, assetIdArg)
173- else throw(errInvalidValues)
174- let actions = $t040994858._1
175- let assetId = $t040994858._2
176- let assetIdStr = toBase64String(assetId)
177- let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress)
178- let keyNativeAddress = (assetIdStr + keyAssetAddress)
179- if (if (isDefined(getBinary(keySourceAddress)))
180- then true
181- else isDefined(getBinary(keyNativeAddress)))
182- then throw(errAlreadyExists)
183- else (actions ++ [BinaryEntry(keySourceAddress, assetId), BinaryEntry(keyNativeAddress, assetSourceAndAddress), IntegerEntry((assetIdStr + keyAssetType), type), IntegerEntry((assetIdStr + keyAssetPrecision), precision), IntegerEntry((assetIdStr + keyAssetMinFee), minFee), BooleanEntry((assetIdStr + keyAssetIsActive), true)])
184- }
185- else throw("Strict value is not equal to itself.")
186- }
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)]
18778
18879
18980
19081 @Callable(i)
191-func removeAsset (assetSourceAndAddress,newAuthority) = {
192- let callerCheck = assertCallerIsManager(i, ASSET_MANAGER)
193- if ((callerCheck == callerCheck))
82+func createUnlock (lockId,recipient,amount,lockSource,tokenSourceAndAddress,signature) = {
83+ let checkLockId = assertValidLockId(lockId)
84+ if ((checkLockId == checkLockId))
19485 then {
195- let keySourceAddress = (toBase64String(assetSourceAndAddress) + keyAssetAddress)
196- let assetId = valueOrErrorMessage(getBinary(keySourceAddress), errNotExists)
197- let assetIdStr = toBase64String(assetId)
198- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errNotExists)
199- let actions = if ((type == typeBase))
86+ let checkCaller = assertCallerIsBridge(i)
87+ if ((checkCaller == checkCaller))
20088 then {
201- let balance = wavesBalance(this)
202- if ((balance.available > 0))
203- then [ScriptTransfer(Address(newAuthority), balance.available, unit)]
204- else nil
205- }
206- else if ((type == typeNative))
207- then {
208- let balance = assetBalance(this, assetId)
209- if ((balance > 0))
210- then [ScriptTransfer(Address(newAuthority), balance, assetId)]
211- else nil
212- }
213- else if ((type == typeWrapped))
214- then nil
215- else throw(errInvalidValues)
216- (actions ++ [DeleteEntry(keySourceAddress), DeleteEntry((assetIdStr + keyAssetAddress)), DeleteEntry((assetIdStr + keyAssetType)), DeleteEntry((assetIdStr + keyAssetPrecision)), DeleteEntry((assetIdStr + keyAssetMinFee)), DeleteEntry((assetIdStr + keyAssetIsActive))])
217- }
218- else throw("Strict value is not equal to itself.")
219- }
220-
221-
222-
223-@Callable(i)
224-func lock (lockId,recipient,destination) = {
225- let birdgeCheck = assertBridgeIsActive()
226- if ((birdgeCheck == birdgeCheck))
227- then if ((size(i.payments) != 1))
228- then throw(errNotOnePayment)
229- else {
230- let assetId = valueOrElse(i.payments[0].assetId, baseAssetId)
231- let assetIdStr = toBase64String(assetId)
232- let assetCheck = assertAssetIsActive(assetIdStr)
233- if ((assetCheck == assetCheck))
234- then {
235- let amount = i.payments[0].amount
236- let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized)
237- let fee = getFee(amount, assetIdStr)
238- let amountWithoutFee = (amount - fee)
239- if ((0 >= amountWithoutFee))
240- then throw(errNotEnoughBalance)
241- else {
242- let assetSourceAndAddress = valueOrErrorMessage(getBinary((assetIdStr + keyAssetAddress)), errAssetNotFound)
243- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound)
244- let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound)
245- let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized)
246- let createLock = invoke(Address(validatorAddress), "createLock", [lockId, recipient, toSystemPrecision(amountWithoutFee, precision), destination, assetSourceAndAddress], nil)
247- if ((createLock == createLock))
248- then if ((type == typeBase))
249- then [ScriptTransfer(Address(feeCollector), fee, unit)]
250- else if ((type == typeNative))
251- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
252- else if ((type == typeWrapped))
253- then [Burn(assetId, amountWithoutFee), ScriptTransfer(Address(feeCollector), fee, assetId)]
254- else throw(errInvalidValues)
255- else throw("Strict value is not equal to itself.")
256- }
257- }
258- else throw("Strict value is not equal to itself.")
259- }
260- else throw("Strict value is not equal to itself.")
261- }
262-
263-
264-
265-@Callable(i)
266-func unlock (lockId,recipient,amount,lockSource,assetSourceAndAddress,signature) = {
267- let birdgeCheck = assertBridgeIsActive()
268- if ((birdgeCheck == birdgeCheck))
269- then {
270- let assetId = valueOrErrorMessage(getBinary((toBase64String(assetSourceAndAddress) + keyAssetAddress)), errAssetNotFound)
271- let assetIdStr = toBase64String(assetId)
272- let type = valueOrErrorMessage(getInteger((assetIdStr + keyAssetType)), errAssetNotFound)
273- let precision = valueOrErrorMessage(getInteger((assetIdStr + keyAssetPrecision)), errAssetNotFound)
274- let validatorAddress = valueOrErrorMessage(getBinary(keyValidator), errUninitialized)
275- let unlockSigner = valueOrErrorMessage(getBinary(keyUnlockSigner), errUninitialized)
276- let feeCollector = valueOrErrorMessage(getBinary(keyFeeCollector), errUninitialized)
277- let createUnlock = invoke(Address(validatorAddress), "createUnlock", [lockId, recipient, amount, lockSource, assetSourceAndAddress, signature], nil)
278- if ((createUnlock == createUnlock))
279- then {
280- let isValid = match createUnlock {
281- case v: Boolean =>
282- v
283- case _ =>
284- false
285- }
286- if (!(isValid))
287- then throw(errInvalidValues)
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)
28894 else {
289- let fee = if ((unlockSigner == i.caller.bytes))
290- then valueOrErrorMessage(getInteger((assetIdStr + keyAssetMinFee)), errAssetNotFound)
291- else 0
292- let amountToSend = fromSystemPrecision(amount, precision)
293- let amountToSendWithoutFee = (amountToSend - fee)
294- if ((0 >= amountToSendWithoutFee))
295- then throw(errNotEnoughBalance)
296- else if ((type == typeBase))
297- then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, unit)] ++ (if ((fee > 0))
298- then [ScriptTransfer(Address(feeCollector), fee, unit)]
299- else nil))
300- else if ((type == typeNative))
301- then ([ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0))
302- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
303- else nil))
304- else if ((type == typeWrapped))
305- then ([Reissue(assetId, amountToSend, true), ScriptTransfer(Address(recipient), amountToSendWithoutFee, assetId)] ++ (if ((fee > 0))
306- then [ScriptTransfer(Address(feeCollector), fee, assetId)]
307- else nil))
308- else throw(errInvalidValues)
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)
309101 }
310102 }
311103 else throw("Strict value is not equal to itself.")
312104 }
313105 else throw("Strict value is not equal to itself.")
314106 }
315107
316108
317109
318110 @Callable(i)
319-func setManager (managerType,manager) = {
320- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
321- if ((callerCheck == callerCheck))
322- then [BinaryEntry((managerType + keyManager), manager)]
323- else throw("Strict value is not equal to itself.")
324- }
325-
326-
327-
328-@Callable(i)
329-func setFeeCollector (feeCollector) = {
330- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
331- if ((callerCheck == callerCheck))
332- then [BinaryEntry(keyFeeCollector, feeCollector)]
333- else throw("Strict value is not equal to itself.")
334- }
335-
336-
337-
338-@Callable(i)
339-func setValidator (validator) = {
340- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
341- if ((callerCheck == callerCheck))
342- then [BinaryEntry(keyValidator, validator)]
343- else throw("Strict value is not equal to itself.")
344- }
345-
346-
347-
348-@Callable(i)
349-func startBridge () = {
350- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
351- if ((callerCheck == callerCheck))
352- then [BooleanEntry(keyIsActive, true)]
353- else throw("Strict value is not equal to itself.")
354- }
355-
356-
357-
358-@Callable(i)
359-func stopBridge () = {
360- let callerCheck = assertCallerIsManager(i, STOP_MANAGER)
361- if ((callerCheck == callerCheck))
362- then [BooleanEntry(keyIsActive, false)]
363- else throw("Strict value is not equal to itself.")
364- }
365-
366-
367-
368-@Callable(i)
369-func setMinFee (assetId,minFee) = {
370- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
371- if ((callerCheck == callerCheck))
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))
372116 then {
373- let assetIdStr = toBase64String(assetId)
374-[IntegerEntry((assetIdStr + keyAssetMinFee), minFee)]
375- }
376- else throw("Strict value is not equal to itself.")
377- }
378-
379-
380-
381-@Callable(i)
382-func setBaseFeeRate (baseFeeRateBP) = {
383- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
384- if ((callerCheck == callerCheck))
385- then [IntegerEntry(ketBaseFeeRateBP, baseFeeRateBP)]
386- else throw("Strict value is not equal to itself.")
387- }
388-
389-
390-
391-@Callable(i)
392-func setAssetState (assetId,state) = {
393- let callerCheck = assertCallerIsManager(i, BRIDGE_MANAGER)
394- if ((callerCheck == callerCheck))
395- then {
396- let assetIdStr = toBase64String(assetId)
397-[BooleanEntry((assetIdStr + keyAssetIsActive), state)]
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.")
398126 }
399127 else throw("Strict value is not equal to itself.")
400128 }
401129
402130

github/deemru/w8io/026f985 
47.27 ms