@dynamic-labs-wallet/node-evm 0.0.185 → 0.0.186

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.js CHANGED
@@ -4,6 +4,15 @@ var node = require('@dynamic-labs-wallet/node');
4
4
  var viem = require('viem');
5
5
  var chains = require('viem/chains');
6
6
  var utils = require('viem/utils');
7
+ var client = require('@dynamic-labs-sdk/client');
8
+ var core = require('@dynamic-labs-sdk/client/core');
9
+ var viem$1 = require('@dynamic-labs-sdk/evm/viem');
10
+ var waas = require('@dynamic-labs-sdk/evm/waas');
11
+ var zerodev = require('@dynamic-labs-sdk/zerodev');
12
+ var core$1 = require('@dynamic-labs-sdk/zerodev/core');
13
+ var ecdsaValidator = require('@zerodev/ecdsa-validator');
14
+ var sdk = require('@zerodev/sdk');
15
+ var accounts = require('viem/accounts');
7
16
 
8
17
  function _extends() {
9
18
  _extends = Object.assign || function assign(target) {
@@ -65,7 +74,8 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
65
74
  return this.baseJWTAuthToken;
66
75
  }
67
76
  get apiUrl() {
68
- return this.baseApiUrl;
77
+ var _this_baseApiUrl;
78
+ return (_this_baseApiUrl = this.baseApiUrl) != null ? _this_baseApiUrl : 'https://app.dynamicauth.com';
69
79
  }
70
80
  createViemPublicClient({ chain, rpcUrl }) {
71
81
  return viem.createPublicClient({
@@ -521,6 +531,283 @@ class DynamicEvmWalletClient extends node.DynamicWalletClient {
521
531
  return node.revokeDelegation(client, params);
522
532
  };
523
533
 
534
+ const getJwtExpiration = (jwt)=>{
535
+ if (!jwt) {
536
+ return 0;
537
+ }
538
+ return JSON.parse(Buffer.from(jwt.split('.')[1], 'base64').toString()).exp * 1000;
539
+ };
540
+ class MemoryStorageAdapter {
541
+ async getItem(key) {
542
+ if (key.includes('session')) {
543
+ // This is a workaround so we can pass the JWT that the authenticate the node SDK to
544
+ // the vanilla client, once set we can refresh the user and populate the user data, wallets and etc.
545
+ return JSON.stringify({
546
+ value: {
547
+ token: this.jwt,
548
+ sessionExpiration: getJwtExpiration(this.jwt),
549
+ legacyToken: null,
550
+ mfaToken: null,
551
+ captchaToken: null,
552
+ sessionKeys: null
553
+ }
554
+ });
555
+ }
556
+ var _this_store_get;
557
+ return (_this_store_get = this.store.get(key)) != null ? _this_store_get : null;
558
+ }
559
+ async setItem(key, value) {
560
+ this.store.set(key, value);
561
+ }
562
+ async removeItem(key) {
563
+ this.store.delete(key);
564
+ }
565
+ clear() {
566
+ this.store.clear();
567
+ }
568
+ get size() {
569
+ return this.store.size;
570
+ }
571
+ constructor(jwt){
572
+ this.store = new Map();
573
+ this.jwt = jwt;
574
+ }
575
+ }
576
+ const createMemoryStorageAdapter = (jwt)=>{
577
+ return new MemoryStorageAdapter(jwt);
578
+ };
579
+
580
+ const createViemSignerAdapter = ({ evmClient, accountAddress, password, externalServerKeyShares, delegated })=>{
581
+ return accounts.toAccount({
582
+ address: accountAddress,
583
+ signMessage: async ({ message })=>{
584
+ if (delegated) {
585
+ return delegatedSignMessage(delegated.delegatedClient, {
586
+ walletId: delegated.walletId,
587
+ walletApiKey: delegated.walletApiKey,
588
+ keyShare: delegated.keyShare,
589
+ message: message
590
+ });
591
+ }
592
+ const signature = await evmClient.signMessage({
593
+ message: message,
594
+ accountAddress,
595
+ password,
596
+ externalServerKeyShares
597
+ });
598
+ return signature;
599
+ },
600
+ signTypedData: async (typedData)=>{
601
+ if (delegated) {
602
+ return delegatedSignTypedData(delegated.delegatedClient, {
603
+ walletId: delegated.walletId,
604
+ walletApiKey: delegated.walletApiKey,
605
+ keyShare: delegated.keyShare,
606
+ typedData: typedData
607
+ });
608
+ }
609
+ return evmClient.signTypedData({
610
+ accountAddress,
611
+ typedData: typedData,
612
+ password: password,
613
+ externalServerKeyShares
614
+ });
615
+ },
616
+ signTransaction: async (transaction)=>{
617
+ if (delegated) {
618
+ return delegatedSignTransaction(delegated.delegatedClient, {
619
+ walletId: delegated.walletId,
620
+ walletApiKey: delegated.walletApiKey,
621
+ keyShare: delegated.keyShare,
622
+ transaction
623
+ });
624
+ }
625
+ const signedTx = await evmClient.signTransaction({
626
+ senderAddress: accountAddress,
627
+ transaction,
628
+ password,
629
+ externalServerKeyShares
630
+ });
631
+ return signedTx;
632
+ },
633
+ signAuthorization: async (authorization)=>{
634
+ if (delegated) {
635
+ const signature = await delegatedSignAuthorization(delegated.delegatedClient, {
636
+ walletId: delegated.walletId,
637
+ walletApiKey: delegated.walletApiKey,
638
+ keyShare: delegated.keyShare,
639
+ authorization
640
+ });
641
+ var _authorization_address;
642
+ const signedAuthorization = {
643
+ address: (_authorization_address = authorization.address) != null ? _authorization_address : authorization.contractAddress,
644
+ chainId: authorization.chainId,
645
+ nonce: authorization.nonce,
646
+ r: signature.r,
647
+ s: signature.s,
648
+ v: signature.v,
649
+ yParity: signature.yParity
650
+ };
651
+ return signedAuthorization;
652
+ }
653
+ const signature = await evmClient.signAuthorization({
654
+ authorization,
655
+ accountAddress,
656
+ password,
657
+ externalServerKeyShares
658
+ });
659
+ var _authorization_address1;
660
+ const signedAuthorization = {
661
+ address: (_authorization_address1 = authorization.address) != null ? _authorization_address1 : authorization.contractAddress,
662
+ chainId: authorization.chainId,
663
+ nonce: authorization.nonce,
664
+ r: signature.r,
665
+ s: signature.s,
666
+ v: signature.v,
667
+ yParity: signature.yParity
668
+ };
669
+ return signedAuthorization;
670
+ }
671
+ });
672
+ };
673
+
674
+ class DynamicEvmZeroDevClient {
675
+ async initialize() {
676
+ await client.initializeClient(this.dynamicClient);
677
+ if ('jwtAuthToken' in this.evmClient) {
678
+ // Fetch user data to populate wallet accounts
679
+ await client.refreshUser(this.dynamicClient);
680
+ }
681
+ }
682
+ /**
683
+ * Get network data by networkId from project configuration
684
+ */ getNetworkData(networkId) {
685
+ const networksData = client.getNetworksData(this.dynamicClient);
686
+ const networkData = networksData.find((n)=>n.networkId === networkId);
687
+ core.assertDefined(networkData, `No network found with networkId: ${networkId}. Available networks: ${networksData.map((n)=>n.networkId).join(', ')}`);
688
+ return networkData;
689
+ }
690
+ async createKernelClientForAddress(options) {
691
+ const viemSigner = createViemSignerAdapter({
692
+ evmClient: this.evmClient,
693
+ accountAddress: options.address,
694
+ password: options.password,
695
+ externalServerKeyShares: options.externalServerKeyShares,
696
+ delegated: options.delegated
697
+ });
698
+ const activeNetworkData = this.getNetworkData(options.networkId);
699
+ const viemChain = viem$1.mapNetworkDataToViemChain(activeNetworkData);
700
+ var _options_bundlerRpc;
701
+ const bundlerRpc = (_options_bundlerRpc = options.bundlerRpc) != null ? _options_bundlerRpc : core$1.getZerodevRpc({
702
+ bundlerProvider: options.bundlerProvider,
703
+ networkId: activeNetworkData.networkId,
704
+ rpcType: 'bundler'
705
+ }, this.dynamicClient);
706
+ const bundlerTransport = viem.http(bundlerRpc);
707
+ const publicClient = viem.createPublicClient({
708
+ chain: viemChain,
709
+ transport: bundlerTransport
710
+ });
711
+ const account = await this.createKernelAccountWithCustomSigner({
712
+ publicClient,
713
+ signer: viemSigner
714
+ });
715
+ var _options_paymasterRpc;
716
+ const paymasterRpc = (_options_paymasterRpc = options.paymasterRpc) != null ? _options_paymasterRpc : core$1.getZerodevRpc({
717
+ bundlerProvider: options.bundlerProvider,
718
+ networkId: activeNetworkData.networkId,
719
+ rpcType: 'paymaster'
720
+ }, this.dynamicClient);
721
+ var _options_withSponsorship;
722
+ const paymasterConfig = ((_options_withSponsorship = options.withSponsorship) != null ? _options_withSponsorship : true) ? core$1.getPaymasterConfig({
723
+ chain: viemChain,
724
+ gasTokenAddress: options.gasTokenAddress,
725
+ paymasterRpc
726
+ }) : {};
727
+ const kernelClient = sdk.createKernelAccountClient(_extends({
728
+ account,
729
+ bundlerTransport,
730
+ chain: viemChain,
731
+ client: publicClient,
732
+ userOperation: {
733
+ estimateFeesPerGas: async ({ bundlerClient })=>sdk.getUserOperationGasPrice(bundlerClient)
734
+ }
735
+ }, paymasterConfig));
736
+ return kernelClient;
737
+ }
738
+ async createKernelAccountWithCustomSigner({ publicClient, signer }) {
739
+ const zerodevProvider = core$1.getZerodevProviderFromSettings(this.dynamicClient);
740
+ core.assertDefined(zerodevProvider, 'Zerodev provider is not enabled in project settings');
741
+ const useEIP7702 = zerodevProvider.enableEIP7702;
742
+ const entryPointVersion = zerodevProvider.entryPointVersion;
743
+ const entryPoint = core$1.getEntryPoint(entryPointVersion);
744
+ if (useEIP7702) {
745
+ return sdk.createKernelAccount(publicClient, {
746
+ eip7702Account: signer,
747
+ entryPoint,
748
+ kernelVersion: sdk.constants.KERNEL_V3_3
749
+ });
750
+ }
751
+ const kernelVersionValue = zerodevProvider.kernelVersion;
752
+ const kernelVersion = core$1.getKernelVersion({
753
+ entryPoint,
754
+ kernelVersion: kernelVersionValue
755
+ });
756
+ var _zerodevProvider_enableKernelV3Migration;
757
+ const kernelV3MigrationEnabled = (_zerodevProvider_enableKernelV3Migration = zerodevProvider.enableKernelV3Migration) != null ? _zerodevProvider_enableKernelV3Migration : false;
758
+ if (kernelV3MigrationEnabled) {
759
+ const apiKernelVersion = core$1.getKernelVersion({
760
+ entryPoint,
761
+ kernelVersion: zerodevProvider.kernelVersion
762
+ });
763
+ return ecdsaValidator.createEcdsaKernelMigrationAccount(publicClient, {
764
+ entryPoint,
765
+ migrationVersion: {
766
+ from: kernelVersion,
767
+ to: apiKernelVersion
768
+ },
769
+ signer
770
+ });
771
+ }
772
+ const validator = await core$1.getEcdsaValidator({
773
+ ecdsaProviderType: zerodevProvider.ecdsaProviderType,
774
+ entryPoint,
775
+ kernelVersion,
776
+ publicClient,
777
+ signer
778
+ });
779
+ return sdk.createKernelAccount(publicClient, {
780
+ entryPoint,
781
+ kernelVersion,
782
+ plugins: {
783
+ sudo: validator
784
+ }
785
+ });
786
+ }
787
+ constructor(evmClient){
788
+ this.evmClient = evmClient;
789
+ var _evmClient_jwtAuthToken;
790
+ const authToken = 'jwtAuthToken' in evmClient ? (_evmClient_jwtAuthToken = evmClient.jwtAuthToken) != null ? _evmClient_jwtAuthToken : null : null;
791
+ const storageAdapter = createMemoryStorageAdapter(authToken);
792
+ this.dynamicClient = client.createDynamicClient({
793
+ environmentId: evmClient.environmentId,
794
+ autoInitialize: false,
795
+ coreConfig: {
796
+ storageAdapter,
797
+ fetch: fetch,
798
+ apiBaseUrl: `${evmClient.apiUrl}/api/v0`
799
+ }
800
+ });
801
+ zerodev.addZerodevExtension(this.dynamicClient);
802
+ waas.addWaasEvmExtension(this.dynamicClient);
803
+ }
804
+ }
805
+ const createZerodevClient = async (evmClient)=>{
806
+ const client = new DynamicEvmZeroDevClient(evmClient);
807
+ await client.initialize();
808
+ return client;
809
+ };
810
+
524
811
  exports.DynamicEvmWalletClient = DynamicEvmWalletClient;
525
812
  exports.ERROR_ACCOUNT_ADDRESS_REQUIRED = ERROR_ACCOUNT_ADDRESS_REQUIRED;
526
813
  exports.ERROR_CREATE_WALLET_ACCOUNT = ERROR_CREATE_WALLET_ACCOUNT;
@@ -530,6 +817,7 @@ exports.ERROR_SIGN_TYPED_DATA = ERROR_SIGN_TYPED_DATA;
530
817
  exports.ERROR_VERIFY_MESSAGE_SIGNATURE = ERROR_VERIFY_MESSAGE_SIGNATURE;
531
818
  exports.EVM_SIGN_MESSAGE_PREFIX = EVM_SIGN_MESSAGE_PREFIX;
532
819
  exports.createDelegatedEvmWalletClient = createDelegatedEvmWalletClient;
820
+ exports.createZerodevClient = createZerodevClient;
533
821
  exports.delegatedSignAuthorization = delegatedSignAuthorization;
534
822
  exports.delegatedSignMessage = delegatedSignMessage;
535
823
  exports.delegatedSignTransaction = delegatedSignTransaction;
package/index.esm.js CHANGED
@@ -2,6 +2,15 @@ import { MessageHash, DynamicWalletClient, getMPCChainConfig, getExternalServerK
2
2
  import { stringToHex, bytesToHex, size, concat, hashTypedData, serializeSignature, getAddress, createPublicClient, http, parseSignature, serializeTransaction } from 'viem';
3
3
  import { mainnet } from 'viem/chains';
4
4
  import { hashAuthorization } from 'viem/utils';
5
+ import { initializeClient, refreshUser, getNetworksData, createDynamicClient } from '@dynamic-labs-sdk/client';
6
+ import { assertDefined } from '@dynamic-labs-sdk/client/core';
7
+ import { mapNetworkDataToViemChain } from '@dynamic-labs-sdk/evm/viem';
8
+ import { addWaasEvmExtension } from '@dynamic-labs-sdk/evm/waas';
9
+ import { addZerodevExtension } from '@dynamic-labs-sdk/zerodev';
10
+ import { getZerodevRpc, getPaymasterConfig, getZerodevProviderFromSettings, getEntryPoint, getKernelVersion, getEcdsaValidator } from '@dynamic-labs-sdk/zerodev/core';
11
+ import { createEcdsaKernelMigrationAccount } from '@zerodev/ecdsa-validator';
12
+ import { createKernelAccountClient, getUserOperationGasPrice, createKernelAccount, constants } from '@zerodev/sdk';
13
+ import { toAccount } from 'viem/accounts';
5
14
 
6
15
  function _extends() {
7
16
  _extends = Object.assign || function assign(target) {
@@ -63,7 +72,8 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
63
72
  return this.baseJWTAuthToken;
64
73
  }
65
74
  get apiUrl() {
66
- return this.baseApiUrl;
75
+ var _this_baseApiUrl;
76
+ return (_this_baseApiUrl = this.baseApiUrl) != null ? _this_baseApiUrl : 'https://app.dynamicauth.com';
67
77
  }
68
78
  createViemPublicClient({ chain, rpcUrl }) {
69
79
  return createPublicClient({
@@ -519,4 +529,281 @@ class DynamicEvmWalletClient extends DynamicWalletClient {
519
529
  return revokeDelegation$1(client, params);
520
530
  };
521
531
 
522
- export { DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_SIGN_MESSAGE_PREFIX, createDelegatedEvmWalletClient, delegatedSignAuthorization, delegatedSignMessage, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, revokeDelegation, serializeECDSASignature };
532
+ const getJwtExpiration = (jwt)=>{
533
+ if (!jwt) {
534
+ return 0;
535
+ }
536
+ return JSON.parse(Buffer.from(jwt.split('.')[1], 'base64').toString()).exp * 1000;
537
+ };
538
+ class MemoryStorageAdapter {
539
+ async getItem(key) {
540
+ if (key.includes('session')) {
541
+ // This is a workaround so we can pass the JWT that the authenticate the node SDK to
542
+ // the vanilla client, once set we can refresh the user and populate the user data, wallets and etc.
543
+ return JSON.stringify({
544
+ value: {
545
+ token: this.jwt,
546
+ sessionExpiration: getJwtExpiration(this.jwt),
547
+ legacyToken: null,
548
+ mfaToken: null,
549
+ captchaToken: null,
550
+ sessionKeys: null
551
+ }
552
+ });
553
+ }
554
+ var _this_store_get;
555
+ return (_this_store_get = this.store.get(key)) != null ? _this_store_get : null;
556
+ }
557
+ async setItem(key, value) {
558
+ this.store.set(key, value);
559
+ }
560
+ async removeItem(key) {
561
+ this.store.delete(key);
562
+ }
563
+ clear() {
564
+ this.store.clear();
565
+ }
566
+ get size() {
567
+ return this.store.size;
568
+ }
569
+ constructor(jwt){
570
+ this.store = new Map();
571
+ this.jwt = jwt;
572
+ }
573
+ }
574
+ const createMemoryStorageAdapter = (jwt)=>{
575
+ return new MemoryStorageAdapter(jwt);
576
+ };
577
+
578
+ const createViemSignerAdapter = ({ evmClient, accountAddress, password, externalServerKeyShares, delegated })=>{
579
+ return toAccount({
580
+ address: accountAddress,
581
+ signMessage: async ({ message })=>{
582
+ if (delegated) {
583
+ return delegatedSignMessage(delegated.delegatedClient, {
584
+ walletId: delegated.walletId,
585
+ walletApiKey: delegated.walletApiKey,
586
+ keyShare: delegated.keyShare,
587
+ message: message
588
+ });
589
+ }
590
+ const signature = await evmClient.signMessage({
591
+ message: message,
592
+ accountAddress,
593
+ password,
594
+ externalServerKeyShares
595
+ });
596
+ return signature;
597
+ },
598
+ signTypedData: async (typedData)=>{
599
+ if (delegated) {
600
+ return delegatedSignTypedData(delegated.delegatedClient, {
601
+ walletId: delegated.walletId,
602
+ walletApiKey: delegated.walletApiKey,
603
+ keyShare: delegated.keyShare,
604
+ typedData: typedData
605
+ });
606
+ }
607
+ return evmClient.signTypedData({
608
+ accountAddress,
609
+ typedData: typedData,
610
+ password: password,
611
+ externalServerKeyShares
612
+ });
613
+ },
614
+ signTransaction: async (transaction)=>{
615
+ if (delegated) {
616
+ return delegatedSignTransaction(delegated.delegatedClient, {
617
+ walletId: delegated.walletId,
618
+ walletApiKey: delegated.walletApiKey,
619
+ keyShare: delegated.keyShare,
620
+ transaction
621
+ });
622
+ }
623
+ const signedTx = await evmClient.signTransaction({
624
+ senderAddress: accountAddress,
625
+ transaction,
626
+ password,
627
+ externalServerKeyShares
628
+ });
629
+ return signedTx;
630
+ },
631
+ signAuthorization: async (authorization)=>{
632
+ if (delegated) {
633
+ const signature = await delegatedSignAuthorization(delegated.delegatedClient, {
634
+ walletId: delegated.walletId,
635
+ walletApiKey: delegated.walletApiKey,
636
+ keyShare: delegated.keyShare,
637
+ authorization
638
+ });
639
+ var _authorization_address;
640
+ const signedAuthorization = {
641
+ address: (_authorization_address = authorization.address) != null ? _authorization_address : authorization.contractAddress,
642
+ chainId: authorization.chainId,
643
+ nonce: authorization.nonce,
644
+ r: signature.r,
645
+ s: signature.s,
646
+ v: signature.v,
647
+ yParity: signature.yParity
648
+ };
649
+ return signedAuthorization;
650
+ }
651
+ const signature = await evmClient.signAuthorization({
652
+ authorization,
653
+ accountAddress,
654
+ password,
655
+ externalServerKeyShares
656
+ });
657
+ var _authorization_address1;
658
+ const signedAuthorization = {
659
+ address: (_authorization_address1 = authorization.address) != null ? _authorization_address1 : authorization.contractAddress,
660
+ chainId: authorization.chainId,
661
+ nonce: authorization.nonce,
662
+ r: signature.r,
663
+ s: signature.s,
664
+ v: signature.v,
665
+ yParity: signature.yParity
666
+ };
667
+ return signedAuthorization;
668
+ }
669
+ });
670
+ };
671
+
672
+ class DynamicEvmZeroDevClient {
673
+ async initialize() {
674
+ await initializeClient(this.dynamicClient);
675
+ if ('jwtAuthToken' in this.evmClient) {
676
+ // Fetch user data to populate wallet accounts
677
+ await refreshUser(this.dynamicClient);
678
+ }
679
+ }
680
+ /**
681
+ * Get network data by networkId from project configuration
682
+ */ getNetworkData(networkId) {
683
+ const networksData = getNetworksData(this.dynamicClient);
684
+ const networkData = networksData.find((n)=>n.networkId === networkId);
685
+ assertDefined(networkData, `No network found with networkId: ${networkId}. Available networks: ${networksData.map((n)=>n.networkId).join(', ')}`);
686
+ return networkData;
687
+ }
688
+ async createKernelClientForAddress(options) {
689
+ const viemSigner = createViemSignerAdapter({
690
+ evmClient: this.evmClient,
691
+ accountAddress: options.address,
692
+ password: options.password,
693
+ externalServerKeyShares: options.externalServerKeyShares,
694
+ delegated: options.delegated
695
+ });
696
+ const activeNetworkData = this.getNetworkData(options.networkId);
697
+ const viemChain = mapNetworkDataToViemChain(activeNetworkData);
698
+ var _options_bundlerRpc;
699
+ const bundlerRpc = (_options_bundlerRpc = options.bundlerRpc) != null ? _options_bundlerRpc : getZerodevRpc({
700
+ bundlerProvider: options.bundlerProvider,
701
+ networkId: activeNetworkData.networkId,
702
+ rpcType: 'bundler'
703
+ }, this.dynamicClient);
704
+ const bundlerTransport = http(bundlerRpc);
705
+ const publicClient = createPublicClient({
706
+ chain: viemChain,
707
+ transport: bundlerTransport
708
+ });
709
+ const account = await this.createKernelAccountWithCustomSigner({
710
+ publicClient,
711
+ signer: viemSigner
712
+ });
713
+ var _options_paymasterRpc;
714
+ const paymasterRpc = (_options_paymasterRpc = options.paymasterRpc) != null ? _options_paymasterRpc : getZerodevRpc({
715
+ bundlerProvider: options.bundlerProvider,
716
+ networkId: activeNetworkData.networkId,
717
+ rpcType: 'paymaster'
718
+ }, this.dynamicClient);
719
+ var _options_withSponsorship;
720
+ const paymasterConfig = ((_options_withSponsorship = options.withSponsorship) != null ? _options_withSponsorship : true) ? getPaymasterConfig({
721
+ chain: viemChain,
722
+ gasTokenAddress: options.gasTokenAddress,
723
+ paymasterRpc
724
+ }) : {};
725
+ const kernelClient = createKernelAccountClient(_extends({
726
+ account,
727
+ bundlerTransport,
728
+ chain: viemChain,
729
+ client: publicClient,
730
+ userOperation: {
731
+ estimateFeesPerGas: async ({ bundlerClient })=>getUserOperationGasPrice(bundlerClient)
732
+ }
733
+ }, paymasterConfig));
734
+ return kernelClient;
735
+ }
736
+ async createKernelAccountWithCustomSigner({ publicClient, signer }) {
737
+ const zerodevProvider = getZerodevProviderFromSettings(this.dynamicClient);
738
+ assertDefined(zerodevProvider, 'Zerodev provider is not enabled in project settings');
739
+ const useEIP7702 = zerodevProvider.enableEIP7702;
740
+ const entryPointVersion = zerodevProvider.entryPointVersion;
741
+ const entryPoint = getEntryPoint(entryPointVersion);
742
+ if (useEIP7702) {
743
+ return createKernelAccount(publicClient, {
744
+ eip7702Account: signer,
745
+ entryPoint,
746
+ kernelVersion: constants.KERNEL_V3_3
747
+ });
748
+ }
749
+ const kernelVersionValue = zerodevProvider.kernelVersion;
750
+ const kernelVersion = getKernelVersion({
751
+ entryPoint,
752
+ kernelVersion: kernelVersionValue
753
+ });
754
+ var _zerodevProvider_enableKernelV3Migration;
755
+ const kernelV3MigrationEnabled = (_zerodevProvider_enableKernelV3Migration = zerodevProvider.enableKernelV3Migration) != null ? _zerodevProvider_enableKernelV3Migration : false;
756
+ if (kernelV3MigrationEnabled) {
757
+ const apiKernelVersion = getKernelVersion({
758
+ entryPoint,
759
+ kernelVersion: zerodevProvider.kernelVersion
760
+ });
761
+ return createEcdsaKernelMigrationAccount(publicClient, {
762
+ entryPoint,
763
+ migrationVersion: {
764
+ from: kernelVersion,
765
+ to: apiKernelVersion
766
+ },
767
+ signer
768
+ });
769
+ }
770
+ const validator = await getEcdsaValidator({
771
+ ecdsaProviderType: zerodevProvider.ecdsaProviderType,
772
+ entryPoint,
773
+ kernelVersion,
774
+ publicClient,
775
+ signer
776
+ });
777
+ return createKernelAccount(publicClient, {
778
+ entryPoint,
779
+ kernelVersion,
780
+ plugins: {
781
+ sudo: validator
782
+ }
783
+ });
784
+ }
785
+ constructor(evmClient){
786
+ this.evmClient = evmClient;
787
+ var _evmClient_jwtAuthToken;
788
+ const authToken = 'jwtAuthToken' in evmClient ? (_evmClient_jwtAuthToken = evmClient.jwtAuthToken) != null ? _evmClient_jwtAuthToken : null : null;
789
+ const storageAdapter = createMemoryStorageAdapter(authToken);
790
+ this.dynamicClient = createDynamicClient({
791
+ environmentId: evmClient.environmentId,
792
+ autoInitialize: false,
793
+ coreConfig: {
794
+ storageAdapter,
795
+ fetch: fetch,
796
+ apiBaseUrl: `${evmClient.apiUrl}/api/v0`
797
+ }
798
+ });
799
+ addZerodevExtension(this.dynamicClient);
800
+ addWaasEvmExtension(this.dynamicClient);
801
+ }
802
+ }
803
+ const createZerodevClient = async (evmClient)=>{
804
+ const client = new DynamicEvmZeroDevClient(evmClient);
805
+ await client.initialize();
806
+ return client;
807
+ };
808
+
809
+ export { DynamicEvmWalletClient, ERROR_ACCOUNT_ADDRESS_REQUIRED, ERROR_CREATE_WALLET_ACCOUNT, ERROR_KEYGEN_FAILED, ERROR_SIGN_MESSAGE, ERROR_SIGN_TYPED_DATA, ERROR_VERIFY_MESSAGE_SIGNATURE, EVM_SIGN_MESSAGE_PREFIX, createDelegatedEvmWalletClient, createZerodevClient, delegatedSignAuthorization, delegatedSignMessage, delegatedSignTransaction, delegatedSignTypedData, deriveAccountAddress, formatEVMMessage, formatTypedData, revokeDelegation, serializeECDSASignature };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@dynamic-labs-wallet/node-evm",
3
- "version": "0.0.185",
3
+ "version": "0.0.186",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "dependencies": {
7
- "@dynamic-labs-wallet/node": "0.0.185",
7
+ "@dynamic-labs-wallet/node": "0.0.186",
8
8
  "@dynamic-labs/sdk-api-core": "^0.0.801",
9
9
  "@dynamic-labs-sdk/client": "^0.1.0-alpha.22",
10
10
  "@dynamic-labs-sdk/zerodev": "^0.1.0-alpha.22",
package/src/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './client/index.js';
2
2
  export * from './delegatedClient.js';
3
+ export * from './zerodev/index.js';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../packages/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,oBAAoB,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { createZerodevClient } from './client.js';
2
+ export type { KernelClient } from './types.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/zerodev/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC"}