@dynamic-labs/utils 1.0.0-alpha.1 → 1.0.0-alpha.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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,40 @@
1
1
 
2
+ ## [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)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * fix solflare mobile wallet deep linking ([#3998](https://github.com/dynamic-labs/DynamicAuth/issues/3998)) ([10069ae](https://github.com/dynamic-labs/DynamicAuth/commit/10069ae9ed5d8e1978131f57c3e90680e85d2efb))
8
+ * 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))
9
+
10
+ ## [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)
11
+
12
+
13
+ ### ⚠ BREAKING CHANGES
14
+
15
+ * rename walletsByChain to bridgeChains (#3954)
16
+
17
+ ### Features
18
+
19
+ * passkey management and recovery ([#3911](https://github.com/dynamic-labs/DynamicAuth/issues/3911)) ([b692b3a](https://github.com/dynamic-labs/DynamicAuth/commit/b692b3a8697d0ffb441faae97e609b144965695d))
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * 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))
25
+ * 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))
26
+ * nextjs issues to show transaction modals ([#3964](https://github.com/dynamic-labs/DynamicAuth/issues/3964)) ([9326ac4](https://github.com/dynamic-labs/DynamicAuth/commit/9326ac49394e067ce38b17faff08b4fabf91bb3f))
27
+ * onEmbeddedWalletCreated not being called ([#3975](https://github.com/dynamic-labs/DynamicAuth/issues/3975)) ([035cebe](https://github.com/dynamic-labs/DynamicAuth/commit/035cebe02891048e62c66a7277ed7f43c27e559d))
28
+ * 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))
29
+ * 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))
30
+ * **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))
31
+ * zerodev sign message with ethers ([#3972](https://github.com/dynamic-labs/DynamicAuth/issues/3972)) ([5de3873](https://github.com/dynamic-labs/DynamicAuth/commit/5de3873daa9cbfeef6dd9123b7a319d8e6b412d5))
32
+ * **zerodev:** ensure ECDSAProvider supports sendUserOperation ([#4003](https://github.com/dynamic-labs/DynamicAuth/issues/4003)) ([c8f5886](https://github.com/dynamic-labs/DynamicAuth/commit/c8f58868fcf6912fd11a92940369faf37e3fcdde))
33
+ * **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))
34
+
35
+
36
+ * rename walletsByChain to bridgeChains ([#3954](https://github.com/dynamic-labs/DynamicAuth/issues/3954)) ([a91e8fe](https://github.com/dynamic-labs/DynamicAuth/commit/a91e8fe605694ccd8a00b71aa194c0c5191f156c))
37
+
2
38
  ## [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
39
 
4
40
 
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.3",
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.3",
33
+ "@dynamic-labs/types": "1.0.0-alpha.3"
34
34
  }
35
35
  }
@@ -0,0 +1,13 @@
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('Transaction gas cannot be sponsored.');
10
+ }
11
+ }
12
+
13
+ exports.TransactionGasCannotBeSponsoredError = TransactionGasCannotBeSponsoredError;
@@ -0,0 +1,4 @@
1
+ import { DynamicError } from './DynamicError';
2
+ export declare class TransactionGasCannotBeSponsoredError extends DynamicError {
3
+ constructor();
4
+ }
@@ -0,0 +1,9 @@
1
+ import { DynamicError } from './DynamicError.js';
2
+
3
+ class TransactionGasCannotBeSponsoredError extends DynamicError {
4
+ constructor() {
5
+ super('Transaction gas cannot be sponsored.');
6
+ }
7
+ }
8
+
9
+ export { TransactionGasCannotBeSponsoredError };
@@ -14,3 +14,4 @@ export * from './MissingEnvironmentIdError';
14
14
  export * from './GateBlockedError';
15
15
  export * from './UserHasAccountWithEmailError';
16
16
  export * from './SocialAccountAlreadyExistsError';
17
+ export * from './TransactionGasCannotBeSponsoredError';
package/src/index.cjs CHANGED
@@ -20,6 +20,7 @@ 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');
23
24
  var CancellablePromise = require('./CancellablePromise/CancellablePromise.cjs');
24
25
  var isFunction = require('./isFunction/isFunction.cjs');
25
26
  var isMobile = require('./isMobile.cjs');
@@ -30,6 +31,7 @@ var getProvidersFromWindow = require('./getProvidersFromWindow.cjs');
30
31
  var sleep = require('./sleep/sleep.cjs');
31
32
  var getOrMapViemChain = require('./getOrMapViemChain.cjs');
32
33
  var retryableFn = require('./retryableFn.cjs');
34
+ var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
33
35
 
34
36
 
35
37
 
@@ -51,6 +53,7 @@ exports.MissingEnvironmentIdError = MissingEnvironmentIdError.MissingEnvironment
51
53
  exports.GateBlockedError = GateBlockedError.GateBlockedError;
52
54
  exports.UserHasAccountWithEmailError = UserHasAccountWithEmailError.UserHasAccountWithEmailError;
53
55
  exports.SocialAccountAlreadyExistsError = SocialAccountAlreadyExistsError.SocialAccountAlreadyExistsError;
56
+ exports.TransactionGasCannotBeSponsoredError = TransactionGasCannotBeSponsoredError.TransactionGasCannotBeSponsoredError;
54
57
  exports.CancellablePromise = CancellablePromise.CancellablePromise;
55
58
  exports.isFunction = isFunction.isFunction;
56
59
  exports.getAndroidVersion = isMobile.getAndroidVersion;
@@ -75,3 +78,4 @@ exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
75
78
  exports.mapChain = getOrMapViemChain.mapChain;
76
79
  exports.FALLBACK_UNDEFINED = retryableFn.FALLBACK_UNDEFINED;
77
80
  exports.retryableFn = retryableFn.retryableFn;
81
+ exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
package/src/index.d.ts CHANGED
@@ -11,3 +11,4 @@ export * from './getProvidersFromWindow';
11
11
  export * from './sleep';
12
12
  export * from './getOrMapViemChain';
13
13
  export * from './retryableFn';
14
+ export * from './wrapMethodWithCallback';
package/src/index.js CHANGED
@@ -16,6 +16,7 @@ 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';
19
20
  export { CancellablePromise } from './CancellablePromise/CancellablePromise.js';
20
21
  export { isFunction } from './isFunction/isFunction.js';
21
22
  export { getAndroidVersion, isAndroid, isIOS, isIPad, isIPhone, isIPhone8OrEarlier, isLegacySafari, isMobile, isSamsungBrowser, isWindows } from './isMobile.js';
@@ -26,3 +27,4 @@ export { getProvidersFromWindow } from './getProvidersFromWindow.js';
26
27
  export { sleep } from './sleep/sleep.js';
27
28
  export { getChain, getOrMapViemChain, mapChain } from './getOrMapViemChain.js';
28
29
  export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
30
+ export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.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 };