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: wrap MNT to WMNT and unwrap WETH to ETH when deposit #85

Merged
merged 42 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
b802cec
update for auto wrap MNT to WMNT when depost
MickWang Apr 8, 2024
4d9cd13
unwrap weth when deposit
MickWang Apr 8, 2024
e965cb9
add weth contracts
MickWang Apr 9, 2024
bbb9ed3
fix conflicts
MickWang Apr 9, 2024
26e0260
fix lint issues
MickWang Apr 10, 2024
593cea3
fix lint issues
MickWang Apr 10, 2024
f4721ea
Merge branch 'main' into feat/wrap_mnt
MickWang Apr 12, 2024
1f27cb1
update feature.yml
MickWang Apr 12, 2024
626ff91
fix lint error
MickWang Apr 12, 2024
143b496
Merge branch 'main' into feat/wrap_mnt
MickWang Apr 12, 2024
a0245aa
Merge pull request #104 from zkLinkProtocol/feat/open_withdraw
zkLeonardo Apr 14, 2024
b935e75
Merge pull request #105 from zkLinkProtocol/feat/open_withdraw
zkLeonardo Apr 14, 2024
5a4ed69
Merge pull request #106 from zkLinkProtocol/feat/open_withdraw
zkLeonardo Apr 14, 2024
d0b3978
Merge pull request #109 from zkLinkProtocol/feat/not_withdraw_merge
zkLeonardo Apr 14, 2024
5b8a9f9
support merege token withraw
MickWang Apr 15, 2024
acc4c7a
update ui fir withdraw merge token
MickWang Apr 15, 2024
b9068ff
update estimate withdraw left time
MickWang Apr 15, 2024
1ed296b
update approve for merge token
MickWang Apr 16, 2024
6dd4166
update ui for withdraw merge token
MickWang Apr 16, 2024
1e6ed2c
Merge pull request #113 from zkLinkProtocol/feat/binance-banner
MickWang Apr 16, 2024
fa1f963
Merge pull request #115 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 16, 2024
456cdce
update ui for merge token allowance
MickWang Apr 16, 2024
1f6ff86
update ui for merge token allowance
MickWang Apr 16, 2024
79f24f6
Merge pull request #116 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 16, 2024
fc37521
fix: Fixing the issue of incorrect chain display in the withdraw feature
haymond-ZK Apr 16, 2024
f99860e
Merge pull request #117 from zkLinkProtocol/feature-withdraw
MickWang Apr 16, 2024
ce7e4bf
update switch chain for binance
MickWang Apr 16, 2024
7a3ad9e
Merge pull request #119 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 16, 2024
20e6316
add selected token check
MickWang Apr 16, 2024
be7a084
update binnace wallet display name
MickWang Apr 16, 2024
3068782
Merge pull request #120 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 16, 2024
f3c6922
fix change network text issue
MickWang Apr 17, 2024
43ea917
Merge pull request #125 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 17, 2024
ecef897
remove debugger
MickWang Apr 17, 2024
4c0d7d4
Merge pull request #126 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 17, 2024
4aaa20b
feat:wrap MNT and unwrap WETH
Apr 17, 2024
a1fb928
fix text error
MickWang Apr 17, 2024
b58afc1
Merge pull request #129 from zkLinkProtocol/feat/withdraw_merge
zkLeonardo Apr 17, 2024
65f7328
Merge branch 'main' into feat/wrap_mnt
MickWang Apr 17, 2024
2c9e54d
fix conflicts
MickWang Apr 17, 2024
f9c9a76
Merge branch 'preview' into feat/wrap_mnt
MickWang Apr 18, 2024
e5a5646
fix:mantle weth and icon url
zkcarl Apr 18, 2024
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
1 change: 1 addition & 0 deletions composables/zksync/useWithdrawalFinalization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export default (transactionInfo: ComputedRef<TransactionInfo>) => {
erc20BridgeL1: eraNetwork.erc20BridgeL1,
erc20BridgeL2: eraNetwork.erc20BridgeL2,
l1Gateway: eraNetwork.l1Gateway,
wethContract: eraNetwork.wethContract
});
provider.setIsEthGasToken(eraNetwork.isEthGasToken ?? true);
return provider;
Expand Down
12 changes: 11 additions & 1 deletion data/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ export type ZkSyncNetwork = {
l1Gateway?: Address;
isEthGasToken?: boolean;
getTokens?: () => Token[] | Promise<Token[]>; // If blockExplorerApi is specified, tokens will be fetched from there. Otherwise, this function will be used.
wethContract?: Address[];
};

