@dynamic-labs/multi-wallet 0.17.0-RC.7 → 0.17.0-RC.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/package.json +8 -14
- package/src/index.cjs +0 -57
- package/src/index.d.ts +0 -13
- package/src/index.js +1 -18
- package/src/multi-wallet.cjs +27 -87
- package/src/multi-wallet.d.ts +0 -1
- package/src/multi-wallet.js +25 -84
- package/src/types.d.ts +2 -23
- package/src/utils/getApiProviders.cjs +15 -0
- package/src/utils/getApiProviders.d.ts +10 -0
- package/src/utils/getApiProviders.js +11 -0
- package/src/utils/message.cjs +3 -4
- package/src/utils/message.js +1 -2
- package/src/wallets/algorand/MyAlgoWalletConnector.cjs +3 -3
- package/src/wallets/algorand/MyAlgoWalletConnector.js +1 -1
- package/src/wallets/constants.cjs +0 -2
- package/src/wallets/constants.js +1 -2
- package/src/wallets/cosmos/KeplrWalletConnect.cjs +16 -17
- package/src/wallets/cosmos/KeplrWalletConnect.d.ts +9 -5
- package/src/wallets/cosmos/KeplrWalletConnect.js +9 -10
- package/src/wallets/cosmos/KeplrWalletConnector.cjs +13 -5
- package/src/wallets/cosmos/KeplrWalletConnector.d.ts +6 -4
- package/src/wallets/cosmos/KeplrWalletConnector.js +13 -5
- package/src/wallets/cosmos/wcClient.lib.cjs +141 -0
- package/src/wallets/{clients/walletConnect/walletConnect.d.ts → cosmos/wcClient.lib.d.ts} +8 -11
- package/src/wallets/cosmos/wcClient.lib.js +126 -0
- package/src/wallets/flow/FlowWalletConnector.cjs +7 -8
- package/src/wallets/flow/FlowWalletConnector.js +2 -3
- package/src/wallets/flow/lilico.cjs +2 -2
- package/src/wallets/flow/lilico.js +1 -1
- package/src/wallets/solana/CoinbaseSolana.cjs +8 -11
- package/src/wallets/solana/CoinbaseSolana.d.ts +1 -3
- package/src/wallets/solana/CoinbaseSolana.js +8 -11
- package/src/wallets/solana/glow.cjs +8 -11
- package/src/wallets/solana/glow.d.ts +1 -3
- package/src/wallets/solana/glow.js +8 -11
- package/src/wallets/solana/injected/BraveSol.cjs +2 -1
- package/src/wallets/solana/injected/BraveSol.js +2 -1
- package/src/wallets/solana/phantom-ledger.cjs +5 -5
- package/src/wallets/solana/phantom-ledger.js +1 -1
- package/src/wallets/solana/phantom.cjs +11 -15
- package/src/wallets/solana/phantom.d.ts +1 -3
- package/src/wallets/solana/phantom.js +9 -13
- package/src/wallets/solana/slope.cjs +4 -4
- package/src/wallets/solana/slope.js +1 -1
- package/src/wallets/solana/solProviderHelper.cjs +49 -51
- package/src/wallets/solana/solProviderHelper.d.ts +20 -20
- package/src/wallets/solana/solProviderHelper.js +48 -50
- package/src/wallets/solana/solWalletConnector.cjs +2 -2
- package/src/wallets/solana/solWalletConnector.js +1 -1
- package/src/wallets/solana/solflare.cjs +6 -7
- package/src/wallets/solana/solflare.d.ts +0 -2
- package/src/wallets/solana/solflare.js +6 -7
- package/src/wallets/starknet/braavos.cjs +2 -2
- package/src/wallets/starknet/braavos.js +1 -1
- package/src/wallets/starknet/starknetWalletConnector.cjs +5 -6
- package/src/wallets/starknet/starknetWalletConnector.js +2 -3
- package/src/wallets/window.d.ts +10 -22
- package/src/errors.cjs +0 -66
- package/src/errors.d.ts +0 -34
- package/src/errors.js +0 -54
- package/src/utils/CancellablePromise/CancellablePromise.cjs +0 -33
- package/src/utils/CancellablePromise/CancellablePromise.d.ts +0 -9
- package/src/utils/CancellablePromise/CancellablePromise.js +0 -29
- package/src/utils/CancellablePromise/index.d.ts +0 -1
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.cjs +0 -54
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.d.ts +0 -3
- package/src/utils/assignConfirmationScreenToProvider/assignConfirmationScreenToProvider.js +0 -50
- package/src/utils/assignConfirmationScreenToProvider/index.d.ts +0 -1
- package/src/utils/encoding.cjs +0 -18
- package/src/utils/encoding.d.ts +0 -4
- package/src/utils/encoding.js +0 -12
- package/src/utils/findProvider/findProvider.cjs +0 -7
- package/src/utils/findProvider/findProvider.d.ts +0 -2
- package/src/utils/findProvider/findProvider.js +0 -3
- package/src/utils/findProvider/index.d.ts +0 -1
- package/src/utils/getChainInfo/getChainInfo.cjs +0 -59
- package/src/utils/getChainInfo/getChainInfo.d.ts +0 -2
- package/src/utils/getChainInfo/getChainInfo.js +0 -55
- package/src/utils/getChainInfo/index.d.ts +0 -1
- package/src/utils/getWalletConnectorByName.cjs +0 -19
- package/src/utils/getWalletConnectorByName.d.ts +0 -2
- package/src/utils/getWalletConnectorByName.js +0 -15
- package/src/utils/isEmailOTPWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.cjs +0 -7
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.d.ts +0 -2
- package/src/utils/isEmailOTPWalletConnector/isEmailOTPWalletConnector.js +0 -3
- package/src/utils/isEmailWalletConnector/index.d.ts +0 -1
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.cjs +0 -7
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.d.ts +0 -2
- package/src/utils/isEmailWalletConnector/isEmailWalletConnector.js +0 -3
- package/src/utils/isFunction/index.d.ts +0 -1
- package/src/utils/isFunction/isFunction.cjs +0 -8
- package/src/utils/isFunction/isFunction.d.ts +0 -1
- package/src/utils/isFunction/isFunction.js +0 -4
- package/src/utils/isMobile.cjs +0 -54
- package/src/utils/isMobile.d.ts +0 -13
- package/src/utils/isMobile.js +0 -46
- package/src/utils/isSameAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.cjs +0 -9
- package/src/utils/isSameAddress/isSameAddress.d.ts +0 -1
- package/src/utils/isSameAddress/isSameAddress.js +0 -5
- package/src/utils/isSameAddress/utils/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/index.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.cjs +0 -17
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.d.ts +0 -1
- package/src/utils/isSameAddress/utils/normalizeAddress/normalizeAddress.js +0 -13
- package/src/utils/isSocialWalletConnector/index.d.ts +0 -1
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.cjs +0 -7
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.d.ts +0 -2
- package/src/utils/isSocialWalletConnector/isSocialWalletConnector.js +0 -3
- package/src/utils/isUnsupportedProviderError/index.d.ts +0 -1
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.cjs +0 -13
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.d.ts +0 -6
- package/src/utils/isUnsupportedProviderError/isUnsupportedProviderError.js +0 -9
- package/src/utils/logger.cjs +0 -9
- package/src/utils/logger.d.ts +0 -2
- package/src/utils/logger.js +0 -5
- package/src/utils/normalizeWalletName/index.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.cjs +0 -7
- package/src/utils/normalizeWalletName/normalizeWalletName.d.ts +0 -1
- package/src/utils/normalizeWalletName/normalizeWalletName.js +0 -3
- package/src/utils/shouldLowercaseAddress.cjs +0 -11
- package/src/utils/shouldLowercaseAddress.d.ts +0 -1
- package/src/utils/shouldLowercaseAddress.js +0 -7
- package/src/utils/walletConnect.cjs +0 -31
- package/src/utils/walletConnect.d.ts +0 -5
- package/src/utils/walletConnect.js +0 -27
- package/src/wallets/ProviderLookup.cjs +0 -18
- package/src/wallets/ProviderLookup.d.ts +0 -4
- package/src/wallets/ProviderLookup.js +0 -14
- package/src/wallets/clients/coinbase/coinbase.cjs +0 -73
- package/src/wallets/clients/coinbase/coinbase.d.ts +0 -6
- package/src/wallets/clients/coinbase/coinbase.js +0 -66
- package/src/wallets/clients/coinbase/index.d.ts +0 -2
- package/src/wallets/clients/coinbase/types.d.ts +0 -14
- package/src/wallets/clients/walletConnect/index.d.ts +0 -1
- package/src/wallets/clients/walletConnect/types.d.ts +0 -4
- package/src/wallets/clients/walletConnect/walletConnect.cjs +0 -250
- package/src/wallets/clients/walletConnect/walletConnect.js +0 -233
- package/src/wallets/cosmos/getKeplrConnector.cjs +0 -18
- package/src/wallets/cosmos/getKeplrConnector.d.ts +0 -6
- package/src/wallets/cosmos/getKeplrConnector.js +0 -14
- package/src/wallets/ethereum/BloctoEvm.cjs +0 -111
- package/src/wallets/ethereum/BloctoEvm.d.ts +0 -22
- package/src/wallets/ethereum/BloctoEvm.js +0 -105
- package/src/wallets/ethereum/EthWalletConnector.cjs +0 -207
- package/src/wallets/ethereum/EthWalletConnector.d.ts +0 -38
- package/src/wallets/ethereum/EthWalletConnector.js +0 -203
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.cjs +0 -63
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/EmailMagicWalletConnector.js +0 -59
- package/src/wallets/ethereum/MagicConnector/EmailMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.cjs +0 -62
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.d.ts +0 -11
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/EmailOTPMagicWalletConnector.js +0 -58
- package/src/wallets/ethereum/MagicConnector/EmailOTPMagicWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.cjs +0 -103
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.d.ts +0 -33
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/MagicClientNetworkHandler.js +0 -99
- package/src/wallets/ethereum/MagicConnector/MagicClientNetworkHandler/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.cjs +0 -56
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.d.ts +0 -12
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/MagicSocialWalletConnector.js +0 -52
- package/src/wallets/ethereum/MagicConnector/MagicSocialWalletConnector/index.d.ts +0 -1
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.cjs +0 -177
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.d.ts +0 -54
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/MagicWalletConnector.js +0 -173
- package/src/wallets/ethereum/MagicConnector/MagicWalletConnector/index.d.ts +0 -2
- package/src/wallets/ethereum/MagicConnector/index.d.ts +0 -5
- package/src/wallets/ethereum/coinbase.cjs +0 -66
- package/src/wallets/ethereum/coinbase.d.ts +0 -25
- package/src/wallets/ethereum/coinbase.js +0 -64
- package/src/wallets/ethereum/ethProviderHelper.cjs +0 -197
- package/src/wallets/ethereum/ethProviderHelper.d.ts +0 -40
- package/src/wallets/ethereum/ethProviderHelper.js +0 -193
- package/src/wallets/ethereum/evm-network.cjs +0 -20
- package/src/wallets/ethereum/evm-network.d.ts +0 -6
- package/src/wallets/ethereum/evm-network.js +0 -16
- package/src/wallets/ethereum/fortmatic.cjs +0 -76
- package/src/wallets/ethereum/fortmatic.d.ts +0 -25
- package/src/wallets/ethereum/fortmatic.js +0 -70
- package/src/wallets/ethereum/injected/BloctoInjected.cjs +0 -13
- package/src/wallets/ethereum/injected/BloctoInjected.d.ts +0 -6
- package/src/wallets/ethereum/injected/BloctoInjected.js +0 -11
- package/src/wallets/ethereum/injected/BraveEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/BraveEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/BraveEvm.js +0 -11
- package/src/wallets/ethereum/injected/Dawn.cjs +0 -13
- package/src/wallets/ethereum/injected/Dawn.d.ts +0 -6
- package/src/wallets/ethereum/injected/Dawn.js +0 -11
- package/src/wallets/ethereum/injected/ExodusEvm.cjs +0 -13
- package/src/wallets/ethereum/injected/ExodusEvm.d.ts +0 -6
- package/src/wallets/ethereum/injected/ExodusEvm.js +0 -11
- package/src/wallets/ethereum/injected/Frame.cjs +0 -13
- package/src/wallets/ethereum/injected/Frame.d.ts +0 -6
- package/src/wallets/ethereum/injected/Frame.js +0 -11
- package/src/wallets/ethereum/injected/GameStop.cjs +0 -13
- package/src/wallets/ethereum/injected/GameStop.d.ts +0 -6
- package/src/wallets/ethereum/injected/GameStop.js +0 -11
- package/src/wallets/ethereum/injected/Opera.cjs +0 -13
- package/src/wallets/ethereum/injected/Opera.d.ts +0 -6
- package/src/wallets/ethereum/injected/Opera.js +0 -11
- package/src/wallets/ethereum/injected/PhantomEvm.cjs +0 -37
- package/src/wallets/ethereum/injected/PhantomEvm.d.ts +0 -7
- package/src/wallets/ethereum/injected/PhantomEvm.js +0 -35
- package/src/wallets/ethereum/injected/Trust.cjs +0 -13
- package/src/wallets/ethereum/injected/Trust.d.ts +0 -6
- package/src/wallets/ethereum/injected/Trust.js +0 -11
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.cjs +0 -13
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.d.ts +0 -6
- package/src/wallets/ethereum/injected/UnknownInjectedWallet.js +0 -11
- package/src/wallets/ethereum/injected/Zerion.cjs +0 -13
- package/src/wallets/ethereum/injected/Zerion.d.ts +0 -6
- package/src/wallets/ethereum/injected/Zerion.js +0 -11
- package/src/wallets/ethereum/meta-mask.cjs +0 -63
- package/src/wallets/ethereum/meta-mask.d.ts +0 -26
- package/src/wallets/ethereum/meta-mask.js +0 -61
- package/src/wallets/getMobileOrInjectedWallet.cjs +0 -22
- package/src/wallets/getMobileOrInjectedWallet.d.ts +0 -9
- package/src/wallets/getMobileOrInjectedWallet.js +0 -18
- package/src/wallets/getWalletConnectConnector.cjs +0 -16
- package/src/wallets/getWalletConnectConnector.d.ts +0 -5
- package/src/wallets/getWalletConnectConnector.js +0 -12
- package/src/wallets/walletConnect/index.d.ts +0 -2
- package/src/wallets/walletConnect/walletConnect.cjs +0 -133
- package/src/wallets/walletConnect/walletConnect.d.ts +0 -34
- package/src/wallets/walletConnect/walletConnect.js +0 -127
- package/src/wallets/walletConnect/walletConnectV2.cjs +0 -268
- package/src/wallets/walletConnect/walletConnectV2.d.ts +0 -38
- package/src/wallets/walletConnect/walletConnectV2.js +0 -262
- package/src/wallets/walletConnect/zerion.d.ts +0 -6
|
@@ -1,23 +1,20 @@
|
|
|
1
1
|
import Client from '@walletconnect/client';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
2
|
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
5
|
-
import {
|
|
3
|
+
import { FetchPublicAddressOpts, PayloadParams, WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { KeplrWalletConnectV1 } from './wcClient';
|
|
6
5
|
export declare const initClient: (name: string, settings?: any) => Client;
|
|
7
|
-
/**
|
|
8
|
-
* Attach event handlers to WalletConnect events.
|
|
9
|
-
*/
|
|
10
|
-
export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => (() => void);
|
|
11
|
-
export declare const teardownWalletConnectEventListeners: (client: Client) => void;
|
|
12
6
|
/**
|
|
13
7
|
* Initialize a client from a stored session and terminate the connection.
|
|
14
8
|
*/
|
|
15
9
|
export declare const killWalletConnectSession: (client: Client) => Promise<void>;
|
|
10
|
+
/**
|
|
11
|
+
* Attach event handlers to WalletConnect events.
|
|
12
|
+
*/
|
|
13
|
+
export declare const setupWalletConnectEventListeners: (opts: WalletEventListeners, client: Client) => void;
|
|
14
|
+
export declare const teardownWalletConnectEventListeners: (client: Client) => void;
|
|
15
|
+
export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
|
|
16
16
|
export declare const getDeepLink: (uri: string, metadata: WalletSchema, { removeWCUri, }?: {
|
|
17
17
|
removeWCUri?: boolean | undefined;
|
|
18
18
|
}) => string;
|
|
19
19
|
export declare const createSession: (client: Client) => Promise<PayloadParams>;
|
|
20
|
-
export declare const useDeepLink: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => void;
|
|
21
20
|
export declare const fetchWalletConnectCosmosPublicAddress: (metadata: WalletSchema, wcClient: Client, provider: KeplrWalletConnectV1, opts: FetchPublicAddressOpts & Required<Pick<FetchPublicAddressOpts, 'chainId'>>) => Promise<string>;
|
|
22
|
-
export declare const fetchWalletConnectEVMPublicAddress: (metadata: WalletSchema, wcClient: Client, opts?: FetchPublicAddressOpts) => Promise<string | undefined>;
|
|
23
|
-
export declare const signWalletConnectPersonalMessage: (messageToSign: string, metadata: WalletSchema, client: Client, rpcProvider?: () => Promise<ethers.providers.JsonRpcProvider | undefined>) => Promise<string | undefined>;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { __awaiter } from 'tslib';
|
|
2
|
+
import Client from '@walletconnect/client';
|
|
3
|
+
import { logger, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { isMobile, isIOS } from '@dynamic-labs/utils';
|
|
5
|
+
|
|
6
|
+
const initClient = (name, settings) => {
|
|
7
|
+
const storageId = `walletconnect-${name}`;
|
|
8
|
+
const session = localStorage.getItem(storageId);
|
|
9
|
+
const clientArgs = session
|
|
10
|
+
? { session: JSON.parse(session), storageId }
|
|
11
|
+
: { bridge: 'https://bridge.walletconnect.org', storageId };
|
|
12
|
+
return new Client(Object.assign(Object.assign({}, clientArgs), settings));
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Initialize a client from a stored session and terminate the connection.
|
|
16
|
+
*/
|
|
17
|
+
const killWalletConnectSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
18
|
+
try {
|
|
19
|
+
if (client === null || client === void 0 ? void 0 : client.connected) {
|
|
20
|
+
yield client.killSession();
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
logger.debug(e);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
/**
|
|
28
|
+
* Attach event handlers to WalletConnect events.
|
|
29
|
+
*/
|
|
30
|
+
const setupWalletConnectEventListeners = (opts, client) => {
|
|
31
|
+
if (!client) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
let prevAccount;
|
|
35
|
+
let prevChain;
|
|
36
|
+
if (client.connected) {
|
|
37
|
+
// eslint-disable-next-line prefer-destructuring
|
|
38
|
+
prevAccount = client.accounts[0];
|
|
39
|
+
prevChain = client.chainId;
|
|
40
|
+
}
|
|
41
|
+
client.on('disconnect', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
yield ((_a = opts.onDisconnect) === null || _a === void 0 ? void 0 : _a.call(opts));
|
|
44
|
+
}));
|
|
45
|
+
client.on('session_update', (_, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
var _b, _c;
|
|
47
|
+
// eslint-disable-next-line prefer-destructuring
|
|
48
|
+
const { accounts, chainId } = payload.params[0];
|
|
49
|
+
const didAccountChange = !isSameAddress(prevAccount || '', accounts[0], 'eip155');
|
|
50
|
+
const didChainChange = prevChain !== chainId;
|
|
51
|
+
// eslint-disable-next-line prefer-destructuring
|
|
52
|
+
prevAccount = accounts[0];
|
|
53
|
+
prevChain = chainId;
|
|
54
|
+
if (didAccountChange) {
|
|
55
|
+
yield ((_b = opts.onAccountChange) === null || _b === void 0 ? void 0 : _b.call(opts, accounts));
|
|
56
|
+
}
|
|
57
|
+
if (didChainChange) {
|
|
58
|
+
yield ((_c = opts.onChainChange) === null || _c === void 0 ? void 0 : _c.call(opts, String(chainId)));
|
|
59
|
+
}
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
const teardownWalletConnectEventListeners = (client) => {
|
|
63
|
+
client.off('disconnect');
|
|
64
|
+
client.off('session_update');
|
|
65
|
+
};
|
|
66
|
+
const useDeepLink = (metadata, wcClient, opts) => {
|
|
67
|
+
var _a, _b, _c;
|
|
68
|
+
const deepLink = getDeepLink(wcClient.uri, metadata);
|
|
69
|
+
if (isMobile()) {
|
|
70
|
+
window.location.href = deepLink;
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
if ((_a = metadata === null || metadata === void 0 ? void 0 : metadata.desktop) === null || _a === void 0 ? void 0 : _a.native) {
|
|
74
|
+
(_b = opts === null || opts === void 0 ? void 0 : opts.onDesktopUri) === null || _b === void 0 ? void 0 : _b.call(opts, deepLink);
|
|
75
|
+
}
|
|
76
|
+
(_c = opts === null || opts === void 0 ? void 0 : opts.onDisplayUri) === null || _c === void 0 ? void 0 : _c.call(opts, wcClient.uri);
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const getDeepLink = (uri, metadata, { removeWCUri = false, } = {}) => {
|
|
80
|
+
var _a, _b, _c, _d;
|
|
81
|
+
if (!isMobile()) {
|
|
82
|
+
const origin = ((_a = metadata.desktop) === null || _a === void 0 ? void 0 : _a.universal) || ((_b = metadata.desktop) === null || _b === void 0 ? void 0 : _b.native);
|
|
83
|
+
if (removeWCUri)
|
|
84
|
+
return origin || '';
|
|
85
|
+
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
86
|
+
}
|
|
87
|
+
// deeplinks for ios require special treatment
|
|
88
|
+
// see: https://docs.walletconnect.com/mobile-linking#for-ios
|
|
89
|
+
else if (isIOS()) {
|
|
90
|
+
const origin = ((_c = metadata.mobile) === null || _c === void 0 ? void 0 : _c.universal) || ((_d = metadata.mobile) === null || _d === void 0 ? void 0 : _d.native);
|
|
91
|
+
if (removeWCUri)
|
|
92
|
+
return origin || '';
|
|
93
|
+
return `${origin}?uri=${encodeURIComponent(uri !== null && uri !== void 0 ? uri : '')}`;
|
|
94
|
+
}
|
|
95
|
+
// on android, the deeplink is simply the uri
|
|
96
|
+
// see: https://docs.walletconnect.com/mobile-linking#for-android
|
|
97
|
+
return uri;
|
|
98
|
+
};
|
|
99
|
+
const createSession = (client) => __awaiter(void 0, void 0, void 0, function* () {
|
|
100
|
+
return new Promise((resolve, reject) => {
|
|
101
|
+
client.on('connect', (error, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
102
|
+
if (error)
|
|
103
|
+
throw error;
|
|
104
|
+
resolve(payload);
|
|
105
|
+
}));
|
|
106
|
+
client.on('disconnect', (error, payload) => {
|
|
107
|
+
reject(error || payload.params[0].message);
|
|
108
|
+
});
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
const fetchWalletConnectCosmosPublicAddress = (metadata, wcClient, provider, opts) => __awaiter(void 0, void 0, void 0, function* () {
|
|
112
|
+
var _a;
|
|
113
|
+
if (wcClient.connected) {
|
|
114
|
+
const key = yield provider.getKey(opts.chainId);
|
|
115
|
+
return key.bech32Address;
|
|
116
|
+
}
|
|
117
|
+
yield wcClient.createSession();
|
|
118
|
+
useDeepLink(metadata, wcClient, opts);
|
|
119
|
+
const payload = yield createSession(wcClient);
|
|
120
|
+
const key = yield provider.getKey(opts.chainId);
|
|
121
|
+
(_a = opts === null || opts === void 0 ? void 0 : opts.onConnect) === null || _a === void 0 ? void 0 : _a.call(opts, payload);
|
|
122
|
+
wcClient.accounts = [key.bech32Address];
|
|
123
|
+
return key.bech32Address;
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
export { createSession, fetchWalletConnectCosmosPublicAddress, getDeepLink, initClient, killWalletConnectSession, setupWalletConnectEventListeners, teardownWalletConnectEventListeners, useDeepLink };
|
|
@@ -5,8 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var fcl = require('@onflow/fcl');
|
|
7
7
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
|
-
var
|
|
9
|
-
var logger = require('../../utils/logger.cjs');
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
10
9
|
|
|
11
10
|
const get = (key) => {
|
|
12
11
|
if (typeof window === 'undefined') {
|
|
@@ -19,7 +18,7 @@ const get = (key) => {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
catch (e) {
|
|
22
|
-
|
|
21
|
+
walletConnectorCore.logger.error(e);
|
|
23
22
|
}
|
|
24
23
|
return undefined;
|
|
25
24
|
};
|
|
@@ -73,7 +72,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
73
72
|
return user.addr;
|
|
74
73
|
}
|
|
75
74
|
catch (error) {
|
|
76
|
-
|
|
75
|
+
walletConnectorCore.logger.error(error);
|
|
77
76
|
return undefined;
|
|
78
77
|
}
|
|
79
78
|
});
|
|
@@ -94,7 +93,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
94
93
|
return JSON.stringify(data);
|
|
95
94
|
}
|
|
96
95
|
catch (error) {
|
|
97
|
-
|
|
96
|
+
walletConnectorCore.logger.error(error);
|
|
98
97
|
return undefined;
|
|
99
98
|
}
|
|
100
99
|
});
|
|
@@ -104,7 +103,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
104
103
|
const message = Buffer.from(messageToSign).toString('hex');
|
|
105
104
|
const signedMessage = yield fcl.currentUser().signUserMessage(message);
|
|
106
105
|
if (signedMessage.includes('Declined')) {
|
|
107
|
-
throw new
|
|
106
|
+
throw new utils.DynamicError('User declined the signature');
|
|
108
107
|
}
|
|
109
108
|
return JSON.stringify(signedMessage);
|
|
110
109
|
});
|
|
@@ -124,7 +123,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
124
123
|
return yield fcl.send([fcl.script(code)]).then(fcl.decode);
|
|
125
124
|
}
|
|
126
125
|
catch (error) {
|
|
127
|
-
|
|
126
|
+
walletConnectorCore.logger.error(error);
|
|
128
127
|
return undefined;
|
|
129
128
|
}
|
|
130
129
|
}
|
|
@@ -140,7 +139,7 @@ class FlowWalletConnector extends walletConnectorCore.WalletConnectorBase {
|
|
|
140
139
|
}
|
|
141
140
|
switchNetwork() {
|
|
142
141
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
143
|
-
throw new
|
|
142
|
+
throw new utils.DynamicError('Not supported');
|
|
144
143
|
});
|
|
145
144
|
}
|
|
146
145
|
getConnectedAccounts() {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { currentUser, config, send, script, decode } from '@onflow/fcl';
|
|
3
|
-
import { WalletConnectorBase } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import { DynamicError } from '
|
|
5
|
-
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { WalletConnectorBase, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
+
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
5
|
|
|
7
6
|
const get = (key) => {
|
|
8
7
|
if (typeof window === 'undefined') {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var fcl = require('@onflow/fcl');
|
|
5
|
-
var
|
|
5
|
+
var utils = require('@dynamic-labs/utils');
|
|
6
6
|
var FlowWalletConnector = require('./FlowWalletConnector.cjs');
|
|
7
7
|
|
|
8
8
|
class Lilico extends FlowWalletConnector.FlowWalletConnector {
|
|
@@ -27,7 +27,7 @@ class Lilico extends FlowWalletConnector.FlowWalletConnector {
|
|
|
27
27
|
}
|
|
28
28
|
signDelay() {
|
|
29
29
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
30
|
-
if (
|
|
30
|
+
if (utils.isMobile()) {
|
|
31
31
|
return Promise.resolve();
|
|
32
32
|
}
|
|
33
33
|
return new Promise((resolve) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { config } from '@onflow/fcl';
|
|
3
|
-
import { isMobile } from '
|
|
3
|
+
import { isMobile } from '@dynamic-labs/utils';
|
|
4
4
|
import { FlowWalletConnector } from './FlowWalletConnector.js';
|
|
5
5
|
|
|
6
6
|
class Lilico extends FlowWalletConnector {
|
|
@@ -8,45 +8,42 @@ class CoinbaseSolana extends solWalletConnector.SolWalletConnector {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.name = 'CoinbaseSolana';
|
|
11
|
-
this.solProviderHelper = new solProviderHelper.SolProviderHelper();
|
|
12
11
|
}
|
|
13
12
|
setupEventListeners(listeners) {
|
|
14
|
-
|
|
15
|
-
return this.solProviderHelper._setupEventListeners(listeners, this.solProviderHelper.findProvider(this.name));
|
|
16
|
-
});
|
|
13
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(listeners, solProviderHelper.SolProviderHelper.findProvider(this.name));
|
|
17
14
|
}
|
|
18
15
|
teardownEventListeners() {
|
|
19
|
-
|
|
16
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.name);
|
|
20
17
|
}
|
|
21
18
|
connect() {
|
|
22
19
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
yield
|
|
20
|
+
yield solProviderHelper.SolProviderHelper.connectWithName(this.name);
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
23
|
getSigner() {
|
|
27
24
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return
|
|
25
|
+
return solProviderHelper.SolProviderHelper.connectWithName(this.name);
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
28
|
isInstalledOnBrowser() {
|
|
32
|
-
return
|
|
29
|
+
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.name);
|
|
33
30
|
}
|
|
34
31
|
fetchPublicAddress() {
|
|
35
32
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
36
33
|
if (this.isInstalledOnBrowser()) {
|
|
37
|
-
return
|
|
34
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
38
35
|
}
|
|
39
36
|
return;
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
signMessage(messageToSign) {
|
|
43
40
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return
|
|
41
|
+
return solProviderHelper.SolProviderHelper.signMessageWithName(messageToSign, this.name);
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
getConnectedAccounts() {
|
|
48
45
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
49
|
-
return
|
|
46
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithName(this.name);
|
|
50
47
|
});
|
|
51
48
|
}
|
|
52
49
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { ISolana } from '../window';
|
|
3
3
|
import { SolWalletConnector } from './solWalletConnector';
|
|
4
|
-
import { SolProviderHelper } from './solProviderHelper';
|
|
5
4
|
declare class CoinbaseSolana extends SolWalletConnector {
|
|
6
5
|
name: string;
|
|
7
|
-
|
|
8
|
-
setupEventListeners(listeners: WalletEventListeners): Promise<() => void>;
|
|
6
|
+
setupEventListeners(listeners: WalletEventListeners): void;
|
|
9
7
|
teardownEventListeners(): void;
|
|
10
8
|
connect(): Promise<void>;
|
|
11
9
|
getSigner(): Promise<ISolana | undefined>;
|
|
@@ -6,45 +6,42 @@ class CoinbaseSolana extends SolWalletConnector {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.name = 'CoinbaseSolana';
|
|
9
|
-
this.solProviderHelper = new SolProviderHelper();
|
|
10
9
|
}
|
|
11
10
|
setupEventListeners(listeners) {
|
|
12
|
-
|
|
13
|
-
return this.solProviderHelper._setupEventListeners(listeners, this.solProviderHelper.findProvider(this.name));
|
|
14
|
-
});
|
|
11
|
+
SolProviderHelper._setupEventListeners(listeners, SolProviderHelper.findProvider(this.name));
|
|
15
12
|
}
|
|
16
13
|
teardownEventListeners() {
|
|
17
|
-
|
|
14
|
+
SolProviderHelper._teardownEventListeners(this.name);
|
|
18
15
|
}
|
|
19
16
|
connect() {
|
|
20
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
yield
|
|
18
|
+
yield SolProviderHelper.connectWithName(this.name);
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
getSigner() {
|
|
25
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
return
|
|
23
|
+
return SolProviderHelper.connectWithName(this.name);
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
isInstalledOnBrowser() {
|
|
30
|
-
return
|
|
27
|
+
return SolProviderHelper.isInstalledHelper(this.name);
|
|
31
28
|
}
|
|
32
29
|
fetchPublicAddress() {
|
|
33
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
31
|
if (this.isInstalledOnBrowser()) {
|
|
35
|
-
return
|
|
32
|
+
return SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
36
33
|
}
|
|
37
34
|
return;
|
|
38
35
|
});
|
|
39
36
|
}
|
|
40
37
|
signMessage(messageToSign) {
|
|
41
38
|
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
return
|
|
39
|
+
return SolProviderHelper.signMessageWithName(messageToSign, this.name);
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
getConnectedAccounts() {
|
|
46
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
47
|
-
return
|
|
44
|
+
return SolProviderHelper.getConnectedAccountsWithName(this.name);
|
|
48
45
|
});
|
|
49
46
|
}
|
|
50
47
|
}
|
|
@@ -8,42 +8,39 @@ class Glow extends solWalletConnector.SolWalletConnector {
|
|
|
8
8
|
constructor() {
|
|
9
9
|
super(...arguments);
|
|
10
10
|
this.name = 'Glow';
|
|
11
|
-
this.solProviderHelper = new solProviderHelper.SolProviderHelper();
|
|
12
11
|
}
|
|
13
12
|
setupEventListeners(listeners) {
|
|
14
|
-
|
|
15
|
-
return this.solProviderHelper._setupEventListeners(listeners, this.solProviderHelper.findProvider(this.name));
|
|
16
|
-
});
|
|
13
|
+
solProviderHelper.SolProviderHelper._setupEventListeners(listeners, solProviderHelper.SolProviderHelper.findProvider(this.name));
|
|
17
14
|
}
|
|
18
15
|
teardownEventListeners() {
|
|
19
|
-
|
|
16
|
+
solProviderHelper.SolProviderHelper._teardownEventListeners(this.name);
|
|
20
17
|
}
|
|
21
18
|
connect() {
|
|
22
19
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
23
|
-
yield
|
|
20
|
+
yield solProviderHelper.SolProviderHelper.connectWithName(this.name);
|
|
24
21
|
});
|
|
25
22
|
}
|
|
26
23
|
getSigner() {
|
|
27
24
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return
|
|
25
|
+
return solProviderHelper.SolProviderHelper.connectWithName(this.name);
|
|
29
26
|
});
|
|
30
27
|
}
|
|
31
28
|
isInstalledOnBrowser() {
|
|
32
|
-
return
|
|
29
|
+
return solProviderHelper.SolProviderHelper.isInstalledHelper(this.name);
|
|
33
30
|
}
|
|
34
31
|
fetchPublicAddress() {
|
|
35
32
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
36
|
-
return
|
|
33
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
37
34
|
});
|
|
38
35
|
}
|
|
39
36
|
signMessage(messageToSign) {
|
|
40
37
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
|
-
return
|
|
38
|
+
return solProviderHelper.SolProviderHelper.signMessageWithName(messageToSign, this.name);
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
getConnectedAccounts() {
|
|
45
42
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
46
|
-
return
|
|
43
|
+
return solProviderHelper.SolProviderHelper.getConnectedAccountsWithName(this.name);
|
|
47
44
|
});
|
|
48
45
|
}
|
|
49
46
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { WalletEventListeners } from '@dynamic-labs/wallet-connector-core';
|
|
2
2
|
import { SolWalletConnector } from './solWalletConnector';
|
|
3
|
-
import { SolProviderHelper } from './solProviderHelper';
|
|
4
3
|
declare class Glow extends SolWalletConnector {
|
|
5
4
|
name: string;
|
|
6
|
-
|
|
7
|
-
setupEventListeners(listeners: WalletEventListeners): Promise<() => void>;
|
|
5
|
+
setupEventListeners(listeners: WalletEventListeners): void;
|
|
8
6
|
teardownEventListeners(): void;
|
|
9
7
|
connect(): Promise<void>;
|
|
10
8
|
getSigner(): Promise<import("../window").ISolana | undefined>;
|
|
@@ -6,42 +6,39 @@ class Glow extends SolWalletConnector {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super(...arguments);
|
|
8
8
|
this.name = 'Glow';
|
|
9
|
-
this.solProviderHelper = new SolProviderHelper();
|
|
10
9
|
}
|
|
11
10
|
setupEventListeners(listeners) {
|
|
12
|
-
|
|
13
|
-
return this.solProviderHelper._setupEventListeners(listeners, this.solProviderHelper.findProvider(this.name));
|
|
14
|
-
});
|
|
11
|
+
SolProviderHelper._setupEventListeners(listeners, SolProviderHelper.findProvider(this.name));
|
|
15
12
|
}
|
|
16
13
|
teardownEventListeners() {
|
|
17
|
-
|
|
14
|
+
SolProviderHelper._teardownEventListeners(this.name);
|
|
18
15
|
}
|
|
19
16
|
connect() {
|
|
20
17
|
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
-
yield
|
|
18
|
+
yield SolProviderHelper.connectWithName(this.name);
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
getSigner() {
|
|
25
22
|
return __awaiter(this, void 0, void 0, function* () {
|
|
26
|
-
return
|
|
23
|
+
return SolProviderHelper.connectWithName(this.name);
|
|
27
24
|
});
|
|
28
25
|
}
|
|
29
26
|
isInstalledOnBrowser() {
|
|
30
|
-
return
|
|
27
|
+
return SolProviderHelper.isInstalledHelper(this.name);
|
|
31
28
|
}
|
|
32
29
|
fetchPublicAddress() {
|
|
33
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
|
-
return
|
|
31
|
+
return SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
35
32
|
});
|
|
36
33
|
}
|
|
37
34
|
signMessage(messageToSign) {
|
|
38
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
return
|
|
36
|
+
return SolProviderHelper.signMessageWithName(messageToSign, this.name);
|
|
40
37
|
});
|
|
41
38
|
}
|
|
42
39
|
getConnectedAccounts() {
|
|
43
40
|
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
-
return
|
|
41
|
+
return SolProviderHelper.getConnectedAccountsWithName(this.name);
|
|
45
42
|
});
|
|
46
43
|
}
|
|
47
44
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var phantom = require('../phantom.cjs');
|
|
5
|
+
var solProviderHelper = require('../solProviderHelper.cjs');
|
|
5
6
|
|
|
6
7
|
class BraveSol extends phantom {
|
|
7
8
|
constructor() {
|
|
@@ -10,7 +11,7 @@ class BraveSol extends phantom {
|
|
|
10
11
|
}
|
|
11
12
|
fetchPublicAddress() {
|
|
12
13
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
13
|
-
return
|
|
14
|
+
return solProviderHelper.SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
14
15
|
});
|
|
15
16
|
}
|
|
16
17
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import Phantom from '../phantom.js';
|
|
3
|
+
import { SolProviderHelper } from '../solProviderHelper.js';
|
|
3
4
|
|
|
4
5
|
class BraveSol extends Phantom {
|
|
5
6
|
constructor() {
|
|
@@ -8,7 +9,7 @@ class BraveSol extends Phantom {
|
|
|
8
9
|
}
|
|
9
10
|
fetchPublicAddress() {
|
|
10
11
|
return __awaiter(this, void 0, void 0, function* () {
|
|
11
|
-
return
|
|
12
|
+
return SolProviderHelper.fetchPublicAddressWithName(this.name);
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
}
|
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var web3_js = require('@solana/web3.js');
|
|
7
|
-
var
|
|
7
|
+
var utils = require('@dynamic-labs/utils');
|
|
8
8
|
var extractNonce = require('../../utils/extractNonce.cjs');
|
|
9
9
|
var phantom = require('./phantom.cjs');
|
|
10
10
|
|
|
@@ -30,7 +30,7 @@ class PhantomLedger extends phantom {
|
|
|
30
30
|
}
|
|
31
31
|
signMessage() {
|
|
32
32
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
throw new
|
|
33
|
+
throw new utils.NotSupportedError(`Message signing is currently not supported on ${walletName}
|
|
34
34
|
You can use signMessageViaTransaction instead to achieve similar functionality
|
|
35
35
|
by signing a transaction with a memo instruction.
|
|
36
36
|
You can read more about it here https://github.com/solana-labs/solana/issues/21366`);
|
|
@@ -40,7 +40,7 @@ class PhantomLedger extends phantom {
|
|
|
40
40
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
41
41
|
const nonce = extractNonce.extractNonce(messageToSign);
|
|
42
42
|
if (!nonce) {
|
|
43
|
-
throw new
|
|
43
|
+
throw new utils.DynamicError('Nonce missing');
|
|
44
44
|
}
|
|
45
45
|
return this.signMessageViaTransaction(nonce);
|
|
46
46
|
});
|
|
@@ -49,14 +49,14 @@ class PhantomLedger extends phantom {
|
|
|
49
49
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
|
50
50
|
const address = yield this.fetchPublicAddress();
|
|
51
51
|
if (!address) {
|
|
52
|
-
throw new
|
|
52
|
+
throw new utils.DynamicError('Address missing');
|
|
53
53
|
}
|
|
54
54
|
const transaction = this.buildAuthTx(messageToSign);
|
|
55
55
|
transaction.feePayer = new web3_js.PublicKey(address);
|
|
56
56
|
transaction.recentBlockhash = (yield this.getWeb3Provider().getLatestBlockhash()).blockhash;
|
|
57
57
|
const signer = yield this.getSigner();
|
|
58
58
|
if (!signer) {
|
|
59
|
-
throw new
|
|
59
|
+
throw new utils.DynamicError('Signer not found');
|
|
60
60
|
}
|
|
61
61
|
const signedTransaction = yield signer.signTransaction(transaction);
|
|
62
62
|
return JSON.stringify({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from 'tslib';
|
|
2
2
|
import { PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
-
import { NotSupportedError, DynamicError } from '
|
|
3
|
+
import { NotSupportedError, DynamicError } from '@dynamic-labs/utils';
|
|
4
4
|
import { extractNonce } from '../../utils/extractNonce.js';
|
|
5
5
|
import Phantom from './phantom.js';
|
|
6
6
|
|