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): non-mm wallets #438

Merged
merged 67 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
a052dce
feat(bridge): add transaction list
shadab-taiko Dec 9, 2022
d76d0ef
fix(bridge): remove console.log
shadab-taiko Dec 9, 2022
f25a583
transaction impl
cyberhorsey Dec 9, 2022
fdc5f4a
test
cyberhorsey Dec 10, 2022
0364597
merge main
cyberhorsey Dec 12, 2022
8c02198
wip, local storage for transactons, claiming, new stores, deprecate r…
cyberhorsey Dec 12, 2022
65e8ad5
claim
cyberhorsey Dec 12, 2022
d6c0edc
tests
cyberhorsey Dec 12, 2022
7abe5c8
jest
cyberhorsey Dec 12, 2022
d031ed4
pending tx
cyberhorsey Dec 12, 2022
e558824
proof validation
cyberhorsey Dec 12, 2022
5b1872e
tests
cyberhorsey Dec 12, 2022
4e7fb10
process message requires manual gas limit
cyberhorsey Dec 12, 2022
6679a1d
jest
cyberhorsey Dec 12, 2022
4580e82
mm mobile code
cyberhorsey Dec 12, 2022
3b0e513
mm mobile
cyberhorsey Dec 12, 2022
4d46ae0
custom fee
cyberhorsey Dec 13, 2022
1f22421
value not data
cyberhorsey Dec 13, 2022
5e845b6
fee
cyberhorsey Dec 13, 2022
1056d92
Merge branch 'main' into bridge-transactions
cyberhorsey Dec 13, 2022
57a9ea5
jest
cyberhorsey Dec 13, 2022
1074c4f
Merge branch 'bridge-transactions' of github.com:taikochain/taiko-mon…
cyberhorsey Dec 13, 2022
9919935
rm log
cyberhorsey Dec 13, 2022
8ad363e
tests
cyberhorsey Dec 13, 2022
b178aaf
tests
cyberhorsey Dec 13, 2022
0af6df6
erc20 bridging
cyberhorsey Dec 14, 2022
9fbc6a7
token vault address refactor
cyberhorsey Dec 14, 2022
6ad04a2
bridge opts
cyberhorsey Dec 14, 2022
c56b5a2
bridge fix
cyberhorsey Dec 14, 2022
429d8c0
get canonicalToBridged for cross layer tokens
cyberhorsey Dec 14, 2022
b76f695
golang lint
cyberhorsey Dec 14, 2022
3cff81c
Merge branch 'main' into bridge-transactions
cyberhorsey Dec 14, 2022
cbce623
rm console log
cyberhorsey Dec 14, 2022
fc1cdba
Merge branch 'bridge-transactions' of github.com:taikochain/taiko-mon…
cyberhorsey Dec 14, 2022
f4b3df2
merge main
cyberhorsey Dec 14, 2022
f71be3f
feat(bridge): non mm wallets
shadab-taiko Dec 14, 2022
2a409bc
env rename, add bridge address and test erc20 dynamically, remove tko
cyberhorsey Dec 14, 2022
3b007ac
fix number input
cyberhorsey Dec 14, 2022
b510396
wip tx view
cyberhorsey Dec 14, 2022
63c8962
reactive tx list
cyberhorsey Dec 14, 2022
07c5455
show Pending state if message header is not synced
cyberhorsey Dec 14, 2022
1b0dcc1
tests
cyberhorsey Dec 15, 2022
1fe523b
Update packages/bridge-ui/.default.env
cyberhorsey Dec 15, 2022
27ee4a7
Update packages/bridge-ui/src/components/Loader.svelte
cyberhorsey Dec 15, 2022
15b2105
Update packages/bridge-ui/src/app.css
cyberhorsey Dec 15, 2022
059dc1d
rm old way of doing bridge tx's
cyberhorsey Dec 15, 2022
81792fd
Merge branch 'bridge-transactions' of github.com:taikochain/taiko-mon…
cyberhorsey Dec 15, 2022
1c86bd3
unused css
cyberhorsey Dec 15, 2022
80994d8
Merge branch 'main' into bridge-transactions
cyberhorsey Dec 15, 2022
8fd3ce0
feat(bridge): switch network using wagmi
shadab-taiko Dec 15, 2022
791337e
merge conflict
cyberhorsey Dec 15, 2022
a484a4b
merge bridge tx into branch, resolve conflcits
cyberhorsey Dec 15, 2022
6871140
Fetch tx on signer load
cyberhorsey Dec 15, 2022
d0196db
feat(bridge): style changes
shadab-taiko Dec 15, 2022
16438f3
rm switchethereumchain, useless function now
cyberhorsey Dec 15, 2022
f36df2a
Merge branch 'main' of github.com-taiko:taikochain/taiko-mono into no…
shadab-taiko Dec 16, 2022
75a1657
jest
cyberhorsey Dec 16, 2022
67fd2f6
Merge branch 'main' into non-mm-wallets
shadab-taiko Dec 19, 2022
36e99e2
fix(bridge): non mm wallets
shadab-taiko Dec 19, 2022
f57baa3
fix(bridge): workaround for process.env.NODE_DEBUG
shadab-taiko Dec 19, 2022
02a7dae
chore(bridge): add vite mjs file to gitignore
shadab-taiko Dec 19, 2022
80fc455
Merge branch 'main' into non-mm-wallets
cyberhorsey Dec 20, 2022
e8ce626
fix(bridge): production build
shadab-taiko Dec 20, 2022
09ead7e
add deps for wagmi
cyberhorsey Dec 20, 2022
65a9683
Merge branch 'main' into non-mm-wallets
cyberhorsey Dec 20, 2022
3043b89
bump wagmi
cyberhorsey Dec 20, 2022
f58bed3
fix wagmi
cyberhorsey Dec 20, 2022
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
6 changes: 5 additions & 1 deletion packages/bridge-ui/.default.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,8 @@ VITE_NODE_ENV=dev
VITE_L1_RPC_URL=""
VITE_L2_RPC_URL=""
VITE_TAIKO_BRIDGE_ADDRESS=""
VITE_MAINNET_BRIDGE_ADDRESS=""
VITE_MAINNET_BRIDGE_ADDRESS=""
VITE_TEST_ERC20_ADDRESS_MAINNET=""
VITE_MAINNET_TOKEN_VAULT_ADDRESS=""
VITE_TAIKO_TOKEN_VAULT_ADDRESS=""
VITE_TEST_ERC20_ADDRESS_MAINNET=""
4 changes: 2 additions & 2 deletions packages/bridge-ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export default {
],
coverageThreshold: {
global: {
statements: 99.45,
branches: 93.65,
statements: 98.95,
branches: 90.19,
functions: 100,
lines: 100,
},
Expand Down
68 changes: 45 additions & 23 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
import { wrap } from "svelte-spa-router/wrap";
import QueryProvider from "./components/providers/QueryProvider.svelte";
import Router from "svelte-spa-router";
import { SvelteToast, toast } from "@zerodevx/svelte-toast";
import { SvelteToast } from "@zerodevx/svelte-toast";
import type { SvelteToastOptions } from "@zerodevx/svelte-toast";
import { configureChains, createClient, InjectedConnector } from '@wagmi/core';
import { publicProvider } from '@wagmi/core/providers/public';
import { jsonRpcProvider } from '@wagmi/core/providers/jsonRpc';
import { CoinbaseWalletConnector } from '@wagmi/core/connectors/coinbaseWallet';
import { WalletConnectConnector } from '@wagmi/core/connectors/walletConnect';
import {
configureChains,
createClient,
InjectedConnector,
} from "@wagmi/core";
import { publicProvider } from "@wagmi/core/providers/public";
import { jsonRpcProvider } from "@wagmi/core/providers/jsonRpc";
import { CoinbaseWalletConnector } from "@wagmi/core/connectors/coinbaseWallet";
import { WalletConnectConnector } from "@wagmi/core/connectors/walletConnect";

import Home from "./pages/home/Home.svelte";
import { setupI18n } from "./i18n";
Expand All @@ -25,9 +29,15 @@
import { signer } from "./store/signer";
import type { Transactioner } from "./domain/transactions";
import { wagmiClient } from "./store/wagmi";

setupI18n({ withLocale: "en" });
import { chains, CHAIN_MAINNET, CHAIN_TKO, mainnet, taiko } from "./domain/chain";
import {
chains,
CHAIN_MAINNET,
CHAIN_TKO,
mainnet,
taiko,
} from "./domain/chain";
import SwitchEthereumChainModal from "./components/modals/SwitchEthereumChainModal.svelte";
import { ProofService } from "./proof/service";
import { ethers } from "ethers";
Expand All @@ -36,6 +46,7 @@
import { StorageService } from "./storage/service";
import { MessageStatus } from "./domain/message";
import BridgeABI from "./constants/abi/Bridge";
import { providers } from "./store/providers";

const providerMap: Map<number, ethers.providers.JsonRpcProvider> = new Map<
number,
Expand All @@ -49,28 +60,36 @@
CHAIN_TKO.id,
new ethers.providers.JsonRpcProvider(import.meta.env.VITE_L2_RPC_URL)
);
providers.set(providerMap);

