From e6b74fe62687671fe1ff985474c56d66cd5abd66 Mon Sep 17 00:00:00 2001 From: Petar Penovic Date: Tue, 30 May 2023 06:44:02 +0200 Subject: [PATCH] fix: expose RPC provider chain id override --- src/provider/rpc.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index db223a31f..b9a278292 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -38,6 +38,7 @@ export type RpcProviderOptions = { retries?: number; headers?: object; blockIdentifier?: BlockIdentifier; + chainId?: StarknetChainId; }; // Default Pathfinder disabled pending block https://github.com/eqlabs/pathfinder/blob/main/README.md @@ -53,22 +54,22 @@ export class RpcProvider implements ProviderInterface { public headers: object; - private chainId!: StarknetChainId; - private responseParser = new RPCResponseParser(); private retries: number; private blockIdentifier: BlockIdentifier; + private chainId?: StarknetChainId; + constructor(optionsOrProvider: RpcProviderOptions) { - const { nodeUrl, retries, headers, blockIdentifier } = optionsOrProvider; + const { nodeUrl, retries, headers, blockIdentifier, chainId } = optionsOrProvider; this.nodeUrl = nodeUrl; this.retries = retries || defaultOptions.retries; this.headers = { ...defaultOptions.headers, ...headers }; this.blockIdentifier = blockIdentifier || defaultOptions.blockIdentifier; - - this.getChainId(); + this.chainId = chainId; + this.getChainId(); // internally skipped if chainId has value } public fetch(method: any, params: any): Promise {