|
|
@ -195,7 +195,6 @@ export class HyperlaneSmartProvider |
|
|
|
// Trigger the next provider in line
|
|
|
|
// Trigger the next provider in line
|
|
|
|
if (pIndex < providers.length) { |
|
|
|
if (pIndex < providers.length) { |
|
|
|
const provider = providers[pIndex]; |
|
|
|
const provider = providers[pIndex]; |
|
|
|
const providerUrl = provider.getBaseUrl(); |
|
|
|
|
|
|
|
const isLastProvider = pIndex === providers.length - 1; |
|
|
|
const isLastProvider = pIndex === providers.length - 1; |
|
|
|
|
|
|
|
|
|
|
|
// Skip the explorer provider if it's currently in a cooldown period
|
|
|
|
// Skip the explorer provider if it's currently in a cooldown period
|
|
|
@ -211,7 +210,7 @@ export class HyperlaneSmartProvider |
|
|
|
|
|
|
|
|
|
|
|
const resultPromise = this.wrapProviderPerform( |
|
|
|
const resultPromise = this.wrapProviderPerform( |
|
|
|
provider, |
|
|
|
provider, |
|
|
|
providerUrl, |
|
|
|
pIndex, |
|
|
|
method, |
|
|
|
method, |
|
|
|
params, |
|
|
|
params, |
|
|
|
reqId, |
|
|
|
reqId, |
|
|
@ -225,7 +224,7 @@ export class HyperlaneSmartProvider |
|
|
|
return result.value; |
|
|
|
return result.value; |
|
|
|
} else if (result.status === ProviderStatus.Timeout) { |
|
|
|
} else if (result.status === ProviderStatus.Timeout) { |
|
|
|
this.logger( |
|
|
|
this.logger( |
|
|
|
`Slow response from provider using ${providerUrl}.${ |
|
|
|
`Slow response from provider #${pIndex}.${ |
|
|
|
!isLastProvider ? ' Triggering next provider.' : '' |
|
|
|
!isLastProvider ? ' Triggering next provider.' : '' |
|
|
|
}`,
|
|
|
|
}`,
|
|
|
|
); |
|
|
|
); |
|
|
@ -233,7 +232,7 @@ export class HyperlaneSmartProvider |
|
|
|
pIndex += 1; |
|
|
|
pIndex += 1; |
|
|
|
} else if (result.status === ProviderStatus.Error) { |
|
|
|
} else if (result.status === ProviderStatus.Error) { |
|
|
|
this.logger( |
|
|
|
this.logger( |
|
|
|
`Error from provider using ${providerUrl}.${ |
|
|
|
`Error from provider #${pIndex}.${ |
|
|
|
!isLastProvider ? ' Triggering next provider.' : '' |
|
|
|
!isLastProvider ? ' Triggering next provider.' : '' |
|
|
|
}`,
|
|
|
|
}`,
|
|
|
|
); |
|
|
|
); |
|
|
@ -283,22 +282,24 @@ export class HyperlaneSmartProvider |
|
|
|
// Warp for additional logging and error handling
|
|
|
|
// Warp for additional logging and error handling
|
|
|
|
protected async wrapProviderPerform( |
|
|
|
protected async wrapProviderPerform( |
|
|
|
provider: HyperlaneProvider, |
|
|
|
provider: HyperlaneProvider, |
|
|
|
providerUrl: string, |
|
|
|
pIndex: number, |
|
|
|
method: string, |
|
|
|
method: string, |
|
|
|
params: any, |
|
|
|
params: any, |
|
|
|
reqId: number, |
|
|
|
reqId: number, |
|
|
|
): Promise<ProviderPerformResult> { |
|
|
|
): Promise<ProviderPerformResult> { |
|
|
|
try { |
|
|
|
try { |
|
|
|
this.logger( |
|
|
|
if (this.options?.debug) |
|
|
|
`Provider using ${providerUrl} performing method ${method} for reqId ${reqId}`, |
|
|
|
this.logger( |
|
|
|
); |
|
|
|
`Provider #${pIndex} performing method ${method} for reqId ${reqId}`, |
|
|
|
|
|
|
|
); |
|
|
|
const result = await provider.perform(method, params, reqId); |
|
|
|
const result = await provider.perform(method, params, reqId); |
|
|
|
return { status: ProviderStatus.Success, value: result }; |
|
|
|
return { status: ProviderStatus.Success, value: result }; |
|
|
|
} catch (error) { |
|
|
|
} catch (error) { |
|
|
|
this.logger( |
|
|
|
if (this.options?.debug) |
|
|
|
`Error performing ${method} on provider ${providerUrl} for reqId ${reqId}`, |
|
|
|
this.logger( |
|
|
|
error, |
|
|
|
`Error performing ${method} on provider #${pIndex} for reqId ${reqId}`, |
|
|
|
); |
|
|
|
error, |
|
|
|
|
|
|
|
); |
|
|
|
return { status: ProviderStatus.Error, error }; |
|
|
|
return { status: ProviderStatus.Error, error }; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|