const { chains: wagmiChains, provider, webSocketProvider } = configureChains(
const {
chains: wagmiChains,
provider,
webSocketProvider,
} = configureChains(
[mainnet, taiko],
[publicProvider(), jsonRpcProvider({
rpc: (chain) => ({
http: providerMap.get(chain.id).connection.url,
[
publicProvider(),
jsonRpcProvider({
rpc: (chain) => ({
http: providerMap.get(chain.id).connection.url,
}),
}),
})],
]
);

$wagmiClient = createClient({
provider,
connectors: [
new InjectedConnector({
chains: wagmiChains
chains: wagmiChains,
}),
new CoinbaseWalletConnector({
chains: wagmiChains,
options: {
appName: 'Taiko Bridge',
},
}),
chains: wagmiChains,
options: {
appName: "Taiko Bridge",
},
}),
new WalletConnectConnector({
chains: wagmiChains,
options: {
Expand All @@ -92,8 +111,11 @@
});

chainIdToTokenVaultAddress.update((store) => {
store.set(CHAIN_TKO.id, import.meta.env.VITE_TAIKO_BRIDGE_ADDRESS);
store.set(CHAIN_MAINNET.id, import.meta.env.VITE_MAINNET_BRIDGE_ADDRESS);
store.set(CHAIN_TKO.id, import.meta.env.VITE_TAIKO_TOKEN_VAULT_ADDRESS);
store.set(
CHAIN_MAINNET.id,
import.meta.env.VITE_MAINNET_TOKEN_VAULT_ADDRESS
);
return store;
});

Expand Down Expand Up @@ -137,12 +159,12 @@
if (tx.interval) clearInterval(tx.interval);

if (tx.status === MessageStatus.New) {
const provider = providerMap.get(tx.message.destChainId.toNumber());
const provider = providerMap.get(tx.toChainId);

const interval = setInterval(async () => {
tx.interval = interval;
const contract = new ethers.Contract(
chains[tx.message.destChainId.toNumber()].bridgeAddress,
chains[tx.toChainId].bridgeAddress,
BridgeABI,
provider
);
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,4 @@

.dropdown-content.address-dropdown-content {
border-radius: 6px;
}
}
84 changes: 32 additions & 52 deletions packages/bridge-ui/src/components/AddressDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,9 @@
import { errorToast } from "../utils/toast";
import CopyIcon from "./icons/Copy.svelte";
import DisconnectIcon from "./icons/Disconnect.svelte";
import TransactionsIcon from "./icons/Transactions.svelte";
import { slide } from "svelte/transition";
import { fromChain } from "../store/chain";
import { truncateString } from "../utils/truncateString";
import Transactions from "./Transactions.svelte";
import { transactions } from "../store/transactions";

let showTransactions = false;

let address: string;
let addressAvatarImgData: string;
Expand Down Expand Up @@ -98,54 +93,39 @@
tabindex="0"
class="dropdown-content address-dropdown-content menu shadow bg-dark-3 rounded-sm w-64 mt-2 pb-2"
>
{#if !showTransactions}
<div class="p-5 pb-0 flex flex-col items-center" transition:slide>
{#if $fromChain && $signer}
<svelte:component this={$fromChain.icon} />
<div class="text-lg mt-2">
{tokenBalance.length > 10
? `${truncateString(tokenBalance)}...`
: tokenBalance} ETH
</div>
{/if}
</div>
<div class="divider" />
<div class="flex hover:bg-dark-5 items-center py-2 px-2">
<img
width="24"
height="24"
src="data:image/png;base64,{addressAvatarImgData}"
class="rounded-full mr-2 inline-block"
alt="avatar"
/>
{addressSubsection(address)}
</div>
<div
class="cursor-pointer flex hover:bg-dark-5 items-center py-2 px-2"
on:click={async () => await copyToClipboard(address)}
>
<CopyIcon />
Copy Address
</div>
<div
class="cursor-pointer flex hover:bg-dark-5 items-center py-2 px-2"
on:click={async () => await disconnect()}
>
<DisconnectIcon /> Disconnect
</div>
{#if $transactions && $transactions.length}
<div
class="cursor-pointer flex hover:bg-dark-5 items-center py-2 px-2"
on:click={() => (showTransactions = true)}
>
<TransactionsIcon />
{$transactions.length} Transactions
<div class="p-5 pb-0 flex flex-col items-center" transition:slide>
{#if $fromChain && $signer}
<svelte:component this={$fromChain.icon} />
<div class="text-lg mt-2">
{tokenBalance.length > 10
? `${truncateString(tokenBalance)}...`
: tokenBalance} ETH
</div>
{/if}
{:else}
<div class="" transition:slide>
<Transactions bind:showTransactions />
</div>
{/if}
</div>
<div class="divider" />
<div class="flex hover:bg-dark-5 items-center py-2 px-2">
<img
width="24"
height="24"
src="data:image/png;base64,{addressAvatarImgData}"
class="rounded-full mr-2 inline-block"
alt="avatar"
/>
{addressSubsection(address)}
</div>
<div
class="cursor-pointer flex hover:bg-dark-5 items-center py-2 px-2"
on:click={async () => await copyToClipboard(address)}
>
<CopyIcon />
Copy Address
</div>
<div
class="cursor-pointer flex hover:bg-dark-5 items-center py-2 px-2"
on:click={async () => await disconnect()}
>
<DisconnectIcon /> Disconnect
</div>
</ul>
</div>
3 changes: 1 addition & 2 deletions packages/bridge-ui/src/components/Loader.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7ZM1.39211 7C1.39211 10.0972 3.90285 12.6079 7 12.6079C10.0972 12.6079 12.6079 10.0972 12.6079 7C12.6079 3.90285 10.0972 1.39211 7 1.39211C3.90285 1.39211 1.39211 3.90285 1.39211 7Z" fill="#B20F89"/>
<path d="M14 7C14 8.1941 13.6945 9.36835 13.1127 10.4111C12.5308 11.4538 11.6918 12.3304 10.6756 12.9574C9.65935 13.5844 8.49961 13.941 7.30665 13.9933C6.1137 14.0456 4.9272 13.7919 3.85998 13.2562L4.48444 12.012C5.33942 12.4411 6.28996 12.6444 7.24567 12.6025C8.20138 12.5606 9.13048 12.2749 9.94461 11.7726C10.7587 11.2703 11.4309 10.5681 11.897 9.73271C12.3632 8.89735 12.6079 7.95663 12.6079 7H14Z" fill="#FC0FC0"/>
</svg>

</svg>
Loading