@dynamic-labs/multi-wallet 0.17.0-RC.8 → 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.
Files changed (184) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/package.json +7 -12
  3. package/src/index.cjs +0 -44
  4. package/src/index.d.ts +0 -11
  5. package/src/index.js +1 -16
  6. package/src/multi-wallet.cjs +16 -64
  7. package/src/multi-wallet.d.ts +0 -1
  8. package/src/multi-wallet.js +12 -59
  9. package/src/types.d.ts +0 -2
  10. package/src/utils/message.cjs +1 -2
  11. package/src/utils/message.js +1 -2
  12. package/src/wallets/constants.cjs +0 -2
  13. package/src/wallets/constants.js +1 -2
  14. package/src/wallets/cosmos/KeplrWalletConnect.cjs +4 -6
  15. package/src/wallets/cosmos/KeplrWalletConnect.d.ts +4 -1
  16. package/src/wallets/cosmos/KeplrWalletConnect.js +2 -4
  17. package/src/wallets/cosmos/KeplrWalletConnector.d.ts +1 -2
  18. package/src/wallets/cosmos/wcClient.lib.cjs +45 -4
  19. package/src/wallets/cosmos/wcClient.lib.js +42 -3
  20. package/src/wallets/flow/lilico.cjs +2 -2
  21. package/src/wallets/flow/lilico.js +1 -1
  22. package/src/wallets/solana/phantom.cjs +3 -3
  23. package/src/wallets/solana/phantom.js +1 -1
  24. package/src/wallets/solana/solProviderHelper.cjs +3 -4
  25. package/src/wallets/solana/solProviderHelper.d.ts +3 -3
  26. package/src/wallets/solana/solProviderHelper.js +1 -2
  27. package/src/wallets/starknet/braavos.cjs +2 -2
  28. package/src/wallets/starknet/braavos.js +1 -1
  29. package/src/wallets/window.d.ts +10 -22
  30. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs +0 -54
  31. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +0 -3
  32. package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.js +0 -50
  33. package/src/utils/assignConfirmationScreenToProvider/index.d.ts +0 -1
  34. package/src/utils/encoding.cjs +0 -18
  35. package/src/utils/encoding.d.ts +0 -4
  36. package/src/utils/encoding.js +0 -12
  37. package/src/utils/getChainInfo/getChainInfo.cjs +0 -59
  38. package/src/utils/getChainInfo/getChainInfo.d.ts +0 -2
  39. package/src/utils/getChainInfo/getChainInfo.js +0 -55
  40. package/src/utils/getChainInfo/index.d.ts +0 -1
  41. package/src/utils/getWalletConnectorByName.cjs +0 -19
  42. package/src/utils/getWalletConnectorByName.d.ts +0 -2
  43. package/src/utils/getWalletConnectorByName.js +0 -15
  44. package/src/utils/isEmailOTPWalletConnector/index.d.ts +0 -1
  45. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.cjs +0 -7
  46. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +0 -2
  47. package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.js +0 -3
  48. package/src/utils/isEmailWalletConnector/index.d.ts +0 -1
  49. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.cjs +0 -7
  50. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +0 -2
  51. package/src/utils/isEmailWalletConnector/isEmailWalletConnector.js +0 -3
  52. package/src/utils/isFunction/index.d.ts +0 -1
  53. package/src/utils/isFunction/isFunction.cjs +0 -8
  54. package/src/utils/isFunction/isFunction.d.ts +0 -1
  55. package/src/utils/isFunction/isFunction.js +0 -4
  56. package/src/utils/isMobile.cjs +0 -54
  57. package/src/utils/isMobile.d.ts +0 -13
  58. package/src/utils/isMobile.js +0 -46
  59. package/src/utils/isSameAddress/index.d.ts +0 -1
  60. package/src/utils/isSameAddress/isSameAddress.cjs +0 -9
  61. package/src/utils/isSameAddress/isSameAddress.d.ts +0 -1
  62. package/src/utils/isSameAddress/isSameAddress.js +0 -5
  63. package/src/utils/isSameAddress/utils/index.d.ts +0 -1
  64. package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +0 -1
  65. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +0 -17
  66. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +0 -1
  67. package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +0 -13
  68. package/src/utils/isSocialWalletConnector/index.d.ts +0 -1
  69. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.cjs +0 -7
  70. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +0 -2
  71. package/src/utils/isSocialWalletConnector/isSocialWalletConnector.js +0 -3
  72. package/src/utils/isUnsupportedProviderError/index.d.ts +0 -1
  73. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +0 -13
  74. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +0 -6
  75. package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +0 -9
  76. package/src/utils/normalizeWalletName/index.d.ts +0 -1
  77. package/src/utils/normalizeWalletName/normalizeWalletName.cjs +0 -7
  78. package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +0 -1
  79. package/src/utils/normalizeWalletName/normalizeWalletName.js +0 -3
  80. package/src/utils/shouldLowercaseAddress.cjs +0 -11
  81. package/src/utils/shouldLowercaseAddress.d.ts +0 -1
  82. package/src/utils/shouldLowercaseAddress.js +0 -7
  83. package/src/utils/walletConnect.cjs +0 -33
  84. package/src/utils/walletConnect.d.ts +0 -4
  85. package/src/utils/walletConnect.js +0 -29
  86. package/src/wallets/ProviderLookup.cjs +0 -18
  87. package/src/wallets/ProviderLookup.d.ts +0 -4
  88. package/src/wallets/ProviderLookup.js +0 -14
  89. package/src/wallets/clients/coinbase/coinbase.cjs +0 -73
  90. package/src/wallets/clients/coinbase/coinbase.d.ts +0 -6
  91. package/src/wallets/clients/coinbase/coinbase.js +0 -66
  92. package/src/wallets/clients/coinbase/index.d.ts +0 -2
  93. package/src/wallets/clients/coinbase/types.d.ts +0 -14
  94. package/src/wallets/clients/walletConnect/index.d.ts +0 -1
  95. package/src/wallets/clients/walletConnect/types.d.ts +0 -4
  96. package/src/wallets/clients/walletConnect/walletConnect.cjs +0 -229
  97. package/src/wallets/clients/walletConnect/walletConnect.d.ts +0 -21
  98. package/src/wallets/clients/walletConnect/walletConnect.js +0 -213
  99. package/src/wallets/ethereum/BloctoEvm.cjs +0 -109
  100. package/src/wallets/ethereum/BloctoEvm.d.ts +0 -20
  101. package/src/wallets/ethereum/BloctoEvm.js +0 -103
  102. package/src/wallets/ethereum/EthWalletConnector.cjs +0 -206
  103. package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -39
  104. package/src/wallets/ethereum/EthWalletConnector.js +0 -202
  105. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -61
  106. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
  107. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -57
  108. package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/index.d.ts +0 -1
  109. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +0 -62
  110. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.d.ts +0 -11
  111. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +0 -58
  112. package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/index.d.ts +0 -1
  113. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +0 -78
  114. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -31
  115. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -74
  116. package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
  117. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -61
  118. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
  119. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -57
  120. package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
  121. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -179
  122. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -54
  123. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -175
  124. package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/index.d.ts +0 -2
  125. package/src/wallets/ethereum/MagicConnector/index.d.ts +0 -5
  126. package/src/wallets/ethereum/coinbase.cjs +0 -63
  127. package/src/wallets/ethereum/coinbase.d.ts +0 -22
  128. package/src/wallets/ethereum/coinbase.js +0 -61
  129. package/src/wallets/ethereum/ethProviderHelper.cjs +0 -199
  130. package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -33
  131. package/src/wallets/ethereum/ethProviderHelper.js +0 -195
  132. package/src/wallets/ethereum/evm-network.cjs +0 -20
  133. package/src/wallets/ethereum/evm-network.d.ts +0 -6
  134. package/src/wallets/ethereum/evm-network.js +0 -16
  135. package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -12
  136. package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -5
  137. package/src/wallets/ethereum/injected/BloctoInjected.js +0 -10
  138. package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -12
  139. package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -5
  140. package/src/wallets/ethereum/injected/BraveEvm.js +0 -10
  141. package/src/wallets/ethereum/injected/Dawn.cjs +0 -12
  142. package/src/wallets/ethereum/injected/Dawn.d.ts +0 -5
  143. package/src/wallets/ethereum/injected/Dawn.js +0 -10
  144. package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -12
  145. package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -5
  146. package/src/wallets/ethereum/injected/ExodusEvm.js +0 -10
  147. package/src/wallets/ethereum/injected/Frame.cjs +0 -12
  148. package/src/wallets/ethereum/injected/Frame.d.ts +0 -5
  149. package/src/wallets/ethereum/injected/Frame.js +0 -10
  150. package/src/wallets/ethereum/injected/GameStop.cjs +0 -12
  151. package/src/wallets/ethereum/injected/GameStop.d.ts +0 -5
  152. package/src/wallets/ethereum/injected/GameStop.js +0 -10
  153. package/src/wallets/ethereum/injected/InjectedWalletBase.cjs +0 -74
  154. package/src/wallets/ethereum/injected/InjectedWalletBase.d.ts +0 -24
  155. package/src/wallets/ethereum/injected/InjectedWalletBase.js +0 -72
  156. package/src/wallets/ethereum/injected/MetaMask.cjs +0 -13
  157. package/src/wallets/ethereum/injected/MetaMask.d.ts +0 -6
  158. package/src/wallets/ethereum/injected/MetaMask.js +0 -11
  159. package/src/wallets/ethereum/injected/Opera.cjs +0 -12
  160. package/src/wallets/ethereum/injected/Opera.d.ts +0 -5
  161. package/src/wallets/ethereum/injected/Opera.js +0 -10
  162. package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -36
  163. package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -6
  164. package/src/wallets/ethereum/injected/PhantomEvm.js +0 -34
  165. package/src/wallets/ethereum/injected/Trust.cjs +0 -13
  166. package/src/wallets/ethereum/injected/Trust.d.ts +0 -6
  167. package/src/wallets/ethereum/injected/Trust.js +0 -11
  168. package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +0 -12
  169. package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -5
  170. package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -10
  171. package/src/wallets/ethereum/injected/Zerion.cjs +0 -13
  172. package/src/wallets/ethereum/injected/Zerion.d.ts +0 -6
  173. package/src/wallets/ethereum/injected/Zerion.js +0 -11
  174. package/src/wallets/getWalletConnectConnector.cjs +0 -16
  175. package/src/wallets/getWalletConnectConnector.d.ts +0 -5
  176. package/src/wallets/getWalletConnectConnector.js +0 -12
  177. package/src/wallets/walletConnect/index.d.ts +0 -2
  178. package/src/wallets/walletConnect/walletConnect.cjs +0 -133
  179. package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
  180. package/src/wallets/walletConnect/walletConnect.js +0 -127
  181. package/src/wallets/walletConnect/walletConnectV2.cjs +0 -268
  182. package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -38
  183. package/src/wallets/walletConnect/walletConnectV2.js +0 -262
  184. package/src/wallets/walletConnect/zerion.d.ts +0 -6
