Skip to content

Commit

Permalink
Merge branch 'main' into bindings-slice
Browse files Browse the repository at this point in the history
  • Loading branch information
bitdivine authored Dec 17, 2024
2 parents 3c8021a + 90d529b commit 002cd66
Show file tree
Hide file tree
Showing 44 changed files with 463 additions and 57 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ic-stable-structures = "0.6.7"
ic-metrics-encoder = "1.1.1"
ic-canister-sig-creation = "1.1.0"
ic-verifiable-credentials = "1.0.1"
candid = "0.10.10"
candid = "0.10.11"
ethers-core = "= 2.0.11"
futures = "0.3"
serde = "1"
Expand Down
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.
9 changes: 4 additions & 5 deletions e2e/receive-tokens-modal.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import {
RECEIVE_TOKENS_MODAL,
RECEIVE_TOKENS_MODAL_BTC_MAINNET_SECTION,
RECEIVE_TOKENS_MODAL_BTC_REGTEST_SECTION,
RECEIVE_TOKENS_MODAL_BTC_TESTNET_SECTION,
RECEIVE_TOKENS_MODAL_ETH_SECTION,
RECEIVE_TOKENS_MODAL_ICP_SECTION,
RECEIVE_TOKENS_MODAL_ICRC_SECTION,
Expand Down Expand Up @@ -39,9 +37,10 @@ testWithII('should display receive-tokens modal', async () => {
RECEIVE_TOKENS_MODAL_ICRC_SECTION,
RECEIVE_TOKENS_MODAL_ICP_SECTION,
RECEIVE_TOKENS_MODAL_ETH_SECTION,
RECEIVE_TOKENS_MODAL_BTC_MAINNET_SECTION,
RECEIVE_TOKENS_MODAL_BTC_TESTNET_SECTION,
RECEIVE_TOKENS_MODAL_BTC_REGTEST_SECTION
RECEIVE_TOKENS_MODAL_BTC_MAINNET_SECTION
// TODO: Adjust test to activate testnet setting first
// RECEIVE_TOKENS_MODAL_BTC_TESTNET_SECTION,
// RECEIVE_TOKENS_MODAL_BTC_REGTEST_SECTION
])
});
});
Expand Down
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.
11 changes: 2 additions & 9 deletions e2e/utils/pages/activity.page.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,15 @@
import type { Page } from '@playwright/test';
import { ACTIVITY_URL } from '../constants/e2e.constants';
import { NAVIGATION_ITEM_ACTIVITY } from '$lib/constants/test-ids.constants';
import { HomepageLoggedIn, type HomepageLoggedInParams } from './homepage.page';

export type ActivityPageParams = HomepageLoggedInParams;

export class ActivityPage extends HomepageLoggedIn {
// TODO: Remove this variable, when the activity page is implemented
readonly #page: Page;

constructor({ page, iiPage, viewportSize }: ActivityPageParams) {
super({ page, iiPage, viewportSize });

this.#page = page;
}

// TODO: Implement this method clicking on the navigation item instead of using the URL, when the activity page is implemented
override async extendWaitForReady(): Promise<void> {
await this.#page.goto(ACTIVITY_URL);
await this.navigateTo(NAVIGATION_ITEM_ACTIVITY);
await this.waitForLoadState();
}
}
2 changes: 1 addition & 1 deletion e2e/utils/pages/explorer.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ExplorerPage extends HomepageLoggedIn {
}

override async extendWaitForReady(): Promise<void> {
await this.clickByTestId(NAVIGATION_ITEM_EXPLORER);
await this.navigateTo(NAVIGATION_ITEM_EXPLORER);
await this.waitForLoadState();
}
}
18 changes: 18 additions & 0 deletions e2e/utils/pages/homepage.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ abstract class Homepage {
await this.#page.getByTestId(testId).click();
}

protected async isVisibleByTestId(testId: string): Promise<boolean> {
const element = this.#page.locator(`[data-tid="${testId}"]`);
return await element.isVisible();
}

private async isSelectorVisible({ selector }: SelectorOperationParams): Promise<boolean> {
return await this.#page.isVisible(selector);
}
Expand Down Expand Up @@ -216,6 +221,19 @@ abstract class Homepage {
await this.#page.waitForLoadState('networkidle');
}