export const nexusNode: ZkSyncNetwork[] = [
Expand All @@ -167,6 +168,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x83Bc7394738A7A084081aF22EEC0051908c0055c",
isEthGasToken: true,
l1Network: l1Networks.mainnet,
wethContract: ["0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"],
},
{
id: 810180,
Expand All @@ -182,6 +184,7 @@ export const nexusNode: ZkSyncNetwork[] = [
erc20BridgeL2: "0x01c3f51294494e350AD69B999Db6B382b3B510b9",
isEthGasToken: true,
l1Network: l1Networks.linea,
wethContract: ["0xe5d7c2a44ffddf6b295a15c148167daaaf5cf34f"],
},
{
id: 810180,
Expand All @@ -198,6 +201,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0xeCD189e0f390826E137496a4e4a23ACf76c942Ab",
isEthGasToken: true,
l1Network: l1Networks.zkSync,
wethContract: ["0x5aea5775959fbc2557cc8789bc1bf90a239d9a91", "0x8Ebe4A94740515945ad826238Fc4D56c6B8b0e60"],
},
{
id: 810180,
Expand All @@ -214,6 +218,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x273D59aed2d793167c162E64b9162154B07583C0",
isEthGasToken: true,
l1Network: l1Networks.arbitrum,
wethContract: ["0x82af49447d8a07e3bd95bd0d56f35241523fbab1"],
},
{
id: 810180,
Expand All @@ -228,8 +233,9 @@ export const nexusNode: ZkSyncNetwork[] = [
erc20BridgeL1: "0x62351b47e060c61868Ab7E05920Cb42bD9A5f2B2",
erc20BridgeL2: "0x321Ce902eDFC6466B224ce5D9A7Bc16858855272",
l1Gateway: "0xdE1Ce751405Fe6D836349226EEdCDFFE1C3BE269",
isEthGasToken: false,
isEthGasToken: true,
l1Network: l1Networks.mantle,
wethContract: ["0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111"],
},
{
id: 810180,
Expand All @@ -246,6 +252,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x649Dfa2c4d09D877419fA1eDC4005BfbEF7CD82D",
isEthGasToken: true,
l1Network: l1Networks.manta,
wethContract: ["0x0Dc808adcE2099A9F62AA87D9670745AbA741746"],
},
{
id: 810180,
Expand All @@ -262,6 +269,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x41FaF46Ca4Dfd912B65B66D29BdD432782BB1158",
isEthGasToken: true,
l1Network: l1Networks.blast,
wethContract: ["0x4300000000000000000000000000000000000004"],
},
{
id: 810180,
Expand All @@ -278,6 +286,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x668e8F67adB8219e1816C2E5bBEa055A78AF3026",
isEthGasToken: true,
l1Network: l1Networks.optimism,
wethContract: ["0x4200000000000000000000000000000000000006"],
},
{
id: 810180,
Expand All @@ -294,6 +303,7 @@ export const nexusNode: ZkSyncNetwork[] = [
l1Gateway: "0x4eEA93966AA5cd658225E0D43b665A5a491d2b7E",
isEthGasToken: true,
l1Network: l1Networks.base,
wethContract: ["0x4200000000000000000000000000000000000006"],
},
];

Expand Down
8 changes: 7 additions & 1 deletion store/zksync/ethereumBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,13 @@
const filterL1tokens = Object.values(l1Tokens.value ?? []).filter(
(e) => e.networkKey === selectedNetwork.value.key || e.address === ETH_TOKEN.l1Address
);

if (selectedNetwork.value.key === "mantle") {
const nativeToken = filterL1tokens.find((e) => e.address === ETH_TOKEN.l1Address);
const wmntToken = filterL1tokens.find((e) => e.symbol === "WMNT");
nativeToken!.symbol = "MNT";
nativeToken!.price = wmntToken?.price ?? 0;
nativeToken!.iconUrl = "/img/mantle.svg";
}
const publicClient = getPublicClient(wagmiConfig as Config, { chainId: l1Network.value?.id });

const ethBalance = await getBalance(wagmiConfig as Config, {
Expand Down Expand Up @@ -108,7 +114,7 @@
try {
await requestBalance({ force: true });
} catch {}
isSaveToken = false;

Check failure on line 117 in store/zksync/ethereumBalance.ts

View workflow job for this annotation

GitHub Actions / Build

Empty block statement
};

const {
Expand Down
2 changes: 2 additions & 0 deletions store/zksync/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export const useZkSyncProviderStore = defineStore("zkSyncProvider", () => {
erc20BridgeL1: eraNetwork.erc20BridgeL1,
erc20BridgeL2: eraNetwork.erc20BridgeL2,
l1Gateway: eraNetwork.l1Gateway,
wethContract: eraNetwork.wethContract
});
provider.setIsEthGasToken(eraNetwork.isEthGasToken ?? true);
return provider;
Expand All @@ -33,6 +34,7 @@ export const useZkSyncProviderStore = defineStore("zkSyncProvider", () => {
erc20BridgeL1: primaryNetwork.erc20BridgeL1,
erc20BridgeL2: primaryNetwork.erc20BridgeL2,
l1Gateway: primaryNetwork.l1Gateway,
wethContract: primaryNetwork.wethContract
});
primaryProvider.setIsEthGasToken(primaryNetwork.isEthGasToken ?? true);
return primaryProvider;
Expand Down
1 change: 1 addition & 0 deletions store/zksync/transactionStatus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@
const forwardHash = ethers.utils.keccak256(encodedata) as Hash;
console.log(forwardHash);
while (true) {
const canonicalTxHash = await eraWalletStore.getPrimaryL1VoidSigner().getCanonicalTxHash(forwardHash);

Check failure on line 163 in store/zksync/transactionStatus.ts

View workflow job for this annotation

GitHub Actions / Build

Unexpected constant condition
if (canonicalTxHash) return canonicalTxHash;
await sleep(5000);
}
Expand Down Expand Up @@ -207,6 +207,7 @@
erc20BridgeL1: eraNetwork.erc20BridgeL1,
erc20BridgeL2: eraNetwork.erc20BridgeL2,
l1Gateway: eraNetwork.l1Gateway,
wethContract: eraNetwork.wethContract
});
provider.setIsEthGasToken(eraNetwork.isEthGasToken ?? true);
return provider;
Expand Down
2 changes: 2 additions & 0 deletions store/zksync/withdrawals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
erc20BridgeL1: eraNetwork.erc20BridgeL1,
erc20BridgeL2: eraNetwork.erc20BridgeL2,
l1Gateway: eraNetwork.l1Gateway,
wethContract: eraNetwork.wethContract
});
provider.setIsEthGasToken(eraNetwork.isEthGasToken ?? true);
return provider;
Expand Down Expand Up @@ -141,6 +142,7 @@ export const useZkSyncWithdrawalsStore = defineStore("zkSyncWithdrawals", () =>
erc20BridgeL1: eraNetworks.erc20BridgeL1,
erc20BridgeL2: eraNetworks.erc20BridgeL2,
l1Gateway: eraNetworks.l1Gateway,
wethContract: eraNetworks.wethContract,
});
provider.setIsEthGasToken(eraNetworks.isEthGasToken ?? true);
return provider;
Expand Down
1 change: 1 addition & 0 deletions views/transactions/Deposit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -471,7 +471,7 @@
(e) => e.networkKey === eraNetwork.value.key || e.address === ETH_TOKEN.l1Address
);
return filterL1tokens;
// return Object.values(l1Tokens.value ?? []);

