@dynamic-labs/utils 1.0.0-alpha.1 → 1.0.0-alpha.10

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,4 +1,132 @@
1
1
 
2
+ ## [1.0.0-alpha.10](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.9...v1.0.0-alpha.10) (2023-12-08)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * allow transaction error to read from viem error ([#4101](https://github.com/dynamic-labs/DynamicAuth/issues/4101)) ([0f46cbe](https://github.com/dynamic-labs/DynamicAuth/commit/0f46cbea1eb260c2efdeee9b62f669fb3cf4ab93))
8
+ * trigger claim flow for unclaimed embedded smart contract wallet signer ([#4108](https://github.com/dynamic-labs/DynamicAuth/issues/4108)) ([37c9013](https://github.com/dynamic-labs/DynamicAuth/commit/37c9013109f2d6a37bde041da9072c5f5fa2df67))
9
+ * WalletConnect v2 connector with non active chains ([#4085](https://github.com/dynamic-labs/DynamicAuth/issues/4085)) ([f69cbe9](https://github.com/dynamic-labs/DynamicAuth/commit/f69cbe96012563f71e89939c96f2a46926e7b394))
10
+
11
+ ## [1.0.0-alpha.9](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.8...v1.0.0-alpha.9) (2023-12-07)
12
+
13
+
14
+ ### ⚠ BREAKING CHANGES
15
+
16
+ * how to migrate
17
+ Whenever you would use the property wallets from the object returned by useDynamicContext, you must now rename it to walletConnectorOptions.
18
+
19
+ ### Features
20
+
21
+ * add support for eip6963 ([#4064](https://github.com/dynamic-labs/DynamicAuth/issues/4064)) ([3f8cf0e](https://github.com/dynamic-labs/DynamicAuth/commit/3f8cf0e4250945f3a331f701d491a308fab5f7b8))
22
+ * allow AA wallets to access owner features ([#4079](https://github.com/dynamic-labs/DynamicAuth/issues/4079)) ([9efc2be](https://github.com/dynamic-labs/DynamicAuth/commit/9efc2bee87ec9193c3682863d72024b3586de724))
23
+ * introduce UserWalletsContext ([#4083](https://github.com/dynamic-labs/DynamicAuth/issues/4083)) ([b9ca7f6](https://github.com/dynamic-labs/DynamicAuth/commit/b9ca7f6b0aff4b3992325b70cc9a903ece445c7f))
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * ensure zero dev provider will receive a signer ([#4084](https://github.com/dynamic-labs/DynamicAuth/issues/4084)) ([f02a540](https://github.com/dynamic-labs/DynamicAuth/commit/f02a54036d39bfc5fb0c262f292acf914e4bd653))
29
+ * render recovery section only when turnkey provider is enabled ([#4093](https://github.com/dynamic-labs/DynamicAuth/issues/4093)) ([5f29bd2](https://github.com/dynamic-labs/DynamicAuth/commit/5f29bd23ccca2e307822377be28396edc7ab1fda))
30
+ * reset selected social provider on logout ([#4078](https://github.com/dynamic-labs/DynamicAuth/issues/4078)) ([85dc611](https://github.com/dynamic-labs/DynamicAuth/commit/85dc611d9c0e733bdb9d316b008bdaa35bcc2a91))
31
+
32
+
33
+ * rename wallets > walletConnectorOptions ([#4086](https://github.com/dynamic-labs/DynamicAuth/issues/4086)) ([10a7795](https://github.com/dynamic-labs/DynamicAuth/commit/10a779567e751469a667095726da52d78facbd57))
34
+
35
+ ## [1.0.0-alpha.8](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.7...v1.0.0-alpha.8) (2023-12-05)
36
+
37
+
38
+ ### ⚠ BREAKING CHANGES
39
+
40
+ * rename EthereumSmartWalletConnectors to ZeroDevSmartWalletConnectors (#4067)
41
+
42
+
43
+ ### Features
44
+
45
+ * add support for pregenerated wallets + securing them ([#3968](https://github.com/dynamic-labs/DynamicAuth/issues/3968)) ([8212b76](https://github.com/dynamic-labs/DynamicAuth/commit/8212b760ba199bd989e0ba2ad3caf97590db4861))
46
+
47
+ ## [1.0.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2023-12-05)
48
+
49
+
50
+ ### Features
51
+
52
+ * add support for Turnkey HD wallets and backwards compatiblity for private key wallets ([#4011](https://github.com/dynamic-labs/DynamicAuth/issues/4011)) ([75c5258](https://github.com/dynamic-labs/DynamicAuth/commit/75c5258da494d5d4dfa8b96655303dd9645f2269))
53
+
54
+
55
+ ### Bug Fixes
56
+
57
+ * add close button to wallets list ([#4036](https://github.com/dynamic-labs/DynamicAuth/issues/4036)) ([a2b988b](https://github.com/dynamic-labs/DynamicAuth/commit/a2b988bdfc662af6f85d37a79ed6666c483aa447))
58
+ * add support for embedded wallets in connect-only ([#4041](https://github.com/dynamic-labs/DynamicAuth/issues/4041)) ([ceea635](https://github.com/dynamic-labs/DynamicAuth/commit/ceea635b69e2a0c2636b47fbd30639d69dba7a1c))
59
+ * embedded wallet invalid stored chain breaking network picker ([#4050](https://github.com/dynamic-labs/DynamicAuth/issues/4050)) ([2e2384b](https://github.com/dynamic-labs/DynamicAuth/commit/2e2384ba37407d9164cce47e23f5d5f469f7e062))
60
+ * handle insufficient funds from AA provider ([#4027](https://github.com/dynamic-labs/DynamicAuth/issues/4027)) ([6b9cc88](https://github.com/dynamic-labs/DynamicAuth/commit/6b9cc886f4f2590094bd50aba195c07a5532dfa4))
61
+ * prevent double logout caused by wagmi sync ([#4048](https://github.com/dynamic-labs/DynamicAuth/issues/4048)) ([c66c81c](https://github.com/dynamic-labs/DynamicAuth/commit/c66c81c80839aa9ce1cfae76f4afce12e34f3513))
62
+ * properly detect network switch for secondary wallets ([#4038](https://github.com/dynamic-labs/DynamicAuth/issues/4038)) ([f87174d](https://github.com/dynamic-labs/DynamicAuth/commit/f87174de0892dd057401eaf3c0bc68d974add0fc))
63
+ * **use-wallets-connected-state:** update state on wallet id change ([#4045](https://github.com/dynamic-labs/DynamicAuth/issues/4045)) ([ca3a835](https://github.com/dynamic-labs/DynamicAuth/commit/ca3a8359eae386bffa758ed646ac14af8360a7f8))
64
+ * user should be able to see the full passkey name on management view ([#4043](https://github.com/dynamic-labs/DynamicAuth/issues/4043)) ([7bc1b70](https://github.com/dynamic-labs/DynamicAuth/commit/7bc1b7043cbc9f0e21df78a57efc3e6938a99db2))
65
+ * users should be able to easily find passkey recovery ([#4058](https://github.com/dynamic-labs/DynamicAuth/issues/4058)) ([0202ae9](https://github.com/dynamic-labs/DynamicAuth/commit/0202ae98c96544dec5ac357dc77000996e32ad33))
66
+
67
+ ## [1.0.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2023-11-29)
68
+
69
+
70
+ ### Bug Fixes
71
+
72
+ * transaction layout show alert ([#4024](https://github.com/dynamic-labs/DynamicAuth/issues/4024)) ([52057f5](https://github.com/dynamic-labs/DynamicAuth/commit/52057f54ebc32464b2486a2328cb6310caf85208)), closes [#4020](https://github.com/dynamic-labs/DynamicAuth/issues/4020)
73
+
74
+ ## [1.0.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.4...v1.0.0-alpha.5) (2023-11-29)
75
+
76
+
77
+ ### Features
78
+
79
+ * gracefully handle uknown wallet ([#3997](https://github.com/dynamic-labs/DynamicAuth/issues/3997)) ([ce7ff6a](https://github.com/dynamic-labs/DynamicAuth/commit/ce7ff6a50a8e8947050734b61587c8cadd041dbe))
80
+
81
+
82
+ ### Bug Fixes
83
+
84
+ * remove total on sponsored transactions ([#4019](https://github.com/dynamic-labs/DynamicAuth/issues/4019)) ([d976678](https://github.com/dynamic-labs/DynamicAuth/commit/d9766787b29665fbcd7983c5d61c31a4d97c8257))
85
+ * send balance align information ([#4020](https://github.com/dynamic-labs/DynamicAuth/issues/4020)) ([508dccf](https://github.com/dynamic-labs/DynamicAuth/commit/508dccfa2c6aeaed30616b6a41b30002cccb3b40))
86
+
87
+ ## [1.0.0-alpha.4](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.3...v1.0.0-alpha.4) (2023-11-28)
88
+
89
+
90
+ ### Bug Fixes
91
+
92
+ * update zerodev provider initialization ([#4015](https://github.com/dynamic-labs/DynamicAuth/issues/4015)) ([8faca00](https://github.com/dynamic-labs/DynamicAuth/commit/8faca00d414677adc5fecde451ca01da53fe9641))
93
+
94
+ ## [1.0.0-alpha.3](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.2...v1.0.0-alpha.3) (2023-11-28)
95
+
96
+
97
+ ### Bug Fixes
98
+
99
+ * fix solflare mobile wallet deep linking ([#3998](https://github.com/dynamic-labs/DynamicAuth/issues/3998)) ([10069ae](https://github.com/dynamic-labs/DynamicAuth/commit/10069ae9ed5d8e1978131f57c3e90680e85d2efb))
100
+ * passkey error message when reaching limit of accounts ([#4010](https://github.com/dynamic-labs/DynamicAuth/issues/4010)) ([dabce3b](https://github.com/dynamic-labs/DynamicAuth/commit/dabce3b6ada4bac75903b43d5cb125cfd5619d18))
101
+
102
+ ## [1.0.0-alpha.2](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.1...v1.0.0-alpha.2) (2023-11-28)
103
+
104
+
105
+ ### ⚠ BREAKING CHANGES
106
+
107
+ * rename walletsByChain to bridgeChains (#3954)
108
+
109
+ ### Features
110
+
111
+ * passkey management and recovery ([#3911](https://github.com/dynamic-labs/DynamicAuth/issues/3911)) ([b692b3a](https://github.com/dynamic-labs/DynamicAuth/commit/b692b3a8697d0ffb441faae97e609b144965695d))
112
+
113
+
114
+ ### Bug Fixes
115
+
116
+ * ensure all chain rpc providers are always assigned correctly ([#3981](https://github.com/dynamic-labs/DynamicAuth/issues/3981)) ([cd2e25c](https://github.com/dynamic-labs/DynamicAuth/commit/cd2e25c4eb39791866c1ea283d61fff388cce5df))
117
+ * initialize selected chain with first evm network if no value in ls ([#3999](https://github.com/dynamic-labs/DynamicAuth/issues/3999)) ([bc9e43b](https://github.com/dynamic-labs/DynamicAuth/commit/bc9e43be9d33c75bb1236756589f63f17b230ab1))
118
+ * nextjs issues to show transaction modals ([#3964](https://github.com/dynamic-labs/DynamicAuth/issues/3964)) ([9326ac4](https://github.com/dynamic-labs/DynamicAuth/commit/9326ac49394e067ce38b17faff08b4fabf91bb3f))
119
+ * onEmbeddedWalletCreated not being called ([#3975](https://github.com/dynamic-labs/DynamicAuth/issues/3975)) ([035cebe](https://github.com/dynamic-labs/DynamicAuth/commit/035cebe02891048e62c66a7277ed7f43c27e559d))
120
+ * return linked wallets even when there's no primary wallet ([#3965](https://github.com/dynamic-labs/DynamicAuth/issues/3965)) ([27705de](https://github.com/dynamic-labs/DynamicAuth/commit/27705de4ac7e1584efd1245bb9c6a818b1c20742))
121
+ * transaction modal not throwing viem compatible exception ([#3971](https://github.com/dynamic-labs/DynamicAuth/issues/3971)) ([bedab0c](https://github.com/dynamic-labs/DynamicAuth/commit/bedab0c4448bcca5c3e696ceb276867ce55bbd85))
122
+ * **zero-dev:** ensure the sign typed data is parsed for zero dev to handle ([#3974](https://github.com/dynamic-labs/DynamicAuth/issues/3974)) ([f517738](https://github.com/dynamic-labs/DynamicAuth/commit/f517738e1abc138f882525c128cd1ee5e88b9050))
123
+ * zerodev sign message with ethers ([#3972](https://github.com/dynamic-labs/DynamicAuth/issues/3972)) ([5de3873](https://github.com/dynamic-labs/DynamicAuth/commit/5de3873daa9cbfeef6dd9123b7a319d8e6b412d5))
124
+ * **zerodev:** ensure ECDSAProvider supports sendUserOperation ([#4003](https://github.com/dynamic-labs/DynamicAuth/issues/4003)) ([c8f5886](https://github.com/dynamic-labs/DynamicAuth/commit/c8f58868fcf6912fd11a92940369faf37e3fcdde))
125
+ * **zerodev:** ensure transaction is sponsored before submission ([#3932](https://github.com/dynamic-labs/DynamicAuth/issues/3932)) ([74becb7](https://github.com/dynamic-labs/DynamicAuth/commit/74becb7ec2fd55f8b905a9c9f0bbba44a9d22513))
126
+
127
+
128
+ * rename walletsByChain to bridgeChains ([#3954](https://github.com/dynamic-labs/DynamicAuth/issues/3954)) ([a91e8fe](https://github.com/dynamic-labs/DynamicAuth/commit/a91e8fe605694ccd8a00b71aa194c0c5191f156c))
129
+
2
130
  ## [1.0.0-alpha.1](https://github.com/dynamic-labs/DynamicAuth/compare/v1.0.0-alpha.0...v1.0.0-alpha.1) (2023-11-22)
3
131
 
4
132
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/utils",
3
- "version": "1.0.0-alpha.1",
3
+ "version": "1.0.0-alpha.10",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -29,7 +29,7 @@
29
29
  "viem": "^1.5.3"
30
30
  },
31
31
  "dependencies": {
32
- "@dynamic-labs/logger": "1.0.0-alpha.1",
33
- "@dynamic-labs/types": "1.0.0-alpha.1"
32
+ "@dynamic-labs/logger": "1.0.0-alpha.10",
33
+ "@dynamic-labs/types": "1.0.0-alpha.10"
34
34
  }
35
35
  }
@@ -0,0 +1,21 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * A DeferredPromise provides methods to manually resolve or reject a Promise.
7
+ * This is useful in scenarios where you need to resolve or reject a Promise
8
+ * outside of the executor function.
9
+ *
10
+ * @template T The type of the value with which the promise will be resolved.
11
+ */
12
+ class DeferredPromise {
13
+ constructor() {
14
+ this.promise = new Promise((resolve, reject) => {
15
+ this.resolve = resolve;
16
+ this.reject = reject;
17
+ });
18
+ }
19
+ }
20
+
21
+ exports.DeferredPromise = DeferredPromise;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * A DeferredPromise provides methods to manually resolve or reject a Promise.
3
+ * This is useful in scenarios where you need to resolve or reject a Promise
4
+ * outside of the executor function.
5
+ *
6
+ * @template T The type of the value with which the promise will be resolved.
7
+ */
8
+ export declare class DeferredPromise<T> {
9
+ promise: Promise<T>;
10
+ resolve: (value: T | PromiseLike<T>) => void;
11
+ reject: (reason?: any) => void;
12
+ constructor();
13
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * A DeferredPromise provides methods to manually resolve or reject a Promise.
3
+ * This is useful in scenarios where you need to resolve or reject a Promise
4
+ * outside of the executor function.
5
+ *
6
+ * @template T The type of the value with which the promise will be resolved.
7
+ */
8
+ class DeferredPromise {
9
+ constructor() {
10
+ this.promise = new Promise((resolve, reject) => {
11
+ this.resolve = resolve;
12
+ this.reject = reject;
13
+ });
14
+ }
15
+ }
16
+
17
+ export { DeferredPromise };
@@ -0,0 +1 @@
1
+ export { DeferredPromise } from './DeferredPromise';
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class InsufficientFundsError extends DynamicError.DynamicError {
8
+ constructor() {
9
+ super(InsufficientFundsError.message);
10
+ }
11
+ static isInstance(err) {
12
+ var _a;
13
+ const error = ((_a = err === null || err === void 0 ? void 0 : err.walk) === null || _a === void 0 ? void 0 : _a.call(err)) || err;
14
+ return error instanceof InsufficientFundsError;
15
+ }
16
+ static isErrorMessage(err) {
17
+ var _a;
18
+ const errorWithMessage = err;
19
+ return (((_a = errorWithMessage === null || errorWithMessage === void 0 ? void 0 : errorWithMessage.message) === null || _a === void 0 ? void 0 : _a.includes("AA21 didn't pay prefund")) || false);
20
+ }
21
+ }
22
+ InsufficientFundsError.message = 'Insufficient funds.';
23
+
24
+ exports.InsufficientFundsError = InsufficientFundsError;
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class InsufficientFundsError extends DynamicError {
3
+ constructor();
4
+ static message: string;
5
+ static isInstance(err: {
6
+ walk?: () => unknown;
7
+ } | unknown): err is InsufficientFundsError;
8
+ static isErrorMessage(err: unknown): boolean;
9
+ }
@@ -0,0 +1,20 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class InsufficientFundsError extends DynamicError {
4
+ constructor() {
5
+ super(InsufficientFundsError.message);
6
+ }
7
+ static isInstance(err) {
8
+ var _a;
9
+ const error = ((_a = err === null || err === void 0 ? void 0 : err.walk) === null || _a === void 0 ? void 0 : _a.call(err)) || err;
10
+ return error instanceof InsufficientFundsError;
11
+ }
12
+ static isErrorMessage(err) {
13
+ var _a;
14
+ const errorWithMessage = err;
15
+ return (((_a = errorWithMessage === null || errorWithMessage === void 0 ? void 0 : errorWithMessage.message) === null || _a === void 0 ? void 0 : _a.includes("AA21 didn't pay prefund")) || false);
16
+ }
17
+ }
18
+ InsufficientFundsError.message = 'Insufficient funds.';
19
+
20
+ export { InsufficientFundsError };
@@ -0,0 +1,8 @@
1
+ export type PasskeyError = {
2
+ cause?: {
3
+ code: number;
4
+ name: string;
5
+ message: string;
6
+ };
7
+ code?: number;
8
+ };
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var DynamicError = require('./DynamicError.cjs');
6
+
7
+ class TransactionGasCannotBeSponsoredError extends DynamicError.DynamicError {
8
+ constructor() {
9
+ super(TransactionGasCannotBeSponsoredError.message);
10
+ }
11
+ static isInstance(err) {
12
+ var _a;
13
+ const error = ((_a = err === null || err === void 0 ? void 0 : err.walk) === null || _a === void 0 ? void 0 : _a.call(err)) || err;
14
+ return error instanceof TransactionGasCannotBeSponsoredError;
15
+ }
16
+ static isErrorMessage(err) {
17
+ var _a;
18
+ const errorWithMessage = err;
19
+ return (((_a = errorWithMessage === null || errorWithMessage === void 0 ? void 0 : errorWithMessage.message) === null || _a === void 0 ? void 0 : _a.includes('userOp did not match any gas sponsoring policies')) || false);
20
+ }
21
+ }
22
+ TransactionGasCannotBeSponsoredError.message = 'Transaction gas cannot be sponsored.';
23
+
24
+ exports.TransactionGasCannotBeSponsoredError = TransactionGasCannotBeSponsoredError;
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class TransactionGasCannotBeSponsoredError extends DynamicError {
3
+ constructor();
4
+ static message: string;
5
+ static isInstance(err: {
6
+ walk?: () => unknown;
7
+ } | unknown): err is TransactionGasCannotBeSponsoredError;
8
+ static isErrorMessage(err: unknown): boolean;
9
+ }
@@ -0,0 +1,20 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class TransactionGasCannotBeSponsoredError extends DynamicError {
4
+ constructor() {
5
+ super(TransactionGasCannotBeSponsoredError.message);
6
+ }
7
+ static isInstance(err) {
8
+ var _a;
9
+ const error = ((_a = err === null || err === void 0 ? void 0 : err.walk) === null || _a === void 0 ? void 0 : _a.call(err)) || err;
10
+ return error instanceof TransactionGasCannotBeSponsoredError;
11
+ }
12
+ static isErrorMessage(err) {
13
+ var _a;
14
+ const errorWithMessage = err;
15
+ return (((_a = errorWithMessage === null || errorWithMessage === void 0 ? void 0 : errorWithMessage.message) === null || _a === void 0 ? void 0 : _a.includes('userOp did not match any gas sponsoring policies')) || false);
16
+ }
17
+ }
18
+ TransactionGasCannotBeSponsoredError.message = 'Transaction gas cannot be sponsored.';
19
+
20
+ export { TransactionGasCannotBeSponsoredError };
@@ -14,3 +14,6 @@ export * from './MissingEnvironmentIdError';
14
14
  export * from './GateBlockedError';
15
15
  export * from './UserHasAccountWithEmailError';
16
16
  export * from './SocialAccountAlreadyExistsError';
17
+ export * from './TransactionGasCannotBeSponsoredError';
18
+ export * from './InsufficientFundsError';
19
+ export * from './PasskeyError';
package/src/index.cjs CHANGED
@@ -20,6 +20,8 @@ var MissingEnvironmentIdError = require('./errors/MissingEnvironmentIdError.cjs'
20
20
  var GateBlockedError = require('./errors/GateBlockedError.cjs');
21
21
  var UserHasAccountWithEmailError = require('./errors/UserHasAccountWithEmailError.cjs');
22
22
  var SocialAccountAlreadyExistsError = require('./errors/SocialAccountAlreadyExistsError.cjs');
23
+ var TransactionGasCannotBeSponsoredError = require('./errors/TransactionGasCannotBeSponsoredError.cjs');
24
+ var InsufficientFundsError = require('./errors/InsufficientFundsError.cjs');
23
25
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
24
26
  var isFunction = require('./isFunction/isFunction.cjs');
25
27
  var isMobile = require('./isMobile.cjs');
@@ -30,6 +32,8 @@ var getProvidersFromWindow = require('./getProvidersFromWindow.cjs');
30
32
  var sleep = require('./sleep/sleep.cjs');
31
33
  var getOrMapViemChain = require('./getOrMapViemChain.cjs');
32
34
  var retryableFn = require('./retryableFn.cjs');
35
+ var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
36
+ var DeferredPromise = require('./DeferredPromise/DeferredPromise.cjs');
33
37
 
34
38
 
35
39
 
@@ -51,6 +55,8 @@ exports.MissingEnvironmentIdError = MissingEnvironmentIdError.MissingEnvironment
51
55
  exports.GateBlockedError = GateBlockedError.GateBlockedError;
52
56
  exports.UserHasAccountWithEmailError = UserHasAccountWithEmailError.UserHasAccountWithEmailError;
53
57
  exports.SocialAccountAlreadyExistsError = SocialAccountAlreadyExistsError.SocialAccountAlreadyExistsError;
58
+ exports.TransactionGasCannotBeSponsoredError = TransactionGasCannotBeSponsoredError.TransactionGasCannotBeSponsoredError;
59
+ exports.InsufficientFundsError = InsufficientFundsError.InsufficientFundsError;
54
60
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
55
61
  exports.isFunction = isFunction.isFunction;
56
62
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -75,3 +81,5 @@ exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
75
81
  exports.mapChain = getOrMapViemChain.mapChain;
76
82
  exports.FALLBACK_UNDEFINED = retryableFn.FALLBACK_UNDEFINED;
77
83
  exports.retryableFn = retryableFn.retryableFn;
84
+ exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
85
+ exports.DeferredPromise = DeferredPromise.DeferredPromise;
package/src/index.d.ts CHANGED
@@ -11,3 +11,5 @@ export * from './getProvidersFromWindow';
11
11
  export * from './sleep';
12
12
  export * from './getOrMapViemChain';
13
13
  export * from './retryableFn';
14
+ export * from './wrapMethodWithCallback';
15
+ export * from './DeferredPromise';
package/src/index.js CHANGED
@@ -16,6 +16,8 @@ export { MissingEnvironmentIdError } from './errors/MissingEnvironmentIdError.js
16
16
  export { GateBlockedError } from './errors/GateBlockedError.js';
17
17
  export { UserHasAccountWithEmailError } from './errors/UserHasAccountWithEmailError.js';
18
18
  export { SocialAccountAlreadyExistsError } from './errors/SocialAccountAlreadyExistsError.js';
19
+ export { TransactionGasCannotBeSponsoredError } from './errors/TransactionGasCannotBeSponsoredError.js';
20
+ export { InsufficientFundsError } from './errors/InsufficientFundsError.js';
19
21
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
20
22
  export { isFunction } from './isFunction/isFunction.js';
21
23
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -26,3 +28,5 @@ export { getProvidersFromWindow } from './getProvidersFromWindow.js';
26
28
  export { sleep } from './sleep/sleep.js';
27
29
  export { getChain, getOrMapViemChain, mapChain } from './getOrMapViemChain.js';
28
30
  export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
31
+ export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
32
+ export { DeferredPromise } from './DeferredPromise/DeferredPromise.js';
@@ -0,0 +1 @@
1
+ export { wrapMethodWithCallback } from './wrapMethodWithCallback';
@@ -0,0 +1,46 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ /**
6
+ * Wraps an existing method of an object with a callback function. This allows for additional
7
+ * processing or behavior to be executed around the original method. The original method is
8
+ * called within the callback, and its parameters and return value can be accessed and/or modified.
9
+ *
10
+ * @template T - The type of the object whose method is being wrapped.
11
+ * @template K - The key type of the method within the object.
12
+ * @template F - The type of the function, inferred from the method of the object.
13
+ *
14
+ * @param {T} obj - The object containing the method to be wrapped.
15
+ * @param {K} key - The key of the method in the object to be wrapped.
16
+ * @param {(original: F, ...args: Parameters<F>) => ReturnType<F>} callback - The callback
17
+ * function to wrap around the original method. It receive1`s the original method and its
18
+ * parameters as arguments.
19
+ *
20
+ * @returns {void} - The function does not return a value; it modifies the method of the object in place.
21
+ *
22
+ * @example
23
+ * // Example usage
24
+ * const myObject = {
25
+ * greet(name) {
26
+ * return `Hello, ${name}!`;
27
+ * }
28
+ * };
29
+ *
30
+ * wrapMethodWithCallback(myObject, 'greet', (original, ...args) => {
31
+ * console.log('Greet method called with args:', args);
32
+ * return original(...args).toUpperCase();
33
+ * });
34
+ *
35
+ * console.log(myObject.greet('Alice')); // Logs: 'Greet method called with args: ["Alice"]'
36
+ * // Returns: 'HELLO, ALICE!'
37
+ */
38
+ const wrapMethodWithCallback = (obj, key, callback) => {
39
+ const original = obj[key];
40
+ const boundOriginal = original.bind(obj);
41
+ Object.assign(obj, {
42
+ [key]: (...args) => callback(boundOriginal, ...args),
43
+ });
44
+ };
45
+
46
+ exports.wrapMethodWithCallback = wrapMethodWithCallback;
@@ -0,0 +1,36 @@
1
+ type Method = (...args: any[]) => any;
2
+ /**
3
+ * Wraps an existing method of an object with a callback function. This allows for additional
4
+ * processing or behavior to be executed around the original method. The original method is
5
+ * called within the callback, and its parameters and return value can be accessed and/or modified.
6
+ *
7
+ * @template T - The type of the object whose method is being wrapped.
8
+ * @template K - The key type of the method within the object.
9
+ * @template F - The type of the function, inferred from the method of the object.
10
+ *
11
+ * @param {T} obj - The object containing the method to be wrapped.
12
+ * @param {K} key - The key of the method in the object to be wrapped.
13
+ * @param {(original: F, ...args: Parameters<F>) => ReturnType<F>} callback - The callback
14
+ * function to wrap around the original method. It receive1`s the original method and its
15
+ * parameters as arguments.
16
+ *
17
+ * @returns {void} - The function does not return a value; it modifies the method of the object in place.
18
+ *
19
+ * @example
20
+ * // Example usage
21
+ * const myObject = {
22
+ * greet(name) {
23
+ * return `Hello, ${name}!`;
24
+ * }
25
+ * };
26
+ *
27
+ * wrapMethodWithCallback(myObject, 'greet', (original, ...args) => {
28
+ * console.log('Greet method called with args:', args);
29
+ * return original(...args).toUpperCase();
30
+ * });
31
+ *
32
+ * console.log(myObject.greet('Alice')); // Logs: 'Greet method called with args: ["Alice"]'
33
+ * // Returns: 'HELLO, ALICE!'
34
+ */
35
+ export declare const wrapMethodWithCallback: <T extends object, K extends { [P in keyof T]: T[P] extends Method ? P : never; }[keyof T], F extends Method = T[K] extends Method ? T[K] : never>(obj: T, key: K, callback: (original: F, ...args: Parameters<F>) => ReturnType<F>) => void;
36
+ export {};
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Wraps an existing method of an object with a callback function. This allows for additional
3
+ * processing or behavior to be executed around the original method. The original method is
4
+ * called within the callback, and its parameters and return value can be accessed and/or modified.
5
+ *
6
+ * @template T - The type of the object whose method is being wrapped.
7
+ * @template K - The key type of the method within the object.
8
+ * @template F - The type of the function, inferred from the method of the object.
9
+ *
10
+ * @param {T} obj - The object containing the method to be wrapped.
11
+ * @param {K} key - The key of the method in the object to be wrapped.
12
+ * @param {(original: F, ...args: Parameters<F>) => ReturnType<F>} callback - The callback
13
+ * function to wrap around the original method. It receive1`s the original method and its
14
+ * parameters as arguments.
15
+ *
16
+ * @returns {void} - The function does not return a value; it modifies the method of the object in place.
17
+ *
18
+ * @example
19
+ * // Example usage
20
+ * const myObject = {
21
+ * greet(name) {
22
+ * return `Hello, ${name}!`;
23
+ * }
24
+ * };
25
+ *
26
+ * wrapMethodWithCallback(myObject, 'greet', (original, ...args) => {
27
+ * console.log('Greet method called with args:', args);
28
+ * return original(...args).toUpperCase();
29
+ * });
30
+ *
31
+ * console.log(myObject.greet('Alice')); // Logs: 'Greet method called with args: ["Alice"]'
32
+ * // Returns: 'HELLO, ALICE!'
33
+ */
34
+ const wrapMethodWithCallback = (obj, key, callback) => {
35
+ const original = obj[key];
36
+ const boundOriginal = original.bind(obj);
37
+ Object.assign(obj, {
38
+ [key]: (...args) => callback(boundOriginal, ...args),
39
+ });
40
+ };
41
+
42
+ export { wrapMethodWithCallback };