Skip to content

Commit

Permalink
fix: expose RPC provider chain id override
Browse files Browse the repository at this point in the history
  • Loading branch information
penovicp committed May 30, 2023
1 parent 730f8cf commit e6b74fe
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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<any> {
Expand Down

0 comments on commit e6b74fe

Please sign in to comment.