Skip to content

Commit

Permalink
chore!: remove the chain id property from the provider interface
Browse files Browse the repository at this point in the history
  • Loading branch information
penovicp committed Jan 10, 2023
1 parent e88bec5 commit 425b223
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 12 deletions.
2 changes: 1 addition & 1 deletion __tests__/rpcProvider.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ describeIfRpc('RPCProvider', () => {

test('getChainId', async () => {
const fetchSpy = jest.spyOn(rpcProvider as any, 'fetchEndpoint');
rpcProvider.chainId = undefined as unknown as StarknetChainId;
(rpcProvider as any).chainId = undefined as unknown as StarknetChainId;
const chainId1 = await rpcProvider.getChainId();
const chainId2 = await rpcProvider.getChainId();
expect(fetchSpy.mock.calls.length).toBe(1);
Expand Down
4 changes: 0 additions & 4 deletions src/provider/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,6 @@ export class Provider implements ProviderInterface {
}
}

public get chainId(): StarknetChainId {
return this.provider.chainId;
}

public async getChainId(): Promise<StarknetChainId> {
return this.provider.getChainId();
}
Expand Down
2 changes: 0 additions & 2 deletions src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@ import type { BigNumberish } from '../utils/number';
import { BlockIdentifier } from './utils';

export abstract class ProviderInterface {
public abstract chainId: StarknetChainId;

/**
* Gets the Starknet chain Id
*
Expand Down
5 changes: 2 additions & 3 deletions src/provider/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ const defaultOptions = {
export class RpcProvider implements ProviderInterface {
public nodeUrl: string;

// TODO: consider making private
public chainId!: StarknetChainId;

public headers: object;

private chainId!: StarknetChainId;

private responseParser = new RPCResponseParser();

private retries: number;
Expand Down
4 changes: 2 additions & 2 deletions src/provider/sequencer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ export class SequencerProvider implements ProviderInterface {

public gatewayUrl: string;

public chainId: StarknetChainId;

public headers: object | undefined;

private chainId: StarknetChainId;

private responseParser = new SequencerAPIResponseParser();

private blockIdentifier: BlockIdentifier;
Expand Down

0 comments on commit 425b223

Please sign in to comment.