Skip to content

Commit

Permalink
Merge branch 'main' into feat(backend)/derive-btc-address
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonioVentilii-DFINITY authored Aug 12, 2024
2 parents e9f2021 + 06fa977 commit c9fb75e
Show file tree
Hide file tree
Showing 53 changed files with 357 additions and 300 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/frontend-remove-unused-components.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ jobs:
if ! git diff --cached --quiet; then
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
DELETED_FILES=$(git diff --cached --name-only)
echo "DELETED_FILES=${DELETED_FILES}" >> $GITHUB_ENV
echo "DELETED_FILES<<EOF" >> $GITHUB_ENV
echo "$DELETED_FILES" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
fi
# This action creates a PR only if there are changes.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dfinity/oisy-wallet",
"version": "0.0.31",
"version": "0.0.32",
"private": true,
"license": "Apache-2.0",
"repository": {
Expand Down
15 changes: 13 additions & 2 deletions src/frontend/src/env/networks.icrc.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { LINK_TOKEN, SEPOLIA_LINK_TOKEN } from '$env/tokens-erc20/tokens.link.en
import { OCT_TOKEN } from '$env/tokens-erc20/tokens.oct.env';
import { PEPE_TOKEN, SEPOLIA_PEPE_TOKEN } from '$env/tokens-erc20/tokens.pepe.env';
import { SHIB_TOKEN } from '$env/tokens-erc20/tokens.shib.env';
import { UNI_TOKEN } from '$env/tokens-erc20/tokens.uni.env';
import { SEPOLIA_USDC_TOKEN, USDC_TOKEN } from '$env/tokens-erc20/tokens.usdc.env';
import { USDT_TOKEN } from '$env/tokens-erc20/tokens.usdt.env';
import { WBTC_TOKEN } from '$env/tokens-erc20/tokens.wbtc.env';
Expand Down Expand Up @@ -357,6 +358,14 @@ const CKWSTETH_IC_DATA: IcCkInterface | undefined = nonNullish(CKERC20_PRODUCTIO
}
: undefined;

const CKUNI_IC_DATA: IcCkInterface | undefined = nonNullish(CKERC20_PRODUCTION_DATA?.ckUNI)
? {
...CKERC20_PRODUCTION_DATA.ckUNI,
position: 9,
twinToken: UNI_TOKEN
}
: undefined;

export const CKERC20_LEDGER_CANISTER_TESTNET_IDS: CanisterIdText[] = [
...(nonNullish(LOCAL_CKUSDC_LEDGER_CANISTER_ID) ? [LOCAL_CKUSDC_LEDGER_CANISTER_ID] : []),
...(nonNullish(CKUSDC_STAGING_DATA?.ledgerCanisterId)
Expand All @@ -378,7 +387,8 @@ export const CKERC20_LEDGER_CANISTER_IC_IDS: CanisterIdText[] = [
...(nonNullish(CKSHIB_IC_DATA?.ledgerCanisterId) ? [CKSHIB_IC_DATA.ledgerCanisterId] : []),
...(nonNullish(CKWBTC_IC_DATA?.ledgerCanisterId) ? [CKWBTC_IC_DATA.ledgerCanisterId] : []),
...(nonNullish(CKUSDT_IC_DATA?.ledgerCanisterId) ? [CKUSDT_IC_DATA.ledgerCanisterId] : []),
...(nonNullish(CKWSTETH_IC_DATA?.ledgerCanisterId) ? [CKWSTETH_IC_DATA.ledgerCanisterId] : [])
...(nonNullish(CKWSTETH_IC_DATA?.ledgerCanisterId) ? [CKWSTETH_IC_DATA.ledgerCanisterId] : []),
...(nonNullish(CKUNI_IC_DATA?.ledgerCanisterId) ? [CKUNI_IC_DATA.ledgerCanisterId] : [])
];

export const CKERC20_LEDGER_CANISTER_IDS: CanisterIdText[] = [
Expand Down Expand Up @@ -413,7 +423,8 @@ export const ICRC_TOKENS: IcCkInterface[] = [
...(nonNullish(CKSHIB_IC_DATA) ? [CKSHIB_IC_DATA] : []),
...(nonNullish(CKWBTC_IC_DATA) ? [CKWBTC_IC_DATA] : []),
...(nonNullish(CKUSDT_IC_DATA) ? [CKUSDT_IC_DATA] : []),
...(nonNullish(CKWSTETH_IC_DATA) ? [CKWSTETH_IC_DATA] : [])
...(nonNullish(CKWSTETH_IC_DATA) ? [CKWSTETH_IC_DATA] : []),
...(nonNullish(CKUNI_IC_DATA) ? [CKUNI_IC_DATA] : [])
];

export const ICRC_TOKENS_LEDGER_CANISTER_IDS: LedgerCanisterIdText[] = ICRC_TOKENS.map(
Expand Down
23 changes: 23 additions & 0 deletions src/frontend/src/env/tokens-erc20/tokens.uni.env.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { ETHEREUM_NETWORK } from '$env/networks.env';
import type { RequiredErc20Token } from '$eth/types/erc20';
import uni from '$icp-eth/assets/uni.svg';

export const UNI_DECIMALS = 18;

export const UNI_SYMBOL = 'UNI';

export const UNI_TOKEN_ID: unique symbol = Symbol(UNI_SYMBOL);

export const UNI_TOKEN: RequiredErc20Token = {
id: UNI_TOKEN_ID,
network: ETHEREUM_NETWORK,
standard: 'erc20',
category: 'default',
name: 'Uniswap',
symbol: 'UNI',
decimals: UNI_DECIMALS,
icon: uni,
address: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
exchange: 'erc20',
twinTokenSymbol: 'ckUNI'
};
24 changes: 4 additions & 20 deletions src/frontend/src/env/tokens.erc20.env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { LINK_TOKEN, SEPOLIA_LINK_TOKEN } from '$env/tokens-erc20/tokens.link.en
import { OCT_TOKEN } from '$env/tokens-erc20/tokens.oct.env';
import { PEPE_TOKEN, SEPOLIA_PEPE_TOKEN } from '$env/tokens-erc20/tokens.pepe.env';
import { SHIB_TOKEN } from '$env/tokens-erc20/tokens.shib.env';
import { UNI_TOKEN } from '$env/tokens-erc20/tokens.uni.env';
import { SEPOLIA_USDC_TOKEN, USDC_TOKEN } from '$env/tokens-erc20/tokens.usdc.env';
import { USDT_TOKEN } from '$env/tokens-erc20/tokens.usdt.env';
import { WBTC_TOKEN } from '$env/tokens-erc20/tokens.wbtc.env';
Expand All @@ -27,12 +28,6 @@ const ERC20_CONTRACT_ADDRESS_DMAIL: Erc20Contract = {
exchange: 'erc20'
};

const ERC20_CONTRACT_ADDRESS_UNISWAP: Erc20Contract = {
// Uniswap
address: '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984',
exchange: 'erc20'
};

const ERC20_CONTRACT_ADDRESS_MATIC: Erc20Contract = {
// Polygon
address: '0x7D1AfA7B718fb893dB30A3aBc0Cfc608AaCfeBB0',
Expand Down Expand Up @@ -74,8 +69,7 @@ export const ERC20_CONTRACTS_SEPOLIA: Erc20Contract[] = [
// Weenus
address: '0x7439E9Bb6D8a84dd3A23fe621A30F95403F87fB9',
exchange: 'erc20'
},
ERC20_CONTRACT_ADDRESS_UNISWAP
}
];

export const ERC20_CONTRACT_ICP_GOERLI: Erc20Contract = {
Expand All @@ -84,16 +78,6 @@ export const ERC20_CONTRACT_ICP_GOERLI: Erc20Contract = {
exchange: 'icp'
};

const _ERC20_CONTRACTS_GOERLI: Erc20Contract[] = [
ERC20_CONTRACT_ICP_GOERLI,
{
// Weenus
address: '0xaFF4481D10270F50f203E0763e2597776068CBc5',
exchange: 'erc20'
},
ERC20_CONTRACT_ADDRESS_UNISWAP
];

export const ERC20_CONTRACT_ICP: Erc20Contract = {
// ICP
address: '0x054B8f99D15cC5B35a42a926635977d62692F25b',
Expand All @@ -104,7 +88,6 @@ export const ERC20_CONTRACTS_PRODUCTION: Erc20Contract[] = [
ERC20_CONTRACT_ICP,
ERC20_CONTRACT_ADDRESS_1INCH,
ERC20_CONTRACT_ADDRESS_DMAIL,
ERC20_CONTRACT_ADDRESS_UNISWAP,
ERC20_CONTRACT_ADDRESS_MATIC,
ERC20_CONTRACT_ADDRESS_JASMY,
ERC20_CONTRACT_ADDRESS_DAI,
Expand Down Expand Up @@ -144,7 +127,8 @@ export const ERC20_TWIN_TOKENS_MAINNET: RequiredErc20Token[] = [
SHIB_TOKEN,
WBTC_TOKEN,
USDT_TOKEN,
WSTETH_TOKEN
WSTETH_TOKEN,
UNI_TOKEN
];

export const ERC20_TWIN_TOKENS: RequiredErc20Token[] = [
Expand Down
16 changes: 16 additions & 0 deletions src/frontend/src/env/tokens.sns.json
Original file line number Diff line number Diff line change
Expand Up @@ -430,5 +430,21 @@
"url": "https://cycles-transfer-station.com"
},
"indexCanisterVersion": "up-to-date"
},
{
"ledgerCanisterId": "np5km-uyaaa-aaaaq-aadrq-cai",
"rootCanisterId": "nb7he-piaaa-aaaaq-aadqq-cai",
"indexCanisterId": "n535v-yiaaa-aaaaq-aadsq-cai",
"metadata": {
"decimals": 8,
"name": "DOGMI",
"symbol": "DOGMI",
"fee": {
"__bigint__": "705032704"
},
"alternativeName": "DOGMI",
"url": "https://qu2gy-uqaaa-aaaal-qcv6a-cai.icp0.io"
},
"indexCanisterVersion": "up-to-date"
}
]
24 changes: 0 additions & 24 deletions src/frontend/src/eth/assets/uniswap.svg

This file was deleted.

8 changes: 4 additions & 4 deletions src/frontend/src/eth/components/core/EthListener.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
import { initTransactionsListener } from '$eth/services/eth-listener.services';
import type { WebSocketListener } from '$eth/types/listener';
import type { Token } from '$lib/types/token';
import { address } from '$lib/derived/address.derived';
import type { OptionAddress } from '$lib/types/address';
import { ethAddress } from '$lib/derived/address.derived';
import type { OptionEthAddress } from '$lib/types/address';
export let token: Token;
let listener: WebSocketListener | undefined = undefined;
const initListener = async ({ address }: { address: OptionAddress }) => {
const initListener = async ({ address }: { address: OptionEthAddress }) => {
await listener?.disconnect();
if (isNullish(address)) {
Expand All @@ -21,7 +21,7 @@
listener = initTransactionsListener({ address, token });
};
$: (async () => initListener({ address: $address }))();
$: (async () => initListener({ address: $ethAddress }))();
onDestroy(async () => await listener?.disconnect());
</script>
Expand Down
10 changes: 5 additions & 5 deletions src/frontend/src/eth/components/core/EthWalletAddress.svelte
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { shortenWithMiddleEllipsis } from '$lib/utils/format.utils';
import Copy from '$lib/components/ui/Copy.svelte';
import { address } from '$lib/derived/address.derived';
import { ethAddress } from '$lib/derived/address.derived';
import ExternalLink from '$lib/components/ui/ExternalLink.svelte';
import { nonNullish, notEmptyString } from '@dfinity/utils';
import { explorerUrl as explorerUrlStore } from '$eth/derived/network.derived';
import { i18n } from '$lib/stores/i18n.store';
let explorerUrl: string | undefined = notEmptyString($address)
? `${$explorerUrlStore}/address/${$address}`
let explorerUrl: string | undefined = notEmptyString($ethAddress)
? `${$explorerUrlStore}/address/${$ethAddress}`
: undefined;
</script>

Expand All @@ -18,8 +18,8 @@
>

<output class="break-all" id="eth-wallet-address"
>{shortenWithMiddleEllipsis($address ?? '')}</output
><Copy inline color="inherit" value={$address ?? ''} text={$i18n.wallet.text.address_copied} />
>{shortenWithMiddleEllipsis($ethAddress ?? '')}</output
><Copy inline color="inherit" value={$ethAddress ?? ''} text={$i18n.wallet.text.address_copied} />
</div>

{#if nonNullish(explorerUrl)}
Expand Down
6 changes: 3 additions & 3 deletions src/frontend/src/eth/components/fee/FeeContext.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { WebSocketListener } from '$eth/types/listener';
import type { Erc20Token } from '$eth/types/erc20';
import { address } from '$lib/derived/address.derived';
import { ethAddress } from '$lib/derived/address.derived';
import { toastsError, toastsHide } from '$lib/stores/toasts.store';
import { debounce } from '@dfinity/utils';
import { initMinedTransactionsListener } from '$eth/services/eth-listener.services';
Expand Down Expand Up @@ -52,9 +52,9 @@
try {
const params: GetFeeData = {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
to: mapAddressStartsWith0x(destination !== '' ? destination : $address!),
to: mapAddressStartsWith0x(destination !== '' ? destination : $ethAddress!),
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
from: mapAddressStartsWith0x($address!)
from: mapAddressStartsWith0x($ethAddress!)
};
const { getFeeData } = infuraProviders($sendToken.network.id);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { openMetamaskTransaction } from '$eth/services/metamask.services';
import { metamaskAvailable } from '$eth/derived/metamask.derived';
import { address } from '$lib/derived/address.derived';
import { ethAddress } from '$lib/derived/address.derived';
import IconMetamask from '$lib/components/icons/IconMetamask.svelte';
import { toastsError } from '$lib/stores/toasts.store';
import { networkEthereum } from '$lib/derived/network.derived';
Expand All @@ -17,7 +17,7 @@
}
await openMetamaskTransaction({
address: $address,
address: $ethAddress,
network: $selectedEthereumNetwork
});
};
Expand Down
14 changes: 5 additions & 9 deletions src/frontend/src/eth/components/send/EthSend.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
import { modalEthSend } from '$lib/derived/modal.derived';
import EthSendModal from '$eth/components/send/EthSendModal.svelte';
import { waitWalletReady } from '$lib/services/actions.services';
import SendButton from '$lib/components/send/SendButton.svelte';
import { loadTokenAndRun } from '$icp/services/token.services';
import type { Token } from '$lib/types/token';
import SendButtonWithModal from '$lib/components/send/SendButtonWithModal.svelte';
export let token: Token;
const modalId = Symbol();
const isDisabled = (): boolean => $addressNotLoaded;
const openSend = async () => {
const openSend = async (modalId: symbol) => {
if (isDisabled()) {
const status = await waitWalletReady(isDisabled);
Expand All @@ -28,8 +26,6 @@
};
</script>

<SendButton on:click={async () => await openSend()} />

{#if $modalEthSend && $modalStore?.data === modalId}
<EthSendModal on:nnsClose />
{/if}
<SendButtonWithModal open={async (modalId) => await openSend(modalId)} isOpen={$modalEthSend}>
<EthSendModal on:nnsClose slot="modal" />
</SendButtonWithModal>
Loading

0 comments on commit c9fb75e

Please sign in to comment.