Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion yarn-project/wallet-sdk/src/base-wallet/base_wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import type { AuthWitness } from '@aztec/stdlib/auth-witness';
import { AztecAddress } from '@aztec/stdlib/aztec-address';
import {
type ContractInstanceWithAddress,
type NodeInfo,
computePartialAddress,
getContractClassFromArtifact,
} from '@aztec/stdlib/contract';
Expand Down Expand Up @@ -113,6 +114,9 @@ export type CompleteFeeOptionsConfig = {
export abstract class BaseWallet implements Wallet {
protected minFeePadding = 0.5;
protected cancellableTransactions = false;
// A wallet is instantiated for a particular chain, so chain info never changes during its lifetime.
// We cache it here because getChainInfo is called frequently (every tx simulation, send, auth wit, etc.).
private nodeInfoPromise: Promise<NodeInfo> | undefined;

// Protected because we want to force wallets to instantiate their own PXE.
protected constructor(
Expand Down Expand Up @@ -144,7 +148,10 @@ export abstract class BaseWallet implements Wallet {
}

async getChainInfo(): Promise<ChainInfo> {
const { l1ChainId, rollupVersion } = await this.aztecNode.getNodeInfo();
if (!this.nodeInfoPromise) {
this.nodeInfoPromise = this.aztecNode.getNodeInfo();
}
const { l1ChainId, rollupVersion } = await this.nodeInfoPromise;
return { chainId: new Fr(l1ChainId), version: new Fr(rollupVersion) };
}

Expand Down
Loading