@dynamic-labs/solana 4.40.2 → 4.41.0
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 +12 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.cjs +112 -10
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.d.ts +6 -2
- package/src/walletConnect/SolanaWalletConnectConnector/SolanaWalletConnectConnector.js +113 -11
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,16 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.41.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.40.2...v4.41.0) (2025-10-29)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* **react-native:** add MFA recovery methods ([#9788](https://github.com/dynamic-labs/dynamic-auth/issues/9788)) ([664e0d5](https://github.com/dynamic-labs/dynamic-auth/commit/664e0d5878530abc9e645c8801a87f3109cfd8f9))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* crypto.com link opening on mobile ([#9779](https://github.com/dynamic-labs/dynamic-auth/issues/9779)) ([3439ac9](https://github.com/dynamic-labs/dynamic-auth/commit/3439ac9e2610360c6204f6195433ae3e05e26c30))
|
|
13
|
+
|
|
2
14
|
### [4.40.2](https://github.com/dynamic-labs/dynamic-auth/compare/v4.40.1...v4.40.2) (2025-10-28)
|
|
3
15
|
|
|
4
16
|
|
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.
|
|
3
|
+
"version": "4.41.0",
|
|
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",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/wallet-connect": "4.
|
|
21
|
+
"@dynamic-labs/wallet-connect": "4.41.0",
|
|
22
22
|
"@solana/web3.js": "1.98.1",
|
|
23
23
|
"@wallet-standard/app": "1.0.1",
|
|
24
24
|
"@wallet-standard/base": "1.0.1",
|
|
@@ -29,17 +29,17 @@
|
|
|
29
29
|
"@walletconnect/sign-client": "2.21.5",
|
|
30
30
|
"@walletconnect/utils": "2.21.5",
|
|
31
31
|
"@walletconnect/types": "2.21.5",
|
|
32
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
33
|
-
"@dynamic-labs/embedded-wallet-solana": "4.
|
|
34
|
-
"@dynamic-labs/logger": "4.
|
|
35
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
32
|
+
"@dynamic-labs/assert-package-version": "4.41.0",
|
|
33
|
+
"@dynamic-labs/embedded-wallet-solana": "4.41.0",
|
|
34
|
+
"@dynamic-labs/logger": "4.41.0",
|
|
35
|
+
"@dynamic-labs/rpc-providers": "4.41.0",
|
|
36
36
|
"@dynamic-labs/sdk-api-core": "0.0.813",
|
|
37
|
-
"@dynamic-labs/solana-core": "4.
|
|
38
|
-
"@dynamic-labs/types": "4.
|
|
39
|
-
"@dynamic-labs/utils": "4.
|
|
40
|
-
"@dynamic-labs/waas-svm": "4.
|
|
41
|
-
"@dynamic-labs/wallet-book": "4.
|
|
42
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
37
|
+
"@dynamic-labs/solana-core": "4.41.0",
|
|
38
|
+
"@dynamic-labs/types": "4.41.0",
|
|
39
|
+
"@dynamic-labs/utils": "4.41.0",
|
|
40
|
+
"@dynamic-labs/waas-svm": "4.41.0",
|
|
41
|
+
"@dynamic-labs/wallet-book": "4.41.0",
|
|
42
|
+
"@dynamic-labs/wallet-connector-core": "4.41.0",
|
|
43
43
|
"eventemitter3": "5.0.1"
|
|
44
44
|
},
|
|
45
45
|
"peerDependencies": {}
|
|
@@ -55,11 +55,18 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
55
55
|
}
|
|
56
56
|
return SolanaWalletConnectConnector.signClientReference;
|
|
57
57
|
}
|
|
58
|
+
getAvailableMethods() {
|
|
59
|
+
var _a, _b;
|
|
60
|
+
if (!this.session) {
|
|
61
|
+
return [];
|
|
62
|
+
}
|
|
63
|
+
return (_b = (_a = this.session.namespaces.solana) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [];
|
|
64
|
+
}
|
|
58
65
|
getSupportedNetworks() {
|
|
59
66
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
60
67
|
var _a, _b;
|
|
61
68
|
if (!this.session) {
|
|
62
|
-
return
|
|
69
|
+
return this.solNetworks.map((network) => network.chainId.toString());
|
|
63
70
|
}
|
|
64
71
|
const sessionChains = (_b = (_a = this.session.namespaces.solana) === null || _a === void 0 ? void 0 : _a.chains) !== null && _b !== void 0 ? _b : [];
|
|
65
72
|
return this.solNetworks
|
|
@@ -80,6 +87,46 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
80
87
|
this.activeAccountEmitter.off('activeAccountDidChange', listener);
|
|
81
88
|
};
|
|
82
89
|
}
|
|
90
|
+
isSendBalanceUnsupported() {
|
|
91
|
+
// If there is no session, we assume the wallet supports send balance
|
|
92
|
+
// If we didn't, the send TX button would turn disabled on a refresh
|
|
93
|
+
if (!this.session) {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
const supportedMethods = this.getAvailableMethods();
|
|
97
|
+
return (!supportedMethods.includes('solana_signAndSendTransaction') &&
|
|
98
|
+
!supportedMethods.includes('solana_signTransaction'));
|
|
99
|
+
}
|
|
100
|
+
createUiTransaction(from) {
|
|
101
|
+
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
102
|
+
yield this.validateActiveWallet(from);
|
|
103
|
+
if (this.isSendBalanceUnsupported()) {
|
|
104
|
+
throw new utils.DynamicError('Wallet does not support signing transactions. Please connect to a wallet that supports signing transactions.');
|
|
105
|
+
}
|
|
106
|
+
const transaction = new solanaCore.SolanaUiTransaction({
|
|
107
|
+
connection: this.getWalletClient(),
|
|
108
|
+
from,
|
|
109
|
+
onSubmit: (transaction) => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
110
|
+
var _a;
|
|
111
|
+
if (!transaction)
|
|
112
|
+
return;
|
|
113
|
+
const blockhash = yield this.getWalletClient().getLatestBlockhash();
|
|
114
|
+
if ('version' in transaction) {
|
|
115
|
+
transaction.message.recentBlockhash =
|
|
116
|
+
blockhash.blockhash;
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
// Use the 'from' parameter which is the validated active wallet address
|
|
120
|
+
transaction.recentBlockhash = blockhash.blockhash;
|
|
121
|
+
transaction.feePayer =
|
|
122
|
+
(_a = transaction.feePayer) !== null && _a !== void 0 ? _a : new web3_js.PublicKey(from);
|
|
123
|
+
}
|
|
124
|
+
return yield this.signAndSendTransaction(transaction);
|
|
125
|
+
}),
|
|
126
|
+
});
|
|
127
|
+
return transaction;
|
|
128
|
+
});
|
|
129
|
+
}
|
|
83
130
|
getSigner() {
|
|
84
131
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
85
132
|
return createSolanaSignerForWalletConnect.createSolanaSignerForWalletConnect({ walletConnector: this });
|
|
@@ -125,7 +172,8 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
125
172
|
const chainParam = event.data;
|
|
126
173
|
let chainId = chainParam;
|
|
127
174
|
// Handle potentially CAIP-2 format
|
|
128
|
-
if (chainParam
|
|
175
|
+
if (typeof chainParam === 'string' &&
|
|
176
|
+
chainParam.startsWith('solana:')) {
|
|
129
177
|
const chainHash = chainParam.split(':')[1];
|
|
130
178
|
chainId =
|
|
131
179
|
(_b = (_a = this.solNetworks
|
|
@@ -137,7 +185,7 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
137
185
|
return;
|
|
138
186
|
}
|
|
139
187
|
// This will already emit an event so no need to call this.emit('chainChange', { chain: chainId });
|
|
140
|
-
this.switchNetwork({ networkChainId: parseInt(chainId) });
|
|
188
|
+
this.switchNetwork({ networkChainId: parseInt(String(chainId)) });
|
|
141
189
|
return;
|
|
142
190
|
}
|
|
143
191
|
if (event.name === 'accountsChanged') {
|
|
@@ -212,8 +260,14 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
212
260
|
}
|
|
213
261
|
logger.logger.debug('[SolanaWalletConnect] getAddress - connecting to WalletConnect');
|
|
214
262
|
const chains = this.solNetworks.map((network) => `solana:${network.genesisHash}`);
|
|
263
|
+
// Await for the promise in case this gets called right as the window is loaded
|
|
264
|
+
// and the sign client is still initializing
|
|
265
|
+
const signClient = yield SolanaWalletConnectConnector.signClientPromise;
|
|
266
|
+
if (!signClient) {
|
|
267
|
+
throw new utils.DynamicError('Failed to access sign client for Wallet Connect Solana: Sign client not initialized');
|
|
268
|
+
}
|
|
215
269
|
try {
|
|
216
|
-
const { approval, uri } = yield
|
|
270
|
+
const { approval, uri } = yield signClient.connect({
|
|
217
271
|
optionalNamespaces: {
|
|
218
272
|
solana: {
|
|
219
273
|
chains,
|
|
@@ -330,12 +384,27 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
330
384
|
if (!activeAddress) {
|
|
331
385
|
throw new utils.DynamicError('Active account address is required');
|
|
332
386
|
}
|
|
387
|
+
logger.logger.debug('[SolanaWalletConnect] Signing transaction', {
|
|
388
|
+
activeAddress,
|
|
389
|
+
isVersioned: 'version' in transaction,
|
|
390
|
+
transaction,
|
|
391
|
+
});
|
|
333
392
|
const serializedTransaction = this.serializeTransaction(transaction);
|
|
393
|
+
logger.logger.debug('[SolanaWalletConnect] Sending to wallet for signing', {
|
|
394
|
+
serializedLength: serializedTransaction.length,
|
|
395
|
+
});
|
|
334
396
|
const { transaction: signedTransaction } = yield this.signClientRequest({
|
|
335
397
|
method: 'solana_signTransaction',
|
|
336
398
|
params: { transaction: serializedTransaction },
|
|
337
399
|
});
|
|
400
|
+
logger.logger.debug('[SolanaWalletConnect] Received signed transaction from wallet', {
|
|
401
|
+
signedTransactionLength: signedTransaction.length,
|
|
402
|
+
signedTransactionPreview: signedTransaction.substring(0, 50),
|
|
403
|
+
});
|
|
338
404
|
const decodedTransaction = bs58__default["default"].decode(signedTransaction);
|
|
405
|
+
logger.logger.debug('[SolanaWalletConnect] Decoded signed transaction', {
|
|
406
|
+
decodedLength: decodedTransaction.length,
|
|
407
|
+
});
|
|
339
408
|
if (solanaCore.isVersionedTransaction(transaction)) {
|
|
340
409
|
return web3_js.VersionedTransaction.deserialize(decodedTransaction);
|
|
341
410
|
}
|
|
@@ -361,12 +430,45 @@ class SolanaWalletConnectConnector extends solanaCore.SolanaWalletConnector {
|
|
|
361
430
|
}
|
|
362
431
|
signAndSendTransaction(transaction, options) {
|
|
363
432
|
return _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
433
|
+
const supportedMethods = this.getAvailableMethods();
|
|
434
|
+
// Try to use signAndSendTransaction if supported
|
|
435
|
+
if (supportedMethods.includes('solana_signAndSendTransaction')) {
|
|
436
|
+
const serializedTransaction = this.serializeTransaction(transaction);
|
|
437
|
+
const { signature } = yield this.signClientRequest({
|
|
438
|
+
method: 'solana_signAndSendTransaction',
|
|
439
|
+
params: { options, transaction: serializedTransaction },
|
|
440
|
+
});
|
|
441
|
+
return signature;
|
|
442
|
+
}
|
|
443
|
+
// Fallback: use signTransaction + sendRawTransaction
|
|
444
|
+
if (supportedMethods.includes('solana_signTransaction')) {
|
|
445
|
+
logger.logger.debug('[SolanaWalletConnect] Using fallback: signTransaction + sendRawTransaction');
|
|
446
|
+
const signedTransaction = yield this.signTransaction(transaction);
|
|
447
|
+
const isSigned = solanaCore.isTxAlreadySigned(signedTransaction);
|
|
448
|
+
logger.logger.debug('[SolanaWalletConnect] Transaction signed, checking signatures', {
|
|
449
|
+
hasSignatures: 'signatures' in signedTransaction &&
|
|
450
|
+
signedTransaction.signatures.length > 0,
|
|
451
|
+
isSigned,
|
|
452
|
+
signaturesLength: 'signatures' in signedTransaction
|
|
453
|
+
? signedTransaction.signatures.length
|
|
454
|
+
: 'N/A',
|
|
455
|
+
});
|
|
456
|
+
if (!isSigned) {
|
|
457
|
+
throw new utils.DynamicError('Transaction returned from wallet was not properly signed. The wallet may have rejected the signing request.');
|
|
458
|
+
}
|
|
459
|
+
// When sending a signed transaction, serialize it without flags
|
|
460
|
+
// (requireAllSignatures and verifySignatures are only for unsigned transactions)
|
|
461
|
+
const serialized = signedTransaction.serialize();
|
|
462
|
+
logger.logger.debug('[SolanaWalletConnect] Transaction serialized', {
|
|
463
|
+
serializedLength: serialized.length,
|
|
464
|
+
});
|
|
465
|
+
const signature = yield this.getWalletClient().sendRawTransaction(serialized, options);
|
|
466
|
+
logger.logger.debug('[SolanaWalletConnect] Transaction sent successfully', {
|
|
467
|
+
signature,
|
|
468
|
+
});
|
|
469
|
+
return signature;
|
|
470
|
+
}
|
|
471
|
+
throw new utils.DynamicError('Wallet does not support signing and sending transactions. Please connect to a wallet that supports at least solana_signTransaction.');
|
|
370
472
|
});
|
|
371
473
|
}
|
|
372
474
|
getDeepLink() {
|
|
@@ -2,7 +2,8 @@ import { SendOptions, Transaction, VersionedTransaction } from '@solana/web3.js'
|
|
|
2
2
|
import SignClient from '@walletconnect/sign-client';
|
|
3
3
|
import type { SessionTypes } from '@walletconnect/types';
|
|
4
4
|
import { ISolanaSigner, SolanaWalletConnector, SolanaWalletConnectorOpts } from '@dynamic-labs/solana-core';
|
|
5
|
-
import { DeepLinkVariant, GetAddressOpts, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
|
+
import { DeepLinkVariant, GetAddressOpts, ISendBalanceWalletConnector, IWalletConnectConnector } from '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import { IUITransaction } from '@dynamic-labs/types';
|
|
6
7
|
export type SolanaWalletConnectConnectorOpts = SolanaWalletConnectorOpts & {
|
|
7
8
|
projectId?: string;
|
|
8
9
|
walletName: string;
|
|
@@ -11,7 +12,7 @@ export type SolanaWalletConnectConnectorOpts = SolanaWalletConnectorOpts & {
|
|
|
11
12
|
appName?: string;
|
|
12
13
|
overrideKey?: string;
|
|
13
14
|
};
|
|
14
|
-
export declare class SolanaWalletConnectConnector extends SolanaWalletConnector implements IWalletConnectConnector {
|
|
15
|
+
export declare class SolanaWalletConnectConnector extends SolanaWalletConnector implements IWalletConnectConnector, ISendBalanceWalletConnector {
|
|
15
16
|
name: string;
|
|
16
17
|
static signClientReference: SignClient | undefined;
|
|
17
18
|
static signClientPromise: Promise<SignClient> | undefined;
|
|
@@ -35,9 +36,12 @@ export declare class SolanaWalletConnectConnector extends SolanaWalletConnector
|
|
|
35
36
|
* immediately available.
|
|
36
37
|
*/
|
|
37
38
|
get signClient(): SignClient;
|
|
39
|
+
getAvailableMethods(): string[];
|
|
38
40
|
getSupportedNetworks(): Promise<string[]>;
|
|
39
41
|
getActiveAddress(): string | undefined;
|
|
40
42
|
listenToActiveAccountChange(listener: (account: string) => void): VoidFunction;
|
|
43
|
+
isSendBalanceUnsupported(): boolean;
|
|
44
|
+
createUiTransaction(from: string): Promise<IUITransaction>;
|
|
41
45
|
getSigner(): Promise<ISolanaSigner>;
|
|
42
46
|
connect(): Promise<void>;
|
|
43
47
|
init(): Promise<void>;
|
|
@@ -4,7 +4,7 @@ import { PublicKey, VersionedTransaction, Transaction } from '@solana/web3.js';
|
|
|
4
4
|
import { SDK_ERRORS } from '@walletconnect/utils';
|
|
5
5
|
import bs58 from 'bs58';
|
|
6
6
|
import EventEmitter from 'eventemitter3';
|
|
7
|
-
import { SolanaWalletConnector, isVersionedTransaction } from '@dynamic-labs/solana-core';
|
|
7
|
+
import { SolanaWalletConnector, SolanaUiTransaction, isVersionedTransaction, isTxAlreadySigned } from '@dynamic-labs/solana-core';
|
|
8
8
|
import { StorageService, DynamicError, filterDuplicates, isMobile, PlatformService, bufferToBase64 } from '@dynamic-labs/utils';
|
|
9
9
|
import { getSignClientSingleton } from '@dynamic-labs/wallet-connect';
|
|
10
10
|
import { performPlatformSpecificConnectionMethod, getDeepLink, isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -46,11 +46,18 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
46
46
|
}
|
|
47
47
|
return SolanaWalletConnectConnector.signClientReference;
|
|
48
48
|
}
|
|
49
|
+
getAvailableMethods() {
|
|
50
|
+
var _a, _b;
|
|
51
|
+
if (!this.session) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
return (_b = (_a = this.session.namespaces.solana) === null || _a === void 0 ? void 0 : _a.methods) !== null && _b !== void 0 ? _b : [];
|
|
55
|
+
}
|
|
49
56
|
getSupportedNetworks() {
|
|
50
57
|
return __awaiter(this, void 0, void 0, function* () {
|
|
51
58
|
var _a, _b;
|
|
52
59
|
if (!this.session) {
|
|
53
|
-
return
|
|
60
|
+
return this.solNetworks.map((network) => network.chainId.toString());
|
|
54
61
|
}
|
|
55
62
|
const sessionChains = (_b = (_a = this.session.namespaces.solana) === null || _a === void 0 ? void 0 : _a.chains) !== null && _b !== void 0 ? _b : [];
|
|
56
63
|
return this.solNetworks
|
|
@@ -71,6 +78,46 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
71
78
|
this.activeAccountEmitter.off('activeAccountDidChange', listener);
|
|
72
79
|
};
|
|
73
80
|
}
|
|
81
|
+
isSendBalanceUnsupported() {
|
|
82
|
+
// If there is no session, we assume the wallet supports send balance
|
|
83
|
+
// If we didn't, the send TX button would turn disabled on a refresh
|
|
84
|
+
if (!this.session) {
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
const supportedMethods = this.getAvailableMethods();
|
|
88
|
+
return (!supportedMethods.includes('solana_signAndSendTransaction') &&
|
|
89
|
+
!supportedMethods.includes('solana_signTransaction'));
|
|
90
|
+
}
|
|
91
|
+
createUiTransaction(from) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
93
|
+
yield this.validateActiveWallet(from);
|
|
94
|
+
if (this.isSendBalanceUnsupported()) {
|
|
95
|
+
throw new DynamicError('Wallet does not support signing transactions. Please connect to a wallet that supports signing transactions.');
|
|
96
|
+
}
|
|
97
|
+
const transaction = new SolanaUiTransaction({
|
|
98
|
+
connection: this.getWalletClient(),
|
|
99
|
+
from,
|
|
100
|
+
onSubmit: (transaction) => __awaiter(this, void 0, void 0, function* () {
|
|
101
|
+
var _a;
|
|
102
|
+
if (!transaction)
|
|
103
|
+
return;
|
|
104
|
+
const blockhash = yield this.getWalletClient().getLatestBlockhash();
|
|
105
|
+
if ('version' in transaction) {
|
|
106
|
+
transaction.message.recentBlockhash =
|
|
107
|
+
blockhash.blockhash;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
// Use the 'from' parameter which is the validated active wallet address
|
|
111
|
+
transaction.recentBlockhash = blockhash.blockhash;
|
|
112
|
+
transaction.feePayer =
|
|
113
|
+
(_a = transaction.feePayer) !== null && _a !== void 0 ? _a : new PublicKey(from);
|
|
114
|
+
}
|
|
115
|
+
return yield this.signAndSendTransaction(transaction);
|
|
116
|
+
}),
|
|
117
|
+
});
|
|
118
|
+
return transaction;
|
|
119
|
+
});
|
|
120
|
+
}
|
|
74
121
|
getSigner() {
|
|
75
122
|
return __awaiter(this, void 0, void 0, function* () {
|
|
76
123
|
return createSolanaSignerForWalletConnect({ walletConnector: this });
|
|
@@ -116,7 +163,8 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
116
163
|
const chainParam = event.data;
|
|
117
164
|
let chainId = chainParam;
|
|
118
165
|
// Handle potentially CAIP-2 format
|
|
119
|
-
if (chainParam
|
|
166
|
+
if (typeof chainParam === 'string' &&
|
|
167
|
+
chainParam.startsWith('solana:')) {
|
|
120
168
|
const chainHash = chainParam.split(':')[1];
|
|
121
169
|
chainId =
|
|
122
170
|
(_b = (_a = this.solNetworks
|
|
@@ -128,7 +176,7 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
128
176
|
return;
|
|
129
177
|
}
|
|
130
178
|
// This will already emit an event so no need to call this.emit('chainChange', { chain: chainId });
|
|
131
|
-
this.switchNetwork({ networkChainId: parseInt(chainId) });
|
|
179
|
+
this.switchNetwork({ networkChainId: parseInt(String(chainId)) });
|
|
132
180
|
return;
|
|
133
181
|
}
|
|
134
182
|
if (event.name === 'accountsChanged') {
|
|
@@ -203,8 +251,14 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
203
251
|
}
|
|
204
252
|
logger.debug('[SolanaWalletConnect] getAddress - connecting to WalletConnect');
|
|
205
253
|
const chains = this.solNetworks.map((network) => `solana:${network.genesisHash}`);
|
|
254
|
+
// Await for the promise in case this gets called right as the window is loaded
|
|
255
|
+
// and the sign client is still initializing
|
|
256
|
+
const signClient = yield SolanaWalletConnectConnector.signClientPromise;
|
|
257
|
+
if (!signClient) {
|
|
258
|
+
throw new DynamicError('Failed to access sign client for Wallet Connect Solana: Sign client not initialized');
|
|
259
|
+
}
|
|
206
260
|
try {
|
|
207
|
-
const { approval, uri } = yield
|
|
261
|
+
const { approval, uri } = yield signClient.connect({
|
|
208
262
|
optionalNamespaces: {
|
|
209
263
|
solana: {
|
|
210
264
|
chains,
|
|
@@ -321,12 +375,27 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
321
375
|
if (!activeAddress) {
|
|
322
376
|
throw new DynamicError('Active account address is required');
|
|
323
377
|
}
|
|
378
|
+
logger.debug('[SolanaWalletConnect] Signing transaction', {
|
|
379
|
+
activeAddress,
|
|
380
|
+
isVersioned: 'version' in transaction,
|
|
381
|
+
transaction,
|
|
382
|
+
});
|
|
324
383
|
const serializedTransaction = this.serializeTransaction(transaction);
|
|
384
|
+
logger.debug('[SolanaWalletConnect] Sending to wallet for signing', {
|
|
385
|
+
serializedLength: serializedTransaction.length,
|
|
386
|
+
});
|
|
325
387
|
const { transaction: signedTransaction } = yield this.signClientRequest({
|
|
326
388
|
method: 'solana_signTransaction',
|
|
327
389
|
params: { transaction: serializedTransaction },
|
|
328
390
|
});
|
|
391
|
+
logger.debug('[SolanaWalletConnect] Received signed transaction from wallet', {
|
|
392
|
+
signedTransactionLength: signedTransaction.length,
|
|
393
|
+
signedTransactionPreview: signedTransaction.substring(0, 50),
|
|
394
|
+
});
|
|
329
395
|
const decodedTransaction = bs58.decode(signedTransaction);
|
|
396
|
+
logger.debug('[SolanaWalletConnect] Decoded signed transaction', {
|
|
397
|
+
decodedLength: decodedTransaction.length,
|
|
398
|
+
});
|
|
330
399
|
if (isVersionedTransaction(transaction)) {
|
|
331
400
|
return VersionedTransaction.deserialize(decodedTransaction);
|
|
332
401
|
}
|
|
@@ -352,12 +421,45 @@ class SolanaWalletConnectConnector extends SolanaWalletConnector {
|
|
|
352
421
|
}
|
|
353
422
|
signAndSendTransaction(transaction, options) {
|
|
354
423
|
return __awaiter(this, void 0, void 0, function* () {
|
|
355
|
-
const
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
424
|
+
const supportedMethods = this.getAvailableMethods();
|
|
425
|
+
// Try to use signAndSendTransaction if supported
|
|
426
|
+
if (supportedMethods.includes('solana_signAndSendTransaction')) {
|
|
427
|
+
const serializedTransaction = this.serializeTransaction(transaction);
|
|
428
|
+
const { signature } = yield this.signClientRequest({
|
|
429
|
+
method: 'solana_signAndSendTransaction',
|
|
430
|
+
params: { options, transaction: serializedTransaction },
|
|
431
|
+
});
|
|
432
|
+
return signature;
|
|
433
|
+
}
|
|
434
|
+
// Fallback: use signTransaction + sendRawTransaction
|
|
435
|
+
if (supportedMethods.includes('solana_signTransaction')) {
|
|
436
|
+
logger.debug('[SolanaWalletConnect] Using fallback: signTransaction + sendRawTransaction');
|
|
437
|
+
const signedTransaction = yield this.signTransaction(transaction);
|
|
438
|
+
const isSigned = isTxAlreadySigned(signedTransaction);
|
|
439
|
+
logger.debug('[SolanaWalletConnect] Transaction signed, checking signatures', {
|
|
440
|
+
hasSignatures: 'signatures' in signedTransaction &&
|
|
441
|
+
signedTransaction.signatures.length > 0,
|
|
442
|
+
isSigned,
|
|
443
|
+
signaturesLength: 'signatures' in signedTransaction
|
|
444
|
+
? signedTransaction.signatures.length
|
|
445
|
+
: 'N/A',
|
|
446
|
+
});
|
|
447
|
+
if (!isSigned) {
|
|
448
|
+
throw new DynamicError('Transaction returned from wallet was not properly signed. The wallet may have rejected the signing request.');
|
|
449
|
+
}
|
|
450
|
+
// When sending a signed transaction, serialize it without flags
|
|
451
|
+
// (requireAllSignatures and verifySignatures are only for unsigned transactions)
|
|
452
|
+
const serialized = signedTransaction.serialize();
|
|
453
|
+
logger.debug('[SolanaWalletConnect] Transaction serialized', {
|
|
454
|
+
serializedLength: serialized.length,
|
|
455
|
+
});
|
|
456
|
+
const signature = yield this.getWalletClient().sendRawTransaction(serialized, options);
|
|
457
|
+
logger.debug('[SolanaWalletConnect] Transaction sent successfully', {
|
|
458
|
+
signature,
|
|
459
|
+
});
|
|
460
|
+
return signature;
|
|
461
|
+
}
|
|
462
|
+
throw new DynamicError('Wallet does not support signing and sending transactions. Please connect to a wallet that supports at least solana_signTransaction.');
|
|
361
463
|
});
|
|
362
464
|
}
|
|
363
465
|
getDeepLink() {
|