@dynamic-labs/global-wallet-client 4.14.0 → 4.16.0
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 +31 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +16 -8
- package/src/features.cjs +30 -0
- package/src/features.d.ts +11 -0
- package/src/features.js +12 -0
- package/src/index.cjs +1 -1
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -1
- package/src/lib/client/assignClient/assignClient.cjs +15 -0
- package/src/lib/client/assignClient/assignClient.d.ts +2 -0
- package/src/lib/client/assignClient/assignClient.js +11 -0
- package/src/lib/client/assignClient/index.d.ts +1 -0
- package/src/lib/client/assignCore/assignCore.cjs +15 -0
- package/src/lib/client/assignCore/assignCore.d.ts +2 -0
- package/src/lib/client/assignCore/assignCore.js +11 -0
- package/src/lib/client/assignCore/index.d.ts +1 -0
- package/src/lib/client/createClientStore/createClientStore.cjs +20 -0
- package/src/lib/client/createClientStore/createClientStore.d.ts +35 -0
- package/src/lib/client/createClientStore/createClientStore.js +16 -0
- package/src/lib/client/createClientStore/index.d.ts +1 -0
- package/src/lib/client/createCore/createCore.cjs +42 -0
- package/src/lib/client/createCore/createCore.d.ts +19 -0
- package/src/lib/client/createCore/createCore.js +38 -0
- package/src/lib/client/createCore/index.d.ts +1 -0
- package/src/lib/client/createGlobalWalletClient/createGlobalWalletClient.cjs +35 -0
- package/src/lib/client/createGlobalWalletClient/createGlobalWalletClient.d.ts +11 -0
- package/src/lib/client/createGlobalWalletClient/createGlobalWalletClient.js +31 -0
- package/src/lib/client/createGlobalWalletClient/index.d.ts +1 -0
- package/src/lib/client/getClient/getClient.cjs +14 -0
- package/src/lib/client/getClient/getClient.d.ts +2 -0
- package/src/lib/client/getClient/getClient.js +10 -0
- package/src/lib/client/getClient/index.d.ts +1 -0
- package/src/lib/client/getCore/getCore.cjs +10 -0
- package/src/lib/client/getCore/getCore.d.ts +3 -0
- package/src/lib/client/getCore/getCore.js +6 -0
- package/src/lib/client/getCore/index.d.ts +1 -0
- package/src/lib/client/index.d.ts +7 -0
- package/src/lib/client/types.d.ts +5 -0
- package/src/lib/errors/ClientDisconnectedError.cjs +12 -0
- package/src/lib/errors/ClientDisconnectedError.d.ts +3 -0
- package/src/lib/errors/ClientDisconnectedError.js +8 -0
- package/src/lib/errors/NetworkNotSupportedError.cjs +18 -0
- package/src/lib/errors/NetworkNotSupportedError.d.ts +3 -0
- package/src/lib/errors/NetworkNotSupportedError.js +14 -0
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.cjs +37 -25
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.d.ts +1 -1
- package/src/lib/ethereum/functions/eip1193Provider/createEIP1193Provider.js +37 -25
- package/src/lib/functions/clearStore/clearStore.cjs +24 -0
- package/src/lib/functions/clearStore/clearStore.d.ts +5 -0
- package/src/lib/functions/clearStore/clearStore.js +20 -0
- package/src/lib/functions/clearStore/index.d.ts +1 -0
- package/src/lib/{actions/connectAction/createConnectAction.cjs → functions/connect/connect.cjs} +32 -12
- package/src/lib/functions/connect/connect.d.ts +15 -0
- package/src/lib/{actions/connectAction/createConnectAction.js → functions/connect/connect.js} +32 -12
- package/src/lib/functions/connect/index.d.ts +1 -0
- package/src/lib/functions/createPopupMessageClient/createPopupMessageClient.d.ts +6 -6
- package/src/lib/functions/createPopupOpener/createPopupOpener.cjs +5 -6
- package/src/lib/functions/createPopupOpener/createPopupOpener.d.ts +4 -5
- package/src/lib/functions/createPopupOpener/createPopupOpener.js +5 -6
- package/src/lib/functions/createPopupOpener/index.d.ts +1 -1
- package/src/lib/functions/disconnect/disconnect.cjs +38 -0
- package/src/lib/functions/disconnect/disconnect.d.ts +14 -0
- package/src/lib/functions/disconnect/disconnect.js +34 -0
- package/src/lib/functions/disconnect/index.d.ts +1 -0
- package/src/lib/functions/getActiveConnection/getActiveConnection.cjs +35 -0
- package/src/lib/functions/getActiveConnection/getActiveConnection.d.ts +6 -0
- package/src/lib/functions/getActiveConnection/getActiveConnection.js +31 -0
- package/src/lib/functions/getActiveConnection/index.d.ts +1 -0
- package/src/lib/functions/getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs +38 -0
- package/src/lib/functions/getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.d.ts +16 -0
- package/src/lib/functions/getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.js +34 -0
- package/src/lib/functions/getCurrentEthereumNetworkId/index.d.ts +1 -0
- package/src/lib/functions/getCurrentSolanaNetwork/getCurrentSolanaNetwork.cjs +38 -0
- package/src/lib/functions/getCurrentSolanaNetwork/getCurrentSolanaNetwork.d.ts +16 -0
- package/src/lib/functions/getCurrentSolanaNetwork/getCurrentSolanaNetwork.js +34 -0
- package/src/lib/functions/getCurrentSolanaNetwork/index.d.ts +1 -0
- package/src/lib/functions/getEthereumWallets/getEthereumWallets.cjs +17 -0
- package/src/lib/functions/getEthereumWallets/getEthereumWallets.d.ts +10 -0
- package/src/lib/functions/getEthereumWallets/getEthereumWallets.js +13 -0
- package/src/lib/functions/getEthereumWallets/index.d.ts +1 -0
- package/src/lib/functions/getSolanaWallets/getSolanaWallets.cjs +17 -0
- package/src/lib/functions/getSolanaWallets/getSolanaWallets.d.ts +10 -0
- package/src/lib/functions/getSolanaWallets/getSolanaWallets.js +13 -0
- package/src/lib/functions/getSolanaWallets/index.d.ts +1 -0
- package/src/lib/functions/getSupportedEthereumNetworks/getSupportedEthereumNetworks.cjs +31 -0
- package/src/lib/functions/getSupportedEthereumNetworks/getSupportedEthereumNetworks.d.ts +9 -0
- package/src/lib/functions/getSupportedEthereumNetworks/getSupportedEthereumNetworks.js +27 -0
- package/src/lib/functions/getSupportedEthereumNetworks/index.d.ts +1 -0
- package/src/lib/functions/getWalletNetwork/getWalletNetwork.cjs +37 -0
- package/src/lib/functions/getWalletNetwork/getWalletNetwork.d.ts +9 -0
- package/src/lib/functions/getWalletNetwork/getWalletNetwork.js +33 -0
- package/src/lib/functions/getWalletNetwork/index.d.ts +1 -0
- package/src/lib/functions/isEthereumNetworkSupported/index.d.ts +1 -0
- package/src/lib/functions/isEthereumNetworkSupported/isEthereumNetworkSupported.cjs +8 -0
- package/src/lib/functions/isEthereumNetworkSupported/isEthereumNetworkSupported.d.ts +4 -0
- package/src/lib/functions/isEthereumNetworkSupported/isEthereumNetworkSupported.js +4 -0
- package/src/lib/functions/isEthereumWallet/index.d.ts +1 -0
- package/src/lib/functions/isEthereumWallet/isEthereumWallet.cjs +15 -0
- package/src/lib/functions/isEthereumWallet/isEthereumWallet.d.ts +9 -0
- package/src/lib/functions/isEthereumWallet/isEthereumWallet.js +11 -0
- package/src/lib/functions/isSolanaWallet/index.d.ts +1 -0
- package/src/lib/functions/isSolanaWallet/isSolanaWallet.cjs +15 -0
- package/src/lib/functions/isSolanaWallet/isSolanaWallet.d.ts +9 -0
- package/src/lib/functions/isSolanaWallet/isSolanaWallet.js +11 -0
- package/src/lib/functions/onEvent/index.d.ts +1 -0
- package/src/lib/functions/onEvent/onEvent.cjs +46 -0
- package/src/lib/functions/onEvent/onEvent.d.ts +23 -0
- package/src/lib/functions/onEvent/onEvent.js +42 -0
- package/src/lib/functions/setInitialConnectionState/index.d.ts +1 -0
- package/src/lib/functions/setInitialConnectionState/setInitialConnectionState.cjs +31 -0
- package/src/lib/functions/setInitialConnectionState/setInitialConnectionState.d.ts +7 -0
- package/src/lib/functions/setInitialConnectionState/setInitialConnectionState.js +27 -0
- package/src/lib/functions/signEthereumMessage/index.d.ts +1 -0
- package/src/lib/functions/signEthereumMessage/signEthereumMessage.cjs +40 -0
- package/src/lib/functions/signEthereumMessage/signEthereumMessage.d.ts +9 -0
- package/src/lib/functions/signEthereumMessage/signEthereumMessage.js +36 -0
- package/src/lib/functions/signMessage/index.d.ts +1 -0
- package/src/lib/functions/signMessage/signMessage.cjs +37 -0
- package/src/lib/functions/signMessage/signMessage.d.ts +24 -0
- package/src/lib/functions/signMessage/signMessage.js +33 -0
- package/src/lib/functions/signSolanaMessage/index.d.ts +1 -0
- package/src/lib/functions/signSolanaMessage/signSolanaMessage.cjs +31 -0
- package/src/lib/functions/signSolanaMessage/signSolanaMessage.d.ts +9 -0
- package/src/lib/functions/signSolanaMessage/signSolanaMessage.js +27 -0
- package/src/lib/functions/switchEthereumNetwork/index.d.ts +1 -0
- package/src/lib/functions/switchEthereumNetwork/switchEthereumNetwork.cjs +45 -0
- package/src/lib/functions/switchEthereumNetwork/switchEthereumNetwork.d.ts +12 -0
- package/src/lib/functions/switchEthereumNetwork/switchEthereumNetwork.js +41 -0
- package/src/lib/functions/switchNetwork/index.d.ts +1 -0
- package/src/lib/functions/switchNetwork/switchNetwork.cjs +33 -0
- package/src/lib/functions/switchNetwork/switchNetwork.d.ts +11 -0
- package/src/lib/functions/switchNetwork/switchNetwork.js +29 -0
- package/src/lib/solana/functions/convertBaseWalletToWalletAccount/convertBaseWalletToWalletAccount.d.ts +1 -1
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.cjs +10 -2
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.d.ts +1 -1
- package/src/lib/solana/functions/createSolanaSignAndSendTransactionFeature/createSolanaSignAndSendTransactionFeature.js +10 -2
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.cjs +10 -2
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.d.ts +1 -1
- package/src/lib/solana/functions/createSolanaSignMessageFeature/createSolanaSignMessageFeature.js +10 -2
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.cjs +10 -2
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.d.ts +1 -1
- package/src/lib/solana/functions/createSolanaSignTransactionFeature/createSolanaSignTransactionFeature.js +10 -2
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.cjs +2 -1
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.d.ts +1 -1
- package/src/lib/solana/functions/createSolanaWallet/createSolanaWallet.js +2 -1
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.cjs +5 -3
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.d.ts +1 -1
- package/src/lib/solana/functions/createStandardConnectFeature/createStandardConnectFeature.js +5 -3
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.cjs +2 -1
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.d.ts +1 -1
- package/src/lib/solana/functions/createStandardDisconnectFeature/createStandardDisconnectFeature.js +2 -1
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.cjs +5 -3
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.d.ts +1 -1
- package/src/lib/solana/functions/createStandardEventsFeature/createStandardEventsFeature.js +5 -3
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.cjs +5 -2
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.d.ts +1 -1
- package/src/lib/solana/functions/getSolanaChains/getSolanaChains.js +5 -2
- package/src/lib/actions/connectAction/createConnectAction.d.ts +0 -11
- package/src/lib/actions/connectAction/index.d.ts +0 -1
- package/src/lib/actions/disconnectAction/createDisconnectAction.cjs +0 -14
- package/src/lib/actions/disconnectAction/createDisconnectAction.d.ts +0 -7
- package/src/lib/actions/disconnectAction/createDisconnectAction.js +0 -10
- package/src/lib/actions/disconnectAction/index.d.ts +0 -1
- package/src/lib/createGlobalWalletClient.cjs +0 -69
- package/src/lib/createGlobalWalletClient.d.ts +0 -61
- package/src/lib/createGlobalWalletClient.js +0 -65
- package/src/lib/ethereum/functions/isNetworkSupported/index.d.ts +0 -1
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.cjs +0 -8
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.d.ts +0 -4
- package/src/lib/ethereum/functions/isNetworkSupported/isNetworkSupported.js +0 -4
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.cjs +0 -10
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.d.ts +0 -6
- package/src/lib/functions/createClientEventEmitter/createClientEventEmitter.js +0 -6
- package/src/lib/functions/createClientEventEmitter/index.d.ts +0 -1
- package/src/lib/functions/createEthereumModule/createEthereumModule.cjs +0 -24
- package/src/lib/functions/createEthereumModule/createEthereumModule.d.ts +0 -12
- package/src/lib/functions/createEthereumModule/createEthereumModule.js +0 -20
- package/src/lib/functions/createEthereumModule/index.d.ts +0 -1
- package/src/lib/functions/createSolanaModule/createSolanaModule.cjs +0 -17
- package/src/lib/functions/createSolanaModule/createSolanaModule.d.ts +0 -9
- package/src/lib/functions/createSolanaModule/createSolanaModule.js +0 -13
- package/src/lib/functions/createSolanaModule/index.d.ts +0 -1
- package/src/lib/store/createClientStore.cjs +0 -102
- package/src/lib/store/createClientStore.d.ts +0 -75
- package/src/lib/store/createClientStore.js +0 -98
- package/src/lib/store/index.d.ts +0 -1
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var _package = require('../../package.cjs');
|
|
7
|
-
var createConnectAction = require('./actions/connectAction/createConnectAction.cjs');
|
|
8
|
-
var createPopupOpener = require('./functions/createPopupOpener/createPopupOpener.cjs');
|
|
9
|
-
var createClientStore = require('./store/createClientStore.cjs');
|
|
10
|
-
var createClientEventEmitter = require('./functions/createClientEventEmitter/createClientEventEmitter.cjs');
|
|
11
|
-
var createDisconnectAction = require('./actions/disconnectAction/createDisconnectAction.cjs');
|
|
12
|
-
var createEthereumModule = require('./functions/createEthereumModule/createEthereumModule.cjs');
|
|
13
|
-
var createSolanaModule = require('./functions/createSolanaModule/createSolanaModule.cjs');
|
|
14
|
-
var addVersionPostfixToUrl = require('./functions/addVersionPostfixToUrl/addVersionPostfixToUrl.cjs');
|
|
15
|
-
var isSSR = require('./functions/isSSR/isSSR.cjs');
|
|
16
|
-
var fakeStorage = require('./constants/fakeStorage/fakeStorage.cjs');
|
|
17
|
-
var DisconnectError = require('./errors/DisconnectError.cjs');
|
|
18
|
-
var logger = require('./constants/logger.cjs');
|
|
19
|
-
|
|
20
|
-
const createGlobalWalletClient = ({ environmentId, popup: popupInfo, developmentOptions: { postfixPopupUrlWithVersion = true } = {}, }) => {
|
|
21
|
-
const eventEmitter = createClientEventEmitter.createClientEventEmitter();
|
|
22
|
-
eventEmitter.on('connect', () => logger.logger.logVerboseTroubleshootingMessage('EventEmitter: connect'));
|
|
23
|
-
eventEmitter.on('disconnect', () => logger.logger.logVerboseTroubleshootingMessage('EventEmitter: disconnect'));
|
|
24
|
-
const store = createClientStore.createClientStore({
|
|
25
|
-
environmentId,
|
|
26
|
-
storage: isSSR.isSSR() ? fakeStorage.fakeStorage : localStorage,
|
|
27
|
-
});
|
|
28
|
-
const popupUrl = postfixPopupUrlWithVersion
|
|
29
|
-
? addVersionPostfixToUrl.addVersionPostfixToUrl(_package.version, popupInfo.url)
|
|
30
|
-
: popupInfo.url;
|
|
31
|
-
const disconnect = createDisconnectAction.createDisconnectAction({
|
|
32
|
-
onDisconnect: () => eventEmitter.emit('disconnect'),
|
|
33
|
-
store,
|
|
34
|
-
});
|
|
35
|
-
const openPopup = createPopupOpener.createPopupOpener({
|
|
36
|
-
environmentId,
|
|
37
|
-
onError: (error) => {
|
|
38
|
-
if (error instanceof DisconnectError.DisconnectError) {
|
|
39
|
-
disconnect();
|
|
40
|
-
}
|
|
41
|
-
},
|
|
42
|
-
popupHeight: popupInfo.height,
|
|
43
|
-
popupUrl,
|
|
44
|
-
popupWidth: popupInfo.width,
|
|
45
|
-
store,
|
|
46
|
-
});
|
|
47
|
-
const connect = createConnectAction.createConnectAction({
|
|
48
|
-
onConnect: () => eventEmitter.emit('connect'),
|
|
49
|
-
openPopup,
|
|
50
|
-
store,
|
|
51
|
-
});
|
|
52
|
-
return {
|
|
53
|
-
connect,
|
|
54
|
-
disconnect,
|
|
55
|
-
ethereum: createEthereumModule.createEthereumModule({ store }),
|
|
56
|
-
invoke: openPopup,
|
|
57
|
-
off: eventEmitter.off.bind(eventEmitter),
|
|
58
|
-
on: eventEmitter.on.bind(eventEmitter),
|
|
59
|
-
once: eventEmitter.once.bind(eventEmitter),
|
|
60
|
-
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter),
|
|
61
|
-
removeListener: eventEmitter.removeListener.bind(eventEmitter),
|
|
62
|
-
solana: createSolanaModule.createSolanaModule({ store }),
|
|
63
|
-
get wallets() {
|
|
64
|
-
return store.wallets;
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
exports.createGlobalWalletClient = createGlobalWalletClient;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { DevelopmentOptions, PopupInfo } from './types';
|
|
2
|
-
export type CreateGlobalWalletClientProps = {
|
|
3
|
-
environmentId: string;
|
|
4
|
-
popup: PopupInfo;
|
|
5
|
-
developmentOptions?: DevelopmentOptions;
|
|
6
|
-
};
|
|
7
|
-
export declare const createGlobalWalletClient: ({ environmentId, popup: popupInfo, developmentOptions: { postfixPopupUrlWithVersion }, }: CreateGlobalWalletClientProps) => {
|
|
8
|
-
connect: ({ chain }: import("./types").ConnectArgs) => Promise<import("dist/packages/types/src").BaseWallet>;
|
|
9
|
-
disconnect: () => void;
|
|
10
|
-
ethereum: {
|
|
11
|
-
readonly currentNetworkId: number | null;
|
|
12
|
-
readonly supportedNetworks: {
|
|
13
|
-
chainId: number;
|
|
14
|
-
rpcUrl?: string | undefined;
|
|
15
|
-
}[];
|
|
16
|
-
switchNetwork: (network: number) => void;
|
|
17
|
-
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
18
|
-
};
|
|
19
|
-
invoke: <TPopupAction extends import("dist/packages/types/src").IPopupAction>({ params, pathname, }: {
|
|
20
|
-
params: import("dist/packages/types/src").GetPopupActionFuncArgs<TPopupAction>;
|
|
21
|
-
pathname: import("dist/packages/types/src").GetPopupActionName<TPopupAction>;
|
|
22
|
-
}) => Promise<import("dist/packages/types/src").GetPopupActionResult<TPopupAction>>;
|
|
23
|
-
off: <T extends "connect" | "disconnect">(event: T, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
24
|
-
connect: () => void;
|
|
25
|
-
disconnect: () => void;
|
|
26
|
-
}>[Extract<T, "connect" | "disconnect">]) => void) | undefined, context?: any, once?: boolean | undefined) => import("eventemitter3").EventEmitter<{
|
|
27
|
-
connect: () => void;
|
|
28
|
-
disconnect: () => void;
|
|
29
|
-
}, any>;
|
|
30
|
-
on: <T_1 extends "connect" | "disconnect">(event: T_1, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
31
|
-
connect: () => void;
|
|
32
|
-
disconnect: () => void;
|
|
33
|
-
}>[Extract<T_1, "connect" | "disconnect">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
34
|
-
connect: () => void;
|
|
35
|
-
disconnect: () => void;
|
|
36
|
-
}, any>;
|
|
37
|
-
once: <T_2 extends "connect" | "disconnect">(event: T_2, fn: (...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
38
|
-
connect: () => void;
|
|
39
|
-
disconnect: () => void;
|
|
40
|
-
}>[Extract<T_2, "connect" | "disconnect">]) => void, context?: any) => import("eventemitter3").EventEmitter<{
|
|
41
|
-
connect: () => void;
|
|
42
|
-
disconnect: () => void;
|
|
43
|
-
}, any>;
|
|
44
|
-
removeAllListeners: (event?: "connect" | "disconnect" | undefined) => import("eventemitter3").EventEmitter<{
|
|
45
|
-
connect: () => void;
|
|
46
|
-
disconnect: () => void;
|
|
47
|
-
}, any>;
|
|
48
|
-
removeListener: <T_3 extends "connect" | "disconnect">(event: T_3, fn?: ((...args: import("eventemitter3").EventEmitter.ArgumentMap<{
|
|
49
|
-
connect: () => void;
|
|
50
|
-
disconnect: () => void;
|
|
51
|
-
}>[Extract<T_3, "connect" | "disconnect">]) => void) | undefined, context?: any, once?: boolean | undefined) => import("eventemitter3").EventEmitter<{
|
|
52
|
-
connect: () => void;
|
|
53
|
-
disconnect: () => void;
|
|
54
|
-
}, any>;
|
|
55
|
-
solana: {
|
|
56
|
-
readonly currentNetwork: string | null;
|
|
57
|
-
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
58
|
-
};
|
|
59
|
-
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
60
|
-
};
|
|
61
|
-
export type GlobalWalletClient = ReturnType<typeof createGlobalWalletClient>;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { version } from '../../package.js';
|
|
3
|
-
import { createConnectAction } from './actions/connectAction/createConnectAction.js';
|
|
4
|
-
import { createPopupOpener } from './functions/createPopupOpener/createPopupOpener.js';
|
|
5
|
-
import { createClientStore } from './store/createClientStore.js';
|
|
6
|
-
import { createClientEventEmitter } from './functions/createClientEventEmitter/createClientEventEmitter.js';
|
|
7
|
-
import { createDisconnectAction } from './actions/disconnectAction/createDisconnectAction.js';
|
|
8
|
-
import { createEthereumModule } from './functions/createEthereumModule/createEthereumModule.js';
|
|
9
|
-
import { createSolanaModule } from './functions/createSolanaModule/createSolanaModule.js';
|
|
10
|
-
import { addVersionPostfixToUrl } from './functions/addVersionPostfixToUrl/addVersionPostfixToUrl.js';
|
|
11
|
-
import { isSSR } from './functions/isSSR/isSSR.js';
|
|
12
|
-
import { fakeStorage } from './constants/fakeStorage/fakeStorage.js';
|
|
13
|
-
import { DisconnectError } from './errors/DisconnectError.js';
|
|
14
|
-
import { logger } from './constants/logger.js';
|
|
15
|
-
|
|
16
|
-
const createGlobalWalletClient = ({ environmentId, popup: popupInfo, developmentOptions: { postfixPopupUrlWithVersion = true } = {}, }) => {
|
|
17
|
-
const eventEmitter = createClientEventEmitter();
|
|
18
|
-
eventEmitter.on('connect', () => logger.logVerboseTroubleshootingMessage('EventEmitter: connect'));
|
|
19
|
-
eventEmitter.on('disconnect', () => logger.logVerboseTroubleshootingMessage('EventEmitter: disconnect'));
|
|
20
|
-
const store = createClientStore({
|
|
21
|
-
environmentId,
|
|
22
|
-
storage: isSSR() ? fakeStorage : localStorage,
|
|
23
|
-
});
|
|
24
|
-
const popupUrl = postfixPopupUrlWithVersion
|
|
25
|
-
? addVersionPostfixToUrl(version, popupInfo.url)
|
|
26
|
-
: popupInfo.url;
|
|
27
|
-
const disconnect = createDisconnectAction({
|
|
28
|
-
onDisconnect: () => eventEmitter.emit('disconnect'),
|
|
29
|
-
store,
|
|
30
|
-
});
|
|
31
|
-
const openPopup = createPopupOpener({
|
|
32
|
-
environmentId,
|
|
33
|
-
onError: (error) => {
|
|
34
|
-
if (error instanceof DisconnectError) {
|
|
35
|
-
disconnect();
|
|
36
|
-
}
|
|
37
|
-
},
|
|
38
|
-
popupHeight: popupInfo.height,
|
|
39
|
-
popupUrl,
|
|
40
|
-
popupWidth: popupInfo.width,
|
|
41
|
-
store,
|
|
42
|
-
});
|
|
43
|
-
const connect = createConnectAction({
|
|
44
|
-
onConnect: () => eventEmitter.emit('connect'),
|
|
45
|
-
openPopup,
|
|
46
|
-
store,
|
|
47
|
-
});
|
|
48
|
-
return {
|
|
49
|
-
connect,
|
|
50
|
-
disconnect,
|
|
51
|
-
ethereum: createEthereumModule({ store }),
|
|
52
|
-
invoke: openPopup,
|
|
53
|
-
off: eventEmitter.off.bind(eventEmitter),
|
|
54
|
-
on: eventEmitter.on.bind(eventEmitter),
|
|
55
|
-
once: eventEmitter.once.bind(eventEmitter),
|
|
56
|
-
removeAllListeners: eventEmitter.removeAllListeners.bind(eventEmitter),
|
|
57
|
-
removeListener: eventEmitter.removeListener.bind(eventEmitter),
|
|
58
|
-
solana: createSolanaModule({ store }),
|
|
59
|
-
get wallets() {
|
|
60
|
-
return store.wallets;
|
|
61
|
-
},
|
|
62
|
-
};
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export { createGlobalWalletClient };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { isNetworkSupported } from './isNetworkSupported';
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const isNetworkSupported = (chainId, supportedNetworks) => supportedNetworks.some((network) => network.chainId === chainId);
|
|
7
|
-
|
|
8
|
-
exports.isNetworkSupported = isNetworkSupported;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var eventemitter3 = require('eventemitter3');
|
|
7
|
-
|
|
8
|
-
const createClientEventEmitter = () => new eventemitter3.EventEmitter();
|
|
9
|
-
|
|
10
|
-
exports.createClientEventEmitter = createClientEventEmitter;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createClientEventEmitter } from './createClientEventEmitter';
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const createEthereumModule = ({ store }) => ({
|
|
7
|
-
get currentNetworkId() {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
return (_b = (_a = store.ethereum) === null || _a === void 0 ? void 0 : _a.currentNetworkId) !== null && _b !== void 0 ? _b : null;
|
|
10
|
-
},
|
|
11
|
-
get supportedNetworks() {
|
|
12
|
-
var _a, _b;
|
|
13
|
-
return (_b = (_a = store.ethereum) === null || _a === void 0 ? void 0 : _a.supportedNetworks) !== null && _b !== void 0 ? _b : [];
|
|
14
|
-
},
|
|
15
|
-
switchNetwork: (network) => {
|
|
16
|
-
store.switchEthereumNetwork(network);
|
|
17
|
-
},
|
|
18
|
-
get wallets() {
|
|
19
|
-
var _a;
|
|
20
|
-
return (_a = store.wallets.filter(({ chain }) => chain === 'EVM')) !== null && _a !== void 0 ? _a : [];
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
exports.createEthereumModule = createEthereumModule;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { ClientStore } from '../../store';
|
|
2
|
-
export declare const createEthereumModule: ({ store }: {
|
|
3
|
-
store: ClientStore;
|
|
4
|
-
}) => {
|
|
5
|
-
readonly currentNetworkId: number | null;
|
|
6
|
-
readonly supportedNetworks: {
|
|
7
|
-
chainId: number;
|
|
8
|
-
rpcUrl?: string | undefined;
|
|
9
|
-
}[];
|
|
10
|
-
switchNetwork: (network: number) => void;
|
|
11
|
-
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
12
|
-
};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
const createEthereumModule = ({ store }) => ({
|
|
3
|
-
get currentNetworkId() {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
return (_b = (_a = store.ethereum) === null || _a === void 0 ? void 0 : _a.currentNetworkId) !== null && _b !== void 0 ? _b : null;
|
|
6
|
-
},
|
|
7
|
-
get supportedNetworks() {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
return (_b = (_a = store.ethereum) === null || _a === void 0 ? void 0 : _a.supportedNetworks) !== null && _b !== void 0 ? _b : [];
|
|
10
|
-
},
|
|
11
|
-
switchNetwork: (network) => {
|
|
12
|
-
store.switchEthereumNetwork(network);
|
|
13
|
-
},
|
|
14
|
-
get wallets() {
|
|
15
|
-
var _a;
|
|
16
|
-
return (_a = store.wallets.filter(({ chain }) => chain === 'EVM')) !== null && _a !== void 0 ? _a : [];
|
|
17
|
-
},
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
export { createEthereumModule };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createEthereumModule } from './createEthereumModule';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
const createSolanaModule = ({ store }) => ({
|
|
7
|
-
get currentNetwork() {
|
|
8
|
-
var _a, _b;
|
|
9
|
-
return (_b = (_a = store.solana) === null || _a === void 0 ? void 0 : _a.currentNetwork) !== null && _b !== void 0 ? _b : null;
|
|
10
|
-
},
|
|
11
|
-
get wallets() {
|
|
12
|
-
var _a;
|
|
13
|
-
return (_a = store.wallets.filter(({ chain }) => chain === 'SOL')) !== null && _a !== void 0 ? _a : [];
|
|
14
|
-
},
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
exports.createSolanaModule = createSolanaModule;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { ClientStore } from '../../store';
|
|
2
|
-
type CreateSolanaModuleProps = {
|
|
3
|
-
store: ClientStore;
|
|
4
|
-
};
|
|
5
|
-
export declare const createSolanaModule: ({ store }: CreateSolanaModuleProps) => {
|
|
6
|
-
readonly currentNetwork: string | null;
|
|
7
|
-
readonly wallets: import("dist/packages/types/src").BaseWallet[];
|
|
8
|
-
};
|
|
9
|
-
export {};
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
const createSolanaModule = ({ store }) => ({
|
|
3
|
-
get currentNetwork() {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
return (_b = (_a = store.solana) === null || _a === void 0 ? void 0 : _a.currentNetwork) !== null && _b !== void 0 ? _b : null;
|
|
6
|
-
},
|
|
7
|
-
get wallets() {
|
|
8
|
-
var _a;
|
|
9
|
-
return (_a = store.wallets.filter(({ chain }) => chain === 'SOL')) !== null && _a !== void 0 ? _a : [];
|
|
10
|
-
},
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
export { createSolanaModule };
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createSolanaModule } from './createSolanaModule';
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
'use strict';
|
|
3
|
-
|
|
4
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
-
|
|
6
|
-
var store = require('@dynamic-labs/store');
|
|
7
|
-
var logger = require('../constants/logger.cjs');
|
|
8
|
-
|
|
9
|
-
const createClientStore = ({ environmentId, storage = localStorage, }) => {
|
|
10
|
-
const store$1 = store.persist({
|
|
11
|
-
name: `global-wallet-client-${environmentId}`,
|
|
12
|
-
partialize: (state) => state,
|
|
13
|
-
storage,
|
|
14
|
-
store: store.createStore(() => ({
|
|
15
|
-
connection: null,
|
|
16
|
-
ethereum: null,
|
|
17
|
-
solana: null,
|
|
18
|
-
wallets: [],
|
|
19
|
-
})),
|
|
20
|
-
});
|
|
21
|
-
return {
|
|
22
|
-
/**
|
|
23
|
-
* Resets the store to its initial state
|
|
24
|
-
*/
|
|
25
|
-
clear: () => {
|
|
26
|
-
logger.logger.logVerboseTroubleshootingMessage('clear store');
|
|
27
|
-
store$1.setState(store$1.getInitialState());
|
|
28
|
-
},
|
|
29
|
-
/**
|
|
30
|
-
* Get all Ethereum state from the current connection
|
|
31
|
-
*/
|
|
32
|
-
get ethereum() {
|
|
33
|
-
this.getActiveConnection();
|
|
34
|
-
return store$1.getState().ethereum;
|
|
35
|
-
},
|
|
36
|
-
/**
|
|
37
|
-
* Retrieves the current active connection if it exists and hasn't expired
|
|
38
|
-
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
39
|
-
*/
|
|
40
|
-
getActiveConnection: () => {
|
|
41
|
-
const { connection } = store$1.getState();
|
|
42
|
-
if (!connection) {
|
|
43
|
-
return null;
|
|
44
|
-
}
|
|
45
|
-
if (connection.expiresAt < Date.now()) {
|
|
46
|
-
logger.logger.logVerboseTroubleshootingMessage('Connection expired');
|
|
47
|
-
// Clear the connection if it has expired
|
|
48
|
-
store$1.setState(store$1.getInitialState());
|
|
49
|
-
return null;
|
|
50
|
-
}
|
|
51
|
-
return connection;
|
|
52
|
-
},
|
|
53
|
-
/**
|
|
54
|
-
* Updates current connection, wallets
|
|
55
|
-
* Used when the popup confirm a connection
|
|
56
|
-
* @param {GlobalWalletConnection | null} connection - The connection to store, or null to clear it
|
|
57
|
-
*/
|
|
58
|
-
setInitialConnectionState: ({ connection, wallets, ethereum, solana, }) => {
|
|
59
|
-
logger.logger.logVerboseTroubleshootingMessage('setInitialConnectionState', {
|
|
60
|
-
connection,
|
|
61
|
-
ethereum,
|
|
62
|
-
solana,
|
|
63
|
-
wallets,
|
|
64
|
-
});
|
|
65
|
-
store$1.setState({ connection, ethereum, solana, wallets });
|
|
66
|
-
},
|
|
67
|
-
/**
|
|
68
|
-
* Get all Solana wallets connected to the current connection
|
|
69
|
-
*/
|
|
70
|
-
get solana() {
|
|
71
|
-
this.getActiveConnection();
|
|
72
|
-
return store$1.getState().solana;
|
|
73
|
-
},
|
|
74
|
-
/**
|
|
75
|
-
* Switches the Ethereum network
|
|
76
|
-
* @param {number} networkId - The network ID to switch to
|
|
77
|
-
*/
|
|
78
|
-
switchEthereumNetwork(networkId) {
|
|
79
|
-
this.getActiveConnection();
|
|
80
|
-
const { ethereum } = store$1.getState();
|
|
81
|
-
if (!ethereum) {
|
|
82
|
-
throw new Error('No connection found');
|
|
83
|
-
}
|
|
84
|
-
store$1.setState({
|
|
85
|
-
ethereum: Object.assign(Object.assign({}, ethereum), { currentNetworkId: networkId }),
|
|
86
|
-
});
|
|
87
|
-
logger.logger.logVerboseTroubleshootingMessage('switchEthereumNetwork', {
|
|
88
|
-
from: Object.assign({}, ethereum),
|
|
89
|
-
to: store$1.getState().ethereum,
|
|
90
|
-
});
|
|
91
|
-
},
|
|
92
|
-
/**
|
|
93
|
-
* Get all wallets connected to the current connection
|
|
94
|
-
*/
|
|
95
|
-
get wallets() {
|
|
96
|
-
this.getActiveConnection();
|
|
97
|
-
return store$1.getState().wallets;
|
|
98
|
-
},
|
|
99
|
-
};
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
exports.createClientStore = createClientStore;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { BaseWallet, GlobalWalletConnection } from '@dynamic-labs/types';
|
|
2
|
-
type CreateClientStoreProps = {
|
|
3
|
-
storage?: Storage;
|
|
4
|
-
environmentId: string;
|
|
5
|
-
};
|
|
6
|
-
type ClientStoreState = {
|
|
7
|
-
/**
|
|
8
|
-
* Connection data between client and popup
|
|
9
|
-
*/
|
|
10
|
-
connection: GlobalWalletConnection | null;
|
|
11
|
-
/**
|
|
12
|
-
* All EVM and Solana wallets connected to this Dapp
|
|
13
|
-
*/
|
|
14
|
-
wallets: BaseWallet[];
|
|
15
|
-
/**
|
|
16
|
-
* Ethereum specific state
|
|
17
|
-
*/
|
|
18
|
-
ethereum: {
|
|
19
|
-
supportedNetworks: {
|
|
20
|
-
chainId: number;
|
|
21
|
-
rpcUrl?: string;
|
|
22
|
-
}[];
|
|
23
|
-
currentNetworkId: number;
|
|
24
|
-
} | null;
|
|
25
|
-
/**
|
|
26
|
-
* Solana specific state
|
|
27
|
-
*/
|
|
28
|
-
solana: {
|
|
29
|
-
currentNetwork: string;
|
|
30
|
-
} | null;
|
|
31
|
-
};
|
|
32
|
-
export declare const createClientStore: ({ environmentId, storage, }: CreateClientStoreProps) => {
|
|
33
|
-
/**
|
|
34
|
-
* Resets the store to its initial state
|
|
35
|
-
*/
|
|
36
|
-
clear: () => void;
|
|
37
|
-
/**
|
|
38
|
-
* Get all Ethereum state from the current connection
|
|
39
|
-
*/
|
|
40
|
-
readonly ethereum: {
|
|
41
|
-
supportedNetworks: {
|
|
42
|
-
chainId: number;
|
|
43
|
-
rpcUrl?: string;
|
|
44
|
-
}[];
|
|
45
|
-
currentNetworkId: number;
|
|
46
|
-
} | null;
|
|
47
|
-
/**
|
|
48
|
-
* Retrieves the current active connection if it exists and hasn't expired
|
|
49
|
-
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
50
|
-
*/
|
|
51
|
-
getActiveConnection: () => GlobalWalletConnection | null;
|
|
52
|
-
/**
|
|
53
|
-
* Updates current connection, wallets
|
|
54
|
-
* Used when the popup confirm a connection
|
|
55
|
-
* @param {GlobalWalletConnection | null} connection - The connection to store, or null to clear it
|
|
56
|
-
*/
|
|
57
|
-
setInitialConnectionState: ({ connection, wallets, ethereum, solana, }: Pick<ClientStoreState, 'connection' | 'wallets' | 'ethereum' | 'solana'>) => void;
|
|
58
|
-
/**
|
|
59
|
-
* Get all Solana wallets connected to the current connection
|
|
60
|
-
*/
|
|
61
|
-
readonly solana: {
|
|
62
|
-
currentNetwork: string;
|
|
63
|
-
} | null;
|
|
64
|
-
/**
|
|
65
|
-
* Switches the Ethereum network
|
|
66
|
-
* @param {number} networkId - The network ID to switch to
|
|
67
|
-
*/
|
|
68
|
-
switchEthereumNetwork(networkId: number): void;
|
|
69
|
-
/**
|
|
70
|
-
* Get all wallets connected to the current connection
|
|
71
|
-
*/
|
|
72
|
-
readonly wallets: BaseWallet[];
|
|
73
|
-
};
|
|
74
|
-
export type ClientStore = ReturnType<typeof createClientStore>;
|
|
75
|
-
export {};
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import { persist, createStore } from '@dynamic-labs/store';
|
|
3
|
-
import { logger } from '../constants/logger.js';
|
|
4
|
-
|
|
5
|
-
const createClientStore = ({ environmentId, storage = localStorage, }) => {
|
|
6
|
-
const store = persist({
|
|
7
|
-
name: `global-wallet-client-${environmentId}`,
|
|
8
|
-
partialize: (state) => state,
|
|
9
|
-
storage,
|
|
10
|
-
store: createStore(() => ({
|
|
11
|
-
connection: null,
|
|
12
|
-
ethereum: null,
|
|
13
|
-
solana: null,
|
|
14
|
-
wallets: [],
|
|
15
|
-
})),
|
|
16
|
-
});
|
|
17
|
-
return {
|
|
18
|
-
/**
|
|
19
|
-
* Resets the store to its initial state
|
|
20
|
-
*/
|
|
21
|
-
clear: () => {
|
|
22
|
-
logger.logVerboseTroubleshootingMessage('clear store');
|
|
23
|
-
store.setState(store.getInitialState());
|
|
24
|
-
},
|
|
25
|
-
/**
|
|
26
|
-
* Get all Ethereum state from the current connection
|
|
27
|
-
*/
|
|
28
|
-
get ethereum() {
|
|
29
|
-
this.getActiveConnection();
|
|
30
|
-
return store.getState().ethereum;
|
|
31
|
-
},
|
|
32
|
-
/**
|
|
33
|
-
* Retrieves the current active connection if it exists and hasn't expired
|
|
34
|
-
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
35
|
-
*/
|
|
36
|
-
getActiveConnection: () => {
|
|
37
|
-
const { connection } = store.getState();
|
|
38
|
-
if (!connection) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
if (connection.expiresAt < Date.now()) {
|
|
42
|
-
logger.logVerboseTroubleshootingMessage('Connection expired');
|
|
43
|
-
// Clear the connection if it has expired
|
|
44
|
-
store.setState(store.getInitialState());
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
return connection;
|
|
48
|
-
},
|
|
49
|
-
/**
|
|
50
|
-
* Updates current connection, wallets
|
|
51
|
-
* Used when the popup confirm a connection
|
|
52
|
-
* @param {GlobalWalletConnection | null} connection - The connection to store, or null to clear it
|
|
53
|
-
*/
|
|
54
|
-
setInitialConnectionState: ({ connection, wallets, ethereum, solana, }) => {
|
|
55
|
-
logger.logVerboseTroubleshootingMessage('setInitialConnectionState', {
|
|
56
|
-
connection,
|
|
57
|
-
ethereum,
|
|
58
|
-
solana,
|
|
59
|
-
wallets,
|
|
60
|
-
});
|
|
61
|
-
store.setState({ connection, ethereum, solana, wallets });
|
|
62
|
-
},
|
|
63
|
-
/**
|
|
64
|
-
* Get all Solana wallets connected to the current connection
|
|
65
|
-
*/
|
|
66
|
-
get solana() {
|
|
67
|
-
this.getActiveConnection();
|
|
68
|
-
return store.getState().solana;
|
|
69
|
-
},
|
|
70
|
-
/**
|
|
71
|
-
* Switches the Ethereum network
|
|
72
|
-
* @param {number} networkId - The network ID to switch to
|
|
73
|
-
*/
|
|
74
|
-
switchEthereumNetwork(networkId) {
|
|
75
|
-
this.getActiveConnection();
|
|
76
|
-
const { ethereum } = store.getState();
|
|
77
|
-
if (!ethereum) {
|
|
78
|
-
throw new Error('No connection found');
|
|
79
|
-
}
|
|
80
|
-
store.setState({
|
|
81
|
-
ethereum: Object.assign(Object.assign({}, ethereum), { currentNetworkId: networkId }),
|
|
82
|
-
});
|
|
83
|
-
logger.logVerboseTroubleshootingMessage('switchEthereumNetwork', {
|
|
84
|
-
from: Object.assign({}, ethereum),
|
|
85
|
-
to: store.getState().ethereum,
|
|
86
|
-
});
|
|
87
|
-
},
|
|
88
|
-
/**
|
|
89
|
-
* Get all wallets connected to the current connection
|
|
90
|
-
*/
|
|
91
|
-
get wallets() {
|
|
92
|
-
this.getActiveConnection();
|
|
93
|
-
return store.getState().wallets;
|
|
94
|
-
},
|
|
95
|
-
};
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export { createClientStore };
|
package/src/lib/store/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { createClientStore, type ClientStore } from './createClientStore';
|