Skip to content

Commit

Permalink
Merge pull request #2248 from blockscout/fe-2195
Browse files Browse the repository at this point in the history
filecoin addresses support
  • Loading branch information
isstuev authored Nov 4, 2024
2 parents ae26fd9 + ef7e993 commit 8facbe5
Show file tree
Hide file tree
Showing 47 changed files with 264 additions and 43 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy-review-l2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- eth
- eth_sepolia
- eth_goerli
- filecoin
- optimism
- optimism_celestia
- optimism_sepolia
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/deploy-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ on:
- eth
- eth_sepolia
- eth_goerli
- filecoin
- optimism
- optimism_celestia
- optimism_sepolia
Expand Down
1 change: 1 addition & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@
"eth",
"eth_goerli",
"eth_sepolia",
"filecoin",
"optimism",
"optimism_celestia",
"optimism_sepolia",
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.arbitrum
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Arbitrum One network explorer
# https://arbitrum.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=arbitrum"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=arbitrum"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.arbitrum_nova
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Arbitrum One network explorer
# https://arbitrum.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=arbitrum"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=arbitrum"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.base
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Base Mainnet network explorer
# https://base.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=base"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=base"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.celo_alfajores
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Celo Alfajores network explorer
# https://celo-alfajores.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=celo_alfajores"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=celo_alfajores"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.eth
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Ethereum network explorer
# https://eth.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=eth"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=eth"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.eth_sepolia
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Sepolia network explorer
# https://eth-sepolia.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=eth_sepolia"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=eth_sepolia"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
42 changes: 42 additions & 0 deletions configs/envs/.env.filecoin
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Set of ENVs for Filecoin Virtual Machine network explorer
# https://filecoin.blockscout.com
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=filecoin"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
NEXT_PUBLIC_APP_HOST=localhost
NEXT_PUBLIC_APP_PORT=3000
NEXT_PUBLIC_APP_ENV=development
NEXT_PUBLIC_API_WEBSOCKET_PROTOCOL=ws

