Skip to content

Commit

Permalink
fix: missing Transaction type
Browse files Browse the repository at this point in the history
  • Loading branch information
leonimella committed Jan 28, 2025
1 parent 4c28bd4 commit b181f50
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 42 deletions.
35 changes: 12 additions & 23 deletions mocks/txs/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ import * as decodedInputDataMock from 'mocks/txs/decodedInputData';
export const base: Transaction = {
base_fee_per_gas: '10000000000',
block: 29611750,
confirmation_duration: [
0,
6364,
],
confirmation_duration: [ 0, 6364 ],
confirmations: 508299,
created_contract: null,
decoded_input: decodedInputDataMock.withoutIndexedFields,
Expand All @@ -26,7 +23,7 @@ export const base: Transaction = {
is_contract: false,
name: null,
is_verified: null,
private_tags: [ ],
private_tags: [],
public_tags: [ publicTag ],
watchlist_names: [],
ens_domain_name: 'kitty.kitty.cat.eth',
Expand All @@ -42,7 +39,8 @@ export const base: Transaction = {
nonce: 27831,
position: 7,
priority_fee: '1299672384375000',
raw_input: '0xfa4b78b90000000000000000000000000000000000000000000000000000000005001bcfe835d1028984e9e6e7d016b77164eacbcc6cc061e9333c0b37982b504f7ea791000000000000000000000000a79b29ad7e0196c95b87f4663ded82fbf2e3add8',
raw_input:
'0xfa4b78b90000000000000000000000000000000000000000000000000000000005001bcfe835d1028984e9e6e7d016b77164eacbcc6cc061e9333c0b37982b504f7ea791000000000000000000000000a79b29ad7e0196c95b87f4663ded82fbf2e3add8',
result: 'success',
revert_reason: null,
status: 'ok',
Expand All @@ -62,9 +60,7 @@ export const base: Transaction = {
token_transfers_overflow: false,
tx_burnt_fee: '461030000000000',
tx_tag: null,
tx_types: [
'contract_call',
],
tx_types: [ 'contract_call' ],
type: 2,
value: '42000000000000000000',
actions: [],
Expand Down Expand Up @@ -102,9 +98,7 @@ export const withContractCreation: Transaction = {
watchlist_names: [],
ens_domain_name: null,
},
tx_types: [
'contract_creation',
],
tx_types: [ 'contract_creation' ],
};

export const withTokenTransfer: Transaction = {
Expand All @@ -130,9 +124,7 @@ export const withTokenTransfer: Transaction = {
tokenTransferMock.erc1155D,
],
token_transfers_overflow: true,
tx_types: [
'token_transfer',
],
tx_types: [ 'token_transfer' ],
};

export const withDecodedRevertReason: Transaction = {
Expand Down Expand Up @@ -170,9 +162,9 @@ export const withRawRevertReason: Transaction = {
is_verified: true,
is_contract: true,
name: 'Bad guy',
private_tags: [ ],
private_tags: [],
public_tags: [],
watchlist_names: [ ],
watchlist_names: [],
ens_domain_name: null,
},
};
Expand Down Expand Up @@ -209,7 +201,8 @@ export const withActionsUniswap: Transaction = {
address1: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6',
amount0: '7143.488560357232097378',
amount1: '10',
symbol0: 'Ring ding ding daa baa Baa aramba baa bom baa barooumba Wh-wha-what's going on-on? Ding, ding This is the Crazy Frog Ding, ding Bem',
symbol0:
'Ring ding ding daa baa Baa aramba baa bom baa barooumba Wh-wha-what's going on-on? Ding, ding This is the Crazy Frog Ding, ding Bem',
symbol1: 'Ether',
},
protocol: 'uniswap_v3',
Expand All @@ -218,11 +211,7 @@ export const withActionsUniswap: Transaction = {
{
data: {
address: '0xC36442b4a4522E871399CD717aBDD847Ab11FE88',
ids: [
'53699',
'53700123456',
'42',
],
ids: [ '53699', '53700123456', '42' ],
name: 'Uniswap V3: Positions NFT',
symbol: 'UNI-V3-POS',
to: '0x6d872Fb5F5B2B1f71fA9AadE159bc3976c1946B7',
Expand Down
9 changes: 2 additions & 7 deletions stubs/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,7 @@ export const TX: Transaction = {
base_fee_per_gas: '24',
from: ADDRESS_PARAMS,
token_transfers: null,
tx_types: [
'coin_transfer',
],
tx_types: [ 'coin_transfer' ],
gas_used: '21000',
created_contract: null,
position: 0,
Expand All @@ -44,10 +42,7 @@ export const TX: Transaction = {
value: '42000420000000000000',
max_priority_fee_per_gas: null,
revert_reason: null,
confirmation_duration: [
0,
14545,
],
confirmation_duration: [ 0, 14545 ],
tx_tag: null,
};

Expand Down
2 changes: 1 addition & 1 deletion types/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export type Transaction = {
max_fee_per_blob_gas?: string;
shard_id?: string;
to_shard_id?: string;
claimed_reward: string | null;
claimed_reward?: string;
delegated_amount?: string;
undelegated_amount?: string;
};
Expand Down
29 changes: 18 additions & 11 deletions ui/block/useBlockTxsQuery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,13 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
pathParams: { height_or_hash: heightOrHash },
options: {
enabled: Boolean(tab === 'txs' && !blockQuery.isPlaceholderData && !blockQuery.isDegradedData),
placeholderData: generateListStub<'block_txs'>(TX, 50, { next_page_params: {
block_number: 9004925,
index: 49,
items_count: 50,
} }),
placeholderData: generateListStub<'block_txs'>(TX, 50, {
next_page_params: {
block_number: 9004925,
index: 49,
items_count: 50,
},
}),
refetchOnMount: false,
retry: (failureCount, error) => {
if (isRefetchEnabled) {
Expand Down Expand Up @@ -129,7 +131,10 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
};
},
placeholderData: GET_BLOCK_WITH_TRANSACTIONS,
enabled: publicClient !== undefined && tab === 'txs' && (blockQuery.isDegradedData || apiQuery.isError || apiQuery.errorUpdateCount > 0),
enabled:
publicClient !== undefined &&
tab === 'txs' &&
(blockQuery.isDegradedData || apiQuery.isError || apiQuery.errorUpdateCount > 0),
retry: false,
refetchOnMount: false,
});
Expand All @@ -152,14 +157,16 @@ export default function useBlockTxsQuery({ heightOrHash, blockQuery, tab }: Para
}
}, [ rpcQuery.data, rpcQuery.isPlaceholderData ]);

const isRpcQuery = Boolean((
blockQuery.isDegradedData ||
((apiQuery.isError || apiQuery.isPlaceholderData) && apiQuery.errorUpdateCount > 0)
) && rpcQuery.data && publicClient);
const isRpcQuery = Boolean(
(blockQuery.isDegradedData ||
((apiQuery.isError || apiQuery.isPlaceholderData) && apiQuery.errorUpdateCount > 0)) &&
rpcQuery.data &&
publicClient,
);

const rpcQueryWithPages: QueryWithPagesResult<'block_txs'> = React.useMemo(() => {
return {
...rpcQuery as UseQueryResult<BlockTransactionsResponse, ResourceError>,
...(rpcQuery as UseQueryResult<BlockTransactionsResponse, ResourceError>),
pagination: emptyPagination,
onFilterChange: () => {},
onSortingChange: () => {},
Expand Down

0 comments on commit b181f50

Please sign in to comment.