1
1
/* eslint-disable @typescript-eslint/no-explicit-any */
2
- import { ChainId } from '@0xsequence/network'
3
2
import { Relayer , Signers } from '@0xsequence/wallet-core'
4
3
import { Address , Hex } from 'ox'
5
4
@@ -57,7 +56,7 @@ export class DappClient {
57
56
58
57
public readonly origin : string
59
58
60
- private chainSessionManagers : Map < ChainId , ChainSessionManager > = new Map ( )
59
+ private chainSessionManagers : Map < bigint , ChainSessionManager > = new Map ( )
61
60
private transport : DappTransport
62
61
private keymachineUrl : string
63
62
private walletUrl : string
@@ -235,7 +234,7 @@ export class DappClient {
235
234
this . userEmail = implicitSession . userEmail ?? null
236
235
237
236
const explicitSessions = await this . sequenceStorage . getExplicitSessions ( )
238
- const chainIdsToInitialize = new Set < ChainId > ( [
237
+ const chainIdsToInitialize = new Set < bigint > ( [
239
238
implicitSession . chainId ,
240
239
...explicitSessions . filter ( ( s ) => Address . isEqual ( s . walletAddress , this . walletAddress ! ) ) . map ( ( s ) => s . chainId ) ,
241
240
] )
@@ -328,7 +327,7 @@ export class DappClient {
328
327
329
328
/**
330
329
* Initiates a connection with the wallet and creates a new session.
331
- * @param chainId The primary chain ID for the new session. { @link ChainId}
330
+ * @param chainId The primary chain ID for the new session.
332
331
* @param permissions (Optional) Permissions to request for an initial explicit session. {@link Signers.Session.ExplicitParams}
333
332
* @param options (Optional) Connection options, such as a preferred login method or email for social or email logins.
334
333
* @throws If the connection process fails. {@link ConnectionError}
@@ -345,7 +344,7 @@ export class DappClient {
345
344
* });
346
345
*/
347
346
async connect (
348
- chainId : ChainId ,
347
+ chainId : bigint ,
349
348
permissions ?: Signers . Session . ExplicitParams ,
350
349
options : {
351
350
preferredLoginMethod ?: 'google' | 'apple' | 'email' | 'passkey' | 'mnemonic'
@@ -375,7 +374,7 @@ export class DappClient {
375
374
* Adds a new explicit session for a given chain to an existing wallet.
376
375
* @remarks
377
376
* An `explicit session` is a session that can interact with any contract, subject to user-approved permissions.
378
- * @param chainId The chain ID on which to add the explicit session. { @link ChainId}
377
+ * @param chainId The chain ID on which to add the explicit session.
379
378
* @param permissions The permissions to request for the new session. {@link Signers.Session.ExplicitParams}
380
379
*
381
380
* @throws If the session cannot be added. {@link AddExplicitSessionError}
@@ -408,7 +407,7 @@ export class DappClient {
408
407
* await dappClient.addExplicitSession(1, permissions);
409
408
* }
410
409
*/
411
- async addExplicitSession ( chainId : ChainId , permissions : Signers . Session . ExplicitParams ) : Promise < void > {
410
+ async addExplicitSession ( chainId : bigint , permissions : Signers . Session . ExplicitParams ) : Promise < void > {
412
411
if ( ! this . isInitialized || ! this . walletAddress )
413
412
throw new InitializationError ( 'Cannot add an explicit session without an existing wallet.' )
414
413
@@ -425,7 +424,7 @@ export class DappClient {
425
424
426
425
/**
427
426
* Modifies the permissions of an existing explicit session for a given chain and session address.
428
- * @param chainId The chain ID on which the explicit session exists. { @link ChainId}
427
+ * @param chainId The chain ID on which the explicit session exists.
429
428
* @param sessionAddress The address of the explicit session to modify. {@link Address.Address}
430
429
* @param permissions The new permissions to set for the session. {@link Signers.Session.ExplicitParams}
431
430
*
@@ -454,7 +453,7 @@ export class DappClient {
454
453
* }
455
454
*/
456
455
async modifyExplicitSession (
457
- chainId : ChainId ,
456
+ chainId : bigint ,
458
457
sessionAddress : Address . Address ,
459
458
permissions : Signers . Session . ExplicitParams ,
460
459
) : Promise < void > {
@@ -474,7 +473,7 @@ export class DappClient {
474
473
475
474
/**
476
475
* Gets the gas fee options for an array of transactions.
477
- * @param chainId The chain ID on which to get the fee options. { @link ChainId}
476
+ * @param chainId The chain ID on which to get the fee options.
478
477
* @param transactions An array of transactions to get fee options for. These transactions will not be sent.
479
478
* @throws If the fee options cannot be fetched. {@link FeeOptionError}
480
479
* @throws If the client or relevant chain is not initialized. {@link InitializationError}
@@ -501,7 +500,7 @@ export class DappClient {
501
500
* const txHash = await dappClient.sendTransaction(1, transactions, feeOption);
502
501
* }
503
502
*/
504
- async getFeeOptions ( chainId : ChainId , transactions : Transaction [ ] ) : Promise < Relayer . FeeOption [ ] > {
503
+ async getFeeOptions ( chainId : bigint , transactions : Transaction [ ] ) : Promise < Relayer . FeeOption [ ] > {
505
504
if ( ! this . isInitialized ) throw new InitializationError ( 'Not initialized' )
506
505
const chainSessionManager = this . getChainSessionManager ( chainId )
507
506
if ( ! chainSessionManager . isInitialized )
@@ -511,7 +510,7 @@ export class DappClient {
511
510
512
511
/**
513
512
* Signs and sends a transaction using an available session signer.
514
- * @param chainId The chain ID on which to send the transaction. { @link ChainId}
513
+ * @param chainId The chain ID on which to send the transaction.
515
514
* @param transactions An array of transactions to be executed atomically in a single batch. {@link Transaction}
516
515
* @param feeOption (Optional) The selected fee option to sponsor the transaction. {@link Relayer.FeeOption}
517
516
* @throws {TransactionError } If the transaction fails to send or confirm.
@@ -534,11 +533,7 @@ export class DappClient {
534
533
*
535
534
* const txHash = await dappClient.sendTransaction(1, [transaction]);
536
535
*/
537
- async sendTransaction (
538
- chainId : ChainId ,
539
- transactions : Transaction [ ] ,
540
- feeOption ?: Relayer . FeeOption ,
541
- ) : Promise < Hex . Hex > {
536
+ async sendTransaction ( chainId : bigint , transactions : Transaction [ ] , feeOption ?: Relayer . FeeOption ) : Promise < Hex . Hex > {
542
537
if ( ! this . isInitialized ) throw new InitializationError ( 'Not initialized' )
543
538
const chainSessionManager = this . getChainSessionManager ( chainId )
544
539
if ( ! chainSessionManager . isInitialized )
@@ -548,7 +543,7 @@ export class DappClient {
548
543
549
544
/**
550
545
* Signs a standard message (EIP-191) using an available session signer.
551
- * @param chainId The chain ID on which to sign the message. { @link ChainId}
546
+ * @param chainId The chain ID on which to sign the message.
552
547
* @param message The message to sign.
553
548
* @throws If the message cannot be signed. {@link SigningError}
554
549
* @throws If the client or relevant chain is not initialized. {@link InitializationError}
@@ -566,7 +561,7 @@ export class DappClient {
566
561
* await dappClient.signMessage(1, message);
567
562
* }
568
563
*/
569
- async signMessage ( chainId : ChainId , message : string ) : Promise < void > {
564
+ async signMessage ( chainId : bigint , message : string ) : Promise < void > {
570
565
if ( ! this . isInitialized ) throw new InitializationError ( 'Not initialized' )
571
566
const chainSessionManager = this . getChainSessionManager ( chainId )
572
567
if ( ! chainSessionManager . isInitialized )
@@ -576,7 +571,7 @@ export class DappClient {
576
571
577
572
/**
578
573
* Signs a typed data object (EIP-712) using an available session signer.
579
- * @param chainId The chain ID on which to sign the typed data. { @link ChainId}
574
+ * @param chainId The chain ID on which to sign the typed data.
580
575
* @param typedData The typed data object to sign.
581
576
* @throws If the typed data cannot be signed. {@link SigningError}
582
577
* @throws If the client or relevant chain is not initialized. {@link InitializationError}
@@ -594,7 +589,7 @@ export class DappClient {
594
589
* await dappClient.signTypedData(1, typedData);
595
590
* }
596
591
*/
597
- async signTypedData ( chainId : ChainId , typedData : TypedData ) : Promise < void > {
592
+ async signTypedData ( chainId : bigint , typedData : TypedData ) : Promise < void > {
598
593
if ( ! this . isInitialized ) throw new InitializationError ( 'Not initialized' )
599
594
const chainSessionManager = this . getChainSessionManager ( chainId )
600
595
if ( ! chainSessionManager . isInitialized )
@@ -652,10 +647,10 @@ export class DappClient {
652
647
653
648
/**
654
649
* @private Retrieves or creates a ChainSessionManager for a given chain ID.
655
- * @param chainId The chain ID to get the ChainSessionManager for. { @link ChainId}
650
+ * @param chainId The chain ID to get the ChainSessionManager for.
656
651
* @returns The ChainSessionManager for the given chain ID. {@link ChainSessionManager}
657
652
*/
658
- private getChainSessionManager ( chainId : ChainId ) : ChainSessionManager {
653
+ private getChainSessionManager ( chainId : bigint ) : ChainSessionManager {
659
654
let chainSessionManager = this . chainSessionManagers . get ( chainId )
660
655
if ( ! chainSessionManager ) {
661
656
chainSessionManager = new ChainSessionManager (
0 commit comments