Skip to content

Commit

Permalink
Merge branch 'feat/ic-token-zod' into feat/optional-index-canister
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker authored Nov 5, 2024
2 parents e9caffd + ff5c7a7 commit 8394355
Show file tree
Hide file tree
Showing 56 changed files with 538 additions and 217 deletions.
2 changes: 1 addition & 1 deletion src/frontend/src/btc/components/send/BtcSendForm.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { isNullish, nonNullish } from '@dfinity/utils';
import { onMount } from 'svelte';
import BtcSendAmount from './BtcSendAmount.svelte';
import BtcSendAmount from '$btc/components/send/BtcSendAmount.svelte';
import BtcSendDestination from '$btc/components/send/BtcSendDestination.svelte';
import { loadBtcPendingSentTransactions } from '$btc/services/btc-pending-sent-transactions.services';
import type { BtcAmountAssertionError } from '$btc/types/btc-send';
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/btc/components/send/BtcSendReview.svelte
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<script lang="ts">
import { isNullish } from '@dfinity/utils';
import type { Readable } from 'svelte/store';
import BtcSendWarnings from './BtcSendWarnings.svelte';
import BtcReviewNetwork from '$btc/components/send/BtcReviewNetwork.svelte';
import BtcSendWarnings from '$btc/components/send/BtcSendWarnings.svelte';
import BtcUtxosFee from '$btc/components/send/BtcUtxosFee.svelte';
import {
BtcPendingSentTransactionsStatus,
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/icp-eth/services/eth.services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
type MapCkEthereumPendingTransactionParams
} from '$icp-eth/utils/cketh-transactions.utils';
import { icPendingTransactionsStore } from '$icp/stores/ic-pending-transactions.store';
import type { IcCkLinkedAssets, IcToken, IcTransactionUi } from '$icp/types/ic';
import type { IcCkLinkedAssets, IcToken } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import { nullishSignOut } from '$lib/services/auth.services';
import { i18n } from '$lib/stores/i18n.store';
import { toastsError } from '$lib/stores/toasts.store';
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/icp-eth/utils/cketh-transactions.utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { EthereumNetwork } from '$eth/types/network';
import type { IcCkLinkedAssets, IcToken, IcTransactionUi } from '$icp/types/ic';
import type { IcCkLinkedAssets, IcToken } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import { isNetworkIdETH, isTokenCkErc20Ledger, isTokenCkEthLedger } from '$icp/utils/ic-send.utils';
import { i18n } from '$lib/stores/i18n.store';
import type { NetworkId } from '$lib/types/network';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { BigNumber } from '@ethersproject/bignumber';
import { type ComponentType } from 'svelte';
import IcTransactionLabel from '$icp/components/transactions/IcTransactionLabel.svelte';
import type { IcTransactionType, IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionType, IcTransactionUi } from '$icp/types/ic-transaction';
import IconConvert from '$lib/components/icons/IconConvert.svelte';
import IconConvertFrom from '$lib/components/icons/IconConvertFrom.svelte';
import IconConvertTo from '$lib/components/icons/IconConvertTo.svelte';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { nonNullish } from '@dfinity/utils';
import { BigNumber } from '@ethersproject/bignumber';
import IcTransactionLabel from '$icp/components/transactions/IcTransactionLabel.svelte';
import type { IcTransactionType, IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionType, IcTransactionUi } from '$icp/types/ic-transaction';
import ButtonCloseModal from '$lib/components/ui/ButtonCloseModal.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Copy from '$lib/components/ui/Copy.svelte';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
} from '$icp/derived/ic-token.derived';
import { icTransactions } from '$icp/derived/ic-transactions.derived';
import { loadNextTransactions } from '$icp/services/ic-transactions.services';
import type { IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import TransactionsPlaceholder from '$lib/components/transactions/TransactionsPlaceholder.svelte';
import Header from '$lib/components/ui/Header.svelte';
import { WALLET_PAGINATION } from '$lib/constants/app.constants';
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp/schedulers/ic-wallet.scheduler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IcTransactionAddOnsInfo, IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionAddOnsInfo, IcTransactionUi } from '$icp/types/ic-transaction';
import type { GetTransactions } from '$icp/types/ic.post-message';
import { queryAndUpdate } from '$lib/actors/query.ic';
import { WALLET_TIMER_INTERVAL_MILLIS } from '$lib/constants/app.constants';
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/icp/services/ic-transactions.services.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { getTransactions as getTransactionsIcp } from '$icp/api/icp-index.api';
import { getTransactions as getTransactionsIcrc } from '$icp/api/icrc-index-ng.api';
import { icTransactionsStore } from '$icp/stores/ic-transactions.store';
import type { IcToken, IcTransaction } from '$icp/types/ic';
import type { IcToken } from '$icp/types/ic';
import type { IcTransaction } from '$icp/types/ic-transaction';
import { mapIcTransaction } from '$icp/utils/ic-transactions.utils';
import { mapTransactionIcpToSelf } from '$icp/utils/icp-transactions.utils';
import { mapTransactionIcrcToSelf } from '$icp/utils/icrc-transactions.utils';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { type IcCertifiedTransaction } from '$icp/stores/ic-transactions.store';
import type { IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import { initCertifiedStore, type CertifiedStore } from '$lib/stores/certified.store';
import type { CertifiedData } from '$lib/types/store';
import type { TokenId } from '$lib/types/token';
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp/stores/ic-transactions.store.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import {
initTransactionsStore,
type CertifiedTransaction,
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp/types/btc.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { IcTransactionIdText } from '$icp/types/ic';
import type { IcTransactionIdText } from '$icp/types/ic-transaction';
import type { RetrieveBtcStatusV2 } from '@dfinity/ckbtc';

export type BtcWithdrawalStatuses = Record<IcTransactionIdText, RetrieveBtcStatusV2>;
46 changes: 46 additions & 0 deletions src/frontend/src/icp/types/ic-transaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import type { TransactionType } from '$lib/types/transaction';
import type { Transaction, TransactionWithId } from '@dfinity/ledger-icp';
import type {
IcrcTransaction as IcrcTransactionCandid,
IcrcTransactionWithId
} from '@dfinity/ledger-icrc';

export interface IcTransactionAddOnsInfo {
transferToSelf?: 'send' | 'receive';
}

export type IcpTransaction = { transaction: Transaction & IcTransactionAddOnsInfo } & Pick<
TransactionWithId,
'id'
>;
export type IcrcTransaction = {
transaction: IcrcTransactionCandid & IcTransactionAddOnsInfo;
} & Pick<IcrcTransactionWithId, 'id'>;

export type IcTransaction = IcpTransaction | IcrcTransaction;

export type IcTransactionType = TransactionType | 'approve' | 'burn' | 'mint';

export type IcTransactionIdText = string;

export type IcTransactionStatus = 'executed' | 'pending' | 'reimbursed' | 'failed';

export interface IcTransactionUi {
id: bigint | string;
type: IcTransactionType;
// e.g. BTC Received
typeLabel?: string;
from?: string;
// e.g. From: BTC Network
fromLabel?: string;
fromExplorerUrl?: string;
to?: string;
// e.g. To: BTC Network
toLabel?: string;
toExplorerUrl?: string;
incoming?: boolean;
value?: bigint;
timestamp?: bigint;
status: IcTransactionStatus;
txExplorerUrl?: string;
}
46 changes: 0 additions & 46 deletions src/frontend/src/icp/types/ic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,55 +10,9 @@ import {
IcTokenSchema,
IcTokenWithoutIdSchema
} from '$icp/validation/ic-token.validation';
import type { TransactionType } from '$lib/types/transaction';
import type { Option } from '$lib/types/utils';
import type { Transaction, TransactionWithId } from '@dfinity/ledger-icp';
import type {
IcrcTransaction as IcrcTransactionCandid,
IcrcTransactionWithId
} from '@dfinity/ledger-icrc';
import { z } from 'zod';

export interface IcTransactionAddOnsInfo {
transferToSelf?: 'send' | 'receive';
}

export type IcpTransaction = { transaction: Transaction & IcTransactionAddOnsInfo } & Pick<
TransactionWithId,
'id'
>;
export type IcrcTransaction = {
transaction: IcrcTransactionCandid & IcTransactionAddOnsInfo;
} & Pick<IcrcTransactionWithId, 'id'>;

export type IcTransaction = IcpTransaction | IcrcTransaction;

export type IcTransactionType = TransactionType | 'approve' | 'burn' | 'mint';

export type IcTransactionIdText = string;

export type IcTransactionStatus = 'executed' | 'pending' | 'reimbursed' | 'failed';

export interface IcTransactionUi {
id: bigint | string;
type: IcTransactionType;
// e.g. BTC Received
typeLabel?: string;
from?: string;
// e.g. From: BTC Network
fromLabel?: string;
fromExplorerUrl?: string;
to?: string;
// e.g. To: BTC Network
toLabel?: string;
toExplorerUrl?: string;
incoming?: boolean;
value?: bigint;
timestamp?: bigint;
status: IcTransactionStatus;
txExplorerUrl?: string;
}

export type IcFee = z.infer<typeof IcFeeSchema>;

export type IcAppMetadata = z.infer<typeof IcAppMetadataSchema>;
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/icp/utils/ckbtc-transactions.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
import { IC_CKBTC_LEDGER_CANISTER_ID } from '$env/networks.icrc.env';
import type { BtcStatusesData } from '$icp/stores/btc.store';
import type { IcCertifiedTransaction } from '$icp/stores/ic-transactions.store';
import type { IcToken, IcTransactionUi, IcrcTransaction } from '$icp/types/ic';
import type { IcToken } from '$icp/types/ic';
import type { IcTransactionUi, IcrcTransaction } from '$icp/types/ic-transaction';
import { utxoTxIdToString } from '$icp/utils/btc.utils';
import { MINT_MEMO_KYT_FAIL, decodeBurnMemo, decodeMintMemo } from '$icp/utils/ckbtc-memo.utils';
import { mapIcrcTransaction } from '$icp/utils/icrc-transactions.utils';
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/icp/utils/cketh-transactions.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
STAGING_CKETH_LEDGER_CANISTER_ID
} from '$env/networks.icrc.env';
import { mapAddressStartsWith0x } from '$icp-eth/utils/eth.utils';
import type { IcToken, IcTransactionUi, IcrcTransaction } from '$icp/types/ic';
import type { IcToken } from '$icp/types/ic';
import type { IcTransactionUi, IcrcTransaction } from '$icp/types/ic-transaction';
import {
MINT_MEMO_REIMBURSE_TRANSACTION,
MINT_MEMO_REIMBURSE_WITHDRAWAL,
Expand Down
11 changes: 5 additions & 6 deletions src/frontend/src/icp/utils/ic-transactions.utils.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { ICP_TOKEN_ID } from '$env/tokens.env';
import type { BtcStatusesData } from '$icp/stores/btc.store';
import type { IcCertifiedTransaction } from '$icp/stores/ic-transactions.store';
import type { IcCkToken, IcToken } from '$icp/types/ic';
import type {
IcCkToken,
IcpTransaction,
IcrcTransaction,
IcToken,
IcTransaction,
IcTransactionUi
} from '$icp/types/ic';
IcTransactionUi,
IcpTransaction,
IcrcTransaction
} from '$icp/types/ic-transaction';
import { extendCkBTCTransaction, mapCkBTCTransaction } from '$icp/utils/ckbtc-transactions.utils';
import { mapCkEthereumTransaction } from '$icp/utils/cketh-transactions.utils';
import {
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/src/icp/utils/icp-transactions.utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { ICP_EXPLORER_URL } from '$env/explorers.env';
import type { IcpTransaction, IcTransactionAddOnsInfo, IcTransactionUi } from '$icp/types/ic';
import type {
IcTransactionAddOnsInfo,
IcTransactionUi,
IcpTransaction
} from '$icp/types/ic-transaction';
import { getAccountIdentifier } from '$icp/utils/icp-account.utils';
import type { OptionIdentity } from '$lib/types/identity';
import type { Tokens, Transaction, TransactionWithId } from '@dfinity/ledger-icp';
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/src/icp/utils/icrc-transactions.utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
import type { IcrcTransaction, IcTransactionType, IcTransactionUi } from '$icp/types/ic';
import type {
IcTransactionType,
IcTransactionUi,
IcrcTransaction
} from '$icp/types/ic-transaction';
import { getIcrcAccount } from '$icp/utils/icrc-account.utils';
import type { OptionIdentity } from '$lib/types/identity';
import { encodeIcrcAccount, type IcrcTransactionWithId } from '@dfinity/ledger-icrc';
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/icp/validation/ic-token.validation.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CanisterIdTextSchema } from '$lib/types/canister';
import { CoingeckoCoinsIdSchema } from '$lib/types/coingecko';
import { TokenSchema } from '$lib/types/token';
import { CoingeckoCoinsIdSchema } from '$lib/validation/coingecko.validation';
import { TokenSchema } from '$lib/validation/token.validation';
import { UrlSchema } from '$lib/validation/url.validation';
import { z } from 'zod';

Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp/workers/icp-wallet.worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTransactions as getTransactionsApi } from '$icp/api/icp-index.api';
import { IcWalletScheduler } from '$icp/schedulers/ic-wallet.scheduler';
import type { IcTransactionAddOnsInfo, IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionAddOnsInfo, IcTransactionUi } from '$icp/types/ic-transaction';
import { mapIcpTransaction, mapTransactionIcpToSelf } from '$icp/utils/icp-transactions.utils';
import type { SchedulerJobData, SchedulerJobParams } from '$lib/schedulers/scheduler';
import type { PostMessage, PostMessageDataRequest } from '$lib/types/post-message';
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/icp/workers/icrc-wallet.worker.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { getTransactions as getTransactionsApi } from '$icp/api/icrc-index-ng.api';
import { IcWalletScheduler } from '$icp/schedulers/ic-wallet.scheduler';
import type { IcTransactionUi } from '$icp/types/ic';
import type { IcTransactionUi } from '$icp/types/ic-transaction';
import { mapCkBTCTransaction } from '$icp/utils/ckbtc-transactions.utils';
import { mapCkEthereumTransaction } from '$icp/utils/cketh-transactions.utils';
import {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<script lang="ts">
import { createEventDispatcher } from 'svelte';
import AboutItem from '$lib/components/hero/about/AboutItem.svelte';
import AboutItem from '$lib/components/about/AboutItem.svelte';
import IconInfo from '$lib/components/icons/lucide/IconInfo.svelte';
import { ABOUT_WHY_OISY_BUTTON } from '$lib/constants/test-ids.constants';
import { i18n } from '$lib/stores/i18n.store';
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/lib/components/core/Menu.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
import { IconUser, Popover } from '@dfinity/gix-components';
import { goto } from '$app/navigation';
import { page } from '$app/stores';
import AboutWhyOisy from '$lib/components/about/AboutWhyOisy.svelte';
import MenuAddresses from '$lib/components/core/MenuAddresses.svelte';
import SignOut from '$lib/components/core/SignOut.svelte';
import AboutWhyOisy from '$lib/components/hero/about/AboutWhyOisy.svelte';
import IconGitHub from '$lib/components/icons/IconGitHub.svelte';
import IconlySettings from '$lib/components/icons/iconly/IconlySettings.svelte';
import IconlyUfo from '$lib/components/icons/iconly/IconlyUfo.svelte';
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/lib/components/hero/Header.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
import WalletConnect from '$eth/components/wallet-connect/WalletConnect.svelte';
import AboutWhyOisy from '$lib/components/about/AboutWhyOisy.svelte';
import AboutWhyOisyModal from '$lib/components/about/AboutWhyOisyModal.svelte';
import Menu from '$lib/components/core/Menu.svelte';
import OisyWalletLogoLink from '$lib/components/core/OisyWalletLogoLink.svelte';
import AboutWhyOisy from '$lib/components/hero/about/AboutWhyOisy.svelte';
import AboutWhyOisyModal from '$lib/components/hero/about/AboutWhyOisyModal.svelte';
import { authNotSignedIn, authSignedIn } from '$lib/derived/auth.derived';
import { modalAboutWhyOisy } from '$lib/derived/modal.derived';
</script>
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/lib/components/navigation/InfoMenu.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts">
import AboutWhyOisy from '$lib/components/hero/about/AboutWhyOisy.svelte';
import AboutWhyOisy from '$lib/components/about/AboutWhyOisy.svelte';
import ChangelogLink from '$lib/components/navigation/ChangelogLink.svelte';
</script>

Expand Down
8 changes: 1 addition & 7 deletions src/frontend/src/lib/components/settings/Settings.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
<script lang="ts">
import SettingsSignedIn from '$lib/components/settings/SettingsSignedIn.svelte';
import SettingsSignedOut from '$lib/components/settings/SettingsSignedOut.svelte';
import SettingsVersion from '$lib/components/settings/SettingsVersion.svelte';
import { authSignedIn } from '$lib/derived/auth.derived';
</script>

{#if $authSignedIn}
<SettingsSignedIn />
{:else}
<SettingsSignedOut />
{/if}
<SettingsSignedIn />

<SettingsVersion />

This file was deleted.

12 changes: 0 additions & 12 deletions src/frontend/src/lib/components/tokens/TokenCardSignedOut.svelte

This file was deleted.

Loading

0 comments on commit 8394355

Please sign in to comment.