@dynamic-labs/multi-wallet 0.17.0-RC.6 → 0.17.0-RC.8

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.
Files changed (164) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/package.json +8 -6
  3. package/src/index.cjs +0 -18
  4. package/src/index.d.ts +0 -4
  5. package/src/index.js +1 -4
  6. package/src/multi-wallet.cjs +53 -96
  7. package/src/multi-wallet.js +53 -96
  8. package/src/types.d.ts +9 -47
  9. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +1 -1
  10. package/src/utils/getApiProviders.cjs +15 -0
  11. package/src/utils/getApiProviders.d.ts +10 -0
  12. package/src/utils/getApiProviders.js +11 -0
  13. package/src/utils/message.cjs +2 -2
  14. package/src/utils/message.d.ts +2 -2
  15. package/src/utils/message.js +1 -1
  16. package/src/utils/walletConnect.cjs +11 -8
  17. package/src/utils/walletConnect.d.ts +4 -4
  18. package/src/utils/walletConnect.js +11 -8
  19. package/src/wallets/algorand/MyAlgoWalletConnector.cjs +3 -3
  20. package/src/wallets/algorand/MyAlgoWalletConnector.js +1 -1
  21. package/src/wallets/clients/coinbase/coinbase.cjs +4 -4
  22. package/src/wallets/clients/coinbase/coinbase.js +1 -1
  23. package/src/wallets/clients/coinbase/types.d.ts +2 -2
  24. package/src/wallets/clients/walletConnect/walletConnect.cjs +20 -46
  25. package/src/wallets/clients/walletConnect/walletConnect.d.ts +1 -3
  26. package/src/wallets/clients/walletConnect/walletConnect.js +18 -43
  27. package/src/wallets/cosmos/KeplrWalletConnect.cjs +18 -16
  28. package/src/wallets/cosmos/KeplrWalletConnect.d.ts +7 -6
  29. package/src/wallets/cosmos/KeplrWalletConnect.js +14 -12
  30. package/src/wallets/cosmos/KeplrWalletConnector.cjs +21 -6
  31. package/src/wallets/cosmos/KeplrWalletConnector.d.ts +10 -5
  32. package/src/wallets/cosmos/KeplrWalletConnector.js +21 -6
  33. package/src/wallets/cosmos/wcClient.lib.cjs +100 -0
  34. package/src/wallets/cosmos/wcClient.lib.d.ts +20 -0
  35. package/src/wallets/cosmos/wcClient.lib.js +87 -0
  36. package/src/wallets/ethereum/BloctoEvm.cjs +10 -12
  37. package/src/wallets/ethereum/BloctoEvm.d.ts +2 -7
  38. package/src/wallets/ethereum/BloctoEvm.js +8 -10
  39. package/src/wallets/ethereum/EthWalletConnector.cjs +34 -19
  40. package/src/wallets/ethereum/EthWalletConnector.d.ts +8 -4
  41. package/src/wallets/ethereum/EthWalletConnector.js +28 -13
  42. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -2
  43. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -2
  44. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +2 -2
  45. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +1 -1
  46. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +14 -38
  47. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +5 -7
  48. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +14 -38
  49. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +10 -4
  50. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +9 -3
  51. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +15 -11
  52. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +9 -8
  53. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +13 -9
  54. package/src/wallets/ethereum/coinbase.cjs +9 -11
  55. package/src/wallets/ethereum/coinbase.d.ts +7 -11
  56. package/src/wallets/ethereum/coinbase.js +10 -12
  57. package/src/wallets/ethereum/ethProviderHelper.cjs +103 -101
  58. package/src/wallets/ethereum/ethProviderHelper.d.ts +24 -31
  59. package/src/wallets/ethereum/ethProviderHelper.js +100 -98
  60. package/src/wallets/ethereum/evm-network.cjs +2 -2
  61. package/src/wallets/ethereum/evm-network.d.ts +1 -17
  62. package/src/wallets/ethereum/evm-network.js +2 -2
  63. package/src/wallets/ethereum/injected/BloctoInjected.cjs +2 -3
  64. package/src/wallets/ethereum/injected/BloctoInjected.d.ts +2 -3
  65. package/src/wallets/ethereum/injected/BloctoInjected.js +2 -3
  66. package/src/wallets/ethereum/injected/BraveEvm.cjs +2 -3
  67. package/src/wallets/ethereum/injected/BraveEvm.d.ts +2 -3
  68. package/src/wallets/ethereum/injected/BraveEvm.js +2 -3
  69. package/src/wallets/ethereum/injected/Dawn.cjs +2 -3
  70. package/src/wallets/ethereum/injected/Dawn.d.ts +2 -3
  71. package/src/wallets/ethereum/injected/Dawn.js +2 -3
  72. package/src/wallets/ethereum/injected/ExodusEvm.cjs +2 -3
  73. package/src/wallets/ethereum/injected/ExodusEvm.d.ts +2 -3
  74. package/src/wallets/ethereum/injected/ExodusEvm.js +2 -3
  75. package/src/wallets/ethereum/injected/Frame.cjs +2 -3
  76. package/src/wallets/ethereum/injected/Frame.d.ts +2 -3
  77. package/src/wallets/ethereum/injected/Frame.js +2 -3
  78. package/src/wallets/ethereum/injected/GameStop.cjs +2 -3
  79. package/src/wallets/ethereum/injected/GameStop.d.ts +2 -3
  80. package/src/wallets/ethereum/injected/GameStop.js +2 -3
  81. package/src/wallets/ethereum/injected/InjectedWalletBase.cjs +74 -0
  82. package/src/wallets/ethereum/{meta-mask.d.ts → injected/InjectedWalletBase.d.ts} +7 -9
  83. package/src/wallets/ethereum/injected/InjectedWalletBase.js +72 -0
  84. package/src/wallets/ethereum/injected/MetaMask.cjs +13 -0
  85. package/src/wallets/ethereum/injected/MetaMask.d.ts +6 -0
  86. package/src/wallets/ethereum/injected/MetaMask.js +11 -0
  87. package/src/wallets/ethereum/injected/Opera.cjs +2 -3
  88. package/src/wallets/ethereum/injected/Opera.d.ts +2 -3
  89. package/src/wallets/ethereum/injected/Opera.js +2 -3
  90. package/src/wallets/ethereum/injected/PhantomEvm.cjs +2 -3
  91. package/src/wallets/ethereum/injected/PhantomEvm.d.ts +2 -3
  92. package/src/wallets/ethereum/injected/PhantomEvm.js +2 -3
  93. package/src/wallets/ethereum/injected/Trust.cjs +3 -3
  94. package/src/wallets/ethereum/injected/Trust.d.ts +3 -3
  95. package/src/wallets/ethereum/injected/Trust.js +3 -3
  96. package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +2 -3
  97. package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +2 -3
  98. package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +2 -3
  99. package/src/wallets/ethereum/injected/Zerion.cjs +3 -3
  100. package/src/wallets/ethereum/injected/Zerion.d.ts +3 -3
  101. package/src/wallets/ethereum/injected/Zerion.js +3 -3
  102. package/src/wallets/flow/FlowWalletConnector.cjs +7 -8
  103. package/src/wallets/flow/FlowWalletConnector.js +2 -3
  104. package/src/wallets/getWalletConnectConnector.cjs +7 -10
  105. package/src/wallets/getWalletConnectConnector.d.ts +2 -5
  106. package/src/wallets/getWalletConnectConnector.js +7 -10
  107. package/src/wallets/solana/CoinbaseSolana.cjs +8 -11
  108. package/src/wallets/solana/CoinbaseSolana.d.ts +1 -3
  109. package/src/wallets/solana/CoinbaseSolana.js +8 -11
  110. package/src/wallets/solana/glow.cjs +8 -11
  111. package/src/wallets/solana/glow.d.ts +1 -3
  112. package/src/wallets/solana/glow.js +8 -11
  113. package/src/wallets/solana/injected/BraveSol.cjs +2 -1
  114. package/src/wallets/solana/injected/BraveSol.js +2 -1
  115. package/src/wallets/solana/phantom-ledger.cjs +5 -5
  116. package/src/wallets/solana/phantom-ledger.js +1 -1
  117. package/src/wallets/solana/phantom.cjs +8 -12
  118. package/src/wallets/solana/phantom.d.ts +1 -3
  119. package/src/wallets/solana/phantom.js +8 -12
  120. package/src/wallets/solana/slope.cjs +4 -4
  121. package/src/wallets/solana/slope.js +1 -1
  122. package/src/wallets/solana/solProviderHelper.cjs +47 -48
  123. package/src/wallets/solana/solProviderHelper.d.ts +18 -18
  124. package/src/wallets/solana/solProviderHelper.js +47 -48
  125. package/src/wallets/solana/solWalletConnector.cjs +24 -6
  126. package/src/wallets/solana/solWalletConnector.d.ts +8 -5
  127. package/src/wallets/solana/solWalletConnector.js +23 -5
  128. package/src/wallets/solana/solflare.cjs +6 -7
  129. package/src/wallets/solana/solflare.d.ts +0 -2
  130. package/src/wallets/solana/solflare.js +6 -7
  131. package/src/wallets/starknet/starknetWalletConnector.cjs +5 -6
  132. package/src/wallets/starknet/starknetWalletConnector.js +2 -3
  133. package/src/wallets/walletConnect/index.d.ts +1 -1
  134. package/src/wallets/walletConnect/walletConnect.cjs +8 -7
  135. package/src/wallets/walletConnect/walletConnect.d.ts +7 -7
  136. package/src/wallets/walletConnect/walletConnect.js +6 -5
  137. package/src/wallets/walletConnect/walletConnectV2.cjs +14 -14
  138. package/src/wallets/walletConnect/walletConnectV2.d.ts +7 -7
  139. package/src/wallets/walletConnect/walletConnectV2.js +3 -3
  140. package/src/wallets/walletConnect/zerion.d.ts +2 -4
  141. package/src/errors.cjs +0 -66
  142. package/src/errors.d.ts +0 -34
  143. package/src/errors.js +0 -54
  144. package/src/rpcProviders.cjs +0 -76
  145. package/src/rpcProviders.d.ts +0 -5
  146. package/src/rpcProviders.js +0 -69
  147. package/src/utils/CancellablePromise/CancellablePromise.cjs +0 -33
  148. package/src/utils/CancellablePromise/CancellablePromise.d.ts +0 -9
  149. package/src/utils/CancellablePromise/CancellablePromise.js +0 -29
  150. package/src/utils/CancellablePromise/index.d.ts +0 -1
  151. package/src/utils/logger.cjs +0 -9
  152. package/src/utils/logger.d.ts +0 -2
  153. package/src/utils/logger.js +0 -5
  154. package/src/wallets/cosmos/getKeplrConnector.cjs +0 -18
  155. package/src/wallets/cosmos/getKeplrConnector.d.ts +0 -6
  156. package/src/wallets/cosmos/getKeplrConnector.js +0 -14
  157. package/src/wallets/ethereum/fortmatic.cjs +0 -75
  158. package/src/wallets/ethereum/fortmatic.d.ts +0 -26
  159. package/src/wallets/ethereum/fortmatic.js +0 -69
  160. package/src/wallets/ethereum/meta-mask.cjs +0 -63
  161. package/src/wallets/ethereum/meta-mask.js +0 -61
  162. package/src/wallets/getMobileOrInjectedWallet.cjs +0 -26
  163. package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -8
  164. package/src/wallets/getMobileOrInjectedWallet.js +0 -22
