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

feat(bridge-ui-v2): Activities page #14504

Merged
merged 77 commits into from
Aug 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
8742a9b
feat(nft-bridge): initial UI setup for NFT bridge, fetching images, u…
KorbinianK Jul 24, 2023
a97acd3
Merge remote-tracking branch 'origin/main' into feat/activities
KorbinianK Jul 25, 2023
fe03cc0
feat(bridge-ui-v2): add relayer api, initial activities page
KorbinianK Jul 26, 2023
e5731af
chore(bridge-ui-v2): remove bg asset
KorbinianK Jul 26, 2023
b9554f3
feat(bridge-ui-v2): update bg
KorbinianK Jul 26, 2023
911f3d2
types
jscriptcoder Jul 26, 2023
eed4ee3
types
jscriptcoder Jul 26, 2023
8c58d26
Merge remote-tracking branch 'origin/main' into feat/activities
KorbinianK Jul 26, 2023
44ebb89
bridgetx storage
jscriptcoder Jul 26, 2023
cc2eacf
bridge tx service
jscriptcoder Jul 26, 2023
beea5ad
minor changes in the styling
jscriptcoder Jul 26, 2023
bb6ef3d
minor change
jscriptcoder Jul 26, 2023
613c55c
chore(bridge-ui-v2): types, additional vault configs
KorbinianK Jul 26, 2023
d79bcc6
Merge remote-tracking branch 'origin/feat/bridgetx_storage' into feat…
KorbinianK Jul 26, 2023
2336a19
feat(bridge-ui-v2): BridgeTx storage (#14284)
jscriptcoder Jul 26, 2023
116b4e3
feat(bridge-ui-v2): wip on activities page, checking for connection s…
KorbinianK Jul 26, 2023
526680a
Merge branch 'feat/activities' of https://github.com/taikoxyz/taiko-m…
KorbinianK Jul 26, 2023
38102ca
Merge branch 'main' into feat/activities
KorbinianK Jul 26, 2023
3fb8ffd
feat(bridge-ui-v2): transaction component, update types
KorbinianK Jul 27, 2023
209789b
feat(bridge-ui-v2): removed polling from relayer, fixed receipt fetching
KorbinianK Jul 27, 2023
1b1c46a
fix(bridge-ui-v2): fix i18n links
KorbinianK Jul 28, 2023
bf929af
fix(bridge-ui-v2): added return to _enhance in storage service
KorbinianK Jul 28, 2023
9be854e
feat(bridge-ui-v2): optimize releayeApi filter conditions
KorbinianK Jul 28, 2023
25f64c7
feat(bridge-ui-v2): merging local-storage and relayer tx
KorbinianK Jul 28, 2023
3c399e6
chore(bridge-ui-v2): moved mergeTx function to util
KorbinianK Jul 28, 2023
580caf8
feat(bridge-ui-v2): transaction logic (#14295)
jscriptcoder Jul 28, 2023
563bf3f
feat(bridge-ui-v2): updated styling
KorbinianK Jul 28, 2023
f08092a
Merge branch 'feat/activities' of https://github.com/taikoxyz/taiko-m…
KorbinianK Jul 28, 2023
1a87dcb
feat(bridge-ui-v2): added mobile view
KorbinianK Jul 28, 2023
4097dc4
fix(bridge-ui-v2): i18n fixes
KorbinianK Jul 31, 2023
fcf4b42
fix(bridge-ui-v2): fix i18n
KorbinianK Jul 31, 2023
026583e
feat(bridge-ui-v2): moved dynamic blur to appconfig
KorbinianK Aug 1, 2023
9de45bd
feat(bridge-ui-v2): mobile view
KorbinianK Aug 1, 2023
c2d4b26
feat(bridge-ui-v2): small cleanup, style adjustments for mobile card
KorbinianK Aug 2, 2023
7b8066d
feat(bridge-ui-v2): use component for mobile detection
KorbinianK Aug 2, 2023
09a5cb6
chore
KorbinianK Aug 2, 2023
4744c24
feat(bridge-ui-v2): add todos and fix i18n
KorbinianK Aug 2, 2023
ee458fa
feat(bridge-ui-v2): use responsive tailwind tags
KorbinianK Aug 3, 2023
8467e41
feat(bridge-ui-v2): added chainselector, status details dialog
KorbinianK Aug 3, 2023
18d1180
feat(bridge-ui-v2): Status component (#14312)
jscriptcoder Aug 3, 2023
02afb20
fix(bridge-ui-v2): complying with design (#14376)
jscriptcoder Aug 4, 2023
4e1b370
fix small issue when tx fails
jscriptcoder Aug 4, 2023
4804735
fix(bridge-ui-v2): validating amount (#14380)
jscriptcoder Aug 4, 2023
a795d60
merge main and resolve conflicts
jscriptcoder Aug 7, 2023
12ce9f8
revert change in eventindexer.yml
jscriptcoder Aug 7, 2023
dbb681d
fix pnpm-lock
jscriptcoder Aug 7, 2023
7e2ff25
Merge branch 'feat/activities' of https://github.com/taikoxyz/taiko-m…
jscriptcoder Aug 7, 2023
e253e8b
Revert eventindexer.yml
jscriptcoder Aug 7, 2023
e2a4a9f
revert change
jscriptcoder Aug 7, 2023
02ec5bd
minor fix
jscriptcoder Aug 7, 2023
dd4d403
minor fix
jscriptcoder Aug 7, 2023
463187f
Revert README.md
jscriptcoder Aug 7, 2023
863016d
Revert tokenomics_batch_auction.md
jscriptcoder Aug 7, 2023
908c1f8
Revert eventindexer.yml
jscriptcoder Aug 7, 2023
c63d43d
chore(bridge-ui-v2): update .env-example
KorbinianK Aug 7, 2023
a853f65
chore(bridge-ui-v2): linting
KorbinianK Aug 7, 2023
d908d8c
feat(bridge-ui-v2): decode of base64 without buffer
KorbinianK Aug 7, 2023
d091d3b
fix(bridge-ui-v2): i18n for claim reject
KorbinianK Aug 7, 2023
499a27a
fix(bridge-ui-v2): Buffer missing (#14407)
jscriptcoder Aug 8, 2023
834dc72
chore(bridge-ui-v2): cleanup and i18n
KorbinianK Aug 8, 2023
9f1a0f3
feat(bridge-ui-v2): catch empty receipts
KorbinianK Aug 8, 2023
4dd18b7
feat(bridge-ui-v2): clearing local transaction if relayer tx found,
KorbinianK Aug 8, 2023
4669106
feat(bridge-ui-v2): Light mode (#14420)
jscriptcoder Aug 9, 2023
4b89652
add custom
jscriptcoder Aug 9, 2023
74c70fa
feat(bridge-ui-v2): updated and fixed unit test, linting
KorbinianK Aug 9, 2023
18e5ff8
feat(bridge-ui-v2): processing fee dialog UX
KorbinianK Aug 10, 2023
05ce8b3
Merge branch 'feat/activities' of https://github.com/taikoxyz/taiko-m…
jscriptcoder Aug 10, 2023
8ce51be
fix(bridge-ui-v2): Fix token dropdown (#14436)
jscriptcoder Aug 10, 2023
0095ba7
feat(bridge-ui-v2): style adjustments, feature flag for nft tabs
KorbinianK Aug 10, 2023
d969657
feat(bridge-ui-v2): styling adjustments
KorbinianK Aug 10, 2023
51a61e5
center text in chainselector
KorbinianK Aug 10, 2023
9475ffd
feat(bridge-ui-v2): disable nft bridge in routes if flag set
KorbinianK Aug 10, 2023
5f9f3ac
Merge branch 'feat/activities' of https://github.com/taikoxyz/taiko-m…
jscriptcoder Aug 10, 2023
6f72ce8
fix import
jscriptcoder Aug 10, 2023
a4b3c43
fix amount alert messages
jscriptcoder Aug 10, 2023
de628cd
update .env.example
KorbinianK Aug 10, 2023
01dd098
Merge branch 'main' into feat/activities
KorbinianK Aug 14, 2023
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,7 @@ __pycache__/
# Ignore .husky for new contributors using lefthook while maintaining
# backwards compatibility for past contributors
.husky


# VSCode
.vscode/launch.json
1 change: 0 additions & 1 deletion packages/branding/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,3 @@ Look inside of this package for some common files you can use. Otherwise, please
## Colors

Our primary hex color is `#E81899`. For the full color palette and further details, please resort to the [Figma](<https://www.figma.com/file/qVALIk5srW9nvOJwl6NF6F/Taiko-Brand-Guidelines-(External)>).

14 changes: 14 additions & 0 deletions packages/bridge-ui-v2/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ export PUBLIC_L1_TOKEN_VAULT_ADDRESS=0x
export PUBLIC_L2_TOKEN_VAULT_ADDRESS=0x
export PUBLIC_L3_TOKEN_VAULT_ADDRESS=0x

# ERC721 Token Vault Contract address
export PUBLIC_L1_ERC721_VAULT_ADDRESS=
export PUBLIC_L2_ERC721_VAULT_ADDRESS=
export PUBLIC_L3_ERC721_VAULT_ADDRESS=


# ERC1155 Token Vault Contract address
export PUBLIC_L1_ERC1155_VAULT_ADDRESS=
export PUBLIC_L2_ERC1155_VAULT_ADDRESS=
export PUBLIC_L3_ERC1155_VAULT_ADDRESS=


# Bridge Contract address
export PUBLIC_L1_BRIDGE_ADDRESS=0x
Expand All @@ -61,6 +72,9 @@ export PUBLIC_TEST_ERC20=[]
# WalletConnect Project ID
export PUBLIC_WALLETCONNECT_PROJECT_ID=""

# Enable NFT Bridge ("true" or "false")
export PUBLIC_NFT_BRIDGE_ENABLED=""


# Sentry
export PUBLIC_SENTRY_DSN=https://
Expand Down
8 changes: 6 additions & 2 deletions packages/bridge-ui-v2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@typescript-eslint/parser": "^5.45.0",
"@vitest/coverage-v8": "^0.33.0",
"@wagmi/cli": "^1.0.1",
"abitype": "^0.8.7",
"autoprefixer": "^10.4.14",
"daisyui": "3.1.7",
"eslint": "^8.28.0",
Expand All @@ -37,6 +38,7 @@
"eslint-plugin-svelte": "^2.26.0",
"ethereum-address": "^0.0.4",
"jsdom": "^22.1.0",
"lokijs": "^1.5.12",
"postcss": "^8.4.24",
"prettier": "^3.0.0",
"prettier-plugin-svelte": "^3.0.0",
Expand All @@ -56,9 +58,11 @@
"@web3modal/ethereum": "^2.6.2",
"@web3modal/html": "^2.6.2",
"@zerodevx/svelte-toast": "^0.9.5",
"abitype": "^0.8.2",
"axios": "^1.4.0",
"buffer": "^6.0.3",
"debug": "^4.3.4",
"events": "^3.3.0",
"svelte-i18n": "^3.6.0",
"viem": "^1.2.9"
"viem": "^1.4.1"
}
}
19 changes: 19 additions & 0 deletions packages/bridge-ui-v2/src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,22 @@ export const bridgeService = {
export const pendingTransaction = {
waitTimeout: 300_000,
};

export const storageService = {
bridgeTxPrefix: 'transactions',
customTokenPrefix: 'custom-tokens',
};

export const bridgeTransactionPoller = {
interval: 20_000,
};

export const statusComponent = {
minimumEthToClaim: 0.0001,
};

export const activitiesConfig = {
pageSizeDesktop: 6,
pageSizeMobile: 4,
blurTransitionTime: 300,
};
190 changes: 175 additions & 15 deletions packages/bridge-ui-v2/src/components/Activities/Activities.svelte
Original file line number Diff line number Diff line change
@@ -1,25 +1,185 @@
<script lang="ts">
import { onMount } from 'svelte';
import { t } from 'svelte-i18n';
import type { Address } from 'viem';

import { Card } from '$components/Card';
import { ChainSelector } from '$components/ChainSelector';
import { network } from '$stores/network';
import ChainSelector from '$components/ChainSelector/ChainSelector.svelte';
import { DesktopOrLarger } from '$components/DesktopOrLarger';
import OnAccount from '$components/OnAccount/OnAccount.svelte';
import { Paginator } from '$components/Paginator';
import { Spinner } from '$components/Spinner';
import { activitiesConfig } from '$config';
import { type BridgeTransaction, fetchTransactions } from '$libs/bridge';
import { web3modal } from '$libs/connect';
import { bridgeTxService } from '$libs/storage';
import { account, network } from '$stores';
import type { Account } from '$stores/account';

import ListWithDetailsView from './ListWithDetailsView.svelte';
import TableView from './TableView.svelte';
import MobileDetailsDialog from './MobileDetailsDialog.svelte';
import StatusInfoDialog from './StatusInfoDialog.svelte';
import Transaction from './Transaction.svelte';

let transactions: BridgeTransaction[] = [];

let currentPage = 1;

let isBlurred = false;
const transitionTime = activitiesConfig.blurTransitionTime;

let totalItems = 0;
let pageSize = activitiesConfig.pageSizeDesktop;

let loadingTxs = false;

let detailsOpen = false;
let isDesktopOrLarger: boolean;

let selectedItem: BridgeTransaction | null = null;

const handlePageChange = (detail: number) => {
isBlurred = true;
setTimeout(() => {
currentPage = detail;
isBlurred = false;
}, transitionTime);
};

const getTransactionsToShow = (page: number, pageSize: number, bridgeTx: BridgeTransaction[]) => {
const start = (page - 1) * pageSize;
const end = start + pageSize;
return bridgeTx.slice(start, end);
};

const onWalletConnect = () => web3modal.openModal();

Check warning on line 54 in packages/bridge-ui-v2/src/components/Activities/Activities.svelte

View workflow job for this annotation

GitHub Actions / build

'onWalletConnect' is assigned a value but never used

Check warning on line 54 in packages/bridge-ui-v2/src/components/Activities/Activities.svelte

View workflow job for this annotation

GitHub Actions / build

'onWalletConnect' is assigned a value but never used

const onAccountChange = async (newAccount: Account, oldAccount?: Account) => {
// We want to make sure that we are connected and only
// fetch if the account has changed
if (newAccount?.isConnected && newAccount.address && newAccount.address !== oldAccount?.address) {
loadingTxs = true;

try {
updateTransactions(newAccount.address);
} catch (err) {
console.error(err);
// TODO: handle
} finally {
loadingTxs = false;
}
}
};

const closeDetails = () => {
detailsOpen = false;
selectedItem = null;
};

const openDetails = (tx: BridgeTransaction) => {
detailsOpen = true;
selectedItem = tx;
};

const updateTransactions = async (address: Address) => {
const { mergedTransactions, outdatedLocalTransactions } = await fetchTransactions(address);
transactions = mergedTransactions;
if (outdatedLocalTransactions.length > 0) {
await bridgeTxService.removeTransactions(address, outdatedLocalTransactions);
}
};

onMount(async () => {
// We want to make sure that we are connected before fetching
if (!$account?.isConnected || !$account?.address) return;

loadingTxs = true;

try {
await updateTransactions($account.address);
} catch (err) {
console.error(err);
// TODO: handle
} finally {
loadingTxs = false;
}
});

$: pageSize = isDesktopOrLarger ? activitiesConfig.pageSizeDesktop : activitiesConfig.pageSizeMobile;

$: transactionsToShow = getTransactionsToShow(currentPage, pageSize, transactions);

$: totalItems = transactions.length;

// Some shortcuts to make the code more readable
$: isConnected = $account?.isConnected;
$: hasTxs = transactions.length > 0;

// Controls what we render on the page
$: renderLoading = loadingTxs && isConnected;
$: renderTransactions = !renderLoading && isConnected && hasTxs;
$: renderNoTransactions = !renderLoading && !renderTransactions;
</script>

<Card class="md:min-w-[524px]" title={$t('activities.title')} text={$t('activities.description')}>
<div class="space-y-[35px]">
<ChainSelector label={$t('chain_selector.currently_on')} value={$network} small />
<!-- Small size view -->
<div class="md:hidden">
<ListWithDetailsView />
</div>
<div class="flex flex-col justify-center w-full">
<Card title={$t('activities.title')} text={$t('activities.description')}>
<ChainSelector class="py-[35px] " label={$t('chain_selector.currently_on')} value={$network} switchWallet small />
<div class="flex flex-col" style={`min-height: calc(${transactionsToShow.length} * 80px);`}>
{#if isDesktopOrLarger}
<div class="h-sep" />
<div class="text-white flex">
<div class="w-1/5 py-2">{$t('activities.header.from')}</div>
<div class="w-1/5 py-2">{$t('activities.header.to')}</div>
<div class="w-1/5 py-2">{$t('activities.header.amount')}</div>
<div class="w-1/5 py-2 flex flex-row">
{$t('activities.header.status')}
<StatusInfoDialog />
</div>
<div class="w-1/5 py-2">{$t('activities.header.explorer')}</div>
</div>
<div class="h-sep" />
{/if}

<!-- Medium size view: desktop and larger -->
<div class="hidden md:block">
<TableView />
{#if renderLoading}
<div class="flex items-center justify-center text-white h-[80px]">
<Spinner /> <span class="pl-3">{$t('common.loading')}...</span>
</div>
{/if}

{#if renderTransactions}
<div
class="flex flex-col items-center"
style={isBlurred ? `filter: blur(5px); transition: filter ${transitionTime / 1000}s ease-in-out` : ''}>
{#each transactionsToShow as item (item.hash)}
<Transaction {item} on:click={isDesktopOrLarger ? undefined : () => openDetails(item)} />
<div class="h-sep" />
{/each}
</div>
{/if}

{#if renderNoTransactions}
<div class="flex items-center justify-center text-white h-[80px]">
<span class="pl-3">{$t('activities.no_transactions')}</span>
</div>
{/if}

<!-- TODO: we don't have this in the design -->
<!-- {#if !$account?.isConnected}
<div class="flex items-center justify-center text-white h-[80px]">
<Button type="primary" on:click={onWalletConnect} class="px-[28px] py-[14px] ">
<span class="body-bold">{$t('wallet.connect')}</span>
</Button>
</div>
{/if} -->
</div>
</Card>

<div class="flex justify-end pt-2">
<Paginator {pageSize} {totalItems} on:pageChange={({ detail }) => handlePageChange(detail)} />
</div>
</Card>
</div>

<MobileDetailsDialog {closeDetails} {detailsOpen} {selectedItem} />

<OnAccount change={onAccountChange} />

<DesktopOrLarger bind:is={isDesktopOrLarger} />
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<script lang="ts">
import { chainIcons, type ChainID, getChainName } from '$libs/chain';

export let chainId: ChainID;
const chainName = getChainName(Number(chainId));
const icon = chainIcons[Number(chainId)];
</script>

<div class="flex md:items-stretch self-center justify-items-start'}">
<img src={icon} alt="chain-logo" class="rounded-full w-5 h-5 hidden md:block mr-2" />
<span class="md:font-bold font-normal">{chainName}</span>
</div>
Loading
Loading