@dynamic-labs/solana 4.0.0-alpha.5 → 4.0.0-alpha.51
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 +468 -0
- package/package.cjs +8 -0
- package/package.js +4 -0
- package/package.json +12 -18
- package/src/{CoinbaseSolana.cjs → CoinbaseSolana/CoinbaseSolana.cjs} +6 -14
- package/src/{CoinbaseSolana.d.ts → CoinbaseSolana/CoinbaseSolana.d.ts} +1 -3
- package/src/{CoinbaseSolana.js → CoinbaseSolana/CoinbaseSolana.js} +6 -14
- package/src/CoinbaseSolana/index.d.ts +1 -0
- package/src/{Phantom.cjs → Phantom/Phantom.cjs} +7 -9
- package/src/Phantom/Phantom.d.ts +9 -0
- package/src/{Phantom.js → Phantom/Phantom.js} +7 -9
- package/src/Phantom/index.d.ts +1 -0
- package/src/{solProviderHelper.cjs → SolProviderHelper/SolProviderHelper.cjs} +33 -22
- package/src/{solProviderHelper.d.ts → SolProviderHelper/SolProviderHelper.d.ts} +6 -5
- package/src/{solProviderHelper.js → SolProviderHelper/SolProviderHelper.js} +33 -22
- package/src/SolProviderHelper/index.d.ts +1 -0
- package/src/SolanaWalletConnectors.cjs +21 -0
- package/src/SolanaWalletConnectors.d.ts +2 -0
- package/src/SolanaWalletConnectors.js +17 -0
- package/src/SolanaWalletConnectorsWithConfig/SolanaWalletConnectorsWithConfig.cjs +26 -0
- package/src/SolanaWalletConnectorsWithConfig/SolanaWalletConnectorsWithConfig.d.ts +6 -0
- package/src/SolanaWalletConnectorsWithConfig/SolanaWalletConnectorsWithConfig.js +22 -0
- package/src/SolanaWalletConnectorsWithConfig/index.d.ts +1 -0
- package/src/{Solflare.cjs → Solflare/Solflare.cjs} +9 -10
- package/src/{Solflare.d.ts → Solflare/Solflare.d.ts} +1 -3
- package/src/{Solflare.js → Solflare/Solflare.js} +9 -10
- package/src/Solflare/index.d.ts +1 -0
- package/src/index.cjs +19 -18
- package/src/index.d.ts +7 -5
- package/src/index.js +9 -17
- package/src/injected/{BackpackSol.cjs → BackpackSol/BackpackSol.cjs} +5 -7
- package/src/injected/{BackpackSol.d.ts → BackpackSol/BackpackSol.d.ts} +1 -3
- package/src/injected/{BackpackSol.js → BackpackSol/BackpackSol.js} +5 -7
- package/src/injected/BackpackSol/index.d.ts +1 -0
- package/src/injected/{FallbackSolanaConnector.cjs → FallbackSolanaConnector/FallbackSolanaConnector.cjs} +3 -5
- package/src/injected/{FallbackSolanaConnector.d.ts → FallbackSolanaConnector/FallbackSolanaConnector.d.ts} +1 -3
- package/src/injected/{FallbackSolanaConnector.js → FallbackSolanaConnector/FallbackSolanaConnector.js} +3 -5
- package/src/injected/FallbackSolanaConnector/index.d.ts +1 -0
- package/src/injected/{InjectedWalletBase.cjs → InjectedWalletBase/InjectedWalletBase.cjs} +23 -27
- package/src/injected/{InjectedWalletBase.d.ts → InjectedWalletBase/InjectedWalletBase.d.ts} +6 -8
- package/src/injected/{InjectedWalletBase.js → InjectedWalletBase/InjectedWalletBase.js} +24 -28
- package/src/injected/InjectedWalletBase/index.d.ts +1 -0
- package/src/injected/{PhantomInjected.cjs → PhantomInjected/PhantomInjected.cjs} +5 -7
- package/src/injected/{PhantomInjected.d.ts → PhantomInjected/PhantomInjected.d.ts} +1 -3
- package/src/injected/{PhantomInjected.js → PhantomInjected/PhantomInjected.js} +5 -7
- package/src/injected/PhantomInjected/index.d.ts +1 -0
- package/src/injected/fetchInjectedWalletConnectors.cjs +43 -25
- package/src/injected/fetchInjectedWalletConnectors.js +43 -25
- package/src/injected/index.d.ts +0 -1
- package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +72 -21
- package/src/injected/walletStandard/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +4 -0
- package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +71 -20
- package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.cjs +29 -0
- package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.d.ts +3 -0
- package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/getConnectorConstructorForWalletStandardWallet.js +25 -0
- package/src/injected/walletStandard/getConnectorConstructorForWalletStandardWallet/index.d.ts +1 -0
- package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.cjs +10 -0
- package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.d.ts +1 -0
- package/src/injected/walletStandard/getWalletStandardWallets/getWalletStandardWallets.js +6 -0
- package/src/injected/walletStandard/getWalletStandardWallets/index.d.ts +1 -0
- package/src/phantomRedirect/{PhantomRedirect.cjs → PhantomRedirect/PhantomRedirect.cjs} +28 -25
- package/src/phantomRedirect/{PhantomRedirect.d.ts → PhantomRedirect/PhantomRedirect.d.ts} +3 -3
- package/src/phantomRedirect/{PhantomRedirect.js → PhantomRedirect/PhantomRedirect.js} +10 -7
- package/src/phantomRedirect/PhantomRedirect/index.d.ts +1 -0
- package/src/phantomRedirect/buildUrl/buildUrl.cjs +8 -0
- package/src/phantomRedirect/buildUrl/buildUrl.d.ts +1 -0
- package/src/phantomRedirect/buildUrl/buildUrl.js +4 -0
- package/src/phantomRedirect/buildUrl/index.d.ts +1 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.cjs +34 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.d.ts +1 -0
- package/src/phantomRedirect/decryptPayload/decryptPayload.js +25 -0
- package/src/phantomRedirect/decryptPayload/index.d.ts +1 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.cjs +18 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.d.ts +1 -0
- package/src/phantomRedirect/encryptPayload/encryptPayload.js +10 -0
- package/src/phantomRedirect/encryptPayload/index.d.ts +1 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.cjs +33 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.d.ts +1 -0
- package/src/phantomRedirect/fetchCluster/fetchCluster.js +29 -0
- package/src/phantomRedirect/fetchCluster/index.d.ts +1 -0
- package/src/phantomRedirect/storage/index.d.ts +1 -0
- package/src/phantomRedirect/{storage.d.ts → storage/storage.d.ts} +1 -1
- package/src/utils/logger.cjs +10 -0
- package/src/utils/logger.d.ts +2 -0
- package/src/utils/logger.js +6 -0
- package/src/Phantom.d.ts +0 -12
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +0 -100
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.d.ts +0 -20
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +0 -96
- package/src/SolanaWalletStandardConnector/index.d.ts +0 -1
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +0 -3
- package/src/injected/UnknownInjected.cjs +0 -21
- package/src/injected/UnknownInjected.d.ts +0 -8
- package/src/injected/UnknownInjected.js +0 -17
- package/src/phantomRedirect/utils.cjs +0 -56
- package/src/phantomRedirect/utils.d.ts +0 -4
- package/src/phantomRedirect/utils.js +0 -44
- /package/src/{SolanaWalletStandardConnector/utils → injected/walletStandard}/createSolanaSignerFromWalletStandard/index.d.ts +0 -0
- /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs +0 -0
- /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.d.ts +0 -0
- /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js +0 -0
- /package/src/{utils → injected/walletStandard}/findWalletProviderFromWalletStandard/index.d.ts +0 -0
- /package/src/phantomRedirect/{storage.cjs → storage/storage.cjs} +0 -0
- /package/src/phantomRedirect/{storage.js → storage/storage.js} +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './CoinbaseSolana';
|
|
@@ -3,19 +3,17 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
7
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
|
-
var utils = require('@dynamic-labs/utils');
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
9
7
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
10
|
-
var
|
|
11
|
-
var PhantomInjected = require('
|
|
8
|
+
var utils = require('@dynamic-labs/utils');
|
|
9
|
+
var PhantomInjected = require('../injected/PhantomInjected/PhantomInjected.cjs');
|
|
10
|
+
var PhantomRedirect = require('../phantomRedirect/PhantomRedirect/PhantomRedirect.cjs');
|
|
12
11
|
|
|
13
|
-
class Phantom extends solanaCore.
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
12
|
+
class Phantom extends solanaCore.SolanaWalletConnector {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
16
15
|
this.name = 'Phantom';
|
|
17
16
|
this.overrideKey = 'phantom';
|
|
18
|
-
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
19
17
|
}
|
|
20
18
|
connect() {
|
|
21
19
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
2
|
+
import { WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
export declare class Phantom extends SolanaWalletConnector {
|
|
4
|
+
name: string;
|
|
5
|
+
overrideKey: string;
|
|
6
|
+
connect(): Promise<void>;
|
|
7
|
+
getSigner(): Promise<ISolana | undefined>;
|
|
8
|
+
getMobileOrInstalledWallet(): WalletConnectorCore.WalletConnector;
|
|
9
|
+
}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '
|
|
3
|
-
import {
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
|
+
import { SolanaWalletConnector } from '@dynamic-labs/solana-core';
|
|
4
4
|
import { isMobile } from '@dynamic-labs/utils';
|
|
5
|
-
import {
|
|
6
|
-
import { PhantomRedirect } from '
|
|
7
|
-
import { PhantomInjected } from './injected/PhantomInjected.js';
|
|
5
|
+
import { PhantomInjected } from '../injected/PhantomInjected/PhantomInjected.js';
|
|
6
|
+
import { PhantomRedirect } from '../phantomRedirect/PhantomRedirect/PhantomRedirect.js';
|
|
8
7
|
|
|
9
|
-
class Phantom extends
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
8
|
+
class Phantom extends SolanaWalletConnector {
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
12
11
|
this.name = 'Phantom';
|
|
13
12
|
this.overrideKey = 'phantom';
|
|
14
|
-
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
15
13
|
}
|
|
16
14
|
connect() {
|
|
17
15
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Phantom';
|
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
+
var walletBook = require('@dynamic-labs/wallet-book');
|
|
8
9
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
9
|
-
var
|
|
10
|
-
var
|
|
10
|
+
var findWalletProviderFromWalletStandard = require('../injected/walletStandard/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs');
|
|
11
|
+
var isSignedMessage = require('../utils/isSignedMessage.cjs');
|
|
11
12
|
|
|
12
13
|
class SolProviderHelper {
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
14
|
+
constructor(connector) {
|
|
15
|
+
this.walletBookWallet = walletBook.findWalletBookWallet(connector.walletBook, connector.key);
|
|
16
|
+
this.connector = connector;
|
|
15
17
|
}
|
|
16
18
|
getInjectedConfig() {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
return injectedConfig.find((c) => c.chain === 'sol');
|
|
19
|
+
var _a;
|
|
20
|
+
const injectedConfig = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig;
|
|
21
|
+
return injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.find((c) => c.chain === this.connector.connectedChain.toLowerCase());
|
|
21
22
|
}
|
|
22
23
|
getInstalledProvider() {
|
|
23
24
|
const config = this.getInjectedConfig();
|
|
@@ -68,7 +69,7 @@ class SolProviderHelper {
|
|
|
68
69
|
return walletConnectorCore.ProviderLookup(allInstalledProviders, extensionLocators);
|
|
69
70
|
}
|
|
70
71
|
findProvider() {
|
|
71
|
-
return this.
|
|
72
|
+
return this.connector.findProvider();
|
|
72
73
|
}
|
|
73
74
|
isInstalledHelper() {
|
|
74
75
|
return this.findProvider() !== undefined;
|
|
@@ -132,23 +133,23 @@ class SolProviderHelper {
|
|
|
132
133
|
}
|
|
133
134
|
});
|
|
134
135
|
}
|
|
135
|
-
_setupEventListeners(
|
|
136
|
+
_setupEventListeners() {
|
|
136
137
|
const provider = this.findProvider();
|
|
137
138
|
if (!provider) {
|
|
138
139
|
walletConnectorCore.logger.warn('Provider not found', {
|
|
139
|
-
connector:
|
|
140
|
+
connector: this.connector,
|
|
140
141
|
});
|
|
141
142
|
return;
|
|
142
143
|
}
|
|
143
|
-
if (!
|
|
144
|
+
if (!provider.on) {
|
|
144
145
|
walletConnectorCore.logger.warn('Provider does not support event listeners', {
|
|
145
|
-
connector:
|
|
146
|
+
connector: this.connector,
|
|
146
147
|
provider,
|
|
147
148
|
});
|
|
148
149
|
return;
|
|
149
150
|
}
|
|
150
|
-
provider.on('accountChanged', (publicKey) => this.handleAccountChange(
|
|
151
|
-
provider.on('disconnect', () =>
|
|
151
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(this.connector, provider, publicKey));
|
|
152
|
+
provider.on('disconnect', () => this.connector.emit('disconnect'));
|
|
152
153
|
}
|
|
153
154
|
_teardownEventListeners() {
|
|
154
155
|
const provider = this.findProvider();
|
|
@@ -172,13 +173,23 @@ class SolProviderHelper {
|
|
|
172
173
|
return [];
|
|
173
174
|
}
|
|
174
175
|
const address = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address;
|
|
175
|
-
|
|
176
|
-
if (address)
|
|
176
|
+
if (address) {
|
|
177
177
|
return [address];
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
178
|
+
}
|
|
179
|
+
// adding a try/catch to prevent errors from being thrown
|
|
180
|
+
// when the public key getter throws for wallet standard wallets
|
|
181
|
+
try {
|
|
182
|
+
const publicKey = (_a = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.publicKey) !== null && _a !== void 0 ? _a : (_b = provider.publicKey) === null || _b === void 0 ? void 0 : _b.toString();
|
|
183
|
+
if (publicKey)
|
|
184
|
+
return [publicKey === null || publicKey === void 0 ? void 0 : publicKey.toString()];
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
walletConnectorCore.logger.debug('Error getting public key', {
|
|
188
|
+
connector: this.connector,
|
|
189
|
+
error: e,
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return [];
|
|
182
193
|
});
|
|
183
194
|
}
|
|
184
195
|
}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ExtensionLocator, ISolana } from '@dynamic-labs/solana-core';
|
|
2
2
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import {
|
|
3
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase';
|
|
4
4
|
export declare class SolProviderHelper {
|
|
5
|
-
private
|
|
6
|
-
|
|
5
|
+
private walletBookWallet;
|
|
6
|
+
private connector;
|
|
7
|
+
constructor(connector: InjectedWalletBase);
|
|
7
8
|
getInjectedConfig(): {
|
|
8
9
|
chain: string;
|
|
9
10
|
extensionLocators: {
|
|
@@ -31,7 +32,7 @@ export declare class SolProviderHelper {
|
|
|
31
32
|
connect(): Promise<ISolana | undefined>;
|
|
32
33
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
33
34
|
handleAccountChange(walletConnector: WalletConnector, web3Provider: ISolana, address: string): Promise<void>;
|
|
34
|
-
_setupEventListeners(
|
|
35
|
+
_setupEventListeners(): void;
|
|
35
36
|
_teardownEventListeners(): void;
|
|
36
37
|
getConnectedAccounts(): Promise<string[]>;
|
|
37
38
|
}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { getProvidersFromWindow, bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
4
5
|
import { ProviderLookup, logger } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
6
|
+
import { findWalletProviderFromWalletStandard } from '../injected/walletStandard/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js';
|
|
7
|
+
import { isSignedMessage } from '../utils/isSignedMessage.js';
|
|
7
8
|
|
|
8
9
|
class SolProviderHelper {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
10
|
+
constructor(connector) {
|
|
11
|
+
this.walletBookWallet = findWalletBookWallet(connector.walletBook, connector.key);
|
|
12
|
+
this.connector = connector;
|
|
11
13
|
}
|
|
12
14
|
getInjectedConfig() {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return injectedConfig.find((c) => c.chain === 'sol');
|
|
15
|
+
var _a;
|
|
16
|
+
const injectedConfig = (_a = this.walletBookWallet) === null || _a === void 0 ? void 0 : _a.injectedConfig;
|
|
17
|
+
return injectedConfig === null || injectedConfig === void 0 ? void 0 : injectedConfig.find((c) => c.chain === this.connector.connectedChain.toLowerCase());
|
|
17
18
|
}
|
|
18
19
|
getInstalledProvider() {
|
|
19
20
|
const config = this.getInjectedConfig();
|
|
@@ -64,7 +65,7 @@ class SolProviderHelper {
|
|
|
64
65
|
return ProviderLookup(allInstalledProviders, extensionLocators);
|
|
65
66
|
}
|
|
66
67
|
findProvider() {
|
|
67
|
-
return this.
|
|
68
|
+
return this.connector.findProvider();
|
|
68
69
|
}
|
|
69
70
|
isInstalledHelper() {
|
|
70
71
|
return this.findProvider() !== undefined;
|
|
@@ -128,23 +129,23 @@ class SolProviderHelper {
|
|
|
128
129
|
}
|
|
129
130
|
});
|
|
130
131
|
}
|
|
131
|
-
_setupEventListeners(
|
|
132
|
+
_setupEventListeners() {
|
|
132
133
|
const provider = this.findProvider();
|
|
133
134
|
if (!provider) {
|
|
134
135
|
logger.warn('Provider not found', {
|
|
135
|
-
connector:
|
|
136
|
+
connector: this.connector,
|
|
136
137
|
});
|
|
137
138
|
return;
|
|
138
139
|
}
|
|
139
|
-
if (!
|
|
140
|
+
if (!provider.on) {
|
|
140
141
|
logger.warn('Provider does not support event listeners', {
|
|
141
|
-
connector:
|
|
142
|
+
connector: this.connector,
|
|
142
143
|
provider,
|
|
143
144
|
});
|
|
144
145
|
return;
|
|
145
146
|
}
|
|
146
|
-
provider.on('accountChanged', (publicKey) => this.handleAccountChange(
|
|
147
|
-
provider.on('disconnect', () =>
|
|
147
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(this.connector, provider, publicKey));
|
|
148
|
+
provider.on('disconnect', () => this.connector.emit('disconnect'));
|
|
148
149
|
}
|
|
149
150
|
_teardownEventListeners() {
|
|
150
151
|
const provider = this.findProvider();
|
|
@@ -168,13 +169,23 @@ class SolProviderHelper {
|
|
|
168
169
|
return [];
|
|
169
170
|
}
|
|
170
171
|
const address = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address;
|
|
171
|
-
|
|
172
|
-
if (address)
|
|
172
|
+
if (address) {
|
|
173
173
|
return [address];
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
174
|
+
}
|
|
175
|
+
// adding a try/catch to prevent errors from being thrown
|
|
176
|
+
// when the public key getter throws for wallet standard wallets
|
|
177
|
+
try {
|
|
178
|
+
const publicKey = (_a = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.publicKey) !== null && _a !== void 0 ? _a : (_b = provider.publicKey) === null || _b === void 0 ? void 0 : _b.toString();
|
|
179
|
+
if (publicKey)
|
|
180
|
+
return [publicKey === null || publicKey === void 0 ? void 0 : publicKey.toString()];
|
|
181
|
+
}
|
|
182
|
+
catch (e) {
|
|
183
|
+
logger.debug('Error getting public key', {
|
|
184
|
+
connector: this.connector,
|
|
185
|
+
error: e,
|
|
186
|
+
});
|
|
187
|
+
}
|
|
188
|
+
return [];
|
|
178
189
|
});
|
|
179
190
|
}
|
|
180
191
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SolProviderHelper';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var embeddedWalletSolana = require('@dynamic-labs/embedded-wallet-solana');
|
|
7
|
+
var Phantom = require('./Phantom/Phantom.cjs');
|
|
8
|
+
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
9
|
+
var FallbackSolanaConnector = require('./injected/FallbackSolanaConnector/FallbackSolanaConnector.cjs');
|
|
10
|
+
|
|
11
|
+
const SolanaWalletConnectors = (
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
props) => [
|
|
14
|
+
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
15
|
+
...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
|
|
16
|
+
...embeddedWalletSolana.TurnkeySolanaWalletConnectors(props),
|
|
17
|
+
Phantom.Phantom,
|
|
18
|
+
FallbackSolanaConnector.FallbackSolanaConnector,
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
exports.SolanaWalletConnectors = SolanaWalletConnectors;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { TurnkeySolanaWalletConnectors } from '@dynamic-labs/embedded-wallet-solana';
|
|
3
|
+
import { Phantom } from './Phantom/Phantom.js';
|
|
4
|
+
import { injectedWalletOverrides, fetchInjectedWalletConnectors } from './injected/fetchInjectedWalletConnectors.js';
|
|
5
|
+
import { FallbackSolanaConnector } from './injected/FallbackSolanaConnector/FallbackSolanaConnector.js';
|
|
6
|
+
|
|
7
|
+
const SolanaWalletConnectors = (
|
|
8
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
9
|
+
props) => [
|
|
10
|
+
...injectedWalletOverrides,
|
|
11
|
+
...fetchInjectedWalletConnectors(props),
|
|
12
|
+
...TurnkeySolanaWalletConnectors(props),
|
|
13
|
+
Phantom,
|
|
14
|
+
FallbackSolanaConnector,
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
export { SolanaWalletConnectors };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var SolanaWalletConnectors = require('../SolanaWalletConnectors.cjs');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Allows passing in Solana connection configuration to all wallet connectors.
|
|
10
|
+
*/
|
|
11
|
+
const SolanaWalletConnectorsWithConfig = (connectionConfig) => {
|
|
12
|
+
// Idea here is to ensure that all wallet connectors are constructed with
|
|
13
|
+
// the client-provided connection configuration, so we "wrap" the constructors with it.
|
|
14
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
15
|
+
const classWithConfig = (className) => class extends className {
|
|
16
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
17
|
+
constructor(...args) {
|
|
18
|
+
const [opts] = args;
|
|
19
|
+
super(Object.assign(Object.assign({}, opts), { connectionConfig }));
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
23
|
+
return (props) => SolanaWalletConnectors.SolanaWalletConnectors(props).map(classWithConfig);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
exports.SolanaWalletConnectorsWithConfig = SolanaWalletConnectorsWithConfig;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ConnectionConfig } from '@solana/web3.js';
|
|
2
|
+
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
/**
|
|
4
|
+
* Allows passing in Solana connection configuration to all wallet connectors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const SolanaWalletConnectorsWithConfig: (connectionConfig: ConnectionConfig) => (props: any) => WalletConnectorConstructor[];
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { SolanaWalletConnectors } from '../SolanaWalletConnectors.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Allows passing in Solana connection configuration to all wallet connectors.
|
|
6
|
+
*/
|
|
7
|
+
const SolanaWalletConnectorsWithConfig = (connectionConfig) => {
|
|
8
|
+
// Idea here is to ensure that all wallet connectors are constructed with
|
|
9
|
+
// the client-provided connection configuration, so we "wrap" the constructors with it.
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
11
|
+
const classWithConfig = (className) => class extends className {
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
constructor(...args) {
|
|
14
|
+
const [opts] = args;
|
|
15
|
+
super(Object.assign(Object.assign({}, opts), { connectionConfig }));
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
|
+
return (props) => SolanaWalletConnectors(props).map(classWithConfig);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export { SolanaWalletConnectorsWithConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SolanaWalletConnectorsWithConfig';
|
|
@@ -3,33 +3,32 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
6
|
+
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var
|
|
9
|
-
var InjectedWalletBase = require('./injected/InjectedWalletBase.cjs');
|
|
8
|
+
var InjectedWalletBase = require('../injected/InjectedWalletBase/InjectedWalletBase.cjs');
|
|
10
9
|
|
|
11
10
|
class Solflare extends InjectedWalletBase.InjectedWalletBase {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
14
13
|
this.name = 'Solflare';
|
|
15
14
|
this.overrideKey = 'solflare';
|
|
16
|
-
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
17
15
|
}
|
|
18
16
|
getAddress() {
|
|
19
17
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
var _a, _b
|
|
18
|
+
var _a, _b;
|
|
21
19
|
/**
|
|
22
20
|
* It should redirect to in-app browser if on mobile and if not in the in-app browser,
|
|
23
21
|
* this checks if it is not in the in-app browser by checking if the provider is not available.
|
|
24
22
|
*/
|
|
25
23
|
if (utils.isMobile() && !this.isInstalledOnBrowser()) {
|
|
24
|
+
const mobileDeepLinks = (_a = this.metadata.deepLinks) === null || _a === void 0 ? void 0 : _a.mobile;
|
|
26
25
|
utils.handleMobileWalletRedirect({
|
|
27
|
-
nativeLink: (
|
|
28
|
-
universalLink: (
|
|
26
|
+
nativeLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.native) || 'solflare://ul/v1/browse',
|
|
27
|
+
universalLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.universal) || 'https://solflare.com/ul/v1/browse',
|
|
29
28
|
});
|
|
30
29
|
return;
|
|
31
30
|
}
|
|
32
|
-
return (
|
|
31
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
signMessage(messageToSign) {
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { InjectedWalletBase } from './injected/InjectedWalletBase';
|
|
1
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase';
|
|
3
2
|
export declare class Solflare extends InjectedWalletBase {
|
|
4
3
|
name: string;
|
|
5
4
|
overrideKey: string;
|
|
6
|
-
constructor(opts: SolWalletConnectorOpts);
|
|
7
5
|
getAddress(): Promise<string | undefined>;
|
|
8
6
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
9
7
|
}
|
|
@@ -1,31 +1,30 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '
|
|
2
|
+
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { isMobile, handleMobileWalletRedirect, bufferToBase64 } from '@dynamic-labs/utils';
|
|
4
|
-
import {
|
|
5
|
-
import { InjectedWalletBase } from './injected/InjectedWalletBase.js';
|
|
4
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase/InjectedWalletBase.js';
|
|
6
5
|
|
|
7
6
|
class Solflare extends InjectedWalletBase {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
10
9
|
this.name = 'Solflare';
|
|
11
10
|
this.overrideKey = 'solflare';
|
|
12
|
-
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
13
11
|
}
|
|
14
12
|
getAddress() {
|
|
15
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
var _a, _b
|
|
14
|
+
var _a, _b;
|
|
17
15
|
/**
|
|
18
16
|
* It should redirect to in-app browser if on mobile and if not in the in-app browser,
|
|
19
17
|
* this checks if it is not in the in-app browser by checking if the provider is not available.
|
|
20
18
|
*/
|
|
21
19
|
if (isMobile() && !this.isInstalledOnBrowser()) {
|
|
20
|
+
const mobileDeepLinks = (_a = this.metadata.deepLinks) === null || _a === void 0 ? void 0 : _a.mobile;
|
|
22
21
|
handleMobileWalletRedirect({
|
|
23
|
-
nativeLink: (
|
|
24
|
-
universalLink: (
|
|
22
|
+
nativeLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.native) || 'solflare://ul/v1/browse',
|
|
23
|
+
universalLink: (mobileDeepLinks === null || mobileDeepLinks === void 0 ? void 0 : mobileDeepLinks.universal) || 'https://solflare.com/ul/v1/browse',
|
|
25
24
|
});
|
|
26
25
|
return;
|
|
27
26
|
}
|
|
28
|
-
return (
|
|
27
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
29
28
|
});
|
|
30
29
|
}
|
|
31
30
|
signMessage(messageToSign) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Solflare';
|
package/src/index.cjs
CHANGED
|
@@ -3,29 +3,30 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var fetchInjectedWalletConnectors = require('./injected/fetchInjectedWalletConnectors.cjs');
|
|
9
|
-
var UnknownInjected = require('./injected/UnknownInjected.cjs');
|
|
10
|
-
var FallbackSolanaConnector = require('./injected/FallbackSolanaConnector.cjs');
|
|
11
|
-
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
12
|
-
var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
|
|
6
|
+
var assertPackageVersion = require('@dynamic-labs/assert-package-version');
|
|
7
|
+
var _package = require('../package.cjs');
|
|
13
8
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
9
|
+
var BackpackSol = require('./injected/BackpackSol/BackpackSol.cjs');
|
|
10
|
+
var InjectedWalletBase = require('./injected/InjectedWalletBase/InjectedWalletBase.cjs');
|
|
11
|
+
var SolanaWalletConnectors = require('./SolanaWalletConnectors.cjs');
|
|
12
|
+
var SolanaWalletConnectorsWithConfig = require('./SolanaWalletConnectorsWithConfig/SolanaWalletConnectorsWithConfig.cjs');
|
|
13
|
+
var isBackpackSolanaSigner = require('./utils/isBackpackSolanaSigner.cjs');
|
|
14
|
+
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
14
15
|
|
|
15
16
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
16
|
-
|
|
17
|
-
...fetchInjectedWalletConnectors.injectedWalletOverrides,
|
|
18
|
-
...fetchInjectedWalletConnectors.fetchInjectedWalletConnectors(props),
|
|
19
|
-
...embeddedWalletSolana.TurnkeySolanaWalletConnectors(props),
|
|
20
|
-
Phantom.Phantom,
|
|
21
|
-
UnknownInjected.UnknownInjected,
|
|
22
|
-
FallbackSolanaConnector.FallbackSolanaConnector,
|
|
23
|
-
];
|
|
17
|
+
assertPackageVersion.assertPackageVersion('@dynamic-labs/solana', _package.version);
|
|
24
18
|
|
|
25
|
-
exports
|
|
26
|
-
|
|
19
|
+
Object.defineProperty(exports, 'SolanaWalletConnector', {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return solanaCore.SolanaWalletConnector; }
|
|
22
|
+
});
|
|
27
23
|
Object.defineProperty(exports, 'isSolanaWallet', {
|
|
28
24
|
enumerable: true,
|
|
29
25
|
get: function () { return solanaCore.isSolanaWallet; }
|
|
30
26
|
});
|
|
31
|
-
exports.
|
|
27
|
+
exports.BackpackConnector = BackpackSol.BackpackSol;
|
|
28
|
+
exports.SolanaInjectedConnector = InjectedWalletBase.InjectedWalletBase;
|
|
29
|
+
exports.SolanaWalletConnectors = SolanaWalletConnectors.SolanaWalletConnectors;
|
|
30
|
+
exports.SolanaWalletConnectorsWithConfig = SolanaWalletConnectorsWithConfig.SolanaWalletConnectorsWithConfig;
|
|
31
|
+
exports.isBackpackSolanaSigner = isBackpackSolanaSigner.isBackpackSolanaSigner;
|
|
32
|
+
exports.isSignedMessage = isSignedMessage.isSignedMessage;
|
package/src/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { Phantom } from './Phantom';
|
|
2
|
-
export declare const SolanaWalletConnectors: (props: any) => (import("dist/packages/wallet-connector-core/src").WalletConnectorConstructor | typeof Phantom)[];
|
|
3
|
-
export { isSignedMessage } from './utils/isSignedMessage';
|
|
4
|
-
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
5
1
|
export type { IEmbeddedWalletSolanaSigner } from '@dynamic-labs/embedded-wallet-solana';
|
|
6
|
-
export { isSolanaWallet } from '@dynamic-labs/solana-core';
|
|
2
|
+
export { isSolanaWallet, SolanaWalletConnector, } from '@dynamic-labs/solana-core';
|
|
3
|
+
export { BackpackSol as BackpackConnector } from './injected/BackpackSol';
|
|
4
|
+
export { InjectedWalletBase as SolanaInjectedConnector } from './injected/InjectedWalletBase';
|
|
5
|
+
export { SolanaWalletConnectors } from './SolanaWalletConnectors';
|
|
6
|
+
export { SolanaWalletConnectorsWithConfig } from './SolanaWalletConnectorsWithConfig';
|
|
7
|
+
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
8
|
+
export { isSignedMessage } from './utils/isSignedMessage';
|
package/src/index.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export {
|
|
2
|
+
import { assertPackageVersion } from '@dynamic-labs/assert-package-version';
|
|
3
|
+
import { version } from '../package.js';
|
|
4
|
+
export { SolanaWalletConnector, isSolanaWallet } from '@dynamic-labs/solana-core';
|
|
5
|
+
export { BackpackSol as BackpackConnector } from './injected/BackpackSol/BackpackSol.js';
|
|
6
|
+
export { InjectedWalletBase as SolanaInjectedConnector } from './injected/InjectedWalletBase/InjectedWalletBase.js';
|
|
7
|
+
export { SolanaWalletConnectors } from './SolanaWalletConnectors.js';
|
|
8
|
+
export { SolanaWalletConnectorsWithConfig } from './SolanaWalletConnectorsWithConfig/SolanaWalletConnectorsWithConfig.js';
|
|
8
9
|
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner.js';
|
|
9
|
-
export {
|
|
10
|
+
export { isSignedMessage } from './utils/isSignedMessage.js';
|
|
10
11
|
|
|
11
12
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
12
|
-
|
|
13
|
-
...injectedWalletOverrides,
|
|
14
|
-
...fetchInjectedWalletConnectors(props),
|
|
15
|
-
...TurnkeySolanaWalletConnectors(props),
|
|
16
|
-
Phantom,
|
|
17
|
-
UnknownInjected,
|
|
18
|
-
FallbackSolanaConnector,
|
|
19
|
-
];
|
|
20
|
-
|
|
21
|
-
export { SolanaWalletConnectors };
|
|
13
|
+
assertPackageVersion('@dynamic-labs/solana', version);
|
|
@@ -3,22 +3,20 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
7
7
|
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var
|
|
9
|
-
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
8
|
+
var InjectedWalletBase = require('../InjectedWalletBase/InjectedWalletBase.cjs');
|
|
10
9
|
|
|
11
10
|
class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
14
13
|
this.name = 'Backpack';
|
|
15
14
|
this.overrideKey = 'backpacksol';
|
|
16
|
-
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
17
15
|
}
|
|
18
16
|
getSigner() {
|
|
19
17
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
20
18
|
var _a;
|
|
21
|
-
return (_a = this.
|
|
19
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
22
20
|
});
|
|
23
21
|
}
|
|
24
22
|
signMessage(messageToSign) {
|