Skip to content

Commit

Permalink
Merge branch 'main' into feat(ci)/auto-update-package-lock
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii authored Feb 3, 2025
2 parents 8fbafa1 + a3ed4f2 commit df4cc3a
Show file tree
Hide file tree
Showing 45 changed files with 394 additions and 272 deletions.
4 changes: 3 additions & 1 deletion .github/repo_policies/BOT_APPROVED_FILES
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,6 @@ e2e/**/*.png
declarations/**/*
src/frontend/src/env/tokens/tokens.*.json
src/frontend/src/env/tokens/tokens-erc20/
src/frontend/static/icons/sns/*
src/frontend/static/icons/sns/*
src/frontend/src/**/*.svelte
src/frontend/src/tests/**/*.spec.ts
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 30 additions & 0 deletions e2e/guards-page.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { testWithII } from '@dfinity/internet-identity-playwright';
import { expect } from '@playwright/test';
import { TRANSACTIONS_URL } from './utils/constants/e2e.constants';
import { HomepageLoggedIn } from './utils/pages/homepage.page';
import { TransactionsPage } from './utils/pages/transactions.page';

testWithII(
'should be redirected to home if not network is provided to access transactions',
async ({ page, iiPage }) => {
// We load the transaction page for ICP. This way we know ICP is supported.
const transactionsPage = new TransactionsPage({
page,
iiPage,
tokenSymbol: 'ICP',
networkId: 'ICP'
});

await transactionsPage.waitForReady();

// We go to transactions without network
await page.goto(`${TRANSACTIONS_URL}/?token=Internet%20Computer`);

// We should be redirected to the home screen.
const homepageLoggedIn = new HomepageLoggedIn({ page, iiPage });

await homepageLoggedIn.waitForContentReady();

await expect(page).toHaveScreenshot({ fullPage: true });
}
);
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions e2e/utils/constants/e2e.constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { AppPath } from '$lib/constants/routes.constants';

export const HOMEPAGE_URL = '/';
export const TRANSACTIONS_URL = AppPath.Transactions;

export const LOCAL_REPLICA_URL = 'http://127.0.0.1:4943';

Expand Down
4 changes: 4 additions & 0 deletions e2e/utils/pages/homepage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,10 @@ export class HomepageLoggedIn extends Homepage {

await this.waitForLoaderModal({ state: 'hidden', timeout: 60000 });

await this.waitForContentReady();
}

