Skip to content

Commit 46f9634

Browse files
committed
feat: rpc optionsOrProvider extend with retries
1 parent 0ab5769 commit 46f9634

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

src/provider/rpc.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,10 @@ import { randomAddress } from '../utils/stark';
3131
import { ProviderInterface } from './interface';
3232
import { Block, BlockIdentifier } from './utils';
3333

34-
export type RpcProviderOptions = { nodeUrl: string };
35-
type Options = { retries: number };
34+
export type RpcProviderOptions = {
35+
nodeUrl: string;
36+
retries?: number;
37+
};
3638

3739
export class RpcProvider implements ProviderInterface {
3840
public nodeUrl: string;
@@ -42,12 +44,12 @@ export class RpcProvider implements ProviderInterface {
4244

4345
private responseParser = new RPCResponseParser();
4446

45-
private options: Options;
47+
private retries: number;
4648

47-
constructor(optionsOrProvider: RpcProviderOptions, options: Options) {
48-
const { nodeUrl } = optionsOrProvider;
49+
constructor(optionsOrProvider: RpcProviderOptions) {
50+
const { nodeUrl, retries } = optionsOrProvider;
4951
this.nodeUrl = nodeUrl;
50-
this.options = options;
52+
this.retries = retries || 200;
5153

5254
this.getChainId().then((chainId) => {
5355
this.chainId = chainId;
@@ -298,7 +300,7 @@ export class RpcProvider implements ProviderInterface {
298300
}
299301

300302
public async waitForTransaction(txHash: string, retryInterval: number = 8000) {
301-
let retries = this.options?.retries || 200;
303+
let { retries } = this;
302304
let onchain = false;
303305

304306
while (!onchain) {

0 commit comments

Comments
 (0)