@dynamic-labs/solana 4.39.0 → 4.40.1
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 +19 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +17 -12
- package/src/CoinbaseSolana/CoinbaseSolana.cjs +4 -0
- package/src/CoinbaseSolana/CoinbaseSolana.js +4 -0
- package/src/Phantom/Phantom.cjs +4 -0
- package/src/Phantom/Phantom.js +4 -0
- package/src/SolanaWalletConnectors.cjs +17 -8
- package/src/SolanaWalletConnectors.js +17 -8
- package/src/Solflare/Solflare.cjs +4 -0
- package/src/Solflare/Solflare.js +4 -0
- package/src/index.cjs +3 -1
- package/src/index.js +3 -1
- package/src/injected/BackpackSol/BackpackSol.cjs +4 -0
- package/src/injected/BackpackSol/BackpackSol.js +4 -0
- package/src/injected/FallbackSolanaConnector/FallbackSolanaConnector.cjs +4 -0
- package/src/injected/FallbackSolanaConnector/FallbackSolanaConnector.js +4 -0
- package/src/injected/InjectedWalletBase/InjectedWalletBase.cjs +37 -14
- package/src/injected/InjectedWalletBase/InjectedWalletBase.d.ts +8 -0
- package/src/injected/InjectedWalletBase/InjectedWalletBase.js +37 -14
- package/src/injected/fetchInjectedWalletConnectors.cjs +2 -13
- package/src/injected/fetchInjectedWalletConnectors.js +2 -13
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.cjs +46 -0
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.d.ts +9 -0
- package/src/utils/getConnectorConstructorInjectedWallet/getConnectorConstructorInjectedWallet.js +42 -0
- package/src/utils/getConnectorConstructorInjectedWallet/index.d.ts +1 -0
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs +426 -0
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.d.ts +64 -0
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.js +417 -0
- package/src/walletConnect/SolanaWalletConnectConnector/createSolanaSignerForWalletConnect/createSolanaSignerForWalletConnect.cjs +126 -0
- package/src/walletConnect/SolanaWalletConnectConnector/createSolanaSignerForWalletConnect/createSolanaSignerForWalletConnect.d.ts +7 -0
- package/src/walletConnect/SolanaWalletConnectConnector/createSolanaSignerForWalletConnect/createSolanaSignerForWalletConnect.js +122 -0
- package/src/walletConnect/SolanaWalletConnectConnector/createSolanaSignerForWalletConnect/index.d.ts +1 -0
- package/src/walletConnect/SolanaWalletConnectConnector/index.d.ts +1 -0
- package/src/walletConnect/SolanaWalletConnectConnector/types.d.ts +40 -0
- package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.cjs +64 -0
- package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.d.ts +12 -0
- package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.js +60 -0
- package/src/walletConnect/utils/addSolanaWalletConnectConnectors/index.d.ts +1 -0
- package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.cjs +21 -0
- package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.d.ts +2 -0
- package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.js +17 -0
- package/src/walletConnect/utils/getSolanaWalletConnectConnector/index.d.ts +1 -0
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export type SolanaSessionRequest<T extends AvailableSolanaSessionRequests> = {
|
|
2
|
+
method: T;
|
|
3
|
+
params: SolanaSessionRequestParamMap[T];
|
|
4
|
+
};
|
|
5
|
+
export type AvailableSolanaSessionRequests = keyof SolanaSessionRequestParamMap;
|
|
6
|
+
export type SolanaSessionRequestParamMap = {
|
|
7
|
+
solana_signAllTransactions: {
|
|
8
|
+
transactions: string[];
|
|
9
|
+
};
|
|
10
|
+
solana_signAndSendTransaction: {
|
|
11
|
+
options?: {
|
|
12
|
+
maxRetries?: number;
|
|
13
|
+
minContextSlot?: number;
|
|
14
|
+
preflightCommitment?: 'processed' | 'confirmed' | 'finalized' | 'recent' | 'single' | 'singleGossip' | 'root' | 'max';
|
|
15
|
+
skipPreflight?: boolean;
|
|
16
|
+
};
|
|
17
|
+
transaction: string;
|
|
18
|
+
};
|
|
19
|
+
solana_signMessage: {
|
|
20
|
+
message: string;
|
|
21
|
+
pubkey: string;
|
|
22
|
+
};
|
|
23
|
+
solana_signTransaction: {
|
|
24
|
+
transaction: string;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
export type SolanaSessionRequestResultMap = {
|
|
28
|
+
solana_signAllTransactions: {
|
|
29
|
+
transactions: string[];
|
|
30
|
+
};
|
|
31
|
+
solana_signAndSendTransaction: {
|
|
32
|
+
signature: string;
|
|
33
|
+
};
|
|
34
|
+
solana_signMessage: {
|
|
35
|
+
signature: string;
|
|
36
|
+
};
|
|
37
|
+
solana_signTransaction: {
|
|
38
|
+
transaction: string;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
7
|
+
var SolanaWalletConnectConnector = require('../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
|
|
11
|
+
* by checking what connectors are already present
|
|
12
|
+
*/
|
|
13
|
+
const addSolanaWalletConnectConnectors = ({ walletBook, connectors: currentConnectors, }) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const walletEntries = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {});
|
|
16
|
+
const allWcConstructors = walletEntries
|
|
17
|
+
.filter(([, wallet]) => {
|
|
18
|
+
var _a;
|
|
19
|
+
return wallet.walletConnect &&
|
|
20
|
+
(
|
|
21
|
+
// Exclude wallets that don't support Solana
|
|
22
|
+
(_a = wallet.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
|
|
23
|
+
})
|
|
24
|
+
.map(([key, wallet]) => {
|
|
25
|
+
const { shortName } = wallet;
|
|
26
|
+
const name = shortName || wallet.name;
|
|
27
|
+
const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector.SolanaWalletConnectConnector {
|
|
28
|
+
constructor(props) {
|
|
29
|
+
super(Object.assign(Object.assign({}, props), { metadata: walletConnectorCore.getWalletMetadataFromWalletBook({
|
|
30
|
+
walletBookWallet: wallet,
|
|
31
|
+
walletKey: key,
|
|
32
|
+
}), overrideKey: key, walletName: name }));
|
|
33
|
+
this.overrideKey = key;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const entryKeysWithSameGroup = walletEntries
|
|
37
|
+
.filter(([, { group }]) => group && group === wallet.group)
|
|
38
|
+
.map(([key]) => key);
|
|
39
|
+
// We store the key and the keys of all other entries in the same group
|
|
40
|
+
// so that we can filter out from the WC connectors we just built both the ones
|
|
41
|
+
// whose key is already present in the current connectors and the ones whose key is in the same group
|
|
42
|
+
// as one of the current connectors.
|
|
43
|
+
// We need to check the groups as well because the wallet book entry that we use to create the Sol WC
|
|
44
|
+
// connector might be coming from the EVM wallet book entry (due to historical reasons, that's the entry
|
|
45
|
+
// that has the WC data)
|
|
46
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
|
|
47
|
+
value: key,
|
|
48
|
+
writable: false,
|
|
49
|
+
});
|
|
50
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'groupedKeys', {
|
|
51
|
+
value: entryKeysWithSameGroup,
|
|
52
|
+
writable: false,
|
|
53
|
+
});
|
|
54
|
+
return SolanaWalletConnectConnectorConstructor;
|
|
55
|
+
});
|
|
56
|
+
const filteredWcConstructors = allWcConstructors.filter((constructor) => currentConnectors.every((existingConnector) =>
|
|
57
|
+
// @ts-expect-error - the key type is not defined for the constructor
|
|
58
|
+
existingConnector['key'] !== constructor['key'] &&
|
|
59
|
+
// @ts-expect-error - the key type is not defined for the constructor
|
|
60
|
+
!constructor['groupedKeys'].includes(existingConnector['key'])));
|
|
61
|
+
return [...currentConnectors, ...filteredWcConstructors];
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.addSolanaWalletConnectConnectors = addSolanaWalletConnectConnectors;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { WalletBookSchema } from '@dynamic-labs/wallet-book';
|
|
2
|
+
import { WalletConnectorConstructor } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
type FetchSolanaWalletConnectWalletsProps = {
|
|
4
|
+
walletBook: WalletBookSchema;
|
|
5
|
+
connectors: WalletConnectorConstructor[];
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
|
|
9
|
+
* by checking what connectors are already present
|
|
10
|
+
*/
|
|
11
|
+
export declare const addSolanaWalletConnectConnectors: ({ walletBook, connectors: currentConnectors, }: FetchSolanaWalletConnectWalletsProps) => Array<WalletConnectorConstructor>;
|
|
12
|
+
export {};
|
package/src/walletConnect/utils/addSolanaWalletConnectConnectors/addSolanaWalletConnectConnectors.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { getWalletMetadataFromWalletBook } from '@dynamic-labs/wallet-connector-core';
|
|
3
|
+
import { SolanaWalletConnectConnector } from '../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Adds Solana WalletConnect connectors to the list of connectors, avoiding duplicates
|
|
7
|
+
* by checking what connectors are already present
|
|
8
|
+
*/
|
|
9
|
+
const addSolanaWalletConnectConnectors = ({ walletBook, connectors: currentConnectors, }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const walletEntries = Object.entries((_a = walletBook === null || walletBook === void 0 ? void 0 : walletBook.wallets) !== null && _a !== void 0 ? _a : {});
|
|
12
|
+
const allWcConstructors = walletEntries
|
|
13
|
+
.filter(([, wallet]) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return wallet.walletConnect &&
|
|
16
|
+
(
|
|
17
|
+
// Exclude wallets that don't support Solana
|
|
18
|
+
(_a = wallet.chains) === null || _a === void 0 ? void 0 : _a.some((chain) => chain.includes('solana:')));
|
|
19
|
+
})
|
|
20
|
+
.map(([key, wallet]) => {
|
|
21
|
+
const { shortName } = wallet;
|
|
22
|
+
const name = shortName || wallet.name;
|
|
23
|
+
const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector {
|
|
24
|
+
constructor(props) {
|
|
25
|
+
super(Object.assign(Object.assign({}, props), { metadata: getWalletMetadataFromWalletBook({
|
|
26
|
+
walletBookWallet: wallet,
|
|
27
|
+
walletKey: key,
|
|
28
|
+
}), overrideKey: key, walletName: name }));
|
|
29
|
+
this.overrideKey = key;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const entryKeysWithSameGroup = walletEntries
|
|
33
|
+
.filter(([, { group }]) => group && group === wallet.group)
|
|
34
|
+
.map(([key]) => key);
|
|
35
|
+
// We store the key and the keys of all other entries in the same group
|
|
36
|
+
// so that we can filter out from the WC connectors we just built both the ones
|
|
37
|
+
// whose key is already present in the current connectors and the ones whose key is in the same group
|
|
38
|
+
// as one of the current connectors.
|
|
39
|
+
// We need to check the groups as well because the wallet book entry that we use to create the Sol WC
|
|
40
|
+
// connector might be coming from the EVM wallet book entry (due to historical reasons, that's the entry
|
|
41
|
+
// that has the WC data)
|
|
42
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
|
|
43
|
+
value: key,
|
|
44
|
+
writable: false,
|
|
45
|
+
});
|
|
46
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'groupedKeys', {
|
|
47
|
+
value: entryKeysWithSameGroup,
|
|
48
|
+
writable: false,
|
|
49
|
+
});
|
|
50
|
+
return SolanaWalletConnectConnectorConstructor;
|
|
51
|
+
});
|
|
52
|
+
const filteredWcConstructors = allWcConstructors.filter((constructor) => currentConnectors.every((existingConnector) =>
|
|
53
|
+
// @ts-expect-error - the key type is not defined for the constructor
|
|
54
|
+
existingConnector['key'] !== constructor['key'] &&
|
|
55
|
+
// @ts-expect-error - the key type is not defined for the constructor
|
|
56
|
+
!constructor['groupedKeys'].includes(existingConnector['key'])));
|
|
57
|
+
return [...currentConnectors, ...filteredWcConstructors];
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { addSolanaWalletConnectConnectors };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './addSolanaWalletConnectConnectors';
|
package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.cjs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var SolanaWalletConnectConnector = require('../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs');
|
|
7
|
+
|
|
8
|
+
const getSolanaWalletConnectConnector = () => {
|
|
9
|
+
const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector.SolanaWalletConnectConnector {
|
|
10
|
+
constructor(props) {
|
|
11
|
+
super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
|
|
15
|
+
value: 'walletconnectsol',
|
|
16
|
+
writable: false,
|
|
17
|
+
});
|
|
18
|
+
return SolanaWalletConnectConnectorConstructor;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
exports.getSolanaWalletConnectConnector = getSolanaWalletConnectConnector;
|
package/src/walletConnect/utils/getSolanaWalletConnectConnector/getSolanaWalletConnectConnector.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { SolanaWalletConnectConnector } from '../../SolanaWalletConnectConnector/SolanaWalletConnectConnector.js';
|
|
3
|
+
|
|
4
|
+
const getSolanaWalletConnectConnector = () => {
|
|
5
|
+
const SolanaWalletConnectConnectorConstructor = class extends SolanaWalletConnectConnector {
|
|
6
|
+
constructor(props) {
|
|
7
|
+
super(Object.assign(Object.assign({}, props), { metadata: { groupKey: 'walletconnect', name: 'WalletConnect' }, walletName: 'WalletConnect Sol' }));
|
|
8
|
+
}
|
|
9
|
+
};
|
|
10
|
+
Object.defineProperty(SolanaWalletConnectConnectorConstructor, 'key', {
|
|
11
|
+
value: 'walletconnectsol',
|
|
12
|
+
writable: false,
|
|
13
|
+
});
|
|
14
|
+
return SolanaWalletConnectConnectorConstructor;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { getSolanaWalletConnectConnector };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getSolanaWalletConnectConnector } from './getSolanaWalletConnectConnector';
|