@dynamic-labs/solana 4.0.0-alpha.4 → 4.0.0-alpha.41
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 +361 -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} +17 -16
- package/src/{solProviderHelper.d.ts → SolProviderHelper/SolProviderHelper.d.ts} +6 -5
- package/src/{solProviderHelper.js → SolProviderHelper/SolProviderHelper.js} +17 -16
- 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/SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs +2 -2
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.d.ts +3 -3
- package/src/SolanaWalletStandardConnector/SolanaWalletStandardConnector.js +3 -3
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.cjs +2 -2
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.d.ts +2 -2
- package/src/SolanaWalletStandardConnector/utils/createSolanaSignerFromWalletStandard/createSolanaSignerFromWalletStandard.js +1 -1
- 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 +3 -5
- package/src/injected/BackpackSol.d.ts +0 -2
- package/src/injected/BackpackSol.js +3 -5
- package/src/injected/FallbackSolanaConnector.cjs +2 -4
- package/src/injected/FallbackSolanaConnector.d.ts +0 -2
- package/src/injected/FallbackSolanaConnector.js +2 -4
- package/src/injected/InjectedWalletBase.cjs +21 -25
- package/src/injected/InjectedWalletBase.d.ts +6 -8
- package/src/injected/InjectedWalletBase.js +22 -26
- package/src/injected/PhantomInjected.cjs +3 -5
- package/src/injected/PhantomInjected.d.ts +0 -2
- package/src/injected/PhantomInjected.js +3 -5
- package/src/injected/fetchInjectedWalletConnectors.cjs +4 -5
- package/src/injected/fetchInjectedWalletConnectors.js +4 -5
- package/src/injected/index.d.ts +0 -1
- 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/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/phantomRedirect/{storage.cjs → storage/storage.cjs} +0 -0
- /package/src/phantomRedirect/{storage.js → storage/storage.js} +0 -0
|
@@ -3,16 +3,14 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var walletBook = require('@dynamic-labs/wallet-book');
|
|
7
6
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
8
7
|
|
|
9
8
|
class FallbackSolanaConnector extends InjectedWalletBase.InjectedWalletBase {
|
|
10
|
-
constructor(
|
|
11
|
-
super(
|
|
9
|
+
constructor() {
|
|
10
|
+
super(...arguments);
|
|
12
11
|
this.name = 'Fallback Connector';
|
|
13
12
|
this.overrideKey = 'fallbackconnector';
|
|
14
13
|
this.isAvailable = false;
|
|
15
|
-
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
16
14
|
}
|
|
17
15
|
isInstalledOnBrowser() {
|
|
18
16
|
return false;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
|
|
2
1
|
import { InjectedWalletBase } from './InjectedWalletBase';
|
|
3
2
|
export declare class FallbackSolanaConnector extends InjectedWalletBase {
|
|
4
3
|
name: string;
|
|
5
4
|
overrideKey: string;
|
|
6
5
|
isAvailable: boolean;
|
|
7
|
-
constructor(opts: SolWalletConnectorOpts);
|
|
8
6
|
isInstalledOnBrowser(): boolean;
|
|
9
7
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
3
2
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
4
3
|
|
|
5
4
|
class FallbackSolanaConnector extends InjectedWalletBase {
|
|
6
|
-
constructor(
|
|
7
|
-
super(
|
|
5
|
+
constructor() {
|
|
6
|
+
super(...arguments);
|
|
8
7
|
this.name = 'Fallback Connector';
|
|
9
8
|
this.overrideKey = 'fallbackconnector';
|
|
10
9
|
this.isAvailable = false;
|
|
11
|
-
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
12
10
|
}
|
|
13
11
|
isInstalledOnBrowser() {
|
|
14
12
|
return false;
|
|
@@ -5,44 +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
|
-
var
|
|
10
|
+
var SolProviderHelper = require('../SolProviderHelper/SolProviderHelper.cjs');
|
|
12
11
|
var SignMessageNotSupportedError = require('../errors/SignMessageNotSupportedError.cjs');
|
|
13
12
|
|
|
14
|
-
class InjectedWalletBase extends solanaCore.
|
|
15
|
-
|
|
16
|
-
if (!this.
|
|
17
|
-
this.
|
|
13
|
+
class InjectedWalletBase extends solanaCore.SolanaWalletConnector {
|
|
14
|
+
get solProviderHelper() {
|
|
15
|
+
if (!this._solProviderHelper) {
|
|
16
|
+
this._solProviderHelper = new SolProviderHelper.SolProviderHelper(this);
|
|
18
17
|
}
|
|
19
|
-
|
|
20
|
-
this.solProviderHelper = new solProviderHelper.SolProviderHelper(this.wallet);
|
|
21
|
-
}
|
|
22
|
-
return this.solProviderHelper;
|
|
18
|
+
return this._solProviderHelper;
|
|
23
19
|
}
|
|
24
|
-
|
|
20
|
+
findProvider() {
|
|
25
21
|
var _a;
|
|
26
|
-
return (_a = this.
|
|
22
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
27
23
|
}
|
|
28
24
|
setupEventListeners() {
|
|
29
25
|
var _a;
|
|
30
|
-
(_a = this.
|
|
26
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._setupEventListeners();
|
|
31
27
|
}
|
|
32
28
|
teardownEventListeners() {
|
|
33
29
|
var _a;
|
|
34
|
-
(_a = this.
|
|
30
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._teardownEventListeners();
|
|
35
31
|
}
|
|
36
32
|
connect() {
|
|
37
33
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
38
34
|
var _a;
|
|
39
|
-
yield ((_a = this.
|
|
35
|
+
yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect());
|
|
40
36
|
});
|
|
41
37
|
}
|
|
42
38
|
getSigner() {
|
|
43
39
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
44
40
|
var _a;
|
|
45
|
-
return (_a = this.
|
|
41
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
46
42
|
});
|
|
47
43
|
}
|
|
48
44
|
createUiTransaction(from) {
|
|
@@ -53,6 +49,8 @@ class InjectedWalletBase extends solanaCore.SolWalletConnector {
|
|
|
53
49
|
from,
|
|
54
50
|
onSubmit: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
55
51
|
var _a;
|
|
52
|
+
if (!transaction)
|
|
53
|
+
return;
|
|
56
54
|
const signer = yield this.getSigner();
|
|
57
55
|
if (!signer)
|
|
58
56
|
throw new Error('Signer not found');
|
|
@@ -72,23 +70,21 @@ class InjectedWalletBase extends solanaCore.SolWalletConnector {
|
|
|
72
70
|
return (yield signer.signAndSendTransaction(transaction)).signature;
|
|
73
71
|
}),
|
|
74
72
|
});
|
|
75
|
-
transaction.feeDeducted = true;
|
|
76
73
|
return transaction;
|
|
77
74
|
});
|
|
78
75
|
}
|
|
79
76
|
isInstalledOnBrowser() {
|
|
80
77
|
var _a;
|
|
81
|
-
return Boolean((_a = this.
|
|
78
|
+
return Boolean((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
|
|
82
79
|
}
|
|
83
80
|
getAddress() {
|
|
84
81
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
85
82
|
var _a, _b;
|
|
86
83
|
if (!this.isInstalledOnBrowser()) {
|
|
87
84
|
if (utils.isMobile() &&
|
|
88
|
-
((_a = this.
|
|
89
|
-
this.wallet.mobile.inAppBrowser &&
|
|
85
|
+
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
90
86
|
this.mobileExperience === 'in-app-browser') {
|
|
91
|
-
const inAppBrowserCompiledTemplate = utils.template(this.
|
|
87
|
+
const inAppBrowserCompiledTemplate = utils.template(this.metadata.inAppBrowserUrl);
|
|
92
88
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
93
89
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
94
90
|
});
|
|
@@ -96,23 +92,23 @@ class InjectedWalletBase extends solanaCore.SolWalletConnector {
|
|
|
96
92
|
}
|
|
97
93
|
return;
|
|
98
94
|
}
|
|
99
|
-
return (_b = this.
|
|
95
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
100
96
|
});
|
|
101
97
|
}
|
|
102
98
|
signMessage(messageToSign) {
|
|
103
99
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
104
100
|
var _a, _b;
|
|
105
|
-
const walletAddress = yield ((_a = this.
|
|
101
|
+
const walletAddress = yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
|
|
106
102
|
if (walletAddress && this.isLedgerAddress(walletAddress)) {
|
|
107
103
|
throw new SignMessageNotSupportedError.SignMessageNotSupportedError(this.name);
|
|
108
104
|
}
|
|
109
|
-
return (_b = this.
|
|
105
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.signMessage(messageToSign);
|
|
110
106
|
});
|
|
111
107
|
}
|
|
112
108
|
getConnectedAccounts() {
|
|
113
109
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
114
110
|
var _a, _b;
|
|
115
|
-
return (_b = (_a = this.
|
|
111
|
+
return (_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getConnectedAccounts()) !== null && _b !== void 0 ? _b : [];
|
|
116
112
|
});
|
|
117
113
|
}
|
|
118
114
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { SolWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
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
|
-
import { SolProviderHelper } from '../
|
|
6
|
-
export declare abstract class InjectedWalletBase extends
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
getProvider(): ISolana | undefined;
|
|
4
|
+
import { SolProviderHelper } from '../SolProviderHelper';
|
|
5
|
+
export declare abstract class InjectedWalletBase extends SolanaWalletConnector implements ISendBalanceWalletConnector {
|
|
6
|
+
_solProviderHelper: SolProviderHelper | undefined;
|
|
7
|
+
get solProviderHelper(): SolProviderHelper | undefined;
|
|
8
|
+
findProvider(): ISolana | undefined;
|
|
11
9
|
setupEventListeners(): void;
|
|
12
10
|
teardownEventListeners(): void;
|
|
13
11
|
connect(): Promise<void>;
|
|
@@ -1,44 +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
|
-
import {
|
|
7
|
-
import { SolProviderHelper } from '../
|
|
5
|
+
import { SolanaWalletConnector, SolanaUiTransaction } from '@dynamic-labs/solana-core';
|
|
6
|
+
import { SolProviderHelper } from '../SolProviderHelper/SolProviderHelper.js';
|
|
8
7
|
import { SignMessageNotSupportedError } from '../errors/SignMessageNotSupportedError.js';
|
|
9
8
|
|
|
10
|
-
class InjectedWalletBase extends
|
|
11
|
-
|
|
12
|
-
if (!this.
|
|
13
|
-
this.
|
|
9
|
+
class InjectedWalletBase extends SolanaWalletConnector {
|
|
10
|
+
get solProviderHelper() {
|
|
11
|
+
if (!this._solProviderHelper) {
|
|
12
|
+
this._solProviderHelper = new SolProviderHelper(this);
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
this.solProviderHelper = new SolProviderHelper(this.wallet);
|
|
17
|
-
}
|
|
18
|
-
return this.solProviderHelper;
|
|
14
|
+
return this._solProviderHelper;
|
|
19
15
|
}
|
|
20
|
-
|
|
16
|
+
findProvider() {
|
|
21
17
|
var _a;
|
|
22
|
-
return (_a = this.
|
|
18
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getInstalledProvider();
|
|
23
19
|
}
|
|
24
20
|
setupEventListeners() {
|
|
25
21
|
var _a;
|
|
26
|
-
(_a = this.
|
|
22
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._setupEventListeners();
|
|
27
23
|
}
|
|
28
24
|
teardownEventListeners() {
|
|
29
25
|
var _a;
|
|
30
|
-
(_a = this.
|
|
26
|
+
(_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a._teardownEventListeners();
|
|
31
27
|
}
|
|
32
28
|
connect() {
|
|
33
29
|
return __awaiter(this, void 0, void 0, function* () {
|
|
34
30
|
var _a;
|
|
35
|
-
yield ((_a = this.
|
|
31
|
+
yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect());
|
|
36
32
|
});
|
|
37
33
|
}
|
|
38
34
|
getSigner() {
|
|
39
35
|
return __awaiter(this, void 0, void 0, function* () {
|
|
40
36
|
var _a;
|
|
41
|
-
return (_a = this.
|
|
37
|
+
return (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.connect();
|
|
42
38
|
});
|
|
43
39
|
}
|
|
44
40
|
createUiTransaction(from) {
|
|
@@ -49,6 +45,8 @@ class InjectedWalletBase extends SolWalletConnector {
|
|
|
49
45
|
from,
|
|
50
46
|
onSubmit: (transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
51
47
|
var _a;
|
|
48
|
+
if (!transaction)
|
|
49
|
+
return;
|
|
52
50
|
const signer = yield this.getSigner();
|
|
53
51
|
if (!signer)
|
|
54
52
|
throw new Error('Signer not found');
|
|
@@ -68,23 +66,21 @@ class InjectedWalletBase extends SolWalletConnector {
|
|
|
68
66
|
return (yield signer.signAndSendTransaction(transaction)).signature;
|
|
69
67
|
}),
|
|
70
68
|
});
|
|
71
|
-
transaction.feeDeducted = true;
|
|
72
69
|
return transaction;
|
|
73
70
|
});
|
|
74
71
|
}
|
|
75
72
|
isInstalledOnBrowser() {
|
|
76
73
|
var _a;
|
|
77
|
-
return Boolean((_a = this.
|
|
74
|
+
return Boolean((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.isInstalledHelper());
|
|
78
75
|
}
|
|
79
76
|
getAddress() {
|
|
80
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
81
78
|
var _a, _b;
|
|
82
79
|
if (!this.isInstalledOnBrowser()) {
|
|
83
80
|
if (isMobile() &&
|
|
84
|
-
((_a = this.
|
|
85
|
-
this.wallet.mobile.inAppBrowser &&
|
|
81
|
+
((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.inAppBrowserUrl) &&
|
|
86
82
|
this.mobileExperience === 'in-app-browser') {
|
|
87
|
-
const inAppBrowserCompiledTemplate = template(this.
|
|
83
|
+
const inAppBrowserCompiledTemplate = template(this.metadata.inAppBrowserUrl);
|
|
88
84
|
const deepLink = inAppBrowserCompiledTemplate({
|
|
89
85
|
encodedDappURI: encodeURIComponent(window.location.toString()),
|
|
90
86
|
});
|
|
@@ -92,23 +88,23 @@ class InjectedWalletBase extends SolWalletConnector {
|
|
|
92
88
|
}
|
|
93
89
|
return;
|
|
94
90
|
}
|
|
95
|
-
return (_b = this.
|
|
91
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.getAddress();
|
|
96
92
|
});
|
|
97
93
|
}
|
|
98
94
|
signMessage(messageToSign) {
|
|
99
95
|
return __awaiter(this, void 0, void 0, function* () {
|
|
100
96
|
var _a, _b;
|
|
101
|
-
const walletAddress = yield ((_a = this.
|
|
97
|
+
const walletAddress = yield ((_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getAddress());
|
|
102
98
|
if (walletAddress && this.isLedgerAddress(walletAddress)) {
|
|
103
99
|
throw new SignMessageNotSupportedError(this.name);
|
|
104
100
|
}
|
|
105
|
-
return (_b = this.
|
|
101
|
+
return (_b = this.solProviderHelper) === null || _b === void 0 ? void 0 : _b.signMessage(messageToSign);
|
|
106
102
|
});
|
|
107
103
|
}
|
|
108
104
|
getConnectedAccounts() {
|
|
109
105
|
return __awaiter(this, void 0, void 0, function* () {
|
|
110
106
|
var _a, _b;
|
|
111
|
-
return (_b = (_a = this.
|
|
107
|
+
return (_b = (_a = this.solProviderHelper) === null || _a === void 0 ? void 0 : _a.getConnectedAccounts()) !== null && _b !== void 0 ? _b : [];
|
|
112
108
|
});
|
|
113
109
|
}
|
|
114
110
|
}
|
|
@@ -5,15 +5,13 @@ 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');
|
|
9
8
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
10
9
|
|
|
11
10
|
class PhantomInjected extends InjectedWalletBase.InjectedWalletBase {
|
|
12
|
-
constructor(
|
|
13
|
-
super(
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
14
13
|
this.name = 'Phantom';
|
|
15
14
|
this.overrideKey = 'phantom';
|
|
16
|
-
this.wallet = walletBook.findWalletBookWallet(this.walletBook, this.key);
|
|
17
15
|
}
|
|
18
16
|
getAddress() {
|
|
19
17
|
const _super = Object.create(null, {
|
|
@@ -34,7 +32,7 @@ class PhantomInjected extends InjectedWalletBase.InjectedWalletBase {
|
|
|
34
32
|
}
|
|
35
33
|
canGetChainAddress() {
|
|
36
34
|
var _a, _b;
|
|
37
|
-
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;
|
|
38
36
|
}
|
|
39
37
|
}
|
|
40
38
|
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { SolWalletConnectorOpts } from '@dynamic-labs/solana-core';
|
|
2
1
|
import { InjectedWalletBase } from './InjectedWalletBase';
|
|
3
2
|
export declare class PhantomInjected extends InjectedWalletBase {
|
|
4
3
|
name: string;
|
|
5
4
|
overrideKey: string;
|
|
6
|
-
constructor(opts: SolWalletConnectorOpts);
|
|
7
5
|
getAddress(): Promise<string | undefined>;
|
|
8
6
|
canGetChainAddress(): boolean;
|
|
9
7
|
}
|
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../_virtual/_tslib.js';
|
|
3
3
|
import { isMobile, handleMobileWalletRedirect } from '@dynamic-labs/utils';
|
|
4
|
-
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
4
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
6
5
|
|
|
7
6
|
class PhantomInjected extends InjectedWalletBase {
|
|
8
|
-
constructor(
|
|
9
|
-
super(
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
10
9
|
this.name = 'Phantom';
|
|
11
10
|
this.overrideKey = 'phantom';
|
|
12
|
-
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
13
11
|
}
|
|
14
12
|
getAddress() {
|
|
15
13
|
const _super = Object.create(null, {
|
|
@@ -30,7 +28,7 @@ class PhantomInjected extends InjectedWalletBase {
|
|
|
30
28
|
}
|
|
31
29
|
canGetChainAddress() {
|
|
32
30
|
var _a, _b;
|
|
33
|
-
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;
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
34
|
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var CoinbaseSolana = require('../CoinbaseSolana.cjs');
|
|
7
|
-
var Solflare = require('../Solflare.cjs');
|
|
6
|
+
var CoinbaseSolana = require('../CoinbaseSolana/CoinbaseSolana.cjs');
|
|
7
|
+
var Solflare = require('../Solflare/Solflare.cjs');
|
|
8
8
|
var SolanaWalletStandardConnector = require('../SolanaWalletStandardConnector/SolanaWalletStandardConnector.cjs');
|
|
9
9
|
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
10
10
|
var BackpackSol = require('./BackpackSol.cjs');
|
|
@@ -48,10 +48,9 @@ const fetchInjectedWalletConnectors = ({ walletBook, }) => {
|
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
return class extends InjectedWalletBase.InjectedWalletBase {
|
|
51
|
-
constructor(
|
|
52
|
-
super(
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
53
|
this.name = name;
|
|
54
|
-
this.wallet = wallet;
|
|
55
54
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
56
55
|
this.overrideKey = key;
|
|
57
56
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { CoinbaseSolana } from '../CoinbaseSolana.js';
|
|
3
|
-
import { Solflare } from '../Solflare.js';
|
|
2
|
+
import { CoinbaseSolana } from '../CoinbaseSolana/CoinbaseSolana.js';
|
|
3
|
+
import { Solflare } from '../Solflare/Solflare.js';
|
|
4
4
|
import { SolanaWalletStandardConnector } from '../SolanaWalletStandardConnector/SolanaWalletStandardConnector.js';
|
|
5
5
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
6
6
|
import { BackpackSol } from './BackpackSol.js';
|
|
@@ -44,10 +44,9 @@ const fetchInjectedWalletConnectors = ({ walletBook, }) => {
|
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
return class extends InjectedWalletBase {
|
|
47
|
-
constructor(
|
|
48
|
-
super(
|
|
47
|
+
constructor() {
|
|
48
|
+
super(...arguments);
|
|
49
49
|
this.name = name;
|
|
50
|
-
this.wallet = wallet;
|
|
51
50
|
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
52
51
|
this.overrideKey = key;
|
|
53
52
|
}
|
package/src/injected/index.d.ts
CHANGED
|
@@ -3,20 +3,23 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('
|
|
7
|
-
var nacl = require('tweetnacl');
|
|
8
|
-
var bs58 = require('bs58');
|
|
6
|
+
var _tslib = require('../../../_virtual/_tslib.cjs');
|
|
9
7
|
var web3_js = require('@solana/web3.js');
|
|
8
|
+
var bs58 = require('bs58');
|
|
9
|
+
var nacl = require('tweetnacl');
|
|
10
10
|
var solanaCore = require('@dynamic-labs/solana-core');
|
|
11
|
-
var
|
|
12
|
-
var
|
|
11
|
+
var buildUrl = require('../buildUrl/buildUrl.cjs');
|
|
12
|
+
var decryptPayload = require('../decryptPayload/decryptPayload.cjs');
|
|
13
|
+
var encryptPayload = require('../encryptPayload/encryptPayload.cjs');
|
|
14
|
+
var fetchCluster = require('../fetchCluster/fetchCluster.cjs');
|
|
15
|
+
var storage = require('../storage/storage.cjs');
|
|
13
16
|
|
|
14
17
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
15
18
|
|
|
16
|
-
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
17
19
|
var bs58__default = /*#__PURE__*/_interopDefaultLegacy(bs58);
|
|
20
|
+
var nacl__default = /*#__PURE__*/_interopDefaultLegacy(nacl);
|
|
18
21
|
|
|
19
|
-
class PhantomRedirect extends solanaCore.
|
|
22
|
+
class PhantomRedirect extends solanaCore.SolanaWalletConnector {
|
|
20
23
|
constructor(props) {
|
|
21
24
|
super(Object.assign({}, props));
|
|
22
25
|
this.name = 'Phantom';
|
|
@@ -48,11 +51,11 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
48
51
|
const rpc = (_b = (_a = this.solNetworks[0].privateCustomerRpcUrls) === null || _a === void 0 ? void 0 : _a[0]) !== null && _b !== void 0 ? _b : this.solNetworks[0].rpcUrls[0];
|
|
49
52
|
const params = new URLSearchParams({
|
|
50
53
|
app_url: isLocalHost ? 'https://demo.dynamic.xyz' : window.location.href,
|
|
51
|
-
cluster: yield
|
|
54
|
+
cluster: yield fetchCluster.fetchCluster(rpc),
|
|
52
55
|
dapp_encryption_public_key: bs58__default["default"].encode(keyPair.publicKey),
|
|
53
56
|
redirect_link: window.location.href,
|
|
54
57
|
});
|
|
55
|
-
const url =
|
|
58
|
+
const url = buildUrl.buildUrl('connect', params);
|
|
56
59
|
window.location.href = url;
|
|
57
60
|
});
|
|
58
61
|
}
|
|
@@ -62,7 +65,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
62
65
|
const { data, nonce, phantom_encryption_public_key: phantomEncryptionPublicKey, encryptionSecretKey, } = this.getInputsOrThrow('getSession', ['data', 'nonce', 'phantom_encryption_public_key'], ['encryptionSecretKey']);
|
|
63
66
|
const sharedSecret = nacl__default["default"].box.before(bs58__default["default"].decode(phantomEncryptionPublicKey), encryptionSecretKey);
|
|
64
67
|
storage.storage.sharedSecret.set(sharedSecret);
|
|
65
|
-
const connectData =
|
|
68
|
+
const connectData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
66
69
|
storage.storage.session.set(connectData.session);
|
|
67
70
|
storage.storage.address.set(new web3_js.PublicKey(connectData.public_key));
|
|
68
71
|
params.delete('phantom_encryption_public_key');
|
|
@@ -80,14 +83,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
80
83
|
message: bs58__default["default"].encode(Buffer.from(messageToSign)),
|
|
81
84
|
session,
|
|
82
85
|
};
|
|
83
|
-
const [nonce, encryptedPayload] =
|
|
86
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
84
87
|
const params = new URLSearchParams({
|
|
85
88
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
86
89
|
nonce: bs58__default["default"].encode(nonce),
|
|
87
90
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
88
91
|
redirect_link: window.location.href,
|
|
89
92
|
});
|
|
90
|
-
const url =
|
|
93
|
+
const url = buildUrl.buildUrl('signMessage', params);
|
|
91
94
|
storage.storage.method.set('signMessage');
|
|
92
95
|
window.location.href = url;
|
|
93
96
|
// throwing this to prevent local storage from being cleared.
|
|
@@ -104,7 +107,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
104
107
|
extractSignature() {
|
|
105
108
|
const params = new URLSearchParams(window.location.search);
|
|
106
109
|
const { data, nonce, sharedSecret, message } = this.getInputsOrThrow('extractSignature', ['data', 'nonce'], ['sharedSecret', 'message']);
|
|
107
|
-
const signMessageData =
|
|
110
|
+
const signMessageData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
108
111
|
params.delete('data');
|
|
109
112
|
params.delete('nonce');
|
|
110
113
|
history.replaceState(null, '', `${window.location.origin}${window.location.pathname}?${params.toString()}`);
|
|
@@ -116,7 +119,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
116
119
|
extractTransactions() {
|
|
117
120
|
const params = new URLSearchParams(window.location.search);
|
|
118
121
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransactions', ['data', 'nonce'], ['sharedSecret']);
|
|
119
|
-
const signAllTransactionsData =
|
|
122
|
+
const signAllTransactionsData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
120
123
|
const decodedTransactions = signAllTransactionsData.transactions.map((t) => web3_js.Transaction.from(bs58__default["default"].decode(t)));
|
|
121
124
|
params.delete('data');
|
|
122
125
|
params.delete('nonce');
|
|
@@ -126,7 +129,7 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
126
129
|
extractTransaction() {
|
|
127
130
|
const params = new URLSearchParams(window.location.search);
|
|
128
131
|
const { data, nonce, sharedSecret } = this.getInputsOrThrow('extractTransaction', ['data', 'nonce'], ['sharedSecret']);
|
|
129
|
-
const signTransactionData =
|
|
132
|
+
const signTransactionData = decryptPayload.decryptPayload(data, nonce, sharedSecret);
|
|
130
133
|
const decodedTransaction = web3_js.Transaction.from(bs58__default["default"].decode(signTransactionData.transaction));
|
|
131
134
|
params.delete('data');
|
|
132
135
|
params.delete('nonce');
|
|
@@ -200,14 +203,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
200
203
|
session,
|
|
201
204
|
transactions: serializedTransactions,
|
|
202
205
|
};
|
|
203
|
-
const [nonce, encryptedPayload] =
|
|
206
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
204
207
|
const params = new URLSearchParams({
|
|
205
208
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
206
209
|
nonce: bs58__default["default"].encode(nonce),
|
|
207
210
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
208
211
|
redirect_link: window.location.href,
|
|
209
212
|
});
|
|
210
|
-
const url =
|
|
213
|
+
const url = buildUrl.buildUrl('signAllTransactions', params);
|
|
211
214
|
window.location.href = url;
|
|
212
215
|
// actual signatures will be retrieved upon redirect back to dapp
|
|
213
216
|
return [];
|
|
@@ -219,14 +222,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
219
222
|
session,
|
|
220
223
|
transaction: bs58__default["default"].encode(transaction.serialize({ requireAllSignatures: false })),
|
|
221
224
|
};
|
|
222
|
-
const [nonce, encryptedPayload] =
|
|
225
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
223
226
|
const params = new URLSearchParams({
|
|
224
227
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
225
228
|
nonce: bs58__default["default"].encode(nonce),
|
|
226
229
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
227
230
|
redirect_link: window.location.href,
|
|
228
231
|
});
|
|
229
|
-
const url =
|
|
232
|
+
const url = buildUrl.buildUrl('signAndSendTransaction', params);
|
|
230
233
|
storage.storage.method.set('signAndSendTransaction');
|
|
231
234
|
window.location.href = url;
|
|
232
235
|
// actual signature will be retrived upon redirect back to dapp
|
|
@@ -238,14 +241,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
238
241
|
message: bs58__default["default"].encode(Buffer.from(message)),
|
|
239
242
|
session,
|
|
240
243
|
};
|
|
241
|
-
const [nonce, encryptedPayload] =
|
|
244
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
242
245
|
const params = new URLSearchParams({
|
|
243
246
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
244
247
|
nonce: bs58__default["default"].encode(nonce),
|
|
245
248
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
246
249
|
redirect_link: window.location.href,
|
|
247
250
|
});
|
|
248
|
-
const url =
|
|
251
|
+
const url = buildUrl.buildUrl('signMessage', params);
|
|
249
252
|
window.location.href = url;
|
|
250
253
|
// actual signature will be retrived upon redirect back to dapp
|
|
251
254
|
return { signature: Buffer.from('') };
|
|
@@ -259,14 +262,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
259
262
|
session,
|
|
260
263
|
transaction: serializedTransaction,
|
|
261
264
|
};
|
|
262
|
-
const [nonce, encryptedPayload] =
|
|
265
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
263
266
|
const params = new URLSearchParams({
|
|
264
267
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
265
268
|
nonce: bs58__default["default"].encode(nonce),
|
|
266
269
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
267
270
|
redirect_link: window.location.href,
|
|
268
271
|
});
|
|
269
|
-
const url =
|
|
272
|
+
const url = buildUrl.buildUrl('signTransaction', params);
|
|
270
273
|
window.location.href = url;
|
|
271
274
|
return transaction;
|
|
272
275
|
}),
|
|
@@ -291,14 +294,14 @@ class PhantomRedirect extends solanaCore.SolWalletConnector {
|
|
|
291
294
|
if (!address || !session || !encryptionPublicKey || !sharedSecret)
|
|
292
295
|
return;
|
|
293
296
|
const payload = { session };
|
|
294
|
-
const [nonce, encryptedPayload] =
|
|
297
|
+
const [nonce, encryptedPayload] = encryptPayload.encryptPayload(payload, sharedSecret);
|
|
295
298
|
const params = new URLSearchParams({
|
|
296
299
|
dapp_encryption_public_key: bs58__default["default"].encode(encryptionPublicKey),
|
|
297
300
|
nonce: bs58__default["default"].encode(nonce),
|
|
298
301
|
payload: bs58__default["default"].encode(encryptedPayload),
|
|
299
302
|
redirect_link: window.location.href,
|
|
300
303
|
});
|
|
301
|
-
const url =
|
|
304
|
+
const url = buildUrl.buildUrl('disconnect', params);
|
|
302
305
|
window.location.href = url;
|
|
303
306
|
});
|
|
304
307
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Transaction } from '@solana/web3.js';
|
|
2
|
+
import { SolanaWalletConnector, type ISolana } from '@dynamic-labs/solana-core';
|
|
2
3
|
import { IPhantomRedirectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
export declare class PhantomRedirect extends SolWalletConnector implements IPhantomRedirectConnector {
|
|
4
|
+
import { Method } from '../types';
|
|
5
|
+
export declare class PhantomRedirect extends SolanaWalletConnector implements IPhantomRedirectConnector {
|
|
6
6
|
name: string;
|
|
7
7
|
overrideKey: string;
|
|
8
8
|
constructor(props: any);
|