@hyperbridge/sdk 1.0.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.
Files changed (69) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +127 -0
  3. package/dist/abis/erc6160.d.ts +370 -0
  4. package/dist/abis/erc6160.js +238 -0
  5. package/dist/abis/erc6160.js.map +1 -0
  6. package/dist/abis/evmHost.d.ts +1752 -0
  7. package/dist/abis/evmHost.js +2250 -0
  8. package/dist/abis/evmHost.js.map +1 -0
  9. package/dist/abis/handler.d.ts +580 -0
  10. package/dist/abis/handler.js +750 -0
  11. package/dist/abis/handler.js.map +1 -0
  12. package/dist/abis/pingModule.d.ts +594 -0
  13. package/dist/abis/pingModule.js +765 -0
  14. package/dist/abis/pingModule.js.map +1 -0
  15. package/dist/abis/tokenGateway.d.ts +839 -0
  16. package/dist/abis/tokenGateway.js +471 -0
  17. package/dist/abis/tokenGateway.js.map +1 -0
  18. package/dist/chain.d.ts +83 -0
  19. package/dist/chain.js +34 -0
  20. package/dist/chain.js.map +1 -0
  21. package/dist/chains/evm.d.ts +86 -0
  22. package/dist/chains/evm.js +249 -0
  23. package/dist/chains/evm.js.map +1 -0
  24. package/dist/chains/substrate.d.ts +88 -0
  25. package/dist/chains/substrate.js +287 -0
  26. package/dist/chains/substrate.js.map +1 -0
  27. package/dist/client.d.ts +216 -0
  28. package/dist/client.js +774 -0
  29. package/dist/client.js.map +1 -0
  30. package/dist/index.d.ts +6 -0
  31. package/dist/index.js +7 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/queries.d.ts +3 -0
  34. package/dist/queries.js +78 -0
  35. package/dist/queries.js.map +1 -0
  36. package/dist/tests/hyperbridgeRequests.test.d.ts +1 -0
  37. package/dist/tests/hyperbridgeRequests.test.js +415 -0
  38. package/dist/tests/hyperbridgeRequests.test.js.map +1 -0
  39. package/dist/tests/postRequest.test.d.ts +1 -0
  40. package/dist/tests/postRequest.test.js +293 -0
  41. package/dist/tests/postRequest.test.js.map +1 -0
  42. package/dist/tests/setup.d.ts +1 -0
  43. package/dist/tests/setup.js +6 -0
  44. package/dist/tests/setup.js.map +1 -0
  45. package/dist/tests/tokenGateway.test.d.ts +1 -0
  46. package/dist/tests/tokenGateway.test.js +85 -0
  47. package/dist/tests/tokenGateway.test.js.map +1 -0
  48. package/dist/tests/xcmGateway.test.d.ts +1 -0
  49. package/dist/tests/xcmGateway.test.js +71 -0
  50. package/dist/tests/xcmGateway.test.js.map +1 -0
  51. package/dist/types/index.d.ts +238 -0
  52. package/dist/types/index.js +30 -0
  53. package/dist/types/index.js.map +1 -0
  54. package/dist/utils/mmr.d.ts +13 -0
  55. package/dist/utils/mmr.js +153 -0
  56. package/dist/utils/mmr.js.map +1 -0
  57. package/dist/utils/substrate.d.ts +1913 -0
  58. package/dist/utils/substrate.js +361 -0
  59. package/dist/utils/substrate.js.map +1 -0
  60. package/dist/utils/tokenGateway.d.ts +68 -0
  61. package/dist/utils/tokenGateway.js +151 -0
  62. package/dist/utils/tokenGateway.js.map +1 -0
  63. package/dist/utils/xcmGateway.d.ts +81 -0
  64. package/dist/utils/xcmGateway.js +218 -0
  65. package/dist/utils/xcmGateway.js.map +1 -0
  66. package/dist/utils.d.ts +57 -0
  67. package/dist/utils.js +96 -0
  68. package/dist/utils.js.map +1 -0
  69. package/package.json +74 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) [year] [fullname]
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,127 @@
1
+ # @hyperbridge/sdk
2
+
3
+ A JavaScript/TypeScript SDK for interacting with the Hyperbridge indexer and monitoring cross-chain messages.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @hyperbridge/sdk
9
+ # or
10
+ yarn add @hyperbridge/sdk
11
+ # or
12
+ pnpm add @hyperbridge/sdk
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Initialize Client
18
+
19
+ ```ts
20
+ import { IndexerClient } from "@hyperbridge/sdk"
21
+
22
+ const indexer = new IndexerClient({
23
+ source: {
24
+ consensusStateId: "BSC0",
25
+ rpcUrl: "https://data-seed-prebsc-1-s1.binance.org:8545",
26
+ stateMachineId: "EVM-97",
27
+ host: "0x...", // Host contract address
28
+ },
29
+ dest: {
30
+ consensusStateId: "GNO0",
31
+ rpcUrl: "https://rpc.chiadochain.net",
32
+ stateMachineId: "EVM-10200",
33
+ host: "0x...", // Host contract address
34
+ },
35
+ hyperbridge: {
36
+ consensusStateId: "PAS0",
37
+ stateMachineId: "KUSAMA-4009",
38
+ wsUrl: "wss://gargantua.polytope.technology",
39
+ },
40
+ url: "http://localhost:3000", // URL of the Hyperbridge indexer API
41
+ pollInterval: 1_000, // Every second
42
+ })
43
+ ```
44
+
45
+ ### Monitor Post Request Status
46
+
47
+ ```ts
48
+ import { postRequestCommitment } from "@hyperbridge/sdk"
49
+
50
+ // Get status stream for a commitment
51
+ const commitment = postRequestCommitment(request)
52
+ for await (const status of indexer.postRequestStatusStream(commitment)) {
53
+ switch (status.status) {
54
+ case RequestStatus.SOURCE_FINALIZED:
55
+ console.log("Request finalized on source chain")
56
+ break
57
+ case RequestStatus.HYPERBRIDGE_DELIVERED:
58
+ console.log("Request delivered to Hyperbridge")
59
+ break
60
+ // other statuses
61
+ }
62
+ }
63
+ ```
64
+
65
+ ### Monitor Timeout Status
66
+
67
+ ```ts
68
+ // Get timeout status stream
69
+ for await (const timeout of indexer.postRequestTimeoutStream(commitment)) {
70
+ switch (timeout.status) {
71
+ case TimeoutStatus.PENDING_TIMEOUT:
72
+ console.log("Request pending timeout")
73
+ break
74
+ case TimeoutStatus.HYPERBRIDGE_TIMED_OUT:
75
+ console.log("Request timed out on Hyperbridge")
76
+ break
77
+ // other timeout statuses
78
+ }
79
+ }
80
+ ```
81
+
82
+ ### Query Request Status
83
+
84
+ ```ts
85
+ // Get current status
86
+ const request = await indexer.queryRequestWithStatus(commitment)
87
+ console.log(request?.statuses)
88
+ ```
89
+
90
+ ### Chain Utilities
91
+
92
+ ```ts
93
+ import { EvmChain, SubstrateChain } from "@hyperbridge/sdk"
94
+
95
+ // Interact with EVM chains
96
+ const evmChain = new EvmChain({
97
+ url: "https://rpc.chiadochain.net",
98
+ chainId: 10200,
99
+ host: "0x58A41B89F4871725E5D898d98eF4BF917601c5eB",
100
+ })
101
+
102
+ // Interact with Substrate chains
103
+ const hyperbridge = new SubstrateChain({
104
+ ws: "wss://gargantua.dev.polytope.technology",
105
+ hasher: "Keccak",
106
+ })
107
+
108
+ const proof = await hyperbridge.queryStateProof(blockNumber, keys)
109
+ ```
110
+
111
+ ## API Reference
112
+
113
+ ### Classes
114
+
115
+ - IndexerClient - Main client for interacting with the indexer
116
+ - EvmChain - Utilities for EVM chain interaction
117
+ - SubstrateChain - Utilities for Substrate chain interaction
118
+
119
+ ### Types
120
+
121
+ - RequestStatus - Enum of possible request statuses
122
+ - TimeoutStatus - Enum of possible timeout statuses
123
+ - HexString - Type for hex-encoded strings
124
+
125
+ ### Examples
126
+
127
+ See the tests [directory](/packages/sdk/src/tests/postRequest.test.ts) for complete examples.
@@ -0,0 +1,370 @@
1
+ declare const _default: {
2
+ ABI: readonly [{
3
+ readonly inputs: readonly [{
4
+ readonly internalType: "address";
5
+ readonly name: "admin";
6
+ readonly type: "address";
7
+ }, {
8
+ readonly internalType: "string";
9
+ readonly name: "name";
10
+ readonly type: "string";
11
+ }, {
12
+ readonly internalType: "string";
13
+ readonly name: "symbol";
14
+ readonly type: "string";
15
+ }];
16
+ readonly stateMutability: "nonpayable";
17
+ readonly type: "constructor";
18
+ }, {
19
+ readonly inputs: readonly [];
20
+ readonly name: "NotRoleAdmin";
21
+ readonly type: "error";
22
+ }, {
23
+ readonly inputs: readonly [];
24
+ readonly name: "PermissionDenied";
25
+ readonly type: "error";
26
+ }, {
27
+ readonly anonymous: false;
28
+ readonly inputs: readonly [{
29
+ readonly indexed: true;
30
+ readonly internalType: "address";
31
+ readonly name: "owner";
32
+ readonly type: "address";
33
+ }, {
34
+ readonly indexed: true;
35
+ readonly internalType: "address";
36
+ readonly name: "spender";
37
+ readonly type: "address";
38
+ }, {
39
+ readonly indexed: false;
40
+ readonly internalType: "uint256";
41
+ readonly name: "value";
42
+ readonly type: "uint256";
43
+ }];
44
+ readonly name: "Approval";
45
+ readonly type: "event";
46
+ }, {
47
+ readonly anonymous: false;
48
+ readonly inputs: readonly [{
49
+ readonly indexed: true;
50
+ readonly internalType: "address";
51
+ readonly name: "from";
52
+ readonly type: "address";
53
+ }, {
54
+ readonly indexed: true;
55
+ readonly internalType: "address";
56
+ readonly name: "to";
57
+ readonly type: "address";
58
+ }, {
59
+ readonly indexed: false;
60
+ readonly internalType: "uint256";
61
+ readonly name: "value";
62
+ readonly type: "uint256";
63
+ }];
64
+ readonly name: "Transfer";
65
+ readonly type: "event";
66
+ }, {
67
+ readonly inputs: readonly [];
68
+ readonly name: "BURNER_ROLE";
69
+ readonly outputs: readonly [{
70
+ readonly internalType: "bytes32";
71
+ readonly name: "";
72
+ readonly type: "bytes32";
73
+ }];
74
+ readonly stateMutability: "view";
75
+ readonly type: "function";
76
+ }, {
77
+ readonly inputs: readonly [];
78
+ readonly name: "MINTER_ROLE";
79
+ readonly outputs: readonly [{
80
+ readonly internalType: "bytes32";
81
+ readonly name: "";
82
+ readonly type: "bytes32";
83
+ }];
84
+ readonly stateMutability: "view";
85
+ readonly type: "function";
86
+ }, {
87
+ readonly inputs: readonly [{
88
+ readonly internalType: "address";
89
+ readonly name: "owner";
90
+ readonly type: "address";
91
+ }, {
92
+ readonly internalType: "address";
93
+ readonly name: "spender";
94
+ readonly type: "address";
95
+ }];
96
+ readonly name: "allowance";
97
+ readonly outputs: readonly [{
98
+ readonly internalType: "uint256";
99
+ readonly name: "";
100
+ readonly type: "uint256";
101
+ }];
102
+ readonly stateMutability: "view";
103
+ readonly type: "function";
104
+ }, {
105
+ readonly inputs: readonly [{
106
+ readonly internalType: "address";
107
+ readonly name: "spender";
108
+ readonly type: "address";
109
+ }, {
110
+ readonly internalType: "uint256";
111
+ readonly name: "amount";
112
+ readonly type: "uint256";
113
+ }];
114
+ readonly name: "approve";
115
+ readonly outputs: readonly [{
116
+ readonly internalType: "bool";
117
+ readonly name: "";
118
+ readonly type: "bool";
119
+ }];
120
+ readonly stateMutability: "nonpayable";
121
+ readonly type: "function";
122
+ }, {
123
+ readonly inputs: readonly [{
124
+ readonly internalType: "address";
125
+ readonly name: "account";
126
+ readonly type: "address";
127
+ }];
128
+ readonly name: "balanceOf";
129
+ readonly outputs: readonly [{
130
+ readonly internalType: "uint256";
131
+ readonly name: "";
132
+ readonly type: "uint256";
133
+ }];
134
+ readonly stateMutability: "view";
135
+ readonly type: "function";
136
+ }, {
137
+ readonly inputs: readonly [{
138
+ readonly internalType: "address";
139
+ readonly name: "_from";
140
+ readonly type: "address";
141
+ }, {
142
+ readonly internalType: "uint256";
143
+ readonly name: "_amount";
144
+ readonly type: "uint256";
145
+ }, {
146
+ readonly internalType: "bytes";
147
+ readonly name: "";
148
+ readonly type: "bytes";
149
+ }];
150
+ readonly name: "burn";
151
+ readonly outputs: readonly [];
152
+ readonly stateMutability: "nonpayable";
153
+ readonly type: "function";
154
+ }, {
155
+ readonly inputs: readonly [];
156
+ readonly name: "decimals";
157
+ readonly outputs: readonly [{
158
+ readonly internalType: "uint8";
159
+ readonly name: "";
160
+ readonly type: "uint8";
161
+ }];
162
+ readonly stateMutability: "view";
163
+ readonly type: "function";
164
+ }, {
165
+ readonly inputs: readonly [{
166
+ readonly internalType: "address";
167
+ readonly name: "spender";
168
+ readonly type: "address";
169
+ }, {
170
+ readonly internalType: "uint256";
171
+ readonly name: "subtractedValue";
172
+ readonly type: "uint256";
173
+ }];
174
+ readonly name: "decreaseAllowance";
175
+ readonly outputs: readonly [{
176
+ readonly internalType: "bool";
177
+ readonly name: "";
178
+ readonly type: "bool";
179
+ }];
180
+ readonly stateMutability: "nonpayable";
181
+ readonly type: "function";
182
+ }, {
183
+ readonly inputs: readonly [];
184
+ readonly name: "getBurnerRole";
185
+ readonly outputs: readonly [{
186
+ readonly internalType: "bytes32";
187
+ readonly name: "";
188
+ readonly type: "bytes32";
189
+ }];
190
+ readonly stateMutability: "pure";
191
+ readonly type: "function";
192
+ }, {
193
+ readonly inputs: readonly [];
194
+ readonly name: "getMinterRole";
195
+ readonly outputs: readonly [{
196
+ readonly internalType: "bytes32";
197
+ readonly name: "";
198
+ readonly type: "bytes32";
199
+ }];
200
+ readonly stateMutability: "pure";
201
+ readonly type: "function";
202
+ }, {
203
+ readonly inputs: readonly [{
204
+ readonly internalType: "bytes32";
205
+ readonly name: "_role";
206
+ readonly type: "bytes32";
207
+ }, {
208
+ readonly internalType: "address";
209
+ readonly name: "_account";
210
+ readonly type: "address";
211
+ }];
212
+ readonly name: "grantRole";
213
+ readonly outputs: readonly [];
214
+ readonly stateMutability: "nonpayable";
215
+ readonly type: "function";
216
+ }, {
217
+ readonly inputs: readonly [{
218
+ readonly internalType: "bytes32";
219
+ readonly name: "_role";
220
+ readonly type: "bytes32";
221
+ }, {
222
+ readonly internalType: "address";
223
+ readonly name: "_account";
224
+ readonly type: "address";
225
+ }];
226
+ readonly name: "hasRole";
227
+ readonly outputs: readonly [{
228
+ readonly internalType: "bool";
229
+ readonly name: "";
230
+ readonly type: "bool";
231
+ }];
232
+ readonly stateMutability: "view";
233
+ readonly type: "function";
234
+ }, {
235
+ readonly inputs: readonly [{
236
+ readonly internalType: "address";
237
+ readonly name: "spender";
238
+ readonly type: "address";
239
+ }, {
240
+ readonly internalType: "uint256";
241
+ readonly name: "addedValue";
242
+ readonly type: "uint256";
243
+ }];
244
+ readonly name: "increaseAllowance";
245
+ readonly outputs: readonly [{
246
+ readonly internalType: "bool";
247
+ readonly name: "";
248
+ readonly type: "bool";
249
+ }];
250
+ readonly stateMutability: "nonpayable";
251
+ readonly type: "function";
252
+ }, {
253
+ readonly inputs: readonly [{
254
+ readonly internalType: "address";
255
+ readonly name: "_to";
256
+ readonly type: "address";
257
+ }, {
258
+ readonly internalType: "uint256";
259
+ readonly name: "_amount";
260
+ readonly type: "uint256";
261
+ }, {
262
+ readonly internalType: "bytes";
263
+ readonly name: "";
264
+ readonly type: "bytes";
265
+ }];
266
+ readonly name: "mint";
267
+ readonly outputs: readonly [];
268
+ readonly stateMutability: "nonpayable";
269
+ readonly type: "function";
270
+ }, {
271
+ readonly inputs: readonly [];
272
+ readonly name: "name";
273
+ readonly outputs: readonly [{
274
+ readonly internalType: "string";
275
+ readonly name: "";
276
+ readonly type: "string";
277
+ }];
278
+ readonly stateMutability: "view";
279
+ readonly type: "function";
280
+ }, {
281
+ readonly inputs: readonly [{
282
+ readonly internalType: "bytes32";
283
+ readonly name: "_role";
284
+ readonly type: "bytes32";
285
+ }, {
286
+ readonly internalType: "address";
287
+ readonly name: "_account";
288
+ readonly type: "address";
289
+ }];
290
+ readonly name: "revokeRole";
291
+ readonly outputs: readonly [];
292
+ readonly stateMutability: "nonpayable";
293
+ readonly type: "function";
294
+ }, {
295
+ readonly inputs: readonly [{
296
+ readonly internalType: "bytes4";
297
+ readonly name: "_interfaceId";
298
+ readonly type: "bytes4";
299
+ }];
300
+ readonly name: "supportsInterface";
301
+ readonly outputs: readonly [{
302
+ readonly internalType: "bool";
303
+ readonly name: "";
304
+ readonly type: "bool";
305
+ }];
306
+ readonly stateMutability: "view";
307
+ readonly type: "function";
308
+ }, {
309
+ readonly inputs: readonly [];
310
+ readonly name: "symbol";
311
+ readonly outputs: readonly [{
312
+ readonly internalType: "string";
313
+ readonly name: "";
314
+ readonly type: "string";
315
+ }];
316
+ readonly stateMutability: "view";
317
+ readonly type: "function";
318
+ }, {
319
+ readonly inputs: readonly [];
320
+ readonly name: "totalSupply";
321
+ readonly outputs: readonly [{
322
+ readonly internalType: "uint256";
323
+ readonly name: "";
324
+ readonly type: "uint256";
325
+ }];
326
+ readonly stateMutability: "view";
327
+ readonly type: "function";
328
+ }, {
329
+ readonly inputs: readonly [{
330
+ readonly internalType: "address";
331
+ readonly name: "to";
332
+ readonly type: "address";
333
+ }, {
334
+ readonly internalType: "uint256";
335
+ readonly name: "amount";
336
+ readonly type: "uint256";
337
+ }];
338
+ readonly name: "transfer";
339
+ readonly outputs: readonly [{
340
+ readonly internalType: "bool";
341
+ readonly name: "";
342
+ readonly type: "bool";
343
+ }];
344
+ readonly stateMutability: "nonpayable";
345
+ readonly type: "function";
346
+ }, {
347
+ readonly inputs: readonly [{
348
+ readonly internalType: "address";
349
+ readonly name: "from";
350
+ readonly type: "address";
351
+ }, {
352
+ readonly internalType: "address";
353
+ readonly name: "to";
354
+ readonly type: "address";
355
+ }, {
356
+ readonly internalType: "uint256";
357
+ readonly name: "amount";
358
+ readonly type: "uint256";
359
+ }];
360
+ readonly name: "transferFrom";
361
+ readonly outputs: readonly [{
362
+ readonly internalType: "bool";
363
+ readonly name: "";
364
+ readonly type: "bool";
365
+ }];
366
+ readonly stateMutability: "nonpayable";
367
+ readonly type: "function";
368
+ }];
369
+ };
370
+ export default _default;