@paraspell/evm-snowbridge 13.2.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ParaSpell
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,63 @@
1
+ <br /><br />
2
+
3
+ <div align="center">
4
+ <h1 align="center">@paraspell/evm-snowbridge</h1>
5
+ <h4 align="center"> An extension to @paraspell/sdk for Snowbridge interactions from Ethereum to Polkadot. </h4>
6
+ <p align="center">
7
+ <a href="https://npmjs.com/package/@paraspell/evm-snowbridge">
8
+ <img alt="version" src="https://img.shields.io/npm/v/@paraspell/evm-snowbridge?style=flat-square" />
9
+ </a>
10
+ <a href="https://npmjs.com/package/@paraspell/evm-snowbridge">
11
+ <img alt="downloads" src="https://img.shields.io/npm/dm/@paraspell/evm-snowbridge?style=flat-square" />
12
+ </a>
13
+ <a href="https://github.com/paraspell/xcm-sdk/actions">
14
+ <img alt="build" src="https://github.com/paraspell/xcm-tools/actions/workflows/ci.yml/badge.svg" />
15
+ </a>
16
+ </p>
17
+ <p>How to interact <a href = "https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#ethereum-polkadot-transfer" \>[here]</p>
18
+ <p>XCM SDK starter template project <a href = "https://github.com/paraspell/xcm-sdk-template" \>[here]</p>
19
+ </div>
20
+
21
+ <br /><br />
22
+ <br /><br />
23
+
24
+ # Installation
25
+
26
+ Please reffer to [SDK documentation](https://paraspell.github.io/docs/xcm-sdk/send-xcm.html#ethereum-polkadot-transfer)
27
+
28
+ ## 💻 Testing
29
+
30
+ - Run compilation using `pnpm compile`
31
+
32
+ - Run linting test using `pnpm lint`
33
+
34
+ - Run unit tests using `pnpm test`
35
+
36
+ > [!NOTE]
37
+ > Snowbridge transfers can be tested in [Playground](https://playground.paraspell.xyz/https://playground.paraspell.xyz/xcm-sdk/xcm-transfer).
38
+
39
+ ## Contribute to XCM Tools and earn rewards 💰
40
+
41
+ We run an open Bug Bounty Program that rewards contributors for reporting and fixing bugs in the project. More information on bug bounty can be found in the [official documentation](https://paraspell.github.io/docs/contribution-guidelines.html).
42
+
43
+ ## Get Support 🚑
44
+
45
+ - Contact form on our [landing page](https://paraspell.xyz/#contact-us).
46
+ - Message us on our [X](https://x.com/paraspell).
47
+ - Support channel on [telegram](https://t.me/paraspell).
48
+
49
+ ## License
50
+
51
+ Made with 💛 by [ParaSpell✨](https://paraspell.xyz/)
52
+
53
+ Published under [MIT License](https://github.com/paraspell/xcm-tools/blob/main/packages/evm-snowbridge/LICENSE).
54
+
55
+ ## Supported by
56
+
57
+ <p align="center">
58
+ <picture>
59
+ <source media="(prefers-color-scheme: dark)" srcset="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_transparent.png">
60
+ <source media="(prefers-color-scheme: light)" srcset="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_w3f_standard.png">
61
+ <img width="750" alt="Shows a black logo in light color mode and a white one in dark color mode." src="https://github.com/paraspell/presskit/blob/main/logos_supporters/polkadot_kusama_w3f_standard.png">
62
+ </picture>
63
+ </p>
@@ -0,0 +1,13 @@
1
+ import { TEvmTransferOptions } from '@paraspell/sdk-core';
2
+ import { WalletClient, Hash } from 'viem';
3
+
4
+ declare const executeEvmSnowbridgeTransfer: <TApi, TRes, TSigner>({ api, signer, recipient, to, currency }: TEvmTransferOptions<TApi, TRes, TSigner>) => Promise<string>;
5
+
6
+ declare const approveToken: (signer: WalletClient, amount: bigint, symbol: string) => Promise<Hash>;
7
+
8
+ declare const getTokenBalance: (signer: WalletClient, symbol: string) => Promise<{
9
+ balance: bigint;
10
+ gatewayAllowance: bigint;
11
+ }>;
12
+
13
+ export { approveToken, executeEvmSnowbridgeTransfer, getTokenBalance };
package/dist/index.mjs ADDED
@@ -0,0 +1,459 @@
1
+ import { getParaId, RoutingResolutionError, MissingParameterError, findAssetInfoOrThrow, abstractDecimals, assertHasId, isOverrideLocationSpecifier, UnsupportedOperationError, InvalidAddressError, registerEvmSnowbridgeExtension } from '@paraspell/sdk-core';
2
+ import { toPolkadotV2, SnowbridgeApi } from '@snowbridge/api';
3
+ import { ViemEthereumProvider } from '@snowbridge/provider-viem';
4
+ import { bridgeInfoFor } from '@snowbridge/registry';
5
+ import { createPublicClient, custom, isAddress, maxUint128 } from 'viem';
6
+ import { IERC20_ABI } from '@snowbridge/base-types';
7
+
8
+ function asyncGeneratorStep(n, t, e, r, o, a, c) {
9
+ try {
10
+ var i = n[a](c),
11
+ u = i.value;
12
+ } catch (n) {
13
+ return void e(n);
14
+ }
15
+ i.done ? t(u) : Promise.resolve(u).then(r, o);
16
+ }
17
+ function _asyncToGenerator(n) {
18
+ return function () {
19
+ var t = this,
20
+ e = arguments;
21
+ return new Promise(function (r, o) {
22
+ var a = n.apply(t, e);
23
+ function _next(n) {
24
+ asyncGeneratorStep(a, r, o, _next, _throw, "next", n);
25
+ }
26
+ function _throw(n) {
27
+ asyncGeneratorStep(a, r, o, _next, _throw, "throw", n);
28
+ }
29
+ _next(void 0);
30
+ });
31
+ };
32
+ }
33
+ function _defineProperty(e, r, t) {
34
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
35
+ value: t,
36
+ enumerable: true,
37
+ configurable: true,
38
+ writable: true
39
+ }) : e[r] = t, e;
40
+ }
41
+ function ownKeys(e, r) {
42
+ var t = Object.keys(e);
43
+ if (Object.getOwnPropertySymbols) {
44
+ var o = Object.getOwnPropertySymbols(e);
45
+ r && (o = o.filter(function (r) {
46
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
47
+ })), t.push.apply(t, o);
48
+ }
49
+ return t;
50
+ }
51
+ function _objectSpread2(e) {
52
+ for (var r = 1; r < arguments.length; r++) {
53
+ var t = null != arguments[r] ? arguments[r] : {};
54
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
55
+ _defineProperty(e, r, t[r]);
56
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
57
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
58
+ });
59
+ }
60
+ return e;
61
+ }
62
+ function _regenerator() {
63
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */
64
+ var e,
65
+ t,
66
+ r = "function" == typeof Symbol ? Symbol : {},
67
+ n = r.iterator || "@@iterator",
68
+ o = r.toStringTag || "@@toStringTag";
69
+ function i(r, n, o, i) {
70
+ var c = n && n.prototype instanceof Generator ? n : Generator,
71
+ u = Object.create(c.prototype);
72
+ return _regeneratorDefine(u, "_invoke", function (r, n, o) {
73
+ var i,
74
+ c,
75
+ u,
76
+ f = 0,
77
+ p = o || [],
78
+ y = false,
79
+ G = {
80
+ p: 0,
81
+ n: 0,
82
+ v: e,
83
+ a: d,
84
+ f: d.bind(e, 4),
85
+ d: function (t, r) {
86
+ return i = t, c = 0, u = e, G.n = r, a;
87
+ }
88
+ };
89
+ function d(r, n) {
90
+ for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) {
91
+ var o,
92
+ i = p[t],
93
+ d = G.p,
94
+ l = i[2];
95
+ r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0));
96
+ }
97
+ if (o || r > 1) return a;
98
+ throw y = true, n;
99
+ }
100
+ return function (o, p, l) {
101
+ if (f > 1) throw TypeError("Generator is already running");
102
+ for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) {
103
+ i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u);
104
+ try {
105
+ if (f = 2, i) {
106
+ if (c || (o = "next"), t = i[o]) {
107
+ if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object");
108
+ if (!t.done) return t;
109
+ u = t.value, c < 2 && (c = 0);
110
+ } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1);
111
+ i = e;
112
+ } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break;
113
+ } catch (t) {
114
+ i = e, c = 1, u = t;
115
+ } finally {
116
+ f = 1;
117
+ }
118
+ }
119
+ return {
120
+ value: t,
121
+ done: y
122
+ };
123
+ };
124
+ }(r, o, i), true), u;
125
+ }
126
+ var a = {};
127
+ function Generator() {}
128
+ function GeneratorFunction() {}
129
+ function GeneratorFunctionPrototype() {}
130
+ t = Object.getPrototypeOf;
131
+ var c = [][n] ? t(t([][n]())) : (_regeneratorDefine(t = {}, n, function () {
132
+ return this;
133
+ }), t),
134
+ u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c);
135
+ function f(e) {
136
+ return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e;
137
+ }
138
+ return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine(u), _regeneratorDefine(u, o, "Generator"), _regeneratorDefine(u, n, function () {
139
+ return this;
140
+ }), _regeneratorDefine(u, "toString", function () {
141
+ return "[object Generator]";
142
+ }), (_regenerator = function () {
143
+ return {
144
+ w: i,
145
+ m: f
146
+ };
147
+ })();
148
+ }
149
+ function _regeneratorDefine(e, r, n, t) {
150
+ var i = Object.defineProperty;
151
+ try {
152
+ i({}, "", {});
153
+ } catch (e) {
154
+ i = 0;
155
+ }
156
+ _regeneratorDefine = function (e, r, n, t) {
157
+ function o(r, n) {
158
+ _regeneratorDefine(e, r, function (e) {
159
+ return this._invoke(r, n, e);
160
+ });
161
+ }
162
+ r ? i ? i(e, r, {
163
+ value: n,
164
+ enumerable: !t,
165
+ configurable: !t,
166
+ writable: !t
167
+ }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
168
+ }, _regeneratorDefine(e, r, n, t);
169
+ }
170
+ function _toPrimitive(t, r) {
171
+ if ("object" != typeof t || !t) return t;
172
+ var e = t[Symbol.toPrimitive];
173
+ if (void 0 !== e) {
174
+ var i = e.call(t, r);
175
+ if ("object" != typeof i) return i;
176
+ throw new TypeError("@@toPrimitive must return a primitive value.");
177
+ }
178
+ return ("string" === r ? String : Number)(t);
179
+ }
180
+ function _toPropertyKey(t) {
181
+ var i = _toPrimitive(t, "string");
182
+ return "symbol" == typeof i ? i : i + "";
183
+ }
184
+
185
+ var createEnvironment = function createEnvironment(env) {
186
+ return _objectSpread2(_objectSpread2({}, env), {}, {
187
+ assetOverrides: {
188
+ '3369': [{
189
+ token: '0xba41ddf06b7ffd89d1267b5a93bfef2424eb2003',
190
+ name: 'Mythos',
191
+ minimumBalance: 10000000000000000n,
192
+ symbol: 'MYTH',
193
+ decimals: 18,
194
+ isSufficient: true
195
+ }]
196
+ },
197
+ precompiles: {
198
+ '2004': '0x000000000000000000000000000000000000081A'
199
+ },
200
+ ethereumChains: _objectSpread2(_objectSpread2({}, env.ethereumChains), {}, _defineProperty({}, getParaId('Moonbeam'), 'https://rpc.api.moonbeam.network'))
201
+ });
202
+ };
203
+
204
+ var executeEvmSnowbridgeTransfer = /*#__PURE__*/function () {
205
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(_ref) {
206
+ var _signer$account, _signer$chain;
207
+ var api, signer, recipient, to, currency, ethAsset, amount, info, environment, snowbridgeApi, publicClient, destParaId, sender, account, sourceAddress, fee, transfer, validated, hash, receipt, messageReceipt, _t;
208
+ return _regenerator().w(function (_context) {
209
+ while (1) switch (_context.n) {
210
+ case 0:
211
+ api = _ref.api, signer = _ref.signer, recipient = _ref.recipient, to = _ref.to, currency = _ref.currency;
212
+ if (!Array.isArray(currency)) {
213
+ _context.n = 1;
214
+ break;
215
+ }
216
+ throw new UnsupportedOperationError('Multi-assets are not yet supported for Snowbridge transfers');
217
+ case 1:
218
+ if (!('location' in currency && isOverrideLocationSpecifier(currency.location))) {
219
+ _context.n = 2;
220
+ break;
221
+ }
222
+ throw new UnsupportedOperationError('Override location is not supported for Snowbridge transfers');
223
+ case 2:
224
+ ethAsset = findAssetInfoOrThrow('Ethereum', currency, to);
225
+ amount = abstractDecimals(currency.amount, ethAsset.decimals, api);
226
+ info = bridgeInfoFor('polkadot_mainnet');
227
+ environment = createEnvironment(info.environment);
228
+ snowbridgeApi = new SnowbridgeApi({
229
+ info: _objectSpread2(_objectSpread2({}, info), {}, {
230
+ environment: environment
231
+ }),
232
+ ethereumProvider: new ViemEthereumProvider()
233
+ });
234
+ publicClient = createPublicClient({
235
+ transport: custom(signer.transport),
236
+ chain: signer.chain
237
+ });
238
+ snowbridgeApi.context.setEthProvider(environment.ethChainId, publicClient);
239
+ destParaId = getParaId(to);
240
+ assertHasId(ethAsset);
241
+ sender = snowbridgeApi.sender({
242
+ kind: 'ethereum',
243
+ id: environment.ethChainId
244
+ }, {
245
+ kind: 'polkadot',
246
+ id: destParaId
247
+ });
248
+ if (!((_signer$account = signer.account) !== null && _signer$account !== void 0)) {
249
+ _context.n = 3;
250
+ break;
251
+ }
252
+ _t = _signer$account;
253
+ _context.n = 5;
254
+ break;
255
+ case 3:
256
+ _context.n = 4;
257
+ return signer.getAddresses();
258
+ case 4:
259
+ _t = _context.v[0];
260
+ case 5:
261
+ account = _t;
262
+ if (account) {
263
+ _context.n = 6;
264
+ break;
265
+ }
266
+ throw new MissingParameterError('signer.account', 'viem WalletClient must have an account configured.');
267
+ case 6:
268
+ sourceAddress = typeof account === 'string' ? account : account.address;
269
+ _context.n = 7;
270
+ return sender.fee(ethAsset.assetId);
271
+ case 7:
272
+ fee = _context.v;
273
+ _context.n = 8;
274
+ return sender.tx(sourceAddress, recipient, ethAsset.assetId, amount, fee);
275
+ case 8:
276
+ transfer = _context.v;
277
+ _context.n = 9;
278
+ return sender.validate(transfer);
279
+ case 9:
280
+ validated = _context.v;
281
+ if (!validated.logs.find(function (l) {
282
+ return l.kind === toPolkadotV2.ValidationKind.Error;
283
+ })) {
284
+ _context.n = 10;
285
+ break;
286
+ }
287
+ throw new RoutingResolutionError("Validation failed with following errors: \n\n ".concat(validated.logs.filter(function (l) {
288
+ return l.kind === toPolkadotV2.ValidationKind.Error;
289
+ }).map(function (l) {
290
+ return l.message;
291
+ }).join('\n\n')));
292
+ case 10:
293
+ _context.n = 11;
294
+ return signer.sendTransaction(_objectSpread2(_objectSpread2({}, transfer.tx), {}, {
295
+ account: account,
296
+ chain: (_signer$chain = signer.chain) !== null && _signer$chain !== void 0 ? _signer$chain : null
297
+ }));
298
+ case 11:
299
+ hash = _context.v;
300
+ _context.n = 12;
301
+ return publicClient.waitForTransactionReceipt({
302
+ hash: hash
303
+ });
304
+ case 12:
305
+ receipt = _context.v;
306
+ if (!(receipt.status !== 'success')) {
307
+ _context.n = 13;
308
+ break;
309
+ }
310
+ throw new RoutingResolutionError("Transaction ".concat(hash, " not included."));
311
+ case 13:
312
+ _context.n = 14;
313
+ return sender.messageId(receipt);
314
+ case 14:
315
+ messageReceipt = _context.v;
316
+ if (messageReceipt) {
317
+ _context.n = 15;
318
+ break;
319
+ }
320
+ throw new RoutingResolutionError("Transaction ".concat(hash, " did not emit a message."));
321
+ case 15:
322
+ return _context.a(2, hash);
323
+ }
324
+ }, _callee);
325
+ }));
326
+ return function executeEvmSnowbridgeTransfer(_x) {
327
+ return _ref2.apply(this, arguments);
328
+ };
329
+ }();
330
+
331
+ var approveToken = /*#__PURE__*/function () {
332
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, amount, symbol) {
333
+ var _signer$account, _signer$chain;
334
+ var asset, _bridgeInfoFor, gatewayContract, account, _t;
335
+ return _regenerator().w(function (_context) {
336
+ while (1) switch (_context.n) {
337
+ case 0:
338
+ asset = findAssetInfoOrThrow('Ethereum', {
339
+ symbol: symbol
340
+ });
341
+ assertHasId(asset);
342
+ _bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), gatewayContract = _bridgeInfoFor.environment.gatewayContract;
343
+ if (!((_signer$account = signer.account) !== null && _signer$account !== void 0)) {
344
+ _context.n = 1;
345
+ break;
346
+ }
347
+ _t = _signer$account;
348
+ _context.n = 3;
349
+ break;
350
+ case 1:
351
+ _context.n = 2;
352
+ return signer.getAddresses();
353
+ case 2:
354
+ _t = _context.v[0];
355
+ case 3:
356
+ account = _t;
357
+ if (account) {
358
+ _context.n = 4;
359
+ break;
360
+ }
361
+ throw new MissingParameterError('signer.account', 'viem WalletClient must have an account configured.');
362
+ case 4:
363
+ if (isAddress(gatewayContract)) {
364
+ _context.n = 5;
365
+ break;
366
+ }
367
+ throw new InvalidAddressError(gatewayContract);
368
+ case 5:
369
+ if (isAddress(asset.assetId)) {
370
+ _context.n = 6;
371
+ break;
372
+ }
373
+ throw new InvalidAddressError(asset.assetId);
374
+ case 6:
375
+ return _context.a(2, signer.writeContract({
376
+ address: asset.assetId,
377
+ abi: IERC20_ABI,
378
+ functionName: 'approve',
379
+ args: [gatewayContract, amount],
380
+ account: account,
381
+ chain: (_signer$chain = signer.chain) !== null && _signer$chain !== void 0 ? _signer$chain : null
382
+ }));
383
+ }
384
+ }, _callee);
385
+ }));
386
+ return function approveToken(_x, _x2, _x3) {
387
+ return _ref.apply(this, arguments);
388
+ };
389
+ }();
390
+
391
+ var getTokenBalance = /*#__PURE__*/function () {
392
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(signer, symbol) {
393
+ var _signer$account;
394
+ var asset, _bridgeInfoFor, gatewayContract, account, ownerAddress, publicClient, _findAssetInfoOrThrow, assetId, balance, _t;
395
+ return _regenerator().w(function (_context) {
396
+ while (1) switch (_context.n) {
397
+ case 0:
398
+ asset = findAssetInfoOrThrow('Ethereum', {
399
+ symbol: symbol
400
+ });
401
+ assertHasId(asset);
402
+ _bridgeInfoFor = bridgeInfoFor('polkadot_mainnet'), gatewayContract = _bridgeInfoFor.environment.gatewayContract;
403
+ if (!((_signer$account = signer.account) !== null && _signer$account !== void 0)) {
404
+ _context.n = 1;
405
+ break;
406
+ }
407
+ _t = _signer$account;
408
+ _context.n = 3;
409
+ break;
410
+ case 1:
411
+ _context.n = 2;
412
+ return signer.getAddresses();
413
+ case 2:
414
+ _t = _context.v[0];
415
+ case 3:
416
+ account = _t;
417
+ if (account) {
418
+ _context.n = 4;
419
+ break;
420
+ }
421
+ throw new MissingParameterError('signer.account', 'viem WalletClient must have an account configured.');
422
+ case 4:
423
+ ownerAddress = typeof account === 'string' ? account : account.address;
424
+ publicClient = createPublicClient({
425
+ transport: custom(signer.transport),
426
+ chain: signer.chain
427
+ });
428
+ _findAssetInfoOrThrow = findAssetInfoOrThrow('Ethereum', {
429
+ symbol: 'ETH'
430
+ }), assetId = _findAssetInfoOrThrow.assetId;
431
+ if (!(asset.assetId.toLowerCase() === (assetId === null || assetId === void 0 ? void 0 : assetId.toLowerCase()))) {
432
+ _context.n = 6;
433
+ break;
434
+ }
435
+ _context.n = 5;
436
+ return publicClient.getBalance({
437
+ address: ownerAddress
438
+ });
439
+ case 5:
440
+ balance = _context.v;
441
+ return _context.a(2, {
442
+ balance: balance,
443
+ gatewayAllowance: maxUint128
444
+ });
445
+ case 6:
446
+ return _context.a(2, new ViemEthereumProvider().erc20Balance(publicClient, asset.assetId, ownerAddress, gatewayContract));
447
+ }
448
+ }, _callee);
449
+ }));
450
+ return function getTokenBalance(_x, _x2) {
451
+ return _ref.apply(this, arguments);
452
+ };
453
+ }();
454
+
455
+ registerEvmSnowbridgeExtension({
456
+ executeEvmSnowbridgeTransfer: executeEvmSnowbridgeTransfer
457
+ });
458
+
459
+ export { approveToken, executeEvmSnowbridgeTransfer, getTokenBalance };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@paraspell/evm-snowbridge",
3
+ "version": "13.2.2",
4
+ "description": "Optional Snowbridge extension for @paraspell/sdk enabling Ethereum -> Polkadot transfers.",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/paraspell/xcm-tools.git",
8
+ "directory": "packages/evm-snowbridge"
9
+ },
10
+ "license": "MIT",
11
+ "type": "module",
12
+ "exports": {
13
+ ".": {
14
+ "types": "./dist/index.d.ts",
15
+ "import": "./dist/index.mjs"
16
+ }
17
+ },
18
+ "main": "dist/index.mjs",
19
+ "module": "./dist/index.mjs",
20
+ "types": "./dist/index.d.ts",
21
+ "files": [
22
+ "dist"
23
+ ],
24
+ "keywords": [],
25
+ "author": "",
26
+ "dependencies": {
27
+ "@snowbridge/api": "^1.0.13",
28
+ "@snowbridge/base-types": "^1.0.13",
29
+ "@snowbridge/provider-viem": "^1.0.13",
30
+ "@snowbridge/registry": "^1.0.13",
31
+ "viem": "^2.47.6",
32
+ "@paraspell/sdk-core": "13.3.0"
33
+ },
34
+ "devDependencies": {
35
+ "@babel/plugin-syntax-import-attributes": "^7.28.6",
36
+ "@babel/preset-env": "^7.29.2",
37
+ "@codecov/rollup-plugin": "^1.9.1",
38
+ "@rollup/plugin-babel": "^7.0.0",
39
+ "@rollup/plugin-json": "^6.1.0",
40
+ "@rollup/plugin-typescript": "^12.3.0",
41
+ "@vitest/coverage-v8": "^4.1.2",
42
+ "dotenv": "^17.3.1",
43
+ "rollup": "^4.60.1",
44
+ "rollup-plugin-dts": "^6.4.1",
45
+ "tslib": "^2.8.1"
46
+ },
47
+ "scripts": {
48
+ "compile": "tsc --noEmit",
49
+ "build": "rollup -c",
50
+ "lint:check": "eslint src",
51
+ "lint": "eslint --fix src",
52
+ "format:check": "prettier --check src",
53
+ "format:write": "prettier --write src",
54
+ "test": "vitest run",
55
+ "test:cov": "vitest run --coverage",
56
+ "test:watch": "vitest",
57
+ "runAll": "pnpm compile && pnpm format:write && pnpm lint && pnpm test"
58
+ }
59
+ }