Skip to content

Commit

Permalink
Replace url with provider index
Browse files Browse the repository at this point in the history
  • Loading branch information
jmrossy committed Dec 19, 2023
1 parent 1f1eab0 commit decdf0c
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions typescript/sdk/src/providers/SmartProvider/SmartProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ export class HyperlaneSmartProvider
// Trigger the next provider in line
if (pIndex < providers.length) {
const provider = providers[pIndex];
const providerUrl = provider.getBaseUrl();
const isLastProvider = pIndex === providers.length - 1;

// Skip the explorer provider if it's currently in a cooldown period
Expand All @@ -211,7 +210,7 @@ export class HyperlaneSmartProvider

const resultPromise = this.wrapProviderPerform(
provider,
providerUrl,
pIndex,
method,
params,
reqId,
Expand All @@ -225,15 +224,15 @@ export class HyperlaneSmartProvider
return result.value;
} else if (result.status === ProviderStatus.Timeout) {
this.logger(
`Slow response from provider using ${providerUrl}.${
`Slow response from provider #${pIndex}.${
!isLastProvider ? ' Triggering next provider.' : ''
}`,
);
providerResultPromises.push(resultPromise);
pIndex += 1;
} else if (result.status === ProviderStatus.Error) {
this.logger(
`Error from provider using ${providerUrl}.${
`Error from provider #${pIndex}.${
!isLastProvider ? ' Triggering next provider.' : ''
}`,
);
Expand Down Expand Up @@ -283,22 +282,22 @@ export class HyperlaneSmartProvider
// Warp for additional logging and error handling
protected async wrapProviderPerform(
provider: HyperlaneProvider,
providerUrl: string,
pIndex: number,
method: string,
params: any,
reqId: number,
): Promise<ProviderPerformResult> {
try {
if (this.options?.debug)
this.logger(
`Provider using ${providerUrl} performing method ${method} for reqId ${reqId}`,
`Provider #${pIndex} performing method ${method} for reqId ${reqId}`,
);
const result = await provider.perform(method, params, reqId);
return { status: ProviderStatus.Success, value: result };
} catch (error) {
if (this.options?.debug)
this.logger(
`Error performing ${method} on provider ${providerUrl} for reqId ${reqId}`,
`Error performing ${method} on provider #${pIndex} for reqId ${reqId}`,
error,
);
return { status: ProviderStatus.Error, error };
Expand Down

0 comments on commit decdf0c

Please sign in to comment.