Skip to content

Commit

Permalink
Merge pull request #1184 from DarkFlorist/print-error-on-block-proces…
Browse files Browse the repository at this point in the history
…sing-failure

print error if we fail to process a block
  • Loading branch information
KillariDev authored Nov 21, 2024
2 parents 825f46e + c31736a commit 8a8ca75
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
3 changes: 2 additions & 1 deletion app/ts/background/background-startup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ async function newBlockAttemptCallback(blockheader: EthereumBlockHeader, ethereu
}
}

async function onErrorBlockCallback(ethereumClientService: EthereumClientService) {
async function onErrorBlockCallback(ethereumClientService: EthereumClientService, error: unknown) {
try {
const rpcConnectionStatus = {
isConnected: false,
Expand All @@ -206,6 +206,7 @@ async function onErrorBlockCallback(ethereumClientService: EthereumClientService
await setRpcConnectionStatus(rpcConnectionStatus)
await updateExtensionBadge()
await sendPopupMessageToOpenWindows({ method: 'popup_failed_to_get_block', data: { rpcConnectionStatus } })
await handleUnexpectedError(error)
} catch(error) {
await handleUnexpectedError(error)
}
Expand Down
8 changes: 4 additions & 4 deletions app/ts/simulation/services/EthereumClientService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ export class EthereumClientService {
private cacheRefreshTimer: NodeJS.Timer | undefined = undefined
private retrievingBlock = false
private newBlockAttemptCallback: (blockHeader: EthereumBlockHeader, ethereumClientService: EthereumClientService, isNewBlock: boolean) => Promise<void>
private onErrorBlockCallback: (ethereumClientService: EthereumClientService) => Promise<void>
private onErrorBlockCallback: (ethereumClientService: EthereumClientService, error: unknown) => Promise<void>
private requestHandler
private rpcEntry

constructor(requestHandler: IEthereumJSONRpcRequestHandler, newBlockAttemptCallback: (blockHeader: EthereumBlockHeader, ethereumClientService: EthereumClientService, isNewBlock: boolean) => Promise<void>, onErrorBlockCallback: (ethereumClientService: EthereumClientService) => Promise<void>, rpcEntry: RpcEntry) {
constructor(requestHandler: IEthereumJSONRpcRequestHandler, newBlockAttemptCallback: (blockHeader: EthereumBlockHeader, ethereumClientService: EthereumClientService, isNewBlock: boolean) => Promise<void>, onErrorBlockCallback: (ethereumClientService: EthereumClientService, error: unknown) => Promise<void>, rpcEntry: RpcEntry) {
this.requestHandler = requestHandler
this.newBlockAttemptCallback = newBlockAttemptCallback
this.onErrorBlockCallback = onErrorBlockCallback
Expand Down Expand Up @@ -80,8 +80,8 @@ export class EthereumClientService {
if (gotNewBlock) this.requestHandler.clearCache()
this.newBlockAttemptCallback(newBlock, this, gotNewBlock)
this.cachedBlock = newBlock
} catch(error) {
return this.onErrorBlockCallback(this)
} catch(error: unknown) {
return this.onErrorBlockCallback(this, error)
} finally {
this.retrievingBlock = false
}
Expand Down
4 changes: 2 additions & 2 deletions app/ts/simulation/simulator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export const parseInputData = async (transaction: { to: EthereumAddress | undefi
return { paramName, typeValue: parseSolidityValueByTypePure(verifiedSolidityType.value, value, isArray) }
})
return {
input: transaction.input,
input: transaction.input,
type: 'Parsed' as const,
name: parsed.name,
args: valuesWithTypes,
Expand Down Expand Up @@ -208,7 +208,7 @@ export class Simulator {
public ethereum: EthereumClientService
public tokenPriceService: TokenPriceService
private newBlockAttemptCallback: NewBlockCallBack
public constructor(rpcNetwork: RpcEntry, newBlockAttemptCallback: NewBlockCallBack, onErrorBlockCallback: (ethereumClientService: EthereumClientService) => Promise<void>, tokenPriceCacheAge = 60000) {
public constructor(rpcNetwork: RpcEntry, newBlockAttemptCallback: NewBlockCallBack, onErrorBlockCallback: (ethereumClientService: EthereumClientService, error: unknown) => Promise<void>, tokenPriceCacheAge = 60000) {
this.newBlockAttemptCallback = newBlockAttemptCallback
this.ethereum = new EthereumClientService(
new EthereumJSONRpcRequestHandler(rpcNetwork.httpsRpc, true),
Expand Down

0 comments on commit 8a8ca75

Please sign in to comment.