Check failure on line 474 in views/transactions/Deposit.vue

View workflow job for this annotation

GitHub Actions / Build

'ETH_TOKEN' is not defined
});
const availableBalances = computed<TokenAmount[]>(() => {
return balance.value ?? [];
Expand Down Expand Up @@ -832,6 +832,7 @@
}, 2000);
})
.catch((err) => {
console.log(err)
transactionError.value = err as Error;
transactionStatus.value = "not-started";
});
Expand Down
161 changes: 161 additions & 0 deletions zksync-web3-nova/abi/WrappedMNT.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
[
{ "type": "constructor", "inputs": [] },
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }],
"name": "allowance",
"inputs": [
{ "type": "address", "name": "owner", "internalType": "address" },
{ "type": "address", "name": "spender", "internalType": "address" }
]
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }],
"name": "approve",
"inputs": [
{ "type": "address", "name": "spender", "internalType": "address" },
{ "type": "uint256", "name": "amount", "internalType": "uint256" }
]
},
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }],
"name": "balanceOf",
"inputs": [
{ "type": "address", "name": "account", "internalType": "address" }
]
},
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "uint8", "name": "", "internalType": "uint8" }],
"name": "decimals",
"inputs": []
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }],
"name": "decreaseAllowance",
"inputs": [
{ "type": "address", "name": "spender", "internalType": "address" },
{
"type": "uint256",
"name": "subtractedValue",
"internalType": "uint256"
}
]
},
{
"type": "function",
"stateMutability": "payable",
"outputs": [],
"name": "deposit",
"inputs": []
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }],
"name": "increaseAllowance",
"inputs": [
{ "type": "address", "name": "spender", "internalType": "address" },
{ "type": "uint256", "name": "addedValue", "internalType": "uint256" }
]
},
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "string", "name": "", "internalType": "string" }],
"name": "name",
"inputs": []
},
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "string", "name": "", "internalType": "string" }],
"name": "symbol",
"inputs": []
},
{
"type": "function",
"stateMutability": "view",
"outputs": [{ "type": "uint256", "name": "", "internalType": "uint256" }],
"name": "totalSupply",
"inputs": []
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }],
"name": "transfer",
"inputs": [
{ "type": "address", "name": "recipient", "internalType": "address" },
{ "type": "uint256", "name": "amount", "internalType": "uint256" }
]
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [{ "type": "bool", "name": "", "internalType": "bool" }],
"name": "transferFrom",
"inputs": [
{ "type": "address", "name": "sender", "internalType": "address" },
{ "type": "address", "name": "recipient", "internalType": "address" },
{ "type": "uint256", "name": "amount", "internalType": "uint256" }
]
},
{
"type": "function",
"stateMutability": "nonpayable",
"outputs": [],
"name": "withdraw",
"inputs": [
{ "type": "uint256", "name": "_amount", "internalType": "uint256" }
]
},
{
"type": "event",
"name": "Approval",
"inputs": [
{ "type": "address", "name": "owner", "indexed": true },
{ "type": "address", "name": "spender", "indexed": true },
{ "type": "uint256", "name": "value", "indexed": false }
],
"anonymous": false
},
{
"type": "event",
"name": "Deposit",
"inputs": [
{ "type": "address", "name": "dst", "indexed": true },
{ "type": "uint256", "name": "wad", "indexed": false }
],
"anonymous": false
},
{
"type": "event",
"name": "Transfer",
"inputs": [
{ "type": "address", "name": "from", "indexed": true },
{ "type": "address", "name": "to", "indexed": true },
{ "type": "uint256", "name": "value", "indexed": false }
],
"anonymous": false
},
{
"type": "event",
"name": "Withdrawal",
"inputs": [
{ "type": "address", "name": "src", "indexed": true },
{ "type": "uint256", "name": "wad", "indexed": false }
],
"anonymous": false
},
{ "type": "receive" },
{ "type": "fallback" }
]
Loading
Loading