@hyperbridge/sdk 1.0.0 → 1.1.12

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 (78) hide show
  1. package/README.md +45 -3
  2. package/dist/browser/index.d.ts +1952 -0
  3. package/dist/browser/index.js +6827 -0
  4. package/dist/browser/index.js.map +1 -0
  5. package/dist/browser/web_bg.wasm +0 -0
  6. package/dist/node/index.d.ts +1952 -0
  7. package/dist/node/index.js +6778 -0
  8. package/dist/node/index.js.map +1 -0
  9. package/dist/node/node_bg.wasm +0 -0
  10. package/package.json +43 -15
  11. package/plugins/vite.d.ts +11 -0
  12. package/plugins/vite.js +55 -0
  13. package/dist/abis/erc6160.d.ts +0 -370
  14. package/dist/abis/erc6160.js +0 -238
  15. package/dist/abis/erc6160.js.map +0 -1
  16. package/dist/abis/evmHost.d.ts +0 -1752
  17. package/dist/abis/evmHost.js +0 -2250
  18. package/dist/abis/evmHost.js.map +0 -1
  19. package/dist/abis/handler.d.ts +0 -580
  20. package/dist/abis/handler.js +0 -750
  21. package/dist/abis/handler.js.map +0 -1
  22. package/dist/abis/pingModule.d.ts +0 -594
  23. package/dist/abis/pingModule.js +0 -765
  24. package/dist/abis/pingModule.js.map +0 -1
  25. package/dist/abis/tokenGateway.d.ts +0 -839
  26. package/dist/abis/tokenGateway.js +0 -471
  27. package/dist/abis/tokenGateway.js.map +0 -1
  28. package/dist/chain.d.ts +0 -83
  29. package/dist/chain.js +0 -34
  30. package/dist/chain.js.map +0 -1
  31. package/dist/chains/evm.d.ts +0 -86
  32. package/dist/chains/evm.js +0 -249
  33. package/dist/chains/evm.js.map +0 -1
  34. package/dist/chains/substrate.d.ts +0 -88
  35. package/dist/chains/substrate.js +0 -287
  36. package/dist/chains/substrate.js.map +0 -1
  37. package/dist/client.d.ts +0 -216
  38. package/dist/client.js +0 -774
  39. package/dist/client.js.map +0 -1
  40. package/dist/index.d.ts +0 -6
  41. package/dist/index.js +0 -7
  42. package/dist/index.js.map +0 -1
  43. package/dist/queries.d.ts +0 -3
  44. package/dist/queries.js +0 -78
  45. package/dist/queries.js.map +0 -1
  46. package/dist/tests/hyperbridgeRequests.test.d.ts +0 -1
  47. package/dist/tests/hyperbridgeRequests.test.js +0 -415
  48. package/dist/tests/hyperbridgeRequests.test.js.map +0 -1
  49. package/dist/tests/postRequest.test.d.ts +0 -1
  50. package/dist/tests/postRequest.test.js +0 -293
  51. package/dist/tests/postRequest.test.js.map +0 -1
  52. package/dist/tests/setup.d.ts +0 -1
  53. package/dist/tests/setup.js +0 -6
  54. package/dist/tests/setup.js.map +0 -1
  55. package/dist/tests/tokenGateway.test.d.ts +0 -1
  56. package/dist/tests/tokenGateway.test.js +0 -85
  57. package/dist/tests/tokenGateway.test.js.map +0 -1
  58. package/dist/tests/xcmGateway.test.d.ts +0 -1
  59. package/dist/tests/xcmGateway.test.js +0 -71
  60. package/dist/tests/xcmGateway.test.js.map +0 -1
  61. package/dist/types/index.d.ts +0 -238
  62. package/dist/types/index.js +0 -30
  63. package/dist/types/index.js.map +0 -1
  64. package/dist/utils/mmr.d.ts +0 -13
  65. package/dist/utils/mmr.js +0 -153
  66. package/dist/utils/mmr.js.map +0 -1
  67. package/dist/utils/substrate.d.ts +0 -1913
  68. package/dist/utils/substrate.js +0 -361
  69. package/dist/utils/substrate.js.map +0 -1
  70. package/dist/utils/tokenGateway.d.ts +0 -68
  71. package/dist/utils/tokenGateway.js +0 -151
  72. package/dist/utils/tokenGateway.js.map +0 -1
  73. package/dist/utils/xcmGateway.d.ts +0 -81
  74. package/dist/utils/xcmGateway.js +0 -218
  75. package/dist/utils/xcmGateway.js.map +0 -1
  76. package/dist/utils.d.ts +0 -57
  77. package/dist/utils.js +0 -96
  78. package/dist/utils.js.map +0 -1
