@dynamic-labs-wallet/node-evm 0.0.353 → 1.0.0-beta
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/index.cjs +104 -133
- package/index.esm.js +105 -134
- package/package.json +4 -3
- package/src/client/accountAdapter.d.ts +3 -3
- package/src/client/accountAdapter.d.ts.map +1 -1
- package/src/client/client.d.ts +32 -27
- package/src/client/client.d.ts.map +1 -1
- package/src/zerodev/types.d.ts +2 -2
- package/src/zerodev/types.d.ts.map +1 -1
package/index.cjs
CHANGED
|
@@ -265,9 +265,9 @@ const logError$1 = node.createLogError('node-evm');
|
|
|
265
265
|
return node.revokeDelegation(client, params);
|
|
266
266
|
};
|
|
267
267
|
|
|
268
|
-
const createAccountAdapter = ({ evmClient,
|
|
268
|
+
const createAccountAdapter = ({ evmClient, walletMetadata, password, externalServerKeyShares, delegated })=>{
|
|
269
269
|
return accounts.toAccount({
|
|
270
|
-
address: accountAddress,
|
|
270
|
+
address: walletMetadata.accountAddress,
|
|
271
271
|
signMessage: async ({ message })=>{
|
|
272
272
|
if (delegated) {
|
|
273
273
|
return delegatedSignMessage(delegated.delegatedClient, {
|
|
@@ -279,7 +279,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
279
279
|
}
|
|
280
280
|
const signature = await evmClient.signMessage({
|
|
281
281
|
message: message,
|
|
282
|
-
|
|
282
|
+
walletMetadata,
|
|
283
283
|
password,
|
|
284
284
|
externalServerKeyShares
|
|
285
285
|
});
|
|
@@ -295,7 +295,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
295
295
|
});
|
|
296
296
|
}
|
|
297
297
|
return evmClient.signTypedData({
|
|
298
|
-
|
|
298
|
+
walletMetadata,
|
|
299
299
|
typedData: typedData,
|
|
300
300
|
password: password,
|
|
301
301
|
externalServerKeyShares
|
|
@@ -311,7 +311,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
311
311
|
});
|
|
312
312
|
}
|
|
313
313
|
const signedTx = await evmClient.signTransaction({
|
|
314
|
-
|
|
314
|
+
walletMetadata,
|
|
315
315
|
transaction,
|
|
316
316
|
password,
|
|
317
317
|
externalServerKeyShares
|
|
@@ -340,7 +340,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
340
340
|
}
|
|
341
341
|
const signature = await evmClient.signAuthorization({
|
|
342
342
|
authorization,
|
|
343
|
-
|
|
343
|
+
walletMetadata,
|
|
344
344
|
password,
|
|
345
345
|
externalServerKeyShares
|
|
346
346
|
});
|
|
@@ -360,7 +360,6 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
360
360
|
};
|
|
361
361
|
|
|
362
362
|
const logError = node.createLogError('node-evm');
|
|
363
|
-
const keySharesRequiredFor = (action)=>`External server key shares are required to ${action}. No backup shares available for recovery.`;
|
|
364
363
|
class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
365
364
|
get jwtAuthToken() {
|
|
366
365
|
return this.baseJWTAuthToken;
|
|
@@ -375,10 +374,10 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
375
374
|
transport: viem.http(rpcUrl)
|
|
376
375
|
});
|
|
377
376
|
}
|
|
378
|
-
async getWalletClient({
|
|
377
|
+
async getWalletClient({ walletMetadata, password, externalServerKeyShares, chain, chainId, rpcUrl }) {
|
|
379
378
|
const account = createAccountAdapter({
|
|
380
379
|
evmClient: this,
|
|
381
|
-
|
|
380
|
+
walletMetadata,
|
|
382
381
|
password,
|
|
383
382
|
externalServerKeyShares
|
|
384
383
|
});
|
|
@@ -419,10 +418,11 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
419
418
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
420
419
|
* @param password - The password to use for the wallet.
|
|
421
420
|
* @param onError - The function to call if an error occurs.
|
|
422
|
-
* @param
|
|
421
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
423
422
|
* @returns The account address, public key, raw public key, external server key shares, and wallet id.
|
|
424
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password
|
|
423
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
425
424
|
try {
|
|
425
|
+
let resolvedWalletId;
|
|
426
426
|
let ceremonyCeremonyCompleteResolver;
|
|
427
427
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
428
428
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -432,54 +432,48 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
432
432
|
chainName: this.chainName,
|
|
433
433
|
thresholdSignatureScheme,
|
|
434
434
|
skipLock: true,
|
|
435
|
+
password,
|
|
436
|
+
backUpToDynamic,
|
|
435
437
|
onError,
|
|
436
|
-
onCeremonyComplete: (
|
|
437
|
-
|
|
438
|
-
const checksumAddress = viem.getAddress(accountAddress);
|
|
439
|
-
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
440
|
-
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
441
|
-
accountAddress: checksumAddress,
|
|
442
|
-
walletId,
|
|
443
|
-
chainName: this.chainName,
|
|
444
|
-
thresholdSignatureScheme,
|
|
445
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
446
|
-
index,
|
|
447
|
-
value
|
|
448
|
-
]))),
|
|
449
|
-
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
450
|
-
});
|
|
451
|
-
this.logger.debug('walletMap updated for wallet', {
|
|
452
|
-
context: {
|
|
453
|
-
accountAddress,
|
|
454
|
-
walletId,
|
|
455
|
-
walletMap: this.walletMap
|
|
456
|
-
}
|
|
457
|
-
});
|
|
438
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
439
|
+
resolvedWalletId = walletId;
|
|
458
440
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
459
441
|
}
|
|
460
442
|
});
|
|
461
443
|
// Wait for the ceremony to complete before proceeding
|
|
462
444
|
await ceremonyCompletePromise;
|
|
463
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
445
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
464
446
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
465
447
|
}
|
|
466
448
|
// Get EVM address from public key
|
|
467
449
|
const { accountAddress, publicKeyHex } = deriveAccountAddress({
|
|
468
450
|
rawPublicKey: rawPublicKey
|
|
469
451
|
});
|
|
470
|
-
const
|
|
452
|
+
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
453
|
+
const walletMetadata = {
|
|
454
|
+
walletId: resolvedWalletId,
|
|
455
|
+
accountAddress,
|
|
456
|
+
chainName: this.chainName,
|
|
457
|
+
thresholdSignatureScheme,
|
|
458
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
459
|
+
index,
|
|
460
|
+
value
|
|
461
|
+
])))
|
|
462
|
+
};
|
|
463
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
471
464
|
accountAddress,
|
|
472
465
|
externalServerKeyShares,
|
|
473
466
|
password,
|
|
474
|
-
|
|
467
|
+
backUpToDynamic,
|
|
468
|
+
walletMetadata
|
|
475
469
|
});
|
|
470
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
476
471
|
return {
|
|
477
|
-
|
|
478
|
-
accountAddress,
|
|
472
|
+
walletMetadata,
|
|
479
473
|
rawPublicKey,
|
|
480
474
|
publicKeyHex,
|
|
481
475
|
externalServerKeyShares,
|
|
482
|
-
externalKeySharesWithBackupStatus
|
|
476
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
483
477
|
};
|
|
484
478
|
} catch (error) {
|
|
485
479
|
logError({
|
|
@@ -490,24 +484,16 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
490
484
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
491
485
|
}
|
|
492
486
|
}
|
|
493
|
-
async signMessage({ message,
|
|
487
|
+
async signMessage({ message, walletMetadata, password = undefined, externalServerKeyShares, context, onError }) {
|
|
488
|
+
const { accountAddress } = walletMetadata;
|
|
494
489
|
try {
|
|
495
490
|
if (!accountAddress) {
|
|
496
491
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
497
492
|
}
|
|
498
|
-
// Format the message for EVM signing
|
|
499
493
|
const formattedMessage = formatEVMMessage(message);
|
|
500
494
|
const resolvedContext = context != null ? context : {
|
|
501
495
|
evmMessage: message
|
|
502
496
|
};
|
|
503
|
-
// Attempt to recover key shares from backup if not provided
|
|
504
|
-
await this.ensureKeySharesRecovered({
|
|
505
|
-
accountAddress,
|
|
506
|
-
password,
|
|
507
|
-
walletOperation: node.WalletOperation.SIGN_MESSAGE,
|
|
508
|
-
externalServerKeyShares,
|
|
509
|
-
errorMessage: keySharesRequiredFor('sign a message')
|
|
510
|
-
});
|
|
511
497
|
const signatureEcdsa = await this.sign({
|
|
512
498
|
message: formattedMessage,
|
|
513
499
|
accountAddress: accountAddress,
|
|
@@ -515,11 +501,10 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
515
501
|
password,
|
|
516
502
|
externalServerKeyShares,
|
|
517
503
|
context: resolvedContext,
|
|
518
|
-
onError
|
|
504
|
+
onError,
|
|
505
|
+
walletMetadata
|
|
519
506
|
});
|
|
520
|
-
|
|
521
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
522
|
-
return serializedSignature;
|
|
507
|
+
return serializeECDSASignature(signatureEcdsa);
|
|
523
508
|
} catch (error) {
|
|
524
509
|
logError({
|
|
525
510
|
message: ERROR_SIGN_MESSAGE,
|
|
@@ -528,20 +513,16 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
528
513
|
accountAddress
|
|
529
514
|
}
|
|
530
515
|
});
|
|
531
|
-
throw new Error(ERROR_SIGN_MESSAGE
|
|
516
|
+
throw new Error(ERROR_SIGN_MESSAGE, {
|
|
517
|
+
cause: error
|
|
518
|
+
});
|
|
532
519
|
}
|
|
533
520
|
}
|
|
534
521
|
isSignAuthorizationSupported() {
|
|
535
522
|
return true;
|
|
536
523
|
}
|
|
537
|
-
async signPrehashedMessage({ prehashed,
|
|
538
|
-
|
|
539
|
-
accountAddress,
|
|
540
|
-
password,
|
|
541
|
-
walletOperation: node.WalletOperation.SIGN_MESSAGE,
|
|
542
|
-
externalServerKeyShares,
|
|
543
|
-
errorMessage: recoverErrorMessage
|
|
544
|
-
});
|
|
524
|
+
async signPrehashedMessage({ prehashed, walletMetadata, password, externalServerKeyShares, context, onError }) {
|
|
525
|
+
const { accountAddress } = walletMetadata;
|
|
545
526
|
const signatureEcdsa = await this.sign({
|
|
546
527
|
message: prehashed,
|
|
547
528
|
accountAddress: accountAddress,
|
|
@@ -550,11 +531,13 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
550
531
|
externalServerKeyShares,
|
|
551
532
|
isFormatted: true,
|
|
552
533
|
context,
|
|
553
|
-
onError
|
|
534
|
+
onError,
|
|
535
|
+
walletMetadata
|
|
554
536
|
});
|
|
555
537
|
return serializeECDSASignature(signatureEcdsa);
|
|
556
538
|
}
|
|
557
|
-
async signAuthorization({ authorization,
|
|
539
|
+
async signAuthorization({ authorization, walletMetadata, password = undefined, externalServerKeyShares, onError }) {
|
|
540
|
+
const { accountAddress } = walletMetadata;
|
|
558
541
|
try {
|
|
559
542
|
if (!accountAddress) {
|
|
560
543
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
@@ -563,14 +546,13 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
563
546
|
const prehashed = digest.startsWith('0x') ? digest.slice(2) : digest;
|
|
564
547
|
const serializedSignature = await this.signPrehashedMessage({
|
|
565
548
|
prehashed,
|
|
566
|
-
|
|
549
|
+
walletMetadata,
|
|
567
550
|
password,
|
|
568
551
|
externalServerKeyShares,
|
|
569
552
|
context: {
|
|
570
553
|
eip7702Auth: authorization
|
|
571
554
|
},
|
|
572
|
-
onError
|
|
573
|
-
recoverErrorMessage: keySharesRequiredFor('sign authorization')
|
|
555
|
+
onError
|
|
574
556
|
});
|
|
575
557
|
return viem.parseSignature(serializedSignature);
|
|
576
558
|
} catch (error) {
|
|
@@ -581,22 +563,24 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
581
563
|
accountAddress
|
|
582
564
|
}
|
|
583
565
|
});
|
|
584
|
-
throw new Error(ERROR_SIGN_MESSAGE
|
|
566
|
+
throw new Error(ERROR_SIGN_MESSAGE, {
|
|
567
|
+
cause: error
|
|
568
|
+
});
|
|
585
569
|
}
|
|
586
570
|
}
|
|
587
|
-
async signRawMessage({ message,
|
|
571
|
+
async signRawMessage({ message, walletMetadata, password = undefined, externalServerKeyShares, context, onError }) {
|
|
572
|
+
const { accountAddress } = walletMetadata;
|
|
588
573
|
try {
|
|
589
574
|
if (!accountAddress) {
|
|
590
575
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
591
576
|
}
|
|
592
577
|
return await this.signPrehashedMessage({
|
|
593
578
|
prehashed: node.stripHexPrefix(message),
|
|
594
|
-
|
|
579
|
+
walletMetadata,
|
|
595
580
|
password,
|
|
596
581
|
externalServerKeyShares,
|
|
597
582
|
context,
|
|
598
|
-
onError
|
|
599
|
-
recoverErrorMessage: keySharesRequiredFor('sign a raw message')
|
|
583
|
+
onError
|
|
600
584
|
});
|
|
601
585
|
} catch (error) {
|
|
602
586
|
logError({
|
|
@@ -606,24 +590,26 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
606
590
|
accountAddress
|
|
607
591
|
}
|
|
608
592
|
});
|
|
609
|
-
throw new Error(ERROR_SIGN_RAW_MESSAGE
|
|
593
|
+
throw new Error(ERROR_SIGN_RAW_MESSAGE, {
|
|
594
|
+
cause: error
|
|
595
|
+
});
|
|
610
596
|
}
|
|
611
597
|
}
|
|
612
|
-
async signTypedData({
|
|
598
|
+
async signTypedData({ walletMetadata, typedData, password = undefined, externalServerKeyShares, onError }) {
|
|
599
|
+
const { accountAddress } = walletMetadata;
|
|
613
600
|
try {
|
|
614
601
|
if (!accountAddress) {
|
|
615
602
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
616
603
|
}
|
|
617
604
|
return await this.signPrehashedMessage({
|
|
618
605
|
prehashed: formatTypedData(typedData),
|
|
619
|
-
|
|
606
|
+
walletMetadata,
|
|
620
607
|
password,
|
|
621
608
|
externalServerKeyShares,
|
|
622
609
|
context: {
|
|
623
610
|
evmTypedData: typedData
|
|
624
611
|
},
|
|
625
|
-
onError
|
|
626
|
-
recoverErrorMessage: keySharesRequiredFor('sign typed data')
|
|
612
|
+
onError
|
|
627
613
|
});
|
|
628
614
|
} catch (error) {
|
|
629
615
|
logError({
|
|
@@ -633,7 +619,9 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
633
619
|
accountAddress
|
|
634
620
|
}
|
|
635
621
|
});
|
|
636
|
-
throw new Error(ERROR_SIGN_TYPED_DATA
|
|
622
|
+
throw new Error(ERROR_SIGN_TYPED_DATA, {
|
|
623
|
+
cause: error
|
|
624
|
+
});
|
|
637
625
|
}
|
|
638
626
|
}
|
|
639
627
|
async verifyMessageSignature({ accountAddress, message, signature }) {
|
|
@@ -659,31 +647,22 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
659
647
|
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
660
648
|
}
|
|
661
649
|
}
|
|
662
|
-
async signTransaction({
|
|
663
|
-
|
|
664
|
-
accountAddress: senderAddress,
|
|
665
|
-
password
|
|
666
|
-
});
|
|
667
|
-
// Attempt to recover key shares from backup if not provided
|
|
668
|
-
await this.ensureKeySharesRecovered({
|
|
669
|
-
accountAddress: senderAddress,
|
|
670
|
-
password,
|
|
671
|
-
walletOperation: node.WalletOperation.SIGN_TRANSACTION,
|
|
672
|
-
externalServerKeyShares,
|
|
673
|
-
errorMessage: keySharesRequiredFor('sign transaction')
|
|
674
|
-
});
|
|
650
|
+
async signTransaction({ walletMetadata, transaction, password = undefined, externalServerKeyShares }) {
|
|
651
|
+
const { accountAddress } = walletMetadata;
|
|
675
652
|
const serializedTx = viem.serializeTransaction(transaction);
|
|
676
653
|
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
677
654
|
if (!(serializedTxBytes instanceof Uint8Array)) {
|
|
678
|
-
throw new
|
|
655
|
+
throw new TypeError('Invalid serializedTxBytes');
|
|
679
656
|
}
|
|
680
657
|
// Get signature using MPC (this will coordinate with server party)
|
|
681
658
|
const signatureEcdsa = await this.sign({
|
|
682
659
|
message: serializedTxBytes,
|
|
683
|
-
accountAddress
|
|
660
|
+
accountAddress,
|
|
684
661
|
chainName: this.chainName,
|
|
685
662
|
password,
|
|
686
|
-
externalServerKeyShares
|
|
663
|
+
externalServerKeyShares,
|
|
664
|
+
walletMetadata,
|
|
665
|
+
walletOperation: node.WalletOperation.SIGN_TRANSACTION
|
|
687
666
|
});
|
|
688
667
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
689
668
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -703,30 +682,20 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
703
682
|
message: 'Error signing transaction:',
|
|
704
683
|
error: error,
|
|
705
684
|
context: {
|
|
706
|
-
|
|
685
|
+
accountAddress
|
|
707
686
|
}
|
|
708
687
|
});
|
|
709
688
|
throw error;
|
|
710
689
|
}
|
|
711
690
|
}
|
|
712
|
-
async exportPrivateKey({
|
|
713
|
-
|
|
714
|
-
accountAddress,
|
|
715
|
-
password
|
|
716
|
-
});
|
|
717
|
-
// Attempt to recover key shares from backup if not provided
|
|
718
|
-
await this.ensureKeySharesRecovered({
|
|
719
|
-
accountAddress,
|
|
720
|
-
password,
|
|
721
|
-
walletOperation: node.WalletOperation.EXPORT_PRIVATE_KEY,
|
|
722
|
-
externalServerKeyShares,
|
|
723
|
-
errorMessage: keySharesRequiredFor('export private key')
|
|
724
|
-
});
|
|
691
|
+
async exportPrivateKey({ walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
692
|
+
const { accountAddress } = walletMetadata;
|
|
725
693
|
const { derivedPrivateKey } = await this.exportKey({
|
|
726
694
|
accountAddress,
|
|
727
695
|
chainName: this.chainName,
|
|
728
696
|
password,
|
|
729
|
-
externalServerKeyShares
|
|
697
|
+
externalServerKeyShares,
|
|
698
|
+
walletMetadata
|
|
730
699
|
});
|
|
731
700
|
return {
|
|
732
701
|
derivedPrivateKey
|
|
@@ -749,9 +718,10 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
749
718
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
750
719
|
* @param password - The password to use for the wallet.
|
|
751
720
|
* @param onError - The function to call if an error occurs.
|
|
752
|
-
* @param
|
|
721
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
753
722
|
* @returns The account address, public key, raw public key, external server key shares.
|
|
754
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password
|
|
723
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, backUpToDynamic = false, onError }) {
|
|
724
|
+
let resolvedWalletId;
|
|
755
725
|
let ceremonyCeremonyCompleteResolver;
|
|
756
726
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
757
727
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -761,21 +731,10 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
761
731
|
chainName,
|
|
762
732
|
privateKey,
|
|
763
733
|
thresholdSignatureScheme,
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
769
|
-
accountAddress: checksumAddress,
|
|
770
|
-
walletId,
|
|
771
|
-
chainName: this.chainName,
|
|
772
|
-
thresholdSignatureScheme,
|
|
773
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
774
|
-
index,
|
|
775
|
-
value
|
|
776
|
-
]))),
|
|
777
|
-
externalServerKeySharesBackupInfo: node.getExternalServerKeyShareBackupInfo()
|
|
778
|
-
});
|
|
734
|
+
password,
|
|
735
|
+
backUpToDynamic,
|
|
736
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
737
|
+
resolvedWalletId = walletId;
|
|
779
738
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
780
739
|
},
|
|
781
740
|
onError: (e)=>{
|
|
@@ -787,26 +746,38 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
|
|
|
787
746
|
onError == null ? void 0 : onError(e);
|
|
788
747
|
}
|
|
789
748
|
});
|
|
790
|
-
// Wait for the ceremony to complete before proceeding
|
|
791
749
|
await ceremonyCompletePromise;
|
|
792
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
750
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
793
751
|
throw new Error('Error creating wallet account');
|
|
794
752
|
}
|
|
795
753
|
const { accountAddress, publicKeyHex } = deriveAccountAddress({
|
|
796
754
|
rawPublicKey: rawPublicKey
|
|
797
755
|
});
|
|
798
|
-
const
|
|
756
|
+
const chainConfig = node.getMPCChainConfig(this.chainName);
|
|
757
|
+
const walletMetadata = {
|
|
758
|
+
walletId: resolvedWalletId,
|
|
759
|
+
accountAddress,
|
|
760
|
+
chainName: this.chainName,
|
|
761
|
+
thresholdSignatureScheme,
|
|
762
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
763
|
+
index,
|
|
764
|
+
value
|
|
765
|
+
])))
|
|
766
|
+
};
|
|
767
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
799
768
|
accountAddress,
|
|
800
769
|
externalServerKeyShares,
|
|
801
770
|
password,
|
|
802
|
-
|
|
771
|
+
backUpToDynamic,
|
|
772
|
+
walletMetadata
|
|
803
773
|
});
|
|
774
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
804
775
|
return {
|
|
805
|
-
|
|
776
|
+
walletMetadata,
|
|
806
777
|
rawPublicKey,
|
|
807
778
|
publicKeyHex,
|
|
808
779
|
externalServerKeyShares,
|
|
809
|
-
externalKeySharesWithBackupStatus
|
|
780
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
810
781
|
};
|
|
811
782
|
}
|
|
812
783
|
async getEvmWallets() {
|
|
@@ -891,7 +862,7 @@ class DynamicEvmZeroDevClient {
|
|
|
891
862
|
async createKernelClientForAddress(options) {
|
|
892
863
|
const viemSigner = createAccountAdapter({
|
|
893
864
|
evmClient: this.evmClient,
|
|
894
|
-
|
|
865
|
+
walletMetadata: options.walletMetadata,
|
|
895
866
|
password: options.password,
|
|
896
867
|
externalServerKeyShares: options.externalServerKeyShares,
|
|
897
868
|
delegated: options.delegated
|
package/index.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { toAccount } from 'viem/accounts';
|
|
2
|
-
import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig,
|
|
2
|
+
import { MessageHash, createLogError, createDelegatedWalletClient, delegatedSignMessage as delegatedSignMessage$1, stripHexPrefix, revokeDelegation as revokeDelegation$1, DynamicWalletClient, getMPCChainConfig, WalletOperation } from '@dynamic-labs-wallet/node';
|
|
3
3
|
import { getAddress, stringToHex, bytesToHex, size, concat, hashTypedData, serializeSignature, parseSignature, serializeTransaction, createPublicClient, http, defineChain, createWalletClient } from 'viem';
|
|
4
4
|
import { hashAuthorization } from 'viem/utils';
|
|
5
5
|
import { mainnet } from 'viem/chains';
|
|
@@ -263,9 +263,9 @@ const logError$1 = createLogError('node-evm');
|
|
|
263
263
|
return revokeDelegation$1(client, params);
|
|
264
264
|
};
|
|
265
265
|
|
|
266
|
-
const createAccountAdapter = ({ evmClient,
|
|
266
|
+
const createAccountAdapter = ({ evmClient, walletMetadata, password, externalServerKeyShares, delegated })=>{
|
|
267
267
|
return toAccount({
|
|
268
|
-
address: accountAddress,
|
|
268
|
+
address: walletMetadata.accountAddress,
|
|
269
269
|
signMessage: async ({ message })=>{
|
|
270
270
|
if (delegated) {
|
|
271
271
|
return delegatedSignMessage(delegated.delegatedClient, {
|
|
@@ -277,7 +277,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
277
277
|
}
|
|
278
278
|
const signature = await evmClient.signMessage({
|
|
279
279
|
message: message,
|
|
280
|
-
|
|
280
|
+
walletMetadata,
|
|
281
281
|
password,
|
|
282
282
|
externalServerKeyShares
|
|
283
283
|
});
|
|
@@ -293,7 +293,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
293
293
|
});
|
|
294
294
|
}
|
|
295
295
|
return evmClient.signTypedData({
|
|
296
|
-
|
|
296
|
+
walletMetadata,
|
|
297
297
|
typedData: typedData,
|
|
298
298
|
password: password,
|
|
299
299
|
externalServerKeyShares
|
|
@@ -309,7 +309,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
309
309
|
});
|
|
310
310
|
}
|
|
311
311
|
const signedTx = await evmClient.signTransaction({
|
|
312
|
-
|
|
312
|
+
walletMetadata,
|
|
313
313
|
transaction,
|
|
314
314
|
password,
|
|
315
315
|
externalServerKeyShares
|
|
@@ -338,7 +338,7 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
338
338
|
}
|
|
339
339
|
const signature = await evmClient.signAuthorization({
|
|
340
340
|
authorization,
|
|
341
|
-
|
|
341
|
+
walletMetadata,
|
|
342
342
|
password,
|
|
343
343
|
externalServerKeyShares
|
|
344
344
|
});
|
|
@@ -358,7 +358,6 @@ const createAccountAdapter = ({ evmClient, accountAddress, password, externalSer
|
|
|
358
358
|
};
|
|
359
359
|
|
|
360
360
|
const logError = createLogError('node-evm');
|
|
361
|
-
const keySharesRequiredFor = (action)=>`External server key shares are required to ${action}. No backup shares available for recovery.`;
|
|
362
361
|
class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
363
362
|
get jwtAuthToken() {
|
|
364
363
|
return this.baseJWTAuthToken;
|
|
@@ -373,10 +372,10 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
373
372
|
transport: http(rpcUrl)
|
|
374
373
|
});
|
|
375
374
|
}
|
|
376
|
-
async getWalletClient({
|
|
375
|
+
async getWalletClient({ walletMetadata, password, externalServerKeyShares, chain, chainId, rpcUrl }) {
|
|
377
376
|
const account = createAccountAdapter({
|
|
378
377
|
evmClient: this,
|
|
379
|
-
|
|
378
|
+
walletMetadata,
|
|
380
379
|
password,
|
|
381
380
|
externalServerKeyShares
|
|
382
381
|
});
|
|
@@ -417,10 +416,11 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
417
416
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
418
417
|
* @param password - The password to use for the wallet.
|
|
419
418
|
* @param onError - The function to call if an error occurs.
|
|
420
|
-
* @param
|
|
419
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
421
420
|
* @returns The account address, public key, raw public key, external server key shares, and wallet id.
|
|
422
|
-
*/ async createWalletAccount({ thresholdSignatureScheme, password
|
|
421
|
+
*/ async createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic = false }) {
|
|
423
422
|
try {
|
|
423
|
+
let resolvedWalletId;
|
|
424
424
|
let ceremonyCeremonyCompleteResolver;
|
|
425
425
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
426
426
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -430,54 +430,48 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
430
430
|
chainName: this.chainName,
|
|
431
431
|
thresholdSignatureScheme,
|
|
432
432
|
skipLock: true,
|
|
433
|
+
password,
|
|
434
|
+
backUpToDynamic,
|
|
433
435
|
onError,
|
|
434
|
-
onCeremonyComplete: (
|
|
435
|
-
|
|
436
|
-
const checksumAddress = getAddress(accountAddress);
|
|
437
|
-
const chainConfig = getMPCChainConfig(this.chainName);
|
|
438
|
-
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
439
|
-
accountAddress: checksumAddress,
|
|
440
|
-
walletId,
|
|
441
|
-
chainName: this.chainName,
|
|
442
|
-
thresholdSignatureScheme,
|
|
443
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
444
|
-
index,
|
|
445
|
-
value
|
|
446
|
-
]))),
|
|
447
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
448
|
-
});
|
|
449
|
-
this.logger.debug('walletMap updated for wallet', {
|
|
450
|
-
context: {
|
|
451
|
-
accountAddress,
|
|
452
|
-
walletId,
|
|
453
|
-
walletMap: this.walletMap
|
|
454
|
-
}
|
|
455
|
-
});
|
|
436
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
437
|
+
resolvedWalletId = walletId;
|
|
456
438
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
457
439
|
}
|
|
458
440
|
});
|
|
459
441
|
// Wait for the ceremony to complete before proceeding
|
|
460
442
|
await ceremonyCompletePromise;
|
|
461
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
443
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
462
444
|
throw new Error(ERROR_KEYGEN_FAILED);
|
|
463
445
|
}
|
|
464
446
|
// Get EVM address from public key
|
|
465
447
|
const { accountAddress, publicKeyHex } = deriveAccountAddress({
|
|
466
448
|
rawPublicKey: rawPublicKey
|
|
467
449
|
});
|
|
468
|
-
const
|
|
450
|
+
const chainConfig = getMPCChainConfig(this.chainName);
|
|
451
|
+
const walletMetadata = {
|
|
452
|
+
walletId: resolvedWalletId,
|
|
453
|
+
accountAddress,
|
|
454
|
+
chainName: this.chainName,
|
|
455
|
+
thresholdSignatureScheme,
|
|
456
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
457
|
+
index,
|
|
458
|
+
value
|
|
459
|
+
])))
|
|
460
|
+
};
|
|
461
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
469
462
|
accountAddress,
|
|
470
463
|
externalServerKeyShares,
|
|
471
464
|
password,
|
|
472
|
-
|
|
465
|
+
backUpToDynamic,
|
|
466
|
+
walletMetadata
|
|
473
467
|
});
|
|
468
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
474
469
|
return {
|
|
475
|
-
|
|
476
|
-
accountAddress,
|
|
470
|
+
walletMetadata,
|
|
477
471
|
rawPublicKey,
|
|
478
472
|
publicKeyHex,
|
|
479
473
|
externalServerKeyShares,
|
|
480
|
-
externalKeySharesWithBackupStatus
|
|
474
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
481
475
|
};
|
|
482
476
|
} catch (error) {
|
|
483
477
|
logError({
|
|
@@ -488,24 +482,16 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
488
482
|
throw new Error(ERROR_CREATE_WALLET_ACCOUNT);
|
|
489
483
|
}
|
|
490
484
|
}
|
|
491
|
-
async signMessage({ message,
|
|
485
|
+
async signMessage({ message, walletMetadata, password = undefined, externalServerKeyShares, context, onError }) {
|
|
486
|
+
const { accountAddress } = walletMetadata;
|
|
492
487
|
try {
|
|
493
488
|
if (!accountAddress) {
|
|
494
489
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
495
490
|
}
|
|
496
|
-
// Format the message for EVM signing
|
|
497
491
|
const formattedMessage = formatEVMMessage(message);
|
|
498
492
|
const resolvedContext = context != null ? context : {
|
|
499
493
|
evmMessage: message
|
|
500
494
|
};
|
|
501
|
-
// Attempt to recover key shares from backup if not provided
|
|
502
|
-
await this.ensureKeySharesRecovered({
|
|
503
|
-
accountAddress,
|
|
504
|
-
password,
|
|
505
|
-
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
506
|
-
externalServerKeyShares,
|
|
507
|
-
errorMessage: keySharesRequiredFor('sign a message')
|
|
508
|
-
});
|
|
509
495
|
const signatureEcdsa = await this.sign({
|
|
510
496
|
message: formattedMessage,
|
|
511
497
|
accountAddress: accountAddress,
|
|
@@ -513,11 +499,10 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
513
499
|
password,
|
|
514
500
|
externalServerKeyShares,
|
|
515
501
|
context: resolvedContext,
|
|
516
|
-
onError
|
|
502
|
+
onError,
|
|
503
|
+
walletMetadata
|
|
517
504
|
});
|
|
518
|
-
|
|
519
|
-
const serializedSignature = serializeECDSASignature(signatureEcdsa);
|
|
520
|
-
return serializedSignature;
|
|
505
|
+
return serializeECDSASignature(signatureEcdsa);
|
|
521
506
|
} catch (error) {
|
|
522
507
|
logError({
|
|
523
508
|
message: ERROR_SIGN_MESSAGE,
|
|
@@ -526,20 +511,16 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
526
511
|
accountAddress
|
|
527
512
|
}
|
|
528
513
|
});
|
|
529
|
-
throw new Error(ERROR_SIGN_MESSAGE
|
|
514
|
+
throw new Error(ERROR_SIGN_MESSAGE, {
|
|
515
|
+
cause: error
|
|
516
|
+
});
|
|
530
517
|
}
|
|
531
518
|
}
|
|
532
519
|
isSignAuthorizationSupported() {
|
|
533
520
|
return true;
|
|
534
521
|
}
|
|
535
|
-
async signPrehashedMessage({ prehashed,
|
|
536
|
-
|
|
537
|
-
accountAddress,
|
|
538
|
-
password,
|
|
539
|
-
walletOperation: WalletOperation.SIGN_MESSAGE,
|
|
540
|
-
externalServerKeyShares,
|
|
541
|
-
errorMessage: recoverErrorMessage
|
|
542
|
-
});
|
|
522
|
+
async signPrehashedMessage({ prehashed, walletMetadata, password, externalServerKeyShares, context, onError }) {
|
|
523
|
+
const { accountAddress } = walletMetadata;
|
|
543
524
|
const signatureEcdsa = await this.sign({
|
|
544
525
|
message: prehashed,
|
|
545
526
|
accountAddress: accountAddress,
|
|
@@ -548,11 +529,13 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
548
529
|
externalServerKeyShares,
|
|
549
530
|
isFormatted: true,
|
|
550
531
|
context,
|
|
551
|
-
onError
|
|
532
|
+
onError,
|
|
533
|
+
walletMetadata
|
|
552
534
|
});
|
|
553
535
|
return serializeECDSASignature(signatureEcdsa);
|
|
554
536
|
}
|
|
555
|
-
async signAuthorization({ authorization,
|
|
537
|
+
async signAuthorization({ authorization, walletMetadata, password = undefined, externalServerKeyShares, onError }) {
|
|
538
|
+
const { accountAddress } = walletMetadata;
|
|
556
539
|
try {
|
|
557
540
|
if (!accountAddress) {
|
|
558
541
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
@@ -561,14 +544,13 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
561
544
|
const prehashed = digest.startsWith('0x') ? digest.slice(2) : digest;
|
|
562
545
|
const serializedSignature = await this.signPrehashedMessage({
|
|
563
546
|
prehashed,
|
|
564
|
-
|
|
547
|
+
walletMetadata,
|
|
565
548
|
password,
|
|
566
549
|
externalServerKeyShares,
|
|
567
550
|
context: {
|
|
568
551
|
eip7702Auth: authorization
|
|
569
552
|
},
|
|
570
|
-
onError
|
|
571
|
-
recoverErrorMessage: keySharesRequiredFor('sign authorization')
|
|
553
|
+
onError
|
|
572
554
|
});
|
|
573
555
|
return parseSignature(serializedSignature);
|
|
574
556
|
} catch (error) {
|
|
@@ -579,22 +561,24 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
579
561
|
accountAddress
|
|
580
562
|
}
|
|
581
563
|
});
|
|
582
|
-
throw new Error(ERROR_SIGN_MESSAGE
|
|
564
|
+
throw new Error(ERROR_SIGN_MESSAGE, {
|
|
565
|
+
cause: error
|
|
566
|
+
});
|
|
583
567
|
}
|
|
584
568
|
}
|
|
585
|
-
async signRawMessage({ message,
|
|
569
|
+
async signRawMessage({ message, walletMetadata, password = undefined, externalServerKeyShares, context, onError }) {
|
|
570
|
+
const { accountAddress } = walletMetadata;
|
|
586
571
|
try {
|
|
587
572
|
if (!accountAddress) {
|
|
588
573
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
589
574
|
}
|
|
590
575
|
return await this.signPrehashedMessage({
|
|
591
576
|
prehashed: stripHexPrefix(message),
|
|
592
|
-
|
|
577
|
+
walletMetadata,
|
|
593
578
|
password,
|
|
594
579
|
externalServerKeyShares,
|
|
595
580
|
context,
|
|
596
|
-
onError
|
|
597
|
-
recoverErrorMessage: keySharesRequiredFor('sign a raw message')
|
|
581
|
+
onError
|
|
598
582
|
});
|
|
599
583
|
} catch (error) {
|
|
600
584
|
logError({
|
|
@@ -604,24 +588,26 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
604
588
|
accountAddress
|
|
605
589
|
}
|
|
606
590
|
});
|
|
607
|
-
throw new Error(ERROR_SIGN_RAW_MESSAGE
|
|
591
|
+
throw new Error(ERROR_SIGN_RAW_MESSAGE, {
|
|
592
|
+
cause: error
|
|
593
|
+
});
|
|
608
594
|
}
|
|
609
595
|
}
|
|
610
|
-
async signTypedData({
|
|
596
|
+
async signTypedData({ walletMetadata, typedData, password = undefined, externalServerKeyShares, onError }) {
|
|
597
|
+
const { accountAddress } = walletMetadata;
|
|
611
598
|
try {
|
|
612
599
|
if (!accountAddress) {
|
|
613
600
|
throw new Error(ERROR_ACCOUNT_ADDRESS_REQUIRED);
|
|
614
601
|
}
|
|
615
602
|
return await this.signPrehashedMessage({
|
|
616
603
|
prehashed: formatTypedData(typedData),
|
|
617
|
-
|
|
604
|
+
walletMetadata,
|
|
618
605
|
password,
|
|
619
606
|
externalServerKeyShares,
|
|
620
607
|
context: {
|
|
621
608
|
evmTypedData: typedData
|
|
622
609
|
},
|
|
623
|
-
onError
|
|
624
|
-
recoverErrorMessage: keySharesRequiredFor('sign typed data')
|
|
610
|
+
onError
|
|
625
611
|
});
|
|
626
612
|
} catch (error) {
|
|
627
613
|
logError({
|
|
@@ -631,7 +617,9 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
631
617
|
accountAddress
|
|
632
618
|
}
|
|
633
619
|
});
|
|
634
|
-
throw new Error(ERROR_SIGN_TYPED_DATA
|
|
620
|
+
throw new Error(ERROR_SIGN_TYPED_DATA, {
|
|
621
|
+
cause: error
|
|
622
|
+
});
|
|
635
623
|
}
|
|
636
624
|
}
|
|
637
625
|
async verifyMessageSignature({ accountAddress, message, signature }) {
|
|
@@ -657,31 +645,22 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
657
645
|
throw new Error(ERROR_VERIFY_MESSAGE_SIGNATURE);
|
|
658
646
|
}
|
|
659
647
|
}
|
|
660
|
-
async signTransaction({
|
|
661
|
-
|
|
662
|
-
accountAddress: senderAddress,
|
|
663
|
-
password
|
|
664
|
-
});
|
|
665
|
-
// Attempt to recover key shares from backup if not provided
|
|
666
|
-
await this.ensureKeySharesRecovered({
|
|
667
|
-
accountAddress: senderAddress,
|
|
668
|
-
password,
|
|
669
|
-
walletOperation: WalletOperation.SIGN_TRANSACTION,
|
|
670
|
-
externalServerKeyShares,
|
|
671
|
-
errorMessage: keySharesRequiredFor('sign transaction')
|
|
672
|
-
});
|
|
648
|
+
async signTransaction({ walletMetadata, transaction, password = undefined, externalServerKeyShares }) {
|
|
649
|
+
const { accountAddress } = walletMetadata;
|
|
673
650
|
const serializedTx = serializeTransaction(transaction);
|
|
674
651
|
const serializedTxBytes = Uint8Array.from(Buffer.from(serializedTx.slice(2), 'hex'));
|
|
675
652
|
if (!(serializedTxBytes instanceof Uint8Array)) {
|
|
676
|
-
throw new
|
|
653
|
+
throw new TypeError('Invalid serializedTxBytes');
|
|
677
654
|
}
|
|
678
655
|
// Get signature using MPC (this will coordinate with server party)
|
|
679
656
|
const signatureEcdsa = await this.sign({
|
|
680
657
|
message: serializedTxBytes,
|
|
681
|
-
accountAddress
|
|
658
|
+
accountAddress,
|
|
682
659
|
chainName: this.chainName,
|
|
683
660
|
password,
|
|
684
|
-
externalServerKeyShares
|
|
661
|
+
externalServerKeyShares,
|
|
662
|
+
walletMetadata,
|
|
663
|
+
walletOperation: WalletOperation.SIGN_TRANSACTION
|
|
685
664
|
});
|
|
686
665
|
if (!('r' in signatureEcdsa && 's' in signatureEcdsa && 'v' in signatureEcdsa)) {
|
|
687
666
|
throw new Error('Invalid signature format returned from MPC signing');
|
|
@@ -701,30 +680,20 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
701
680
|
message: 'Error signing transaction:',
|
|
702
681
|
error: error,
|
|
703
682
|
context: {
|
|
704
|
-
|
|
683
|
+
accountAddress
|
|
705
684
|
}
|
|
706
685
|
});
|
|
707
686
|
throw error;
|
|
708
687
|
}
|
|
709
688
|
}
|
|
710
|
-
async exportPrivateKey({
|
|
711
|
-
|
|
712
|
-
accountAddress,
|
|
713
|
-
password
|
|
714
|
-
});
|
|
715
|
-
// Attempt to recover key shares from backup if not provided
|
|
716
|
-
await this.ensureKeySharesRecovered({
|
|
717
|
-
accountAddress,
|
|
718
|
-
password,
|
|
719
|
-
walletOperation: WalletOperation.EXPORT_PRIVATE_KEY,
|
|
720
|
-
externalServerKeyShares,
|
|
721
|
-
errorMessage: keySharesRequiredFor('export private key')
|
|
722
|
-
});
|
|
689
|
+
async exportPrivateKey({ walletMetadata, password = undefined, externalServerKeyShares }) {
|
|
690
|
+
const { accountAddress } = walletMetadata;
|
|
723
691
|
const { derivedPrivateKey } = await this.exportKey({
|
|
724
692
|
accountAddress,
|
|
725
693
|
chainName: this.chainName,
|
|
726
694
|
password,
|
|
727
|
-
externalServerKeyShares
|
|
695
|
+
externalServerKeyShares,
|
|
696
|
+
walletMetadata
|
|
728
697
|
});
|
|
729
698
|
return {
|
|
730
699
|
derivedPrivateKey
|
|
@@ -747,9 +716,10 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
747
716
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
748
717
|
* @param password - The password to use for the wallet.
|
|
749
718
|
* @param onError - The function to call if an error occurs.
|
|
750
|
-
* @param
|
|
719
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
751
720
|
* @returns The account address, public key, raw public key, external server key shares.
|
|
752
|
-
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password
|
|
721
|
+
*/ async importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, backUpToDynamic = false, onError }) {
|
|
722
|
+
let resolvedWalletId;
|
|
753
723
|
let ceremonyCeremonyCompleteResolver;
|
|
754
724
|
const ceremonyCompletePromise = new Promise((resolve)=>{
|
|
755
725
|
ceremonyCeremonyCompleteResolver = resolve;
|
|
@@ -759,21 +729,10 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
759
729
|
chainName,
|
|
760
730
|
privateKey,
|
|
761
731
|
thresholdSignatureScheme,
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
this.walletMap[checksumAddress] = _extends({}, this.walletMap[checksumAddress] || {}, {
|
|
767
|
-
accountAddress: checksumAddress,
|
|
768
|
-
walletId,
|
|
769
|
-
chainName: this.chainName,
|
|
770
|
-
thresholdSignatureScheme,
|
|
771
|
-
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
772
|
-
index,
|
|
773
|
-
value
|
|
774
|
-
]))),
|
|
775
|
-
externalServerKeySharesBackupInfo: getExternalServerKeyShareBackupInfo()
|
|
776
|
-
});
|
|
732
|
+
password,
|
|
733
|
+
backUpToDynamic,
|
|
734
|
+
onCeremonyComplete: (_accountAddress, walletId)=>{
|
|
735
|
+
resolvedWalletId = walletId;
|
|
777
736
|
ceremonyCeremonyCompleteResolver(undefined);
|
|
778
737
|
},
|
|
779
738
|
onError: (e)=>{
|
|
@@ -785,26 +744,38 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
785
744
|
onError == null ? void 0 : onError(e);
|
|
786
745
|
}
|
|
787
746
|
});
|
|
788
|
-
// Wait for the ceremony to complete before proceeding
|
|
789
747
|
await ceremonyCompletePromise;
|
|
790
|
-
if (!rawPublicKey || !externalServerKeyShares) {
|
|
748
|
+
if (!rawPublicKey || !externalServerKeyShares || !resolvedWalletId) {
|
|
791
749
|
throw new Error('Error creating wallet account');
|
|
792
750
|
}
|
|
793
751
|
const { accountAddress, publicKeyHex } = deriveAccountAddress({
|
|
794
752
|
rawPublicKey: rawPublicKey
|
|
795
753
|
});
|
|
796
|
-
const
|
|
754
|
+
const chainConfig = getMPCChainConfig(this.chainName);
|
|
755
|
+
const walletMetadata = {
|
|
756
|
+
walletId: resolvedWalletId,
|
|
757
|
+
accountAddress,
|
|
758
|
+
chainName: this.chainName,
|
|
759
|
+
thresholdSignatureScheme,
|
|
760
|
+
derivationPath: JSON.stringify(Object.fromEntries(chainConfig.derivationPath.map((value, index)=>[
|
|
761
|
+
index,
|
|
762
|
+
value
|
|
763
|
+
])))
|
|
764
|
+
};
|
|
765
|
+
const { keySharesWithBackupStatus, backupInfo } = await this.storeEncryptedBackupByWalletWithRetry({
|
|
797
766
|
accountAddress,
|
|
798
767
|
externalServerKeyShares,
|
|
799
768
|
password,
|
|
800
|
-
|
|
769
|
+
backUpToDynamic,
|
|
770
|
+
walletMetadata
|
|
801
771
|
});
|
|
772
|
+
walletMetadata.externalServerKeySharesBackupInfo = backupInfo;
|
|
802
773
|
return {
|
|
803
|
-
|
|
774
|
+
walletMetadata,
|
|
804
775
|
rawPublicKey,
|
|
805
776
|
publicKeyHex,
|
|
806
777
|
externalServerKeyShares,
|
|
807
|
-
externalKeySharesWithBackupStatus
|
|
778
|
+
externalKeySharesWithBackupStatus: keySharesWithBackupStatus
|
|
808
779
|
};
|
|
809
780
|
}
|
|
810
781
|
async getEvmWallets() {
|
|
@@ -889,7 +860,7 @@ class DynamicEvmZeroDevClient {
|
|
|
889
860
|
async createKernelClientForAddress(options) {
|
|
890
861
|
const viemSigner = createAccountAdapter({
|
|
891
862
|
evmClient: this.evmClient,
|
|
892
|
-
|
|
863
|
+
walletMetadata: options.walletMetadata,
|
|
893
864
|
password: options.password,
|
|
894
865
|
externalServerKeyShares: options.externalServerKeyShares,
|
|
895
866
|
delegated: options.delegated
|
package/package.json
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs-wallet/node-evm",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "1.0.0-beta",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@dynamic-labs-wallet/node": "0.0
|
|
7
|
+
"@dynamic-labs-wallet/node": "1.0.0-beta",
|
|
8
8
|
"@dynamic-labs/sdk-api-core": "^0.0.984",
|
|
9
9
|
"@dynamic-labs-sdk/client": "0.3.0",
|
|
10
10
|
"@dynamic-labs-sdk/zerodev": "0.3.0",
|
|
11
11
|
"@dynamic-labs-sdk/evm": "0.3.0",
|
|
12
12
|
"@zerodev/ecdsa-validator": "5.4.9",
|
|
13
|
-
"@zerodev/sdk": "5.4.36"
|
|
13
|
+
"@zerodev/sdk": "5.4.36",
|
|
14
|
+
"@dynamic-labs-wallet/core": "1.0.0-beta"
|
|
14
15
|
},
|
|
15
16
|
"publishConfig": {
|
|
16
17
|
"access": "public"
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import type { ServerKeyShare, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { Account } from 'viem';
|
|
3
3
|
import { type createDelegatedEvmWalletClient } from '../delegatedClient.js';
|
|
4
4
|
import type { EvmClientBase } from '../zerodev/types.js';
|
|
5
|
-
export declare const createAccountAdapter: ({ evmClient,
|
|
5
|
+
export declare const createAccountAdapter: ({ evmClient, walletMetadata, password, externalServerKeyShares, delegated, }: {
|
|
6
6
|
evmClient: EvmClientBase;
|
|
7
|
-
|
|
7
|
+
walletMetadata: WalletMetadata;
|
|
8
8
|
password?: string;
|
|
9
9
|
externalServerKeyShares?: ServerKeyShare[];
|
|
10
10
|
delegated?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accountAdapter.d.ts","sourceRoot":"","sources":["../../src/client/accountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"accountAdapter.d.ts","sourceRoot":"","sources":["../../src/client/accountAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,OAAO,EAAkB,MAAM,MAAM,CAAC;AAGpD,OAAO,EACL,KAAK,8BAA8B,EAKpC,MAAM,uBAAuB,CAAC;AAC/B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEzD,eAAO,MAAM,oBAAoB,iFAM9B;IACD,SAAS,EAAE,aAAa,CAAC;IACzB,cAAc,EAAE,cAAc,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,uBAAuB,CAAC,EAAE,cAAc,EAAE,CAAC;IAC3C,SAAS,CAAC,EAAE;QACV,eAAe,EAAE,UAAU,CAAC,OAAO,8BAA8B,CAAC,CAAC;QACnE,QAAQ,EAAE,MAAM,CAAC;QACjB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,cAAc,CAAC;KAC1B,CAAC;CACH,KAAG,OA6FH,CAAC"}
|
package/src/client/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import { DynamicWalletClient, type DynamicWalletClientProps, type EcdsaKeygenResult, type EcdsaPublicKey, type Ed25519KeygenResult, type ServerKeyShare, type ThresholdSignatureScheme, type WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { SignMessageContext } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import { type Account, type Chain, type PublicClient, type SignableMessage, type TransactionSerializable, type Transport, type TypedData, type WalletClient } from 'viem';
|
|
4
4
|
export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
@@ -10,8 +10,8 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
10
10
|
chain: Chain;
|
|
11
11
|
rpcUrl?: string;
|
|
12
12
|
}): PublicClient;
|
|
13
|
-
getWalletClient({
|
|
14
|
-
|
|
13
|
+
getWalletClient({ walletMetadata, password, externalServerKeyShares, chain, chainId, rpcUrl, }: {
|
|
14
|
+
walletMetadata: WalletMetadata;
|
|
15
15
|
password?: string;
|
|
16
16
|
externalServerKeyShares?: ServerKeyShare[];
|
|
17
17
|
chain?: Chain;
|
|
@@ -23,29 +23,27 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
23
23
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
24
24
|
* @param password - The password to use for the wallet.
|
|
25
25
|
* @param onError - The function to call if an error occurs.
|
|
26
|
-
* @param
|
|
26
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
27
27
|
* @returns The account address, public key, raw public key, external server key shares, and wallet id.
|
|
28
28
|
*/
|
|
29
|
-
createWalletAccount({ thresholdSignatureScheme, password, onError,
|
|
29
|
+
createWalletAccount({ thresholdSignatureScheme, password, onError, backUpToDynamic, }: {
|
|
30
30
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
31
31
|
password?: string;
|
|
32
32
|
onError?: (error: Error) => void;
|
|
33
|
-
|
|
33
|
+
backUpToDynamic?: boolean;
|
|
34
34
|
}): Promise<{
|
|
35
|
-
|
|
35
|
+
walletMetadata: WalletMetadata;
|
|
36
36
|
publicKeyHex: string;
|
|
37
37
|
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
38
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
39
38
|
externalServerKeyShares: ServerKeyShare[];
|
|
40
39
|
externalKeySharesWithBackupStatus: Array<{
|
|
41
40
|
share: ServerKeyShare;
|
|
42
41
|
backedUpToClientKeyShareService: boolean;
|
|
43
42
|
}>;
|
|
44
|
-
walletId: string;
|
|
45
43
|
}>;
|
|
46
|
-
signMessage({ message,
|
|
44
|
+
signMessage({ message, walletMetadata, password, externalServerKeyShares, context, onError, }: {
|
|
47
45
|
message: string;
|
|
48
|
-
|
|
46
|
+
walletMetadata: WalletMetadata;
|
|
49
47
|
password?: string;
|
|
50
48
|
externalServerKeyShares?: ServerKeyShare[];
|
|
51
49
|
context?: SignMessageContext;
|
|
@@ -53,9 +51,9 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
53
51
|
}): Promise<`0x${string}`>;
|
|
54
52
|
isSignAuthorizationSupported(): boolean;
|
|
55
53
|
private signPrehashedMessage;
|
|
56
|
-
signAuthorization({ authorization,
|
|
54
|
+
signAuthorization({ authorization, walletMetadata, password, externalServerKeyShares, onError, }: {
|
|
57
55
|
authorization: any;
|
|
58
|
-
|
|
56
|
+
walletMetadata: WalletMetadata;
|
|
59
57
|
password?: string;
|
|
60
58
|
externalServerKeyShares?: ServerKeyShare[];
|
|
61
59
|
onError?: (error: Error) => void;
|
|
@@ -70,16 +68,16 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
70
68
|
yParity: number;
|
|
71
69
|
v?: never;
|
|
72
70
|
}>;
|
|
73
|
-
signRawMessage({ message,
|
|
71
|
+
signRawMessage({ message, walletMetadata, password, externalServerKeyShares, context, onError, }: {
|
|
74
72
|
message: string;
|
|
75
|
-
|
|
73
|
+
walletMetadata: WalletMetadata;
|
|
76
74
|
password?: string;
|
|
77
75
|
externalServerKeyShares?: ServerKeyShare[];
|
|
78
76
|
context?: SignMessageContext;
|
|
79
77
|
onError?: (error: Error) => void;
|
|
80
78
|
}): Promise<string>;
|
|
81
|
-
signTypedData({
|
|
82
|
-
|
|
79
|
+
signTypedData({ walletMetadata, typedData, password, externalServerKeyShares, onError, }: {
|
|
80
|
+
walletMetadata: WalletMetadata;
|
|
83
81
|
typedData: TypedData;
|
|
84
82
|
password?: string;
|
|
85
83
|
externalServerKeyShares?: ServerKeyShare[];
|
|
@@ -90,14 +88,14 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
90
88
|
message: SignableMessage;
|
|
91
89
|
signature: any;
|
|
92
90
|
}): Promise<boolean>;
|
|
93
|
-
signTransaction({
|
|
94
|
-
|
|
91
|
+
signTransaction({ walletMetadata, transaction, password, externalServerKeyShares, }: {
|
|
92
|
+
walletMetadata: WalletMetadata;
|
|
95
93
|
transaction: TransactionSerializable;
|
|
96
94
|
password?: string;
|
|
97
95
|
externalServerKeyShares?: ServerKeyShare[];
|
|
98
96
|
}): Promise<string>;
|
|
99
|
-
exportPrivateKey({
|
|
100
|
-
|
|
97
|
+
exportPrivateKey({ walletMetadata, password, externalServerKeyShares, }: {
|
|
98
|
+
walletMetadata: WalletMetadata;
|
|
101
99
|
password?: string;
|
|
102
100
|
externalServerKeyShares?: ServerKeyShare[];
|
|
103
101
|
}): Promise<{
|
|
@@ -116,27 +114,34 @@ export declare class DynamicEvmWalletClient extends DynamicWalletClient {
|
|
|
116
114
|
* @param thresholdSignatureScheme - The threshold signature scheme to use for the wallet.
|
|
117
115
|
* @param password - The password to use for the wallet.
|
|
118
116
|
* @param onError - The function to call if an error occurs.
|
|
119
|
-
* @param
|
|
117
|
+
* @param backUpToDynamic - Whether to back up the external server key shares to the client share service. By default, it is false.
|
|
120
118
|
* @returns The account address, public key, raw public key, external server key shares.
|
|
121
119
|
*/
|
|
122
|
-
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password,
|
|
120
|
+
importPrivateKey({ privateKey, chainName, thresholdSignatureScheme, password, backUpToDynamic, onError, }: {
|
|
123
121
|
privateKey: string;
|
|
124
122
|
chainName: string;
|
|
125
123
|
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
126
124
|
password?: string;
|
|
127
|
-
|
|
125
|
+
backUpToDynamic?: boolean;
|
|
128
126
|
onError?: (error: Error) => void;
|
|
129
127
|
}): Promise<{
|
|
130
|
-
|
|
128
|
+
walletMetadata: WalletMetadata;
|
|
131
129
|
publicKeyHex: string;
|
|
132
130
|
rawPublicKey: EcdsaPublicKey | Uint8Array | string | undefined;
|
|
133
|
-
/** @deprecated Use externalKeySharesWithBackupStatus instead */
|
|
134
131
|
externalServerKeyShares: ServerKeyShare[];
|
|
135
132
|
externalKeySharesWithBackupStatus: Array<{
|
|
136
133
|
share: ServerKeyShare;
|
|
137
134
|
backedUpToClientKeyShareService: boolean;
|
|
138
135
|
}>;
|
|
139
136
|
}>;
|
|
140
|
-
getEvmWallets(): Promise<
|
|
137
|
+
getEvmWallets(): Promise<{
|
|
138
|
+
walletId: string;
|
|
139
|
+
chainName: string;
|
|
140
|
+
accountAddress: string;
|
|
141
|
+
externalServerKeySharesBackupInfo: import("build/core/index.esm.js").KeyShareBackupInfo;
|
|
142
|
+
externalServerKeyShares: never[];
|
|
143
|
+
derivationPath: string | undefined;
|
|
144
|
+
thresholdSignatureScheme: ThresholdSignatureScheme;
|
|
145
|
+
}[]>;
|
|
141
146
|
}
|
|
142
147
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,mBAAmB,EACnB,KAAK,wBAAwB,EAC7B,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAEnB,KAAK,mBAAmB,EAExB,KAAK,cAAc,EAEnB,KAAK,wBAAwB,EAC7B,KAAK,cAAc,EAEpB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AACrE,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAMV,KAAK,YAAY,EAEjB,KAAK,eAAe,EACpB,KAAK,uBAAuB,EAC5B,KAAK,SAAS,EACd,KAAK,SAAS,EACd,KAAK,YAAY,EAClB,MAAM,MAAM,CAAC;AAiBd,qBAAa,sBAAuB,SAAQ,mBAAmB;IAC7D,QAAQ,CAAC,SAAS,SAAS;gBAEf,EACV,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,KAAK,EACL,oBAAoB,EACpB,MAAM,GACP,EAAE,wBAAwB;IAW3B,IAAI,YAAY,IAAI,MAAM,GAAG,SAAS,CAErC;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,sBAAsB,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;QAAE,KAAK,EAAE,KAAK,CAAC;QAAC,MAAM,CAAC,EAAE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AS,CAAC;QAC/D,uBAAuB,EAAE,cAAc,EAAE,CAAC;QAC1C,iCAAiC,EAAE,KAAK,CAAC;YACvC,KAAK,EAAE,cAAc,CAAC;YACtB,+BAA+B,EAAE,OAAO,CAAC;SAC1C,CAAC,CAAC;KACJ,CAAC;IAiEI,aAAa;;;;;;;;;CAKpB"}
|
package/src/zerodev/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ServerKeyShare } from '@dynamic-labs-wallet/node';
|
|
1
|
+
import type { ServerKeyShare, WalletMetadata } from '@dynamic-labs-wallet/node';
|
|
2
2
|
import type { ZerodevBundlerProvider } from '@dynamic-labs/sdk-api-core';
|
|
3
3
|
import type { KernelAccountClient } from '@zerodev/sdk';
|
|
4
4
|
import type { Chain, Client, Hex, RpcSchema, Transport } from 'viem';
|
|
@@ -6,7 +6,7 @@ import type { SmartAccount } from 'viem/account-abstraction';
|
|
|
6
6
|
import type { DynamicEvmWalletClient } from '../client/client.js';
|
|
7
7
|
import type { createDelegatedEvmWalletClient, DelegatedEvmWalletClient } from '../delegatedClient.js';
|
|
8
8
|
export type ZeroDevKernelOptions = {
|
|
9
|
-
|
|
9
|
+
walletMetadata: WalletMetadata;
|
|
10
10
|
networkId: string;
|
|
11
11
|
password?: string;
|
|
12
12
|
externalServerKeyShares?: ServerKeyShare[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/zerodev/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/zerodev/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACzE,OAAO,KAAK,EAAE,mBAAmB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