@dynamic-labs/solana 1.1.0-alpha.10 → 1.1.0-alpha.12
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 +33 -0
- package/package.json +6 -6
- package/src/CoinbaseSolana.cjs +9 -33
- package/src/CoinbaseSolana.d.ts +5 -10
- package/src/CoinbaseSolana.js +9 -33
- package/src/Solflare.d.ts +4 -9
- package/src/index.cjs +3 -15
- package/src/index.d.ts +1 -4
- package/src/index.js +3 -13
- package/src/injected/BackpackSol.cjs +6 -21
- package/src/injected/BackpackSol.d.ts +3 -5
- package/src/injected/BackpackSol.js +6 -21
- package/src/injected/InjectedWalletBase.cjs +20 -16
- package/src/injected/InjectedWalletBase.d.ts +7 -2
- package/src/injected/InjectedWalletBase.js +20 -16
- package/src/injected/Phantom.cjs +4 -2
- package/src/injected/Phantom.d.ts +2 -0
- package/src/injected/Phantom.js +4 -2
- package/src/injected/PhantomLedger.cjs +4 -2
- package/src/injected/PhantomLedger.d.ts +2 -0
- package/src/injected/PhantomLedger.js +4 -2
- package/src/injected/fetchInjectedWalletConnectors.cjs +50 -0
- package/src/injected/fetchInjectedWalletConnectors.d.ts +6 -0
- package/src/injected/fetchInjectedWalletConnectors.js +45 -0
- package/src/injected/index.d.ts +1 -2
- package/src/solProviderHelper.cjs +99 -114
- package/src/solProviderHelper.d.ts +28 -29
- package/src/solProviderHelper.js +99 -114
- package/src/Glow.cjs +0 -50
- package/src/Glow.d.ts +0 -12
- package/src/Glow.js +0 -46
- package/src/Solflare.cjs +0 -83
- package/src/Solflare.js +0 -79
- package/src/injected/BraveSol.cjs +0 -21
- package/src/injected/BraveSol.d.ts +0 -5
- package/src/injected/BraveSol.js +0 -17
- package/src/injected/ExodusSol.cjs +0 -14
- package/src/injected/ExodusSol.d.ts +0 -4
- package/src/injected/ExodusSol.js +0 -10
- package/src/injected/MagicEdenSol.cjs +0 -14
- package/src/injected/MagicEdenSol.d.ts +0 -4
- package/src/injected/MagicEdenSol.js +0 -10
- package/src/injected/index.cjs +0 -21
- package/src/injected/index.js +0 -17
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
|
+
import { SolWalletConnectorOpts } from '../solWalletConnector';
|
|
2
3
|
import { InjectedWalletBase } from './InjectedWalletBase';
|
|
3
4
|
export declare const MEMO_PROGRAM_ID: PublicKey;
|
|
4
5
|
export declare class PhantomLedger extends InjectedWalletBase {
|
|
@@ -7,6 +8,7 @@ export declare class PhantomLedger extends InjectedWalletBase {
|
|
|
7
8
|
* exporting it in this way, we avoid to instantiate the whole PhantomLedger class every time.
|
|
8
9
|
*/
|
|
9
10
|
name: string;
|
|
11
|
+
constructor(opts: SolWalletConnectorOpts);
|
|
10
12
|
signMessage(): Promise<string | undefined>;
|
|
11
13
|
proveOwnership(messageToSign: string): Promise<string | undefined>;
|
|
12
14
|
signMessageViaTransaction(messageToSign: string): Promise<string>;
|
|
@@ -2,13 +2,14 @@ import { __awaiter } from '../../_virtual/_tslib.js';
|
|
|
2
2
|
import { PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js';
|
|
3
3
|
import { NotSupportedError, DynamicError } from '@dynamic-labs/utils';
|
|
4
4
|
import { PhantomLedgerWalletName } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { findWalletBookWallet } from '@dynamic-labs/wallet-book';
|
|
5
6
|
import { extractNonce } from '../utils/extractNonce.js';
|
|
6
7
|
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
7
8
|
|
|
8
9
|
const MEMO_PROGRAM_ID = new PublicKey('MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr');
|
|
9
10
|
class PhantomLedger extends InjectedWalletBase {
|
|
10
|
-
constructor() {
|
|
11
|
-
super(
|
|
11
|
+
constructor(opts) {
|
|
12
|
+
super(opts);
|
|
12
13
|
/**
|
|
13
14
|
* I'm exporting the walletName to use it for DYN-1447. As we only need the wallet name,
|
|
14
15
|
* exporting it in this way, we avoid to instantiate the whole PhantomLedger class every time.
|
|
@@ -23,6 +24,7 @@ class PhantomLedger extends InjectedWalletBase {
|
|
|
23
24
|
}));
|
|
24
25
|
return transaction;
|
|
25
26
|
};
|
|
27
|
+
this.wallet = findWalletBookWallet(this.walletBook, this.key);
|
|
26
28
|
}
|
|
27
29
|
signMessage() {
|
|
28
30
|
return __awaiter(this, void 0, void 0, function* () {
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var CoinbaseSolana = require('../CoinbaseSolana.cjs');
|
|
6
|
+
var Slope = require('../Slope.cjs');
|
|
7
|
+
var InjectedWalletBase = require('./InjectedWalletBase.cjs');
|
|
8
|
+
var Phantom = require('./Phantom.cjs');
|
|
9
|
+
var PhantomLedger = require('./PhantomLedger.cjs');
|
|
10
|
+
var BackpackSol = require('./BackpackSol.cjs');
|
|
11
|
+
|
|
12
|
+
const injectedWalletOverrides = [
|
|
13
|
+
CoinbaseSolana.CoinbaseSolana,
|
|
14
|
+
Slope.Slope,
|
|
15
|
+
Phantom.Phantom,
|
|
16
|
+
PhantomLedger.PhantomLedger,
|
|
17
|
+
BackpackSol.BackpackSol,
|
|
18
|
+
];
|
|
19
|
+
const filteredInjectedWalletKeysOverrides = [
|
|
20
|
+
'coinbasesolana',
|
|
21
|
+
'slope',
|
|
22
|
+
'phantom',
|
|
23
|
+
'phantomledger',
|
|
24
|
+
'backpacksol',
|
|
25
|
+
];
|
|
26
|
+
const fetchInjectedWalletConnectors = ({ walletBook, }) => {
|
|
27
|
+
var _a;
|
|
28
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
29
|
+
.filter(([key, wallet]) => {
|
|
30
|
+
var _a;
|
|
31
|
+
return ((_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sol')) &&
|
|
32
|
+
!filteredInjectedWalletKeysOverrides.includes(key);
|
|
33
|
+
})
|
|
34
|
+
.map(([key, wallet]) => {
|
|
35
|
+
const { shortName } = wallet;
|
|
36
|
+
const name = shortName || wallet.name;
|
|
37
|
+
return class extends InjectedWalletBase.InjectedWalletBase {
|
|
38
|
+
constructor(props) {
|
|
39
|
+
super(Object.assign({}, props));
|
|
40
|
+
this.name = name;
|
|
41
|
+
this.wallet = wallet;
|
|
42
|
+
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
43
|
+
this.overrideKey = key;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
exports.fetchInjectedWalletConnectors = fetchInjectedWalletConnectors;
|
|
50
|
+
exports.injectedWalletOverrides = injectedWalletOverrides;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
export declare const injectedWalletOverrides: WalletConnectorConstructor[];
|
|
4
|
+
export declare const fetchInjectedWalletConnectors: ({ walletBook, }: {
|
|
5
|
+
walletBook: WalletBookSchema;
|
|
6
|
+
}) => WalletConnectorConstructor[];
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { CoinbaseSolana } from '../CoinbaseSolana.js';
|
|
2
|
+
import { Slope } from '../Slope.js';
|
|
3
|
+
import { InjectedWalletBase } from './InjectedWalletBase.js';
|
|
4
|
+
import { Phantom } from './Phantom.js';
|
|
5
|
+
import { PhantomLedger } from './PhantomLedger.js';
|
|
6
|
+
import { BackpackSol } from './BackpackSol.js';
|
|
7
|
+
|
|
8
|
+
const injectedWalletOverrides = [
|
|
9
|
+
CoinbaseSolana,
|
|
10
|
+
Slope,
|
|
11
|
+
Phantom,
|
|
12
|
+
PhantomLedger,
|
|
13
|
+
BackpackSol,
|
|
14
|
+
];
|
|
15
|
+
const filteredInjectedWalletKeysOverrides = [
|
|
16
|
+
'coinbasesolana',
|
|
17
|
+
'slope',
|
|
18
|
+
'phantom',
|
|
19
|
+
'phantomledger',
|
|
20
|
+
'backpacksol',
|
|
21
|
+
];
|
|
22
|
+
const fetchInjectedWalletConnectors = ({ walletBook, }) => {
|
|
23
|
+
var _a;
|
|
24
|
+
return Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {})
|
|
25
|
+
.filter(([key, wallet]) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return ((_a = wallet.injectedConfig) === null || _a === void 0 ? void 0 : _a.find((config) => config.chain === 'sol')) &&
|
|
28
|
+
!filteredInjectedWalletKeysOverrides.includes(key);
|
|
29
|
+
})
|
|
30
|
+
.map(([key, wallet]) => {
|
|
31
|
+
const { shortName } = wallet;
|
|
32
|
+
const name = shortName || wallet.name;
|
|
33
|
+
return class extends InjectedWalletBase {
|
|
34
|
+
constructor(props) {
|
|
35
|
+
super(Object.assign({}, props));
|
|
36
|
+
this.name = name;
|
|
37
|
+
this.wallet = wallet;
|
|
38
|
+
// this is the key from the wallet book entry so that we don't purely rely on the normalized name
|
|
39
|
+
this.overrideKey = key;
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { fetchInjectedWalletConnectors, injectedWalletOverrides };
|
package/src/injected/index.d.ts
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export declare const injectedWallets: (typeof BraveSol)[];
|
|
1
|
+
export * from './fetchInjectedWalletConnectors';
|
|
@@ -3,57 +3,81 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var _tslib = require('../_virtual/_tslib.cjs');
|
|
6
|
-
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
6
|
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
8
8
|
var isSignedMessage = require('./utils/isSignedMessage.cjs');
|
|
9
9
|
|
|
10
|
-
var _a;
|
|
11
10
|
class SolProviderHelper {
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
constructor(wallet) {
|
|
12
|
+
this.wallet = wallet;
|
|
14
13
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
getInjectedConfig() {
|
|
15
|
+
if (!this.wallet || !this.wallet.injectedConfig)
|
|
16
|
+
return;
|
|
17
|
+
const { injectedConfig } = this.wallet;
|
|
18
|
+
return injectedConfig.find((c) => c.chain === 'sol');
|
|
19
|
+
}
|
|
20
|
+
getInstalledProvider() {
|
|
21
|
+
const config = this.getInjectedConfig();
|
|
22
|
+
if (!config || !config.extensionLocators) {
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
return this.installedProviderLookup(config.extensionLocators);
|
|
18
26
|
}
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
|
|
27
|
+
installedProviders() {
|
|
28
|
+
const config = this.getInjectedConfig();
|
|
29
|
+
if (!config)
|
|
30
|
+
return [];
|
|
31
|
+
const providers = [];
|
|
32
|
+
if (config.windowLocations) {
|
|
33
|
+
for (const windowLocation of config.windowLocations) {
|
|
34
|
+
const foundProviders = utils.getProvidersFromWindow(windowLocation);
|
|
35
|
+
if (foundProviders && foundProviders.length)
|
|
36
|
+
providers.push(...foundProviders);
|
|
37
|
+
}
|
|
23
38
|
}
|
|
24
|
-
|
|
25
|
-
solana.providers
|
|
26
|
-
|
|
27
|
-
}
|
|
39
|
+
if (window.solana) {
|
|
40
|
+
if (!window.solana.providers) {
|
|
41
|
+
providers.push(window.solana);
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
window.solana.providers.forEach((provider) => providers.push(provider));
|
|
45
|
+
}
|
|
28
46
|
}
|
|
29
|
-
return
|
|
47
|
+
return providers;
|
|
48
|
+
}
|
|
49
|
+
installedProviderLookup(providerFlags) {
|
|
50
|
+
const allInstalledProviders = this.installedProviders();
|
|
51
|
+
// If no provider flags are provided, return the first provider
|
|
52
|
+
// This is required for the coinbaseSolana window provider which has no locators
|
|
53
|
+
if (providerFlags.length === 0)
|
|
54
|
+
return allInstalledProviders[0];
|
|
55
|
+
return walletConnectorCore.ProviderLookup(allInstalledProviders, providerFlags);
|
|
30
56
|
}
|
|
31
|
-
|
|
32
|
-
return this.
|
|
57
|
+
findProvider() {
|
|
58
|
+
return this.getInstalledProvider();
|
|
33
59
|
}
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return (_c = (_b = this.providers)[walletKey]) === null || _c === void 0 ? void 0 : _c.call(_b);
|
|
60
|
+
isInstalledHelper() {
|
|
61
|
+
return this.findProvider() !== undefined;
|
|
37
62
|
}
|
|
38
|
-
|
|
63
|
+
fetchPublicAddress() {
|
|
64
|
+
var _a;
|
|
39
65
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
40
|
-
const provider = this.findProvider(
|
|
66
|
+
const provider = this.findProvider();
|
|
41
67
|
if (!provider) {
|
|
42
|
-
return
|
|
68
|
+
return undefined;
|
|
43
69
|
}
|
|
44
70
|
if (!provider.isConnected) {
|
|
45
71
|
yield provider.connect();
|
|
46
72
|
}
|
|
47
|
-
|
|
48
|
-
return publicKey ? publicKey.toString() : Promise.resolve(undefined);
|
|
73
|
+
return (_a = provider.publicKey) === null || _a === void 0 ? void 0 : _a.toString();
|
|
49
74
|
});
|
|
50
75
|
}
|
|
51
|
-
|
|
76
|
+
connect() {
|
|
52
77
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
53
|
-
const provider = this.findProvider(
|
|
54
|
-
if (!provider)
|
|
55
|
-
return
|
|
56
|
-
}
|
|
78
|
+
const provider = this.findProvider();
|
|
79
|
+
if (!provider)
|
|
80
|
+
return undefined;
|
|
57
81
|
try {
|
|
58
82
|
if (!provider.isConnected) {
|
|
59
83
|
yield provider.connect();
|
|
@@ -65,116 +89,77 @@ class SolProviderHelper {
|
|
|
65
89
|
}
|
|
66
90
|
});
|
|
67
91
|
}
|
|
68
|
-
|
|
92
|
+
signMessage(messageToSign) {
|
|
69
93
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
70
|
-
const walletAddress = yield this.
|
|
71
|
-
if (!walletAddress)
|
|
72
|
-
return
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
return Promise.resolve(undefined);
|
|
77
|
-
}
|
|
94
|
+
const walletAddress = yield this.fetchPublicAddress();
|
|
95
|
+
if (!walletAddress)
|
|
96
|
+
return undefined;
|
|
97
|
+
const provider = this.findProvider();
|
|
98
|
+
if (!provider)
|
|
99
|
+
return undefined;
|
|
78
100
|
if (!provider.isConnected) {
|
|
79
101
|
yield provider.connect();
|
|
80
102
|
}
|
|
81
103
|
const encodedMessage = new TextEncoder().encode(messageToSign);
|
|
82
104
|
const signedMessage = yield provider.signMessage(encodedMessage, 'utf8');
|
|
83
|
-
if (!signedMessage)
|
|
84
|
-
return
|
|
85
|
-
}
|
|
105
|
+
if (!signedMessage)
|
|
106
|
+
return undefined;
|
|
86
107
|
return utils.bufferToBase64(isSignedMessage.isSignedMessage(signedMessage) ? signedMessage.signature : signedMessage);
|
|
87
108
|
});
|
|
88
109
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
110
|
+
handleAccountChange(walletConnector, web3Provider, address) {
|
|
111
|
+
var _a;
|
|
112
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
113
|
+
if (!address) {
|
|
114
|
+
yield (web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.connect());
|
|
115
|
+
if ((_a = web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.publicKey) === null || _a === void 0 ? void 0 : _a.toString()) {
|
|
116
|
+
walletConnector.emit('accountChange', {
|
|
117
|
+
accounts: [web3Provider.publicKey.toString()],
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
if (address.toString()) {
|
|
123
|
+
walletConnector.emit('accountChange', { accounts: [address.toString()] });
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
_setupEventListeners(walletConnector) {
|
|
128
|
+
const provider = this.findProvider();
|
|
129
|
+
provider === null || provider === void 0 ? void 0 : provider.on('accountChanged', (publicKey) => this.handleAccountChange(walletConnector, provider, publicKey));
|
|
130
|
+
provider === null || provider === void 0 ? void 0 : provider.on('disconnect', () => walletConnector.emit('disconnect'));
|
|
92
131
|
}
|
|
93
|
-
|
|
94
|
-
const
|
|
95
|
-
if (!
|
|
132
|
+
_teardownEventListeners() {
|
|
133
|
+
const provider = this.findProvider();
|
|
134
|
+
if (!provider)
|
|
96
135
|
return;
|
|
97
|
-
|
|
98
|
-
web3Provider.removeAllListeners();
|
|
136
|
+
provider.removeAllListeners();
|
|
99
137
|
}
|
|
100
|
-
|
|
101
|
-
var
|
|
138
|
+
getConnectedAccounts() {
|
|
139
|
+
var _a, _b;
|
|
102
140
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
103
|
-
const provider = this.findProvider(
|
|
104
|
-
if (!provider)
|
|
141
|
+
const provider = this.findProvider();
|
|
142
|
+
if (!provider)
|
|
105
143
|
return [];
|
|
106
|
-
}
|
|
107
144
|
let connectionResult;
|
|
108
145
|
try {
|
|
109
146
|
if (!provider.isConnected) {
|
|
110
|
-
connectionResult = yield provider.connect({
|
|
111
|
-
onlyIfTrusted: true,
|
|
112
|
-
});
|
|
147
|
+
connectionResult = yield provider.connect({ onlyIfTrusted: true });
|
|
113
148
|
}
|
|
114
149
|
}
|
|
115
150
|
catch (e) {
|
|
116
151
|
return [];
|
|
117
152
|
}
|
|
118
153
|
const address = connectionResult === null || connectionResult === void 0 ? void 0 : connectionResult.address;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
if (address) {
|
|
154
|
+
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();
|
|
155
|
+
if (address)
|
|
122
156
|
return [address];
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
else {
|
|
157
|
+
else if (publicKey)
|
|
158
|
+
return [publicKey === null || publicKey === void 0 ? void 0 : publicKey.toString()];
|
|
159
|
+
else
|
|
128
160
|
return [];
|
|
129
|
-
}
|
|
130
161
|
});
|
|
131
162
|
}
|
|
132
163
|
}
|
|
133
|
-
_a = SolProviderHelper;
|
|
134
|
-
SolProviderHelper.GlowProvider = () => _a.installedProviderLookup([{ flag: 'isGlow', value: true }]);
|
|
135
|
-
SolProviderHelper.CoinbaseProvider = () => _a.findSolanaProviders(window.coinbaseSolana)[0];
|
|
136
|
-
SolProviderHelper.PhantomProvider = () => _a.installedProviderLookup([
|
|
137
|
-
{ flag: 'isPhantom', value: true },
|
|
138
|
-
{ flag: 'isBraveWallet', value: false },
|
|
139
|
-
{ flag: 'isExodus', value: false },
|
|
140
|
-
{ flag: 'isMagicEden', value: false },
|
|
141
|
-
]);
|
|
142
|
-
SolProviderHelper.MagicEdenProvider = () => _a.installedProviderLookup([{ flag: 'isMagicEden', value: true }]);
|
|
143
|
-
SolProviderHelper.SolflareProvider = () => _a.installedProviderLookup([{ flag: 'isSolflare', value: true }]);
|
|
144
|
-
SolProviderHelper.BraveProvider = () => _a.installedProviderLookup([
|
|
145
|
-
{ flag: 'isPhantom', value: true },
|
|
146
|
-
{ flag: 'isBraveWallet', value: true },
|
|
147
|
-
]);
|
|
148
|
-
SolProviderHelper.ExodusProvider = () => _a.installedProviderLookup([
|
|
149
|
-
{ flag: 'isPhantom', value: true },
|
|
150
|
-
{ flag: 'isExodus', value: true },
|
|
151
|
-
]);
|
|
152
|
-
SolProviderHelper.BackpackSol = () => _a.installedProviderLookup([{ flag: 'isBackpack', value: true }]);
|
|
153
|
-
SolProviderHelper.providers = {
|
|
154
|
-
backpacksol: _a.BackpackSol,
|
|
155
|
-
bravesol: _a.BraveProvider,
|
|
156
|
-
coinbasesolana: _a.CoinbaseProvider,
|
|
157
|
-
exodussol: _a.ExodusProvider,
|
|
158
|
-
glow: _a.GlowProvider,
|
|
159
|
-
magicedensol: _a.MagicEdenProvider,
|
|
160
|
-
phantom: _a.PhantomProvider,
|
|
161
|
-
phantomledger: _a.PhantomProvider,
|
|
162
|
-
solflare: _a.SolflareProvider,
|
|
163
|
-
};
|
|
164
|
-
SolProviderHelper.handleAccountChange = (walletConnector, web3Provider, address) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
165
|
-
var _b;
|
|
166
|
-
if (!address) {
|
|
167
|
-
yield (web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.connect());
|
|
168
|
-
if ((_b = web3Provider === null || web3Provider === void 0 ? void 0 : web3Provider.publicKey) === null || _b === void 0 ? void 0 : _b.toString()) {
|
|
169
|
-
walletConnector.emit('accountChange', {
|
|
170
|
-
accounts: [web3Provider.publicKey.toString()],
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
if (address.toString()) {
|
|
176
|
-
walletConnector.emit('accountChange', { accounts: [address.toString()] });
|
|
177
|
-
}
|
|
178
|
-
});
|
|
179
164
|
|
|
180
165
|
exports.SolProviderHelper = SolProviderHelper;
|
|
@@ -1,33 +1,32 @@
|
|
|
1
|
+
import { WalletSchema } from '@dynamic-labs/wallet-book';
|
|
1
2
|
import { ProviderCondition, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
2
3
|
import { ISolana, ProviderFlag } from './types';
|
|
3
|
-
type Provider = () => ISolana | undefined;
|
|
4
|
-
export type AccountChangeEventHandler = (address: {
|
|
5
|
-
toString(): string;
|
|
6
|
-
} | null) => Promise<void>;
|
|
7
|
-
export type DisconnectEventHandler = () => Promise<void>;
|
|
8
4
|
export declare class SolProviderHelper {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
5
|
+
private wallet;
|
|
6
|
+
constructor(wallet: WalletSchema);
|
|
7
|
+
getInjectedConfig(): {
|
|
8
|
+
chain: string;
|
|
9
|
+
extensionLocators: {
|
|
10
|
+
value: boolean;
|
|
11
|
+
flag: string;
|
|
12
|
+
}[];
|
|
13
|
+
providerInterface?: string | undefined;
|
|
14
|
+
walletStandard?: {
|
|
15
|
+
features: string[];
|
|
16
|
+
name: string;
|
|
17
|
+
} | undefined;
|
|
18
|
+
windowLocations?: string[] | undefined;
|
|
19
|
+
} | undefined;
|
|
20
|
+
getInstalledProvider(): ISolana | undefined;
|
|
21
|
+
installedProviders(): (import("./types").ISolanaSigner | import("./types").ICoinbaseSolanaSigner)[];
|
|
22
|
+
installedProviderLookup(providerFlags: Array<ProviderCondition<ProviderFlag>>): ISolana | undefined;
|
|
23
|
+
findProvider(): ISolana | undefined;
|
|
24
|
+
isInstalledHelper(): boolean;
|
|
25
|
+
fetchPublicAddress(): Promise<string | undefined>;
|
|
26
|
+
connect(): Promise<ISolana | undefined>;
|
|
27
|
+
signMessage(messageToSign: string): Promise<string | undefined>;
|
|
28
|
+
handleAccountChange(walletConnector: WalletConnector, web3Provider: ISolana, address: string): Promise<void>;
|
|
29
|
+
_setupEventListeners(walletConnector: WalletConnector): void;
|
|
30
|
+
_teardownEventListeners(): void;
|
|
31
|
+
getConnectedAccounts(): Promise<string[]>;
|
|
32
32
|
}
|
|
33
|
-
export {};
|