@dynamic-labs/multi-wallet 0.17.0-RC.7 → 0.17.0-RC.9
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 +37 -0
- package/package.json +8 -14
- package/src/index.cjs +0 -57
- package/src/index.d.ts +0 -13
- package/src/index.js +1 -18
- package/src/multi-wallet.cjs +27 -87
- package/src/multi-wallet.d.ts +0 -1
- package/src/multi-wallet.js +25 -84
- package/src/types.d.ts +2 -23
- package/src/utils/getApiProviders.cjs +15 -0
- package/src/utils/getApiProviders.d.ts +10 -0
- package/src/utils/getApiProviders.js +11 -0
- package/src/utils/message.cjs +3 -4
- package/src/utils/message.js +1 -2
- package/src/wallets/algorand/MyAlgoWalletConnector.cjs +3 -3
- package/src/wallets/algorand/MyAlgoWalletConnector.js +1 -1
- package/src/wallets/constants.cjs +0 -2
- package/src/wallets/constants.js +1 -2
- package/src/wallets/cosmos/KeplrWalletConnect.cjs +16 -17
- package/src/wallets/cosmos/KeplrWalletConnect.d.ts +9 -5
- package/src/wallets/cosmos/KeplrWalletConnect.js +9 -10
- package/src/wallets/cosmos/KeplrWalletConnector.cjs +13 -5
- package/src/wallets/cosmos/KeplrWalletConnector.d.ts +6 -4
- package/src/wallets/cosmos/KeplrWalletConnector.js +13 -5
- package/src/wallets/cosmos/wcClient.lib.cjs +141 -0
- package/src/wallets/{clients/walletConnect/walletConnect.d.ts → cosmos/wcClient.lib.d.ts} +8 -11
- package/src/wallets/cosmos/wcClient.lib.js +126 -0
- package/src/wallets/flow/FlowWalletConnector.cjs +7 -8
- package/src/wallets/flow/FlowWalletConnector.js +2 -3
- package/src/wallets/flow/lilico.cjs +2 -2
- package/src/wallets/flow/lilico.js +1 -1
- package/src/wallets/solana/CoinbaseSolana.cjs +8 -11
- package/src/wallets/solana/CoinbaseSolana.d.ts +1 -3
- package/src/wallets/solana/CoinbaseSolana.js +8 -11
- package/src/wallets/solana/glow.cjs +8 -11
- package/src/wallets/solana/glow.d.ts +1 -3
- package/src/wallets/solana/glow.js +8 -11
- package/src/wallets/solana/injected/BraveSol.cjs +2 -1
- package/src/wallets/solana/injected/BraveSol.js +2 -1
- package/src/wallets/solana/phantom-ledger.cjs +5 -5
- package/src/wallets/solana/phantom-ledger.js +1 -1
- package/src/wallets/solana/phantom.cjs +11 -15
- package/src/wallets/solana/phantom.d.ts +1 -3
- package/src/wallets/solana/phantom.js +9 -13
- package/src/wallets/solana/slope.cjs +4 -4
- package/src/wallets/solana/slope.js +1 -1
- package/src/wallets/solana/solProviderHelper.cjs +49 -51
- package/src/wallets/solana/solProviderHelper.d.ts +20 -20
- package/src/wallets/solana/solProviderHelper.js +48 -50
- package/src/wallets/solana/solWalletConnector.cjs +2 -2
- package/src/wallets/solana/solWalletConnector.js +1 -1
- package/src/wallets/solana/solflare.cjs +6 -7
- package/src/wallets/solana/solflare.d.ts +0 -2
- package/src/wallets/solana/solflare.js +6 -7
- package/src/wallets/starknet/braavos.cjs +2 -2
- package/src/wallets/starknet/braavos.js +1 -1
- package/src/wallets/starknet/starknetWalletConnector.cjs +5 -6
- package/src/wallets/starknet/starknetWalletConnector.js +2 -3
- package/src/wallets/window.d.ts +10 -22
- package/src/errors.cjs +0 -66
- package/src/errors.d.ts +0 -34
- package/src/errors.js +0 -54
- package/src/utils/CancellablePromise/CancellablePromise.cjs +0 -33
- package/src/utils/CancellablePromise/CancellablePromise.d.ts +0 -9
- package/src/utils/CancellablePromise/CancellablePromise.js +0 -29
- package/src/utils/CancellablePromise/index.d.ts +0 -1
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs +0 -54
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +0 -3
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.js +0 -50
- package/src/utils/assignConfirmationScreenToProvider/index.d.ts +0 -1
- package/src/utils/encoding.cjs +0 -18
- package/src/utils/encoding.d.ts +0 -4
- package/src/utils/encoding.js +0 -12
- package/src/utils/findProvider/findProvider.cjs +0 -7
- package/src/utils/findProvider/findProvider.d.ts +0 -2
- package/src/utils/findProvider/findProvider.js +0 -3
- package/src/utils/findProvider/index.d.ts +0 -1
- package/src/utils/getChainInfo/getChainInfo.cjs +0 -59
- package/src/utils/getChainInfo/getChainInfo.d.ts +0 -2
- package/src/utils/getChainInfo/getChainInfo.js +0 -55
- package/src/utils/getChainInfo/index.d.ts +0 -1
- package/src/utils/getWalletConnectorByName.cjs +0 -19
- package/src/utils/getWalletConnectorByName.d.ts +0 -2
- package/src/utils/getWalletConnectorByName.js +0 -15
- package/src/utils/isEmailOTPWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.cjs +0 -7
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +0 -2
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.js +0 -3
- package/src/utils/isEmailWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.cjs +0 -7
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +0 -2
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.js +0 -3
- package/src/utils/isFunction/index.d.ts +0 -1
- package/src/utils/isFunction/isFunction.cjs +0 -8
- package/src/utils/isFunction/isFunction.d.ts +0 -1
- package/src/utils/isFunction/isFunction.js +0 -4
- package/src/utils/isMobile.cjs +0 -54
- package/src/utils/isMobile.d.ts +0 -13
- package/src/utils/isMobile.js +0 -46
- package/src/utils/isSameAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.cjs +0 -9
- package/src/utils/isSameAddress/isSameAddress.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.js +0 -5
- package/src/utils/isSameAddress/utils/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +0 -17
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +0 -13
- package/src/utils/isSocialWalletConnector/index.d.ts +0 -1
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.cjs +0 -7
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +0 -2
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.js +0 -3
- package/src/utils/isUnsupportedProviderError/index.d.ts +0 -1
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +0 -13
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +0 -6
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +0 -9
- package/src/utils/logger.cjs +0 -9
- package/src/utils/logger.d.ts +0 -2
- package/src/utils/logger.js +0 -5
- package/src/utils/normalizeWalletName/index.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.cjs +0 -7
- package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.js +0 -3
- package/src/utils/shouldLowercaseAddress.cjs +0 -11
- package/src/utils/shouldLowercaseAddress.d.ts +0 -1
- package/src/utils/shouldLowercaseAddress.js +0 -7
- package/src/utils/walletConnect.cjs +0 -31
- package/src/utils/walletConnect.d.ts +0 -5
- package/src/utils/walletConnect.js +0 -27
- package/src/wallets/ProviderLookup.cjs +0 -18
- package/src/wallets/ProviderLookup.d.ts +0 -4
- package/src/wallets/ProviderLookup.js +0 -14
- package/src/wallets/clients/coinbase/coinbase.cjs +0 -73
- package/src/wallets/clients/coinbase/coinbase.d.ts +0 -6
- package/src/wallets/clients/coinbase/coinbase.js +0 -66
- package/src/wallets/clients/coinbase/index.d.ts +0 -2
- package/src/wallets/clients/coinbase/types.d.ts +0 -14
- package/src/wallets/clients/walletConnect/index.d.ts +0 -1
- package/src/wallets/clients/walletConnect/types.d.ts +0 -4
- package/src/wallets/clients/walletConnect/walletConnect.cjs +0 -250
- package/src/wallets/clients/walletConnect/walletConnect.js +0 -233
- package/src/wallets/cosmos/getKeplrConnector.cjs +0 -18
- package/src/wallets/cosmos/getKeplrConnector.d.ts +0 -6
- package/src/wallets/cosmos/getKeplrConnector.js +0 -14
- package/src/wallets/ethereum/BloctoEvm.cjs +0 -111
- package/src/wallets/ethereum/BloctoEvm.d.ts +0 -22
- package/src/wallets/ethereum/BloctoEvm.js +0 -105
- package/src/wallets/ethereum/EthWalletConnector.cjs +0 -207
- package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -38
- package/src/wallets/ethereum/EthWalletConnector.js +0 -203
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -63
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -59
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +0 -62
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.d.ts +0 -11
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +0 -58
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +0 -103
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -33
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -99
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -56
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -52
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -177
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -54
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -173
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/index.d.ts +0 -5
- package/src/wallets/ethereum/coinbase.cjs +0 -66
- package/src/wallets/ethereum/coinbase.d.ts +0 -25
- package/src/wallets/ethereum/coinbase.js +0 -64
- package/src/wallets/ethereum/ethProviderHelper.cjs +0 -197
- package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -40
- package/src/wallets/ethereum/ethProviderHelper.js +0 -193
- package/src/wallets/ethereum/evm-network.cjs +0 -20
- package/src/wallets/ethereum/evm-network.d.ts +0 -6
- package/src/wallets/ethereum/evm-network.js +0 -16
- package/src/wallets/ethereum/fortmatic.cjs +0 -76
- package/src/wallets/ethereum/fortmatic.d.ts +0 -25
- package/src/wallets/ethereum/fortmatic.js +0 -70
- package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -13
- package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -6
- package/src/wallets/ethereum/injected/BloctoInjected.js +0 -11
- package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/BraveEvm.js +0 -11
- package/src/wallets/ethereum/injected/Dawn.cjs +0 -13
- package/src/wallets/ethereum/injected/Dawn.d.ts +0 -6
- package/src/wallets/ethereum/injected/Dawn.js +0 -11
- package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/ExodusEvm.js +0 -11
- package/src/wallets/ethereum/injected/Frame.cjs +0 -13
- package/src/wallets/ethereum/injected/Frame.d.ts +0 -6
- package/src/wallets/ethereum/injected/Frame.js +0 -11
- package/src/wallets/ethereum/injected/GameStop.cjs +0 -13
- package/src/wallets/ethereum/injected/GameStop.d.ts +0 -6
- package/src/wallets/ethereum/injected/GameStop.js +0 -11
- package/src/wallets/ethereum/injected/Opera.cjs +0 -13
- package/src/wallets/ethereum/injected/Opera.d.ts +0 -6
- package/src/wallets/ethereum/injected/Opera.js +0 -11
- package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -37
- package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -7
- package/src/wallets/ethereum/injected/PhantomEvm.js +0 -35
- package/src/wallets/ethereum/injected/Trust.cjs +0 -13
- package/src/wallets/ethereum/injected/Trust.d.ts +0 -6
- package/src/wallets/ethereum/injected/Trust.js +0 -11
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +0 -13
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -6
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -11
- package/src/wallets/ethereum/injected/Zerion.cjs +0 -13
- package/src/wallets/ethereum/injected/Zerion.d.ts +0 -6
- package/src/wallets/ethereum/injected/Zerion.js +0 -11
- package/src/wallets/ethereum/meta-mask.cjs +0 -63
- package/src/wallets/ethereum/meta-mask.d.ts +0 -26
- package/src/wallets/ethereum/meta-mask.js +0 -61
- package/src/wallets/getMobileOrInjectedWallet.cjs +0 -22
- package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -9
- package/src/wallets/getMobileOrInjectedWallet.js +0 -18
- package/src/wallets/getWalletConnectConnector.cjs +0 -16
- package/src/wallets/getWalletConnectConnector.d.ts +0 -5
- package/src/wallets/getWalletConnectConnector.js +0 -12
- package/src/wallets/walletConnect/index.d.ts +0 -2
- package/src/wallets/walletConnect/walletConnect.cjs +0 -133
- package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
- package/src/wallets/walletConnect/walletConnect.js +0 -127
- package/src/wallets/walletConnect/walletConnectV2.cjs +0 -268
- package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -38
- package/src/wallets/walletConnect/walletConnectV2.js +0 -262
- package/src/wallets/walletConnect/zerion.d.ts +0 -6
package/src/types.d.ts
CHANGED
|
@@ -1,39 +1,19 @@
|
|
|
1
|
-
import { ethers } from 'ethers';
|
|
2
|
-
import { OAuthProvider } from '@magic-ext/oauth';
|
|
3
1
|
import type { Provider } from '@dynamic-labs/sdk-api';
|
|
4
2
|
import { WalletConnector, Chain } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import { NetworkConfigurationMap } from '@dynamic-labs/types';
|
|
3
|
+
import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
|
|
6
4
|
import { ChainRpcProviders } from '@dynamic-labs/rpc-providers';
|
|
7
|
-
import { MagicLinkConfig } from './wallets/ethereum/MagicConnector';
|
|
8
|
-
export type VendorCredentials = {
|
|
9
|
-
fortmatic?: string;
|
|
10
|
-
};
|
|
11
5
|
export type GetSupportedWalletsOpts = {
|
|
12
6
|
appLogoUrl?: string;
|
|
13
7
|
appName?: string;
|
|
14
8
|
chainRpcProviders: typeof ChainRpcProviders;
|
|
9
|
+
customerApiProviders?: Provider[];
|
|
15
10
|
isWalletConnectV2Enabled?: boolean;
|
|
16
|
-
magicLinkConfig?: MagicLinkConfig;
|
|
17
11
|
networkConfigurations?: NetworkConfigurationMap;
|
|
18
|
-
providers?: Provider[];
|
|
19
12
|
skipMemo?: boolean;
|
|
20
|
-
vendorCredentials?: VendorCredentials;
|
|
21
13
|
walletConnectProjectId?: string;
|
|
22
14
|
walletUiUtils?: WalletUiUtils;
|
|
23
15
|
};
|
|
24
16
|
export type GetSupportedWallets = (opts: GetSupportedWalletsOpts) => Promise<WalletConnector[]>;
|
|
25
|
-
export type WalletUiUtils = {
|
|
26
|
-
enableInternalSign: () => void;
|
|
27
|
-
sendTransaction: (props: {
|
|
28
|
-
handler: (transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>) => Promise<ethers.providers.TransactionResponse>;
|
|
29
|
-
provider: ethers.providers.Web3Provider;
|
|
30
|
-
transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
|
|
31
|
-
}) => Promise<ethers.providers.TransactionResponse>;
|
|
32
|
-
signMessage: (props: {
|
|
33
|
-
handler: (message: string | ethers.utils.Bytes) => Promise<string>;
|
|
34
|
-
message: string | ethers.utils.Bytes;
|
|
35
|
-
}) => Promise<string>;
|
|
36
|
-
};
|
|
37
17
|
export type ChainInfo = {
|
|
38
18
|
blockchainName: string;
|
|
39
19
|
displayName: string;
|
|
@@ -44,4 +24,3 @@ export type ChainWihtIcon = {
|
|
|
44
24
|
icon?: string;
|
|
45
25
|
name: string | undefined;
|
|
46
26
|
};
|
|
47
|
-
export type SocialOAuthProvider = OAuthProvider;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var sdkApi = require('@dynamic-labs/sdk-api');
|
|
6
|
+
|
|
7
|
+
const getApiProviders = (providers) => Object.values(sdkApi.ProviderEnum).reduce((acc, provider) => {
|
|
8
|
+
const foundProvider = providers.find((providerSetting) => providerSetting.provider === provider);
|
|
9
|
+
if (foundProvider) {
|
|
10
|
+
acc[provider] = foundProvider;
|
|
11
|
+
}
|
|
12
|
+
return acc;
|
|
13
|
+
}, {});
|
|
14
|
+
|
|
15
|
+
exports.getApiProviders = getApiProviders;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Provider, ProviderEnum } from '@dynamic-labs/sdk-api';
|
|
2
|
+
export declare const getApiProviders: (providers: Provider[]) => {
|
|
3
|
+
emailOnly?: Provider | undefined;
|
|
4
|
+
magicLink?: Provider | undefined;
|
|
5
|
+
google?: Provider | undefined;
|
|
6
|
+
facebook?: Provider | undefined;
|
|
7
|
+
twitter?: Provider | undefined;
|
|
8
|
+
discord?: Provider | undefined;
|
|
9
|
+
github?: Provider | undefined;
|
|
10
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ProviderEnum } from '@dynamic-labs/sdk-api';
|
|
2
|
+
|
|
3
|
+
const getApiProviders = (providers) => Object.values(ProviderEnum).reduce((acc, provider) => {
|
|
4
|
+
const foundProvider = providers.find((providerSetting) => providerSetting.provider === provider);
|
|
5
|
+
if (foundProvider) {
|
|
6
|
+
acc[provider] = foundProvider;
|
|
7
|
+
}
|
|
8
|
+
return acc;
|
|
9
|
+
}, {});
|
|
10
|
+
|
|
11
|
+
export { getApiProviders };
|
package/src/utils/message.cjs
CHANGED
|
@@ -3,15 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var utils = require('ethers/lib/utils');
|
|
6
|
-
var
|
|
7
|
-
var getChainInfo = require('./getChainInfo/getChainInfo.cjs');
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
7
|
|
|
9
8
|
const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
|
|
10
9
|
var _a, _b;
|
|
11
10
|
if (blockchain === 'STARK') {
|
|
12
11
|
return nonce;
|
|
13
12
|
}
|
|
14
|
-
const blockchainName = (_b = (_a =
|
|
13
|
+
const blockchainName = (_b = (_a = walletConnectorCore.getChainInfo(blockchain)) === null || _a === void 0 ? void 0 : _a.blockchainName) !== null && _b !== void 0 ? _b : 'Ethereum';
|
|
15
14
|
// This format follows the sign-in with ethereum (SIWE) standard,
|
|
16
15
|
// but we are using it also for non-ethereum wallets for now (eg. Solana)
|
|
17
16
|
// for more context on format and fields, please see:
|
|
@@ -48,7 +47,7 @@ const getEip55Address = (publicKey, chainId) => {
|
|
|
48
47
|
}
|
|
49
48
|
}
|
|
50
49
|
catch (err) {
|
|
51
|
-
|
|
50
|
+
walletConnectorCore.logger.debug(`Error getting checksum, returning default ${publicKey}`);
|
|
52
51
|
}
|
|
53
52
|
return publicKey;
|
|
54
53
|
};
|
package/src/utils/message.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { getAddress } from 'ethers/lib/utils.js';
|
|
2
|
-
import { logger } from '
|
|
3
|
-
import { getChainInfo } from './getChainInfo/getChainInfo.js';
|
|
2
|
+
import { getChainInfo, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
3
|
|
|
5
4
|
const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
|
|
6
5
|
var _a, _b;
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var MyAlgoConnect = require('@randlabs/myalgo-connect');
|
|
5
5
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
6
|
-
var
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
7
|
var localStorageAsync = require('../../utils/localStorageAsync.cjs');
|
|
8
8
|
var myalgoSigner = require('./myalgoSigner.cjs');
|
|
9
9
|
|
|
@@ -96,7 +96,7 @@ class MyAlgoWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
96
96
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
97
97
|
const address = yield this.fetchPublicAddress();
|
|
98
98
|
if (!address)
|
|
99
|
-
throw new
|
|
99
|
+
throw new utils.DynamicError('MyAlgo Wallet Connector - Not connected!');
|
|
100
100
|
return new myalgoSigner.MyAlgoSigner(address, this.getClient());
|
|
101
101
|
});
|
|
102
102
|
}
|
|
@@ -111,7 +111,7 @@ class MyAlgoWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
111
111
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
112
112
|
const address = yield this.fetchPublicAddress();
|
|
113
113
|
if (!address)
|
|
114
|
-
throw new
|
|
114
|
+
throw new utils.DynamicError('getBalance - Not connected!');
|
|
115
115
|
const response = yield fetch(`https://indexer.algoexplorerapi.io/v2/accounts/${address}`);
|
|
116
116
|
if (!response.ok) {
|
|
117
117
|
// if the request fails due to rate limits, return cached value
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import MyAlgoConnect from '@randlabs/myalgo-connect';
|
|
3
3
|
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { DynamicError } from '
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
5
5
|
import { getItemAsync, setItemAsync, removeItemAsync } from '../../utils/localStorageAsync.js';
|
|
6
6
|
import { MyAlgoSigner } from './myalgoSigner.js';
|
|
7
7
|
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const infuraId = '87939db78f824920ada5c872db3e56b8';
|
|
6
5
|
const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
|
|
7
6
|
const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
8
7
|
domain: {
|
|
@@ -13,4 +12,3 @@ const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
|
13
12
|
|
|
14
13
|
exports.DEFAULT_STARKNET_TYPED_DATA_DOMAIN = DEFAULT_STARKNET_TYPED_DATA_DOMAIN;
|
|
15
14
|
exports.ETH_STARKNET_ADDRESS = ETH_STARKNET_ADDRESS;
|
|
16
|
-
exports.infuraId = infuraId;
|
package/src/wallets/constants.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const infuraId = '87939db78f824920ada5c872db3e56b8';
|
|
2
1
|
const ETH_STARKNET_ADDRESS = '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7';
|
|
3
2
|
const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
4
3
|
domain: {
|
|
@@ -7,4 +6,4 @@ const DEFAULT_STARKNET_TYPED_DATA_DOMAIN = {
|
|
|
7
6
|
},
|
|
8
7
|
};
|
|
9
8
|
|
|
10
|
-
export { DEFAULT_STARKNET_TYPED_DATA_DOMAIN, ETH_STARKNET_ADDRESS
|
|
9
|
+
export { DEFAULT_STARKNET_TYPED_DATA_DOMAIN, ETH_STARKNET_ADDRESS };
|
|
@@ -4,15 +4,13 @@ var tslib = require('tslib');
|
|
|
4
4
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
5
5
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
6
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
|
-
var walletConnect = require('../clients/walletConnect/walletConnect.cjs');
|
|
8
|
-
var isMobile = require('../../utils/isMobile.cjs');
|
|
9
|
-
var logger = require('../../utils/logger.cjs');
|
|
10
7
|
var wcClient = require('./wcClient.cjs');
|
|
8
|
+
var wcClient_lib = require('./wcClient.lib.cjs');
|
|
11
9
|
|
|
12
10
|
const DYNAMIC_KEPLR_NETWORK_ID = 'dynamic_keplr_wc_network_id';
|
|
13
11
|
class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
14
|
-
constructor(
|
|
15
|
-
super();
|
|
12
|
+
constructor(props) {
|
|
13
|
+
super(props);
|
|
16
14
|
this.name = 'Keplr';
|
|
17
15
|
this.isWalletConnect = true;
|
|
18
16
|
this.canConnectViaQrCode = true;
|
|
@@ -29,14 +27,15 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
29
27
|
};
|
|
30
28
|
this.supportedChains = ['COSMOS'];
|
|
31
29
|
this.connectedChain = 'COSMOS';
|
|
32
|
-
this.evmNetworks = utils.parseEvmNetworks(
|
|
30
|
+
this.evmNetworks = utils.parseEvmNetworks(props.cosmosNetworks);
|
|
33
31
|
const persistedNetworkId = localStorage.getItem(DYNAMIC_KEPLR_NETWORK_ID);
|
|
34
32
|
if (persistedNetworkId) {
|
|
35
33
|
this.selectedNetworkId = Number(persistedNetworkId);
|
|
36
34
|
}
|
|
37
35
|
else {
|
|
38
36
|
this.selectedNetworkId =
|
|
39
|
-
(evmNetworks[0] && utils.parseChainId(evmNetworks[0].chainId)) ||
|
|
37
|
+
(this.evmNetworks[0] && utils.parseChainId(this.evmNetworks[0].chainId)) ||
|
|
38
|
+
401;
|
|
40
39
|
}
|
|
41
40
|
}
|
|
42
41
|
get evmNetwork() {
|
|
@@ -71,7 +70,7 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
71
70
|
if (this.client) {
|
|
72
71
|
return this.client;
|
|
73
72
|
}
|
|
74
|
-
this.client =
|
|
73
|
+
this.client = wcClient_lib.initClient(this.key, this.clientOptions);
|
|
75
74
|
return this.client;
|
|
76
75
|
}
|
|
77
76
|
getNetwork() {
|
|
@@ -88,7 +87,7 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
88
87
|
localStorage.setItem(DYNAMIC_KEPLR_NETWORK_ID, networkChainId.toString());
|
|
89
88
|
}
|
|
90
89
|
catch (e) {
|
|
91
|
-
|
|
90
|
+
walletConnectorCore.logger.error(e);
|
|
92
91
|
}
|
|
93
92
|
});
|
|
94
93
|
}
|
|
@@ -116,7 +115,7 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
116
115
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
117
116
|
const client = this.getClient();
|
|
118
117
|
const keplr = this.getProvider();
|
|
119
|
-
return
|
|
118
|
+
return wcClient_lib.fetchWalletConnectCosmosPublicAddress(walletBook.getWalletBookWallet(this.name), client, keplr, Object.assign(Object.assign({}, opts), { chainId: this.chainId, onConnect: (payload) => {
|
|
120
119
|
var _a;
|
|
121
120
|
payload.params[0].chainId = this.selectedNetworkId;
|
|
122
121
|
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
@@ -139,14 +138,14 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
139
138
|
return balance.toString();
|
|
140
139
|
}
|
|
141
140
|
catch (e) {
|
|
142
|
-
|
|
141
|
+
walletConnectorCore.logger.error(e);
|
|
143
142
|
return '0';
|
|
144
143
|
}
|
|
145
144
|
});
|
|
146
145
|
}
|
|
147
146
|
endSession() {
|
|
148
147
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
149
|
-
|
|
148
|
+
wcClient_lib.killWalletConnectSession(this.getClient());
|
|
150
149
|
});
|
|
151
150
|
}
|
|
152
151
|
getConnectedAccounts() {
|
|
@@ -160,11 +159,11 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
160
159
|
getDeepLink() {
|
|
161
160
|
var _a;
|
|
162
161
|
const wallet = walletBook.getWalletBookWallet(this.name);
|
|
163
|
-
if (!
|
|
162
|
+
if (!utils.isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
|
|
164
163
|
return undefined;
|
|
165
164
|
}
|
|
166
|
-
return
|
|
167
|
-
removeWCUri:
|
|
165
|
+
return wcClient_lib.getDeepLink(this.getClient().uri, wallet, {
|
|
166
|
+
removeWCUri: utils.isIOS() && this.key === 'cryptocom',
|
|
168
167
|
});
|
|
169
168
|
}
|
|
170
169
|
getRpcProvider() {
|
|
@@ -180,14 +179,14 @@ class KeplrWalletConnect extends walletConnectorCore.WalletConnectorBase {
|
|
|
180
179
|
return this.getProvider();
|
|
181
180
|
}
|
|
182
181
|
setupEventListeners(listeners) {
|
|
183
|
-
|
|
182
|
+
wcClient_lib.setupWalletConnectEventListeners({
|
|
184
183
|
onAccountChange: listeners.onAccountChange,
|
|
185
184
|
onChainChange: listeners.onChainChange,
|
|
186
185
|
onDisconnect: listeners.onDisconnect,
|
|
187
186
|
}, this.getClient());
|
|
188
187
|
}
|
|
189
188
|
teardownEventListeners() {
|
|
190
|
-
|
|
189
|
+
wcClient_lib.teardownWalletConnectEventListeners(this.getClient());
|
|
191
190
|
}
|
|
192
191
|
supportsNetworkSwitching() {
|
|
193
192
|
return true;
|
|
@@ -2,12 +2,16 @@ import Client from '@walletconnect/client';
|
|
|
2
2
|
import { OfflineAminoSigner } from '@keplr-wallet/types';
|
|
3
3
|
import { Chain, FetchPublicAddressOpts, WalletConnectorBase, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import { EvmNetwork, GenericNetwork } from '@dynamic-labs/types';
|
|
5
|
-
import { SwitchNetworkOps } from '../ethereum/EthWalletConnector';
|
|
6
5
|
import { KeplrWalletConnectV1 } from './wcClient';
|
|
6
|
+
export type KeplrWalletConnectProps = {
|
|
7
|
+
cosmosNetworks: GenericNetwork[];
|
|
8
|
+
};
|
|
9
|
+
export type SwitchNetworkOps = {
|
|
10
|
+
networkChainId?: number;
|
|
11
|
+
networkName?: string;
|
|
12
|
+
};
|
|
7
13
|
declare class KeplrWalletConnect extends WalletConnectorBase {
|
|
8
|
-
constructor(
|
|
9
|
-
evmNetworks: GenericNetwork[];
|
|
10
|
-
});
|
|
14
|
+
constructor(props: KeplrWalletConnectProps);
|
|
11
15
|
name: string;
|
|
12
16
|
isWalletConnect: boolean;
|
|
13
17
|
canConnectViaQrCode: boolean;
|
|
@@ -39,7 +43,7 @@ declare class KeplrWalletConnect extends WalletConnectorBase {
|
|
|
39
43
|
getRpcProvider(): Promise<unknown>;
|
|
40
44
|
getSigner(): Promise<OfflineAminoSigner | undefined>;
|
|
41
45
|
getWeb3Provider(): KeplrWalletConnectV1 | undefined;
|
|
42
|
-
setupEventListeners(listeners: WalletEventListeners):
|
|
46
|
+
setupEventListeners(listeners: WalletEventListeners): void;
|
|
43
47
|
teardownEventListeners(): void;
|
|
44
48
|
supportsNetworkSwitching(): boolean;
|
|
45
49
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
-
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
|
-
import { parseEvmNetworks, parseChainId } from '@dynamic-labs/utils';
|
|
5
|
-
import { initClient, fetchWalletConnectCosmosPublicAddress, killWalletConnectSession, getDeepLink, setupWalletConnectEventListeners, teardownWalletConnectEventListeners } from '../clients/walletConnect/walletConnect.js';
|
|
6
|
-
import { isMobile, isIOS } from '../../utils/isMobile.js';
|
|
7
|
-
import { logger } from '../../utils/logger.js';
|
|
4
|
+
import { parseEvmNetworks, parseChainId, isMobile, isIOS } from '@dynamic-labs/utils';
|
|
8
5
|
import { KeplrWalletConnectV1 } from './wcClient.js';
|
|
6
|
+
import { initClient, fetchWalletConnectCosmosPublicAddress, killWalletConnectSession, getDeepLink, setupWalletConnectEventListeners, teardownWalletConnectEventListeners } from './wcClient.lib.js';
|
|
9
7
|
|
|
10
8
|
const DYNAMIC_KEPLR_NETWORK_ID = 'dynamic_keplr_wc_network_id';
|
|
11
9
|
class KeplrWalletConnect extends WalletConnectorBase {
|
|
12
|
-
constructor(
|
|
13
|
-
super();
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(props);
|
|
14
12
|
this.name = 'Keplr';
|
|
15
13
|
this.isWalletConnect = true;
|
|
16
14
|
this.canConnectViaQrCode = true;
|
|
@@ -27,14 +25,15 @@ class KeplrWalletConnect extends WalletConnectorBase {
|
|
|
27
25
|
};
|
|
28
26
|
this.supportedChains = ['COSMOS'];
|
|
29
27
|
this.connectedChain = 'COSMOS';
|
|
30
|
-
this.evmNetworks = parseEvmNetworks(
|
|
28
|
+
this.evmNetworks = parseEvmNetworks(props.cosmosNetworks);
|
|
31
29
|
const persistedNetworkId = localStorage.getItem(DYNAMIC_KEPLR_NETWORK_ID);
|
|
32
30
|
if (persistedNetworkId) {
|
|
33
31
|
this.selectedNetworkId = Number(persistedNetworkId);
|
|
34
32
|
}
|
|
35
33
|
else {
|
|
36
34
|
this.selectedNetworkId =
|
|
37
|
-
(evmNetworks[0] && parseChainId(evmNetworks[0].chainId)) ||
|
|
35
|
+
(this.evmNetworks[0] && parseChainId(this.evmNetworks[0].chainId)) ||
|
|
36
|
+
401;
|
|
38
37
|
}
|
|
39
38
|
}
|
|
40
39
|
get evmNetwork() {
|
|
@@ -178,7 +177,7 @@ class KeplrWalletConnect extends WalletConnectorBase {
|
|
|
178
177
|
return this.getProvider();
|
|
179
178
|
}
|
|
180
179
|
setupEventListeners(listeners) {
|
|
181
|
-
|
|
180
|
+
setupWalletConnectEventListeners({
|
|
182
181
|
onAccountChange: listeners.onAccountChange,
|
|
183
182
|
onChainChange: listeners.onChainChange,
|
|
184
183
|
onDisconnect: listeners.onDisconnect,
|
|
@@ -5,12 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var
|
|
8
|
+
var KeplrWalletConnect = require('./KeplrWalletConnect.cjs');
|
|
9
9
|
|
|
10
10
|
const DYNAMIC_KEPLR_NETWORK_ID = 'dynamic_keplr_network_id';
|
|
11
11
|
class KeplrWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
getMobileOrInstalledWallet() {
|
|
13
|
+
if (this.isInstalledOnBrowser()) {
|
|
14
|
+
return this;
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
return new KeplrWalletConnect(this.constructorProps);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
14
22
|
this.switchNetworkOnlyFromWallet = true;
|
|
15
23
|
this._selectedNetworkId = 401;
|
|
16
24
|
this.name = 'Keplr';
|
|
@@ -21,7 +29,7 @@ class KeplrWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
21
29
|
402: 'axelar-dojo-1',
|
|
22
30
|
403: 'osmosis-1',
|
|
23
31
|
};
|
|
24
|
-
this.evmNetworks = utils.parseEvmNetworks(
|
|
32
|
+
this.evmNetworks = utils.parseEvmNetworks(props.cosmosNetworks);
|
|
25
33
|
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
26
34
|
const persistedNetworkId = localStorage.getItem(DYNAMIC_KEPLR_NETWORK_ID);
|
|
27
35
|
if (persistedNetworkId) {
|
|
@@ -182,7 +190,7 @@ class KeplrWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
182
190
|
return balance.toString();
|
|
183
191
|
}
|
|
184
192
|
catch (e) {
|
|
185
|
-
|
|
193
|
+
walletConnectorCore.logger.error(e);
|
|
186
194
|
return '0';
|
|
187
195
|
}
|
|
188
196
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Keplr as KeplrWallet } from '@keplr-wallet/types';
|
|
2
2
|
import { Chain, WalletConnectorBase, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { EvmNetwork, GenericNetwork } from '@dynamic-labs/types';
|
|
4
|
-
import { SwitchNetworkOps } from '
|
|
4
|
+
import KeplrWalletConnect, { SwitchNetworkOps } from './KeplrWalletConnect';
|
|
5
5
|
export interface IFetchBalanceResponse {
|
|
6
6
|
balances: IFetchBalanceBalance[];
|
|
7
7
|
pagination: IFetchBalancePagination;
|
|
@@ -14,6 +14,9 @@ export interface IFetchBalancePagination {
|
|
|
14
14
|
next_key: any;
|
|
15
15
|
total: string;
|
|
16
16
|
}
|
|
17
|
+
export type KeplrWalletConnectorProps = {
|
|
18
|
+
cosmosNetworks: GenericNetwork[];
|
|
19
|
+
};
|
|
17
20
|
export declare class KeplrWalletConnector extends WalletConnectorBase {
|
|
18
21
|
evmNetworks: EvmNetwork[];
|
|
19
22
|
switchNetworkOnlyFromWallet: boolean;
|
|
@@ -22,9 +25,8 @@ export declare class KeplrWalletConnector extends WalletConnectorBase {
|
|
|
22
25
|
connectedChain: Chain;
|
|
23
26
|
supportedChains: Chain[];
|
|
24
27
|
chainIdMap: Record<number, string>;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
});
|
|
28
|
+
getMobileOrInstalledWallet(): this | KeplrWalletConnect;
|
|
29
|
+
constructor(props: KeplrWalletConnectorProps);
|
|
28
30
|
get selectedNetworkId(): number;
|
|
29
31
|
set selectedNetworkId(networkId: number);
|
|
30
32
|
getWeb3Provider(): KeplrWallet;
|
|
@@ -1,12 +1,20 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
|
-
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
2
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { parseEvmNetworks, parseChainId } from '@dynamic-labs/utils';
|
|
4
|
-
import
|
|
4
|
+
import KeplrWalletConnect from './KeplrWalletConnect.js';
|
|
5
5
|
|
|
6
6
|
const DYNAMIC_KEPLR_NETWORK_ID = 'dynamic_keplr_network_id';
|
|
7
7
|
class KeplrWalletConnector extends WalletConnectorBase {
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
getMobileOrInstalledWallet() {
|
|
9
|
+
if (this.isInstalledOnBrowser()) {
|
|
10
|
+
return this;
|
|
11
|
+
}
|
|
12
|
+
else {
|
|
13
|
+
return new KeplrWalletConnect(this.constructorProps);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
constructor(props) {
|
|
17
|
+
super(props);
|
|
10
18
|
this.switchNetworkOnlyFromWallet = true;
|
|
11
19
|
this._selectedNetworkId = 401;
|
|
12
20
|
this.name = 'Keplr';
|
|
@@ -17,7 +25,7 @@ class KeplrWalletConnector extends WalletConnectorBase {
|
|
|
17
25
|
402: 'axelar-dojo-1',
|
|
18
26
|
403: 'osmosis-1',
|
|
19
27
|
};
|
|
20
|
-
this.evmNetworks = parseEvmNetworks(
|
|
28
|
+
this.evmNetworks = parseEvmNetworks(props.cosmosNetworks);
|
|
21
29
|
this._handleAccountChange = this._handleAccountChange.bind(this);
|
|
22
30
|
const persistedNetworkId = localStorage.getItem(DYNAMIC_KEPLR_NETWORK_ID);
|
|
23
31
|
if (persistedNetworkId) {
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib = require('tslib');
|
|
6
|
+
var Client = require('@walletconnect/client');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
|
|
10
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
11
|
+
|
|
12
|
+
var Client__default = /*#__PURE__*/_interopDefaultLegacy(Client);
|
|
13
|
+
|
|
14
|
+
const initClient = (name, settings) => {
|
|
15
|
+
const storageId = `walletconnect-${name}`;
|
|
16
|
+
const session = localStorage.getItem(storageId);
|
|
17
|
+
const clientArgs = session
|
|
18
|
+
? { session: JSON.parse(session), storageId }
|
|
19
|
+
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
20
|
+
return new Client__default["default"](Object.assign(Object.assign({}, clientArgs), settings));
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Initialize a client from a stored session and terminate the connection.
|
|
24
|
+
*/
|
|
25
|
+
const killWalletConnectSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
26
|
+
try {
|
|
27
|
+
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
28
|
+
yield client.killSession();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
walletConnectorCore.logger.debug(e);
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Attach event handlers to WalletConnect events.
|
|
37
|
+
*/
|
|
38
|
+
const setupWalletConnectEventListeners = (opts, client) => {
|
|
39
|
+
if (!client) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
let prevAccount;
|
|
43
|
+
let prevChain;
|
|
44
|
+
if (client.connected) {
|
|
45
|
+
// eslint-disable-next-line prefer-destructuring
|
|
46
|
+
prevAccount = client.accounts[0];
|
|
47
|
+
prevChain = client.chainId;
|
|
48
|
+
}
|
|
49
|
+
client.on('disconnect', () => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
50
|
+
var _a;
|
|
51
|
+
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
52
|
+
}));
|
|
53
|
+
client.on('session_update', (_, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
var _b, _c;
|
|
55
|
+
// eslint-disable-next-line prefer-destructuring
|
|
56
|
+
const { accounts, chainId } = payload.params[0];
|
|
57
|
+
const didAccountChange = !walletConnectorCore.isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
58
|
+
const didChainChange = prevChain !== chainId;
|
|
59
|
+
// eslint-disable-next-line prefer-destructuring
|
|
60
|
+
prevAccount = accounts[0];
|
|
61
|
+
prevChain = chainId;
|
|
62
|
+
if (didAccountChange) {
|
|
63
|
+
yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
|
|
64
|
+
}
|
|
65
|
+
if (didChainChange) {
|
|
66
|
+
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
67
|
+
}
|
|
68
|
+
}));
|
|
69
|
+
};
|
|
70
|
+
const teardownWalletConnectEventListeners = (client) => {
|
|
71
|
+
client.off('disconnect');
|
|
72
|
+
client.off('session_update');
|
|
73
|
+
};
|
|
74
|
+
const useDeepLink = (metadata, wcClient, opts) => {
|
|
75
|
+
var _a, _b, _c;
|
|
76
|
+
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
77
|
+
if (utils.isMobile()) {
|
|
78
|
+
window.location.href = deepLink;
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
82
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
83
|
+
}
|
|
84
|
+
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
88
|
+
var _a, _b, _c, _d;
|
|
89
|
+
if (!utils.isMobile()) {
|
|
90
|
+
const origin = ((_a = metadata.desktop) === null || _a === void 0 ? void 0 : _a.universal) || ((_b = metadata.desktop) === null || _b === void 0 ? void 0 : _b.native);
|
|
91
|
+
if (removeWCUri)
|
|
92
|
+
return origin || '';
|
|
93
|
+
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
94
|
+
}
|
|
95
|
+
// deeplinks for ios require special treatment
|
|
96
|
+
// see: https://docs.walletconnect.com/mobile-linking#for-ios
|
|
97
|
+
else if (utils.isIOS()) {
|
|
98
|
+
const origin = ((_c = metadata.mobile) === null || _c === void 0 ? void 0 : _c.universal) || ((_d = metadata.mobile) === null || _d === void 0 ? void 0 : _d.native);
|
|
99
|
+
if (removeWCUri)
|
|
100
|
+
return origin || '';
|
|
101
|
+
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
102
|
+
}
|
|
103
|
+
// on android, the deeplink is simply the uri
|
|
104
|
+
// see: https://docs.walletconnect.com/mobile-linking#for-android
|
|
105
|
+
return uri;
|
|
106
|
+
};
|
|
107
|
+
const createSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
108
|
+
return new Promise((resolve, reject) => {
|
|
109
|
+
client.on('connect', (error, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
110
|
+
if (error)
|
|
111
|
+
throw error;
|
|
112
|
+
resolve(payload);
|
|
113
|
+
}));
|
|
114
|
+
client.on('disconnect', (error, payload) => {
|
|
115
|
+
reject(error || payload.params[0].message);
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
120
|
+
var _a;
|
|
121
|
+
if (wcClient.connected) {
|
|
122
|
+
const key = yield provider.getKey(opts.chainId);
|
|
123
|
+
return key.bech32Address;
|
|
124
|
+
}
|
|
125
|
+
yield wcClient.createSession();
|
|
126
|
+
useDeepLink(metadata, wcClient, opts);
|
|
127
|
+
const payload = yield createSession(wcClient);
|
|
128
|
+
const key = yield provider.getKey(opts.chainId);
|
|
129
|
+
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
130
|
+
wcClient.accounts = [key.bech32Address];
|
|
131
|
+
return key.bech32Address;
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
exports.createSession = createSession;
|
|
135
|
+
exports.fetchWalletConnectCosmosPublicAddress = fetchWalletConnectCosmosPublicAddress;
|
|
136
|
+
exports.getDeepLink = getDeepLink;
|
|
137
|
+
exports.initClient = initClient;
|
|
138
|
+
exports.killWalletConnectSession = killWalletConnectSession;
|
|
139
|
+
exports.setupWalletConnectEventListeners = setupWalletConnectEventListeners;
|
|
140
|
+
exports.teardownWalletConnectEventListeners = teardownWalletConnectEventListeners;
|
|
141
|
+
exports.useDeepLink = useDeepLink;
|