@@ -1,10 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase.js';
2
-
3
- class Opera extends InjectedWalletBase {
4
- constructor() {
5
- super(...arguments);
6
- this.name = 'Opera';
7
- }
8
- }
9
-
10
- export { Opera as default };
@@ -1,36 +0,0 @@
1
- 'use strict';
2
-
3
- var tslib = require('tslib');
4
- var isMobile = require('../../../utils/isMobile.cjs');
5
- var InjectedWalletBase = require('./InjectedWalletBase.cjs');
6
-
7
- class PhantomEvm extends InjectedWalletBase {
8
- constructor() {
9
- super(...arguments);
10
- this.name = 'PhantomEvm';
11
- }
12
- fetchPublicAddress() {
13
- const _super = Object.create(null, {
14
- fetchPublicAddress: { get: () => super.fetchPublicAddress }
15
- });
16
- return tslib.__awaiter(this, void 0, void 0, function* () {
17
- if (this.isInstalledOnBrowser()) {
18
- return _super.fetchPublicAddress.call(this);
19
- }
20
- const url = encodeURIComponent(window.location.toString());
21
- const ref = encodeURIComponent(window.location.origin);
22
- // samsung browser only supports native links, not universal links
23
- if (isMobile.isMobile()) {
24
- if (isMobile.isSamsungBrowser()) {
25
- window.location.assign(`phantom://browse/${url}?ref=${ref}`);
26
- }
27
- else {
28
- window.location.assign(`https://phantom.app/ul/browse/${url}?ref=${ref}`);
29
- }
30
- }
31
- return undefined;
32
- });
33
- }
34
- }
35
-
36
- module.exports = PhantomEvm;
@@ -1,6 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase';
2
- declare class PhantomEvm extends InjectedWalletBase {
3
- name: string;
4
- fetchPublicAddress(): Promise<string | undefined>;
5
- }
6
- export default PhantomEvm;
@@ -1,34 +0,0 @@
1
- import { __awaiter } from 'tslib';
2
- import { isMobile, isSamsungBrowser } from '../../../utils/isMobile.js';
3
- import InjectedWalletBase from './InjectedWalletBase.js';
4
-
5
- class PhantomEvm extends InjectedWalletBase {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'PhantomEvm';
9
- }
10
- fetchPublicAddress() {
11
- const _super = Object.create(null, {
12
- fetchPublicAddress: { get: () => super.fetchPublicAddress }
13
- });
14
- return __awaiter(this, void 0, void 0, function* () {
15
- if (this.isInstalledOnBrowser()) {
16
- return _super.fetchPublicAddress.call(this);
17
- }
18
- const url = encodeURIComponent(window.location.toString());
19
- const ref = encodeURIComponent(window.location.origin);
20
- // samsung browser only supports native links, not universal links
21
- if (isMobile()) {
22
- if (isSamsungBrowser()) {
23
- window.location.assign(`phantom://browse/${url}?ref=${ref}`);
24
- }
25
- else {
26
- window.location.assign(`https://phantom.app/ul/browse/${url}?ref=${ref}`);
27
- }
28
- }
29
- return undefined;
30
- });
31
- }
32
- }
33
-
34
- export { PhantomEvm as default };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var InjectedWalletBase = require('./InjectedWalletBase.cjs');
4
-
5
- class Trust extends InjectedWalletBase {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'Trust';
9
- this.walletConnectorFallback = true;
10
- }
11
- }
12
-
13
- module.exports = Trust;
@@ -1,6 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase';
2
- declare class Trust extends InjectedWalletBase {
3
- name: string;
4
- walletConnectorFallback: boolean;
5
- }
6
- export default Trust;
@@ -1,11 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase.js';
2
-
3
- class Trust extends InjectedWalletBase {
4
- constructor() {
5
- super(...arguments);
6
- this.name = 'Trust';
7
- this.walletConnectorFallback = true;
8
- }
9
- }
10
-
11
- export { Trust as default };
@@ -1,12 +0,0 @@
1
- 'use strict';
2
-
3
- var InjectedWalletBase = require('./InjectedWalletBase.cjs');
4
-
5
- class UnknownInjectedWallet extends InjectedWalletBase {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'InjectedWallet';
9
- }
10
- }
11
-
12
- module.exports = UnknownInjectedWallet;
@@ -1,5 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase';
2
- declare class UnknownInjectedWallet extends InjectedWalletBase {
3
- name: string;
4
- }
5
- export default UnknownInjectedWallet;
@@ -1,10 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase.js';
2
-
3
- class UnknownInjectedWallet extends InjectedWalletBase {
4
- constructor() {
5
- super(...arguments);
6
- this.name = 'InjectedWallet';
7
- }
8
- }
9
-
10
- export { UnknownInjectedWallet as default };
@@ -1,13 +0,0 @@
1
- 'use strict';
2
-
3
- var InjectedWalletBase = require('./InjectedWalletBase.cjs');
4
-
5
- class Zerion extends InjectedWalletBase {
6
- constructor() {
7
- super(...arguments);
8
- this.name = 'Zerion';
9
- this.walletConnectorFallback = true;
10
- }
11
- }
12
-
13
- module.exports = Zerion;
@@ -1,6 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase';
2
- declare class Zerion extends InjectedWalletBase {
3
- name: string;
4
- walletConnectorFallback: boolean;
5
- }
6
- export default Zerion;
@@ -1,11 +0,0 @@
1
- import InjectedWalletBase from './InjectedWalletBase.js';
2
-
3
- class Zerion extends InjectedWalletBase {
4
- constructor() {
5
- super(...arguments);
6
- this.name = 'Zerion';
7
- this.walletConnectorFallback = true;
8
- }
9
- }
10
-
11
- export { Zerion as default };
@@ -1,16 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib = require('tslib');
6
- var walletConnect = require('./walletConnect/walletConnect.cjs');
7
- var walletConnectV2 = require('./walletConnect/walletConnectV2.cjs');
8
-
9
- const getWalletConnectConnector = (_a) => {
10
- var { isWalletConnectV2Enabled } = _a, props = tslib.__rest(_a, ["isWalletConnectV2Enabled"]);
11
- return isWalletConnectV2Enabled
12
- ? new walletConnectV2(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }))
13
- : new walletConnect(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
14
- };
15
-
16
- exports.getWalletConnectConnector = getWalletConnectConnector;
@@ -1,5 +0,0 @@
1
- import WalletConnect from './walletConnect';
2
- import WalletConnectV2, { WalletConnectorV2Opts } from './walletConnect/walletConnectV2';
3
- export declare const getWalletConnectConnector: ({ isWalletConnectV2Enabled, ...props }: Omit<WalletConnectorV2Opts, "walletName"> & {
4
- isWalletConnectV2Enabled: boolean;
5
- }) => WalletConnectV2 | WalletConnect;
@@ -1,12 +0,0 @@
1
- import { __rest } from 'tslib';
2
- import WalletConnect from './walletConnect/walletConnect.js';
3
- import WalletConnectV2 from './walletConnect/walletConnectV2.js';
4
-
5
- const getWalletConnectConnector = (_a) => {
6
- var { isWalletConnectV2Enabled } = _a, props = __rest(_a, ["isWalletConnectV2Enabled"]);
7
- return isWalletConnectV2Enabled
8
- ? new WalletConnectV2(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }))
9
- : new WalletConnect(Object.assign(Object.assign({}, props), { walletName: 'WalletConnect' }));
10
- };
11
-
12
- export { getWalletConnectConnector };
@@ -1,2 +0,0 @@
1
- export { default } from './walletConnect';
2
- export { default as WalletConnectV2, type WalletConnectorV2Opts, } from './walletConnectV2';
@@ -1,133 +0,0 @@
1
- 'use strict';
2
-
3
- var tslib = require('tslib');
4
- var WalletConnectProvider = require('@walletconnect/ethereum-provider');
5
- var ethers = require('ethers');
6
- var walletBook = require('@dynamic-labs/wallet-book');
7
- var utils = require('@dynamic-labs/utils');
8
- var constants = require('../constants.cjs');
9
- var EthWalletConnector = require('../ethereum/EthWalletConnector.cjs');
10
- var walletConnect = require('../clients/walletConnect/walletConnect.cjs');
11
- var isMobile = require('../../utils/isMobile.cjs');
12
- var normalizeWalletName = require('../../utils/normalizeWalletName/normalizeWalletName.cjs');
13
-
14
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
15
-
16
- var WalletConnectProvider__default = /*#__PURE__*/_interopDefaultLegacy(WalletConnectProvider);
17
-
18
- class WalletConnect extends EthWalletConnector.EthWalletConnector {
19
- constructor(_a) {
20
- var { walletName } = _a, props = tslib.__rest(_a, ["walletName"]);
21
- super(props);
22
- this.supportedChains = ['EVM', 'ETH'];
23
- this.connectedChain = 'EVM';
24
- this.canConnectViaQrCode = true;
25
- this.isWalletConnect = true;
26
- this.switchNetworkOnlyFromWallet = false;
27
- this.name = walletName;
28
- }
29
- getClient() {
30
- if (this.client) {
31
- return this.client;
32
- }
33
- this.client = walletConnect.initClient(normalizeWalletName.normalizeWalletName(this.name), this.clientOptions);
34
- return this.client;
35
- }
36
- supportsNetworkSwitching() {
37
- if (this.connectedChain === 'EVM') {
38
- return true;
39
- }
40
- else {
41
- const client = this.getClient();
42
- return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
43
- }
44
- }
45
- setupEventListeners(listeners) {
46
- walletConnect.setupWalletConnectEventListeners({
47
- onAccountChange: listeners.onAccountChange,
48
- onChainChange: listeners.onChainChange,
49
- onDisconnect: listeners.onDisconnect,
50
- }, this.getClient());
51
- }
52
- teardownEventListeners() {
53
- walletConnect.teardownWalletConnectEventListeners(this.getClient());
54
- }
55
- getWeb3Provider() {
56
- const client = this.getClient();
57
- return client
58
- ? new ethers.ethers.providers.Web3Provider(new WalletConnectProvider__default["default"]({
59
- connector: client,
60
- infuraId: constants.infuraId,
61
- rpc: this.evmNetworkRpcMap(),
62
- }), 'any')
63
- : undefined;
64
- }
65
- fetchPublicAddress(opts) {
66
- return tslib.__awaiter(this, void 0, void 0, function* () {
67
- return walletConnect.fetchWalletConnectEVMPublicAddress(walletBook.getWalletBookWallet(this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
68
- var _a;
69
- (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
70
- this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
71
- } }));
72
- });
73
- }
74
- getDeepLink() {
75
- var _a;
76
- const wallet = walletBook.getWalletBookWallet(this.name);
77
- if (!isMobile.isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
78
- return undefined;
79
- }
80
- return walletConnect.getDeepLink(this.getClient().uri, wallet, {
81
- removeWCUri: isMobile.isIOS() && normalizeWalletName.normalizeWalletName(this.name) === 'cryptocom',
82
- });
83
- }
84
- signMessage(messageToSign) {
85
- return tslib.__awaiter(this, void 0, void 0, function* () {
86
- return walletConnect.signWalletConnectPersonalMessage(messageToSign, walletBook.getWalletBookWallet(this.name), this.getClient(),
87
- // don't call getRpcProvider until we really need to
88
- () => tslib.__awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
89
- });
90
- }
91
- endSession() {
92
- return tslib.__awaiter(this, void 0, void 0, function* () {
93
- walletConnect.killWalletConnectSession(this.getClient());
94
- });
95
- }
96
- providerSwitchNetwork({ network, provider, }) {
97
- const _super = Object.create(null, {
98
- providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
99
- });
100
- return tslib.__awaiter(this, void 0, void 0, function* () {
101
- const client = this.getClient();
102
- const currentNetworkId = yield this.getNetwork();
103
- if (currentNetworkId && currentNetworkId === network.chainId) {
104
- return;
105
- }
106
- if (this.switchNetworkOnlyFromWallet !== undefined &&
107
- this.switchNetworkOnlyFromWallet) {
108
- throw new utils.DynamicError('Network switching is only supported through the wallet');
109
- }
110
- if (!this.supportsNetworkSwitching()) {
111
- throw new utils.DynamicError('Network switching not supported');
112
- }
113
- if (!client) {
114
- throw new utils.DynamicError('Client not found');
115
- }
116
- if (isMobile.isMobile()) {
117
- const deepLink = walletConnect.getDeepLink(client.uri, walletBook.getWalletBookWallet(this.name));
118
- window.location.href = deepLink;
119
- }
120
- return _super.providerSwitchNetwork.call(this, { network, provider });
121
- });
122
- }
123
- getConnectedAccounts() {
124
- return tslib.__awaiter(this, void 0, void 0, function* () {
125
- const client = this.getClient();
126
- if (!client.connected)
127
- return [];
128
- return client.accounts;
129
- });
130
- }
131
- }
132
-
133
- module.exports = WalletConnect;
@@ -1,34 +0,0 @@
1
- import Client from '@walletconnect/client';
2
- import { ethers } from 'ethers';
3
- import { Chain, FetchPublicAddressOpts, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
4
- import { EvmNetwork } from '@dynamic-labs/types';
5
- import { EthWalletConnector, EthWalletConnectorOpts } from '../ethereum/EthWalletConnector';
6
- export type WalletConnectOpts = EthWalletConnectorOpts & {
7
- walletName: string;
8
- };
9
- declare class WalletConnect extends EthWalletConnector {
10
- supportedChains: Chain[];
11
- connectedChain: Chain;
12
- name: string;
13
- canConnectViaQrCode: boolean;
14
- isWalletConnect: boolean;
15
- switchNetworkOnlyFromWallet: boolean;
16
- client?: Client;
17
- clientOptions?: any;
18
- constructor({ walletName, ...props }: WalletConnectOpts);
19
- getClient(): Client;
20
- supportsNetworkSwitching(): boolean;
21
- setupEventListeners(listeners: WalletEventListeners): void;
22
- teardownEventListeners(): void;
23
- getWeb3Provider(): ethers.providers.Web3Provider | undefined;
24
- fetchPublicAddress(opts?: FetchPublicAddressOpts): Promise<string | undefined>;
25
- getDeepLink(): string | undefined;
26
- signMessage(messageToSign: string): Promise<string | undefined>;
27
- endSession(): Promise<void>;
28
- providerSwitchNetwork({ network, provider, }: {
29
- network: EvmNetwork;
30
- provider: ethers.providers.Web3Provider;
31
- }): Promise<void>;
32
- getConnectedAccounts(): Promise<string[]>;
33
- }
34
- export default WalletConnect;
@@ -1,127 +0,0 @@
1
- import { __rest, __awaiter } from 'tslib';
2
- import WalletConnectProvider from '@walletconnect/ethereum-provider';
3
- import { ethers } from 'ethers';
4
- import { getWalletBookWallet } from '@dynamic-labs/wallet-book';
5
- import { DynamicError } from '@dynamic-labs/utils';
6
- import { infuraId } from '../constants.js';
7
- import { EthWalletConnector } from '../ethereum/EthWalletConnector.js';
8
- import { initClient, setupWalletConnectEventListeners, teardownWalletConnectEventListeners, fetchWalletConnectEVMPublicAddress, getDeepLink, signWalletConnectPersonalMessage, killWalletConnectSession } from '../clients/walletConnect/walletConnect.js';
9
- import { isMobile, isIOS } from '../../utils/isMobile.js';
10
- import { normalizeWalletName } from '../../utils/normalizeWalletName/normalizeWalletName.js';
11
-
12
- class WalletConnect extends EthWalletConnector {
13
- constructor(_a) {
14
- var { walletName } = _a, props = __rest(_a, ["walletName"]);
15
- super(props);
16
- this.supportedChains = ['EVM', 'ETH'];
17
- this.connectedChain = 'EVM';
18
- this.canConnectViaQrCode = true;
19
- this.isWalletConnect = true;
20
- this.switchNetworkOnlyFromWallet = false;
21
- this.name = walletName;
22
- }
23
- getClient() {
24
- if (this.client) {
25
- return this.client;
26
- }
27
- this.client = initClient(normalizeWalletName(this.name), this.clientOptions);
28
- return this.client;
29
- }
30
- supportsNetworkSwitching() {
31
- if (this.connectedChain === 'EVM') {
32
- return true;
33
- }
34
- else {
35
- const client = this.getClient();
36
- return Boolean(client === null || client === void 0 ? void 0 : client.chainId);
37
- }
38
- }
39
- setupEventListeners(listeners) {
40
- setupWalletConnectEventListeners({
41
- onAccountChange: listeners.onAccountChange,
42
- onChainChange: listeners.onChainChange,
43
- onDisconnect: listeners.onDisconnect,
44
- }, this.getClient());
45
- }
46
- teardownEventListeners() {
47
- teardownWalletConnectEventListeners(this.getClient());
48
- }
49
- getWeb3Provider() {
50
- const client = this.getClient();
51
- return client
52
- ? new ethers.providers.Web3Provider(new WalletConnectProvider({
53
- connector: client,
54
- infuraId,
55
- rpc: this.evmNetworkRpcMap(),
56
- }), 'any')
57
- : undefined;
58
- }
59
- fetchPublicAddress(opts) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- return fetchWalletConnectEVMPublicAddress(getWalletBookWallet(this.name), this.getClient(), Object.assign(Object.assign({}, opts), { onConnect: (payload) => {
62
- var _a;
63
- (_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
64
- this.connectedChain = payload.params[0].chainId ? 'EVM' : 'SOL';
65
- } }));
66
- });
67
- }
68
- getDeepLink() {
69
- var _a;
70
- const wallet = getWalletBookWallet(this.name);
71
- if (!isMobile() && !((_a = wallet.desktop) === null || _a === void 0 ? void 0 : _a.native)) {
72
- return undefined;
73
- }
74
- return getDeepLink(this.getClient().uri, wallet, {
75
- removeWCUri: isIOS() && normalizeWalletName(this.name) === 'cryptocom',
76
- });
77
- }
78
- signMessage(messageToSign) {
79
- return __awaiter(this, void 0, void 0, function* () {
80
- return signWalletConnectPersonalMessage(messageToSign, getWalletBookWallet(this.name), this.getClient(),
81
- // don't call getRpcProvider until we really need to
82
- () => __awaiter(this, void 0, void 0, function* () { return this.getRpcProvider(); }));
83
- });
84
- }
85
- endSession() {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- killWalletConnectSession(this.getClient());
88
- });
89
- }
90
- providerSwitchNetwork({ network, provider, }) {
91
- const _super = Object.create(null, {
92
- providerSwitchNetwork: { get: () => super.providerSwitchNetwork }
93
- });
94
- return __awaiter(this, void 0, void 0, function* () {
95
- const client = this.getClient();
96
- const currentNetworkId = yield this.getNetwork();
97
- if (currentNetworkId && currentNetworkId === network.chainId) {
98
- return;
99
- }
100
- if (this.switchNetworkOnlyFromWallet !== undefined &&
101
- this.switchNetworkOnlyFromWallet) {
102
- throw new DynamicError('Network switching is only supported through the wallet');
103
- }
104
- if (!this.supportsNetworkSwitching()) {
105
- throw new DynamicError('Network switching not supported');
106
- }
107
- if (!client) {
108
- throw new DynamicError('Client not found');
109
- }
110
- if (isMobile()) {
111
- const deepLink = getDeepLink(client.uri, getWalletBookWallet(this.name));
112
- window.location.href = deepLink;
113
- }
114
- return _super.providerSwitchNetwork.call(this, { network, provider });
115
- });
116
- }
117
- getConnectedAccounts() {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const client = this.getClient();
120
- if (!client.connected)
121
- return [];
122
- return client.accounts;
123
- });
124
- }
125
- }
126
-
127
- export { WalletConnect as default };