package/src/types.d.ts CHANGED
@@ -1,58 +1,20 @@
1
- import { Connection } from '@solana/web3.js';
2
- import { ethers } from 'ethers';
3
1
  import { OAuthProvider } from '@magic-ext/oauth';
4
- import type { NetworkConfiguration } from '@dynamic-labs/sdk-api';
2
+ import type { Provider } from '@dynamic-labs/sdk-api';
5
3
  import { WalletConnector, Chain } from '@dynamic-labs/wallet-connector-core';
6
- import { EvmNetwork } from './wallets/ethereum/evm-network';
7
- import { MagicLinkConfig } from './wallets/ethereum/MagicConnector';
8
- export type VendorCredentials = {
9
- fortmatic?: string;
10
- };
11
- export type EvmRpcProvider = {
12
- chainId: number;
13
- chainName: string;
14
- provider: ethers.providers.JsonRpcProvider;
15
- };
16
- export type SolanaRpcProvider = {
17
- chainId?: number;
18
- chainName: string;
19
- provider: Connection;
20
- };
21
- export type RpcProviders = {
22
- evm?: EvmRpcProvider[];
23
- solana?: SolanaRpcProvider[];
24
- };
25
- export type NetworkConfigurationMap = {
26
- cosmos: EvmNetwork[] | undefined;
27
- evm: EvmNetwork[] | undefined;
28
- solana: NetworkConfiguration[] | undefined;
29
- starknet: NetworkConfiguration[] | undefined;
30
- };
4
+ import { NetworkConfigurationMap, WalletUiUtils } from '@dynamic-labs/types';
5
+ import { ChainRpcProviders } from '@dynamic-labs/rpc-providers';
31
6
  export type GetSupportedWalletsOpts = {
32
7
  appLogoUrl?: string;
33
8
  appName?: string;
34
- isWalletConnectV2Enabled: boolean;
35
- magicLinkApiKey?: string;
36
- magicLinkConfig?: MagicLinkConfig;
37
- networkConfigurations: NetworkConfigurationMap | undefined;
9
+ chainRpcProviders: typeof ChainRpcProviders;
10
+ customerApiProviders?: Provider[];
11
+ isWalletConnectV2Enabled?: boolean;
12
+ networkConfigurations?: NetworkConfigurationMap;
38
13
  skipMemo?: boolean;
39
- vendorCredentials?: VendorCredentials;
40
- walletConnectProjectId: string | undefined;
14
+ walletConnectProjectId?: string;
41
15
  walletUiUtils?: WalletUiUtils;
42
16
  };
