Skip to content

Commit

Permalink
Merge branch 'main' into feat/wrap_mnt
Browse files Browse the repository at this point in the history
  • Loading branch information
MickWang authored Apr 17, 2024
2 parents 4aaa20b + 12cfb4f commit 65f7328
Show file tree
Hide file tree
Showing 17 changed files with 186 additions and 65 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: CI
on: [push]
on:
pull_request:
branches:
- main
- preview
- dev

jobs:
build:
Expand All @@ -18,11 +23,11 @@ jobs:

- name: Run Build Command
run: |
if [[ ${{ github.ref }} == 'refs/heads/main' ]]; then
if [[ ${{ github.event.pull_request.base.ref }} == 'main' ]]; then
npm run generate:node:nexus
elif [[ ${{ github.ref }} == 'refs/heads/preview' ]]; then
elif [[ ${{ github.event.pull_request.base.ref }} == 'preview' ]]; then
npm run generate:node:nexus
elif [[ ${{ github.ref }} == 'refs/heads/dev' ]]; then
elif [[ ${{ github.event.pull_request.base.ref }} == 'dev' ]]; then
npm run generate:node:nexus-sepolia
else
echo "No specific build command for this branch."
Expand Down
7 changes: 6 additions & 1 deletion .github/workflows/secrets_scanner.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
name: Leaked Secrets Scan
on: [pull_request]
on:
pull_request:
branches:
- main
- preview
- dev
jobs:
TruffleHog:
runs-on: ubuntu-latest
Expand Down
14 changes: 1 addition & 13 deletions components/header/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,7 @@
</span>
<div>Note: Withdrawals will be enabled before 04/13/2024</div>
</div> -->
<div className="banner" v-if="!route.query.s || route.query.s !== 'okx'">
<!-- <a href="https://app.zklink.io/" target="\_blank">
<img
src="/img/banner.svg"
alt=""
className="bannerImg"
/>
<img
src="/img/mobile.svg"
alt=""
className="mobileImg"
/>
</a> -->
<div className="banner" v-if="route.query.s !== 'okx' && route.query.s !== 'binance'">
<banner />
</div>
</div>
Expand Down
5 changes: 4 additions & 1 deletion components/transaction/TransactionFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@
<div v-if="buttonStep === 'network'" class="transaction-footer-row">
<CommonButtonTopInfo>Incorrect network selected in your wallet</CommonButtonTopInfo>
<CommonButton
v-if="connectorName !== 'WalletConnect'"
v-if="
connectorName !== 'WalletConnect' ||
(connectorName === 'WalletConnect' && (walletName?.includes('OKX') || walletName?.includes('MetaMask')))
"
type="submit"
:disabled="switchingNetworkInProgress"
variant="primary"
Expand Down
8 changes: 8 additions & 0 deletions components/transaction/TransferLineItem.vue
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,14 @@ const getl1NetworkName = () => {
from: eraNetwork.value.name,
to: eraNetwork.value.name,
};
} else if (type === "withdrawal") {
const newNetwork = zkSyncNetworks.find(
(item) => item.key && item.key.toLowerCase() === (props.transfer.token?.networkKey || 'primary').toLowerCase()
)
return {
from: newNetwork?.l1Network?.name,
to: newNetwork?.l1Network?.name,
};
} else {
return {
from: getNetworkInfo().l1Network?.name,
Expand Down
Binary file added public/img-browser-wallet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/banner-binance-mobile.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/banner-binance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 36 additions & 12 deletions store/onboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { useRuntimeConfig } from "#imports";
import { confirmedSupportedWallets, disabledWallets } from "@/data/wallets";
import { useNetworkStore } from "@/store/network";

const isMobile = () => window.innerWidth < 800; // simple way to detect mobile device

export const useOnboardStore = defineStore("onboard", () => {
const { zkSyncNetworks } = useNetworks();
const runtimeConfig = useRuntimeConfig();
Expand Down Expand Up @@ -151,20 +153,42 @@ export const useOnboardStore = defineStore("onboard", () => {
}
};
identifyWalletName();

const autoConnectInBinanceWeb3 = async () => {
const connectors = getConnectors(wagmiConfig);
const injected = connectors.find((item) => item.id === "injected");
if (injected && !account.value?.address && window.innerWidth < 800) {
await injected.connect();
reconnect(wagmiConfig);
}
};

const BinanceWalletId = "8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4";
const excludeWalletIds = ["bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6"];
if (isMobile()) {
excludeWalletIds.push(BinanceWalletId);
}
const featuredWalletIds = [
// "1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",rainbow
"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // okx wallet
// "8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4", // binance web3 wallet
"ad2eff108bf828a39e5cb41331d95861c9cc516aede9cb6a95d75d98c206e204", // Gate.io Wallet
"c7708575a2c3c9e6a8ab493d56cdcc56748f03956051d021b8cd8d697d9a3fd2", // fox wallet
// "aba1f652e61fd536e8a7a5cd5e0319c9047c435ef8f7e907717361ff33bb3588",
// "38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",//bitget
];
if (!isMobile()) {
featuredWalletIds.unshift(BinanceWalletId);
}

const web3modal = createWeb3Modal({
wagmiConfig,
projectId: env.walletConnectProjectID,
connectorImages: {},
excludeWalletIds: ["bc949c5d968ae81310268bf9193f9c9fb7bb4e1283e1284af8f2bd4992535fd6"],
featuredWalletIds: [
// "1ae92b26df02f0abca6304df07debccd18262fdf5fe82daa81593582dac9a369",rainbow
"971e689d0a5be527bac79629b4ee9b925e82208e5168b733496a09c0faed0709", // okx wallet
"8a0ee50d1f22f6651afcae7eb4253e52a3310b90af5daef78a8c4929a9bb99d4", // binance web3 wallet
"ad2eff108bf828a39e5cb41331d95861c9cc516aede9cb6a95d75d98c206e204", // Gate.io Wallet
"c7708575a2c3c9e6a8ab493d56cdcc56748f03956051d021b8cd8d697d9a3fd2", // fox wallet
// "aba1f652e61fd536e8a7a5cd5e0319c9047c435ef8f7e907717361ff33bb3588",
// "38f5d18bd8522c244bdd70cb4a68e0e718865155811c043f052fb9f1c51de662",//bitget
],
connectorImages: {
injected: "/img-browser-wallet.png",
},
excludeWalletIds,
featuredWalletIds,
// termsConditionsUrl: "https://zksync.io/terms",
// privacyPolicyUrl: "https://zksync.io/privacy",
themeMode: selectedColorMode.value,
Expand Down Expand Up @@ -295,7 +319,7 @@ export const useOnboardStore = defineStore("onboard", () => {
if (!l1Network.value) throw new Error(`L1 network is not available on ${selectedNetwork.value.name}`);
return getPublicClient(wagmiConfig, { chainId: chainId || l1Network.value?.id });
},

autoConnectInBinanceWeb3,
subscribeOnAccountChange,
subscribeOnNetworkChange,
};
Expand Down
2 changes: 1 addition & 1 deletion store/zksync/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const getEstmatdDepositDelay = (networkKey: string): number => {
return ESTIMATED_DEPOSIT_DELAY_SECONDARY;
}
};
export const WITHDRAWAL_DELAY = 7 * 24 * 60 * 60 * 1000; // 7 * 24 hours
export const WITHDRAWAL_DELAY = 14 * 24 * 60 * 60 * 1000; // 7 * 24 hours
export type Address = Hash;
export type ForwardL2Request = {
gateway: Address;
Expand Down
23 changes: 21 additions & 2 deletions store/zksync/wallet.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { MERGE_TOKENS } from "./../../utils/constants";
import { getPublicClient } from "@wagmi/core";
import { BigNumber, ethers, VoidSigner } from "ethers";
import { $fetch } from "ofetch";

Expand All @@ -12,6 +14,7 @@ import { useOnboardStore } from "@/store/onboard";
import { useZkSyncProviderStore } from "@/store/zksync/provider";
import { useZkSyncTokensStore } from "@/store/zksync/tokens";
import { L1Signer, L1VoidSigner, Web3Provider } from "@/zksync-web3-nova/src";

export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {
const onboardStore = useOnboardStore();
const providerStore = useZkSyncProviderStore();
Expand Down Expand Up @@ -91,7 +94,7 @@ export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {
await Promise.all([requestAccountState({ force: true }), tokensStore.requestTokens()]);
if (!accountState.value) throw new Error("Account state is not available");
if (!tokens.value) throw new Error("Tokens are not available");
return Object.entries(accountState.value.balances)
const accountBalances = Object.entries(accountState.value.balances)
.filter(([, { token }]) => token)
.map(([, { balance, token }]) => {
return {
Expand All @@ -103,6 +106,21 @@ export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {
amount: balance,
};
});
//add merge tokens
for (const token of MERGE_TOKENS) {
const find = accountBalances.find((item) => item.address.toLowerCase() === token.address.toLowerCase());
if (!find) {
accountBalances.push({
address: token.address,
l1Address: undefined,
name: token!.symbol || undefined,
symbol: token!.symbol!,
decimals: token!.decimals,
amount: "0",
});
}
}
return accountBalances;
};
const getBalancesFromRPC = async (): Promise<TokenAmount[]> => {
await tokensStore.requestTokens();
Expand Down Expand Up @@ -158,7 +176,8 @@ export const useZkSyncWalletStore = defineStore("zkSyncWallet", () => {

const deductBalance = (tokenAddress: string, amount: BigNumberish) => {
if (!balance.value) return;
const tokenBalance = balance.value.find((balance) => balance.address === tokenAddress);
const index = balance.value.findIndex((balance) => balance.address === tokenAddress);
const tokenBalance = balance.value[index];
if (!tokenBalance) return;
const newBalance = BigNumber.from(tokenBalance.amount).sub(amount);
tokenBalance.amount = newBalance.isNegative() ? "0" : newBalance.toString();
Expand Down
33 changes: 33 additions & 0 deletions utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,36 @@ export const ETH_TOKEN: Token = {
decimals: 18,
iconUrl: "/img/eth.svg",
};

export const WITHDRAWAL_DELAY_DAYS = 14;

export const MERGE_TOKENS = [
{
symbol: "USDT",
address: "0x2F8A25ac62179B31D62D7F80884AE57464699059",
targetNetworkKeys: ["ethereum", "arbitrum", "zksync", "linea", "manta", "mantle", "optimism"],
decimals: 6,
},
{
symbol: "WBTC",
address: "0xDa4AaEd3A53962c83B35697Cd138cc6df43aF71f",
targetNetworkKeys: ["ethereum", "arbitrum", "zksync", "linea", "manta", "mantle", "optimism"],
decimals: 18,
},
{
symbol: "USDC",
address: "0x1a1A3b2ff016332e866787B311fcB63928464509",
targetNetworkKeys: ["ethereum", "arbitrum", "zksync", "linea", "manta", "mantle", "optimism", "base"],
decimals: 6,
},
{
symbol: "DAI",
address: "0xF573fA04A73d5AC442F3DEa8741317fEaA3cDeab",
targetNetworkKeys: ["ethereum", "arbitrum", "zksync", "linea", "optimism", "base"],
decimals: 18,
},
];

export const isMergeToken = (address: string) => {
return address && MERGE_TOKENS.some((token) => token.address.toLowerCase() === address.toLowerCase());
};
32 changes: 19 additions & 13 deletions views/transactions/Deposit.vue
Original file line number Diff line number Diff line change
@@ -1,29 +1,37 @@
<template>
<div>
<div class="okx-tips mb-[10px]" v-if="route.query?.s === 'okx'">
<div class="okx-tips-cover"></div>
<div class="cryptopeida-tips okx-cryptopeida mb-[10px]" v-if="route.query?.s === 'okx'">
<div class="cryptopeida-tips-cover"></div>
<!-- <img src="/img/okx-cryptopedia.svg" class="h-[64px] w-[64px] rounded-[8px]" /> -->
<div class="z-2">
<a
href="https://www.okx.com/web3/discover/cryptopedia/event/28"
target="_blank"
class="okx-tips-title z-2 relative flex cursor-pointer items-center gap-[4px]"
class="cryptopeida-tips-title z-2 relative flex cursor-pointer items-center gap-[4px]"
>
<span>OKX Cryptopedia</span>
<img :src="launchIcon" />
</a>
<div class="mt-[5px]">
<p class="okx-tips-desc">
<p class="cryptopeida-tips-desc">
Withdrawals from Nova are locked until April 14th, 10am UTC. During this time, you can use a third-party
bridge to withdraw your assets.
</p>
<p class="okx-tips-desc">
<p class="cryptopeida-tips-desc">
Please wait a few minutes for deposits to arrive before verifying the task on OKX Cryptopedia.
</p>
</div>
</div>
</div>
<div class="mb-[10px]" v-else-if="route.query?.s === 'binance'">
<!-- <img src="/img/okx-cryptopedia.svg" class="h-[64px] w-[64px] rounded-[8px]" /> -->
<div class="z-2">
<img src="/img/banner-binance@2x.png" class="block hidden w-full md:block" />
<img src="/img/banner-binance-mobile@2x.png" class="block block w-full md:hidden" />
</div>
</div>
<PageTitle v-if="step === 'form'">Deposit</PageTitle>
<PageTitle
v-else-if="step === 'confirm'"
Expand All @@ -36,10 +44,6 @@
Confirm transaction
</PageTitle>

<div class="warnBox flex" v-if="!route.query.s || route.query.s !== 'okx'">
<div>Note: Your funds will be locked for a max of 30 days during the campaign.</div>
</div>

<NetworkSelectModal
v-model:opened="fromNetworkModalOpened"
title="From"
Expand Down Expand Up @@ -990,18 +994,20 @@ onboardStore.subscribeOnNetworkChange((newchainId) => {
top: -30px;
}

.okx-tips {
.cryptopeida-tips {
position: relative;
padding: 16px;
border-radius: 8px;
border: 1px solid #262b33;
background: #000;
background-image: url("/img/okx-tips-bg.svg");
background-size: cover;
background-position: center;
background-repeat: no-repeat;
&.okx-cryptopeida {
background-image: url("/img/okx-tips-bg.svg");
}

.okx-tips-cover {
.cryptopeida-tips-cover {
content: "";
position: absolute;
top: 0;
Expand Down Expand Up @@ -1061,7 +1067,7 @@ onboardStore.subscribeOnNetworkChange((newchainId) => {
display: none;
position: absolute;
padding: 12px 20px 12px 24px;
top: -4.5rem;
top: -7.5rem;
width: 35rem;
left: -10rem;
border-radius: 8px;
Expand Down
Loading

0 comments on commit 65f7328

Please sign in to comment.