@dynamic-labs/solana 4.0.0-alpha.37 → 4.0.0-alpha.39
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 +21 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +10 -10
- package/src/CoinbaseSolana/CoinbaseSolana.cjs +1 -1
- package/src/CoinbaseSolana/CoinbaseSolana.js +1 -1
- package/src/Phantom/Phantom.cjs +2 -4
- package/src/Phantom/Phantom.d.ts +1 -4
- package/src/Phantom/Phantom.js +2 -4
- package/src/SolProviderHelper/SolProviderHelper.cjs +13 -13
- package/src/SolProviderHelper/SolProviderHelper.d.ts +5 -6
- package/src/SolProviderHelper/SolProviderHelper.js +13 -13
- package/src/Solflare/Solflare.cjs +1 -1
- package/src/Solflare/Solflare.js +1 -1
- package/src/index.d.ts +0 -1
- package/src/injected/BackpackSol.cjs +1 -1
- package/src/injected/BackpackSol.js +1 -1
- package/src/injected/InjectedWalletBase.cjs +15 -31
- package/src/injected/InjectedWalletBase.d.ts +3 -82
- package/src/injected/InjectedWalletBase.js +15 -31
- package/src/injected/PhantomInjected.cjs +1 -1
- package/src/injected/PhantomInjected.js +1 -1
- package/src/injected/fetchInjectedWalletConnectors.cjs +0 -3
- package/src/injected/fetchInjectedWalletConnectors.js +0 -3
- package/src/types.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.0.0-alpha.39](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.38...v4.0.0-alpha.39) (2024-12-02)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* remove usages of findWalletBookWallet when possible (#7455)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* sdkHasLoaded always false in cookie enabled env ([#7516](https://github.com/dynamic-labs/dynamic-auth/issues/7516)) ([1c3335c](https://github.com/dynamic-labs/dynamic-auth/commit/1c3335c13930e9bffe60cf1c09bc9c9584a59ef7))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* remove usages of findWalletBookWallet when possible ([#7455](https://github.com/dynamic-labs/dynamic-auth/issues/7455)) ([0ce977d](https://github.com/dynamic-labs/dynamic-auth/commit/0ce977d5d4d591c371c6ea2edfb252ba7acff5d2))
|
|
15
|
+
|
|
16
|
+
## [4.0.0-alpha.38](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.37...v4.0.0-alpha.38) (2024-11-27)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Bug Fixes
|
|
20
|
+
|
|
21
|
+
* don't allow user to connect wallet in bridge while sdk is still loading ([#7506](https://github.com/dynamic-labs/dynamic-auth/issues/7506)) ([c0a913d](https://github.com/dynamic-labs/dynamic-auth/commit/c0a913d78675cc66b41f03ea9bfb316de5f95905))
|
|
22
|
+
|
|
2
23
|
## [4.0.0-alpha.37](https://github.com/dynamic-labs/dynamic-auth/compare/v4.0.0-alpha.36...v4.0.0-alpha.37) (2024-11-27)
|
|
3
24
|
|
|
4
25
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/solana",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.39",
|
|
4
4
|
"description": "A React SDK for implementing wallet web3 authentication and authorization to your website.",
|
|
5
5
|
"author": "Dynamic Labs, Inc.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,16 +25,16 @@
|
|
|
25
25
|
"@wallet-standard/experimental-features": "0.1.1",
|
|
26
26
|
"bs58": "5.0.0",
|
|
27
27
|
"tweetnacl": "1.0.3",
|
|
28
|
-
"@dynamic-labs/assert-package-version": "4.0.0-alpha.
|
|
29
|
-
"@dynamic-labs/embedded-wallet-solana": "4.0.0-alpha.
|
|
30
|
-
"@dynamic-labs/logger": "4.0.0-alpha.
|
|
31
|
-
"@dynamic-labs/rpc-providers": "4.0.0-alpha.
|
|
28
|
+
"@dynamic-labs/assert-package-version": "4.0.0-alpha.39",
|
|
29
|
+
"@dynamic-labs/embedded-wallet-solana": "4.0.0-alpha.39",
|
|
30
|
+
"@dynamic-labs/logger": "4.0.0-alpha.39",
|
|
31
|
+
"@dynamic-labs/rpc-providers": "4.0.0-alpha.39",
|
|
32
32
|
"@dynamic-labs/sdk-api-core": "0.0.570",
|
|
33
|
-
"@dynamic-labs/solana-core": "4.0.0-alpha.
|
|
34
|
-
"@dynamic-labs/types": "4.0.0-alpha.
|
|
35
|
-
"@dynamic-labs/utils": "4.0.0-alpha.
|
|
36
|
-
"@dynamic-labs/wallet-book": "4.0.0-alpha.
|
|
37
|
-
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.
|
|
33
|
+
"@dynamic-labs/solana-core": "4.0.0-alpha.39",
|
|
34
|
+
"@dynamic-labs/types": "4.0.0-alpha.39",
|
|
35
|
+
"@dynamic-labs/utils": "4.0.0-alpha.39",
|
|
36
|
+
"@dynamic-labs/wallet-book": "4.0.0-alpha.39",
|
|
37
|
+
"@dynamic-labs/wallet-connector-core": "4.0.0-alpha.39"
|
|
38
38
|
},
|
|
39
39
|
"peerDependencies": {}
|
|
40
40
|
}
|
|
@@ -17,7 +17,7 @@ class CoinbaseSolana extends InjectedWalletBase.InjectedWalletBase {
|
|
|
17
17
|
getSigner() {
|
|
18
18
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
19
19
|
var _a;
|
|
20
|
-
return (_a = this.
|
|
20
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
23
|
signMessage(messageToSign) {
|
|
@@ -13,7 +13,7 @@ class CoinbaseSolana extends InjectedWalletBase {
|
|
|
13
13
|
getSigner() {
|
|
14
14
|
return __awaiter(this, void 0, void 0, function* () {
|
|
15
15
|
var _a;
|
|
16
|
-
return (_a = this.
|
|
16
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
signMessage(messageToSign) {
|
package/src/Phantom/Phantom.cjs
CHANGED
|
@@ -6,16 +6,14 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
8
8
|
var utils = require('@dynamic-labs/utils');
|
|
9
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
10
9
|
var PhantomInjected = require('../injected/PhantomInjected.cjs');
|
|
11
10
|
var PhantomRedirect = require('../phantomRedirect/PhantomRedirect/PhantomRedirect.cjs');
|
|
12
11
|
|
|
13
12
|
class Phantom extends solanaCore.SolanaWalletConnector {
|
|
14
|
-
constructor(
|
|
15
|
-
super(
|
|
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* () {
|
package/src/Phantom/Phantom.d.ts
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
import { SolanaWalletConnector,
|
|
2
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
1
|
+
import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
3
2
|
import { WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
|
|
4
3
|
export declare class Phantom extends SolanaWalletConnector {
|
|
5
4
|
name: string;
|
|
6
5
|
overrideKey: string;
|
|
7
|
-
wallet: WalletSchema | undefined;
|
|
8
|
-
constructor(opts: SolanaWalletConnectorOpts);
|
|
9
6
|
connect(): Promise<void>;
|
|
10
7
|
getSigner(): Promise<ISolana | undefined>;
|
|
11
8
|
getMobileOrInstalledWallet(): WalletConnectorCore.WalletConnector;
|
package/src/Phantom/Phantom.js
CHANGED
|
@@ -2,16 +2,14 @@
|
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { SolanaWalletConnector } from '@dynamic-labs/solana-core';
|
|
4
4
|
import { isMobile } from '@dynamic-labs/utils';
|
|
5
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
6
5
|
import { PhantomInjected } from '../injected/PhantomInjected.js';
|
|
7
6
|
import { PhantomRedirect } from '../phantomRedirect/PhantomRedirect/PhantomRedirect.js';
|
|
8
7
|
|
|
9
8
|
class Phantom extends SolanaWalletConnector {
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
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* () {
|
|
@@ -5,20 +5,20 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
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
10
|
var findWalletProviderFromWalletStandard = require('../utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.cjs');
|
|
10
11
|
var isSignedMessage = require('../utils/isSignedMessage.cjs');
|
|
11
12
|
|
|
12
13
|
class SolProviderHelper {
|
|
13
|
-
constructor(
|
|
14
|
-
this.
|
|
15
|
-
this.
|
|
14
|
+
constructor(connector) {
|
|
15
|
+
this.walletBookWallet = walletBook.findWalletBookWallet(connector.walletBook, connector.key);
|
|
16
|
+
this.connector = connector;
|
|
16
17
|
}
|
|
17
18
|
getInjectedConfig() {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return injectedConfig.find((c) => c.chain === this.chain);
|
|
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());
|
|
22
22
|
}
|
|
23
23
|
getInstalledProvider() {
|
|
24
24
|
const config = this.getInjectedConfig();
|
|
@@ -69,7 +69,7 @@ class SolProviderHelper {
|
|
|
69
69
|
return walletConnectorCore.ProviderLookup(allInstalledProviders, extensionLocators);
|
|
70
70
|
}
|
|
71
71
|
findProvider() {
|
|
72
|
-
return this.
|
|
72
|
+
return this.connector.findProvider();
|
|
73
73
|
}
|
|
74
74
|
isInstalledHelper() {
|
|
75
75
|
return this.findProvider() !== undefined;
|
|
@@ -133,23 +133,23 @@ class SolProviderHelper {
|
|
|
133
133
|
}
|
|
134
134
|
});
|
|
135
135
|
}
|
|
136
|
-
_setupEventListeners(
|
|
136
|
+
_setupEventListeners() {
|
|
137
137
|
const provider = this.findProvider();
|
|
138
138
|
if (!provider) {
|
|
139
139
|
walletConnectorCore.logger.warn('Provider not found', {
|
|
140
|
-
connector:
|
|
140
|
+
connector: this.connector,
|
|
141
141
|
});
|
|
142
142
|
return;
|
|
143
143
|
}
|
|
144
144
|
if (!provider.on) {
|
|
145
145
|
walletConnectorCore.logger.warn('Provider does not support event listeners', {
|
|
146
|
-
connector:
|
|
146
|
+
connector: this.connector,
|
|
147
147
|
provider,
|
|
148
148
|
});
|
|
149
149
|
return;
|
|
150
150
|
}
|
|
151
|
-
provider.on('accountChanged', (publicKey) => this.handleAccountChange(
|
|
152
|
-
provider.on('disconnect', () =>
|
|
151
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(this.connector, provider, publicKey));
|
|
152
|
+
provider.on('disconnect', () => this.connector.emit('disconnect'));
|
|
153
153
|
}
|
|
154
154
|
_teardownEventListeners() {
|
|
155
155
|
const provider = this.findProvider();
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import { ExtensionLocator, ISolana } from '@dynamic-labs/solana-core';
|
|
2
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
3
2
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
4
|
-
import {
|
|
3
|
+
import { InjectedWalletBase } from '../injected/InjectedWalletBase';
|
|
5
4
|
export declare class SolProviderHelper {
|
|
6
|
-
private
|
|
7
|
-
private
|
|
8
|
-
constructor(
|
|
5
|
+
private walletBookWallet;
|
|
6
|
+
private connector;
|
|
7
|
+
constructor(connector: InjectedWalletBase);
|
|
9
8
|
getInjectedConfig(): {
|
|
10
9
|
chain: string;
|
|
11
10
|
extensionLocators: {
|
|
@@ -33,7 +32,7 @@ export declare class SolProviderHelper {
|
|
|
33
32
|
connect(): Promise<ISolana | undefined>;
|
|
34
33
|
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
35
34
|
handleAccountChange(walletConnector: WalletConnector, web3Provider: ISolana, address: string): Promise<void>;
|
|
36
|
-
_setupEventListeners(
|
|
35
|
+
_setupEventListeners(): void;
|
|
37
36
|
_teardownEventListeners(): void;
|
|
38
37
|
getConnectedAccounts(): Promise<string[]>;
|
|
39
38
|
}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
'use client'
|
|
2
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
6
|
import { findWalletProviderFromWalletStandard } from '../utils/findWalletProviderFromWalletStandard/findWalletProviderFromWalletStandard.js';
|
|
6
7
|
import { isSignedMessage } from '../utils/isSignedMessage.js';
|
|
7
8
|
|
|
8
9
|
class SolProviderHelper {
|
|
9
|
-
constructor(
|
|
10
|
-
this.
|
|
11
|
-
this.
|
|
10
|
+
constructor(connector) {
|
|
11
|
+
this.walletBookWallet = findWalletBookWallet(connector.walletBook, connector.key);
|
|
12
|
+
this.connector = connector;
|
|
12
13
|
}
|
|
13
14
|
getInjectedConfig() {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return injectedConfig.find((c) => c.chain === this.chain);
|
|
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());
|
|
18
18
|
}
|
|
19
19
|
getInstalledProvider() {
|
|
20
20
|
const config = this.getInjectedConfig();
|
|
@@ -65,7 +65,7 @@ class SolProviderHelper {
|
|
|
65
65
|
return ProviderLookup(allInstalledProviders, extensionLocators);
|
|
66
66
|
}
|
|
67
67
|
findProvider() {
|
|
68
|
-
return this.
|
|
68
|
+
return this.connector.findProvider();
|
|
69
69
|
}
|
|
70
70
|
isInstalledHelper() {
|
|
71
71
|
return this.findProvider() !== undefined;
|
|
@@ -129,23 +129,23 @@ class SolProviderHelper {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
|
-
_setupEventListeners(
|
|
132
|
+
_setupEventListeners() {
|
|
133
133
|
const provider = this.findProvider();
|
|
134
134
|
if (!provider) {
|
|
135
135
|
logger.warn('Provider not found', {
|
|
136
|
-
connector:
|
|
136
|
+
connector: this.connector,
|
|
137
137
|
});
|
|
138
138
|
return;
|
|
139
139
|
}
|
|
140
140
|
if (!provider.on) {
|
|
141
141
|
logger.warn('Provider does not support event listeners', {
|
|
142
|
-
connector:
|
|
142
|
+
connector: this.connector,
|
|
143
143
|
provider,
|
|
144
144
|
});
|
|
145
145
|
return;
|
|
146
146
|
}
|
|
147
|
-
provider.on('accountChanged', (publicKey) => this.handleAccountChange(
|
|
148
|
-
provider.on('disconnect', () =>
|
|
147
|
+
provider.on('accountChanged', (publicKey) => this.handleAccountChange(this.connector, provider, publicKey));
|
|
148
|
+
provider.on('disconnect', () => this.connector.emit('disconnect'));
|
|
149
149
|
}
|
|
150
150
|
_teardownEventListeners() {
|
|
151
151
|
const provider = this.findProvider();
|
|
@@ -28,7 +28,7 @@ class Solflare extends InjectedWalletBase.InjectedWalletBase {
|
|
|
28
28
|
});
|
|
29
29
|
return;
|
|
30
30
|
}
|
|
31
|
-
return (_b = this.
|
|
31
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
signMessage(messageToSign) {
|
package/src/Solflare/Solflare.js
CHANGED
|
@@ -24,7 +24,7 @@ class Solflare extends InjectedWalletBase {
|
|
|
24
24
|
});
|
|
25
25
|
return;
|
|
26
26
|
}
|
|
27
|
-
return (_b = this.
|
|
27
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
30
|
signMessage(messageToSign) {
|
package/src/index.d.ts
CHANGED
|
@@ -4,6 +4,5 @@ export { BackpackSol as BackpackConnector } from './injected/BackpackSol';
|
|
|
4
4
|
export { InjectedWalletBase as SolanaInjectedConnector } from './injected/InjectedWalletBase';
|
|
5
5
|
export { SolanaWalletConnectors } from './SolanaWalletConnectors';
|
|
6
6
|
export { SolanaWalletConnectorsWithConfig } from './SolanaWalletConnectorsWithConfig';
|
|
7
|
-
export type { AllowedSolanaChain } from './types';
|
|
8
7
|
export { isBackpackSolanaSigner } from './utils/isBackpackSolanaSigner';
|
|
9
8
|
export { isSignedMessage } from './utils/isSignedMessage';
|
|
@@ -16,7 +16,7 @@ class BackpackSol extends InjectedWalletBase.InjectedWalletBase {
|
|
|
16
16
|
getSigner() {
|
|
17
17
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
18
18
|
var _a;
|
|
19
|
-
return (_a = this.
|
|
19
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
20
20
|
});
|
|
21
21
|
}
|
|
22
22
|
signMessage(messageToSign) {
|
|
@@ -12,7 +12,7 @@ class BackpackSol extends InjectedWalletBase {
|
|
|
12
12
|
getSigner() {
|
|
13
13
|
return __awaiter(this, void 0, void 0, function* () {
|
|
14
14
|
var _a;
|
|
15
|
-
return (_a = this.
|
|
15
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
signMessage(messageToSign) {
|
|
@@ -5,56 +5,40 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
var _tslib = require('../../_virtual/_tslib.cjs');
|
|
7
7
|
var web3_js = require('@solana/web3.js');
|
|
8
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
9
8
|
var utils = require('@dynamic-labs/utils');
|
|
10
9
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
11
10
|
var SolProviderHelper = require('../SolProviderHelper/SolProviderHelper.cjs');
|
|
12
11
|
var SignMessageNotSupportedError = require('../errors/SignMessageNotSupportedError.cjs');
|
|
13
12
|
|
|
14
13
|
class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
* The chain being used.
|
|
19
|
-
* Defaults to 'sol', obviously, but since this connector is also used for other chains,
|
|
20
|
-
* such as eclipse, this can be overridden.
|
|
21
|
-
*/
|
|
22
|
-
this.solanaChain = 'sol';
|
|
23
|
-
}
|
|
24
|
-
get wallet() {
|
|
25
|
-
if (!this._wallet) {
|
|
26
|
-
this._wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
27
|
-
}
|
|
28
|
-
return this._wallet;
|
|
29
|
-
}
|
|
30
|
-
getSolProviderHelper() {
|
|
31
|
-
if (this.wallet && !this.solProviderHelper) {
|
|
32
|
-
this.solProviderHelper = new SolProviderHelper.SolProviderHelper(this.wallet, this.solanaChain);
|
|
14
|
+
get solProviderHelper() {
|
|
15
|
+
if (!this._solProviderHelper) {
|
|
16
|
+
this._solProviderHelper = new SolProviderHelper.SolProviderHelper(this);
|
|
33
17
|
}
|
|
34
|
-
return this.
|
|
18
|
+
return this._solProviderHelper;
|
|
35
19
|
}
|
|
36
|
-
|
|
20
|
+
findProvider() {
|
|
37
21
|
var _a;
|
|
38
|
-
return (_a = this.
|
|
22
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
39
23
|
}
|
|
40
24
|
setupEventListeners() {
|
|
41
25
|
var _a;
|
|
42
|
-
(_a = this.
|
|
26
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._setupEventListeners();
|
|
43
27
|
}
|
|
44
28
|
teardownEventListeners() {
|
|
45
29
|
var _a;
|
|
46
|
-
(_a = this.
|
|
30
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._teardownEventListeners();
|
|
47
31
|
}
|
|
48
32
|
connect() {
|
|
49
33
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
50
34
|
var _a;
|
|
51
|
-
yield ((_a = this.
|
|
35
|
+
yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect());
|
|
52
36
|
});
|
|
53
37
|
}
|
|
54
38
|
getSigner() {
|
|
55
39
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
56
40
|
var _a;
|
|
57
|
-
return (_a = this.
|
|
41
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
58
42
|
});
|
|
59
43
|
}
|
|
60
44
|
createUiTransaction(from) {
|
|
@@ -91,7 +75,7 @@ class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
|
|
|
91
75
|
}
|
|
92
76
|
isInstalledOnBrowser() {
|
|
93
77
|
var _a;
|
|
94
|
-
return Boolean((_a = this.
|
|
78
|
+
return Boolean((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
|
|
95
79
|
}
|
|
96
80
|
getAddress() {
|
|
97
81
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
@@ -108,23 +92,23 @@ class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
|
|
|
108
92
|
}
|
|
109
93
|
return;
|
|
110
94
|
}
|
|
111
|
-
return (_b = this.
|
|
95
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
112
96
|
});
|
|
113
97
|
}
|
|
114
98
|
signMessage(messageToSign) {
|
|
115
99
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
116
100
|
var _a, _b;
|
|
117
|
-
const walletAddress = yield ((_a = this.
|
|
101
|
+
const walletAddress = yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
|
|
118
102
|
if (walletAddress && this.isLedgerAddress(walletAddress)) {
|
|
119
103
|
throw new SignMessageNotSupportedError.SignMessageNotSupportedError(this.name);
|
|
120
104
|
}
|
|
121
|
-
return (_b = this.
|
|
105
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.signMessage(messageToSign);
|
|
122
106
|
});
|
|
123
107
|
}
|
|
124
108
|
getConnectedAccounts() {
|
|
125
109
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
126
110
|
var _a, _b;
|
|
127
|
-
return (_b = (_a = this.
|
|
111
|
+
return (_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getConnectedAccounts()) !== null && _b !== void 0 ? _b : [];
|
|
128
112
|
});
|
|
129
113
|
}
|
|
130
114
|
}
|
|
@@ -1,90 +1,11 @@
|
|
|
1
|
-
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
2
1
|
import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
3
2
|
import { IUITransaction } from '@dynamic-labs/types';
|
|
4
3
|
import { ISendBalanceWalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
4
|
import { SolProviderHelper } from '../SolProviderHelper';
|
|
6
|
-
import { AllowedSolanaChain } from '../types';
|
|
7
5
|
export declare abstract class InjectedWalletBase extends SolanaWalletConnector implements ISendBalanceWalletConnector {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
* The chain being used.
|
|
12
|
-
* Defaults to 'sol', obviously, but since this connector is also used for other chains,
|
|
13
|
-
* such as eclipse, this can be overridden.
|
|
14
|
-
*/
|
|
15
|
-
solanaChain: AllowedSolanaChain;
|
|
16
|
-
get wallet(): {
|
|
17
|
-
name: string;
|
|
18
|
-
brand?: {
|
|
19
|
-
alt?: string | undefined;
|
|
20
|
-
primaryColor?: string | undefined;
|
|
21
|
-
spriteId?: string | undefined;
|
|
22
|
-
} | undefined;
|
|
23
|
-
chainGroup?: string | undefined;
|
|
24
|
-
chains?: string[] | undefined;
|
|
25
|
-
desktop?: {
|
|
26
|
-
chromeId?: string | undefined;
|
|
27
|
-
edgeId?: string | undefined;
|
|
28
|
-
firefoxId?: string | undefined;
|
|
29
|
-
native?: string | undefined;
|
|
30
|
-
operaId?: string | undefined;
|
|
31
|
-
safariId?: string | undefined;
|
|
32
|
-
universal?: string | undefined;
|
|
33
|
-
} | undefined;
|
|
34
|
-
eip6963Config?: {
|
|
35
|
-
rdns: string;
|
|
36
|
-
} | undefined;
|
|
37
|
-
filterFromWalletConnect?: boolean | undefined;
|
|
38
|
-
group?: string | undefined;
|
|
39
|
-
hardwareWallets?: string[] | undefined;
|
|
40
|
-
injectedConfig?: {
|
|
41
|
-
chain: string;
|
|
42
|
-
extensionLocators: {
|
|
43
|
-
value: boolean;
|
|
44
|
-
flag: string;
|
|
45
|
-
}[];
|
|
46
|
-
providerInterface?: string | undefined;
|
|
47
|
-
walletStandard?: {
|
|
48
|
-
features: string[];
|
|
49
|
-
name: string;
|
|
50
|
-
providerId?: string | undefined;
|
|
51
|
-
} | undefined;
|
|
52
|
-
walletStandardLocators?: {
|
|
53
|
-
name: string;
|
|
54
|
-
locator: string;
|
|
55
|
-
}[] | undefined;
|
|
56
|
-
windowLocations?: string[] | undefined;
|
|
57
|
-
}[] | undefined;
|
|
58
|
-
mobile?: {
|
|
59
|
-
android?: string | null | undefined;
|
|
60
|
-
androidId?: string | undefined;
|
|
61
|
-
inAppBrowser?: string | null | undefined;
|
|
62
|
-
ios?: string | null | undefined;
|
|
63
|
-
iosId?: string | undefined;
|
|
64
|
-
native?: string | undefined;
|
|
65
|
-
universal?: string | undefined;
|
|
66
|
-
} | undefined;
|
|
67
|
-
mobileExperience?: "in-app-browser" | "redirect" | undefined;
|
|
68
|
-
shortName?: string | undefined;
|
|
69
|
-
showOnlyIfInstalled?: boolean | undefined;
|
|
70
|
-
switchNetworkOnlyFromWallet?: boolean | undefined;
|
|
71
|
-
walletConnect?: {
|
|
72
|
-
sdks?: string[] | undefined;
|
|
73
|
-
} | undefined;
|
|
74
|
-
walletGroup?: string | undefined;
|
|
75
|
-
walletLimitations?: {
|
|
76
|
-
browserExtension?: {
|
|
77
|
-
unsupportedEvents?: string[] | undefined;
|
|
78
|
-
unsupportedMethods?: string[] | undefined;
|
|
79
|
-
} | undefined;
|
|
80
|
-
mobile?: {
|
|
81
|
-
unsupportedEvents?: string[] | undefined;
|
|
82
|
-
unsupportedMethods?: string[] | undefined;
|
|
83
|
-
} | undefined;
|
|
84
|
-
} | undefined;
|
|
85
|
-
} | undefined;
|
|
86
|
-
getSolProviderHelper(): SolProviderHelper | undefined;
|
|
87
|
-
getProvider(): ISolana | undefined;
|
|
6
|
+
_solProviderHelper: SolProviderHelper | undefined;
|
|
7
|
+
get solProviderHelper(): SolProviderHelper | undefined;
|
|
8
|
+
findProvider(): ISolana | undefined;
|
|
88
9
|
setupEventListeners(): void;
|
|
89
10
|
teardownEventListeners(): void;
|
|
90
11
|
connect(): Promise<void>;
|
|
@@ -1,56 +1,40 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { PublicKey } from '@solana/web3.js';
|
|
4
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
4
|
import { isMobile, template } from '@dynamic-labs/utils';
|
|
6
5
|
import { SolanaWalletConnector, SolanaUiTransaction } from '@dynamic-labs/solana-core';
|
|
7
6
|
import { SolProviderHelper } from '../SolProviderHelper/SolProviderHelper.js';
|
|
8
7
|
import { SignMessageNotSupportedError } from '../errors/SignMessageNotSupportedError.js';
|
|
9
8
|
|
|
10
9
|
class InjectedWalletBase extends SolanaWalletConnector {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
* The chain being used.
|
|
15
|
-
* Defaults to 'sol', obviously, but since this connector is also used for other chains,
|
|
16
|
-
* such as eclipse, this can be overridden.
|
|
17
|
-
*/
|
|
18
|
-
this.solanaChain = 'sol';
|
|
19
|
-
}
|
|
20
|
-
get wallet() {
|
|
21
|
-
if (!this._wallet) {
|
|
22
|
-
this._wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
23
|
-
}
|
|
24
|
-
return this._wallet;
|
|
25
|
-
}
|
|
26
|
-
getSolProviderHelper() {
|
|
27
|
-
if (this.wallet && !this.solProviderHelper) {
|
|
28
|
-
this.solProviderHelper = new SolProviderHelper(this.wallet, this.solanaChain);
|
|
10
|
+
get solProviderHelper() {
|
|
11
|
+
if (!this._solProviderHelper) {
|
|
12
|
+
this._solProviderHelper = new SolProviderHelper(this);
|
|
29
13
|
}
|
|
30
|
-
return this.
|
|
14
|
+
return this._solProviderHelper;
|
|
31
15
|
}
|
|
32
|
-
|
|
16
|
+
findProvider() {
|
|
33
17
|
var _a;
|
|
34
|
-
return (_a = this.
|
|
18
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
35
19
|
}
|
|
36
20
|
setupEventListeners() {
|
|
37
21
|
var _a;
|
|
38
|
-
(_a = this.
|
|
22
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._setupEventListeners();
|
|
39
23
|
}
|
|
40
24
|
teardownEventListeners() {
|
|
41
25
|
var _a;
|
|
42
|
-
(_a = this.
|
|
26
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._teardownEventListeners();
|
|
43
27
|
}
|
|
44
28
|
connect() {
|
|
45
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
46
30
|
var _a;
|
|
47
|
-
yield ((_a = this.
|
|
31
|
+
yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect());
|
|
48
32
|
});
|
|
49
33
|
}
|
|
50
34
|
getSigner() {
|
|
51
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
36
|
var _a;
|
|
53
|
-
return (_a = this.
|
|
37
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
54
38
|
});
|
|
55
39
|
}
|
|
56
40
|
createUiTransaction(from) {
|
|
@@ -87,7 +71,7 @@ class InjectedWalletBase extends SolanaWalletConnector {
|
|
|
87
71
|
}
|
|
88
72
|
isInstalledOnBrowser() {
|
|
89
73
|
var _a;
|
|
90
|
-
return Boolean((_a = this.
|
|
74
|
+
return Boolean((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
|
|
91
75
|
}
|
|
92
76
|
getAddress() {
|
|
93
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -104,23 +88,23 @@ class InjectedWalletBase extends SolanaWalletConnector {
|
|
|
104
88
|
}
|
|
105
89
|
return;
|
|
106
90
|
}
|
|
107
|
-
return (_b = this.
|
|
91
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
108
92
|
});
|
|
109
93
|
}
|
|
110
94
|
signMessage(messageToSign) {
|
|
111
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
112
96
|
var _a, _b;
|
|
113
|
-
const walletAddress = yield ((_a = this.
|
|
97
|
+
const walletAddress = yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
|
|
114
98
|
if (walletAddress && this.isLedgerAddress(walletAddress)) {
|
|
115
99
|
throw new SignMessageNotSupportedError(this.name);
|
|
116
100
|
}
|
|
117
|
-
return (_b = this.
|
|
101
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.signMessage(messageToSign);
|
|
118
102
|
});
|
|
119
103
|
}
|
|
120
104
|
getConnectedAccounts() {
|
|
121
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
122
106
|
var _a, _b;
|
|
123
|
-
return (_b = (_a = this.
|
|
107
|
+
return (_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getConnectedAccounts()) !== null && _b !== void 0 ? _b : [];
|
|
124
108
|
});
|
|
125
109
|
}
|
|
126
110
|
}
|
|
@@ -32,7 +32,7 @@ class PhantomInjected extends InjectedWalletBase.InjectedWalletBase {
|
|
|
32
32
|
}
|
|
33
33
|
canGetChainAddress() {
|
|
34
34
|
var _a, _b;
|
|
35
|
-
return ((_b = (_a = this.
|
|
35
|
+
return ((_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) === null || _b === void 0 ? void 0 : _b.publicKey) !== null;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
@@ -28,7 +28,7 @@ class PhantomInjected extends InjectedWalletBase {
|
|
|
28
28
|
}
|
|
29
29
|
canGetChainAddress() {
|
|
30
30
|
var _a, _b;
|
|
31
|
-
return ((_b = (_a = this.
|
|
31
|
+
return ((_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.findProvider()) === null || _b === void 0 ? void 0 : _b.publicKey) !== null;
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
package/src/types.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which Solana chains are available for use.
|
|
3
|
-
*
|
|
4
|
-
* Should follow the same names as those seen in the `injectedConfig[number].chain` property
|
|
5
|
-
* from the `getInjectedConfig` method under SolProviderHelper.
|
|
6
|
-
*/
|
|
7
|
-
export type AllowedSolanaChain = 'sol' | 'eclipse';
|