tx · CaTH2KLxnsnSEcHNRfFAjhm1B8QW1m1NgV75nRAu2FAB 3N9J3wuPH3fe1vTsLwJSticprdzZWXzZtMb: -0.01000000 Waves 2022.05.21 18:46 [2061635] smart account 3N9J3wuPH3fe1vTsLwJSticprdzZWXzZtMb > SELF 0.00000000 Waves
{ "type": 13, "id": "CaTH2KLxnsnSEcHNRfFAjhm1B8QW1m1NgV75nRAu2FAB", "fee": 1000000, "feeAssetId": null, "timestamp": 1653148095451, "version": 2, "chainId": 84, "sender": "3N9J3wuPH3fe1vTsLwJSticprdzZWXzZtMb", "senderPublicKey": "6YTEFQ5JhfL8TsLSjyXNG4TVYq2Jmu3nkmXvxD1Nj5mn", "proofs": [ "4z3isXRBAj7MLSiezMKYNcKX4LAVMWd7kvVxaMxS6TLbQbDyqxPYw7H1tnhcX4iM1vUG2L6EsMJHUBPdsvAaDm9q" ], "script": "base64:AAIFAAAAAAAAACwIAhIGCgQCAgICEggKBgICAQICAhIHCgUCAgECAhIDCgECEgMKAQISAwoBAgAAABUAAAAAEGtleUxvY2tSZWNpcGllbnQCAAAAA19scgAAAAANa2V5TG9ja0Ftb3VudAIAAAADX2xhAAAAABJrZXlMb2NrRGVzdGluYXRpb24CAAAAA19sZAAAAAASa2V5TG9ja0Fzc2V0U291cmNlAgAAAARfbGFzAAAAAAprZXlWZXJzaW9uAgAAAAJfdgAAAAAJa2V5QnJpZGdlAgAAAAJfYgAAAAAJa2V5T3JhY2xlAgAAAAJfbwAAAAAIa2V5QWRtaW4CAAAAAl9hAAAAAAlrZXlVbmxvY2sCAAAAAl91AAAAAA9lcnJVbmF1dGhvcml6ZWQCAAAADHVuYXV0aG9yaXplZAAAAAAQZXJyVW5pbml0aWFsaXplZAIAAAANdW5pbml0aWFsaXplZAAAAAATZXJySW52YWxpZFNpZ25hdHVyZQIAAAARaW52YWxpZCBzaWduYXR1cmUAAAAAEWVyckFscmVhZHlDbGFpbWVkAgAAAAdjbGFpbWVkAAAAABBlcnJBbHJlYWR5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UAAAAJbmV3QnJpZGdlBQAAAANuaWwJAAACAAAAAQIAAAAkU3RyaWN0IHZhbHVlIGlzIG5vdCBlcXVhbCB0byBpdHNlbGYuAAAAAJlbLbE=", "height": 2061635, "applicationStatus": "succeeded", "spentComplexity": 0 } View: original | compacted Prev: 9PRY8NtqmKyvqp7prE1fzSwiumYzyLExDVKHx2kqEhsa Next: 4xUQjh14G5Ac6zsRHHjCZ8V5bSFGxpNf66RSSk8AqAdH Full:
Old | New | Differences | |
---|---|---|---|
1 | 1 | {-# STDLIB_VERSION 5 #-} | |
2 | 2 | {-# SCRIPT_TYPE ACCOUNT #-} | |
3 | 3 | {-# CONTENT_TYPE DAPP #-} | |
4 | 4 | let keyLockRecipient = "_lr" | |
5 | 5 | ||
6 | 6 | let keyLockAmount = "_la" | |
7 | 7 | ||
8 | 8 | let keyLockDestination = "_ld" | |
9 | 9 | ||
10 | 10 | let keyLockAssetSource = "_las" | |
11 | 11 | ||
12 | 12 | let keyVersion = "_v" | |
13 | 13 | ||
14 | 14 | let keyBridge = "_b" | |
15 | 15 | ||
16 | 16 | let keyOracle = "_o" | |
17 | 17 | ||
18 | 18 | let keyAdmin = "_a" | |
19 | 19 | ||
20 | 20 | let keyUnlock = "_u" | |
21 | 21 | ||
22 | 22 | let errUnauthorized = "unauthorized" | |
23 | 23 | ||
24 | 24 | let errUninitialized = "uninitialized" | |
25 | 25 | ||
26 | 26 | let errInvalidSignature = "invalid signature" | |
27 | 27 | ||
28 | 28 | let errAlreadyClaimed = "claimed" | |
29 | 29 | ||
30 | 30 | let errAlreadyLocked = "locked" | |
31 | 31 | ||
32 | 32 | let errInvalidLockId = "invalid lockId" | |
33 | 33 | ||
34 | 34 | let chainWaves = "V0FWRQ==" | |
35 | 35 | ||
36 | 36 | func assertCaller (i,key) = match getBinary(key) { | |
37 | 37 | case authority: ByteVector => | |
38 | 38 | if ((authority != i.caller.bytes)) | |
39 | 39 | then throw(errUnauthorized) | |
40 | 40 | else unit | |
41 | 41 | case _ => | |
42 | 42 | throw(errUninitialized) | |
43 | 43 | } | |
44 | 44 | ||
45 | 45 | ||
46 | 46 | func assertCallerIsBridge (i) = assertCaller(i, keyBridge) | |
47 | 47 | ||
48 | 48 | ||
49 | 49 | func assertCallerIsAdmin (i) = assertCaller(i, keyAdmin) | |
50 | 50 | ||
51 | 51 | ||
52 | 52 | func assertValidLockId (lockId) = { | |
53 | 53 | let version = valueOrErrorMessage(getBinary(keyVersion), errUninitialized) | |
54 | 54 | if (if ((size(lockId) != 16)) | |
55 | 55 | then true | |
56 | 56 | else (take(lockId, 1) != version)) | |
57 | 57 | then throw(errInvalidLockId) | |
58 | 58 | else unit | |
59 | 59 | } | |
60 | 60 | ||
61 | 61 | ||
62 | 62 | func assertLockNotExists (lockRecipientKey) = match getBinary(lockRecipientKey) { | |
63 | 63 | case t: ByteVector => | |
64 | 64 | throw(errAlreadyLocked) | |
65 | 65 | case _ => | |
66 | 66 | unit | |
67 | 67 | } | |
68 | 68 | ||
69 | 69 | ||
70 | 70 | @Callable(i) | |
71 | 71 | func init (admin,version,bridge,oracle) = if (isDefined(getBinary(keyAdmin))) | |
72 | 72 | then throw(errUnauthorized) | |
73 | 73 | else [BinaryEntry(keyVersion, version), BinaryEntry(keyBridge, bridge), BinaryEntry(keyOracle, oracle), BinaryEntry(keyAdmin, admin)] | |
74 | 74 | ||
75 | 75 | ||
76 | 76 | ||
77 | 77 | @Callable(i) | |
78 | 78 | func createUnlock (lockId,recipient,amount,lockSource,tokenSourceAndAddress,signature) = { | |
79 | 79 | let checkLockId = assertValidLockId(lockId) | |
80 | 80 | if ((checkLockId == checkLockId)) | |
81 | 81 | then { | |
82 | 82 | let checkCaller = assertCallerIsBridge(i) | |
83 | 83 | if ((checkCaller == checkCaller)) | |
84 | 84 | then { | |
85 | 85 | let lockIdStr = toBase64String(lockId) | |
86 | 86 | let lockSourceStr = toBase64String(lockSource) | |
87 | 87 | let unlockKey = (((lockSourceStr + "_") + lockIdStr) + keyUnlock) | |
88 | 88 | if (isDefined(getBoolean(unlockKey))) | |
89 | 89 | then throw(errAlreadyClaimed) | |
90 | 90 | else { | |
91 | 91 | let message = makeString([lockIdStr, toBase64String(recipient), toString(amount), lockSourceStr, toBase64String(tokenSourceAndAddress), chainWaves], "_") | |
92 | 92 | let hash = keccak256(toBytes(message)) | |
93 | 93 | let recoveredKey = ecrecover(hash, signature) | |
94 | 94 | if ((recoveredKey != getBinaryValue(keyOracle))) | |
95 | 95 | then throw(errInvalidSignature) | |
96 | 96 | else $Tuple2([BooleanEntry(unlockKey, true)], true) | |
97 | 97 | } | |
98 | 98 | } | |
99 | 99 | else throw("Strict value is not equal to itself.") | |
100 | 100 | } | |
101 | 101 | else throw("Strict value is not equal to itself.") | |
102 | 102 | } | |
103 | 103 | ||
104 | 104 | ||
105 | 105 | ||
106 | 106 | @Callable(i) | |
107 | 107 | func createLock (lockId,recipient,amount,lockDestination,assetSourceAndAddress) = { | |
108 | 108 | let lockIdStr = toBase64String(lockId) | |
109 | 109 | let lockRecipientKey = (lockIdStr + keyLockRecipient) | |
110 | 110 | let checkCaller = assertCallerIsBridge(i) | |
111 | 111 | if ((checkCaller == checkCaller)) | |
112 | 112 | then { | |
113 | 113 | let checkLockId = assertValidLockId(lockId) | |
114 | 114 | if ((checkLockId == checkLockId)) | |
115 | 115 | then { | |
116 | 116 | let checkLock = assertLockNotExists(lockRecipientKey) | |
117 | 117 | if ((checkLock == checkLock)) | |
118 | 118 | then [BinaryEntry((lockIdStr + keyLockRecipient), recipient), IntegerEntry((lockIdStr + keyLockAmount), amount), BinaryEntry((lockIdStr + keyLockDestination), lockDestination), BinaryEntry((lockIdStr + keyLockAssetSource), assetSourceAndAddress)] | |
119 | 119 | else throw("Strict value is not equal to itself.") | |
120 | 120 | } | |
121 | 121 | else throw("Strict value is not equal to itself.") | |
122 | 122 | } | |
123 | 123 | else throw("Strict value is not equal to itself.") | |
124 | 124 | } | |
125 | 125 | ||
126 | 126 | ||
127 | 127 | ||
128 | 128 | @Callable(i) | |
129 | 129 | func setAdmin (newAdmin) = { | |
130 | 130 | let checkCaller = assertCallerIsAdmin(i) | |
131 | 131 | if ((checkCaller == checkCaller)) | |
132 | 132 | then [BinaryEntry(keyAdmin, newAdmin)] | |
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 setOracle (newOracle) = { | |
140 | 140 | let checkCaller = assertCallerIsAdmin(i) | |
141 | 141 | if ((checkCaller == checkCaller)) | |
142 | 142 | then [BinaryEntry(keyOracle, newOracle)] | |
143 | 143 | else throw("Strict value is not equal to itself.") | |
144 | 144 | } | |
145 | 145 | ||
146 | 146 | ||
147 | 147 | ||
148 | 148 | @Callable(i) | |
149 | 149 | func setBridge (newBridge) = { | |
150 | 150 | let checkCaller = assertCallerIsAdmin(i) | |
151 | 151 | if ((checkCaller == checkCaller)) | |
152 | 152 | then [BinaryEntry(keyBridge, newBridge)] | |
153 | 153 | else throw("Strict value is not equal to itself.") | |
154 | 154 | } | |
155 | 155 | ||
156 | 156 |
github/deemru/w8io/169f3d6 26.85 ms ◑