Skip to content

Commit

Permalink
Bind to full prop namings in API v2 endpoints, pt. 2
Browse files Browse the repository at this point in the history
  • Loading branch information
tom2drum committed Nov 27, 2024
1 parent fb1e3bf commit 05de412
Show file tree
Hide file tree
Showing 17 changed files with 60 additions and 50 deletions.
2 changes: 1 addition & 1 deletion mocks/txs/internalTxs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { InternalTransaction, InternalTransactionsResponse } from 'types/api/internalTransaction';

export const base: InternalTransaction = {
block: 29611822,
block_number: 29611822,
created_contract: null,
error: null,
from: {
Expand Down
18 changes: 9 additions & 9 deletions mocks/txs/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import * as decodedInputDataMock from 'mocks/txs/decodedInputData';

export const base: Transaction = {
base_fee_per_gas: '10000000000',
block: 29611750,
block_number: 29611750,
confirmation_duration: [
0,
6364,
Expand Down Expand Up @@ -61,14 +61,14 @@ export const base: Transaction = {
token_transfers: [],
token_transfers_overflow: false,
tx_burnt_fee: '461030000000000',
tx_tag: null,
tx_types: [
transaction_tag: null,
transaction_types: [
'contract_call',
],
type: 2,
value: '42000000000000000000',
actions: [],
has_error_in_internal_txs: false,
has_error_in_internal_transactions: false,
};

export const withWatchListNames: Transaction = {
Expand Down Expand Up @@ -102,7 +102,7 @@ export const withContractCreation: Transaction = {
watchlist_names: [],
ens_domain_name: null,
},
tx_types: [
transaction_types: [
'contract_creation',
],
};
Expand Down Expand Up @@ -132,7 +132,7 @@ export const withTokenTransfer: Transaction = {
tokenTransferMock.erc404B,
],
token_transfers_overflow: true,
tx_types: [
transaction_types: [
'token_transfer',
],
};
Expand Down Expand Up @@ -182,7 +182,7 @@ export const withRawRevertReason: Transaction = {
export const pending: Transaction = {
...base,
base_fee_per_gas: null,
block: null,
block_number: null,
confirmation_duration: [],
confirmations: 0,
decoded_input: null,
Expand All @@ -197,7 +197,7 @@ export const pending: Transaction = {
status: null,
timestamp: null,
tx_burnt_fee: null,
tx_tag: null,
transaction_tag: null,
type: null,
value: '0',
};
Expand Down Expand Up @@ -373,7 +373,7 @@ export const withBlob = {
],
burnt_blob_fee: '2820464441688064',
max_fee_per_blob_gas: '60000000000',
tx_types: [ 'blob_transaction' as const ],
transaction_types: [ 'blob_transaction' as const ],
type: 3,
};

Expand Down
2 changes: 1 addition & 1 deletion stubs/internalTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ADDRESS_PARAMS } from './addressParams';
import { TX_HASH } from './tx';

export const INTERNAL_TX: InternalTransaction = {
block: 9006105,
block_number: 9006105,
created_contract: null,
error: null,
from: ADDRESS_PARAMS,
Expand Down
8 changes: 4 additions & 4 deletions stubs/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const TX: Transaction = {
value: '2100000000000000',
},
gas_limit: '21000',
block: 9004925,
block_number: 9004925,
status: 'ok',
method: 'placeholder',
confirmations: 71,
Expand All @@ -28,14 +28,14 @@ export const TX: Transaction = {
base_fee_per_gas: '24',
from: ADDRESS_PARAMS,
token_transfers: null,
tx_types: [
transaction_types: [
'coin_transfer',
],
gas_used: '21000',
created_contract: null,
position: 0,
nonce: 295929,
has_error_in_internal_txs: false,
has_error_in_internal_transactions: false,
actions: [],
decoded_input: null,
token_transfers_overflow: false,
Expand All @@ -47,7 +47,7 @@ export const TX: Transaction = {
0,
14545,
],
tx_tag: null,
transaction_tag: null,
};

export const TX_ZKEVM_L2: Transaction = {
Expand Down
2 changes: 1 addition & 1 deletion types/api/internalTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type InternalTransaction = (
from: AddressParam;
value: string;
index: number;
block: number;
block_number: number;
timestamp: string;
gas_limit: string;
};
Expand Down
8 changes: 4 additions & 4 deletions types/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export type Transaction = {
result: string;
confirmations: number;
status: 'ok' | 'error' | null | undefined;
block: number | null;
block_number: number | null;
timestamp: string | null;
confirmation_duration: Array<number> | null;
from: AddressParam;
Expand All @@ -54,14 +54,14 @@ export type Transaction = {
token_transfers_overflow: boolean;
exchange_rate: string | null;
method: string | null;
tx_types: Array<TransactionType>;
tx_tag: string | null;
transaction_types: Array<TransactionType>;
transaction_tag: string | null;
actions: Array<TxAction>;
l1_fee?: string;
l1_fee_scalar?: string;
l1_gas_price?: string;
l1_gas_used?: string;
has_error_in_internal_txs: boolean | null;
has_error_in_internal_transactions: boolean | null;
// optimism fields
op_withdrawals?: Array<OpWithdrawal>;
// SUAVE fields
Expand Down
4 changes: 2 additions & 2 deletions ui/address/internals/AddressIntTxsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const TxInternalsListItem = ({
error,
created_contract: createdContract,
transaction_hash: txnHash,
block,
block_number: blockNumber,
timestamp,
currentAddress,
isLoading,
Expand Down Expand Up @@ -59,7 +59,7 @@ const TxInternalsListItem = ({
<Skeleton isLoaded={ !isLoading } fontSize="sm" fontWeight={ 500 }>Block</Skeleton>
<BlockEntity
isLoading={ isLoading }
number={ block }
number={ blockNumber }
noIcon
fontSize="sm"
lineHeight={ 5 }
Expand Down
4 changes: 2 additions & 2 deletions ui/address/internals/AddressIntTxsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const AddressIntTxsTableItem = ({
error,
created_contract: createdContract,
transaction_hash: txnHash,
block,
block_number: blockNumber,
timestamp,
currentAddress,
isLoading,
Expand Down Expand Up @@ -66,7 +66,7 @@ const AddressIntTxsTableItem = ({
<Td verticalAlign="middle">
<BlockEntity
isLoading={ isLoading }
number={ block }
number={ blockNumber }
noIcon
fontSize="sm"
lineHeight={ 5 }
Expand Down
8 changes: 4 additions & 4 deletions ui/block/useBlockTxsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
timestamp: block?.timestamp ? dayjs.unix(Number(block.timestamp)).format() : null,
confirmation_duration: null,
status: undefined,
block: Number(block.number),
block_number: Number(block.number),
value: tx.value.toString(),
gas_price: tx.gasPrice?.toString() ?? null,
base_fee_per_gas: block?.baseFeePerGas?.toString() ?? null,
Expand All @@ -114,13 +114,13 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
tx_burnt_fee: null,
revert_reason: null,
decoded_input: null,
has_error_in_internal_txs: null,
has_error_in_internal_transactions: null,
token_transfers: null,
token_transfers_overflow: false,
exchange_rate: null,
method: null,
tx_types: [],
tx_tag: null,
transaction_types: [],
transaction_tag: null,
actions: [],
};
})
Expand Down
2 changes: 1 addition & 1 deletion ui/home/LatestTxsItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
<TxAdditionalInfo tx={ tx } isLoading={ isLoading } my="3px"/>
<Box ml={ 3 } w="calc(100% - 40px)">
<HStack flexWrap="wrap" my="3px">
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
<TxType types={ tx.transaction_types } isLoading={ isLoading }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
</HStack>
Expand Down
2 changes: 1 addition & 1 deletion ui/home/LatestTxsItemMobile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const LatestTxsItem = ({ tx, isLoading }: Props) => {
>
<Flex justifyContent="space-between">
<HStack flexWrap="wrap">
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
<TxType types={ tx.transaction_types } isLoading={ isLoading }/>
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
</HStack>
Expand Down
4 changes: 2 additions & 2 deletions ui/pages/Transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ const TransactionPageContent = () => {
const tags = (
<EntityTags
isLoading={ isPlaceholderData }
tags={ data?.tx_tag ? [ { slug: data.tx_tag, name: data.tx_tag, tagType: 'private_tag' as const } ] : [] }
tags={ data?.transaction_tag ? [ { slug: data.transaction_tag, name: data.transaction_tag, tagType: 'private_tag' as const } ] : [] }
/>
);

Expand All @@ -94,7 +94,7 @@ const TransactionPageContent = () => {
};
}, [ appProps.referrer ]);

const titleSecondRow = <TxSubHeading hash={ hash } hasTag={ Boolean(data?.tx_tag) } txQuery={ txQuery }/>;
const titleSecondRow = <TxSubHeading hash={ hash } hasTag={ Boolean(data?.transaction_tag) } txQuery={ txQuery }/>;

const content = (() => {
if (isPlaceholderData && !showDegradedView) {
Expand Down
2 changes: 1 addition & 1 deletion ui/shared/AccountActionsMenu/items/PrivateTagMenuItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ const PrivateTagMenuItem = ({ className, hash, entityType = 'address', type }: P
queryData &&
(
('private_tags' in queryData && queryData.private_tags?.length) ||
('tx_tag' in queryData && queryData.tx_tag)
('transaction_tag' in queryData && queryData.transaction_tag)
)
) {
return null;
Expand Down
8 changes: 4 additions & 4 deletions ui/tx/TxDetailsDegraded.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const TxDetailsDegraded = ({ hash, txQuery }: Props) => {
timestamp: block?.timestamp ? dayjs.unix(Number(block.timestamp)).format() : null,
confirmation_duration: null,
status,
block: tx.blockNumber ? Number(tx.blockNumber) : null,
block_number: tx.blockNumber ? Number(tx.blockNumber) : null,
value: tx.value.toString(),
gas_price: gasPrice?.toString() ?? null,
base_fee_per_gas: block?.baseFeePerGas?.toString() ?? null,
Expand All @@ -106,13 +106,13 @@ const TxDetailsDegraded = ({ hash, txQuery }: Props) => {
tx_burnt_fee: null,
revert_reason: null,
decoded_input: null,
has_error_in_internal_txs: null,
has_error_in_internal_transactions: null,
token_transfers: null,
token_transfers_overflow: false,
exchange_rate: null,
method: null,
tx_types: [],
tx_tag: null,
transaction_types: [],
transaction_tag: null,
actions: [],
};
},
Expand Down
4 changes: 2 additions & 2 deletions ui/tx/details/TxInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -282,11 +282,11 @@ const TxInfo = ({ data, isLoading, socketStatus }: Props) => {
Block
</DetailsInfoItem.Label>
<DetailsInfoItem.Value>
{ data.block === null ?
{ data.block_number === null ?
<Text>Pending</Text> : (
<BlockEntity
isLoading={ isLoading }
number={ data.block }
number={ data.block_number }
noIcon
/>
) }
Expand Down
17 changes: 11 additions & 6 deletions ui/txs/TxsListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,14 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
<ListItemMobile display="block" width="100%" isAnimated key={ tx.hash }>
<Flex justifyContent="space-between" mt={ 4 }>
<HStack flexWrap="wrap">
{ tx.translation ?
<TxTranslationType types={ tx.tx_types } isLoading={ isLoading || tx.translation.isLoading } translatationType={ tx.translation.data?.type }/> :
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
{ tx.translation ? (
<TxTranslationType
types={ tx.transaction_types }
isLoading={ isLoading || tx.translation.isLoading }
translatationType={ tx.translation.data?.type }
/>
) :
<TxType types={ tx.transaction_types } isLoading={ isLoading }/>
}
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
Expand All @@ -55,7 +60,7 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
truncation="constant_long"
fontWeight="700"
icon={{
name: tx.tx_types.includes('blob_transaction') ? 'blob' : undefined,
name: tx.transaction_types.includes('blob_transaction') ? 'blob' : undefined,
}}
/>
<TimeAgoWithTooltip
Expand All @@ -81,12 +86,12 @@ const TxsListItem = ({ tx, isLoading, showBlockInfo, currentAddress, enableTimeI
</Skeleton>
</Flex>
) }
{ showBlockInfo && tx.block !== null && (
{ showBlockInfo && tx.block_number !== null && (
<Flex mt={ 2 }>
<Skeleton isLoaded={ !isLoading } display="inline-block" whiteSpace="pre">Block </Skeleton>
<BlockEntity
isLoading={ isLoading }
number={ tx.block }
number={ tx.block_number }
noIcon
/>
</Flex>
Expand Down
15 changes: 10 additions & 5 deletions ui/txs/TxsTableItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,14 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
</Td>
<Td>
<VStack alignItems="start">
{ tx.translation ?
<TxTranslationType types={ tx.tx_types } isLoading={ isLoading || tx.translation.isLoading } translatationType={ tx.translation.data?.type }/> :
<TxType types={ tx.tx_types } isLoading={ isLoading }/>
{ tx.translation ? (
<TxTranslationType
types={ tx.transaction_types }
isLoading={ isLoading || tx.translation.isLoading }
translatationType={ tx.translation.data?.type }
/>
) :
<TxType types={ tx.transaction_types } isLoading={ isLoading }/>
}
<TxStatus status={ tx.status } errorText={ tx.status === 'error' ? tx.result : undefined } isLoading={ isLoading }/>
<TxWatchListTags tx={ tx } isLoading={ isLoading }/>
Expand All @@ -84,10 +89,10 @@ const TxsTableItem = ({ tx, showBlockInfo, currentAddress, enableTimeIncrement,
</Td>
{ showBlockInfo && (
<Td>
{ tx.block && (
{ tx.block_number && (
<BlockEntity
isLoading={ isLoading }
number={ tx.block }
number={ tx.block_number }
noIcon
fontSize="sm"
lineHeight={ 6 }
Expand Down

0 comments on commit 05de412

Please sign in to comment.