From 295e74c9271f168b5967605c671abb3f98464c5d Mon Sep 17 00:00:00 2001 From: Christopher Howard Date: Mon, 29 Jul 2024 15:55:31 -0400 Subject: [PATCH] feat: use BE explorer values for txs (#1635) --- src/core/types/transactions.ts | 6 ++++++ src/core/utils/transactions.ts | 7 +++++++ src/entries/popup/pages/home/Activity/ActivityDetails.tsx | 4 +++- 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/core/types/transactions.ts b/src/core/types/transactions.ts index 02139e55d0..f1eac7dfbd 100644 --- a/src/core/types/transactions.ts +++ b/src/core/types/transactions.ts @@ -62,6 +62,10 @@ type BaseTransaction = { gasPrice?: string; gasLimit?: string; baseFee?: string; + explorer?: { + name: string; + url: string; + }; } & Partial; export type PendingTransaction = BaseTransaction & { @@ -202,6 +206,8 @@ export type TransactionApiResponse = { approval_to?: Address; contract_name?: string; contract_icon_url?: string; + explorer_label?: string; + explorer_url?: string; type?: TransactionType; action?: string; asset?: AssetApiResponse; diff --git a/src/core/utils/transactions.ts b/src/core/utils/transactions.ts index 88af384509..d97ee277e1 100644 --- a/src/core/utils/transactions.ts +++ b/src/core/utils/transactions.ts @@ -301,6 +301,12 @@ export function parseTransaction({ iconUrl: meta.contract_icon_url, }; + const explorer = meta.explorer_label && + meta.explorer_url && { + name: meta.explorer_label, + url: meta.explorer_url, + }; + return { from: tx.address_from, to: addressTo, @@ -322,6 +328,7 @@ export function parseTransaction({ confirmations: tx.block_confirmations, contract, native, + explorer, ...fee, } as RainbowTransaction; } diff --git a/src/entries/popup/pages/home/Activity/ActivityDetails.tsx b/src/entries/popup/pages/home/Activity/ActivityDetails.tsx index 55a3cde9a4..e66a52b7b2 100644 --- a/src/entries/popup/pages/home/Activity/ActivityDetails.tsx +++ b/src/entries/popup/pages/home/Activity/ActivityDetails.tsx @@ -486,7 +486,9 @@ function MoreOptions({ revoke?: boolean; onRevoke: () => void; }) { - const explorer = getTransactionBlockExplorer(transaction); + const explorer = transaction?.explorer?.name + ? transaction.explorer + : getTransactionBlockExplorer(transaction); const hash = transaction.hash; return (