diff --git a/__tests__/config/jest.setup.ts b/__tests__/config/jest.setup.ts index aa784e2bd..90bbc1b5b 100644 --- a/__tests__/config/jest.setup.ts +++ b/__tests__/config/jest.setup.ts @@ -38,8 +38,9 @@ if (process.env.DEBUG === 'true') { response(response) { const cloned = response.clone(); - cloned.json().then(({ result }) => { - const match: any = combiner.find((it: any) => typeof it.result === 'undefined'); + cloned.json().then((res) => { + const { result } = res; + const match: any = combiner.find((it: any) => it.request.body.id === res.id); if (match && 'request' in match) { match.result = result; console.log(util.inspect(match, false, null, true /* enable colors */)); diff --git a/src/channel/rpc_0_6.ts b/src/channel/rpc_0_6.ts index c533c9ef8..05952e2bf 100644 --- a/src/channel/rpc_0_6.ts +++ b/src/channel/rpc_0_6.ts @@ -42,6 +42,8 @@ export class RpcChannel { readonly retries: number; + public requestId: number; + readonly blockIdentifier: BlockIdentifier; private chainId?: StarknetChainId; @@ -65,6 +67,7 @@ export class RpcChannel { this.blockIdentifier = blockIdentifier || defaultOptions.blockIdentifier; this.chainId = chainId; this.waitMode = waitMode || false; + this.requestId = 0; } public fetch(method: string, params?: object, id: string | number = 0) { @@ -102,7 +105,7 @@ export class RpcChannel { params?: RPC.Methods[T]['params'] ): Promise { try { - const rawResult = await this.fetch(method, params); + const rawResult = await this.fetch(method, params, (this.requestId += 1)); const { error, result } = await rawResult.json(); this.errorHandler(method, params, error); return result as RPC.Methods[T]['result'];