@dynamic-labs/global-wallet-client 4.14.0 → 4.15.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 +22 -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
|
@@ -8,7 +8,7 @@ import { getCenteredPopupFeatures } from '../getCenteredPopupFeatures/getCentere
|
|
|
8
8
|
import { PopupClosedError } from '../../errors/PopupClosedError.js';
|
|
9
9
|
import { logger } from '../../constants/logger.js';
|
|
10
10
|
|
|
11
|
-
const createPopupOpener = ({ environmentId, popupUrl, popupWidth = 420, popupHeight = 640,
|
|
11
|
+
const createPopupOpener = ({ environmentId, popupUrl, popupWidth = 420, popupHeight = 640, popupActionTimeout = 1000, // Wait page up to 1 second for new actions before closing
|
|
12
12
|
onError, }) => {
|
|
13
13
|
let popup = null;
|
|
14
14
|
let didOpenPopup = false;
|
|
@@ -20,7 +20,7 @@ onError, }) => {
|
|
|
20
20
|
didOpenPopup = false;
|
|
21
21
|
lastActionId = null;
|
|
22
22
|
};
|
|
23
|
-
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, pathname, }) {
|
|
23
|
+
return (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, pathname, connection, }) {
|
|
24
24
|
logger.logVerboseTroubleshootingMessage('new popup action', {
|
|
25
25
|
params,
|
|
26
26
|
pathname,
|
|
@@ -29,7 +29,6 @@ onError, }) => {
|
|
|
29
29
|
const actionId = new Date().getTime();
|
|
30
30
|
lastActionId = actionId;
|
|
31
31
|
const popupFinalUrl = new URL(popupUrl);
|
|
32
|
-
const activeConnection = store.getActiveConnection();
|
|
33
32
|
const resultDeferredPromise = new DeferredPromise();
|
|
34
33
|
// Setup popup URL and data
|
|
35
34
|
popupFinalUrl.hash = `/${pathname}`;
|
|
@@ -46,15 +45,15 @@ onError, }) => {
|
|
|
46
45
|
}
|
|
47
46
|
// Encrypt params if active connection is present
|
|
48
47
|
if (params) {
|
|
49
|
-
yield mergeAndEncryptParams(popupFinalUrl, params,
|
|
48
|
+
yield mergeAndEncryptParams(popupFinalUrl, params, connection);
|
|
50
49
|
}
|
|
51
50
|
if (popup === null) {
|
|
52
51
|
throw new Error('Failed to open popup');
|
|
53
52
|
}
|
|
54
53
|
waitForPopupResponse({
|
|
55
54
|
decode: (data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
56
|
-
if (
|
|
57
|
-
const decryptedData = yield decryptMessage(
|
|
55
|
+
if (connection && isEncryptedMessage(data)) {
|
|
56
|
+
const decryptedData = yield decryptMessage(connection.sharedSecret, data.encryptedMessage, data.iv);
|
|
58
57
|
return JSON.parse(decryptedData);
|
|
59
58
|
}
|
|
60
59
|
return data;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { createPopupOpener } from './createPopupOpener';
|
|
1
|
+
export { createPopupOpener, type PopupOpener } from './createPopupOpener';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var clearStore = require('../clearStore/clearStore.cjs');
|
|
14
|
+
var getActiveConnection = require('../getActiveConnection/getActiveConnection.cjs');
|
|
15
|
+
var getCore = require('../../client/getCore/getCore.cjs');
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Disconnects the global wallet from the dapp.
|
|
19
|
+
*
|
|
20
|
+
* @param client - The global wallet client.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { Wallet } from 'wallet';
|
|
25
|
+
*
|
|
26
|
+
* disconnect(wallet);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const disconnect = (client) => {
|
|
30
|
+
const core = getCore.getCore(client);
|
|
31
|
+
if (getActiveConnection.getActiveConnection(client) === null) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
clearStore.clearStore(client);
|
|
35
|
+
core.eventEmitter.emit('disconnect');
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.disconnect = disconnect;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { GlobalWalletClient } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Disconnects the global wallet from the dapp.
|
|
4
|
+
*
|
|
5
|
+
* @param client - The global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { Wallet } from 'wallet';
|
|
10
|
+
*
|
|
11
|
+
* disconnect(wallet);
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare const disconnect: (client: GlobalWalletClient) => void;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import 'eventemitter3';
|
|
3
|
+
import '@dynamic-labs/logger';
|
|
4
|
+
import '@dynamic-labs/store';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../constants/logger.js';
|
|
8
|
+
import '../../errors/DisconnectError.js';
|
|
9
|
+
import { clearStore } from '../clearStore/clearStore.js';
|
|
10
|
+
import { getActiveConnection } from '../getActiveConnection/getActiveConnection.js';
|
|
11
|
+
import { getCore } from '../../client/getCore/getCore.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Disconnects the global wallet from the dapp.
|
|
15
|
+
*
|
|
16
|
+
* @param client - The global wallet client.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Wallet } from 'wallet';
|
|
21
|
+
*
|
|
22
|
+
* disconnect(wallet);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const disconnect = (client) => {
|
|
26
|
+
const core = getCore(client);
|
|
27
|
+
if (getActiveConnection(client) === null) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
clearStore(client);
|
|
31
|
+
core.eventEmitter.emit('disconnect');
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { disconnect };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { disconnect } from './disconnect';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var clearStore = require('../clearStore/clearStore.cjs');
|
|
14
|
+
var getCore = require('../../client/getCore/getCore.cjs');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Retrieves the current active connection if it exists and hasn't expired
|
|
18
|
+
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
19
|
+
*/
|
|
20
|
+
const getActiveConnection = (client) => {
|
|
21
|
+
const core = getCore.getCore(client);
|
|
22
|
+
const { connection } = core.store.getState();
|
|
23
|
+
if (!connection) {
|
|
24
|
+
return null;
|
|
25
|
+
}
|
|
26
|
+
if (connection.expiresAt < Date.now()) {
|
|
27
|
+
core.logger.logVerboseTroubleshootingMessage('Connection expired');
|
|
28
|
+
// Clear the connection if it has expired
|
|
29
|
+
clearStore.clearStore(client);
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
return connection;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.getActiveConnection = getActiveConnection;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { GlobalWalletClient } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Retrieves the current active connection if it exists and hasn't expired
|
|
4
|
+
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
5
|
+
*/
|
|
6
|
+
export declare const getActiveConnection: (client: GlobalWalletClient) => import("dist/packages/types/src").GlobalWalletConnection | null;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import 'eventemitter3';
|
|
3
|
+
import '@dynamic-labs/logger';
|
|
4
|
+
import '@dynamic-labs/store';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../constants/logger.js';
|
|
8
|
+
import '../../errors/DisconnectError.js';
|
|
9
|
+
import { clearStore } from '../clearStore/clearStore.js';
|
|
10
|
+
import { getCore } from '../../client/getCore/getCore.js';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves the current active connection if it exists and hasn't expired
|
|
14
|
+
* @returns {Connection | null} The current connection or null if no connection exists or it has expired
|
|
15
|
+
*/
|
|
16
|
+
const getActiveConnection = (client) => {
|
|
17
|
+
const core = getCore(client);
|
|
18
|
+
const { connection } = core.store.getState();
|
|
19
|
+
if (!connection) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
if (connection.expiresAt < Date.now()) {
|
|
23
|
+
core.logger.logVerboseTroubleshootingMessage('Connection expired');
|
|
24
|
+
// Clear the connection if it has expired
|
|
25
|
+
clearStore(client);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
return connection;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export { getActiveConnection };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getActiveConnection } from './getActiveConnection';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var getCore = require('../../client/getCore/getCore.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the current Ethereum network ID that all wallets are connected to.
|
|
17
|
+
*
|
|
18
|
+
* @param client - The global wallet client.
|
|
19
|
+
*
|
|
20
|
+
* @returns The current Ethereum network ID if connected, otherwise `null`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { Wallet } from 'wallet';
|
|
25
|
+
*
|
|
26
|
+
* const currentEthereumNetworkId = getCurrentEthereumNetworkId(Wallet);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const getCurrentEthereumNetworkId = (client) => {
|
|
30
|
+
const core = getCore.getCore(client);
|
|
31
|
+
const { ethereum } = core.store.getState();
|
|
32
|
+
if (!ethereum) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return ethereum.currentNetworkId;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.getCurrentEthereumNetworkId = getCurrentEthereumNetworkId;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GlobalWalletClient } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current Ethereum network ID that all wallets are connected to.
|
|
4
|
+
*
|
|
5
|
+
* @param client - The global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @returns The current Ethereum network ID if connected, otherwise `null`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Wallet } from 'wallet';
|
|
12
|
+
*
|
|
13
|
+
* const currentEthereumNetworkId = getCurrentEthereumNetworkId(Wallet);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCurrentEthereumNetworkId: (client: GlobalWalletClient) => number | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import 'eventemitter3';
|
|
3
|
+
import '@dynamic-labs/logger';
|
|
4
|
+
import '@dynamic-labs/store';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../constants/logger.js';
|
|
8
|
+
import '../../errors/DisconnectError.js';
|
|
9
|
+
import { getCore } from '../../client/getCore/getCore.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets the current Ethereum network ID that all wallets are connected to.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The global wallet client.
|
|
15
|
+
*
|
|
16
|
+
* @returns The current Ethereum network ID if connected, otherwise `null`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Wallet } from 'wallet';
|
|
21
|
+
*
|
|
22
|
+
* const currentEthereumNetworkId = getCurrentEthereumNetworkId(Wallet);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const getCurrentEthereumNetworkId = (client) => {
|
|
26
|
+
const core = getCore(client);
|
|
27
|
+
const { ethereum } = core.store.getState();
|
|
28
|
+
if (!ethereum) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return ethereum.currentNetworkId;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { getCurrentEthereumNetworkId };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCurrentEthereumNetworkId } from './getCurrentEthereumNetworkId';
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var getCore = require('../../client/getCore/getCore.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the current Solana network that all wallets are connected to.
|
|
17
|
+
*
|
|
18
|
+
* @param client - The global wallet client.
|
|
19
|
+
*
|
|
20
|
+
* @returns The current Solana network if connected, otherwise `null`.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* import { Wallet } from 'wallet';
|
|
25
|
+
*
|
|
26
|
+
* const currentSolanaNetwork = getCurrentSolanaNetwork(Wallet);
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
const getCurrentSolanaNetwork = (client) => {
|
|
30
|
+
const core = getCore.getCore(client);
|
|
31
|
+
const { solana } = core.store.getState();
|
|
32
|
+
if (!solana) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
return solana.currentNetwork;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
exports.getCurrentSolanaNetwork = getCurrentSolanaNetwork;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { GlobalWalletClient } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current Solana network that all wallets are connected to.
|
|
4
|
+
*
|
|
5
|
+
* @param client - The global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @returns The current Solana network if connected, otherwise `null`.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Wallet } from 'wallet';
|
|
12
|
+
*
|
|
13
|
+
* const currentSolanaNetwork = getCurrentSolanaNetwork(Wallet);
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare const getCurrentSolanaNetwork: (client: GlobalWalletClient) => string | null;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import 'eventemitter3';
|
|
3
|
+
import '@dynamic-labs/logger';
|
|
4
|
+
import '@dynamic-labs/store';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../constants/logger.js';
|
|
8
|
+
import '../../errors/DisconnectError.js';
|
|
9
|
+
import { getCore } from '../../client/getCore/getCore.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets the current Solana network that all wallets are connected to.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The global wallet client.
|
|
15
|
+
*
|
|
16
|
+
* @returns The current Solana network if connected, otherwise `null`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { Wallet } from 'wallet';
|
|
21
|
+
*
|
|
22
|
+
* const currentSolanaNetwork = getCurrentSolanaNetwork(Wallet);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
const getCurrentSolanaNetwork = (client) => {
|
|
26
|
+
const core = getCore(client);
|
|
27
|
+
const { solana } = core.store.getState();
|
|
28
|
+
if (!solana) {
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
return solana.currentNetwork;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { getCurrentSolanaNetwork };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getCurrentSolanaNetwork } from './getCurrentSolanaNetwork';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Gets all Ethereum wallets from the global wallet client.
|
|
10
|
+
*
|
|
11
|
+
* @param client - The global wallet client.
|
|
12
|
+
*
|
|
13
|
+
* @returns All Ethereum wallets.
|
|
14
|
+
*/
|
|
15
|
+
const getEthereumWallets = (client) => client.wallets.filter(isEthereumWallet.isEthereumWallet);
|
|
16
|
+
|
|
17
|
+
exports.getEthereumWallets = getEthereumWallets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseWallet } from '@dynamic-labs/types';
|
|
2
|
+
import { GlobalWalletClient } from '../../client';
|
|
3
|
+
/**
|
|
4
|
+
* Gets all Ethereum wallets from the global wallet client.
|
|
5
|
+
*
|
|
6
|
+
* @param client - The global wallet client.
|
|
7
|
+
*
|
|
8
|
+
* @returns All Ethereum wallets.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getEthereumWallets: (client: GlobalWalletClient) => BaseWallet[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { isEthereumWallet } from '../isEthereumWallet/isEthereumWallet.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gets all Ethereum wallets from the global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @param client - The global wallet client.
|
|
8
|
+
*
|
|
9
|
+
* @returns All Ethereum wallets.
|
|
10
|
+
*/
|
|
11
|
+
const getEthereumWallets = (client) => client.wallets.filter(isEthereumWallet);
|
|
12
|
+
|
|
13
|
+
export { getEthereumWallets };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getEthereumWallets } from './getEthereumWallets';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var isSolanaWallet = require('../isSolanaWallet/isSolanaWallet.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Gets all Solana wallets from the global wallet client.
|
|
10
|
+
*
|
|
11
|
+
* @param client - The global wallet client.
|
|
12
|
+
*
|
|
13
|
+
* @returns All Solana wallets.
|
|
14
|
+
*/
|
|
15
|
+
const getSolanaWallets = (client) => client.wallets.filter(isSolanaWallet.isSolanaWallet);
|
|
16
|
+
|
|
17
|
+
exports.getSolanaWallets = getSolanaWallets;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { BaseWallet } from '@dynamic-labs/types';
|
|
2
|
+
import { GlobalWalletClient } from '../../client';
|
|
3
|
+
/**
|
|
4
|
+
* Gets all Solana wallets from the global wallet client.
|
|
5
|
+
*
|
|
6
|
+
* @param client - The global wallet client.
|
|
7
|
+
*
|
|
8
|
+
* @returns All Solana wallets.
|
|
9
|
+
*/
|
|
10
|
+
export declare const getSolanaWallets: (client: GlobalWalletClient) => BaseWallet[];
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { isSolanaWallet } from '../isSolanaWallet/isSolanaWallet.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Gets all Solana wallets from the global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @param client - The global wallet client.
|
|
8
|
+
*
|
|
9
|
+
* @returns All Solana wallets.
|
|
10
|
+
*/
|
|
11
|
+
const getSolanaWallets = (client) => client.wallets.filter(isSolanaWallet);
|
|
12
|
+
|
|
13
|
+
export { getSolanaWallets };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSolanaWallets } from './getSolanaWallets';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var getCore = require('../../client/getCore/getCore.cjs');
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Gets the supported Ethereum networks the global wallet supports and can switch to.
|
|
17
|
+
*
|
|
18
|
+
* @param client - The global wallet client.
|
|
19
|
+
*
|
|
20
|
+
* @returns The supported Ethereum networks.
|
|
21
|
+
*/
|
|
22
|
+
const getSupportedEthereumNetworks = (client) => {
|
|
23
|
+
const core = getCore.getCore(client);
|
|
24
|
+
const { ethereum } = core.store.getState();
|
|
25
|
+
if (!ethereum) {
|
|
26
|
+
return [];
|
|
27
|
+
}
|
|
28
|
+
return ethereum.supportedNetworks;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
exports.getSupportedEthereumNetworks = getSupportedEthereumNetworks;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ClientStoreState, GlobalWalletClient } from '../../client';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the supported Ethereum networks the global wallet supports and can switch to.
|
|
4
|
+
*
|
|
5
|
+
* @param client - The global wallet client.
|
|
6
|
+
*
|
|
7
|
+
* @returns The supported Ethereum networks.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getSupportedEthereumNetworks: (client: GlobalWalletClient) => NonNullable<ClientStoreState['ethereum']>['supportedNetworks'];
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import 'eventemitter3';
|
|
3
|
+
import '@dynamic-labs/logger';
|
|
4
|
+
import '@dynamic-labs/store';
|
|
5
|
+
import '../../../../_virtual/_tslib.js';
|
|
6
|
+
import '@dynamic-labs/utils';
|
|
7
|
+
import '../../constants/logger.js';
|
|
8
|
+
import '../../errors/DisconnectError.js';
|
|
9
|
+
import { getCore } from '../../client/getCore/getCore.js';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Gets the supported Ethereum networks the global wallet supports and can switch to.
|
|
13
|
+
*
|
|
14
|
+
* @param client - The global wallet client.
|
|
15
|
+
*
|
|
16
|
+
* @returns The supported Ethereum networks.
|
|
17
|
+
*/
|
|
18
|
+
const getSupportedEthereumNetworks = (client) => {
|
|
19
|
+
const core = getCore(client);
|
|
20
|
+
const { ethereum } = core.store.getState();
|
|
21
|
+
if (!ethereum) {
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
return ethereum.supportedNetworks;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { getSupportedEthereumNetworks };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSupportedEthereumNetworks } from './getSupportedEthereumNetworks';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('eventemitter3');
|
|
7
|
+
require('@dynamic-labs/logger');
|
|
8
|
+
require('@dynamic-labs/store');
|
|
9
|
+
require('../../../../_virtual/_tslib.cjs');
|
|
10
|
+
require('@dynamic-labs/utils');
|
|
11
|
+
require('../../constants/logger.cjs');
|
|
12
|
+
require('../../errors/DisconnectError.cjs');
|
|
13
|
+
var getClient = require('../../client/getClient/getClient.cjs');
|
|
14
|
+
var isEthereumWallet = require('../isEthereumWallet/isEthereumWallet.cjs');
|
|
15
|
+
var isSolanaWallet = require('../isSolanaWallet/isSolanaWallet.cjs');
|
|
16
|
+
var getCurrentEthereumNetworkId = require('../getCurrentEthereumNetworkId/getCurrentEthereumNetworkId.cjs');
|
|
17
|
+
var getCurrentSolanaNetwork = require('../getCurrentSolanaNetwork/getCurrentSolanaNetwork.cjs');
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Gets the current network of a wallet.
|
|
21
|
+
*
|
|
22
|
+
* @param wallet - The wallet to get the network of.
|
|
23
|
+
*
|
|
24
|
+
* @returns The current network of the wallet.
|
|
25
|
+
*/
|
|
26
|
+
const getWalletNetwork = (wallet) => {
|
|
27
|
+
const client = getClient.getClient(wallet);
|
|
28
|
+
if (isEthereumWallet.isEthereumWallet(wallet)) {
|
|
29
|
+
return getCurrentEthereumNetworkId.getCurrentEthereumNetworkId(client);
|
|
30
|
+
}
|
|
31
|
+
if (isSolanaWallet.isSolanaWallet(wallet)) {
|
|
32
|
+
return getCurrentSolanaNetwork.getCurrentSolanaNetwork(client);
|
|
33
|
+
}
|
|
34
|
+
throw new Error('Unsupported wallet type');
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
exports.getWalletNetwork = getWalletNetwork;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseWallet } from '@dynamic-labs/types';
|
|
2
|
+
/**
|
|
3
|
+
* Gets the current network of a wallet.
|
|
4
|
+
*
|
|
5
|
+
* @param wallet - The wallet to get the network of.
|
|
6
|
+
*
|
|
7
|
+
* @returns The current network of the wallet.
|
|
8
|
+
*/
|
|
9
|
+
export declare const getWalletNetwork: (wallet: BaseWallet) => number | string | null;
|