# Instance ENVs
NEXT_PUBLIC_API_BASE_PATH=/
NEXT_PUBLIC_API_HOST=filecoin.blockscout.com
NEXT_PUBLIC_API_SPEC_URL=https://raw.githubusercontent.com/blockscout/blockscout-api-v2-swagger/main/swagger.yaml
NEXT_PUBLIC_CONTRACT_CODE_IDES=[{'title':'Remix IDE','url':'https://remix.ethereum.org/?address={hash}&blockscout={domain}','icon_url':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/ide-icons/remix.png'}]
NEXT_PUBLIC_FOOTER_LINKS=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/footer-links/fvm.json
NEXT_PUBLIC_GRAPHIQL_TRANSACTION=0x5abb6212c1802402b828ed20c2bd4d4a6153b8bee68a5259cba3c8d7a7c6b775
NEXT_PUBLIC_HOMEPAGE_CHARTS=['daily_txs', 'coin_price', 'market_cap']
NEXT_PUBLIC_HOMEPAGE_PLATE_BACKGROUND=linear-gradient(237deg, rgb(26, 58, 150) 14.83%, rgb(111, 223, 164) 132.56%)
NEXT_PUBLIC_HOMEPAGE_PLATE_TEXT_COLOR=rgba(255, 255, 255, 1)
NEXT_PUBLIC_IS_ACCOUNT_SUPPORTED=true
NEXT_PUBLIC_LOGOUT_URL=https://blockscout-filecoin.us.auth0.com/v2/logout
NEXT_PUBLIC_MARKETPLACE_ENABLED=false
NEXT_PUBLIC_METADATA_SERVICE_API_HOST=https://metadata.services.blockscout.com
NEXT_PUBLIC_NETWORK_CURRENCY_DECIMALS=18
NEXT_PUBLIC_NETWORK_CURRENCY_NAME=FIL
NEXT_PUBLIC_NETWORK_CURRENCY_SYMBOL=FIL
NEXT_PUBLIC_NETWORK_EXPLORERS=[{'title':'GeckoTerminal','logo':'https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/explorer-logos/geckoterminal.png','baseUrl':'https://www.geckoterminal.com/','paths':{'token':'/filecoin/pools'}}]
NEXT_PUBLIC_NETWORK_ICON=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/filecoin-icon-dark.svg
NEXT_PUBLIC_NETWORK_ICON_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-icons/filecoin-icon-light.svg
NEXT_PUBLIC_NETWORK_ID=314
NEXT_PUBLIC_NETWORK_LOGO=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/filecoin-logo-dark.svg
NEXT_PUBLIC_NETWORK_LOGO_DARK=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/network-logos/filecoin-logo-light.svg
NEXT_PUBLIC_NETWORK_NAME=Filecoin Virtual Machine
NEXT_PUBLIC_NETWORK_RPC_URL=https://rpc.ankr.com/filecoin
NEXT_PUBLIC_NETWORK_SHORT_NAME=Filecoin Virtual Machine
NEXT_PUBLIC_OG_ENHANCED_DATA_ENABLED=true
NEXT_PUBLIC_OG_IMAGE_URL=https://raw.githubusercontent.com/blockscout/frontend-configs/main/configs/og-images/filecoin.png
NEXT_PUBLIC_STATS_API_HOST=https://stats-filecoin.k8s-prod-1.blockscout.com
NEXT_PUBLIC_TRANSACTION_INTERPRETATION_PROVIDER=blockscout
NEXT_PUBLIC_VISUALIZE_API_HOST=https://visualizer.services.blockscout.com
2 changes: 1 addition & 1 deletion configs/envs/.env.gnosis
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Gnosis chain network explorer
# https://gnosis.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=gnosis"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=gnosis"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.main
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Sepolia network explorer
# https://eth-sepolia.k8s-dev.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=main"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=main"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.optimism
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for OP Mainnet network explorer
# https://optimism.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=optimism"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=optimism"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.optimism_celestia
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for OP Celestia Raspberry network explorer
# https://opcelestia-raspberry.gelatoscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=optimism_celestia"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=optimism_celestia"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.optimism_sepolia
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for OP Sepolia network explorer
# https://optimism-sepolia.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=optimism_sepolia"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=optimism_sepolia"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.polygon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Polygon Mainnet network explorer
# https://polygon.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=polygon"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=polygon"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.rootstock_testnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Rootstock Testnet network explorer
# https://rootstock-testnet.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=rootstock_testnet"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=rootstock_testnet"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.stability_testnet
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Stability Testnet network explorer
# https://stability-testnet.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=stability_testnet"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=stability_testnet"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.zkevm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for Polygon zkEVM network explorer
# https://zkevm.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=zkevm"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=zkevm"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
2 changes: 1 addition & 1 deletion configs/envs/.env.zksync
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set of ENVs for ZkSync Era network explorer
# https://zksync.blockscout.com
# This is an auto-generated file. To update all values, run "yarn preset:sync --name=zksync"
# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=zksync"

# Local ENVs
NEXT_PUBLIC_APP_PROTOCOL=http
Expand Down
9 changes: 9 additions & 0 deletions mocks/address/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,12 @@ export const validator: Address = {
watchlist_address_id: null,
ens_domain_name: null,
};

export const filecoin = {
...validator,
filecoin: {
actor_type: 'evm' as const,
id: 'f02977693',
robust: 'f410fuiwj6a3yxajbohrl5vu6ns6o2e2jriul52lvzci',
},
};
3 changes: 2 additions & 1 deletion tools/preset-sync/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const PRESETS = {
eth_goerli: 'https://eth-goerli.blockscout.com',
eth_sepolia: 'https://eth-sepolia.blockscout.com',
garnet: 'https://explorer.garnetchain.com',
filecoin: 'https://filecoin.blockscout.com',
gnosis: 'https://gnosis.blockscout.com',
optimism: 'https://optimism.blockscout.com',
optimism_celestia: 'https://opcelestia-raspberry.gelatoscout.com',
Expand Down Expand Up @@ -75,7 +76,7 @@ function updateFileContent(envsEntries: Array<[ string, string ]>, presetId: key
const content =
`# Set of ENVs for ${ chainName } network explorer\n` +
'# ' + explorerUrl + '\n' +
`# This is an auto-generated file. To update all values, run "yarn preset:sync --name=${ presetId }"\n` +
`# This is an auto-generated file. To update all values, run "yarn dev:preset:sync --name=${ presetId }"\n` +
'\n' +
'# Local ENVs\n' +
localEnvsContent + '\n' +
Expand Down
4 changes: 3 additions & 1 deletion types/api/address.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Transaction } from 'types/api/transaction';

import type { UserTags, AddressImplementation, AddressParam } from './addressParams';
import type { UserTags, AddressImplementation, AddressParam, AddressFilecoinParams } from './addressParams';
import type { Block, EpochRewardsType } from './block';
import type { InternalTransaction } from './internalTransaction';
import type { MudWorldSchema, MudWorldTable } from './mudWorlds';
Expand All @@ -11,9 +11,11 @@ export interface Address extends UserTags {
block_number_balance_updated_at: number | null;
coin_balance: string | null;
creator_address_hash: string | null;
creator_filecoin_robust_address?: string | null;
creation_tx_hash: string | null;
exchange_rate: string | null;
ens_domain_name: string | null;
filecoin?: AddressFilecoinParams;
// TODO: if we are happy with tabs-counters method, should we delete has_something fields?
has_beacon_chain_withdrawals?: boolean;
has_decompiled_code: boolean;
Expand Down
25 changes: 25 additions & 0 deletions types/api/addressParams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,30 @@ export interface WatchlistName {
display_name: string;
}

export type AddressFilecoinParams = {
actor_type?: FilecoinActorType;
id?: string | null;
robust?: string | null;
}

export type FilecoinActorType =
'account' |
'cron' |
'datacap' |
'eam' |
'ethaccount' |
'evm' |
'init' |
'market' |
'miner' |
'multisig' |
'paych' |
'placeholder' |
'power' |
'reward' |
'system' |
'verifreg';

export interface UserTags {
private_tags: Array<AddressTag> | null;
watchlist_names: Array<WatchlistName> | null;
Expand All @@ -33,6 +57,7 @@ export type AddressParamBasic = {
reputation: number | null;
tags: Array<AddressMetadataTagApi>;
} | null;
filecoin?: AddressFilecoinParams;
}

export type AddressParam = UserTags & AddressParamBasic;
1 change: 1 addition & 0 deletions types/api/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ export interface SmartContract {
remappings?: Array<string>;
};
verified_twin_address_hash: string | null;
verified_twin_filecoin_robust_address?: string | null;
proxy_type: SmartContractProxyType | null;
language: string | null;
license_type: SmartContractLicenseType | null;
Expand Down
4 changes: 4 additions & 0 deletions types/api/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface SearchResultToken {
total_supply: string | null;
is_verified_via_admin_panel: boolean;
is_smart_contract_verified: boolean;
filecoin_robust_address?: string | null;
}

export interface SearchResultAddressOrContract {
Expand All @@ -23,6 +24,7 @@ export interface SearchResultAddressOrContract {
address: string;
is_smart_contract_verified: boolean;
certified?: true;
filecoin_robust_address?: string | null;
url?: string; // not used by the frontend, we build the url ourselves
ens_info?: {
address_hash: string;
Expand All @@ -36,6 +38,7 @@ export interface SearchResultDomain {
type: 'ens_domain';
name: string | null;
address: string;
filecoin_robust_address?: string | null;
is_smart_contract_verified: boolean;
url?: string; // not used by the frontend, we build the url ourselves
ens_info: {
Expand All @@ -49,6 +52,7 @@ export interface SearchResultDomain {
export interface SearchResultLabel {
type: 'label';
address: string;
filecoin_robust_address?: string | null;
name: string;
is_smart_contract_verified: boolean;
url?: string; // not used by the frontend, we build the url ourselves
Expand Down
1 change: 1 addition & 0 deletions types/api/token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface TokenInfo<T extends TokenType = TokenType> {
bridge_type?: string | null;
origin_chain_id?: string | null;
foreign_address?: string | null;
filecoin_robust_address?: string | null;
}

export interface TokenCounters {
Expand Down
23 changes: 23 additions & 0 deletions ui/address/AddressDetails.pw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,17 @@ test.describe('mobile', () => {
});
});

test('filecoin', async({ render, mockApiResponse, page }) => {
await mockApiResponse('address', addressMock.filecoin, { pathParams: { hash: ADDRESS_HASH } });
await mockApiResponse('address_counters', countersMock.forValidator, { pathParams: { hash: ADDRESS_HASH } });

const component = await render(<AddressDetails addressQuery={{ data: addressMock.filecoin } as AddressQuery}/>, { hooksConfig });

await expect(component).toHaveScreenshot({
mask: [ page.locator(pwConfig.adsBannerSelector) ],
maskColor: pwConfig.maskColor,
});
});
});

test('contract', async({ render, page, mockApiResponse }) => {
Expand Down Expand Up @@ -92,3 +103,15 @@ test('validator', async({ render, mockApiResponse, page }) => {
maskColor: pwConfig.maskColor,
});
});

test('filecoin', async({ render, mockApiResponse, page }) => {
await mockApiResponse('address', addressMock.filecoin, { pathParams: { hash: ADDRESS_HASH } });
await mockApiResponse('address_counters', countersMock.forValidator, { pathParams: { hash: ADDRESS_HASH } });

const component = await render(<AddressDetails addressQuery={{ data: addressMock.filecoin } as AddressQuery}/>, { hooksConfig });

await expect(component).toHaveScreenshot({
mask: [ page.locator(pwConfig.adsBannerSelector) ],
maskColor: pwConfig.maskColor,
});
});
Loading

0 comments on commit 8facbe5

Please sign in to comment.