@hyperbridge/sdk 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -3
- package/dist/browser/index.d.ts +2190 -0
- package/dist/browser/index.js +11662 -0
- package/dist/browser/index.js.map +1 -0
- package/dist/browser/web_bg.wasm +0 -0
- package/dist/node/index.d.ts +2190 -0
- package/dist/node/index.js +11613 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/node_bg.wasm +0 -0
- package/package.json +46 -16
- package/plugins/vite.d.ts +11 -0
- package/plugins/vite.js +55 -0
- package/dist/abis/erc6160.d.ts +0 -370
- package/dist/abis/erc6160.js +0 -238
- package/dist/abis/erc6160.js.map +0 -1
- package/dist/abis/evmHost.d.ts +0 -1752
- package/dist/abis/evmHost.js +0 -2250
- package/dist/abis/evmHost.js.map +0 -1
- package/dist/abis/handler.d.ts +0 -580
- package/dist/abis/handler.js +0 -750
- package/dist/abis/handler.js.map +0 -1
- package/dist/abis/pingModule.d.ts +0 -594
- package/dist/abis/pingModule.js +0 -765
- package/dist/abis/pingModule.js.map +0 -1
- package/dist/abis/tokenGateway.d.ts +0 -839
- package/dist/abis/tokenGateway.js +0 -471
- package/dist/abis/tokenGateway.js.map +0 -1
- package/dist/chain.d.ts +0 -83
- package/dist/chain.js +0 -34
- package/dist/chain.js.map +0 -1
- package/dist/chains/evm.d.ts +0 -86
- package/dist/chains/evm.js +0 -249
- package/dist/chains/evm.js.map +0 -1
- package/dist/chains/substrate.d.ts +0 -88
- package/dist/chains/substrate.js +0 -287
- package/dist/chains/substrate.js.map +0 -1
- package/dist/client.d.ts +0 -216
- package/dist/client.js +0 -774
- package/dist/client.js.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -7
- package/dist/index.js.map +0 -1
- package/dist/queries.d.ts +0 -3
- package/dist/queries.js +0 -78
- package/dist/queries.js.map +0 -1
- package/dist/tests/hyperbridgeRequests.test.d.ts +0 -1
- package/dist/tests/hyperbridgeRequests.test.js +0 -415
- package/dist/tests/hyperbridgeRequests.test.js.map +0 -1
- package/dist/tests/postRequest.test.d.ts +0 -1
- package/dist/tests/postRequest.test.js +0 -293
- package/dist/tests/postRequest.test.js.map +0 -1
- package/dist/tests/setup.d.ts +0 -1
- package/dist/tests/setup.js +0 -6
- package/dist/tests/setup.js.map +0 -1
- package/dist/tests/tokenGateway.test.d.ts +0 -1
- package/dist/tests/tokenGateway.test.js +0 -85
- package/dist/tests/tokenGateway.test.js.map +0 -1
- package/dist/tests/xcmGateway.test.d.ts +0 -1
- package/dist/tests/xcmGateway.test.js +0 -71
- package/dist/tests/xcmGateway.test.js.map +0 -1
- package/dist/types/index.d.ts +0 -238
- package/dist/types/index.js +0 -30
- package/dist/types/index.js.map +0 -1
- package/dist/utils/mmr.d.ts +0 -13
- package/dist/utils/mmr.js +0 -153
- package/dist/utils/mmr.js.map +0 -1
- package/dist/utils/substrate.d.ts +0 -1913
- package/dist/utils/substrate.js +0 -361
- package/dist/utils/substrate.js.map +0 -1
- package/dist/utils/tokenGateway.d.ts +0 -68
- package/dist/utils/tokenGateway.js +0 -151
- package/dist/utils/tokenGateway.js.map +0 -1
- package/dist/utils/xcmGateway.d.ts +0 -81
- package/dist/utils/xcmGateway.js +0 -218
- package/dist/utils/xcmGateway.js.map +0 -1
- package/dist/utils.d.ts +0 -57
- package/dist/utils.js +0 -96
- package/dist/utils.js.map +0 -1
package/dist/utils/substrate.js
DELETED
|
@@ -1,361 +0,0 @@
|
|
|
1
|
-
import { Struct, Vector, u8, u64, Tuple, Enum, _void, u32, Option } from "scale-ts";
|
|
2
|
-
export const H256 = Vector(u8, 32);
|
|
3
|
-
export const EvmStateProof = Struct({
|
|
4
|
-
/**
|
|
5
|
-
* Proof of the contract state.
|
|
6
|
-
*/
|
|
7
|
-
contractProof: Vector(Vector(u8)),
|
|
8
|
-
/**
|
|
9
|
-
* Proof of the storage state.
|
|
10
|
-
*/
|
|
11
|
-
storageProof: Vector(Tuple(Vector(u8), Vector(Vector(u8)))),
|
|
12
|
-
});
|
|
13
|
-
export const SubstrateHashing = Enum({
|
|
14
|
-
/* For chains that use keccak as their hashing algo */
|
|
15
|
-
Keccak: _void,
|
|
16
|
-
/* For chains that use blake2b as their hashing algo */
|
|
17
|
-
Blake2: _void,
|
|
18
|
-
});
|
|
19
|
-
export const SubstrateStateMachineProof = Struct({
|
|
20
|
-
/**
|
|
21
|
-
* The hasher used to hash the state machine state.
|
|
22
|
-
*/
|
|
23
|
-
hasher: SubstrateHashing,
|
|
24
|
-
/**
|
|
25
|
-
* Proof of the state machine state.
|
|
26
|
-
*/
|
|
27
|
-
storageProof: Vector(Vector(u8)),
|
|
28
|
-
});
|
|
29
|
-
export const SubstrateStateProof = Enum({
|
|
30
|
-
/*
|
|
31
|
-
* Uses overlay root for verification
|
|
32
|
-
*/
|
|
33
|
-
OverlayProof: SubstrateStateMachineProof,
|
|
34
|
-
/*
|
|
35
|
-
* Uses state root for verification
|
|
36
|
-
*/
|
|
37
|
-
StateProof: SubstrateStateMachineProof,
|
|
38
|
-
});
|
|
39
|
-
export const BasicProof = Vector(Vector(u8));
|
|
40
|
-
export const LeafIndexAndPos = Struct({
|
|
41
|
-
/*
|
|
42
|
-
* Leaf index
|
|
43
|
-
*/
|
|
44
|
-
leafIndex: u64,
|
|
45
|
-
/*
|
|
46
|
-
* Leaf position in the MMR
|
|
47
|
-
*/
|
|
48
|
-
pos: u64,
|
|
49
|
-
});
|
|
50
|
-
export const MmrProof = Struct({
|
|
51
|
-
/*
|
|
52
|
-
* Proof of the leaf index and position.
|
|
53
|
-
*/
|
|
54
|
-
leafIndexAndPos: Vector(LeafIndexAndPos),
|
|
55
|
-
/*
|
|
56
|
-
* Proof of the leaf data.
|
|
57
|
-
*/
|
|
58
|
-
leafCount: u64,
|
|
59
|
-
/*
|
|
60
|
-
* Proof elements (hashes of siblings of inner nodes on the path to the leaf).
|
|
61
|
-
*/
|
|
62
|
-
items: Vector(H256),
|
|
63
|
-
});
|
|
64
|
-
export const ConsensusStateId = Vector(u8, 4);
|
|
65
|
-
export const ConsensusMessage = Struct({
|
|
66
|
-
/*
|
|
67
|
-
* Consensus message data.
|
|
68
|
-
*/
|
|
69
|
-
consensusProof: Vector(u8),
|
|
70
|
-
/*
|
|
71
|
-
* Consensus state Id
|
|
72
|
-
*/
|
|
73
|
-
consensusStateId: ConsensusStateId,
|
|
74
|
-
/*
|
|
75
|
-
* Public key of the sender
|
|
76
|
-
*/
|
|
77
|
-
signer: Vector(u8),
|
|
78
|
-
});
|
|
79
|
-
export const FraudProofMessage = Struct({
|
|
80
|
-
/*
|
|
81
|
-
* The first valid consensus proof
|
|
82
|
-
*/
|
|
83
|
-
proof1: Vector(u8),
|
|
84
|
-
/*
|
|
85
|
-
* The second valid consensus proof
|
|
86
|
-
*/
|
|
87
|
-
proof2: Vector(u8),
|
|
88
|
-
/*
|
|
89
|
-
* Consensus state Id
|
|
90
|
-
*/
|
|
91
|
-
consensusStateId: ConsensusStateId,
|
|
92
|
-
});
|
|
93
|
-
export const StateMachine = Enum({
|
|
94
|
-
/*
|
|
95
|
-
* Evm state machines
|
|
96
|
-
*/
|
|
97
|
-
Evm: u32,
|
|
98
|
-
/*
|
|
99
|
-
* Polkadot parachains
|
|
100
|
-
*/
|
|
101
|
-
Polkadot: u32,
|
|
102
|
-
/*
|
|
103
|
-
* Kusama parachains
|
|
104
|
-
*/
|
|
105
|
-
Kusama: u32,
|
|
106
|
-
/*
|
|
107
|
-
* Substrate-based standalone chain
|
|
108
|
-
*/
|
|
109
|
-
Substrate: ConsensusStateId,
|
|
110
|
-
/*
|
|
111
|
-
* Tendermint chains
|
|
112
|
-
*/
|
|
113
|
-
Tendermint: ConsensusStateId,
|
|
114
|
-
});
|
|
115
|
-
export const StateMachineId = Struct({
|
|
116
|
-
/*
|
|
117
|
-
* The state machine id
|
|
118
|
-
*/
|
|
119
|
-
id: StateMachine,
|
|
120
|
-
/*
|
|
121
|
-
* The consensus state id
|
|
122
|
-
*/
|
|
123
|
-
consensusStateId: ConsensusStateId,
|
|
124
|
-
});
|
|
125
|
-
export const StateMachineHeight = Struct({
|
|
126
|
-
/*
|
|
127
|
-
* The state machine id
|
|
128
|
-
*/
|
|
129
|
-
id: StateMachineId,
|
|
130
|
-
/*
|
|
131
|
-
* The height of the state machine
|
|
132
|
-
*/
|
|
133
|
-
height: u64,
|
|
134
|
-
});
|
|
135
|
-
export const Proof = Struct({
|
|
136
|
-
/*
|
|
137
|
-
* The height of the state machine
|
|
138
|
-
*/
|
|
139
|
-
height: StateMachineHeight,
|
|
140
|
-
/*
|
|
141
|
-
* The proof
|
|
142
|
-
*/
|
|
143
|
-
proof: Vector(u8),
|
|
144
|
-
});
|
|
145
|
-
export const PostRequest = Struct({
|
|
146
|
-
/*
|
|
147
|
-
* The source state machine of this request.
|
|
148
|
-
*/
|
|
149
|
-
source: StateMachine,
|
|
150
|
-
/*
|
|
151
|
-
* The destination state machine of this request.
|
|
152
|
-
*/
|
|
153
|
-
dest: StateMachine,
|
|
154
|
-
/*
|
|
155
|
-
* The nonce of this request on the source chain
|
|
156
|
-
*/
|
|
157
|
-
nonce: u64,
|
|
158
|
-
/*
|
|
159
|
-
* Module identifier of the sending module
|
|
160
|
-
*/
|
|
161
|
-
from: Vector(u8),
|
|
162
|
-
/*
|
|
163
|
-
* Module identifier of the receiving module
|
|
164
|
-
*/
|
|
165
|
-
to: Vector(u8),
|
|
166
|
-
/*
|
|
167
|
-
* Timestamp which this request expires in seconds.
|
|
168
|
-
*/
|
|
169
|
-
timeoutTimestamp: u64,
|
|
170
|
-
/*
|
|
171
|
-
* Encoded request body
|
|
172
|
-
*/
|
|
173
|
-
body: Vector(u8),
|
|
174
|
-
});
|
|
175
|
-
export const PostResponse = Struct({
|
|
176
|
-
/*
|
|
177
|
-
* The request that triggered this response.
|
|
178
|
-
*/
|
|
179
|
-
post: PostRequest,
|
|
180
|
-
/*
|
|
181
|
-
* The response message.
|
|
182
|
-
*/
|
|
183
|
-
response: Vector(u8),
|
|
184
|
-
/*
|
|
185
|
-
* Timestamp at which this response expires in seconds.
|
|
186
|
-
*/
|
|
187
|
-
timeoutTimestamp: u64,
|
|
188
|
-
});
|
|
189
|
-
export const GetRequest = Struct({
|
|
190
|
-
/*
|
|
191
|
-
* The source state machine of this request.
|
|
192
|
-
*/
|
|
193
|
-
source: StateMachine,
|
|
194
|
-
/*
|
|
195
|
-
* The destination state machine of this request.
|
|
196
|
-
*/
|
|
197
|
-
dest: StateMachine,
|
|
198
|
-
/*
|
|
199
|
-
* The nonce of this request on the source chain
|
|
200
|
-
*/
|
|
201
|
-
nonce: u64,
|
|
202
|
-
/*
|
|
203
|
-
* Module identifier of the sending module
|
|
204
|
-
*/
|
|
205
|
-
from: Vector(u8),
|
|
206
|
-
/*
|
|
207
|
-
* Raw Storage keys that would be used to fetch the values from the counterparty
|
|
208
|
-
* For deriving storage keys for ink contract fields follow the guide in the link below
|
|
209
|
-
* `<https://use.ink/datastructures/storage-in-metadata#a-full-example>`
|
|
210
|
-
* Substrate Keys
|
|
211
|
-
*/
|
|
212
|
-
keys: Vector(Vector(u8)),
|
|
213
|
-
/*
|
|
214
|
-
* Some application-specific metadata relating to this request
|
|
215
|
-
*/
|
|
216
|
-
context: Vector(u8),
|
|
217
|
-
/*
|
|
218
|
-
* Host timestamp at which this request expires in seconds
|
|
219
|
-
*/
|
|
220
|
-
timeoutTimestamp: u64,
|
|
221
|
-
});
|
|
222
|
-
export const StorageValue = Struct({
|
|
223
|
-
/*
|
|
224
|
-
* The request storage keys
|
|
225
|
-
*/
|
|
226
|
-
key: Vector(u8),
|
|
227
|
-
/*
|
|
228
|
-
* The verified value
|
|
229
|
-
*/
|
|
230
|
-
value: Option(Vector(u8)),
|
|
231
|
-
});
|
|
232
|
-
export const GetResponse = Struct({
|
|
233
|
-
/*
|
|
234
|
-
* The Get request that triggered this response.
|
|
235
|
-
*/
|
|
236
|
-
get: GetRequest,
|
|
237
|
-
/*
|
|
238
|
-
* Values derived from the state proof
|
|
239
|
-
*/
|
|
240
|
-
values: Vector(StorageValue),
|
|
241
|
-
});
|
|
242
|
-
export const Request = Enum({
|
|
243
|
-
/*
|
|
244
|
-
* A post request allows a module on a state machine to send arbitrary bytes to another module
|
|
245
|
-
* living in another state machine.
|
|
246
|
-
*/
|
|
247
|
-
Post: PostRequest,
|
|
248
|
-
/*
|
|
249
|
-
* A get request allows a module on a state machine to read the storage of another module
|
|
250
|
-
* living in another state machine.
|
|
251
|
-
*/
|
|
252
|
-
Get: GetRequest,
|
|
253
|
-
});
|
|
254
|
-
export const Response = Enum({
|
|
255
|
-
/*
|
|
256
|
-
* The response to a POST request
|
|
257
|
-
*/
|
|
258
|
-
Post: PostResponse,
|
|
259
|
-
/*
|
|
260
|
-
* The response to a GET request
|
|
261
|
-
*/
|
|
262
|
-
Get: GetResponse,
|
|
263
|
-
});
|
|
264
|
-
export const RequestMessage = Struct({
|
|
265
|
-
/*
|
|
266
|
-
* Requests from source chain
|
|
267
|
-
*/
|
|
268
|
-
requests: Vector(PostRequest),
|
|
269
|
-
/*
|
|
270
|
-
* Membership batch proof for these requests
|
|
271
|
-
*/
|
|
272
|
-
proof: Proof,
|
|
273
|
-
/*
|
|
274
|
-
* Signer information. Ideally should be their account identifier
|
|
275
|
-
*/
|
|
276
|
-
signer: Vector(u8),
|
|
277
|
-
});
|
|
278
|
-
export const RequestResponse = Enum({
|
|
279
|
-
/*
|
|
280
|
-
* A set of requests
|
|
281
|
-
*/
|
|
282
|
-
Request: Vector(Request),
|
|
283
|
-
/*
|
|
284
|
-
* A set of responses
|
|
285
|
-
*/
|
|
286
|
-
Response: Vector(Response),
|
|
287
|
-
});
|
|
288
|
-
export const ResponseMessage = Struct({
|
|
289
|
-
/*
|
|
290
|
-
* A set of either POST requests or responses to be handled
|
|
291
|
-
*/
|
|
292
|
-
datagram: Vector(RequestResponse),
|
|
293
|
-
/*
|
|
294
|
-
* Membership batch proof for these requests/responses
|
|
295
|
-
*/
|
|
296
|
-
proof: Proof,
|
|
297
|
-
/*
|
|
298
|
-
* Signer information. Ideally should be their account identifier
|
|
299
|
-
*/
|
|
300
|
-
signer: Vector(u8),
|
|
301
|
-
});
|
|
302
|
-
export const TimeoutMessage = Enum({
|
|
303
|
-
/*
|
|
304
|
-
* A non memership proof for POST requests
|
|
305
|
-
*/
|
|
306
|
-
Post: Struct({
|
|
307
|
-
/*
|
|
308
|
-
* Timed out requests
|
|
309
|
-
*/
|
|
310
|
-
requests: Vector(Request),
|
|
311
|
-
/*
|
|
312
|
-
* Membership batch proof for these requests
|
|
313
|
-
*/
|
|
314
|
-
proof: Proof,
|
|
315
|
-
}),
|
|
316
|
-
/*
|
|
317
|
-
* A non memership proof for POST responses
|
|
318
|
-
*/
|
|
319
|
-
PostResponse: Struct({
|
|
320
|
-
/*
|
|
321
|
-
* Timed out responses
|
|
322
|
-
*/
|
|
323
|
-
responses: Vector(Response),
|
|
324
|
-
/*
|
|
325
|
-
* Membership batch proof for these responses
|
|
326
|
-
*/
|
|
327
|
-
proof: Proof,
|
|
328
|
-
}),
|
|
329
|
-
/*
|
|
330
|
-
* There are no proofs for Get timeouts
|
|
331
|
-
*/
|
|
332
|
-
Get: Struct({
|
|
333
|
-
/*
|
|
334
|
-
* Timed out requests
|
|
335
|
-
*/
|
|
336
|
-
requests: Vector(Request),
|
|
337
|
-
}),
|
|
338
|
-
});
|
|
339
|
-
export const Message = Enum({
|
|
340
|
-
/*
|
|
341
|
-
* A consensus update message
|
|
342
|
-
*/
|
|
343
|
-
ConsensusMessage: ConsensusMessage,
|
|
344
|
-
/*
|
|
345
|
-
* A fraud proof message
|
|
346
|
-
*/
|
|
347
|
-
FraudProofMessage: FraudProofMessage,
|
|
348
|
-
/*
|
|
349
|
-
* A request message
|
|
350
|
-
*/
|
|
351
|
-
RequestMessage: RequestMessage,
|
|
352
|
-
/*
|
|
353
|
-
* A response message
|
|
354
|
-
*/
|
|
355
|
-
ResponseMessage: ResponseMessage,
|
|
356
|
-
/*
|
|
357
|
-
* A request timeout message
|
|
358
|
-
*/
|
|
359
|
-
TimeoutMessage: TimeoutMessage,
|
|
360
|
-
});
|
|
361
|
-
//# sourceMappingURL=substrate.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"substrate.js","sourceRoot":"","sources":["../../src/utils/substrate.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAwBnF,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAA;AAElC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;IACnC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IACjC;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;CAC3D,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,IAAI,CAAC;IACpC,sDAAsD;IACtD,MAAM,EAAE,KAAK;IACb,uDAAuD;IACvD,MAAM,EAAE,KAAK;CACb,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC;IAChD;;OAEG;IACH,MAAM,EAAE,gBAAgB;IACxB;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CAChC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,CAAC;IACvC;;OAEG;IACH,YAAY,EAAE,0BAA0B;IACxC;;OAEG;IACH,UAAU,EAAE,0BAA0B;CACtC,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,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AC,eAAe,CAAC;IACjC;;OAEG;IACH,KAAK,EAAE,KAAK;IACZ;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;CAClB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,CAAC;IAClC;;OAEG;IACH,IAAI,EAAE,MAAM,CAAC;QACZ;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;QACzB;;WAEG;QACH,KAAK,EAAE,KAAK;KACZ,CAAC;IACF;;OAEG;IACH,YAAY,EAAE,MAAM,CAAC;QACpB;;WAEG;QACH,SAAS,EAAE,MAAM,CAAC,QAAQ,CAAC;QAC3B;;WAEG;QACH,KAAK,EAAE,KAAK;KACZ,CAAC;IACF;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;QACX;;WAEG;QACH,QAAQ,EAAE,MAAM,CAAC,OAAO,CAAC;KACzB,CAAC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,CAAC;IAC3B;;OAEG;IACH,gBAAgB,EAAE,gBAAgB;IAClC;;OAEG;IACH,iBAAiB,EAAE,iBAAiB;IACpC;;OAEG;IACH,cAAc,EAAE,cAAc;IAC9B;;OAEG;IACH,eAAe,EAAE,eAAe;IAChC;;OAEG;IACH,cAAc,EAAE,cAAc;CAC9B,CAAC,CAAA"}
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { ApiPromise } from "@polkadot/api";
|
|
2
|
-
import type { HexString } from "../types";
|
|
3
|
-
import type { SignerOptions } from "@polkadot/api/types";
|
|
4
|
-
import { type HyperbridgeTxEvents } from "./xcmGateway";
|
|
5
|
-
export type Params = {
|
|
6
|
-
/** Asset symbol for the teleport operation */
|
|
7
|
-
symbol: string;
|
|
8
|
-
/**
|
|
9
|
-
* Destination state machine identifier (e.g., "EVM-1", "SUBSTRATE-cere")
|
|
10
|
-
* that specifies the target blockchain or network
|
|
11
|
-
*/
|
|
12
|
-
destination: string;
|
|
13
|
-
/**
|
|
14
|
-
* Recipient address in hexadecimal format where the assets will be sent
|
|
15
|
-
* on the destination chain
|
|
16
|
-
*/
|
|
17
|
-
recipient: HexString;
|
|
18
|
-
/**
|
|
19
|
-
* Amount of tokens to teleport, represented as a bigint to handle
|
|
20
|
-
* large numeric values precisely
|
|
21
|
-
*/
|
|
22
|
-
amount: bigint;
|
|
23
|
-
/**
|
|
24
|
-
* Request timeout in block numbers or timestamp, after which the
|
|
25
|
-
* teleport operation will be considered failed
|
|
26
|
-
*/
|
|
27
|
-
timeout: bigint;
|
|
28
|
-
/**
|
|
29
|
-
* Address of the token gateway contract on the destination chain
|
|
30
|
-
* that will process the teleported assets
|
|
31
|
-
*/
|
|
32
|
-
tokenGatewayAddress: Uint8Array;
|
|
33
|
-
/**
|
|
34
|
-
* Fee paid to relayers who process the cross-chain transaction,
|
|
35
|
-
* represented as a bigint
|
|
36
|
-
*/
|
|
37
|
-
relayerFee: bigint;
|
|
38
|
-
/**
|
|
39
|
-
* Optional call data to be executed on the destination chain
|
|
40
|
-
* as part of the teleport operation
|
|
41
|
-
*/
|
|
42
|
-
callData?: Uint8Array;
|
|
43
|
-
/**
|
|
44
|
-
* Flag indicating whether to automatically redeem the tokens
|
|
45
|
-
* for erc20
|
|
46
|
-
*/
|
|
47
|
-
redeem: boolean;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Teleports assets across chains through the token gateway.
|
|
51
|
-
*
|
|
52
|
-
* @param apiPromise - Polkadot API instance
|
|
53
|
-
* @param who - SS58Address
|
|
54
|
-
* @param params - Teleport parameters
|
|
55
|
-
* @param params.symbol - Asset symbol
|
|
56
|
-
* @param params.destination - Target state machine ID
|
|
57
|
-
* @param params.recipient - Recipient address
|
|
58
|
-
* @param params.amount - Amount to teleport
|
|
59
|
-
* @param params.timeout - Operation timeout
|
|
60
|
-
* @param params.tokenGatewayAddress - Gateway contract address
|
|
61
|
-
* @param params.relayerFee - Fee for the relayer
|
|
62
|
-
* @param params.redeem - Whether to redeem on arrival
|
|
63
|
-
* @param params.callData - Optional additional call data
|
|
64
|
-
* @param options - Signer options
|
|
65
|
-
* @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
|
|
66
|
-
* @throws Error when asset ID is unknown or transaction fails
|
|
67
|
-
*/
|
|
68
|
-
export declare function teleport(apiPromise: ApiPromise, who: string, params: Params, options: Partial<SignerOptions>): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { hexToBytes, pad, bytesToHex } from "viem";
|
|
2
|
-
import { Struct, Vector, u8, u64, Option, u128, bool } from "scale-ts";
|
|
3
|
-
import { H256, StateMachine } from "./substrate.js";
|
|
4
|
-
import { convertStateMachineIdToEnum } from "../chain.js";
|
|
5
|
-
import { keccakAsU8a, xxhashAsU8a } from "@polkadot/util-crypto";
|
|
6
|
-
const TeleportParams = Struct({
|
|
7
|
-
/// StateMachine
|
|
8
|
-
destination: StateMachine,
|
|
9
|
-
/// Receipient
|
|
10
|
-
recepient: H256,
|
|
11
|
-
/// Amount
|
|
12
|
-
amount: u128,
|
|
13
|
-
/// Request timeout
|
|
14
|
-
timeout: u64,
|
|
15
|
-
/// Token gateway address
|
|
16
|
-
tokenGatewayAddress: Vector(u8),
|
|
17
|
-
/// Relayer fee
|
|
18
|
-
relayerFee: u128,
|
|
19
|
-
/// Call data
|
|
20
|
-
callData: Option(Vector(u8)),
|
|
21
|
-
/// Redeem
|
|
22
|
-
redeem: bool,
|
|
23
|
-
});
|
|
24
|
-
async function fetchLocalAssetId(params) {
|
|
25
|
-
const { api, assetId } = params;
|
|
26
|
-
// twox_128
|
|
27
|
-
const palletPrefix = xxhashAsU8a("TokenGateway", 128);
|
|
28
|
-
// twox_128
|
|
29
|
-
const storagePrefix = xxhashAsU8a("LocalAssets", 128);
|
|
30
|
-
const full_key = new Uint8Array([...palletPrefix, ...storagePrefix, ...assetId]);
|
|
31
|
-
const hexKey = bytesToHex(full_key);
|
|
32
|
-
// read account balance
|
|
33
|
-
const storage_value = (await api.rpc.state.getStorage(hexKey));
|
|
34
|
-
if (storage_value.isSome) {
|
|
35
|
-
const assetId = storage_value.value.toU8a();
|
|
36
|
-
return assetId;
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Teleports assets across chains through the token gateway.
|
|
42
|
-
*
|
|
43
|
-
* @param apiPromise - Polkadot API instance
|
|
44
|
-
* @param who - SS58Address
|
|
45
|
-
* @param params - Teleport parameters
|
|
46
|
-
* @param params.symbol - Asset symbol
|
|
47
|
-
* @param params.destination - Target state machine ID
|
|
48
|
-
* @param params.recipient - Recipient address
|
|
49
|
-
* @param params.amount - Amount to teleport
|
|
50
|
-
* @param params.timeout - Operation timeout
|
|
51
|
-
* @param params.tokenGatewayAddress - Gateway contract address
|
|
52
|
-
* @param params.relayerFee - Fee for the relayer
|
|
53
|
-
* @param params.redeem - Whether to redeem on arrival
|
|
54
|
-
* @param params.callData - Optional additional call data
|
|
55
|
-
* @param options - Signer options
|
|
56
|
-
* @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
|
|
57
|
-
* @throws Error when asset ID is unknown or transaction fails
|
|
58
|
-
*/
|
|
59
|
-
export async function teleport(apiPromise, who, params, options) {
|
|
60
|
-
const substrateComplianceAddr = (address, stateMachine) => {
|
|
61
|
-
if (stateMachine.startsWith("EVM-"))
|
|
62
|
-
return pad(address, { size: 32, dir: "left" });
|
|
63
|
-
return address;
|
|
64
|
-
};
|
|
65
|
-
const assetId = keccakAsU8a(params.symbol);
|
|
66
|
-
// Fetch scale encoded local asset id
|
|
67
|
-
const scaleEncodedAssetId = await fetchLocalAssetId({ api: apiPromise, assetId });
|
|
68
|
-
if (scaleEncodedAssetId === null) {
|
|
69
|
-
throw new Error("Unknown asset id provided");
|
|
70
|
-
}
|
|
71
|
-
const destination = convertStateMachineIdToEnum(params.destination);
|
|
72
|
-
const recipient = hexToBytes(substrateComplianceAddr(params.recipient, params.destination));
|
|
73
|
-
const teleportParams = {
|
|
74
|
-
destination: destination,
|
|
75
|
-
recepient: Array.from(recipient),
|
|
76
|
-
amount: params.amount,
|
|
77
|
-
timeout: BigInt(params.timeout),
|
|
78
|
-
tokenGatewayAddress: Array.from(params.tokenGatewayAddress),
|
|
79
|
-
relayerFee: BigInt(params.relayerFee),
|
|
80
|
-
redeem: params.redeem,
|
|
81
|
-
callData: params.callData ? Array.from(params.callData) : undefined,
|
|
82
|
-
};
|
|
83
|
-
const encoded = TeleportParams.enc(teleportParams);
|
|
84
|
-
const fullCallData = new Uint8Array([...scaleEncodedAssetId, ...encoded]);
|
|
85
|
-
const tx = apiPromise.tx.tokenGateway.teleport(fullCallData);
|
|
86
|
-
let unsub = () => { };
|
|
87
|
-
const stream = new ReadableStream({
|
|
88
|
-
async start(controller) {
|
|
89
|
-
unsub = await tx.signAndSend(who, options, async (result) => {
|
|
90
|
-
const { isInBlock, isError, dispatchError, txHash, isFinalized, status } = result;
|
|
91
|
-
// @ts-expect-error Type Mismatch
|
|
92
|
-
const events = result.events;
|
|
93
|
-
if (isError) {
|
|
94
|
-
console.error("Transaction failed: ", dispatchError);
|
|
95
|
-
controller.enqueue({ kind: "Error", error: dispatchError });
|
|
96
|
-
return controller.close();
|
|
97
|
-
}
|
|
98
|
-
if (status.type === "Ready") {
|
|
99
|
-
controller.enqueue({
|
|
100
|
-
kind: "Ready",
|
|
101
|
-
transaction_hash: txHash.toHex(),
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
if (isFinalized) {
|
|
105
|
-
controller.enqueue({
|
|
106
|
-
kind: "Finalized",
|
|
107
|
-
transaction_hash: txHash.toHex(),
|
|
108
|
-
events: events,
|
|
109
|
-
});
|
|
110
|
-
return controller.close();
|
|
111
|
-
}
|
|
112
|
-
if (isInBlock) {
|
|
113
|
-
const commitment_hash = readIsmpCommitmentHash(events);
|
|
114
|
-
if (!commitment_hash) {
|
|
115
|
-
controller.enqueue({
|
|
116
|
-
kind: "Error",
|
|
117
|
-
error: new Error("Commitment Hash missing"),
|
|
118
|
-
});
|
|
119
|
-
return controller.close();
|
|
120
|
-
}
|
|
121
|
-
const blockHash = status.asInBlock.toHex();
|
|
122
|
-
const header = await apiPromise.rpc.chain.getHeader(blockHash);
|
|
123
|
-
controller.enqueue({
|
|
124
|
-
kind: "Dispatched",
|
|
125
|
-
transaction_hash: txHash.toHex(),
|
|
126
|
-
block_number: header.number.toBigInt(),
|
|
127
|
-
commitment: commitment_hash,
|
|
128
|
-
events: events,
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
});
|
|
132
|
-
},
|
|
133
|
-
cancel: () => unsub(),
|
|
134
|
-
}, {
|
|
135
|
-
highWaterMark: 3,
|
|
136
|
-
size: () => 1,
|
|
137
|
-
});
|
|
138
|
-
return stream;
|
|
139
|
-
}
|
|
140
|
-
function readIsmpCommitmentHash(events) {
|
|
141
|
-
for (const record of events) {
|
|
142
|
-
const { event } = record;
|
|
143
|
-
if (event.section === "ismp" && event.method === "Request") {
|
|
144
|
-
const commitment = event.data[3].toHex();
|
|
145
|
-
if (!commitment)
|
|
146
|
-
return;
|
|
147
|
-
return commitment;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
//# sourceMappingURL=tokenGateway.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tokenGateway.js","sourceRoot":"","sources":["../../src/utils/tokenGateway.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAS,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAEtD,OAAO,EAAE,2BAA2B,EAAE,MAAM,SAAS,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AE,GAAG,MAAM,CAAA;QAExB,IAAI,KAAK,CAAC,OAAO,KAAK,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YAC5D,MAAM,UAAU,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,CAAA;YAExC,IAAI,CAAC,UAAU;gBAAE,OAAM;YAEvB,OAAO,UAAU,CAAA;QAClB,CAAC;IACF,CAAC;AACF,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import type { ApiPromise } from "@polkadot/api";
|
|
2
|
-
import type { HexString } from "../types";
|
|
3
|
-
import type { SignerOptions } from "@polkadot/api/types";
|
|
4
|
-
import type { EventRecord } from "@polkadot/types/interfaces";
|
|
5
|
-
import type { ISubmittableResult } from "@polkadot/types/types";
|
|
6
|
-
export type HyperbridgeTxEvents = {
|
|
7
|
-
kind: "Ready";
|
|
8
|
-
transaction_hash: HexString;
|
|
9
|
-
} | {
|
|
10
|
-
kind: "Dispatched";
|
|
11
|
-
transaction_hash: HexString;
|
|
12
|
-
block_number: bigint;
|
|
13
|
-
commitment: HexString;
|
|
14
|
-
events: ISubmittableResult["events"];
|
|
15
|
-
} | {
|
|
16
|
-
kind: "Finalized";
|
|
17
|
-
transaction_hash: HexString;
|
|
18
|
-
events: ISubmittableResult["events"];
|
|
19
|
-
} | {
|
|
20
|
-
kind: "Error";
|
|
21
|
-
error: unknown;
|
|
22
|
-
};
|
|
23
|
-
/**
|
|
24
|
-
* Parameters for teleporting DOT from Polkadot relay chain to EVM-based destination
|
|
25
|
-
*/
|
|
26
|
-
export type XcmGatewayParams = {
|
|
27
|
-
/**
|
|
28
|
-
* Destination state machine ID (chain ID) where assets will be teleported to
|
|
29
|
-
* This value identifies the specific EVM chain in the destination network
|
|
30
|
-
*/
|
|
31
|
-
destination: number;
|
|
32
|
-
/**
|
|
33
|
-
* The recipient address on the destination chain (in hex format)
|
|
34
|
-
* This is the EVM address that will receive the teleported assets
|
|
35
|
-
*/
|
|
36
|
-
recipient: HexString;
|
|
37
|
-
/**
|
|
38
|
-
* Amount of DOT to teleport
|
|
39
|
-
* This will be converted to the appropriate format internally
|
|
40
|
-
*/
|
|
41
|
-
amount: bigint;
|
|
42
|
-
/**
|
|
43
|
-
* Request timeout value in blocks or timestamp
|
|
44
|
-
* Specifies how long the teleport request remains valid before expiring
|
|
45
|
-
*/
|
|
46
|
-
timeout: bigint;
|
|
47
|
-
/**
|
|
48
|
-
* The parachain ID of the Hyperbridge
|
|
49
|
-
*/
|
|
50
|
-
paraId: number;
|
|
51
|
-
};
|
|
52
|
-
/**
|
|
53
|
-
* Teleports DOT tokens from Polkadot relay chain to an EVM-based destination chain
|
|
54
|
-
* using XCM (Cross-Consensus Message Format).
|
|
55
|
-
*
|
|
56
|
-
* This function initiates a teleport transaction, monitors its status, and yields events
|
|
57
|
-
* about the transaction's progress through an AsyncGenerator. It handles the complete
|
|
58
|
-
* lifecycle of a teleport operation:
|
|
59
|
-
* 1. Transaction preparation and signing
|
|
60
|
-
* 2. Broadcasting to the relay chain
|
|
61
|
-
* 3. Tracking the transaction until it's included in a block
|
|
62
|
-
* 4. Monitoring Hyperbridge for the commitment hash
|
|
63
|
-
*
|
|
64
|
-
* @param relayApi - Polkadot API instance connected to the relay chain
|
|
65
|
-
* @param hyperbridge - Polkadot API instance connected to the Hyperbridge parachain
|
|
66
|
-
* @param who - Sender's SS58Address address
|
|
67
|
-
* @param options - Transaction signing options
|
|
68
|
-
* @param params - Teleport parameters including destination, recipient, and amount
|
|
69
|
-
* @yields {HyperbridgeTxEvents} Stream of events indicating transaction status
|
|
70
|
-
* @throws {Error} If there's an issue getting the Hyperbridge block or other failures
|
|
71
|
-
*/
|
|
72
|
-
export declare function teleportDot(relayApi: ApiPromise, hyperbridge: ApiPromise, who: string, options: Partial<SignerOptions>, params: XcmGatewayParams): Promise<ReadableStream<HyperbridgeTxEvents>>;
|
|
73
|
-
/**
|
|
74
|
-
* Extracts the commitment hash from the event data if the event data
|
|
75
|
-
* matches the expected data
|
|
76
|
-
*/
|
|
77
|
-
export declare function extractCommitmentHashFromEvent({ record, from: who, params, }: {
|
|
78
|
-
record: EventRecord;
|
|
79
|
-
from: string;
|
|
80
|
-
params: Pick<XcmGatewayParams, "destination" | "recipient">;
|
|
81
|
-
}): HexString | undefined;
|