@paraspell/evm-snowbridge 14.5.2 → 14.5.3

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 (2) hide show
  1. package/dist/index.mjs +117 -2
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -4,8 +4,17 @@ import { ViemEthereumProvider } from '@snowbridge/provider-viem';
4
4
  import { bridgeInfoFor } from '@snowbridge/registry';
5
5
  import { createPublicClient, fallback, webSocket, custom, encodeFunctionData, maxUint128 } from 'viem';
6
6
  import { mainnet } from 'viem/chains';
7
+ import { socketClientCache } from 'viem/utils';
7
8
  import { IERC20_ABI } from '@snowbridge/base-types';
8
9
 
10
+ function _arrayLikeToArray(r, a) {
11
+ (null == a || a > r.length) && (a = r.length);
12
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
13
+ return n;
14
+ }
15
+ function _arrayWithHoles(r) {
16
+ if (Array.isArray(r)) return r;
17
+ }
9
18
  function asyncGeneratorStep(n, t, e, r, o, a, c) {
10
19
  try {
11
20
  var i = n[a](c),
@@ -31,6 +40,54 @@ function _asyncToGenerator(n) {
31
40
  });
32
41
  };
33
42
  }
43
+ function _createForOfIteratorHelper(r, e) {
44
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
45
+ if (!t) {
46
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
47
+ t && (r = t);
48
+ var n = 0,
49
+ F = function () {};
50
+ return {
51
+ s: F,
52
+ n: function () {
53
+ return n >= r.length ? {
54
+ done: true
55
+ } : {
56
+ done: false,
57
+ value: r[n++]
58
+ };
59
+ },
60
+ e: function (r) {
61
+ throw r;
62
+ },
63
+ f: F
64
+ };
65
+ }
66
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
67
+ }
68
+ var o,
69
+ a = true,
70
+ u = false;
71
+ return {
72
+ s: function () {
73
+ t = t.call(r);
74
+ },
75
+ n: function () {
76
+ var r = t.next();
77
+ return a = r.done, r;
78
+ },
79
+ e: function (r) {
80
+ u = true, o = r;
81
+ },
82
+ f: function () {
83
+ try {
84
+ a || null == t.return || t.return();
85
+ } finally {
86
+ if (u) throw o;
87
+ }
88
+ }
89
+ };
90
+ }
34
91
  function _defineProperty(e, r, t) {
35
92
  return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
36
93
  value: t,
@@ -39,6 +96,33 @@ function _defineProperty(e, r, t) {
39
96
  writable: true
40
97
  }) : e[r] = t, e;
41
98
  }
99
+ function _iterableToArrayLimit(r, l) {
100
+ var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
101
+ if (null != t) {
102
+ var e,
103
+ n,
104
+ i,
105
+ u,
106
+ a = [],
107
+ f = true,
108
+ o = false;
109
+ try {
110
+ if (i = (t = t.call(r)).next, 0 === l) ; else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0);
111
+ } catch (r) {
112
+ o = true, n = r;
113
+ } finally {
114
+ try {
115
+ if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return;
116
+ } finally {
117
+ if (o) throw n;
118
+ }
119
+ }
120
+ return a;
121
+ }
122
+ }
123
+ function _nonIterableRest() {
124
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
125
+ }
42
126
  function ownKeys(e, r) {
43
127
  var t = Object.keys(e);
44
128
  if (Object.getOwnPropertySymbols) {
@@ -168,6 +252,9 @@ function _regeneratorDefine(e, r, n, t) {
168
252
  }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2));
169
253
  }, _regeneratorDefine(e, r, n, t);
170
254
  }
255
+ function _slicedToArray(r, e) {
256
+ return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest();
257
+ }
171
258
  function _toPrimitive(t, r) {
172
259
  if ("object" != typeof t || !t) return t;
173
260
  var e = t[Symbol.toPrimitive];
@@ -182,6 +269,13 @@ function _toPropertyKey(t) {
182
269
  var i = _toPrimitive(t, "string");
183
270
  return "symbol" == typeof i ? i : i + "";
184
271
  }
272
+ function _unsupportedIterableToArray(r, a) {
273
+ if (r) {
274
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
275
+ var t = {}.toString.call(r).slice(8, -1);
276
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
277
+ }
278
+ }
185
279
 
186
280
  var createEnvironment = function createEnvironment(env) {
187
281
  return _objectSpread2(_objectSpread2({}, env), {}, {
@@ -199,6 +293,25 @@ var createEnvironment = function createEnvironment(env) {
199
293
  };
200
294
 
201
295
  var ETHEREUM_WS_URLS = ['wss://ethereum-rpc.publicnode.com', 'wss://eth.drpc.org', 'wss://eth.llamarpc.com', 'wss://ethereum.public.blockpi.network/v1/ws/public', 'wss://eth-mainnet.public.blastapi.io'];
296
+ var keepAlive = {
297
+ owner: "paraspell-".concat(Math.random().toString(36).slice(2))
298
+ };
299
+ var closeOwnSockets = function closeOwnSockets() {
300
+ var _iterator = _createForOfIteratorHelper(socketClientCache),
301
+ _step;
302
+ try {
303
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
304
+ var _step$value = _slicedToArray(_step.value, 2),
305
+ id = _step$value[0],
306
+ socketClient = _step$value[1];
307
+ if (id.includes("\"".concat(keepAlive.owner, "\""))) socketClient.close();
308
+ }
309
+ } catch (err) {
310
+ _iterator.e(err);
311
+ } finally {
312
+ _iterator.f();
313
+ }
314
+ };
202
315
  var cache = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
203
316
  var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(client) {
204
317
  return _regenerator().w(function (_context) {
@@ -214,13 +327,15 @@ var cache = createClientCache(MAX_CLIENTS, /*#__PURE__*/function () {
214
327
  return function (_x) {
215
328
  return _ref.apply(this, arguments);
216
329
  };
217
- }(), undefined, EXTENSION_MS);
330
+ }(), closeOwnSockets, EXTENSION_MS);
218
331
  var _createClientPoolHelp = createClientPoolHelpers(cache, function (urls) {
219
332
  var list = Array.isArray(urls) ? urls : [urls];
220
333
  return createPublicClient({
221
334
  chain: mainnet,
222
335
  transport: fallback(list.map(function (url) {
223
- return webSocket(url);
336
+ return webSocket(url, {
337
+ keepAlive: keepAlive
338
+ });
224
339
  }))
225
340
  });
226
341
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paraspell/evm-snowbridge",
3
- "version": "14.5.2",
3
+ "version": "14.5.3",
4
4
  "description": "Optional Snowbridge extension for @paraspell/sdk enabling Ethereum -> Polkadot transfers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -24,7 +24,7 @@
24
24
  "keywords": [],
25
25
  "author": "",
26
26
  "dependencies": {
27
- "@paraspell/sdk-core": "14.5.2",
27
+ "@paraspell/sdk-core": "14.5.3",
28
28
  "@snowbridge/api": "^1.2.1",
29
29
  "@snowbridge/base-types": "^1.2.1",
30
30
  "@snowbridge/provider-viem": "^1.2.1",