@dynamic-labs/waas-svm 4.83.0 → 4.83.2-alpha.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 +37 -853
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +11 -11
- package/src/connector/DynamicWaasSVMConnector.cjs +62 -40
- package/src/connector/DynamicWaasSVMConnector.d.ts +5 -1
- package/src/connector/DynamicWaasSVMConnector.js +63 -41
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/waas-svm",
|
|
3
|
-
"version": "4.83.0",
|
|
3
|
+
"version": "4.83.2-alpha.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,19 +18,19 @@
|
|
|
18
18
|
},
|
|
19
19
|
"homepage": "https://www.dynamic.xyz/",
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
22
|
-
"@dynamic-labs/embedded-wallet-solana": "4.83.0",
|
|
21
|
+
"@dynamic-labs/sdk-api-core": "0.0.985",
|
|
22
|
+
"@dynamic-labs/embedded-wallet-solana": "4.83.2-alpha.0",
|
|
23
23
|
"@solana/web3.js": "1.98.1",
|
|
24
24
|
"eventemitter3": "5.0.1",
|
|
25
25
|
"bs58": "5.0.0",
|
|
26
|
-
"@dynamic-labs/assert-package-version": "4.83.0",
|
|
27
|
-
"@dynamic-labs/logger": "4.83.0",
|
|
28
|
-
"@dynamic-labs/rpc-providers": "4.83.0",
|
|
29
|
-
"@dynamic-labs/solana-core": "4.83.0",
|
|
30
|
-
"@dynamic-labs/types": "4.83.0",
|
|
31
|
-
"@dynamic-labs/utils": "4.83.0",
|
|
32
|
-
"@dynamic-labs/waas": "4.83.0",
|
|
33
|
-
"@dynamic-labs/wallet-connector-core": "4.83.0"
|
|
26
|
+
"@dynamic-labs/assert-package-version": "4.83.2-alpha.0",
|
|
27
|
+
"@dynamic-labs/logger": "4.83.2-alpha.0",
|
|
28
|
+
"@dynamic-labs/rpc-providers": "4.83.2-alpha.0",
|
|
29
|
+
"@dynamic-labs/solana-core": "4.83.2-alpha.0",
|
|
30
|
+
"@dynamic-labs/types": "4.83.2-alpha.0",
|
|
31
|
+
"@dynamic-labs/utils": "4.83.2-alpha.0",
|
|
32
|
+
"@dynamic-labs/waas": "4.83.2-alpha.0",
|
|
33
|
+
"@dynamic-labs/wallet-connector-core": "4.83.2-alpha.0"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {}
|
|
36
36
|
}
|
|
@@ -191,12 +191,21 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
|
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
internalSignTransaction(transaction_1) {
|
|
194
|
-
return _tslib.__awaiter(this, arguments, void 0, function* (transaction, { parentTraceId, startTime, } = {}) {
|
|
194
|
+
return _tslib.__awaiter(this, arguments, void 0, function* (transaction, { parentTraceId, startTime, overrideBlockhash, } = {}) {
|
|
195
195
|
var _a, _b, _c;
|
|
196
196
|
const traceId = parentTraceId || this.generateTraceId();
|
|
197
197
|
const effectiveStartTime = startTime || Date.now();
|
|
198
198
|
// Attempt to sponsor the transaction before signing
|
|
199
199
|
const txToSign = yield this.maybeSponsorTransaction(transaction);
|
|
200
|
+
if (overrideBlockhash) {
|
|
201
|
+
if (solanaCore.isVersionedTransaction(txToSign)) {
|
|
202
|
+
txToSign.message.recentBlockhash = overrideBlockhash.blockhash;
|
|
203
|
+
}
|
|
204
|
+
else {
|
|
205
|
+
txToSign.recentBlockhash = overrideBlockhash.blockhash;
|
|
206
|
+
txToSign.lastValidBlockHeight = overrideBlockhash.lastValidBlockHeight;
|
|
207
|
+
}
|
|
208
|
+
}
|
|
200
209
|
const walletClient = yield this.instrumentAsync({
|
|
201
210
|
context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
|
|
202
211
|
fn: () => _tslib.__awaiter(this, void 0, void 0, function* () { return this.getWaasWalletClient(); }),
|
|
@@ -343,16 +352,25 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
|
|
|
343
352
|
}
|
|
344
353
|
internalSignAndSendTransaction(transaction_1, options_1) {
|
|
345
354
|
return _tslib.__awaiter(this, arguments, void 0, function* (transaction, options, { parentTraceId, startTime, } = {}) {
|
|
355
|
+
var _a;
|
|
346
356
|
const traceId = parentTraceId || this.generateTraceId();
|
|
347
357
|
const effectiveStartTime = startTime || Date.now();
|
|
348
358
|
if (!this.activeAccountAddress) {
|
|
349
359
|
throw new Error('Active account address is required');
|
|
350
360
|
}
|
|
351
361
|
const connection = this.getWalletClient();
|
|
362
|
+
// Refresh the blockhash right before signing so the tx is submitted with
|
|
363
|
+
// a fresh validity window AND so confirmTransaction's expiration check
|
|
364
|
+
// operates on the same blockhash that's embedded in the tx.
|
|
365
|
+
// Use 'finalized' so the blockhash is recognized by every RPC node
|
|
366
|
+
// (a 'confirmed' blockhash may not yet have propagated to the simulating
|
|
367
|
+
// node, which surfaces as "Blockhash not found" at sendRawTransaction).
|
|
368
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('finalized');
|
|
352
369
|
const signedTransaction = yield this.instrumentAsync({
|
|
353
370
|
context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
|
|
354
371
|
fn: () => _tslib.__awaiter(this, void 0, void 0, function* () {
|
|
355
372
|
return this.internalSignTransaction(transaction, {
|
|
373
|
+
overrideBlockhash: { blockhash, lastValidBlockHeight },
|
|
356
374
|
parentTraceId: traceId,
|
|
357
375
|
startTime: effectiveStartTime,
|
|
358
376
|
});
|
|
@@ -380,49 +398,53 @@ class DynamicWaasSVMConnector extends waas.withDynamicWaas(solanaCore.SolanaWall
|
|
|
380
398
|
operation: 'internalSignAndSendTransaction',
|
|
381
399
|
resource: 'sendRawTransaction',
|
|
382
400
|
});
|
|
383
|
-
// Listen for transaction confirmation with timeout
|
|
384
401
|
const confirmationStartTime = Date.now();
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
402
|
+
try {
|
|
403
|
+
const confirmationResult = yield connection.confirmTransaction({
|
|
404
|
+
blockhash,
|
|
405
|
+
lastValidBlockHeight,
|
|
406
|
+
signature,
|
|
407
|
+
}, (_a = options === null || options === void 0 ? void 0 : options.preflightCommitment) !== null && _a !== void 0 ? _a : 'confirmed');
|
|
408
|
+
const confirmationEndTime = Date.now();
|
|
409
|
+
const confirmationStepElapsed = confirmationEndTime - confirmationStartTime;
|
|
410
|
+
const confirmationTotalElapsed = confirmationEndTime - effectiveStartTime;
|
|
411
|
+
if (confirmationResult.value.err) {
|
|
412
|
+
logger.logger.error(`[internalSignAndSendTransaction] Transaction failed - total: ${confirmationTotalElapsed}ms, step: ${confirmationStepElapsed}ms`, {
|
|
413
|
+
accountAddress: this.activeAccountAddress,
|
|
414
|
+
error: confirmationResult.value.err,
|
|
415
|
+
key: 'internalSignAndSendTransaction-transactionFailed',
|
|
391
416
|
rpcUrl: connection.rpcEndpoint,
|
|
392
|
-
|
|
417
|
+
stepTime: confirmationStepElapsed,
|
|
418
|
+
time: confirmationTotalElapsed,
|
|
393
419
|
traceId,
|
|
394
420
|
});
|
|
395
|
-
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
resolve(signature);
|
|
423
|
-
}
|
|
424
|
-
}, (_a = options === null || options === void 0 ? void 0 : options.preflightCommitment) !== null && _a !== void 0 ? _a : 'confirmed');
|
|
425
|
-
});
|
|
421
|
+
throw new utils.TransactionFailedError(confirmationResult.value.err);
|
|
422
|
+
}
|
|
423
|
+
this.instrument(`[internalSignAndSendTransaction] Transaction confirmed - total: ${confirmationTotalElapsed}ms, step: ${confirmationStepElapsed}ms`, {
|
|
424
|
+
key: 'internalSignAndSendTransaction-transactionSuccess',
|
|
425
|
+
rpcUrl: connection.rpcEndpoint,
|
|
426
|
+
stepTime: confirmationStepElapsed,
|
|
427
|
+
time: confirmationTotalElapsed,
|
|
428
|
+
traceId,
|
|
429
|
+
});
|
|
430
|
+
}
|
|
431
|
+
catch (error) {
|
|
432
|
+
if (error instanceof utils.TransactionFailedError) {
|
|
433
|
+
throw error;
|
|
434
|
+
}
|
|
435
|
+
const timeoutTotalElapsed = Date.now() - confirmationStartTime;
|
|
436
|
+
logger.logger.error(`[internalSignAndSendTransaction] Confirmation timed out - total: ${timeoutTotalElapsed}ms`, {
|
|
437
|
+
accountAddress: this.activeAccountAddress,
|
|
438
|
+
error,
|
|
439
|
+
key: 'internalSignAndSendTransaction-confirmationTimedOut',
|
|
440
|
+
rpcUrl: connection.rpcEndpoint,
|
|
441
|
+
signature,
|
|
442
|
+
time: timeoutTotalElapsed,
|
|
443
|
+
traceId,
|
|
444
|
+
});
|
|
445
|
+
throw new utils.TransactionConfirmationTimeoutError(signature);
|
|
446
|
+
}
|
|
447
|
+
return signature;
|
|
426
448
|
});
|
|
427
449
|
}
|
|
428
450
|
signAndSendTransaction(transaction, options) {
|
|
@@ -186,9 +186,13 @@ export declare class DynamicWaasSVMConnector extends DynamicWaasSVMConnector_bas
|
|
|
186
186
|
startTime?: number;
|
|
187
187
|
}): Promise<string>;
|
|
188
188
|
signMessage(message: string): Promise<string>;
|
|
189
|
-
internalSignTransaction<T extends Transaction | VersionedTransaction>(transaction: T, { parentTraceId, startTime, }?: {
|
|
189
|
+
internalSignTransaction<T extends Transaction | VersionedTransaction>(transaction: T, { parentTraceId, startTime, overrideBlockhash, }?: {
|
|
190
190
|
parentTraceId?: string;
|
|
191
191
|
startTime?: number;
|
|
192
|
+
overrideBlockhash?: {
|
|
193
|
+
blockhash: string;
|
|
194
|
+
lastValidBlockHeight: number;
|
|
195
|
+
};
|
|
192
196
|
}): Promise<Transaction | VersionedTransaction>;
|
|
193
197
|
signTransaction<T extends Transaction | VersionedTransaction>(transaction: T): Promise<Transaction | VersionedTransaction>;
|
|
194
198
|
internalSignAllTransactions<T extends Transaction | VersionedTransaction>(transactions: T[]): Promise<(Transaction | VersionedTransaction)[]>;
|
|
@@ -4,7 +4,7 @@ import { PublicKey } from '@solana/web3.js';
|
|
|
4
4
|
import { sponsorSolanaTransaction } from '@dynamic-labs/embedded-wallet-solana';
|
|
5
5
|
import { MFAAction, TokenScope } from '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { SolanaWalletConnector, isVersionedTransaction, SolanaUiTransaction } from '@dynamic-labs/solana-core';
|
|
7
|
-
import { DynamicError } from '@dynamic-labs/utils';
|
|
7
|
+
import { DynamicError, TransactionFailedError, TransactionConfirmationTimeoutError } from '@dynamic-labs/utils';
|
|
8
8
|
import { withDynamicWaas } from '@dynamic-labs/waas';
|
|
9
9
|
import { isSameAddress } from '@dynamic-labs/wallet-connector-core';
|
|
10
10
|
import { logger } from '../../utils/logger.js';
|
|
@@ -187,12 +187,21 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
|
|
|
187
187
|
});
|
|
188
188
|
}
|
|
189
189
|
internalSignTransaction(transaction_1) {
|
|
190
|
-
return __awaiter(this, arguments, void 0, function* (transaction, { parentTraceId, startTime, } = {}) {
|
|
190
|
+
return __awaiter(this, arguments, void 0, function* (transaction, { parentTraceId, startTime, overrideBlockhash, } = {}) {
|
|
191
191
|
var _a, _b, _c;
|
|
192
192
|
const traceId = parentTraceId || this.generateTraceId();
|
|
193
193
|
const effectiveStartTime = startTime || Date.now();
|
|
194
194
|
// Attempt to sponsor the transaction before signing
|
|
195
195
|
const txToSign = yield this.maybeSponsorTransaction(transaction);
|
|
196
|
+
if (overrideBlockhash) {
|
|
197
|
+
if (isVersionedTransaction(txToSign)) {
|
|
198
|
+
txToSign.message.recentBlockhash = overrideBlockhash.blockhash;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
txToSign.recentBlockhash = overrideBlockhash.blockhash;
|
|
202
|
+
txToSign.lastValidBlockHeight = overrideBlockhash.lastValidBlockHeight;
|
|
203
|
+
}
|
|
204
|
+
}
|
|
196
205
|
const walletClient = yield this.instrumentAsync({
|
|
197
206
|
context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
|
|
198
207
|
fn: () => __awaiter(this, void 0, void 0, function* () { return this.getWaasWalletClient(); }),
|
|
@@ -339,16 +348,25 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
|
|
|
339
348
|
}
|
|
340
349
|
internalSignAndSendTransaction(transaction_1, options_1) {
|
|
341
350
|
return __awaiter(this, arguments, void 0, function* (transaction, options, { parentTraceId, startTime, } = {}) {
|
|
351
|
+
var _a;
|
|
342
352
|
const traceId = parentTraceId || this.generateTraceId();
|
|
343
353
|
const effectiveStartTime = startTime || Date.now();
|
|
344
354
|
if (!this.activeAccountAddress) {
|
|
345
355
|
throw new Error('Active account address is required');
|
|
346
356
|
}
|
|
347
357
|
const connection = this.getWalletClient();
|
|
358
|
+
// Refresh the blockhash right before signing so the tx is submitted with
|
|
359
|
+
// a fresh validity window AND so confirmTransaction's expiration check
|
|
360
|
+
// operates on the same blockhash that's embedded in the tx.
|
|
361
|
+
// Use 'finalized' so the blockhash is recognized by every RPC node
|
|
362
|
+
// (a 'confirmed' blockhash may not yet have propagated to the simulating
|
|
363
|
+
// node, which surfaces as "Blockhash not found" at sendRawTransaction).
|
|
364
|
+
const { blockhash, lastValidBlockHeight } = yield connection.getLatestBlockhash('finalized');
|
|
348
365
|
const signedTransaction = yield this.instrumentAsync({
|
|
349
366
|
context: { chainName: 'SVM', startTime: effectiveStartTime, traceId },
|
|
350
367
|
fn: () => __awaiter(this, void 0, void 0, function* () {
|
|
351
368
|
return this.internalSignTransaction(transaction, {
|
|
369
|
+
overrideBlockhash: { blockhash, lastValidBlockHeight },
|
|
352
370
|
parentTraceId: traceId,
|
|
353
371
|
startTime: effectiveStartTime,
|
|
354
372
|
});
|
|
@@ -376,49 +394,53 @@ class DynamicWaasSVMConnector extends withDynamicWaas(SolanaWalletConnector) {
|
|
|
376
394
|
operation: 'internalSignAndSendTransaction',
|
|
377
395
|
resource: 'sendRawTransaction',
|
|
378
396
|
});
|
|
379
|
-
// Listen for transaction confirmation with timeout
|
|
380
397
|
const confirmationStartTime = Date.now();
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
398
|
+
try {
|
|
399
|
+
const confirmationResult = yield connection.confirmTransaction({
|
|
400
|
+
blockhash,
|
|
401
|
+
lastValidBlockHeight,
|
|
402
|
+
signature,
|
|
403
|
+
}, (_a = options === null || options === void 0 ? void 0 : options.preflightCommitment) !== null && _a !== void 0 ? _a : 'confirmed');
|
|
404
|
+
const confirmationEndTime = Date.now();
|
|
405
|
+
const confirmationStepElapsed = confirmationEndTime - confirmationStartTime;
|
|
406
|
+
const confirmationTotalElapsed = confirmationEndTime - effectiveStartTime;
|
|
407
|
+
if (confirmationResult.value.err) {
|
|
408
|
+
logger.error(`[internalSignAndSendTransaction] Transaction failed - total: ${confirmationTotalElapsed}ms, step: ${confirmationStepElapsed}ms`, {
|
|
409
|
+
accountAddress: this.activeAccountAddress,
|
|
410
|
+
error: confirmationResult.value.err,
|
|
411
|
+
key: 'internalSignAndSendTransaction-transactionFailed',
|
|
387
412
|
rpcUrl: connection.rpcEndpoint,
|
|
388
|
-
|
|
413
|
+
stepTime: confirmationStepElapsed,
|
|
414
|
+
time: confirmationTotalElapsed,
|
|
389
415
|
traceId,
|
|
390
416
|
});
|
|
391
|
-
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
resolve(signature);
|
|
419
|
-
}
|
|
420
|
-
}, (_a = options === null || options === void 0 ? void 0 : options.preflightCommitment) !== null && _a !== void 0 ? _a : 'confirmed');
|
|
421
|
-
});
|
|
417
|
+
throw new TransactionFailedError(confirmationResult.value.err);
|
|
418
|
+
}
|
|
419
|
+
this.instrument(`[internalSignAndSendTransaction] Transaction confirmed - total: ${confirmationTotalElapsed}ms, step: ${confirmationStepElapsed}ms`, {
|
|
420
|
+
key: 'internalSignAndSendTransaction-transactionSuccess',
|
|
421
|
+
rpcUrl: connection.rpcEndpoint,
|
|
422
|
+
stepTime: confirmationStepElapsed,
|
|
423
|
+
time: confirmationTotalElapsed,
|
|
424
|
+
traceId,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
catch (error) {
|
|
428
|
+
if (error instanceof TransactionFailedError) {
|
|
429
|
+
throw error;
|
|
430
|
+
}
|
|
431
|
+
const timeoutTotalElapsed = Date.now() - confirmationStartTime;
|
|
432
|
+
logger.error(`[internalSignAndSendTransaction] Confirmation timed out - total: ${timeoutTotalElapsed}ms`, {
|
|
433
|
+
accountAddress: this.activeAccountAddress,
|
|
434
|
+
error,
|
|
435
|
+
key: 'internalSignAndSendTransaction-confirmationTimedOut',
|
|
436
|
+
rpcUrl: connection.rpcEndpoint,
|
|
437
|
+
signature,
|
|
438
|
+
time: timeoutTotalElapsed,
|
|
439
|
+
traceId,
|
|
440
|
+
});
|
|
441
|
+
throw new TransactionConfirmationTimeoutError(signature);
|
|
442
|
+
}
|
|
443
|
+
return signature;
|
|
422
444
|
});
|
|
423
445
|
}
|
|
424
446
|
signAndSendTransaction(transaction, options) {
|