Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(frontend): activity incomplete transaction list #3700

Open
wants to merge 17 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,30 @@
<script lang="ts">
import type { Token } from '@dfinity/utils';
import AllTransactionsList from '$lib/components/transactions/AllTransactionsList.svelte';
import MessageBox from '$lib/components/ui/MessageBox.svelte';
import PageTitle from '$lib/components/ui/PageTitle.svelte';
import { enabledNetworkTokensWithoutIndexCanister } from '$lib/derived/network-tokens.derived';
import { i18n } from '$lib/stores/i18n.store';
import { replacePlaceholders } from '$lib/utils/i18n.utils.js';

let enabledTokensWithoutCanister: Token[];
$: enabledTokensWithoutCanister = $enabledNetworkTokensWithoutIndexCanister;

let tokenList: string;
$: tokenList = enabledTokensWithoutCanister.map((token) => `$${token.symbol}`).join(', ');
peterpeterparker marked this conversation as resolved.
Show resolved Hide resolved
</script>

<div class="flex flex-col gap-5">
<PageTitle>{$i18n.activity.text.title}</PageTitle>

{#if tokenList}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tokenList is never undefined, what's the goal of this check?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This check will return false if the tokenList is undefined, null or empty. If no token were found than the tokenList will be empty and the MessageBox will not be displayed. It works as expected.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or empty.

I don't think so.

Capture d’écran 2024-11-22 à 09 07 51

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterpeterparker
But your test is wrong. The tokenList is not an array but the list of the tokens as string. It is an empty string.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ahhh my bad! Sorry!

Nitpick then: can you use notEmptyString(tokensList)

<MessageBox level="light-warning" closableKey="oisy_ic_hide_incomplete_transaction_list">
{replacePlaceholders($i18n.activity.warning.incomplete_transaction_list, {
$token_list: tokenList
})}
</MessageBox>
{/if}

<MessageBox level="plain" closableKey="oisy_ic_hide_bitcoin_activity">
{$i18n.activity.info.btc_transactions}
</MessageBox>
Expand Down
17 changes: 17 additions & 0 deletions src/frontend/src/lib/derived/network-tokens.derived.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
import { btcTransactionsStore } from '$btc/stores/btc-transactions.store';
import { ethTransactionsStore } from '$eth/stores/eth-transactions.store';
import { icTransactionsStore } from '$icp/stores/ic-transactions.store';
import { exchanges } from '$lib/derived/exchange.derived';
import { pseudoNetworkChainFusion, selectedNetwork } from '$lib/derived/network.derived';
import { enabledTokens, tokensToPin } from '$lib/derived/tokens.derived';
Expand Down Expand Up @@ -36,3 +39,17 @@ export const combinedDerivedSortedNetworkTokensUi: Readable<TokenUi[]> = derived
$exchanges
})
);

/**
* All user-enabled tokens matching the selected network or chain fusion that do not have an index canister.
*/
export const enabledNetworkTokensWithoutIndexCanister: Readable<Token[]> = derived(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Is there plan to reuse this information anywhere else? If not, I would scope the information to the component. I think a lean approach about adding new stores is for the best given our performance issues.

  • Why considering ETH and BTC? Should you just iterate on enabledIcrcTokens or enabledIcrcTokensNoCk?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterpeterparker
No, at the moment it is not planed to reuse it anywhere else. I guess you are right, i should move the implementation into the component.

Why not? Isn't it possible that an ETH or BTC does not have an Index canister?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, at the moment it is not planed to reuse it anywhere else. I guess you are right, i should move the implementation into the component.

I would say let's do that if that works for you?

Isn't it possible that an ETH or BTC

Canisters only existing on the Internet Computer that's why I'm wondering why we are considering Ethereum and Bitcoin, unless e.g. ckBTC or ckETH are listed explicitely within this derived stores but, I don't think it's the case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@peterpeterparker
That's ok for me, i just moved the implementation into the component.

Hmm, i guess you are right.

[enabledNetworkTokens, btcTransactionsStore, ethTransactionsStore, icTransactionsStore],
([$enabledNetworkTokens, $btcTransactionsStore, $ethTransactionsStore, $icTransactionsStore]) =>
$enabledNetworkTokens.filter(
(token: Token) =>
$btcTransactionsStore?.[token.id] === null ||
$ethTransactionsStore?.[token.id] === null ||
$icTransactionsStore?.[token.id] === null
)
);
3 changes: 3 additions & 0 deletions src/frontend/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,9 @@
},
"info": {
"btc_transactions": "BTC transaction information is obtained from central third parties and should be independently verified."
},
"warning": {
"incomplete_transaction_list": "Transaction list is incomplete because $token_list don't have an index canister to provide transaction information."
peterpeterparker marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
1 change: 1 addition & 0 deletions src/frontend/src/lib/types/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -697,6 +697,7 @@ interface I18nLicense_agreement {
interface I18nActivity {
text: { title: string };
info: { btc_transactions: string };
warning: { incomplete_transaction_list: string };
}

interface I18n {
Expand Down
3 changes: 2 additions & 1 deletion src/frontend/src/lib/utils/info.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export type HideInfoKey =
| 'oisy_ic_hide_bitcoin_info'
| 'oisy_ic_hide_ethereum_info'
| 'oisy_ic_hide_erc20_info'
| 'oisy_ic_hide_bitcoin_activity';
| 'oisy_ic_hide_bitcoin_activity'
| 'oisy_ic_hide_incomplete_transaction_list';

export const saveHideInfo = (key: HideInfoKey) => {
try {
Expand Down