async waitForContentReady(): Promise<void> {
await this.waitForTokensInitialization();

await this.waitForLoadState();
Expand Down
28 changes: 15 additions & 13 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"@dfinity/candid": "^2.1.2",
"@dfinity/ckbtc": "^3.1.6",
"@dfinity/cketh": "^3.4.3",
"@dfinity/gix-components": "^5.0.0-next-2024-12-10",
"@dfinity/gix-components": "^5.0.0-next-2025-01-31",
"@dfinity/ledger-icp": "^2.6.7",
"@dfinity/ledger-icrc": "^2.7.2",
"@dfinity/oisy-wallet-signer": "^0.1.4",
Expand Down Expand Up @@ -109,14 +109,14 @@
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-svelte": "^3.3.3",
"prettier-plugin-tailwindcss": "^0.6.10",
"sass": "^1.83.1",
"sass": "^1.83.4",
"svelte": "^4.2.19",
"svelte-check": "^4.1.4",
"tailwindcss": "^3.4.17",
"tslib": "^2.8.1",
"typescript": "^5.4.5",
"vite": "^5.4.14",
"vite-node": "^3.0.2",
"vite-node": "^3.0.4",
"vitest": "^2.1.8",
"vitest-mock-extended": "^2.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.84.0"
channel = "1.84.1"
targets = ["wasm32-unknown-unknown"]
2 changes: 1 addition & 1 deletion scripts/build.icp_ledger.args.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -euxo pipefail

# Ensure that a minter id exists:
dfx identity get-principal --identity minter 2>/dev/null || dfx identity new minter
dfx identity get-principal --identity minter 2>/dev/null || dfx identity new minter --storage-mode=plaintext

MINTER_ACCOUNT_ID=$(dfx ledger account-id --identity minter)
CALLER_ACCOUNT_ID=$(dfx ledger account-id)
Expand Down
7 changes: 2 additions & 5 deletions scripts/build.tokens.sns.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,8 @@ const querySnsAggregator = async (page = 0) => {
};

const saveLogos = async (logos) => {
const writeLogo = async ({ icon, ledgerCanisterId, rootCanisterId }) => {
// Use ledger icon and fallback on Sns icon if not existing
const response = await fetch(
nonNullish(icon) ? icon : `${AGGREGATOR_URL}/root/${rootCanisterId}/logo.png`
);
const writeLogo = async ({ icon, ledgerCanisterId }) => {
const response = await fetch(icon);

const blob = await response.blob();

Expand Down
33 changes: 0 additions & 33 deletions src/frontend/src/btc/components/convert/BtcConvertFeeTotal.svelte

This file was deleted.

2 changes: 1 addition & 1 deletion src/frontend/src/env/tokens/tokens.sns.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
"name": "ALICE",
"symbol": "ALICE",
"fee": {
"__bigint__": "100000000"
"__bigint__": "500000000"
},
"alternativeName": "Alice",
"url": "https://alice.fun/"
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp-eth/services/custom-token.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,5 @@ export const setCustomToken = async ({
}) =>
await setCustomTokenApi({
identity,
token: toCustomToken({ ...token, enabled })
token: toCustomToken({ ...token, enabled, networkKey: 'Icrc' })
});
5 changes: 3 additions & 2 deletions src/frontend/src/icp-eth/services/manage-tokens.services.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { saveUserTokens, type SaveUserToken } from '$eth/services/erc20-user-tokens-services';
import { saveCustomTokens, type SaveCustomToken } from '$icp/services/ic-custom-tokens.services';
import { saveCustomTokens } from '$icp/services/ic-custom-tokens.services';
import { saveTokens, type ManageTokensSaveParams } from '$lib/services/manage-tokens.services';
import type { SaveCustomTokenWithKey } from '$lib/types/custom-token';

export const saveErc20UserTokens = async ({
tokens,
Expand All @@ -19,7 +20,7 @@ export const saveIcrcCustomTokens = async ({
tokens,
...rest
}: {
tokens: SaveCustomToken[];
tokens: SaveCustomTokenWithKey[];
} & ManageTokensSaveParams) => {
await saveTokens({
...rest,
Expand Down
9 changes: 2 additions & 7 deletions src/frontend/src/icp/services/ic-custom-tokens.services.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,18 @@
import { loadCustomTokens } from '$icp/services/icrc.services';
import { icrcCustomTokensStore } from '$icp/stores/icrc-custom-tokens.store';
import type { IcrcCustomToken } from '$icp/types/icrc-custom-token';
import { setManyCustomTokens } from '$lib/api/backend.api';
import { ProgressStepsAddToken } from '$lib/enums/progress-steps';
import type { SaveTokensParams } from '$lib/services/manage-tokens.services';
import { i18n } from '$lib/stores/i18n.store';
import type { SaveCustomTokenWithKey } from '$lib/types/custom-token';
import { toCustomToken } from '$lib/utils/custom-token.utils';
import { get } from 'svelte/store';

export type SaveCustomToken = Pick<
IcrcCustomToken,
'enabled' | 'version' | 'ledgerCanisterId' | 'indexCanisterId'
>;

export const saveCustomTokens = async ({
progress,
identity,
tokens
}: SaveTokensParams<SaveCustomToken>) => {
}: SaveTokensParams<SaveCustomTokenWithKey>) => {
progress(ProgressStepsAddToken.SAVE);

await setManyCustomTokens({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import type { Erc20UserToken } from '$eth/types/erc20-user-token';
import type { EthereumNetwork } from '$eth/types/network';
import IcAddTokenReview from '$icp/components/tokens/IcAddTokenReview.svelte';
import type { SaveCustomToken } from '$icp/services/ic-custom-tokens.services';
import type { IcrcCustomToken } from '$icp/types/icrc-custom-token';
import {
saveErc20UserTokens,
Expand All @@ -25,6 +24,7 @@
import { i18n } from '$lib/stores/i18n.store';
import { modalStore } from '$lib/stores/modal.store';
import { toastsError, toastsShow } from '$lib/stores/toasts.store';
import type { SaveCustomTokenWithKey } from '$lib/types/custom-token';
import type { Network } from '$lib/types/network';
import type { TokenMetadata } from '$lib/types/token';
import { isNullishOrEmpty } from '$lib/utils/input.utils';
Expand Down Expand Up @@ -77,7 +77,7 @@
}
await Promise.allSettled([
...(icrc.length > 0 ? [saveIcrc(icrc)] : []),
...(icrc.length > 0 ? [saveIcrc(icrc.map((t) => ({ ...t, networkKey: 'Icrc' })))] : []),
...(erc20.length > 0 ? [saveErc20(erc20)] : []),
...(spl.length > 0 ? [saveSpl(spl)] : [])
]);
Expand All @@ -94,6 +94,7 @@
await saveIcrc([
{
enabled: true,
networkKey: 'Icrc',
ledgerCanisterId,
indexCanisterId
}
Expand Down Expand Up @@ -152,7 +153,7 @@
const progress = (step: ProgressStepsAddToken) => (saveProgressStep = step);
const saveIcrc = (tokens: SaveCustomToken[]): Promise<void> =>
const saveIcrc = (tokens: SaveCustomTokenWithKey[]): Promise<void> =>
saveIcrcCustomTokens({
tokens,
progress,
Expand Down
20 changes: 10 additions & 10 deletions src/frontend/src/lib/components/tokens/TokensDisplayHandler.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@
import { debounce } from '@dfinity/utils';
import { combinedDerivedSortedNetworkTokensUi } from '$lib/derived/network-tokens.derived';
import { showZeroBalances } from '$lib/derived/settings.derived';
import type { TokenUi } from '$lib/types/token';
import type { TokenUiOrGroupUi } from '$lib/types/token-group';
import { groupTokensByTwin } from '$lib/utils/token-group.utils';
import { filterTokenGroups, groupTokensByTwin } from '$lib/utils/token-group.utils';
// We start it as undefined to avoid showing an empty list before the first update.
export let tokens: TokenUiOrGroupUi[] | undefined = undefined;
let sortedTokens: TokenUi[];
$: sortedTokens = $combinedDerivedSortedNetworkTokensUi.filter(
({ balance, usdBalance }) => Number(balance ?? 0n) || (usdBalance ?? 0) || $showZeroBalances
);
let groupedTokens: TokenUiOrGroupUi[];
$: groupedTokens = groupTokensByTwin(sortedTokens);
$: groupedTokens = groupTokensByTwin($combinedDerivedSortedNetworkTokensUi);
let sortedTokensOrGroups: TokenUiOrGroupUi[];
$: sortedTokensOrGroups = filterTokenGroups({
groupedTokens,
showZeroBalances: $showZeroBalances
});
const updateTokensToDisplay = () => (tokens = [...groupedTokens]);
const updateTokensToDisplay = () => (tokens = [...sortedTokensOrGroups]);
const debounceUpdateTokensToDisplay = debounce(updateTokensToDisplay, 500);
$: sortedTokens, debounceUpdateTokensToDisplay();
$: sortedTokensOrGroups, debounceUpdateTokensToDisplay();
</script>

<slot />
2 changes: 1 addition & 1 deletion src/frontend/src/lib/services/token.services.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import type { SaveUserToken } from '$eth/services/erc20-user-tokens-services';
import type { Erc20Token } from '$eth/types/erc20';
import type { SaveCustomToken } from '$icp/services/ic-custom-tokens.services';
import type { IcCkToken } from '$icp/types/ic-token';
import { busy } from '$lib/stores/busy.store';
import { toastsError } from '$lib/stores/toasts.store';
import { token as tokenStore } from '$lib/stores/token.store';
import type { SaveCustomToken } from '$lib/types/custom-token';
import type { OptionIdentity } from '$lib/types/identity';
import type { Token, TokenStandard } from '$lib/types/token';
import type { Identity } from '@dfinity/agent';
Expand Down
13 changes: 13 additions & 0 deletions src/frontend/src/lib/types/custom-token.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import type { IcrcCustomToken } from '$icp/types/icrc-custom-token';
import type { UserTokenState } from '$lib/types/token-toggleable';

export type CustomTokenNetworkKeys = 'Icrc';

export type IcrcSaveCustomToken = Pick<IcrcCustomToken, 'ledgerCanisterId' | 'indexCanisterId'>;

export type SaveCustomToken = UserTokenState & IcrcSaveCustomToken;

export type SaveCustomTokenWithKey = UserTokenState &
(IcrcSaveCustomToken & {
networkKey: Extract<CustomTokenNetworkKeys, 'Icrc'>;
});
Loading

0 comments on commit df4cc3a

Please sign in to comment.