43
- export type GetSupportedWallets = (opts?: GetSupportedWalletsOpts) => Promise<WalletConnector[]>;
44
- export type WalletUiUtils = {
45
- enableInternalSign: () => void;
46
- sendTransaction: (props: {
47
- handler: (transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>) => Promise<ethers.providers.TransactionResponse>;
48
- provider: ethers.providers.Web3Provider;
49
- transaction: ethers.utils.Deferrable<ethers.providers.TransactionRequest>;
50
- }) => Promise<ethers.providers.TransactionResponse>;
51
- signMessage: (props: {
52
- handler: (message: string | ethers.utils.Bytes) => Promise<string>;
53
- message: string | ethers.utils.Bytes;
54
- }) => Promise<string>;
55
- };
17
+ export type GetSupportedWallets = (opts: GetSupportedWalletsOpts) => Promise<WalletConnector[]>;
56
18
  export type ChainInfo = {
57
19
  blockchainName: string;
58
20
  displayName: string;
@@ -1,3 +1,3 @@
1
1
  import { ethers } from 'ethers';
2
- import { WalletUiUtils } from '../../types';
2
+ import { WalletUiUtils } from '@dynamic-labs/types';
3
3
  export declare const assignConfirmationScreenToProvider: (provider: ethers.providers.Web3Provider, walletUiUtils: WalletUiUtils) => void;
@@ -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 };
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var utils = require('ethers/lib/utils');
6
- var logger = require('./logger.cjs');
6
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
7
7
  var getChainInfo = require('./getChainInfo/getChainInfo.cjs');
