Skip to content

Commit

Permalink
chore: merge main
Browse files Browse the repository at this point in the history
  • Loading branch information
peterpeterparker committed Nov 6, 2024
2 parents 575530a + ca05ca0 commit eb79808
Show file tree
Hide file tree
Showing 13 changed files with 438 additions and 62 deletions.
2 changes: 2 additions & 0 deletions src/frontend/src/env/exchange.env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const EXCHANGE_DISABLED =
JSON.parse(import.meta.env.VITE_EXCHANGE_DISABLED ?? false) === true;
5 changes: 3 additions & 2 deletions src/frontend/src/lib/components/dapps/DappModal.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<script lang="ts">
import { Html, IconGitHub, Modal } from '@dfinity/gix-components';
import { Html, Modal } from '@dfinity/gix-components';
import { nonNullish } from '@dfinity/utils';
import DappTags from '$lib/components/dapps/DappTags.svelte';
import IconGitHub from '$lib/components/icons/IconGitHub.svelte';
import IconOpenChat from '$lib/components/icons/IconOpenChat.svelte';
import IconTelegram from '$lib/components/icons/IconTelegram.svelte';
import IconTwitter from '$lib/components/icons/IconTwitter.svelte';
Expand Down Expand Up @@ -106,7 +107,7 @@
$dAppName: dAppName
})}
>
<IconTwitter />
<IconTwitter size="22" />
</ExternalLinkIcon>
{/if}
{#if nonNullish(github)}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
<script lang="ts">
import { debounce } from '@dfinity/utils';
import { onDestroy, onMount } from 'svelte';
import { EXCHANGE_DISABLED } from '$env/exchange.env';
import { enabledIcrcLedgerCanisterIdsNoCk } from '$icp/derived/icrc.derived';
import { enabledMergedErc20TokensAddresses } from '$icp-eth/derived/icrc-erc20.derived';
import { type ExchangeWorker, initExchangeWorker } from '$lib/services/worker.exchange.services';
let worker: ExchangeWorker | undefined;
const EXCHANGE_DISABLED = JSON.parse(import.meta.env.VITE_EXCHANGE_DISABLED ?? false) === true;
onMount(async () => {
if (EXCHANGE_DISABLED) {
// Using the exchange API during development if not necessary and given its limitation of calls per minute is annoying at it often throws errors on server reload.
Expand Down
28 changes: 13 additions & 15 deletions src/frontend/src/lib/components/icons/IconGitHub.svelte
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path
d="M13.4167 18V15.7071C13.4479 15.3261 13.3943 14.9431 13.2592 14.5836C13.1241 14.2241 12.9108 13.8962 12.6334 13.6219C15.25 13.3422 18 12.3915 18 8.02935C17.9997 6.91391 17.5523 5.84125 16.75 5.03337C17.1298 4.05749 17.103 2.9788 16.675 2.02141C16.675 2.02141 15.6917 1.74178 13.4167 3.20382C11.5067 2.70754 9.49337 2.70754 7.58338 3.20382C5.30839 1.74178 4.32506 2.02141 4.32506 2.02141C3.89703 2.9788 3.87018 4.05749 4.25006 5.03337C3.44183 5.84724 2.99383 6.9296 3.00006 8.05332C3.00006 12.3835 5.75004 13.3343 8.3667 13.6458C8.09253 13.9175 7.88109 14.2414 7.74612 14.5965C7.61117 14.9516 7.55571 15.3301 7.58338 15.7071V18"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<path
d="M7 16.6756C4.85714 17.5436 3.07143 16.6756 2 14"
stroke="currentColor"
stroke-width="1.5"
stroke-linecap="round"
stroke-linejoin="round"
/>
<script lang="ts">
export let size = '20';
</script>

<svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2345_9164)">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M12 0C5.3724 0 0 5.3808 0 12.0204C0 17.3304 3.438 21.8364 8.2068 23.4252C8.8068 23.5356 9.0252 23.1648 9.0252 22.8456C9.0252 22.5612 9.0156 21.804 9.0096 20.802C5.6712 21.528 4.9668 19.1904 4.9668 19.1904C4.422 17.8008 3.6348 17.4312 3.6348 17.4312C2.5452 16.6872 3.7176 16.7016 3.7176 16.7016C4.9212 16.7856 5.5548 17.94 5.5548 17.94C6.6252 19.776 8.364 19.2456 9.0468 18.9384C9.1572 18.162 9.4668 17.6328 9.81 17.3328C7.146 17.0292 4.344 15.9972 4.344 11.3916C4.344 10.08 4.812 9.006 5.5788 8.166C5.4552 7.8624 5.0436 6.6396 5.6964 4.986C5.6964 4.986 6.7044 4.662 8.9964 6.2172C9.97532 5.95022 10.9853 5.81423 12 5.8128C13.02 5.8176 14.046 5.9508 15.0048 6.2172C17.2956 4.662 18.3012 4.9848 18.3012 4.9848C18.9564 6.6396 18.5436 7.8624 18.4212 8.166C19.1892 9.006 19.6548 10.08 19.6548 11.3916C19.6548 16.0092 16.848 17.0256 14.1756 17.3232C14.6064 17.694 14.9892 18.4272 14.9892 19.5492C14.9892 21.1548 14.9748 22.452 14.9748 22.8456C14.9748 23.1672 15.1908 23.5416 15.8004 23.424C18.19 22.6225 20.2672 21.0904 21.7386 19.0441C23.2099 16.9977 24.001 14.5408 24 12.0204C24 5.3808 18.6264 0 12 0Z"
fill="currentColor"
/>
</g>
</svg>
24 changes: 13 additions & 11 deletions src/frontend/src/lib/components/icons/IconTwitter.svelte
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
<!-- source: DFINITY foundation -->
<svg
width="16"
height="20"
viewBox="0 0 16 20"
fill="currentColor"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M12.6009 2.94141H15.0544L9.69434 8.9215L16 17.0591H11.0627L7.19566 12.1237L2.77087 17.0591H0.31595L6.04904 10.6627L0 2.94141H5.06262L8.55811 7.45254L12.6009 2.94141ZM11.7399 15.6256H13.0993L4.32392 4.2996H2.86506L11.7399 15.6256Z"
/>
<script lang="ts">
export let size = '20';
</script>

<svg width={size} height={size} viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<g clip-path="url(#clip0_2345_9171)">
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M15.9455 23L10.396 15.0901L3.44886 23H0.509766L9.09209 13.2311L0.509766 1H8.05571L13.286 8.45502L19.8393 1H22.7784L14.5943 10.3165L23.4914 23H15.9455ZM19.2185 20.77H17.2398L4.71811 3.23H6.6971L11.7121 10.2532L12.5793 11.4719L19.2185 20.77Z"
fill="currentColor"
/>
</g>
</svg>
7 changes: 5 additions & 2 deletions src/frontend/src/lib/derived/exchange.derived.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EXCHANGE_DISABLED } from '$env/exchange.env';
import {
BTC_MAINNET_TOKEN_ID,
BTC_REGTEST_TOKEN_ID,
Expand All @@ -13,10 +14,12 @@ import type { ExchangesData } from '$lib/types/exchange';
import { nonNullish } from '@dfinity/utils';
import { derived, type Readable } from 'svelte/store';

export const exchangeInitialized: Readable<boolean> = derived([exchangeStore], ([$exchangeStore]) =>
nonNullish($exchangeStore)
export const exchangeInitialized: Readable<boolean> = derived(
[exchangeStore],
([$exchangeStore]) => EXCHANGE_DISABLED || nonNullish($exchangeStore)
);

// TODO: create tests for store
export const exchanges: Readable<ExchangesData> = derived(
[exchangeStore, enabledErc20Tokens, enabledIcrcTokens],
([$exchangeStore, $erc20Tokens, $icrcTokens]) => {
Expand Down
9 changes: 7 additions & 2 deletions src/frontend/src/lib/validation/token.validation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { TokenIdSchema } from '$lib/schema/token.schema';
import type { TokenId } from '$lib/types/token';
import { TokenIdSchema, TokenSchema } from '$lib/schema/token.schema';
import type { Token, TokenId } from '$lib/types/token';
import { z } from 'zod';

const TokenIdStringSchema = z.string();
Expand All @@ -8,3 +8,8 @@ export const parseTokenId = (tokenIdString: z.infer<typeof TokenIdStringSchema>)
const validString = TokenIdStringSchema.parse(tokenIdString);
return TokenIdSchema.parse(Symbol(validString));
};

export const isToken = (token: unknown): token is Token => {
const { success } = TokenSchema.safeParse(token);
return success;
};
Loading

0 comments on commit eb79808

Please sign in to comment.