Skip to content

Commit

Permalink
Fix: Catch for no provider
Browse files Browse the repository at this point in the history
  • Loading branch information
arrenv committed Feb 23, 2023
1 parent 1524e0b commit 56ff4c6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 23 deletions.
4 changes: 3 additions & 1 deletion src/modules/dashboard/sagas/utils/safeHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ export const getHomeBridgeByChain = (safeChainId: string) => {
);
}
// @ts-ignore abi type is wrong.
return new ethers.Contract(homeBridgeAddress, HomeAMB, homeSigner);
return homeSigner
? new ethers.Contract(homeBridgeAddress, HomeAMB, homeSigner)
: null;
};

const getErc721 = (
Expand Down
47 changes: 25 additions & 22 deletions src/utils/safes/getTransactionStatuses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,28 +110,31 @@ export const getTransactionStatuses = async (
const homeAMBContract = getHomeBridgeByChain(safeChainId);
const foreignAMBContract = getForeignBridgeByChain(safeChainId);

const messageIds = getMessageIds(
transactionReceipt,
homeAMBContract,
homeAMBContract.address,
);
if (homeAMBContract) {
const messageIds = getMessageIds(
transactionReceipt,
homeAMBContract,
homeAMBContract?.address,
);
const transactionStatuses = await Promise.all(
messageIds.map(async (messageId) => {
const wasTheMessageDelivered = await checkIfTheMessageWasDelivered(
foreignAMBContract,
networkApiURI,
messageId,
safeChainId,
);

// @NOTE: Safe transactions will always be executed automatically on the local env
if (wasTheMessageDelivered || onLocalDevEnvironment) {
return TRANSACTION_STATUS.SUCCESS;
}
return TRANSACTION_STATUS.PENDING;
}),
);

const transactionStatuses = await Promise.all(
messageIds.map(async (messageId) => {
const wasTheMessageDelivered = await checkIfTheMessageWasDelivered(
foreignAMBContract,
networkApiURI,
messageId,
safeChainId,
);

// @NOTE: Safe transactions will always be executed automatically on the local env
if (wasTheMessageDelivered || onLocalDevEnvironment) {
return TRANSACTION_STATUS.SUCCESS;
}
return TRANSACTION_STATUS.PENDING;
}),
);
return transactionStatuses;
}

return transactionStatuses;
return [];
};

0 comments on commit 56ff4c6

Please sign in to comment.