Binary file
package/package.json CHANGED
@@ -1,12 +1,22 @@
1
1
  {
2
2
  "name": "@hyperbridge/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.1.12",
4
4
  "description": "The hyperclient SDK provides utilities for querying proofs and statuses for cross-chain requests from HyperBridge.",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "module": "./dist/index.mjs",
5
+ "type": "module",
6
+ "types": "./dist/node/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "browser": "./dist/browser/index.js",
10
+ "import": "./dist/node/index.js"
11
+ },
12
+ "./plugins/vite": {
13
+ "import": "./plugins/vite.js",
14
+ "types": "./plugins/vite.d.ts"
15
+ }
16
+ },
8
17
  "files": [
9
- "dist"
18
+ "dist",
19
+ "plugins"
10
20
  ],
11
21
  "keywords": [
12
22
  "hyperbridge",
@@ -19,7 +29,6 @@
19
29
  "cryptocurrency",
20
30
  "evm"
21
31
  ],
22
- "type": "module",
23
32
  "homepage": "https://github.com/polytope-labs/hyperbridge-sdk#readme",
24
33
  "bugs": {
25
34
  "url": "https://github.com/polytope-labs/hyperbridge-sdk/issues"
@@ -36,11 +45,14 @@
36
45
  "@polkadot/types": "14.0.1",
37
46
  "@polkadot/util": "13.3.1",
38
47
  "@polkadot/util-crypto": "13.3.1",
48
+ "@types/lodash-es": "^4.17.12",
49
+ "consola": "^3.4.2",
39
50
  "graphql": "^16.10.0",
40
51
  "graphql-request": "^7.1.2",
41
- "lodash": "^4.17.21",
52
+ "lodash-es": "^4.17.15",
42
53
  "rpc-websocket-client": "^1.1.4",
43
54
  "scale-ts": "^1.6.1",
55
+ "std-env": "^3.9.0",
44
56
  "ts-pattern": "^5.6.2",
45
57
  "viem": "^2.23.5"
46
58
  },
@@ -48,25 +60,41 @@
48
60
  "@biomejs/biome": "^1.9.4",
49
61
  "@polkadot/keyring": "13.4.3",
50
62
  "@polytope-labs/hyperclient": "1.2.0",
51
- "@types/lodash": "^4.17.15",
52
63
  "@types/node": "^22.13.5",
53
- "@vitest/coverage-v8": "^3.0.7",
64
+ "@vitest/coverage-v8": "^3.1.4",
54
65
  "dotenv": "^16.4.7",
55
66
  "jsdom": "^26.0.0",
56
67
  "log-timestamp": "^0.3.0",
57
- "resolve-tspaths": "^0.8.23",
68
+ "tsup": "^8.4.0",
58
69
  "typescript": "^5.7.3",
59
70
  "vite-tsconfig-paths": "^5.1.4",
60
- "vitest": "^3.0.7",
61
- "vite": "^6.2.0"
71
+ "vitest": "^3.1.4",
72
+ "@hyperbridge/filler": "0.1.0"
73
+ },
74
+ "peerDependencies": {
75
+ "vite": "^5.0.0 || ^6.0.0"
62
76
  },
63
77
  "publishConfig": {
64
78
  "access": "public"
65
79
  },
