@dynamic-labs/utils 1.0.0-alpha.0 → 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 +84 -0
- package/package.json +3 -3
- package/src/errors/TransactionGasCannotBeSponsoredError.cjs +13 -0
- package/src/errors/TransactionGasCannotBeSponsoredError.d.ts +4 -0
- package/src/errors/TransactionGasCannotBeSponsoredError.js +9 -0
- package/src/errors/index.d.ts +1 -0
- package/src/index.cjs +4 -4
- package/src/index.d.ts +1 -2
- package/src/index.js +2 -2
- package/src/isMobile.cjs +12 -2
- package/src/isMobile.js +12 -2
- package/src/wrapMethodWithCallback/index.d.ts +1 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.cjs +46 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.d.ts +36 -0
- package/src/wrapMethodWithCallback/wrapMethodWithCallback.js +42 -0
- package/src/bigIntToHex/bigIntToHex.cjs +0 -15
- package/src/bigIntToHex/bigIntToHex.d.ts +0 -1
- package/src/bigIntToHex/bigIntToHex.js +0 -11
- package/src/bigIntToHex/index.d.ts +0 -1
- package/src/isBigInt/index.d.ts +0 -1
- package/src/isBigInt/isBigInt.cjs +0 -7
- package/src/isBigInt/isBigInt.d.ts +0 -1
- package/src/isBigInt/isBigInt.js +0 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,88 @@
|
|
|
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
|
+
|
|
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)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Features
|
|
42
|
+
|
|
43
|
+
* add basic zerodev connector ([#3782](https://github.com/dynamic-labs/DynamicAuth/issues/3782)) ([3f8debd](https://github.com/dynamic-labs/DynamicAuth/commit/3f8debddb1bff325389193e0348128ebb9ba59b9))
|
|
44
|
+
* add hcaptcha to dynamic signin methods ([#3853](https://github.com/dynamic-labs/DynamicAuth/issues/3853)) ([a4a9ad3](https://github.com/dynamic-labs/DynamicAuth/commit/a4a9ad3b048e33acc5b885cd797697ca4f41995e))
|
|
45
|
+
* add hcaptcha to magic login methods ([#3894](https://github.com/dynamic-labs/DynamicAuth/issues/3894)) ([c76b750](https://github.com/dynamic-labs/DynamicAuth/commit/c76b750351557ad9cf5bbcc39bd7fd0970b66312))
|
|
46
|
+
* add need help section to sign message modal ([#3847](https://github.com/dynamic-labs/DynamicAuth/issues/3847)) ([4f90617](https://github.com/dynamic-labs/DynamicAuth/commit/4f90617bcf400a7171062435c731d95c6bbf41c7))
|
|
47
|
+
* add perawallet to wallet book ([#3868](https://github.com/dynamic-labs/DynamicAuth/issues/3868)) ([5f4e79d](https://github.com/dynamic-labs/DynamicAuth/commit/5f4e79df202b02088b15c5dfab7feee5789e9ece))
|
|
48
|
+
* add serialization to allow sending events callbacks and wallet connectors used by customers ([0077eb0](https://github.com/dynamic-labs/DynamicAuth/commit/0077eb0af05feb765d0c61911a48d5e98554760a))
|
|
49
|
+
* add support for dynamic domains for starknet signatures ([#3927](https://github.com/dynamic-labs/DynamicAuth/issues/3927)) ([52797ce](https://github.com/dynamic-labs/DynamicAuth/commit/52797ce867c956049bfa5021cf5b1c562e771a2e))
|
|
50
|
+
* add support for Pera Wallet ([#3866](https://github.com/dynamic-labs/DynamicAuth/issues/3866)) ([cb99ae7](https://github.com/dynamic-labs/DynamicAuth/commit/cb99ae77605d913932a77bf2ea565b7e7baf781a))
|
|
51
|
+
* add support for private starknet rpc providers ([#3881](https://github.com/dynamic-labs/DynamicAuth/issues/3881)) ([8fd5ef9](https://github.com/dynamic-labs/DynamicAuth/commit/8fd5ef902d48ef828b1cb89d0e462ea5b54f4e42))
|
|
52
|
+
* add zerodev to wallet book and render generic wallet icon ([#3822](https://github.com/dynamic-labs/DynamicAuth/issues/3822)) ([9c5768d](https://github.com/dynamic-labs/DynamicAuth/commit/9c5768d0fc1169c62927926c0e436b6a448d5656))
|
|
53
|
+
* allow updating evmNetworks in real time ([#3877](https://github.com/dynamic-labs/DynamicAuth/issues/3877)) ([b4a2521](https://github.com/dynamic-labs/DynamicAuth/commit/b4a2521830b859a129d70bad2ae1213db075550d))
|
|
54
|
+
* editable copies as typed data ([#3784](https://github.com/dynamic-labs/DynamicAuth/issues/3784)) ([d6c6d74](https://github.com/dynamic-labs/DynamicAuth/commit/d6c6d74e60c9c9d459414c452fbd780d3f6bc2f9))
|
|
55
|
+
* email inputs now use email keyboard ([#3843](https://github.com/dynamic-labs/DynamicAuth/issues/3843)) ([76926e2](https://github.com/dynamic-labs/DynamicAuth/commit/76926e26b6a188d9d8e3bba2512340610e218e9f))
|
|
56
|
+
* hide unlink if disabled in dashboard ([#3825](https://github.com/dynamic-labs/DynamicAuth/issues/3825)) ([a0625e6](https://github.com/dynamic-labs/DynamicAuth/commit/a0625e6fd01aa5b57e6b8542efe04e280e0c6830))
|
|
57
|
+
* initialize smart wallet from verified credentials ([#3790](https://github.com/dynamic-labs/DynamicAuth/issues/3790)) ([1fc5890](https://github.com/dynamic-labs/DynamicAuth/commit/1fc5890f2e0ef458bfb59d38d536c41d183bc2a2))
|
|
58
|
+
* set smart wallet as primary when owner is an embedded wallet ([#3898](https://github.com/dynamic-labs/DynamicAuth/issues/3898)) ([ec40172](https://github.com/dynamic-labs/DynamicAuth/commit/ec401729f38d946d5431bbbb15c5c1cdc66acb73))
|
|
59
|
+
* support forced network validation via DynamicContext setting ([#3879](https://github.com/dynamic-labs/DynamicAuth/issues/3879)) ([a7993b9](https://github.com/dynamic-labs/DynamicAuth/commit/a7993b9b6bdd739bcb4e66e46d14e7f8623bed66))
|
|
60
|
+
* **transaction:** add sponsored gas transaction ([#3869](https://github.com/dynamic-labs/DynamicAuth/issues/3869)) ([ccceb24](https://github.com/dynamic-labs/DynamicAuth/commit/ccceb2421e029dc60e53912e404b574324d6772f))
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
### Bug Fixes
|
|
64
|
+
|
|
65
|
+
* **account-abstraction:** set verified credentials before setting EOA to wallet connector ([#3941](https://github.com/dynamic-labs/DynamicAuth/issues/3941)) ([7475c46](https://github.com/dynamic-labs/DynamicAuth/commit/7475c465f5ddf9e27d0b05d23e58d9b474fa8fd4))
|
|
66
|
+
* add brand to zerodev object ([#3828](https://github.com/dynamic-labs/DynamicAuth/issues/3828)) ([81cb237](https://github.com/dynamic-labs/DynamicAuth/commit/81cb237df4def8e1c53b4ae145afafccf3b04683))
|
|
67
|
+
* add spriteId to zerodev ([#3829](https://github.com/dynamic-labs/DynamicAuth/issues/3829)) ([6b87c5c](https://github.com/dynamic-labs/DynamicAuth/commit/6b87c5c3d5869f6cd15a7534fb0260932845fbb1))
|
|
68
|
+
* allow metadata to be updated in updateUser hook ([#3928](https://github.com/dynamic-labs/DynamicAuth/issues/3928)) ([4f39fbd](https://github.com/dynamic-labs/DynamicAuth/commit/4f39fbd757b4e816dd60651252575c1f7e4d80aa))
|
|
69
|
+
* blocto flow connect only infinite recursion ([#3883](https://github.com/dynamic-labs/DynamicAuth/issues/3883)) ([6c6f5ba](https://github.com/dynamic-labs/DynamicAuth/commit/6c6f5ba5dc0657cc7ffdc82a4ea7935f65686088))
|
|
70
|
+
* clear project settings on page refresh ([#3826](https://github.com/dynamic-labs/DynamicAuth/issues/3826)) ([da5b8f0](https://github.com/dynamic-labs/DynamicAuth/commit/da5b8f0a99bf913ea11314954e5f08c2b019f50f))
|
|
71
|
+
* don't call computeConnectedStateForWallets too often to avoid infinite loops ([#3946](https://github.com/dynamic-labs/DynamicAuth/issues/3946)) ([de4e61a](https://github.com/dynamic-labs/DynamicAuth/commit/de4e61a3fcdc9c25cbe030c3c25cbc2c04929a93))
|
|
72
|
+
* don't call disconnect multiple times ([#3940](https://github.com/dynamic-labs/DynamicAuth/issues/3940)) ([3ea8623](https://github.com/dynamic-labs/DynamicAuth/commit/3ea86233d8d07dfb3c751a5fec45d5df84e9e143))
|
|
73
|
+
* **embedded wallet:** stop overriding primary wallet selection ([#3796](https://github.com/dynamic-labs/DynamicAuth/issues/3796)) ([75b81e7](https://github.com/dynamic-labs/DynamicAuth/commit/75b81e74d472ce8cc493646b441d2b4fe3962373))
|
|
74
|
+
* exodusevm wallet connect and mobile deep linking ([#3855](https://github.com/dynamic-labs/DynamicAuth/issues/3855)) ([cf0b3f0](https://github.com/dynamic-labs/DynamicAuth/commit/cf0b3f077f935eab32ce45947f62e73342d6c169))
|
|
75
|
+
* handle errors properly when engaging captcha ([#3896](https://github.com/dynamic-labs/DynamicAuth/issues/3896)) ([2596315](https://github.com/dynamic-labs/DynamicAuth/commit/25963153d699b26c6e04ea38b267446d3a3af13b))
|
|
76
|
+
* null safe check to window object ([#3882](https://github.com/dynamic-labs/DynamicAuth/issues/3882)) ([8856b5a](https://github.com/dynamic-labs/DynamicAuth/commit/8856b5ae40d43285eac667401387971b9e3f077d))
|
|
77
|
+
* pass correct wallet connector onLinkSuccess ([#3904](https://github.com/dynamic-labs/DynamicAuth/issues/3904)) ([79cca69](https://github.com/dynamic-labs/DynamicAuth/commit/79cca69ed53a5ef2c4e4d712ce0934e1a4c11459))
|
|
78
|
+
* remove extra captcha context provider instantiation causing unecessary rerenderings ([#3914](https://github.com/dynamic-labs/DynamicAuth/issues/3914)) ([14120a6](https://github.com/dynamic-labs/DynamicAuth/commit/14120a6ac0415f9a59608b376e88de6c729d4e5d))
|
|
79
|
+
* remove the coming soon label ([#3860](https://github.com/dynamic-labs/DynamicAuth/issues/3860)) ([1effb7f](https://github.com/dynamic-labs/DynamicAuth/commit/1effb7f124bda66aae3e8991b5386a1cee28fd99))
|
|
80
|
+
* Revert "chore: fix vite build ([#3849](https://github.com/dynamic-labs/DynamicAuth/issues/3849))" ([#3870](https://github.com/dynamic-labs/DynamicAuth/issues/3870)) ([13bc424](https://github.com/dynamic-labs/DynamicAuth/commit/13bc42483bcb9338babd46eae00988acada83578))
|
|
81
|
+
* **single-wallet:** prompt user to select correct wallet ([#3742](https://github.com/dynamic-labs/DynamicAuth/issues/3742)) ([ccfdd3c](https://github.com/dynamic-labs/DynamicAuth/commit/ccfdd3cc6a4ac7f3b1ea13be92e58982ecfb1c59))
|
|
82
|
+
* update walletconnect.json and walletconnect source schema ([#3854](https://github.com/dynamic-labs/DynamicAuth/issues/3854)) ([88ee546](https://github.com/dynamic-labs/DynamicAuth/commit/88ee5468db0130b19c6637a5632e64e0bb5197ba))
|
|
83
|
+
* useEmailProvider not checking for enabled providers properly ([7c16edc](https://github.com/dynamic-labs/DynamicAuth/commit/7c16edc3785ba10d69762b174f054b0d10b8a072))
|
|
84
|
+
* **wagmi:** ensure chain is defined on wallet client ([#3888](https://github.com/dynamic-labs/DynamicAuth/issues/3888)) ([0e145f6](https://github.com/dynamic-labs/DynamicAuth/commit/0e145f6ac42f55df7a020716d4ddc023554d72f9))
|
|
85
|
+
|
|
2
86
|
## [1.0.0-alpha.0](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0...v1.0.0-alpha.0) (2023-10-31)
|
|
3
87
|
|
|
4
88
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
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.
|
|
33
|
-
"@dynamic-labs/types": "1.0.0-alpha.
|
|
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;
|
package/src/errors/index.d.ts
CHANGED
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');
|
|
@@ -29,9 +30,8 @@ var last = require('./last.cjs');
|
|
|
29
30
|
var getProvidersFromWindow = require('./getProvidersFromWindow.cjs');
|
|
30
31
|
var sleep = require('./sleep/sleep.cjs');
|
|
31
32
|
var getOrMapViemChain = require('./getOrMapViemChain.cjs');
|
|
32
|
-
var bigIntToHex = require('./bigIntToHex/bigIntToHex.cjs');
|
|
33
|
-
var isBigInt = require('./isBigInt/isBigInt.cjs');
|
|
34
33
|
var retryableFn = require('./retryableFn.cjs');
|
|
34
|
+
var wrapMethodWithCallback = require('./wrapMethodWithCallback/wrapMethodWithCallback.cjs');
|
|
35
35
|
|
|
36
36
|
|
|
37
37
|
|
|
@@ -53,6 +53,7 @@ exports.MissingEnvironmentIdError = MissingEnvironmentIdError.MissingEnvironment
|
|
|
53
53
|
exports.GateBlockedError = GateBlockedError.GateBlockedError;
|
|
54
54
|
exports.UserHasAccountWithEmailError = UserHasAccountWithEmailError.UserHasAccountWithEmailError;
|
|
55
55
|
exports.SocialAccountAlreadyExistsError = SocialAccountAlreadyExistsError.SocialAccountAlreadyExistsError;
|
|
56
|
+
exports.TransactionGasCannotBeSponsoredError = TransactionGasCannotBeSponsoredError.TransactionGasCannotBeSponsoredError;
|
|
56
57
|
exports.CancellablePromise = CancellablePromise.CancellablePromise;
|
|
57
58
|
exports.isFunction = isFunction.isFunction;
|
|
58
59
|
exports.getAndroidVersion = isMobile.getAndroidVersion;
|
|
@@ -75,7 +76,6 @@ exports.sleep = sleep.sleep;
|
|
|
75
76
|
exports.getChain = getOrMapViemChain.getChain;
|
|
76
77
|
exports.getOrMapViemChain = getOrMapViemChain.getOrMapViemChain;
|
|
77
78
|
exports.mapChain = getOrMapViemChain.mapChain;
|
|
78
|
-
exports.bigIntToHex = bigIntToHex.bigIntToHex;
|
|
79
|
-
exports.isBigInt = isBigInt.isBigInt;
|
|
80
79
|
exports.FALLBACK_UNDEFINED = retryableFn.FALLBACK_UNDEFINED;
|
|
81
80
|
exports.retryableFn = retryableFn.retryableFn;
|
|
81
|
+
exports.wrapMethodWithCallback = wrapMethodWithCallback.wrapMethodWithCallback;
|
package/src/index.d.ts
CHANGED
|
@@ -10,6 +10,5 @@ export * from './last';
|
|
|
10
10
|
export * from './getProvidersFromWindow';
|
|
11
11
|
export * from './sleep';
|
|
12
12
|
export * from './getOrMapViemChain';
|
|
13
|
-
export * from './bigIntToHex';
|
|
14
|
-
export * from './isBigInt';
|
|
15
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';
|
|
@@ -25,6 +26,5 @@ export { last } from './last.js';
|
|
|
25
26
|
export { getProvidersFromWindow } from './getProvidersFromWindow.js';
|
|
26
27
|
export { sleep } from './sleep/sleep.js';
|
|
27
28
|
export { getChain, getOrMapViemChain, mapChain } from './getOrMapViemChain.js';
|
|
28
|
-
export { bigIntToHex } from './bigIntToHex/bigIntToHex.js';
|
|
29
|
-
export { isBigInt } from './isBigInt/isBigInt.js';
|
|
30
29
|
export { FALLBACK_UNDEFINED, retryableFn } from './retryableFn.js';
|
|
30
|
+
export { wrapMethodWithCallback } from './wrapMethodWithCallback/wrapMethodWithCallback.js';
|
package/src/isMobile.cjs
CHANGED
|
@@ -47,7 +47,9 @@ const isAndroid = () => isMobile() && !isIOS();
|
|
|
47
47
|
const isLegacySafari = () => {
|
|
48
48
|
// We need to check if window.CSS exists and if it has supports function.
|
|
49
49
|
// We can use it only in browsers. This prevents customer tests from failing because of that.
|
|
50
|
-
if (
|
|
50
|
+
if (typeof window === 'undefined' ||
|
|
51
|
+
!window.CSS ||
|
|
52
|
+
typeof window.CSS.supports !== 'function') {
|
|
51
53
|
return false;
|
|
52
54
|
}
|
|
53
55
|
// Older versions of Safari <15 are not supporting aspect-ratio css property.
|
|
@@ -62,7 +64,12 @@ const isSamsungBrowser = () => {
|
|
|
62
64
|
}
|
|
63
65
|
return navigator.userAgent.includes('SamsungBrowser');
|
|
64
66
|
};
|
|
65
|
-
const isWindows = () =>
|
|
67
|
+
const isWindows = () => {
|
|
68
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
return navigator.userAgent.indexOf('Windows') !== -1;
|
|
72
|
+
};
|
|
66
73
|
// regex from: https://github.com/matomo-org/device-detector/blob/master/regexes/device/mobiles.yml
|
|
67
74
|
const iPhoneLegacyRegex = [
|
|
68
75
|
{
|
|
@@ -115,6 +122,9 @@ const iPhoneLegacyRegex = [
|
|
|
115
122
|
},
|
|
116
123
|
];
|
|
117
124
|
const getAndroidVersion = () => {
|
|
125
|
+
if (typeof navigator === 'undefined') {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
118
128
|
const androidVersionMatch = navigator.userAgent.match(/Android (\d+(\.\d+)?)/);
|
|
119
129
|
if (!androidVersionMatch) {
|
|
120
130
|
return;
|
package/src/isMobile.js
CHANGED
|
@@ -43,7 +43,9 @@ const isAndroid = () => isMobile() && !isIOS();
|
|
|
43
43
|
const isLegacySafari = () => {
|
|
44
44
|
// We need to check if window.CSS exists and if it has supports function.
|
|
45
45
|
// We can use it only in browsers. This prevents customer tests from failing because of that.
|
|
46
|
-
if (
|
|
46
|
+
if (typeof window === 'undefined' ||
|
|
47
|
+
!window.CSS ||
|
|
48
|
+
typeof window.CSS.supports !== 'function') {
|
|
47
49
|
return false;
|
|
48
50
|
}
|
|
49
51
|
// Older versions of Safari <15 are not supporting aspect-ratio css property.
|
|
@@ -58,7 +60,12 @@ const isSamsungBrowser = () => {
|
|
|
58
60
|
}
|
|
59
61
|
return navigator.userAgent.includes('SamsungBrowser');
|
|
60
62
|
};
|
|
61
|
-
const isWindows = () =>
|
|
63
|
+
const isWindows = () => {
|
|
64
|
+
if (typeof window === 'undefined' || typeof navigator === 'undefined') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
return navigator.userAgent.indexOf('Windows') !== -1;
|
|
68
|
+
};
|
|
62
69
|
// regex from: https://github.com/matomo-org/device-detector/blob/master/regexes/device/mobiles.yml
|
|
63
70
|
const iPhoneLegacyRegex = [
|
|
64
71
|
{
|
|
@@ -111,6 +118,9 @@ const iPhoneLegacyRegex = [
|
|
|
111
118
|
},
|
|
112
119
|
];
|
|
113
120
|
const getAndroidVersion = () => {
|
|
121
|
+
if (typeof navigator === 'undefined') {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
114
124
|
const androidVersionMatch = navigator.userAgent.match(/Android (\d+(\.\d+)?)/);
|
|
115
125
|
if (!androidVersionMatch) {
|
|
116
126
|
return;
|
|
@@ -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 };
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const bigIntToHex = (value) => {
|
|
6
|
-
if (typeof value !== 'bigint') {
|
|
7
|
-
throw new TypeError('Input must be of type BigInt');
|
|
8
|
-
}
|
|
9
|
-
if (value < 0) {
|
|
10
|
-
throw new RangeError('Negative BigInt values are not supported');
|
|
11
|
-
}
|
|
12
|
-
return `0x${value.toString(16)}`;
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.bigIntToHex = bigIntToHex;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const bigIntToHex: (value: bigint) => `0x${string}`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
const bigIntToHex = (value) => {
|
|
2
|
-
if (typeof value !== 'bigint') {
|
|
3
|
-
throw new TypeError('Input must be of type BigInt');
|
|
4
|
-
}
|
|
5
|
-
if (value < 0) {
|
|
6
|
-
throw new RangeError('Negative BigInt values are not supported');
|
|
7
|
-
}
|
|
8
|
-
return `0x${value.toString(16)}`;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export { bigIntToHex };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { bigIntToHex } from './bigIntToHex';
|
package/src/isBigInt/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isBigInt } from './isBigInt';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isBigInt: (value: bigint | unknown) => value is bigint;
|
package/src/isBigInt/isBigInt.js
DELETED