async navigateTo(testId: string): Promise<void> {
if (await this.isVisibleByTestId(testId)) {
await this.clickByTestId(testId);
} else {
if (await this.isVisibleByTestId(NAVIGATION_MENU_BUTTON)) {
await this.clickByTestId(NAVIGATION_MENU_BUTTON);
}
if (await this.isVisibleByTestId(testId)) {
await this.clickByTestId(testId);
}
}
}

abstract extendWaitForReady(): Promise<void>;

abstract waitForReady(): Promise<void>;
Expand Down
2 changes: 1 addition & 1 deletion e2e/utils/pages/settings.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class SettingsPage extends HomepageLoggedIn {
}

override async extendWaitForReady(): Promise<void> {
await this.clickByTestId(NAVIGATION_ITEM_SETTINGS);
await this.navigateTo(NAVIGATION_ITEM_SETTINGS);

await this.mockSelector({ selector: `[data-tid="${SETTINGS_ADDRESS_LABEL}"]` });

Expand Down
41 changes: 20 additions & 21 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 @@ -76,7 +76,7 @@
"@dfinity/eslint-config-oisy-wallet": "^0.0.6",
"@dfinity/identity-secp256k1": "^2.1.2",
"@dfinity/internet-identity-playwright": "^0.0.4",
"@playwright/test": "^1.49.0",
"@playwright/test": "^1.49.1",
"@rollup/plugin-inject": "^5.0.5",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.11.1",
Expand All @@ -94,11 +94,11 @@
"jsqr": "^1.4.0",
"pem-file": "^1.0.1",
"postcss": "^8.4.49",
"prettier": "^3.4.1",
"prettier": "^3.4.2",
"prettier-plugin-organize-imports": "^4.1.0",
"prettier-plugin-svelte": "^3.3.2",
"prettier-plugin-tailwindcss": "^0.6.9",
"sass": "^1.81.0",
"sass": "^1.83.0",
"svelte": "^4.2.19",
"svelte-check": "^4.1.1",
"tailwindcss": "^3.4.15",
Expand Down
7 changes: 7 additions & 0 deletions src/frontend/src/env/networks/networks.sol.env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { SchnorrKeyId } from '$declarations/signer/signer.did';
import { SIGNER_ROOT_KEY_NAME } from '$env/signer.env';
import solDevnetIconBW from '$lib/assets/networks/sol-devnet-bw.svg';
import solLocalnetIconBW from '$lib/assets/networks/sol-localnet-bw.svg';
import solMainnetIconBW from '$lib/assets/networks/sol-mainnet-bw.svg';
Expand Down Expand Up @@ -61,3 +63,8 @@ export const SOLANA_LOCAL_NETWORK: Network = {
// TODO: to be removed when the feature is fully implemented
export const SOLANA_NETWORK_ENABLED =
JSON.parse(import.meta.env.VITE_SOLANA_NETWORK_ENABLED ?? false) === true;

export const SOLANA_KEY_ID: SchnorrKeyId = {
algorithm: { ed25519: null },
name: SIGNER_ROOT_KEY_NAME
};
7 changes: 7 additions & 0 deletions src/frontend/src/env/signer.env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { BETA, PROD, STAGING } from '$lib/constants/app.constants';

// According to:
// https://internetcomputer.org/docs/current/references/samples/rust/threshold-ecdsa/#deploying-the-canister-on-the-mainnet
// https://internetcomputer.org/docs/current/developer-docs/smart-contracts/signatures/signing-messages-t-schnorr#signing-messages
export const SIGNER_ROOT_KEY_NAME =
PROD || BETA ? 'key_1' : STAGING ? 'test_key_1' : 'dfx_test_key';
53 changes: 51 additions & 2 deletions src/frontend/src/lib/api/idb.api.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
import { browser } from '$app/environment';
import { ETHEREUM_NETWORK_SYMBOL } from '$env/networks/networks.env';
import {
SOLANA_DEVNET_NETWORK_SYMBOL,
SOLANA_LOCAL_NETWORK_SYMBOL,
SOLANA_MAINNET_NETWORK_SYMBOL,
SOLANA_TESTNET_NETWORK_SYMBOL
} from '$env/networks/networks.sol.env';
import { BTC_MAINNET_SYMBOL, BTC_TESTNET_SYMBOL } from '$env/tokens/tokens.btc.env';
import type { BtcAddress, EthAddress } from '$lib/types/address';
import type { IdbBtcAddress, IdbEthAddress, SetIdbAddressParams } from '$lib/types/idb';
import type { BtcAddress, EthAddress, SolAddress } from '$lib/types/address';
import type {
IdbBtcAddress,
IdbEthAddress,
IdbSolAddress,
SetIdbAddressParams
} from '$lib/types/idb';
import type { Principal } from '@dfinity/principal';
import { isNullish } from '@dfinity/utils';
import { createStore, del, get, set, update, type UseStore } from 'idb-keyval';
Expand All @@ -16,6 +27,11 @@ const idbBtcAddressesStoreTestnet = idbAddressesStore(BTC_TESTNET_SYMBOL.toLower

const idbEthAddressesStore = idbAddressesStore(ETHEREUM_NETWORK_SYMBOL.toLowerCase());

const idbSolAddressesStoreMainnet = idbAddressesStore(SOLANA_MAINNET_NETWORK_SYMBOL.toLowerCase());
const idbSolAddressesStoreTestnet = idbAddressesStore(SOLANA_TESTNET_NETWORK_SYMBOL.toLowerCase());
const idbSolAddressesStoreDevnet = idbAddressesStore(SOLANA_DEVNET_NETWORK_SYMBOL.toLowerCase());
const idbSolAddressesStoreLocal = idbAddressesStore(SOLANA_LOCAL_NETWORK_SYMBOL.toLowerCase());

export const setIdbBtcAddressMainnet = ({
address,
principal
Expand All @@ -34,6 +50,30 @@ export const setIdbEthAddress = ({
}: SetIdbAddressParams<EthAddress>): Promise<void> =>
set(principal.toText(), address, idbEthAddressesStore);

export const setIdbSolAddressMainnet = ({
address,
principal
}: SetIdbAddressParams<SolAddress>): Promise<void> =>
set(principal.toText(), address, idbSolAddressesStoreMainnet);

export const setIdbSolAddressTestnet = ({
address,
principal
}: SetIdbAddressParams<SolAddress>): Promise<void> =>
set(principal.toText(), address, idbSolAddressesStoreTestnet);

export const setIdbSolAddressDevnet = ({
address,
principal
}: SetIdbAddressParams<SolAddress>): Promise<void> =>
set(principal.toText(), address, idbSolAddressesStoreDevnet);

export const setIdbSolAddressLocal = ({
address,
principal
}: SetIdbAddressParams<SolAddress>): Promise<void> =>
set(principal.toText(), address, idbSolAddressesStoreLocal);

const updateIdbAddressLastUsage = ({
principal,
idbAddressesStore
Expand Down Expand Up @@ -62,14 +102,23 @@ export const updateIdbBtcAddressMainnetLastUsage = (principal: Principal): Promi
export const updateIdbEthAddressLastUsage = (principal: Principal): Promise<void> =>
updateIdbAddressLastUsage({ principal, idbAddressesStore: idbEthAddressesStore });

export const updateIdbSolAddressMainnetLastUsage = (principal: Principal): Promise<void> =>
updateIdbAddressLastUsage({ principal, idbAddressesStore: idbSolAddressesStoreMainnet });

export const getIdbBtcAddressMainnet = (principal: Principal): Promise<IdbBtcAddress | undefined> =>
get(principal.toText(), idbBtcAddressesStoreMainnet);

export const getIdbEthAddress = (principal: Principal): Promise<IdbEthAddress | undefined> =>
get(principal.toText(), idbEthAddressesStore);

export const getIdbSolAddressMainnet = (principal: Principal): Promise<IdbSolAddress | undefined> =>
get(principal.toText(), idbSolAddressesStoreMainnet);

export const deleteIdbBtcAddressMainnet = (principal: Principal): Promise<void> =>
del(principal.toText(), idbBtcAddressesStoreMainnet);

export const deleteIdbEthAddress = (principal: Principal): Promise<void> =>
del(principal.toText(), idbEthAddressesStore);

export const deleteIdbSolAddressMainnet = (principal: Principal): Promise<void> =>
del(principal.toText(), idbSolAddressesStoreMainnet);
Loading

0 comments on commit 002cd66

Please sign in to comment.