80
+ "engineStrict": true,
81
+ "engines": {
82
+ "node": ">=22.x.x"
83
+ },
66
84
  "scripts": {
67
- "build": "tsc && resolve-tspaths",
68
- "test": "vitest --watch=false --maxConcurrency=1",
69
- "test:watch": "vitest",
85
+ "build": "pnpm run build:browser && pnpm run build:node",
86
+ "build:node": "tsup --config tsup-node.config.ts",
87
+ "build:browser": "tsup --config tsup-browser.config.ts",
88
+ "postinstall": "pnpm run build",
89
+ "test": "npm run test:concurrent && npm run test:sequence",
90
+ "test:file": "vitest --watch=false --maxConcurrency=1",
91
+ "test:concurrent": "vitest --watch=false --exclude=./src/tests/sequential",
92
+ "test:sequence": "vitest --watch=false --sequence.concurrent=false ./src/tests/sequential/**",
93
+ "test:requests": "vitest --watch=false --sequence.concurrent=false ./src/tests/sequential/requests.test.ts",
94
+ "test:intent-gateway": "vitest --watch=false --sequence.concurrent=false ./src/tests/sequential/intentGateway.test.ts",
95
+ "test:token-gateway": "vitest --watch=false --sequence.concurrent=false ./src/tests/sequential/tokenGateway.test.ts",
96
+ "test:evm-substrate": "vitest --watch=false --sequence.concurrent=false ./src/tests/sequential/evm-substrate.test.ts",
97
+ "test:watch": "vitest --exclude=./src/tests/sequential",
70
98
  "lint": "biome lint .",
71
99
  "lint:fix": "biome lint --write .",
72
100
  "format": "prettier --write \"src/**/*.ts\""
@@ -0,0 +1,11 @@
1
+ import type { Plugin } from "vite"
2
+
3
+ /**
4
+ * A Vite plugin that copies the WebAssembly file from @hyperbridge/sdk to the Vite cache directory.
5
+ * This ensures the WASM file is available for browser imports when using Vite.
6
+ *
7
+ * @returns {Plugin} A Vite plugin
8
+ */
9
+ export function copyWasm(): Plugin
10
+
11
+ export default copyWasm
@@ -0,0 +1,55 @@
1
+ import path from "node:path"
2
+ import { copyFile } from "node:fs/promises"
3
+ import { colorize } from "consola/utils"
4
+
5
+ const logMessage = (message) => {
6
+ const time = new Date().toLocaleTimeString([], {
7
+ hour: "2-digit",
8
+ minute: "2-digit",
9
+ second: "2-digit",
10
+ hour12: true,
11
+ })
12
+
13
+ const timestamp = colorize("dim", time)
14
+ const tag = colorize("bold", colorize("magenta", "[hyperbridge]"))
15
+
16
+ return console.log(timestamp, tag, message)
17
+ }
18
+
19
+ /**
20
+ *
21
+ * @returns {Plugin}
22
+ */
23
+ const copyWasm = () => {
24
+ return {
25
+ name: "hyperbridge-copy-wasm-plugin",
26
+ buildStart: async function makeCopy(ctx) {
27
+ const is_dev_mode = Object.keys(ctx).length === 0
28
+
29
+ if (!is_dev_mode) return
30
+
31
+ // Get path to the consuming project's node_modules
32
+ const projectNodeModules = path.resolve(process.cwd(), "node_modules")
33
+
34
+ // Find the @hyperbridge/sdk package in node_modules
35
+ const source = path.resolve(projectNodeModules, "@hyperbridge/sdk/dist/browser/web_bg.wasm")
36
+
37
+ // Destination in the Vite cache directory
38
+ const destDir = path.resolve(projectNodeModules, ".vite/deps")
39
+ const dest = path.resolve(destDir, "web_bg.wasm")
40
+
41
+ // Wait for .vite folder to exist
42
+ setTimeout(async () => {
43
+ try {
44
+ logMessage("📦 Copying wasm dependency")
45
+ await copyFile(source, dest)
46
+ logMessage("✅ Copy complete")
47
+ } catch (error) {
48
+ logMessage(`❌ Error copying wasm file: ${error.message}`)
49
+ }
50
+ }, 2000)
51
+ },
52
+ }
53
+ }
54
+
55
+ export default copyWasm
@@ -1,370 +0,0 @@
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;