Skip to content

Commit

Permalink
Show multiple signers, if they are present
Browse files Browse the repository at this point in the history
For now, we also want to be compatible with the previous
versions of the API, so besides `tx.signers[]``, we
will also look at `tx.sender_0` and `tx.sender_0_eth`.
  • Loading branch information
csillag committed Jan 21, 2025
1 parent da46f7d commit 7596be3
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 11 deletions.
1 change: 1 addition & 0 deletions .changelog/1705.trivial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for displaying multiple signers of runtime transactions
3 changes: 2 additions & 1 deletion src/app/components/Account/ContractCreatorInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ const TxSender: FC<{ scope: SearchScope; txHash: string; alwaysTrim?: boolean }>
}
const query = useGetRuntimeTransactionsTxHash(scope.network, scope.layer, txHash)
const tx = query.data?.data.transactions[0]
const senderAddress = tx?.sender_0_eth || tx?.sender_0
const senderAddress =
tx?.signers?.[0].address_eth ?? tx?.sender_0_eth ?? tx?.signers?.[0].address ?? tx?.sender_0

return query.isLoading ? (
<Skeleton
Expand Down
10 changes: 8 additions & 2 deletions src/app/components/Transactions/RuntimeTransactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,16 @@ export const RuntimeTransactions: FC<TransactionsProps> = ({
<AccountLink
labelOnly={
!!ownAddress &&
(transaction.sender_0_eth === ownAddress || transaction.sender_0 === ownAddress)
((transaction.signers?.[0]?.address_eth ?? transaction.sender_0_eth) === ownAddress ||
(transaction.signers?.[0]?.address ?? transaction.sender_0) === ownAddress)
}
scope={transaction}
address={transaction.sender_0_eth || transaction.sender_0}
address={
transaction.signers?.[0]?.address_eth ??
transaction.sender_0_eth ??
transaction.signers?.[0]?.address ??
transaction.sender_0
}
alwaysTrim
/>
{targetAddress && <TransferIcon />}
Expand Down
42 changes: 34 additions & 8 deletions src/app/pages/RuntimeTransactionDetailPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,13 @@ export const RuntimeTransactionDetailPage: FC = () => {
tokenPrices={tokenPrices}
/>
</SubPageCard>
<DappBanner scope={scope} ethAddress={transaction?.sender_0_eth} />
{transaction?.signers ? (
(transaction?.signers ?? []).map((signer, index) => (
<DappBanner key={`signer-${index}`} scope={scope} ethAddress={signer.address_eth} />
))
) : (
<DappBanner scope={scope} ethAddress={transaction?.sender_0_eth} />
)}
<DappBanner scope={scope} ethAddress={transaction?.to_eth} />
{transaction && (
<SubPageCard title={t('common.events')}>
Expand Down Expand Up @@ -161,15 +167,35 @@ export const RuntimeTransactionDetailView: FC<{
<dt>{t('common.timestamp')}</dt>
<dd>{formattedTimestamp}</dd>

{(transaction?.sender_0 || transaction?.sender_0_eth) && (
{(!!transaction?.signers?.length || !!transaction?.sender_0_eth || !!transaction?.sender_0) && (
<>
<dt>{t('common.from')}</dt>
<dd>
<AccountLink
scope={transaction}
address={(transaction?.sender_0_eth ?? transaction?.sender_0) as string}
/>
<CopyToClipboard value={transaction?.sender_0_eth ?? transaction?.sender_0} />
<dd
style={{
display: 'block',
}}
>
{transaction?.signers ? (
(transaction?.signers ?? []).map((signer, index) => (
<>
<AccountLink
key={`signer-${index}`}
scope={transaction}
address={(signer.address_eth ?? signer.address) as string}
/>
<CopyToClipboard value={signer.address_eth ?? signer.address} />
<br />
</>
))
) : (
<>
<AccountLink
scope={transaction}
address={(transaction?.sender_0_eth ?? transaction?.sender_0_eth) as string}
/>
<CopyToClipboard value={transaction?.sender_0_eth ?? transaction?.sender_0} />
</>
)}
</dd>
</>
)}
Expand Down

0 comments on commit 7596be3

Please sign in to comment.