Skip to content

Commit

Permalink
Noves integration (#1398)
Browse files Browse the repository at this point in the history
* noves integration

* code refactored

* PR changes added

* Code set up for new proxy 'describeTxs'

* minor fix

* Rename Novestranslate.ts to NovesTranslate.ts

* some quick stuff

* partial fixes and commit for changing how useDescribeTxs and txsContent work (new GET endpoint)

* Pending PR fixes

* tx asset flows pageSize of 50

* PR comments fixes

* rename expected api endpoint for the describe_txs endpoint, more accurate and descriptive

* one final re-name for api endpoint (make it clear it's an object vs an action)

* scrollRef fix

* build error fix

* design fixes

* sub heading fix

* Removed pagination in account history

* remove duplicate route

* updated table theme and icon gap

* Removed wrong color in table

* removed null validation in page params

* updated margin

* margin fix

* add icons to contracts

* Sub-heading interpretation simplified

* token alignment fix

* tests added for new functions

* margin fix

* remove divider on mobile asset flows

---------

Co-authored-by: NahuelNoves <[email protected]>
Co-authored-by: francisco-noves <[email protected]>
3 people authored Mar 26, 2024
1 parent 9cdbf6d commit cc9cb36
Showing 40 changed files with 1,840 additions and 17 deletions.
1 change: 1 addition & 0 deletions deploy/values/review/values.yaml.gotmpl
Original file line number Diff line number Diff line change
@@ -79,6 +79,7 @@ frontend:
NEXT_PUBLIC_VIEWS_NFT_MARKETPLACES: "[{'name':'LooksRare','collection_url':'https://goerli.looksrare.org/collections/{hash}','instance_url':'https://goerli.looksrare.org/collections/{hash}/{id}','logo_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/nft-marketplace-logos/looks-rare.png'}]"
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
NEXT_PUBLIC_AD_BANNER_PROVIDER: getit
2 changes: 1 addition & 1 deletion docs/ENVS.md
Original file line number Diff line number Diff line change
@@ -524,7 +524,7 @@ This feature is **enabled by default** with the `['metamask']` value. To switch

| Variable | Type| Description | Compulsoriness | Default value | Example value |
| --- | --- | --- | --- | --- | --- |
| NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER | `blockscout` \| `none` | Transaction interpretation provider that displays human readable transaction description | - | `none` | `blockscout` |
| NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER | `blockscout` \| `noves` \| `none` | Transaction interpretation provider that displays human readable transaction description | - | `none` | `blockscout` |

&nbsp;

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.
4 changes: 2 additions & 2 deletions icons/lightning.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 19 additions & 1 deletion lib/api/resources.ts
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@ import type {
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,
@@ -649,6 +650,20 @@ export const RESOURCES = {
path: '/api/v2/shibarium/withdrawals/count',
},

// NOVES-FI
noves_transaction: {
path: '/api/v2/proxy/noves-fi/transactions/:hash',
pathParams: [ 'hash' as const ],
},
noves_address_history: {
path: '/api/v2/proxy/noves-fi/addresses/:address/transactions',
pathParams: [ 'address' as const ],
filterFields: [],
},
noves_describe_txs: {
path: '/api/v2/proxy/noves-fi/transaction-descriptions',
},

// USER OPS
user_ops: {
path: '/api/v2/proxy/account-abstraction/operations',
@@ -757,7 +772,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' | 'validators';
'domains_lookup' | 'addresses_lookup' | 'user_ops' | 'validators' | 'noves_address_history';

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

@@ -886,6 +901,9 @@ Q extends 'user_ops' ? UserOpsResponse :
Q extends 'user_op' ? UserOp :
Q extends 'user_ops_account' ? UserOpsAccount :
Q extends 'user_op_interpretation'? TxInterpretationResponse :
Q extends 'noves_transaction' ? NovesResponseData :
Q extends 'noves_address_history' ? NovesAccountHistoryResponse :
Q extends 'noves_describe_txs' ? NovesDescribeTxsResponse :
never;
/* eslint-enable @typescript-eslint/indent */

103 changes: 103 additions & 0 deletions mocks/noves/transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import type { NovesResponseData } from 'types/api/noves';

import type { TokensData } from 'ui/tx/assetFlows/utils/getTokensData';

export const hash = '0x380400d04ebb4179a35b1d7fdef260776915f015e978f8587ef2704b843d4e53';

export const transaction: NovesResponseData = {
accountAddress: '0xef6595A423c99f3f2821190A4d96fcE4DcD89a80',
chain: 'eth-goerli',
classificationData: {
description: 'Called function \'stake\' on contract 0xef326CdAdA59D3A740A76bB5f4F88Fb2.',
protocol: {
name: null,
},
received: [],
sent: [
{
action: 'sent',
actionFormatted: 'Sent',
amount: '3000',
from: {
address: '0xef6595A423c99f3f2821190A4d96fcE4DcD89a80',
name: 'This wallet',
},
to: {
address: '0xdD15D2650387Fb6FEDE27ae7392C402a393F8A37',
name: null,
},
token: {
address: '0x1bfe4298796198f8664b18a98640cec7c89b5baa',
decimals: 18,
name: 'PQR-Test',
symbol: 'PQR',
},
},
{
action: 'paidGas',
actionFormatted: 'Paid Gas',
amount: '0.000395521502109448',
from: {
address: '0xef6595A423c99f3f2821190A4d96fcE4DcD89a80',
name: 'This wallet',
},
to: {
address: null,
name: 'Validators',
},
token: {
address: 'ETH',
decimals: 18,
name: 'ETH',
symbol: 'ETH',
},
},
],
source: {
type: null,
},
type: 'unclassified',
typeFormatted: 'Unclassified',
},
rawTransactionData: {
blockNumber: 10388918,
fromAddress: '0xef6595A423c99f3f2821190A4d96fcE4DcD89a80',
gas: 275079,
gasPrice: 1500000008,
timestamp: 1705488588,
toAddress: '0xef326CdAdA59D3A740A76bB5f4F88Fb2f1076164',
transactionFee: {
amount: '395521502109448',
token: {
decimals: 18,
symbol: 'ETH',
},
},
transactionHash: '0x380400d04ebb4179a35b1d7fdef260776915f015e978f8587ef2704b843d4e53',
},
txTypeVersion: 2,
};

export const tokenData: TokensData = {
nameList: [ 'PQR-Test', 'ETH' ],
symbolList: [ 'PQR' ],
idList: [],
byName: {
'PQR-Test': {
name: 'PQR-Test',
symbol: 'PQR',
address: '0x1bfe4298796198f8664b18a98640cec7c89b5baa',
id: undefined,
},
ETH: { name: 'ETH', symbol: null, address: '', id: undefined },
},
bySymbol: {
PQR: {
name: 'PQR-Test',
symbol: 'PQR',
address: '0x1bfe4298796198f8664b18a98640cec7c89b5baa',
id: undefined,
},
'null': { name: 'ETH', symbol: null, address: '', id: undefined },
},
};
5 changes: 3 additions & 2 deletions nextjs/nextjs-routes.d.ts
Original file line number Diff line number Diff line change
@@ -21,11 +21,12 @@ declare module "nextjs-routes" {
| StaticRoute<"/api/media-type">
| StaticRoute<"/api/proxy">
| StaticRoute<"/api-docs">
| DynamicRoute<"/apps/[id]", { "id": string }>
| StaticRoute<"/apps">
| DynamicRoute<"/apps/[id]", { "id": string }>
| StaticRoute<"/auth/auth0">
| StaticRoute<"/auth/profile">
| StaticRoute<"/auth/unverified-email">
| StaticRoute<"/batches">
| DynamicRoute<"/batches/[number]", { "number": string }>
| StaticRoute<"/batches">
| DynamicRoute<"/blobs/[hash]", { "hash": string }>
@@ -38,8 +39,8 @@ declare module "nextjs-routes" {
| StaticRoute<"/graphiql">
| StaticRoute<"/">
| StaticRoute<"/login">
| DynamicRoute<"/name-domains/[name]", { "name": string }>
| StaticRoute<"/name-domains">
| DynamicRoute<"/name-domains/[name]", { "name": string }>
| DynamicRoute<"/op/[hash]", { "hash": string }>
| StaticRoute<"/ops">
| StaticRoute<"/output-roots">
43 changes: 43 additions & 0 deletions stubs/noves/NovesTranslate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import type { NovesResponseData, NovesClassificationData, NovesRawTransactionData } from 'types/api/noves';

const NOVES_TRANSLATE_CLASSIFIED: NovesClassificationData = {
description: 'Sent 0.04 ETH',
received: [ {
action: 'Sent Token',
actionFormatted: 'Sent Token',
amount: '45',
from: { name: '', address: '0xa0393A76b132526a70450273CafeceB45eea6dEE' },
to: { name: '', address: '0xa0393A76b132526a70450273CafeceB45eea6dEE' },
token: {
address: '',
name: 'ETH',
symbol: 'ETH',
decimals: 18,
},
} ],
sent: [],
source: {
type: '',
},
type: '0x2',
typeFormatted: 'Send NFT',
};

const NOVES_TRANSLATE_RAW: NovesRawTransactionData = {
blockNumber: 1,
fromAddress: '0xCFC123a23dfeD71bDAE054e487989d863C525C73',
gas: 2,
gasPrice: 3,
timestamp: 20000,
toAddress: '0xCFC123a23dfeD71bDAE054e487989d863C525C73',
transactionFee: 2,
transactionHash: '0x128b79937a0eDE33258992c9668455f997f1aF24',
};

export const NOVES_TRANSLATE: NovesResponseData = {
accountAddress: '0x2b824349b320cfa72f292ab26bf525adb00083ba9fa097141896c3c8c74567cc',
chain: 'base',
txTypeVersion: 2,
rawTransactionData: NOVES_TRANSLATE_RAW,
classificationData: NOVES_TRANSLATE_CLASSIFIED,
};
124 changes: 124 additions & 0 deletions types/api/noves.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
export interface NovesResponseData {
txTypeVersion: number;
chain: string;
accountAddress: string;
classificationData: NovesClassificationData;
rawTransactionData: NovesRawTransactionData;
}

export interface NovesClassificationData {
type: string;
typeFormatted?: string;
description: string;
sent: Array<NovesSentReceived>;
received: Array<NovesSentReceived>;
approved?: Approved;
protocol?: {
name: string | null;
};
source: {
type: string | null;
};
message?: string;
}

export interface Approved {
amount: string;
spender: string;
token?: NovesToken;
nft?: NovesNft;
}

export interface NovesSentReceived {
action: string;
actionFormatted?: string;
amount: string;
to: NovesTo;
from: NovesFrom;
token?: NovesToken;
nft?: NovesNft;
}

export interface NovesToken {
symbol: string;
name: string;
decimals: number;
address: string;
id?: string;
}

export interface NovesNft {
name: string;
id: string;
symbol: string;
address: string;
}

export interface NovesFrom {
name: string | null;
address: string;
}

export interface NovesTo {
name: string | null;
address: string | null;
}

export interface NovesRawTransactionData {
transactionHash: string;
fromAddress: string;
toAddress: string;
blockNumber: number;
gas: number;
gasPrice: number;
transactionFee: NovesTransactionFee | number;
timestamp: number;
}

export interface NovesTransactionFee {
amount: string;
currency?: string;
token?: {
decimals: number;
symbol: string;
};
}

export interface NovesAccountHistoryResponse {
hasNextPage: boolean;
items: Array<NovesResponseData>;
pageNumber: number;
pageSize: number;
next_page_params?: {
startBlock: string;
endBlock: string;
pageNumber: number;
pageSize: number;
ignoreTransactions: string;
viewAsAccountAddress: string;
};
}

export const NovesHistoryFilterValues = [ 'received', 'sent' ] as const;

export type NovesHistoryFilterValue = typeof NovesHistoryFilterValues[number] | undefined;

export interface NovesHistoryFilters {
filter?: NovesHistoryFilterValue;
}

export interface NovesDescribeResponse {
type: string;
description: string;
}

export interface NovesDescribeTxsResponse {
txHash: string;
type: string;
description: string;
}[];

export interface NovesTxTranslation {
data?: NovesDescribeTxsResponse;
isLoading: boolean;
}
3 changes: 3 additions & 0 deletions types/api/transaction.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import type { AddressParam } from './addressParams';
import type { BlockTransactionsResponse } from './block';
import type { DecodedInput } from './decodedInput';
import type { Fee } from './fee';
import type { NovesTxTranslation } from './noves';
import type { OptimisticL2WithdrawalStatus } from './optimisticL2';
import type { TokenInfo } from './token';
import type { TokenTransfer } from './tokenTransfer';
@@ -85,6 +86,8 @@ export type Transaction = {
blob_gas_price?: string;
burnt_blob_fee?: string;
max_fee_per_blob_gas?: string;
// Noves-fi
translation?: NovesTxTranslation;
}

export const ZKEVM_L2_TX_STATUSES = [ 'Confirmed by Sequencer', 'L1 Confirmed' ];
1 change: 1 addition & 0 deletions types/client/txInterpretation.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@ import type { ArrayElement } from 'types/utils';

export const PROVIDERS = [
'blockscout',
'noves',
'none',
] as const;

Loading

0 comments on commit cc9cb36

Please sign in to comment.