Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noves integration #1398

Merged
merged 38 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
5947511
noves integration
juanlenoves Dec 6, 2023
96e2def
code refactored
NahuelNoves Dec 31, 2023
df51e51
Merge branch 'main' into noves
NahuelNoves Jan 16, 2024
18230d4
Merge main into noves - pull changes from blockscout
NahuelNoves Jan 16, 2024
0fca6be
PR changes added
NahuelNoves Jan 30, 2024
e29e77b
Code set up for new proxy 'describeTxs'
NahuelNoves Feb 2, 2024
8c4a911
minor fix
NahuelNoves Feb 2, 2024
8f4b695
Merge branch 'main' into noves
NahuelNoves Feb 6, 2024
6a7a1ba
Rename Novestranslate.ts to NovesTranslate.ts
juanlenoves Feb 8, 2024
e03304a
some quick stuff
juanlenoves Feb 8, 2024
32b7cf5
Merge branch 'main' into noves
juanlenoves Feb 8, 2024
0875d00
partial fixes and commit for changing how useDescribeTxs and txsConte…
juanlenoves Feb 9, 2024
67f9821
Pending PR fixes
NahuelNoves Feb 12, 2024
ba04f7b
tx asset flows pageSize of 50
juanlenoves Feb 12, 2024
d857327
PR comments fixes
NahuelNoves Feb 17, 2024
2dc925d
rename expected api endpoint for the describe_txs endpoint, more accu…
juanlenoves Feb 18, 2024
926ed8b
one final re-name for api endpoint (make it clear it's an object vs a…
juanlenoves Feb 18, 2024
8d66a3e
scrollRef fix
NahuelNoves Feb 20, 2024
830665a
Merge branch 'main' into noves
NahuelNoves Feb 20, 2024
85b006a
build error fix
NahuelNoves Feb 23, 2024
b68a924
design fixes
NahuelNoves Mar 3, 2024
bac02c0
Merge branch 'main' into noves
NahuelNoves Mar 3, 2024
fe5875f
sub heading fix
NahuelNoves Mar 3, 2024
ad72727
Removed pagination in account history
francisco-noves Mar 5, 2024
b0a21ac
remove duplicate route
juanlenoves Mar 6, 2024
79e7316
updated table theme and icon gap
francisco-noves Mar 7, 2024
48cf473
Removed wrong color in table
francisco-noves Mar 7, 2024
9aeb7d6
removed null validation in page params
francisco-noves Mar 8, 2024
301ff00
updated margin
francisco-noves Mar 11, 2024
674f102
margin fix
NahuelNoves Mar 12, 2024
3c288c6
Merge branch 'main' into noves
NahuelNoves Mar 12, 2024
fd3dfa7
add icons to contracts
NahuelNoves Mar 13, 2024
aa7bd83
Sub-heading interpretation simplified
NahuelNoves Mar 20, 2024
fd90cf1
token alignment fix
NahuelNoves Mar 20, 2024
cb0d8e7
tests added for new functions
NahuelNoves Mar 20, 2024
d19d1f3
Merge branch 'main' into noves
NahuelNoves Mar 20, 2024
0c74939
margin fix
NahuelNoves Mar 20, 2024
b18f25d
remove divider on mobile asset flows
NahuelNoves Mar 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion deploy/values/review/values.yaml.gotmpl
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ frontend:
NEXT_PUBLIC_HAS_USER_OPS: true
NEXT_PUBLIC_CONTRACT_CODE_IDES: "[{'title':'Remix IDE','url':'https://remix.blockscout.com/?address={hash}&blockscout=eth-goerli.blockscout.com','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]"
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER: noves
NEXT_PUBLIC_SWAP_BUTTON_URL: uniswap
NEXT_PUBLIC_HAS_CONTRACT_AUDIT_REPORTS: true
envFromSecret:
NEXT_PUBLIC_SENTRY_DSN: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_SENTRY_DSN
SENTRY_CSP_REPORT_URI: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/SENTRY_CSP_REPORT_URI
Expand All @@ -88,4 +90,3 @@ frontend:
FAVICON_GENERATOR_API_KEY: ref+vault://deployment-values/blockscout/common?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_FAVICON_GENERATOR_API_KEY
NEXT_PUBLIC_GROWTH_BOOK_CLIENT_KEY: ref+vault://deployment-values/blockscout/dev/review?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_GROWTH_BOOK_CLIENT_KEY
NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN: ref+vault://deployment-values/blockscout/common?token_env=VAULT_TOKEN&address=https://vault.k8s.blockscout.com#/NEXT_PUBLIC_MIXPANEL_PROJECT_TOKEN

2 changes: 1 addition & 1 deletion icons/gas_xl.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 33 additions & 9 deletions lib/api/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,13 @@ import type { IndexingStatus } from 'types/api/indexingStatus';
import type { InternalTransactionsResponse } from 'types/api/internalTransaction';
import type { LogsResponseTx, LogsResponseAddress } from 'types/api/log';
import type { NovesAccountHistoryResponse, NovesDescribeTxsResponse, NovesResponseData } from 'types/api/noves';
import type {
OptimisticL2DepositsResponse,
OptimisticL2DepositsItem,
OptimisticL2OutputRootsResponse,
OptimisticL2TxnBatchesResponse,
OptimisticL2WithdrawalsResponse,
} from 'types/api/optimisticL2';
import type { RawTracesResponse } from 'types/api/rawTrace';
import type { SearchRedirectResult, SearchResult, SearchResultFilters, SearchResultItem } from 'types/api/search';
import type { ShibariumWithdrawalsResponse, ShibariumDepositsResponse } from 'types/api/shibarium';
Expand Down Expand Up @@ -93,17 +100,14 @@ import type { ArrayElement } from 'types/utils';

import config from 'configs/app';

export interface QueryParamArray {
key: string;
type: 'array';
}
const marketplaceFeature = getFeaturePayload(config.features.marketplace);
const marketplaceApi = marketplaceFeature && 'api' in marketplaceFeature ? marketplaceFeature.api : undefined;

export interface ApiResource {
path: ResourcePath;
endpoint?: string;
basePath?: string;
pathParams?: Array<string>;
queryParams?: Array<string | QueryParamArray>;
needAuth?: boolean; // for external APIs which require authentication
headers?: RequestInit['headers'];
}
Expand Down Expand Up @@ -617,6 +621,25 @@ export const RESOURCES = {
filterFields: [],
},

// SHIBARIUM L2
shibarium_deposits: {
path: '/api/v2/shibarium/deposits',
filterFields: [],
},

shibarium_deposits_count: {
path: '/api/v2/shibarium/deposits/count',
},

shibarium_withdrawals: {
path: '/api/v2/shibarium/withdrawals',
filterFields: [],
},

shibarium_withdrawals_count: {
path: '/api/v2/shibarium/withdrawals/count',
},

// NOVES-FI
noves_transaction: {
path: '/api/v2/proxy/noves-fi/transactions/:hash',
Expand All @@ -630,6 +653,7 @@ export const RESOURCES = {
noves_describe_txs: {
path: '/api/v2/proxy/noves-fi/transaction-descriptions',
},

// USER OPS
user_ops: {
path: '/api/v2/proxy/account-abstraction/operations',
Expand Down Expand Up @@ -728,7 +752,7 @@ export type PaginatedResources = 'blocks' | 'block_txs' |
'zkevm_l2_txn_batches' | 'zkevm_l2_txn_batch_txs' |
'withdrawals' | 'address_withdrawals' | 'block_withdrawals' |
'watchlist' | 'private_tags_address' | 'private_tags_tx' |
'domains_lookup' | 'addresses_lookup' | 'user_ops' | 'noves_address_history';
'domains_lookup' | 'addresses_lookup' | 'user_ops' | 'validators' | 'noves_address_history';

export type PaginatedResponse<Q extends PaginatedResources> = ResourcePayload<Q>;

Expand Down Expand Up @@ -830,9 +854,6 @@ Q extends 'zkevm_l2_txn_batches_count' ? number :
Q extends 'zkevm_l2_txn_batch' ? ZkEvmL2TxnBatch :
Q extends 'zkevm_l2_txn_batch_txs' ? ZkEvmL2TxnBatchTxs :
Q extends 'config_backend_version' ? BackendVersionConfig :
Q extends 'noves_transaction' ? NovesResponseData :
Q extends 'noves_address_history' ? NovesAccountHistoryResponse :
Q extends 'noves_describe_txs' ? NovesDescribeTxsResponse :
Q extends 'addresses_lookup' ? EnsAddressLookupResponse :
Q extends 'domain_info' ? EnsDomainDetailed :
Q extends 'domain_events' ? EnsDomainEventsResponse :
Expand All @@ -856,6 +877,9 @@ Q extends 'shibarium_deposits' ? ShibariumDepositsResponse :
Q extends 'shibarium_withdrawals_count' ? number :
Q extends 'shibarium_deposits_count' ? number :
Q extends 'contract_security_audits' ? SmartContractSecurityAudits :
Q extends 'noves_transaction' ? NovesResponseData :
Q extends 'noves_address_history' ? NovesAccountHistoryResponse :
Q extends 'noves_describe_txs' ? NovesDescribeTxsResponse :
never;
/* eslint-enable @typescript-eslint/indent */

Expand Down
1 change: 1 addition & 0 deletions nextjs/nextjs-routes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ declare module "nextjs-routes" {
| StaticRoute<"/login">
| StaticRoute<"/name-domains">
| DynamicRoute<"/name-domains/[name]", { "name": string }>
| StaticRoute<"/name-domains">
juanlenoves marked this conversation as resolved.
Show resolved Hide resolved
| DynamicRoute<"/op/[hash]", { "hash": string }>
| StaticRoute<"/ops">
| StaticRoute<"/output-roots">
Expand Down
2 changes: 1 addition & 1 deletion types/api/noves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export interface NovesAccountHistoryResponse {
pageNumber: number;
pageSize: number;
next_page_params?: {
startBlock: null;
startBlock: string;
endBlock: string;
pageNumber: number;
pageSize: number;
Expand Down
2 changes: 1 addition & 1 deletion types/api/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { AddressParam } from './addressParams';
import type { BlockTransactionsResponse } from './block';
import type { DecodedInput } from './decodedInput';
import type { Fee } from './fee';
import type { L2WithdrawalStatus } from './l2Withdrawals';
import type { NovesTxTranslation } from './noves';
import type { OptimisticL2WithdrawalStatus } from './optimisticL2';
import type { TokenInfo } from './token';
import type { TokenTransfer } from './tokenTransfer';
import type { TxAction } from './txAction';
Expand Down
29 changes: 11 additions & 18 deletions ui/address/AddressAccountHistory.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import AddressAccountHistoryTableItem from 'ui/address/accountHistory/AddressAcc
import ActionBar from 'ui/shared/ActionBar';
import DataListDisplay from 'ui/shared/DataListDisplay';
import { getFromToValue } from 'ui/shared/Noves/utils';
import Pagination from 'ui/shared/pagination/Pagination';
import useQueryWithPages from 'ui/shared/pagination/useQueryWithPages';
import TheadSticky from 'ui/shared/TheadSticky';

Expand Down Expand Up @@ -58,7 +57,6 @@ const AddressAccountHistory = ({ scrollRef }: Props) => {
isLoading={ pagination.isLoading }
/>

<Pagination ml={{ base: 'auto', lg: 8 }} { ...pagination }/>
juanlenoves marked this conversation as resolved.
Show resolved Hide resolved
</ActionBar>
);

Expand Down Expand Up @@ -108,22 +106,17 @@ const AddressAccountHistory = ({ scrollRef }: Props) => {
);

return (
<>
{ /* should stay before tabs to scroll up with pagination */ }
<Box ref={ scrollRef }></Box>

<DataListDisplay
isError={ isError }
items={ filteredData }
emptyText="There are no transactions."
content={ content }
actionBar={ actionBar }
filterProps={{
hasActiveFilters: Boolean(filterValue),
emptyFilteredText: 'No match found for current filter',
}}
/>
</>
<DataListDisplay
isError={ isError }
items={ filteredData }
emptyText="There are no transactions."
content={ content }
actionBar={ actionBar }
filterProps={{
hasActiveFilters: Boolean(filterValue),
emptyFilteredText: 'No match found for current filter',
}}
/>
);
};

Expand Down
10 changes: 8 additions & 2 deletions ui/address/accountHistory/AddressAccountHistoryListItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Box, Flex, Skeleton, Text } from '@chakra-ui/react';
import React from 'react';
import React, { useMemo } from 'react';

import type { NovesResponseData } from 'types/api/noves';

Expand All @@ -17,6 +17,12 @@ type Props = {

const AddressAccountHistoryListItem = (props: Props) => {

const parsedDescription = useMemo(() => {
const description = props.tx.classificationData.description;

return description.endsWith('.') ? description.substring(0, description.length - 1) : description;
}, [ props.tx.classificationData.description ]);

return (
<ListItemMobile rowGap={ 4 } w="full">
<Skeleton borderRadius="sm" isLoaded={ !props.isPlaceholderData } w="full">
Expand Down Expand Up @@ -46,7 +52,7 @@ const AddressAccountHistoryListItem = (props: Props) => {
whiteSpace="break-spaces"
wordBreak="break-word"
>
{ props.tx.classificationData.description }
{ parsedDescription }
</LinkInternal>
</Skeleton>

Expand Down
16 changes: 11 additions & 5 deletions ui/address/accountHistory/AddressAccountHistoryTableItem.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Td, Tr, Skeleton, Text, Box } from '@chakra-ui/react';
import React from 'react';
import React, { useMemo } from 'react';

import type { NovesResponseData } from 'types/api/noves';

Expand All @@ -16,16 +16,22 @@ type Props = {

const AddressAccountHistoryTableItem = (props: Props) => {

const parsedDescription = useMemo(() => {
const description = props.tx.classificationData.description;

return description.endsWith('.') ? description.substring(0, description.length - 1) : description;
}, [ props.tx.classificationData.description ]);

return (
<Tr>
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200">
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200" _dark={{ borderColor: 'whiteAlpha.200' }}>
juanlenoves marked this conversation as resolved.
Show resolved Hide resolved
<Skeleton borderRadius="sm" flexShrink={ 0 } isLoaded={ !props.isPlaceholderData }>
<Text as="span" color="text_secondary">
{ dayjs(props.tx.rawTransactionData.timestamp * 1000).fromNow() }
</Text>
</Skeleton>
</Td>
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200" >
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200" _dark={{ borderColor: 'whiteAlpha.200' }}>
<Skeleton borderRadius="sm" isLoaded={ !props.isPlaceholderData }>
<Box display="flex">
<IconSvg
Expand All @@ -43,12 +49,12 @@ const AddressAccountHistoryTableItem = (props: Props) => {
whiteSpace="break-spaces"
wordBreak="break-word"
>
{ props.tx.classificationData.description }
{ parsedDescription }
</LinkInternal>
</Box>
</Skeleton>
</Td>
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200" >
<Td px={ 3 } py="18px" fontSize="sm" borderColor="gray.200" _dark={{ borderColor: 'whiteAlpha.200' }}>
<Box flexShrink={ 0 } >
<NovesFromTo txData={ props.tx } currentAddress={ props.currentAddress } isLoaded={ !props.isPlaceholderData }/>
</Box>
Expand Down
15 changes: 6 additions & 9 deletions ui/shared/Noves/NovesFromTo.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Box, Skeleton, Tag, TagLabel } from '@chakra-ui/react';
import { Box, Skeleton } from '@chakra-ui/react';
import type { FC } from 'react';
import React from 'react';

import type { NovesResponseData } from 'types/api/noves';

import type { NovesFlowViewItem } from 'ui/tx/assetFlows/utils/generateFlowViewData';

import Tag from '../chakra/Tag';
import AddressEntity from '../entities/address/AddressEntity';
import { getActionFromTo, getFromTo } from './utils';

Expand Down Expand Up @@ -38,22 +39,18 @@ const NovesFromTo: FC<Props> = ({ isLoaded, txData, currentAddress = '', item })
<Tag
colorScheme={ isSent ? 'yellow' : 'green' }
px={ 0 }
pos="relative"
minW="max-content"
w="113px"
textAlign="center"
>
<TagLabel
w="113px"
textAlign="center"
>
{ data.text }
</TagLabel>
{ data.text }
</Tag>

<AddressEntity
address={ address }
fontWeight="500"
noCopy={ !data.address }
noLink={ !data.address }
noIcon={ address.name === 'Validators' }
ml={ 2 }
truncation="dynamic"
/>
Expand Down
11 changes: 11 additions & 0 deletions ui/shared/pagination/useQueryWithPages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ function getNextPageParams<R extends PaginatedResources>(data: ResourcePayload<R
return;
}

const nextPageParams = data.next_page_params;
if (nextPageParams) {
// check if a page param is "null" and remove it

return Object.entries(nextPageParams)
//eslint-disable-next-line @typescript-eslint/no-unused-vars
.filter(([ _, v ]) => v != null)
.reduce((acc, [ k, v ]) => ({ ...acc, [k]: v }), {});

}
juanlenoves marked this conversation as resolved.
Show resolved Hide resolved

return data.next_page_params;
}

Expand Down
Loading