Skip to content

Commit

Permalink
rollback static method
Browse files Browse the repository at this point in the history
  • Loading branch information
Torres-ssf committed Feb 25, 2025
1 parent 5bf8052 commit 7dc1ca6
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions packages/account/src/providers/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ export default class Provider {
/**
* @hidden
*/
private getFetchFn(options: ProviderOptions): NonNullable<ProviderOptions['fetch']> {
private static getFetchFn(options: ProviderOptions): NonNullable<ProviderOptions['fetch']> {
const { retryOptions, timeout, headers } = options;

return autoRetryFetch(async (...args) => {
Expand All @@ -481,12 +481,6 @@ export default class Provider {
headers: { ...request?.headers, ...headers },
};

const requestBody = JSON.parse(fullRequest.body as string);
if (isBlockSensitiveOperation(requestBody.operationName)) {
requestBody.extensions = { required_fuel_block_height: this.currentBlockHeight };
fullRequest.body = JSON.stringify(requestBody);
}

if (options.requestMiddleware) {
fullRequest = await options.requestMiddleware(fullRequest);
}
Expand Down Expand Up @@ -705,10 +699,18 @@ export default class Provider {
* @hidden
*/
private createOperations(): SdkOperations {
const fetchFn = this.getFetchFn(this.options);
const fetchFn = Provider.getFetchFn(this.options);
const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
fetch: (input: RequestInfo | URL, requestInit?: RequestInit) =>
fetchFn(input.toString(), requestInit || {}, this.options),
fetch: (input: RequestInfo | URL, requestInit?: RequestInit) => {
const request = requestInit || {};
const requestBody = JSON.parse(request?.body as string);
if (isBlockSensitiveOperation(requestBody.operationName)) {
requestBody.extensions = { required_fuel_block_height: this.currentBlockHeight };
request.body = JSON.stringify(requestBody);
}

return fetchFn(input.toString(), requestInit || {}, this.options);
},
responseMiddleware: (response: GraphQLClientResponse<unknown> | Error) => {
this.setCurrentBlockHeight(response as { extensions: unknown });
if ('response' in response) {
Expand Down

0 comments on commit 7dc1ca6

Please sign in to comment.