Skip to content

Commit

Permalink
Update routes to conform to EIP-3091
Browse files Browse the repository at this point in the history
  • Loading branch information
csillag committed Jun 14, 2023
1 parent 9df15ad commit b368978
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 17 deletions.
3 changes: 3 additions & 0 deletions .changelog/534.cfg.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Update routes to conform to [EIP-3091]

[EIP-3091]: https://eips.ethereum.org/EIPS/eip-3091
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('ShowMoreTokensLink', () => {
expect(screen.getByText('+ 3 more')).toBeInTheDocument()
expect(screen.getByRole('link')).toHaveAttribute(
'href',
'/mainnet/emerald/account/oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t/tokens/erc-20#tokens',
'/mainnet/emerald/address/oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t/tokens/erc-20#tokens',
)
})

Expand All @@ -85,7 +85,7 @@ describe('ShowMoreTokensLink', () => {
expect(screen.getByText('+ 1 more')).toBeInTheDocument()
expect(screen.getByRole('link')).toHaveAttribute(
'href',
'/mainnet/emerald/account/oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t/tokens/erc-721#tokens',
'/mainnet/emerald/address/oasis1qrvha284gfztn7wwq6z50c86ceu28jp7csqhpx9t/tokens/erc-721#tokens',
)
})
})
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,14 @@ describe('SearchResultsView', () => {
expect(screen.getByRole('link', { name: '10' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: '10' })).toHaveAttribute(
'href',
'/mainnet/emerald/blocks/1396255#transactions',
'/mainnet/emerald/block/1396255#transactions',
)

expect(screen.getByText('143,553')).toBeInTheDocument()
expect(screen.getByRole('link', { name: '1' })).toBeInTheDocument()
expect(screen.getByRole('link', { name: '1' })).toHaveAttribute(
'href',
'/mainnet/sapphire/blocks/143553#transactions',
'/mainnet/sapphire/block/143553#transactions',
)
})

Expand Down Expand Up @@ -81,7 +81,7 @@ describe('SearchResultsView', () => {
expect(screen.getByText('337325.43836… FTP')).toBeInTheDocument()
expect(screen.getByRole('link', { name: /337325.43836/ })).toHaveAttribute(
'href',
'/mainnet/emerald/account/0xBA504818FdD8D3dBA2Ef8fD9B4F4D5c71aD1d1D3/tokens/erc-20#oasis1qpssvkplnlpzdvwxpgmrhf9j5lkyvaylcvujhjhg',
'/mainnet/emerald/address/0xBA504818FdD8D3dBA2Ef8fD9B4F4D5c71aD1d1D3/tokens/erc-20#oasis1qpssvkplnlpzdvwxpgmrhf9j5lkyvaylcvujhjhg',
)
})
})
14 changes: 7 additions & 7 deletions src/app/utils/route-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ export abstract class RouteUtils {
}

static getLatestTransactionsRoute = ({ network, layer }: SearchScope) => {
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/transactions`
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/tx`
}

static getLatestBlocksRoute = ({ network, layer }: SearchScope) => {
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/blocks`
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/block`
}

static getBlockRoute = ({ network, layer }: SearchScope, blockHeight: number) => {
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/blocks/${encodeURIComponent(
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/block/${encodeURIComponent(
blockHeight,
)}`
}

static getTransactionRoute = (scope: SearchScope, txHash: string) => {
return `/${encodeURIComponent(scope.network)}/${encodeURIComponent(
scope.layer,
)}/transactions/${encodeURIComponent(txHash)}`
return `/${encodeURIComponent(scope.network)}/${encodeURIComponent(scope.layer)}/tx/${encodeURIComponent(
txHash,
)}`
}

static getAccountRoute = ({ network, layer }: SearchScope, account: string) => {
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/account/${encodeURIComponent(
return `/${encodeURIComponent(network)}/${encodeURIComponent(layer)}/address/${encodeURIComponent(
account,
)}`
}
Expand Down
10 changes: 5 additions & 5 deletions src/routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,16 @@ export const routes: RouteObject[] = [
},

{
path: `blocks`,
path: `block`,
element: <BlocksPage />,
},
{
path: `blocks/:blockHeight`,
path: `block/:blockHeight`,
element: <BlockDetailPage />,
loader: blockHeightParamLoader,
},
{
path: `account/:address`,
path: `address/:address`,
element: <AccountDetailsPage />,
loader: addressParamLoader,
children: [
Expand All @@ -87,11 +87,11 @@ export const routes: RouteObject[] = [
],
},
{
path: `transactions`,
path: `tx`,
element: <TransactionsPage />,
},
{
path: `transactions/:hash`,
path: `tx/:hash`,
element: <TransactionDetailPage />,
loader: transactionParamLoader,
},
Expand Down

0 comments on commit b368978

Please sign in to comment.