@dynamic-labs/utils 1.1.0-phantom.0 → 1.2.0-alpha.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/CHANGELOG.md CHANGED
@@ -1,18 +1,175 @@
1
1
 
2
- ## [1.1.0-phantom.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.12...v1.1.0-phantom.0) (2024-01-22)
2
+ ## [1.2.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.26...v1.2.0-alpha.0) (2024-02-09)
3
+
4
+
5
+ ### Features
6
+
7
+ * add retry email otp in headless ([#4639](https://github.com/dynamic-labs/DynamicAuth/issues/4639)) ([70630e2](https://github.com/dynamic-labs/DynamicAuth/commit/70630e28e4b370581add65fc5f69c41c28346cc6))
8
+ * add tabs to wallet list view ([#4619](https://github.com/dynamic-labs/DynamicAuth/issues/4619)) ([c552a8e](https://github.com/dynamic-labs/DynamicAuth/commit/c552a8ec9a484b6015e95e9b3b30cd1cd151a45b))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * current wallet being clipped inside a circle ([#4470](https://github.com/dynamic-labs/DynamicAuth/issues/4470)) ([53149c6](https://github.com/dynamic-labs/DynamicAuth/commit/53149c658ccf73b5576f73e8863bab6e9e5f66a7))
14
+ * hydration issues with ShadowDOM ([#4434](https://github.com/dynamic-labs/DynamicAuth/issues/4434)) ([032dae5](https://github.com/dynamic-labs/DynamicAuth/commit/032dae5036bc5b03095b0d3d41f8ab0a8a678dbb))
15
+ * multi wallet disabled shows one chain even if both are enabled ([#4636](https://github.com/dynamic-labs/DynamicAuth/issues/4636)) ([b5baef3](https://github.com/dynamic-labs/DynamicAuth/commit/b5baef38dcceca7927508ef149c2573c9cb02ddf))
16
+ * solana turnkey connector not refreshing account after session expiration ([#4625](https://github.com/dynamic-labs/DynamicAuth/issues/4625)) ([3e6b1f9](https://github.com/dynamic-labs/DynamicAuth/commit/3e6b1f97bb1ca8f70948678748176a77f05f5ef9))
17
+ * use phantom injected when on in-app browser ([#4630](https://github.com/dynamic-labs/DynamicAuth/issues/4630)) ([b4fab5b](https://github.com/dynamic-labs/DynamicAuth/commit/b4fab5b935fc516c864c2e6eb39c946b18c8897f))
18
+ * wait for sdkHasLoaded to process phantom redirect ([#4628](https://github.com/dynamic-labs/DynamicAuth/issues/4628)) ([5f68f65](https://github.com/dynamic-labs/DynamicAuth/commit/5f68f653652c6108bd62d4314974bca18eb683b1))
19
+
20
+ ## [1.1.0-alpha.26](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.25...v1.1.0-alpha.26) (2024-02-07)
21
+
22
+
23
+ ### Features
24
+
25
+ * add retry when using magic ([#4579](https://github.com/dynamic-labs/DynamicAuth/issues/4579)) ([183561c](https://github.com/dynamic-labs/DynamicAuth/commit/183561cc64f083fd1489c38a8cc8b1c4c51d2924))
26
+
27
+
28
+ ### Bug Fixes
29
+
30
+ * bug where deprecated fields were still being used in the SDK ([#4604](https://github.com/dynamic-labs/DynamicAuth/issues/4604)) ([4fd15fc](https://github.com/dynamic-labs/DynamicAuth/commit/4fd15fc4daa9c5b7bbc81ce05a3b046c80a6d5b4))
31
+ * log magic RPC error and update magic network error ([#4606](https://github.com/dynamic-labs/DynamicAuth/issues/4606)) ([2206961](https://github.com/dynamic-labs/DynamicAuth/commit/22069618a317bc40b1a17fd521eadf0956983de4))
32
+ * onConnect is properly called for additional connected wallets ([#4607](https://github.com/dynamic-labs/DynamicAuth/issues/4607)) ([23241f4](https://github.com/dynamic-labs/DynamicAuth/commit/23241f4d5dc91ac9ca1251710161efbfce42dc40))
33
+
34
+ ## [1.1.0-alpha.25](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.24...v1.1.0-alpha.25) (2024-02-05)
35
+
36
+
37
+ ### Features
38
+
39
+ * add signin with coinbase to sdk ([#4581](https://github.com/dynamic-labs/DynamicAuth/issues/4581)) ([08a31ed](https://github.com/dynamic-labs/DynamicAuth/commit/08a31ed3552c48645b398881f184440800af21ec))
40
+ * exposing hook for creating either one-time code or passkeys authenticators ([#4591](https://github.com/dynamic-labs/DynamicAuth/issues/4591)) ([864d755](https://github.com/dynamic-labs/DynamicAuth/commit/864d75576152a10f73f5901bc06e2d66892b63ab))
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * solana wallet sign message with one-time code session ([#4588](https://github.com/dynamic-labs/DynamicAuth/issues/4588)) ([a738d10](https://github.com/dynamic-labs/DynamicAuth/commit/a738d10814dc5058158b9c0c59a399a375c69c10))
46
+
47
+ ## [1.1.0-alpha.24](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.23...v1.1.0-alpha.24) (2024-02-02)
48
+
49
+
50
+ ### Bug Fixes
51
+
52
+ * remove isFullyConnected when unable to restore wallet ([#4575](https://github.com/dynamic-labs/DynamicAuth/issues/4575)) ([4504ff0](https://github.com/dynamic-labs/DynamicAuth/commit/4504ff03f594cd9a60055e6f52b7ea8001542bbe))
53
+
54
+ ## [1.1.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.22...v1.1.0-alpha.23) (2024-02-01)
55
+
56
+
57
+ ### Features
58
+
59
+ * bitcoin signPsbt ([3c964de](https://github.com/dynamic-labs/DynamicAuth/commit/3c964dea8a55debaf184c5a94f0f5fabdda3c877))
60
+ * embedded wallet email auth flow ([#4353](https://github.com/dynamic-labs/DynamicAuth/issues/4353)) ([4875da3](https://github.com/dynamic-labs/DynamicAuth/commit/4875da32c47c27facef1b1cdbdc214566bbfd171))
61
+
62
+ ## [1.1.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.21...v1.1.0-alpha.22) (2024-02-01)
63
+
64
+
65
+ ### Bug Fixes
66
+
67
+ * onAuthFlowClose not being called ([#4563](https://github.com/dynamic-labs/DynamicAuth/issues/4563)) ([c4b2648](https://github.com/dynamic-labs/DynamicAuth/commit/c4b264885b7dba6e204ef49bf642d25c7d287b04))
68
+
69
+ ## [1.1.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.20...v1.1.0-alpha.21) (2024-02-01)
70
+
71
+
72
+ ### Features
73
+
74
+ * add phantom redirect handling context ([#4479](https://github.com/dynamic-labs/DynamicAuth/issues/4479)) ([e0218ee](https://github.com/dynamic-labs/DynamicAuth/commit/e0218eec1a67787f5c0e7483d542a5f773e911ef))
75
+ * add signPsbt method to bitcoin wallet connectors ([dfdc0fe](https://github.com/dynamic-labs/DynamicAuth/commit/dfdc0fe0e6894c1307b286e89b43a4c58a8808f3))
76
+
77
+
78
+ ### Bug Fixes
79
+
80
+ * relax passkey feature detection check in sdk to avoid false nega… ([#4556](https://github.com/dynamic-labs/DynamicAuth/issues/4556)) ([4554f7d](https://github.com/dynamic-labs/DynamicAuth/commit/4554f7d7c5339859481cdecca95a9c07fae4ba5c))
81
+ * workaround braavos undefined selectedWallet on chainChange event ([#4552](https://github.com/dynamic-labs/DynamicAuth/issues/4552)) ([aa35df0](https://github.com/dynamic-labs/DynamicAuth/commit/aa35df0e894feafa0606aa1c87bd3d3879ebc594))
82
+
83
+ ## [1.1.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.19...v1.1.0-alpha.20) (2024-01-31)
84
+
85
+
86
+ ### Bug Fixes
87
+
88
+ * return all enabled chains in getSupportedNetworks instead of undefined ([#4547](https://github.com/dynamic-labs/DynamicAuth/issues/4547)) ([08e7889](https://github.com/dynamic-labs/DynamicAuth/commit/08e78896e045f24bbd96e39416a7f58006929da0))
89
+ * show modal for existing social account from other signin provider ([#4535](https://github.com/dynamic-labs/DynamicAuth/issues/4535)) ([282914a](https://github.com/dynamic-labs/DynamicAuth/commit/282914ac94b3ef5bd66e0b2265d9e414203a7406))
90
+
91
+ ## [1.1.0-alpha.19](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.18...v1.1.0-alpha.19) (2024-01-31)
92
+
93
+
94
+ ### Features
95
+
96
+ * add PhantomRedirect connector ([#4467](https://github.com/dynamic-labs/DynamicAuth/issues/4467)) ([75d6c95](https://github.com/dynamic-labs/DynamicAuth/commit/75d6c95940fcec185a699c2100b3e2d21a8233d5))
97
+
98
+
99
+ ### Bug Fixes
100
+
101
+ * lock starknet to 5.25.0 since 5.27.0 breaks the build ([#4541](https://github.com/dynamic-labs/DynamicAuth/issues/4541)) ([00b4799](https://github.com/dynamic-labs/DynamicAuth/commit/00b479977f768cb067480e2e565eabf45e1000a2))
102
+
103
+ ## [1.1.0-alpha.18](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.17...v1.1.0-alpha.18) (2024-01-30)
104
+
105
+
106
+ ### Bug Fixes
107
+
108
+ * catch email_associated_with_different_provider from response ([#4532](https://github.com/dynamic-labs/DynamicAuth/issues/4532)) ([52be1b4](https://github.com/dynamic-labs/DynamicAuth/commit/52be1b45af46c2b70972b99d73387eb4d7161ec6))
109
+
110
+ ## [1.1.0-alpha.17](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.16...v1.1.0-alpha.17) (2024-01-30)
111
+
112
+
113
+ ### Features
114
+
115
+ * add sendRawTransaction to BitcoinWalletConnector ([2e86c5a](https://github.com/dynamic-labs/DynamicAuth/commit/2e86c5a5245bd0fc29162ef1f7fe2fbd65245fe1))
116
+
117
+
118
+ ### Bug Fixes
119
+
120
+ * properly handle AccountExistsError for signInOAuth ([#4529](https://github.com/dynamic-labs/DynamicAuth/issues/4529)) ([d37fdc3](https://github.com/dynamic-labs/DynamicAuth/commit/d37fdc310fe4b70f8948fd5ed3d058342afbe08f))
121
+
122
+ ## [1.1.0-alpha.16](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.15...v1.1.0-alpha.16) (2024-01-30)
123
+
124
+
125
+ ### Bug Fixes
126
+
127
+ * add fallback to getWalletBookWallet for customers still passing in name, add deprecation warn ([#4518](https://github.com/dynamic-labs/DynamicAuth/issues/4518)) ([b233ea1](https://github.com/dynamic-labs/DynamicAuth/commit/b233ea1cd640d8d9d94c52ab230787f3d869151a))
128
+ * handle braavos network change to account which doesn not exist ([#4519](https://github.com/dynamic-labs/DynamicAuth/issues/4519)) ([486020f](https://github.com/dynamic-labs/DynamicAuth/commit/486020fb09a274388ba34c8d1b37ac3a1ff3dba6))
129
+
130
+ ## [1.1.0-alpha.15](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.14...v1.1.0-alpha.15) (2024-01-28)
131
+
132
+
133
+ ### Features
134
+
135
+ * add wallet group override to wallet book ([#4488](https://github.com/dynamic-labs/DynamicAuth/issues/4488)) ([cb19ad3](https://github.com/dynamic-labs/DynamicAuth/commit/cb19ad3ea82de488752ceceeaf0e1458a388df6e))
136
+ * enable solana embedded wallets ([#4457](https://github.com/dynamic-labs/DynamicAuth/issues/4457)) ([b0c47f4](https://github.com/dynamic-labs/DynamicAuth/commit/b0c47f4475baa12f52076da46ef993c13bd2c243))
137
+ * group ArgentX wallets ([#4495](https://github.com/dynamic-labs/DynamicAuth/issues/4495)) ([b10d79a](https://github.com/dynamic-labs/DynamicAuth/commit/b10d79a668efecedca37ddb358e6adf95319650d))
138
+
139
+
140
+ ### Bug Fixes
141
+
142
+ * add support for newest backpack extension ([#4468](https://github.com/dynamic-labs/DynamicAuth/issues/4468)) ([a219f32](https://github.com/dynamic-labs/DynamicAuth/commit/a219f325be672599e50b07f6751234a7fc98286e))
143
+ * bump timeout for slower connections ([#4475](https://github.com/dynamic-labs/DynamicAuth/issues/4475)) ([7a07ff5](https://github.com/dynamic-labs/DynamicAuth/commit/7a07ff589eaaf3b28a94d277df3eedabbca60702))
144
+ * change out getWalletBookWallet for findWalletBookWallet to avoid throwing during lookup ([#4477](https://github.com/dynamic-labs/DynamicAuth/issues/4477)) ([4648040](https://github.com/dynamic-labs/DynamicAuth/commit/4648040c166e73dd2c31b0e27897713339436c2f))
145
+ * connect to wallet with wallet connect even if network is not supported ([#4465](https://github.com/dynamic-labs/DynamicAuth/issues/4465)) ([9dbca3e](https://github.com/dynamic-labs/DynamicAuth/commit/9dbca3eb4d4990ee4be642677c1604170b425dc3))
146
+ * pass id to wagmi chain override ([#4512](https://github.com/dynamic-labs/DynamicAuth/issues/4512)) ([2bf2f04](https://github.com/dynamic-labs/DynamicAuth/commit/2bf2f0487f5b1be936dd279107c11fe5d2b42666))
147
+ * switching wallet in extension caused connected flag to be false temporarily ([#4454](https://github.com/dynamic-labs/DynamicAuth/issues/4454)) ([3650f6e](https://github.com/dynamic-labs/DynamicAuth/commit/3650f6ec471a7c779f4d304ab94c9350dd55055b))
148
+
149
+ ## [1.1.0-alpha.14](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.13...v1.1.0-alpha.14) (2024-01-23)
150
+
151
+
152
+ ### Features
153
+
154
+ * add wallet-book retryable ([#4462](https://github.com/dynamic-labs/DynamicAuth/issues/4462)) ([513b1a6](https://github.com/dynamic-labs/DynamicAuth/commit/513b1a67d6c49624398ad4b0cdca4f5618c9583f))
155
+
156
+ ## [1.1.0-alpha.13](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.12...v1.1.0-alpha.13) (2024-01-23)
3
157
 
4
158
 
5
159
  ### Features
6
160
 
7
161
  * add createWalletClientFromWallet helper function ([#4416](https://github.com/dynamic-labs/DynamicAuth/issues/4416)) ([b384898](https://github.com/dynamic-labs/DynamicAuth/commit/b384898061bb3f9b38b2ed670b6650cfc1d4b429))
8
162
  * add hardware wallets to wallet book ([#4445](https://github.com/dynamic-labs/DynamicAuth/issues/4445)) ([66c0f5b](https://github.com/dynamic-labs/DynamicAuth/commit/66c0f5b29a6a700099bb95a6f7622f6178e0bccf))
9
- * add redirect based phantom deeplinking ([c40dfd2](https://github.com/dynamic-labs/DynamicAuth/commit/c40dfd21d0692b9d33593d564ae6879ab15547e2))
163
+ * add support for Argent Web and Mobile ([#4328](https://github.com/dynamic-labs/DynamicAuth/issues/4328)) ([bce20b8](https://github.com/dynamic-labs/DynamicAuth/commit/bce20b8f35a8630f2621f53a541a1acb06a38fc0))
164
+ * enable ledger for glow, solflare and backpack ([#4392](https://github.com/dynamic-labs/DynamicAuth/issues/4392)) ([fa7b992](https://github.com/dynamic-labs/DynamicAuth/commit/fa7b992f87ebc43560f87b43ac56f2cd9909b306))
10
165
 
11
166
 
12
167
  ### Bug Fixes
13
168
 
14
169
  * breaking changes script ([#4440](https://github.com/dynamic-labs/DynamicAuth/issues/4440)) ([446173d](https://github.com/dynamic-labs/DynamicAuth/commit/446173d074d652d81856c6412e304b46b1565320))
15
170
  * broken help icon in create passkey view ([#4428](https://github.com/dynamic-labs/DynamicAuth/issues/4428)) ([e0ffc02](https://github.com/dynamic-labs/DynamicAuth/commit/e0ffc02ffea34b7ac3198ff6e1baf7f9907acddd))
171
+ * infinite loop when connecting with trust wallet ([#4448](https://github.com/dynamic-labs/DynamicAuth/issues/4448)) ([4e20edf](https://github.com/dynamic-labs/DynamicAuth/commit/4e20edf9abaabf20e5e9f9167b44d7f691e844f1))
172
+ * render wagmi elements based on react version ([#4453](https://github.com/dynamic-labs/DynamicAuth/issues/4453)) ([43c624c](https://github.com/dynamic-labs/DynamicAuth/commit/43c624ca996b0c51de1454910f19fdf908149938))
16
173
 
17
174
  ## [1.1.0-alpha.12](https://github.com/dynamic-labs/DynamicAuth/compare/v1.1.0-alpha.11...v1.1.0-alpha.12) (2024-01-18)
18
175
 
@@ -25,6 +25,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
25
25
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
26
26
  step((generator = generator.apply(thisArg, _arguments || [])).next());
27
27
  });
28
- }
28
+ }
29
+
30
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
31
+ var e = new Error(message);
32
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
33
+ };
29
34
 
30
35
  exports.__awaiter = __awaiter;
@@ -21,6 +21,11 @@ function __awaiter(thisArg, _arguments, P, generator) {
21
21
  function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
22
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
23
23
  });
24
- }
24
+ }
25
+
26
+ typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
27
+ var e = new Error(message);
28
+ return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
29
+ };
25
30
 
26
31
  export { __awaiter };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "1.1.0-phantom.0",
3
+ "version": "1.2.0-alpha.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -25,11 +25,12 @@
25
25
  },
26
26
  "./package.json": "./package.json"
27
27
  },
28
+ "dependencies": {
29
+ "tldts": "^6.0.16",
30
+ "@dynamic-labs/logger": "1.2.0-alpha.0",
31
+ "@dynamic-labs/types": "1.2.0-alpha.0"
32
+ },
28
33
  "peerDependencies": {
29
34
  "viem": "^1.19.13 || ^2.2.0"
30
- },
31
- "dependencies": {
32
- "@dynamic-labs/logger": "1.1.0-phantom.0",
33
- "@dynamic-labs/types": "1.1.0-phantom.0"
34
35
  }
35
36
  }
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tldts = require('tldts');
6
+
7
+ const getTLD = () => {
8
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
9
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
10
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
11
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
12
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
13
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
14
+ const data = tldts.parse(window.location.hostname, { allowPrivateDomains: true });
15
+ return data.domain || undefined;
16
+ };
17
+
18
+ exports.getTLD = getTLD;
@@ -0,0 +1 @@
1
+ export declare const getTLD: () => string | undefined;
@@ -0,0 +1,14 @@
1
+ import { parse } from 'tldts';
2
+
3
+ const getTLD = () => {
4
+ // Passing the allowPrivateDomains option prevents returning the actual TLD
5
+ // for domains that have delegated subdomains like herokuapp.com or s3.amazonaws.com
6
+ // full list is contained here https://publicsuffix.org/list/effective_tld_names.dat
7
+ // separated by ICANN DOMAINS and PRIVATE DOMAINS
8
+ // so for instance parse('someapp.herokuapp.com') will return 'someapp.herokuapp.com' as the domain
9
+ // whereas parse('app.dynamic.xyz') will return 'dynamic.xyz'
10
+ const data = parse(window.location.hostname, { allowPrivateDomains: true });
11
+ return data.domain || undefined;
12
+ };
13
+
14
+ export { getTLD };
@@ -0,0 +1 @@
1
+ export { getTLD } from './getTLD';
@@ -6,7 +6,9 @@ require('../errors/TransactionGasCannotBeSponsoredError.cjs');
6
6
  require('../errors/InsufficientFundsError.cjs');
7
7
  require('../logger/logger.cjs');
8
8
  var isMobile = require('../isMobile.cjs');
9
+ require('../../_virtual/_tslib.cjs');
9
10
  require('viem/chains');
11
+ require('tldts');
10
12
 
11
13
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
12
14
  const url = encodeURIComponent(window.location.toString());
@@ -2,7 +2,9 @@ import '../errors/TransactionGasCannotBeSponsoredError.js';
2
2
  import '../errors/InsufficientFundsError.js';
3
3
  import '../logger/logger.js';
4
4
  import { isSamsungBrowser } from '../isMobile.js';
5
+ import '../../_virtual/_tslib.js';
5
6
  import 'viem/chains';
7
+ import 'tldts';
6
8
 
7
9
  const handleMobileWalletRedirect = ({ nativeLink, universalLink, }) => {
8
10
  const url = encodeURIComponent(window.location.toString());
package/src/index.cjs CHANGED
@@ -36,6 +36,8 @@ var retryableFn = require('./retryableFn.cjs');
36
36
  var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
37
37
  var DeferredPromise = require('./DeferredPromise/DeferredPromise.cjs');
38
38
  var handleMobileWalletRedirect = require('./handleMobileWalletRedirect/handleMobileWalletRedirect.cjs');
39
+ var uniq = require('./uniq/uniq.cjs');
40
+ var getTLD = require('./getTLD/getTLD.cjs');
39
41
 
40
42
 
41
43
 
@@ -87,3 +89,5 @@ exports.retryableFn = retryableFn.retryableFn;
87
89
  exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
88
90
  exports.DeferredPromise = DeferredPromise.DeferredPromise;
89
91
  exports.handleMobileWalletRedirect = handleMobileWalletRedirect.handleMobileWalletRedirect;
92
+ exports.uniq = uniq.uniq;
93
+ exports.getTLD = getTLD.getTLD;
package/src/index.d.ts CHANGED
@@ -14,3 +14,5 @@ export * from './retryableFn';
14
14
  export * from './wrapMethodWithCallback';
15
15
  export * from './DeferredPromise';
16
16
  export * from './handleMobileWalletRedirect';
17
+ export * from './uniq';
18
+ export * from './getTLD';
package/src/index.js CHANGED
@@ -32,3 +32,5 @@ export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
32
32
  export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
33
33
  export { DeferredPromise } from './DeferredPromise/DeferredPromise.js';
34
34
  export { handleMobileWalletRedirect } from './handleMobileWalletRedirect/handleMobileWalletRedirect.js';
35
+ export { uniq } from './uniq/uniq.js';
36
+ export { getTLD } from './getTLD/getTLD.js';
@@ -8,6 +8,7 @@ const parseEvmNetworks = (networks) => {
8
8
  const clone = networks.slice();
9
9
  return clone.map((network) => {
10
10
  network.chainId = parseChainId.parseChainId(network.chainId);
11
+ network.networkId = parseChainId.parseChainId(network.networkId);
11
12
  return network;
12
13
  });
13
14
  };
@@ -4,6 +4,7 @@ const parseEvmNetworks = (networks) => {
4
4
  const clone = networks.slice();
5
5
  return clone.map((network) => {
6
6
  network.chainId = parseChainId(network.chainId);
7
+ network.networkId = parseChainId(network.networkId);
7
8
  return network;
8
9
  });
9
10
  };
@@ -3,10 +3,23 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _tslib = require('../_virtual/_tslib.cjs');
6
+ require('./errors/TransactionGasCannotBeSponsoredError.cjs');
7
+ require('./errors/InsufficientFundsError.cjs');
8
+ require('./logger/logger.cjs');
9
+ var sleep = require('./sleep/sleep.cjs');
10
+ require('viem/chains');
11
+ require('tldts');
6
12
 
7
13
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
8
14
  const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
9
- const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', } = options;
15
+ const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, logger, } = options;
16
+ logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
17
+ currentRetry,
18
+ fallbackValue,
19
+ maxRetries,
20
+ retryStrategy,
21
+ timeoutMs,
22
+ });
10
23
  const timeoutPromise = new Promise((_, reject) => {
11
24
  setTimeout(() => {
12
25
  reject(new Error('Timeout'));
@@ -17,7 +30,9 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
17
30
  return result;
18
31
  }
19
32
  catch (err) {
33
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
20
34
  if (currentRetry >= maxRetries) {
35
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
21
36
  if (fallbackValue instanceof Error) {
22
37
  throw fallbackValue;
23
38
  }
@@ -26,22 +41,30 @@ const retryableFn = (fn, options = {}) => _tslib.__awaiter(void 0, void 0, void
26
41
  }
27
42
  return fallbackValue;
28
43
  }
29
- const isTimeout = err.message === 'Timeout';
44
+ const isTimeout = (err === null || err === void 0 ? void 0 : err.message) === 'Timeout';
30
45
  const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
31
46
  (retryStrategy === 'timeout-only' && isTimeout) ||
32
47
  (retryStrategy === 'rejection-only' && !isTimeout);
48
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
33
49
  if (!shouldRetry) {
34
50
  if (fallbackValue instanceof Error) {
51
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
35
52
  throw err;
36
53
  }
37
54
  else if (fallbackValue === FALLBACK_UNDEFINED) {
55
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
38
56
  return undefined;
39
57
  }
58
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
59
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
40
60
  return fallbackValue;
41
61
  }
62
+ if (retryIntervalMs)
63
+ yield sleep.sleep(retryIntervalMs);
42
64
  return retryableFn(fn, {
43
65
  currentRetry: currentRetry + 1,
44
66
  fallbackValue,
67
+ logger,
45
68
  maxRetries,
46
69
  retryStrategy,
47
70
  timeoutMs,
@@ -1,3 +1,4 @@
1
+ import { Logger } from '@dynamic-labs/logger';
1
2
  export declare const FALLBACK_UNDEFINED = "FALLBACK_UNDEFINED";
2
3
  export type RetryableFnOptions<T> = {
3
4
  /** Maximum number of retry attempts before returning fallbackValue */
@@ -10,5 +11,9 @@ export type RetryableFnOptions<T> = {
10
11
  fallbackValue?: T | Error | typeof FALLBACK_UNDEFINED;
11
12
  /** Configure whether the fn should be retried only on timeout, only on rejection, or both */
12
13
  retryStrategy?: 'timeout-only' | 'rejection-only' | 'timeout-and-rejection';
14
+ /** Set the logger to be used */
15
+ logger?: Logger | typeof console;
16
+ /** Ms to wait before a retry */
17
+ retryIntervalMs?: number;
13
18
  };
14
19
  export declare const retryableFn: <T>(fn: () => Promise<T>, options?: RetryableFnOptions<T>) => Promise<T>;
@@ -1,8 +1,21 @@
1
1
  import { __awaiter } from '../_virtual/_tslib.js';
2
+ import './errors/TransactionGasCannotBeSponsoredError.js';
3
+ import './errors/InsufficientFundsError.js';
4
+ import './logger/logger.js';
5
+ import { sleep } from './sleep/sleep.js';
6
+ import 'viem/chains';
7
+ import 'tldts';
2
8
 
3
9
  const FALLBACK_UNDEFINED = 'FALLBACK_UNDEFINED';
4
10
  const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, function* () {
5
- const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', } = options;
11
+ const { maxRetries = 3, currentRetry = 0, timeoutMs = 100, fallbackValue = new Error('Max retries reached'), retryStrategy = 'timeout-only', retryIntervalMs = 0, logger, } = options;
12
+ logger === null || logger === void 0 ? void 0 : logger.debug('Configured retryableFn with options: ', {
13
+ currentRetry,
14
+ fallbackValue,
15
+ maxRetries,
16
+ retryStrategy,
17
+ timeoutMs,
18
+ });
6
19
  const timeoutPromise = new Promise((_, reject) => {
7
20
  setTimeout(() => {
8
21
  reject(new Error('Timeout'));
@@ -13,7 +26,9 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
13
26
  return result;
14
27
  }
15
28
  catch (err) {
29
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn caught error: ', err);
16
30
  if (currentRetry >= maxRetries) {
31
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning/throwing fallback value', err, fallbackValue);
17
32
  if (fallbackValue instanceof Error) {
18
33
  throw fallbackValue;
19
34
  }
@@ -22,22 +37,30 @@ const retryableFn = (fn, options = {}) => __awaiter(void 0, void 0, void 0, func
22
37
  }
23
38
  return fallbackValue;
24
39
  }
25
- const isTimeout = err.message === 'Timeout';
40
+ const isTimeout = (err === null || err === void 0 ? void 0 : err.message) === 'Timeout';
26
41
  const shouldRetry = retryStrategy === 'timeout-and-rejection' ||
27
42
  (retryStrategy === 'timeout-only' && isTimeout) ||
28
43
  (retryStrategy === 'rejection-only' && !isTimeout);
44
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn shouldRetry: ', shouldRetry);
29
45
  if (!shouldRetry) {
30
46
  if (fallbackValue instanceof Error) {
47
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn throwing fallbackValue error: ', fallbackValue);
31
48
  throw err;
32
49
  }
33
50
  else if (fallbackValue === FALLBACK_UNDEFINED) {
51
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning undefined');
34
52
  return undefined;
35
53
  }
54
+ logger === null || logger === void 0 ? void 0 : logger.debug('retryableFn returning fallbackValue: ', fallbackValue);
55
+ logger === null || logger === void 0 ? void 0 : logger.error('Error while retrying function, returning fallback value', err);
36
56
  return fallbackValue;
37
57
  }
58
+ if (retryIntervalMs)
59
+ yield sleep(retryIntervalMs);
38
60
  return retryableFn(fn, {
39
61
  currentRetry: currentRetry + 1,
40
62
  fallbackValue,
63
+ logger,
41
64
  maxRetries,
42
65
  retryStrategy,
43
66
  timeoutMs,
@@ -0,0 +1 @@
1
+ export { uniq } from './uniq';
@@ -0,0 +1,32 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Removes duplicate elements from an array.
7
+ *
8
+ * @param {T[]} array - The array to filter for unique elements.
9
+ * @template T - The type of elements in the array.
10
+ * @returns {T[]} A new array containing only the unique elements of the given array.
11
+ *
12
+ * @example
13
+ * // returns [1, 2, 3, 4, 5]
14
+ * uniq([1, 2, 2, 3, 4, 4, 5]);
15
+ *
16
+ * @example
17
+ * // returns ['apple', 'banana', 'orange']
18
+ * uniq(['apple', 'banana', 'apple', 'orange']);
19
+ *
20
+ */
21
+ const uniq = (array) => {
22
+ const seen = new Set();
23
+ return array.filter((item) => {
24
+ if (seen.has(item)) {
25
+ return false;
26
+ }
27
+ seen.add(item);
28
+ return true;
29
+ });
30
+ };
31
+
32
+ exports.uniq = uniq;
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Removes duplicate elements from an array.
3
+ *
4
+ * @param {T[]} array - The array to filter for unique elements.
5
+ * @template T - The type of elements in the array.
6
+ * @returns {T[]} A new array containing only the unique elements of the given array.
7
+ *
8
+ * @example
9
+ * // returns [1, 2, 3, 4, 5]
10
+ * uniq([1, 2, 2, 3, 4, 4, 5]);
11
+ *
12
+ * @example
13
+ * // returns ['apple', 'banana', 'orange']
14
+ * uniq(['apple', 'banana', 'apple', 'orange']);
15
+ *
16
+ */
17
+ export declare const uniq: <T>(array: T[]) => T[];
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Removes duplicate elements from an array.
3
+ *
4
+ * @param {T[]} array - The array to filter for unique elements.
5
+ * @template T - The type of elements in the array.
6
+ * @returns {T[]} A new array containing only the unique elements of the given array.
7
+ *
8
+ * @example
9
+ * // returns [1, 2, 3, 4, 5]
10
+ * uniq([1, 2, 2, 3, 4, 4, 5]);
11
+ *
12
+ * @example
13
+ * // returns ['apple', 'banana', 'orange']
14
+ * uniq(['apple', 'banana', 'apple', 'orange']);
15
+ *
16
+ */
17
+ const uniq = (array) => {
18
+ const seen = new Set();
19
+ return array.filter((item) => {
20
+ if (seen.has(item)) {
21
+ return false;
22
+ }
23
+ seen.add(item);
24
+ return true;
25
+ });
26
+ };
27
+
28
+ export { uniq };