8
8
 
9
9
  const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
@@ -48,7 +48,7 @@ const getEip55Address = (publicKey, chainId) => {
48
48
  }
49
49
  }
50
50
  catch (err) {
51
- logger.logger.debug(`Error getting checksum, returning default ${publicKey}`);
51
+ walletConnectorCore.logger.debug(`Error getting checksum, returning default ${publicKey}`);
52
52
  }
53
53
  return publicKey;
54
54
  };
@@ -1,7 +1,7 @@
1
1
  import { Chain } from '@dynamic-labs/wallet-connector-core';
2
2
  export interface MessageParameters {
3
3
  blockchain: Chain;
4
- chainId?: number;
4
+ chainId?: number | string;
5
5
  domain: string;
6
6
  issuedAt?: string;
7
7
  nonce: string;
@@ -12,4 +12,4 @@ export interface MessageParameters {
12
12
  uri: string;
13
13
  }
14
14
  export declare const generateMessageToSign: ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt, statement, requestId, resources, }: MessageParameters) => string;
15
- export declare const getEip55Address: (publicKey: string, chainId?: number) => string;
15
+ export declare const getEip55Address: (publicKey: string, chainId?: number | string) => string;
@@ -1,5 +1,5 @@
1
1
  import { getAddress } from 'ethers/lib/utils.js';
2
- import { logger } from './logger.js';
2
+ import { logger } from '@dynamic-labs/wallet-connector-core';
3
3
  import { getChainInfo } from './getChainInfo/getChainInfo.js';
4
4
 
