@dynamic-labs/utils 3.0.0-alpha.4 → 3.0.0-alpha.41
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 +373 -0
- package/_virtual/_tslib.cjs +15 -0
- package/_virtual/_tslib.js +14 -1
- package/package.json +7 -8
- package/src/eip6963/eip6963Provider.cjs +40 -0
- package/src/eip6963/eip6963Provider.d.ts +34 -0
- package/src/eip6963/eip6963Provider.js +35 -0
- package/src/eip6963/index.d.ts +1 -0
- package/src/errors/ExternalAuthError.cjs +14 -0
- package/src/errors/ExternalAuthError.d.ts +4 -0
- package/src/errors/ExternalAuthError.js +10 -0
- package/src/errors/MfaInvalidOtpError.cjs +1 -1
- package/src/errors/MfaInvalidOtpError.js +1 -1
- package/src/errors/NoAccessError.cjs +3 -1
- package/src/errors/NoAccessError.d.ts +5 -1
- package/src/errors/NoAccessError.js +3 -1
- package/src/errors/SandboxMaximumThresholdReachedError.cjs +15 -0
- package/src/errors/SandboxMaximumThresholdReachedError.d.ts +5 -0
- package/src/errors/SandboxMaximumThresholdReachedError.js +11 -0
- package/src/errors/WalletAddressMismatchError.cjs +17 -0
- package/src/errors/WalletAddressMismatchError.d.ts +11 -0
- package/src/errors/WalletAddressMismatchError.js +13 -0
- package/src/errors/index.d.ts +3 -0
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.cjs +0 -7
- package/src/handleMobileWalletRedirect/handleMobileWalletRedirect.js +0 -7
- package/src/index.cjs +15 -4
- package/src/index.d.ts +3 -1
- package/src/index.js +7 -1
- package/src/nativeMobileOauthStateParam.cjs +13 -0
- package/src/nativeMobileOauthStateParam.d.ts +14 -0
- package/src/nativeMobileOauthStateParam.js +9 -0
- package/src/retryableFn.cjs +1 -6
- package/src/retryableFn.js +1 -6
- package/src/services/FetchService/FetchService.cjs +10 -5
- package/src/services/FetchService/FetchService.d.ts +2 -2
- package/src/services/FetchService/FetchService.js +10 -5
- package/src/services/Oauth2Service/Oauth2Service.cjs +38 -0
- package/src/services/Oauth2Service/Oauth2Service.d.ts +35 -0
- package/src/services/Oauth2Service/Oauth2Service.js +34 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.cjs +203 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.d.ts +2 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/createWindowOauth2Service.js +199 -0
- package/src/services/Oauth2Service/createWindowOauth2Service/index.d.ts +1 -0
- package/src/services/Oauth2Service/index.d.ts +2 -0
- package/src/services/PlatformService/PlatformService.cjs +13 -12
- package/src/services/PlatformService/PlatformService.d.ts +2 -3
- package/src/services/PlatformService/PlatformService.js +13 -12
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.cjs +0 -3
- package/src/services/PlatformService/createBrowserPlatformService/createBrowserPlatformService.js +0 -3
- package/src/services/PlatformService/types.d.ts +0 -4
- package/src/getOrMapViemChain.cjs +0 -77
- package/src/getOrMapViemChain.d.ts +0 -11
- package/src/getOrMapViemChain.js +0 -51
package/src/getOrMapViemChain.js
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import * as chains from 'viem/chains';
|
|
3
|
-
|
|
4
|
-
// eslint-disable-next-line import/no-namespace
|
|
5
|
-
/**
|
|
6
|
-
* Gets the chain object for the given chain id.
|
|
7
|
-
* @param chainId - Chain id of the target EVM chain.
|
|
8
|
-
* @returns Viem's chain object.
|
|
9
|
-
*/
|
|
10
|
-
const getChain = (chainId) => {
|
|
11
|
-
for (const chain of Object.values(chains)) {
|
|
12
|
-
if ('id' in chain) {
|
|
13
|
-
if (chain.id === chainId) {
|
|
14
|
-
return chain;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
throw new Error(`Chain with id ${chainId} not found`);
|
|
19
|
-
};
|
|
20
|
-
const mapChain = (network) => {
|
|
21
|
-
var _a;
|
|
22
|
-
return ({
|
|
23
|
-
blockExplorers: ((_a = network.blockExplorerUrls) === null || _a === void 0 ? void 0 : _a[0])
|
|
24
|
-
? {
|
|
25
|
-
default: {
|
|
26
|
-
name: network.blockExplorerUrls[0],
|
|
27
|
-
url: network.blockExplorerUrls[0],
|
|
28
|
-
},
|
|
29
|
-
}
|
|
30
|
-
: undefined,
|
|
31
|
-
id: network.chainId,
|
|
32
|
-
name: network.vanityName || network.name || network.chainName,
|
|
33
|
-
nativeCurrency: network.nativeCurrency,
|
|
34
|
-
rpcUrls: {
|
|
35
|
-
default: { http: network.rpcUrls },
|
|
36
|
-
public: { http: network.rpcUrls },
|
|
37
|
-
},
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
const getOrMapViemChain = (network) => {
|
|
41
|
-
let chain;
|
|
42
|
-
try {
|
|
43
|
-
chain = getChain(network.chainId);
|
|
44
|
-
}
|
|
45
|
-
catch (_a) {
|
|
46
|
-
chain = mapChain(network);
|
|
47
|
-
}
|
|
48
|
-
return chain;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export { getChain, getOrMapViemChain, mapChain };
|