From f20e83a2ea5b565eff84ad427d332ccf0a6ad3b4 Mon Sep 17 00:00:00 2001 From: Antonio Ventilii Date: Wed, 22 Jan 2025 13:31:10 -0300 Subject: [PATCH 1/2] feat(frontend): Solana token menu redirects to token explorer (#4409) # Motivation The token menu for Solana was redirecting to the wallet address page. We want that it redirects to the token explorer page. --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> --- .../sol/components/tokens/SolTokenMenu.svelte | 8 ++++- .../components/tokens/SolTokenMenu.spec.ts | 29 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/src/frontend/src/sol/components/tokens/SolTokenMenu.svelte b/src/frontend/src/sol/components/tokens/SolTokenMenu.svelte index c413506bad..f5a6d89693 100644 --- a/src/frontend/src/sol/components/tokens/SolTokenMenu.svelte +++ b/src/frontend/src/sol/components/tokens/SolTokenMenu.svelte @@ -20,6 +20,7 @@ isNetworkIdSOLTestnet } from '$lib/utils/network.utils'; import type { SolanaNetwork } from '$sol/types/network'; + import { isTokenSpl } from '$sol/utils/spl.utils'; let explorerUrl: string | undefined; $: explorerUrl = ($token?.network as SolanaNetwork)?.explorerUrl; @@ -32,9 +33,14 @@ ? $solAddressLocal : $solAddressMainnet; + let tokenAddress: string | undefined; + $: tokenAddress = nonNullish($token) && isTokenSpl($token) ? $token.address : undefined; + let explorerAddressUrl: string | undefined; $: explorerAddressUrl = nonNullish(explorerUrl) - ? replacePlaceholders(explorerUrl, { $args: `account/${address}/` }) + ? replacePlaceholders(explorerUrl, { + $args: nonNullish(tokenAddress) ? `token/${tokenAddress}/` : `account/${address}/` + }) : undefined; diff --git a/src/frontend/src/tests/sol/components/tokens/SolTokenMenu.spec.ts b/src/frontend/src/tests/sol/components/tokens/SolTokenMenu.spec.ts index 07d59c82ca..2f3663c80b 100644 --- a/src/frontend/src/tests/sol/components/tokens/SolTokenMenu.spec.ts +++ b/src/frontend/src/tests/sol/components/tokens/SolTokenMenu.spec.ts @@ -9,6 +9,7 @@ import { SOLANA_MAINNET_NETWORK, SOLANA_TESTNET_NETWORK } from '$env/networks/networks.sol.env'; +import { TRUMP_TOKEN } from '$env/tokens/tokens-spl/tokens.trump.env'; import { SOLANA_DEVNET_TOKEN, SOLANA_TESTNET_TOKEN, @@ -28,6 +29,7 @@ import { testnetsStore } from '$lib/stores/settings.store'; import { token as tokenStore } from '$lib/stores/token.store'; import { replacePlaceholders } from '$lib/utils/i18n.utils'; import SolTokenMenu from '$sol/components/tokens/SolTokenMenu.svelte'; +import type { SolanaNetwork } from '$sol/types/network'; import { mockPage } from '$tests/mocks/page.store.mock'; import { mockSolAddress } from '$tests/mocks/sol.mock'; import { render, waitFor } from '@testing-library/svelte'; @@ -45,6 +47,11 @@ describe('SolTokenMenu', () => { solAddressMainnetStore.reset(); solAddressTestnetStore.reset(); solAddressDevnetStore.reset(); + + // In component TOkenMenu there is a dependency to the store erc20UserTokensStore that impedes the correct rendering of the component + // So we need to reset the store before each test + // TODO: verify if this dependency can be removed + erc20UserTokensStore.resetAll(); }); const testCases = [ @@ -75,7 +82,6 @@ describe('SolTokenMenu', () => { 'external link forwards to correct $description explorer', async ({ token, explorerUrl, network, store }) => { tokenStore.set(token); - erc20UserTokensStore.reset(token.id); store.set({ certified: true, data: mockSolAddress }); mockPage.mock({ network: network.id.description }); @@ -92,4 +98,25 @@ describe('SolTokenMenu', () => { }); } ); + + it('external link forwards to SPL explorer URL', async () => { + const mockToken = TRUMP_TOKEN; + + tokenStore.set(mockToken); + mockPage.mock({ network: mockToken.network.id.description }); + + const { queryByTestId, getByTestId } = render(SolTokenMenu); + const button = getByTestId(TOKEN_MENU_SOL_BUTTON); + button.click(); + + await waitFor(() => { + const a = queryByTestId(TOKEN_MENU_SOL_EXPLORER_LINK); + expect(a).not.toBeNull(); + expect((a as HTMLAnchorElement).href).toEqual( + replacePlaceholders((mockToken.network as SolanaNetwork).explorerUrl ?? '', { + $args: `token/${mockToken.address}/` + }) + ); + }); + }); }); From 6fbb2505b873dfa72a8a0502caee545610d224a5 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 22 Jan 2025 18:01:11 +0100 Subject: [PATCH 2/2] fix(devops): One more step towards automated releases (#4412) # Motivation The code that selects the beta branch for releases has the if statement at the wrong nesting level. # Changes - Move the if statement to the right level. # Tests Can only be tested properly in main. :-( --- .github/workflows/deploy-to-environment.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy-to-environment.yml b/.github/workflows/deploy-to-environment.yml index a83527f429..08ad86c86d 100644 --- a/.github/workflows/deploy-to-environment.yml +++ b/.github/workflows/deploy-to-environment.yml @@ -60,8 +60,6 @@ jobs: echo "NETWORK=staging" >> $GITHUB_ENV elif [ "${{ github.ref_type }}" == "tag" ]; then echo "NETWORK=beta" >> $GITHUB_ENV - elif [ "${{ github.ref_type }}" == "workflow_run" ]; then - echo "NETWORK=beta" >> $GITHUB_ENV else echo "Error: Unsupported ref type." exit 1 @@ -70,6 +68,8 @@ jobs: elif [ "${{ github.event_name }}" == "workflow_dispatch" ]; then echo "NETWORK=${{ github.event.inputs.network }}" >> $GITHUB_ENV echo "CANISTER=${{ github.event.inputs.canister }}" >> $GITHUB_ENV + elif [ "${{ github.event_name }}" == "workflow_run" ]; then + echo "NETWORK=beta" >> $GITHUB_ENV else echo "Error: Unsupported event type." exit 1