-
Notifications
You must be signed in to change notification settings - Fork 4
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
Problem: zksync-web3.js does not support custom gas token #26
Closed
Closed
Changes from 6 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6ff227a
chore: update ABI and typings
XinyuCRO 8b8525f
feat: add support for custom gas token
XinyuCRO 05deb43
test: add tests for custom gas token
XinyuCRO 4a76143
fix: wethL1 address not returned from server
XinyuCRO 5fa813c
feat: update bindings & publish new version
XinyuCRO c56f28b
fix: rpc url
XinyuCRO e6dc49b
refactor: remove comments
XinyuCRO File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { ethers } from 'ethers'; | ||
|
||
import { Wallet, Provider, utils } from "../build/src"; | ||
|
||
const MNEMONIC="fine music test violin matrix prize squirrel panther purchase material script deal" | ||
const DERIVE_PATH = "m/44'/60'/0'/0/1"; | ||
|
||
const WETH_ADDRESS = "0x8D4F22C9f1F22Ea745C7a828391Ef0E8D1692D4a"; | ||
|
||
const printBalance = async (wallet: Wallet,tag: string) => { | ||
const wethBalance = await wallet.getBalanceL1(WETH_ADDRESS); | ||
console.log(`[${tag}]WETH balance L1: `, ethers.utils.formatEther(wethBalance)); | ||
|
||
let balance = await wallet.getBalance(); | ||
console.log(`[${tag}]ETH balance L2: `, ethers.utils.formatEther(balance)); | ||
} | ||
|
||
const test = async () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. im not sure if we should commit this file, otherwise need to clean it a bit |
||
|
||
let zkWallet = Wallet.fromMnemonic(MNEMONIC, DERIVE_PATH); | ||
zkWallet = zkWallet.connect(new Provider("http://10.202.3.175:3050")); | ||
zkWallet = zkWallet.connectToL1(new ethers.providers.JsonRpcProvider("https://eth-sepolia.public.blastapi.io")); | ||
|
||
const fee = await zkWallet.getFullRequiredDepositFee({ | ||
token: utils.ETH_ADDRESS, | ||
to: zkWallet.address, | ||
}) | ||
|
||
console.log(fee); | ||
|
||
await printBalance(zkWallet, "before deposit") | ||
|
||
const tx = await zkWallet.deposit({ | ||
token: utils.ETH_ADDRESS, | ||
amount: ethers.utils.parseEther("10"), | ||
overrides: { | ||
gasLimit: 1000000, | ||
} | ||
}); | ||
await tx.waitFinalize(); | ||
|
||
await printBalance(zkWallet, "after deposit") | ||
|
||
|
||
const withdrawTx = await zkWallet.withdraw({ | ||
token: utils.ETH_ADDRESS, | ||
amount: ethers.utils.parseEther("10"), | ||
overrides: { | ||
gasLimit: 1000000, | ||
} | ||
}) | ||
const receipt = await withdrawTx.waitFinalize(); | ||
|
||
const finalizeWithdrawTx = await zkWallet.finalizeWithdrawal(receipt.transactionHash) | ||
|
||
await finalizeWithdrawTx.wait(); | ||
|
||
await printBalance(zkWallet, "after withdraw") | ||
} | ||
|
||
test(); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not sure if we can remove it if its not a big change?