5
5
  const generateMessageToSign = ({ blockchain, domain, chainId, nonce, uri, publicKey, issuedAt = new Date().toISOString(), statement, requestId, resources, }) => {
@@ -6,25 +6,28 @@ var walletBook = require('@dynamic-labs/wallet-book');
6
6
  var walletConnect = require('../wallets/walletConnect/walletConnect.cjs');
7
7
  var walletConnectV2 = require('../wallets/walletConnect/walletConnectV2.cjs');
8
8
 
9
- const fetchWalletConnectWallets = (evmNetworks, isV2Enabled) => Object.values(walletBook.useWalletBook().wallets)
9
+ const fetchWalletConnectWallets = ({ isV2Enabled, }) => Object.values(walletBook.useWalletBook().wallets)
10
10
  .filter((wallet) => wallet.walletConnect)
11
11
  .map((wallet) => {
12
12
  var _a;
13
13
  const { shortName } = wallet;
14
14
  const name = shortName || wallet.name;
15
- let connector;
16
15
  // justification: we filtered out null/undefined above
17
16
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
18
17
  if (isV2Enabled && ((_a = wallet.walletConnect.sdks) === null || _a === void 0 ? void 0 : _a.includes('sign_v2'))) {
19
- connector = new walletConnectV2({
20
- evmNetworks,
21
- walletName: name,
22
- });
18
+ return class extends walletConnectV2 {
19
+ constructor(props) {
20
+ super(Object.assign(Object.assign({}, props), { walletName: name }));
21
+ }
22
+ };
23
23
  }
24
24
  else {
25
- connector = new walletConnect({ evmNetworks, walletName: name });
25
+ return class extends walletConnect {
26
+ constructor(props) {
27
+ super(Object.assign(Object.assign({}, props), { walletName: name }));
28
+ }
29
+ };
26
30
  }
27
- return connector;
28
31
  });
29
32
 
30
33
  exports.fetchWalletConnectWallets = fetchWalletConnectWallets;
@@ -1,4 +1,4 @@
1
- import WalletConnect from '../wallets/walletConnect';
2
- import { EvmNetwork } from '../wallets/ethereum/evm-network';
3
- import WalletConnectV2 from '../wallets/walletConnect/walletConnectV2';
4
- export declare const fetchWalletConnectWallets: (evmNetworks: EvmNetwork[], isV2Enabled: boolean) => (WalletConnectV2 | WalletConnect)[];
1
+ import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
2
+ export declare const fetchWalletConnectWallets: ({ isV2Enabled, }: {
3
+ isV2Enabled: boolean;
4
+ }) => Array<WalletConnectorConstructor>;
@@ -2,25 +2,28 @@ import { useWalletBook } from '@dynamic-labs/wallet-book';
2
2
  import WalletConnect from '../wallets/walletConnect/walletConnect.js';
3
3
  import WalletConnectV2 from '../wallets/walletConnect/walletConnectV2.js';
4
4
 
5
- const fetchWalletConnectWallets = (evmNetworks, isV2Enabled) => Object.values(useWalletBook().wallets)
5
+ const fetchWalletConnectWallets = ({ isV2Enabled, }) => Object.values(useWalletBook().wallets)
6
6
  .filter((wallet) => wallet.walletConnect)
7
7
  .map((wallet) => {
8
8
  var _a;
9
9
  const { shortName } = wallet;
10
10
  const name = shortName || wallet.name;
11
- let connector;
12
11
  // justification: we filtered out null/undefined above
13
12
  // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
14
13
  if (isV2Enabled && ((_a = wallet.walletConnect.sdks) === null || _a === void 0 ? void 0 : _a.includes('sign_v2'))) {
15
- connector = new WalletConnectV2({
16
- evmNetworks,
17
- walletName: name,
18
- });
14
+ return class extends WalletConnectV2 {
15
+ constructor(props) {
16
+ super(Object.assign(Object.assign({}, props), { walletName: name }));
17
+ }
18
+ };
19
19
  }
20
20
  else {
21
- connector = new WalletConnect({ evmNetworks, walletName: name });
21
+ return class extends WalletConnect {
22
+ constructor(props) {
23
+ super(Object.assign(Object.assign({}, props), { walletName: name }));
24
+ }
25
+ };
22
26
  }
23
- return connector;
24
27
  });
25
28
 
26
29
  export { fetchWalletConnectWallets };
@@ -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 errors = require('../../errors.cjs');
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 errors.DynamicError('MyAlgo Wallet Connector - Not connected!');
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 errors.DynamicError('getBalance - Not connected!');
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 '../../errors.js';
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
 
@@ -4,8 +4,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var walletSdk = require('@coinbase/wallet-sdk');
7
- var utils = require('ethers/lib/utils');
8
- var errors = require('../../../errors.cjs');
7
+ var utils$1 = require('ethers/lib/utils');
8
+ var utils = require('@dynamic-labs/utils');
9
9
  var constants = require('../../constants.cjs');
10
10
 
11
11
  const jsonRpcUrl = `https://mainnet.infura.io/v3/${constants.infuraId}`;
@@ -42,7 +42,7 @@ const fetchPublicAddress = (coinbaseProviderOpts, opts) => tslib.__awaiter(void
42
42
  const provider = getCoinbaseProvider({ opts: coinbaseProviderOpts });
43
43
  const { qrUrl } = provider;
44
44
  if (!qrUrl) {
45
- throw new errors.DynamicError('no qr url available');
45
+ throw new utils.DynamicError('no qr url available');
46
46
  }
47
47
  (_a = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _a === void 0 ? void 0 : _a.call(opts, qrUrl);
48
48
  const [address] = yield provider.request({
@@ -58,7 +58,7 @@ const signMessage = (coinbaseProviderOpts, messageToSign) => tslib.__awaiter(voi
58
58
  try {
59
59
  return yield provider.request({
60
60
  method: 'personal_sign',
61
- params: [utils.hexlify(utils.toUtf8Bytes(messageToSign)), address.toLowerCase()],
61
+ params: [utils$1.hexlify(utils$1.toUtf8Bytes(messageToSign)), address.toLowerCase()],
62
62
  });
63
63
  }
64
64
  catch (err) {
@@ -1,7 +1,7 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import { CoinbaseWalletSDK } from '@coinbase/wallet-sdk';
3
3
  import { hexlify, toUtf8Bytes } from 'ethers/lib/utils.js';
4
- import { DynamicError } from '../../../errors.js';
4
+ import { DynamicError } from '@dynamic-labs/utils';
5
5
  import { infuraId } from '../../constants.js';
6
6
 
7
7
  const jsonRpcUrl = `https://mainnet.infura.io/v3/${infuraId}`;
@@ -1,9 +1,9 @@
1
1
  import { CoinbaseWalletProvider } from '@coinbase/wallet-sdk';
2
- import { EvmNetwork } from '../../ethereum/evm-network';
2
+ import { GenericNetwork } from '@dynamic-labs/types';
3
3
  export type GetCoinbaseProviderOpts = {
4
4
  appLogoUrl?: string;
5
5
  appName?: string;
6
- evmNetworks?: EvmNetwork[];
6
+ evmNetworks?: GenericNetwork[];
7
7
  };
8
8
  export type CoinbaseProviderHandlerOpts = {
9
9
  onDisconnect(): Promise<void>;
@@ -5,9 +5,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
5
5
  var tslib = require('tslib');
6
6
  var Client = require('@walletconnect/client');
7
7
  var ethers = require('ethers');
8
+ var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
8
9
  var isMobile = require('../../../utils/isMobile.cjs');
9
10
  var isSameAddress = require('../../../utils/isSameAddress/isSameAddress.cjs');
10
- var logger = require('../../../utils/logger.cjs');
11
11
 
12
12
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
13
13
 
@@ -26,9 +26,7 @@ const initClient = (name, settings) => {
26
26
  */
27
27
  const setupWalletConnectEventListeners = (opts, client) => {
28
28
  if (!client) {
29
- return () => {
30
- // nothing to teardown
31
- };
29
+ return;
32
30
  }
33
31
  let prevAccount;
34
32
  let prevChain;
@@ -57,10 +55,6 @@ const setupWalletConnectEventListeners = (opts, client) => {
57
55
  yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
58
56
  }
59
57
  }));
60
- return () => {
61
- client.off('disconnect');
62
- client.off('session_update');
63
- };
64
58
  };
65
59
  const teardownWalletConnectEventListeners = (client) => {
66
60
  client.off('disconnect');
@@ -76,7 +70,7 @@ const killWalletConnectSession = (client) => tslib.__awaiter(void 0, void 0, voi
76
70
  }
77
71
  }
78
72
  catch (e) {
79
- logger.logger.debug(e);
73
+ walletConnectorCore.logger.debug(e);
80
74
  }
81
75
  });
82
76
  const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
@@ -101,19 +95,14 @@ const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
101
95
  };
102
96
  const createSession = (client) => tslib.__awaiter(void 0, void 0, void 0, function* () {
103
97
  return new Promise((resolve, reject) => {
104
- try {
105
- client.on('connect', (error, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
106
- if (error)
107
- throw error;
108
- resolve(payload);
109
- }));
110
- client.on('disconnect', (error, payload) => {
111
- throw error || payload.params[0].message;
112
- });
113
- }
114
- catch (e) {
115
- reject(e);
116
- }
98
+ client.on('connect', (error, payload) => tslib.__awaiter(void 0, void 0, void 0, function* () {
99
+ if (error)
100
+ throw error;
101
+ resolve(payload);
102
+ }));
103
+ client.on('disconnect', (error, payload) => {
104
+ reject(error || payload.params[0].message);
105
+ });
117
106
  });
118
107
  });
119
108
  const useDeepLink = (metadata, wcClient, opts) => {
@@ -129,22 +118,8 @@ const useDeepLink = (metadata, wcClient, opts) => {
129
118
  (_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
130
119
  }
131
120
  };
132
- const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
133
- var _a;
134
- if (wcClient.connected) {
135
- const key = yield provider.getKey(opts.chainId);
136
- return key.bech32Address;
137
- }
138
- yield wcClient.createSession();
139
- useDeepLink(metadata, wcClient, opts);
140
- const payload = yield createSession(wcClient);
141
- const key = yield provider.getKey(opts.chainId);
142
- (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
143
- wcClient.accounts = [key.bech32Address];
144
- return key.bech32Address;
145
- });
146
121
  const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => tslib.__awaiter(void 0, void 0, void 0, function* () {
147
- var _b;
122
+ var _a;
148
123
  if (wcClient.connected) {
149
124
  const [accountPublicAddress] = wcClient.accounts;
150
125
  return accountPublicAddress;
@@ -153,14 +128,14 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => tslib._
153
128
  yield wcClient.createSession();
154
129
  useDeepLink(metadata, wcClient, opts);
155
130
  const payload = yield createSession(wcClient);
156
- (_b = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _b === void 0 ? void 0 : _b.call(opts, payload);
131
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
157
132
  const [accountPublicAddress] = payload.params[0].accounts;
158
133
  return accountPublicAddress;
159
134
  });
160
135
  const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => tslib.__awaiter(void 0, void 0, void 0, function* () {
161
- var _c, _d;
162
- const isCryptoWallet = ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'Crypto.com | DeFi Wallet' ||
163
- ((_d = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'DeFi Wallet';
136
+ var _b, _c;
137
+ const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
138
+ ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
164
139
  if (!client || !client.connected) {
165
140
  return;
166
141
  }
@@ -192,7 +167,7 @@ const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcPr
192
167
  return signature;
193
168
  }
194
169
  catch (e) {
195
- logger.logger.debug(e);
170
+ walletConnectorCore.logger.debug(e);
196
171
  throw e;
197
172
  }
198
173
  });
@@ -204,11 +179,11 @@ const IS_VALID_SIGNATURE_ABI = [
204
179
  'function isValidSignature(bytes32 _message, bytes _signature) public view returns (bytes4)',
205
180
  ];
206
181
  const waitForSafeTransactionOrTimeout = (accountPublicAddress, signature, messageToSign, client, rpcProvider) => tslib.__awaiter(void 0, void 0, void 0, function* () {
207
- var _e;
182
+ var _d;
208
183
  if (signature === '0x' &&
209
184
  // this is what wallet connect client returns there's no `safe` or `Safe`
210
185
  // exact string anywhere, so this seems like the best proxy
211
- ((_e = client.peerMeta) === null || _e === void 0 ? void 0 : _e.name) === 'WalletConnect Safe App') {
186
+ ((_d = client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'WalletConnect Safe App') {
212
187
  if (!rpcProvider) {
213
188
  return;
214
189
  }
@@ -236,7 +211,7 @@ const waitForSafeTransaction = (signature, messageToSign, contract) => tslib.__a
236
211
  return;
237
212
  }
238
213
  catch (err) {
239
- logger.logger.info('Safe transaction cannot be validated yet. Retrying.');
214
+ walletConnectorCore.logger.info('Safe transaction cannot be validated yet. Retrying.');
240
215
  }
241
216
  // try again after 2 seconds
242
217
  yield sleep(2000);
@@ -244,7 +219,6 @@ const waitForSafeTransaction = (signature, messageToSign, contract) => tslib.__a
244
219
  });
245
220
 
246
221
  exports.createSession = createSession;
247
- exports.fetchWalletConnectCosmosPublicAddress = fetchWalletConnectCosmosPublicAddress;
248
222
  exports.fetchWalletConnectEVMPublicAddress = fetchWalletConnectEVMPublicAddress;
249
223
  exports.getDeepLink = getDeepLink;
250
224
  exports.initClient = initClient;
@@ -2,12 +2,11 @@ import Client from '@walletconnect/client';
2
2
  import { ethers } from 'ethers';
3
3
  import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
4
4
  import { WalletSchema } from '@dynamic-labs/wallet-book';
5
- import { KeplrWalletConnectV1 } from '../../cosmos/wcClient';
6
5
  export declare const initClient: (name: string, settings?: any) => Client;
7
6
  /**
8
7
  * Attach event handlers to WalletConnect events.
9
8
  */
10
- export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => (() => void);
9
+ export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => void;
11
10
  export declare const teardownWalletConnectEventListeners: (client: Client) => void;
12
11
  /**
13
12
  * Initialize a client from a stored session and terminate the connection.
@@ -18,6 +17,5 @@ export declare const getDeepLink: (uri: string, metadata: WalletSchema, { remove
18
17
  }) => string;
19
18
  export declare const createSession: (client: Client) => Promise<PayloadParams>;
20
19
  export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
21
- export declare const fetchWalletConnectCosmosPublicAddress: (metadata: WalletSchema, wcClient: Client, provider: KeplrWalletConnectV1, opts: FetchPublicAddressOpts & Required<Pick<FetchPublicAddressOpts, 'chainId'>>) => Promise<string>;
22
20
  export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
23
21
  export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
@@ -1,9 +1,9 @@
1
1
  import { __awaiter } from 'tslib';
2
2
  import Client from '@walletconnect/client';
3
3
  import { Contract, ethers } from 'ethers';
4
+ import { logger } from '@dynamic-labs/wallet-connector-core';
4
5
  import { isMobile, isIOS } from '../../../utils/isMobile.js';
5
6
  import { isSameAddress } from '../../../utils/isSameAddress/isSameAddress.js';
6
- import { logger } from '../../../utils/logger.js';
7
7
 
8
8
  const initClient = (name, settings) => {
9
9
  const storageId = `walletconnect-${name}`;
@@ -18,9 +18,7 @@ const initClient = (name, settings) => {
18
18
  */
19
19
  const setupWalletConnectEventListeners = (opts, client) => {
20
20
  if (!client) {
21
- return () => {
22
- // nothing to teardown
23
- };
21
+ return;
24
22
  }
25
23
  let prevAccount;
26
24
  let prevChain;
@@ -49,10 +47,6 @@ const setupWalletConnectEventListeners = (opts, client) => {
49
47
  yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
50
48
  }
51
49
  }));
52
- return () => {
53
- client.off('disconnect');
54
- client.off('session_update');
55
- };
56
50
  };
57
51
  const teardownWalletConnectEventListeners = (client) => {
58
52
  client.off('disconnect');
@@ -93,19 +87,14 @@ const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
93
87
  };
94
88
  const createSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
95
89
  return new Promise((resolve, reject) => {
96
- try {
97
- client.on('connect', (error, payload) => __awaiter(void 0, void 0, void 0, function* () {
98
- if (error)
99
- throw error;
100
- resolve(payload);
101
- }));
102
- client.on('disconnect', (error, payload) => {
103
- throw error || payload.params[0].message;
104
- });
105
- }
106
- catch (e) {
107
- reject(e);
108
- }
90
+ client.on('connect', (error, payload) => __awaiter(void 0, void 0, void 0, function* () {
91
+ if (error)
92
+ throw error;
93
+ resolve(payload);
94
+ }));
95
+ client.on('disconnect', (error, payload) => {
96
+ reject(error || payload.params[0].message);
97
+ });
109
98
  });
110
99
  });
111
100
  const useDeepLink = (metadata, wcClient, opts) => {
@@ -121,22 +110,8 @@ const useDeepLink = (metadata, wcClient, opts) => {
121
110
  (_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
122
111
  }
123
112
  };
124
- const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => __awaiter(void 0, void 0, void 0, function* () {
125
- var _a;
126
- if (wcClient.connected) {
127
- const key = yield provider.getKey(opts.chainId);
128
- return key.bech32Address;
129
- }
130
- yield wcClient.createSession();
131
- useDeepLink(metadata, wcClient, opts);
132
- const payload = yield createSession(wcClient);
133
- const key = yield provider.getKey(opts.chainId);
134
- (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
135
- wcClient.accounts = [key.bech32Address];
136
- return key.bech32Address;
137
- });
138
113
  const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __awaiter(void 0, void 0, void 0, function* () {
139
- var _b;
114
+ var _a;
140
115
  if (wcClient.connected) {
141
116
  const [accountPublicAddress] = wcClient.accounts;
142
117
  return accountPublicAddress;
@@ -145,14 +120,14 @@ const fetchWalletConnectEVMPublicAddress = (metadata, wcClient, opts) => __await
145
120
  yield wcClient.createSession();
146
121
  useDeepLink(metadata, wcClient, opts);
147
122
  const payload = yield createSession(wcClient);
148
- (_b = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _b === void 0 ? void 0 : _b.call(opts, payload);
123
+ (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
149
124
  const [accountPublicAddress] = payload.params[0].accounts;
150
125
  return accountPublicAddress;
151
126
  });
152
127
  const signWalletConnectPersonalMessage = (messageToSign, metadata, client, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
153
- var _c, _d;
154
- const isCryptoWallet = ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'Crypto.com | DeFi Wallet' ||
155
- ((_d = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'DeFi Wallet';
128
+ var _b, _c;
129
+ const isCryptoWallet = ((_b = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _b === void 0 ? void 0 : _b.name) === 'Crypto.com | DeFi Wallet' ||
130
+ ((_c = client === null || client === void 0 ? void 0 : client.peerMeta) === null || _c === void 0 ? void 0 : _c.name) === 'DeFi Wallet';
156
131
  if (!client || !client.connected) {
157
132
  return;
158
133
  }
@@ -196,11 +171,11 @@ const IS_VALID_SIGNATURE_ABI = [
196
171
  'function isValidSignature(bytes32 _message, bytes _signature) public view returns (bytes4)',
197
172
  ];
198
173
  const waitForSafeTransactionOrTimeout = (accountPublicAddress, signature, messageToSign, client, rpcProvider) => __awaiter(void 0, void 0, void 0, function* () {
199
- var _e;
174
+ var _d;
200
175
  if (signature === '0x' &&
201
176
  // this is what wallet connect client returns there's no `safe` or `Safe`
202
177
  // exact string anywhere, so this seems like the best proxy
203
- ((_e = client.peerMeta) === null || _e === void 0 ? void 0 : _e.name) === 'WalletConnect Safe App') {
178
+ ((_d = client.peerMeta) === null || _d === void 0 ? void 0 : _d.name) === 'WalletConnect Safe App') {
204
179
  if (!rpcProvider) {
205
180
  return;
206
181
  }
@@ -235,4 +210,4 @@ const waitForSafeTransaction = (signature, messageToSign, contract) => __awaiter
235
210
  }
236
211
  });
237
212
 
238
- export { createSession, fetchWalletConnectCosmosPublicAddress, fetchWalletConnectEVMPublicAddress, getDeepLink, initClient, killWalletConnectSession, setupWalletConnectEventListeners, signWalletConnectPersonalMessage, teardownWalletConnectEventListeners, useDeepLink };
213
+ export { createSession, fetchWalletConnectEVMPublicAddress, getDeepLink, initClient, killWalletConnectSession, setupWalletConnectEventListeners, signWalletConnectPersonalMessage, teardownWalletConnectEventListeners, useDeepLink };