@@ -5,7 +5,7 @@ import { createZksyncSessionClient, type ZksyncSsoSessionClient } from "../clien
55import type { Communicator } from "../communicator/index.js" ;
66import { type CustomPaymasterHandler , getTransactionWithPaymasterData } from "../paymaster/index.js" ;
77import type { SessionStateEvent } from "../utils/session.js" ;
8- import { StorageItem } from "../utils/storage.js" ;
8+ import { StorageItem , type StorageLike } from "../utils/storage.js" ;
99import type { AppMetadata , RequestArguments } from "./interface.js" ;
1010import type { AuthServerRpcSchema , ExtractParams , ExtractReturnType , Method , RPCRequestMessage , RPCResponseMessage , RpcSchema } from "./rpc.js" ;
1111import type { SessionPreferences } from "./session/index.js" ;
@@ -44,6 +44,7 @@ type SignerConstructorParams = {
4444 paymasterHandler ?: CustomPaymasterHandler ;
4545 onSessionStateChange ?: ( event : { address : Address ; chainId : number ; state : SessionStateEvent } ) => void ;
4646 skipPreTransactionStateValidation ?: boolean ; // Useful if you want to send session transactions really fast
47+ storage ?: StorageLike ;
4748} ;
4849
4950type ChainsInfo = ExtractReturnType < "eth_requestAccounts" , AuthServerRpcSchema > [ "chainsInfo" ] ;
@@ -60,10 +61,10 @@ export class Signer implements SignerInterface {
6061 private readonly skipPreTransactionStateValidation ?: boolean ;
6162
6263 private _account : StorageItem < Account | null > ;
63- private _chainsInfo = new StorageItem < ChainsInfo > ( StorageItem . scopedStorageKey ( "chainsInfo" ) , [ ] ) ;
64+ private _chainsInfo : StorageItem < ChainsInfo > ;
6465 private client : { instance : ZksyncSsoSessionClient ; type : "session" } | { instance : WalletClient ; type : "auth-server" } | undefined ;
6566
66- constructor ( { metadata, communicator, updateListener, session, chains, transports, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation } : SignerConstructorParams ) {
67+ constructor ( { metadata, communicator, updateListener, session, chains, transports, paymasterHandler, onSessionStateChange, skipPreTransactionStateValidation, storage } : SignerConstructorParams ) {
6768 if ( ! chains . length ) throw new Error ( "At least one chain must be included in the config" ) ;
6869
6970 this . getMetadata = metadata ;
@@ -76,6 +77,7 @@ export class Signer implements SignerInterface {
7677 this . onSessionStateChange = onSessionStateChange ;
7778 this . skipPreTransactionStateValidation = skipPreTransactionStateValidation ;
7879
80+ this . _chainsInfo = new StorageItem < ChainsInfo > ( StorageItem . scopedStorageKey ( "chainsInfo" ) , [ ] , { storage } ) ;
7981 this . _account = new StorageItem < Account | null > ( StorageItem . scopedStorageKey ( "account" ) , null , {
8082 onChange : ( newValue ) => {
8183 if ( newValue ) {
@@ -86,6 +88,7 @@ export class Signer implements SignerInterface {
8688 this . updateListener . onAccountsUpdate ( [ ] ) ;
8789 }
8890 } ,
91+ storage,
8992 } ) ;
9093 try {
9194 if ( this . account ) this . createWalletClient ( ) ;
0 commit comments