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

Zksync wallet #115

Merged
merged 2 commits into from
Jan 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 6 additions & 3 deletions .github/workflows/deploy_and_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
get-network:
runs-on: ubuntu-latest
needs: [lint-and-test]
Expand All @@ -40,13 +41,13 @@ jobs:
result-encoding: string
script: |
const tag = process.env.GITHUB_REF_NAME;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth)$/;
const regex = /v.*\-(eth|hteth|matic|tmatic|bsc|tbsc|arbeth|tarbeth|opeth|topeth|zketh|tzketh)$/;
const network = tag.match(regex);
return network ? network[1] : "hteth";
deploy-to-test:
runs-on: ubuntu-latest
needs: [lint-and-test, get-network]
if: ${{ (needs.get-network.outputs.network == 'hteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) || (needs.get-network.outputs.network == 'tarbeth' ) || (needs.get-network.outputs.network == 'topeth' ) }}
if: ${{ (needs.get-network.outputs.network == 'hteth' ) || (needs.get-network.outputs.network == 'tmatic' ) || (needs.get-network.outputs.network == 'tbsc' ) || (needs.get-network.outputs.network == 'tarbeth' ) || (needs.get-network.outputs.network == 'topeth' ) || (needs.get-network.outputs.network == 'tzketh' ) }}
environment: testnet
steps:
- uses: actions/checkout@v2
Expand All @@ -68,6 +69,7 @@ jobs:
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down Expand Up @@ -99,7 +101,7 @@ jobs:
deploy-to-prod:
runs-on: ubuntu-latest
needs: [lint-and-test, get-network]
if: ${{ (needs.get-network.outputs.network == 'eth' ) || (needs.get-network.outputs.network == 'matic' ) || (needs.get-network.outputs.network == 'bsc' ) || (needs.get-network.outputs.network == 'arbeth' ) || (needs.get-network.outputs.network == 'opeth' ) }}
if: ${{ (needs.get-network.outputs.network == 'eth' ) || (needs.get-network.outputs.network == 'matic' ) || (needs.get-network.outputs.network == 'bsc' ) || (needs.get-network.outputs.network == 'arbeth' ) || (needs.get-network.outputs.network == 'opeth' ) || (needs.get-network.outputs.network == 'zketh' ) }}
environment: mainnet
steps:
- uses: actions/checkout@v2
Expand All @@ -121,6 +123,7 @@ jobs:
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
- name: Update release notes
uses: actions/github-script@v6
with:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ jobs:
BSCSCAN_API_KEY: ${{ secrets.BSCSCAN_API_KEY }}
ARBISCAN_API_KEY: ${{ secrets.ARBISCAN_API_KEY }}
OPTIMISTIC_ETHERSCAN_API_KEY: ${{ secrets.OPTIMISTIC_ETHERSCAN_API_KEY }}
ZKSYNC_EXPLORER_API_KEY: ${{ secrets.ZKSYNC_EXPLORER_API_KEY }}
- run: npm run lint
57 changes: 57 additions & 0 deletions contracts/coins/ZkethWalletSimple.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// SPDX-License-Identifier: Apache-2.0
pragma solidity 0.8.20;
import '../Forwarder.sol';
import '../ERC20Interface.sol';
import '../WalletSimple.sol';

/**
*
* WalletSimple
* ============
*
* Basic multi-signer wallet designed for use in a co-signing environment where 2 signatures are required to move funds.
* Typically used in a 2-of-3 signing configuration. Uses ecrecover to allow for 2 signatures in a single transaction.
*
* The first signature is created on the operation hash (see Data Formats) and passed to sendMultiSig/sendMultiSigToken
* The signer is determined by verifyMultiSig().
*
* The second signature is created by the submitter of the transaction and determined by msg.signer.
*
* Data Formats
* ============
*
* The signature is created with ethereumjs-util.ecsign(operationHash).
* Like the eth_sign RPC call, it packs the values as a 65-byte array of [r, s, v].
* Unlike eth_sign, the message is not prefixed.
*
* The operationHash the result of keccak256(prefix, toAddress, value, data, expireTime).
* For ether transactions, `prefix` is chain id of the coin i.e. for zkSync mainnet it is "324"
* For token transaction, `prefix` is "324-ERC20" and `data` is the tokenContractAddress.
*
*
*/
contract ZkethWalletSimple is WalletSimple {
/**
* Get the network identifier that signers must sign over
* This provides protection signatures being replayed on other chains
*/
function getNetworkId() internal view override returns (string memory) {
return Strings.toString(block.chainid);
}

/**
* Get the network identifier that signers must sign over for token transfers
* This provides protection signatures being replayed on other chains
*/
function getTokenNetworkId() internal view override returns (string memory) {
return string.concat(Strings.toString(block.chainid), '-ERC20');
}

/**
* Get the network identifier that signers must sign over for batch transfers
* This provides protection signatures being replayed on other chains
*/
function getBatchNetworkId() internal view override returns (string memory) {
return string.concat(Strings.toString(block.chainid), '-Batch');
}
}
29 changes: 27 additions & 2 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ const {
QUICKNODE_ETH_HOLESKY_API_KEY,
QUICKNODE_ARBITRUM_SEPOLIA_API_KEY,
QUICKNODE_OPTIMISM_SEPOLIA_API_KEY,
QUICKNODE_ZKSYNC_SEPOLIA_API_KEY,
ETHERSCAN_API_KEY,
ALCHEMY_POLYGON_API_KEY,
POLYGONSCAN_API_KEY,
BSCSCAN_API_KEY,
ARBISCAN_API_KEY,
OPTIMISTIC_ETHERSCAN_API_KEY
OPTIMISTIC_ETHERSCAN_API_KEY,
ZKSYNC_EXPLORER_API_KEY
} = process.env;

const config: HardhatUserConfig = {
Expand Down Expand Up @@ -78,6 +80,10 @@ const config: HardhatUserConfig = {
topeth: {
url: `${QUICKNODE_OPTIMISM_SEPOLIA_API_KEY}`,
accounts: [`${TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
},
tzketh: {
url: `${QUICKNODE_ZKSYNC_SEPOLIA_API_KEY}`,
accounts: [`${TESTNET_PRIVATE_KEY_FOR_CONTRACT_DEPLOYMENT}`]
}
},
gasReporter: {
Expand All @@ -100,7 +106,10 @@ const config: HardhatUserConfig = {
arbitrumSepolia: `${ARBISCAN_API_KEY}`,
// optimism
optimisticEthereum: `${OPTIMISTIC_ETHERSCAN_API_KEY}`,
optimisticSepolia: `${OPTIMISTIC_ETHERSCAN_API_KEY}`
optimisticSepolia: `${OPTIMISTIC_ETHERSCAN_API_KEY}`,
// zksync
zksync: `${ZKSYNC_EXPLORER_API_KEY}`,
zksyncSepolia: `${ZKSYNC_EXPLORER_API_KEY}`
},
customChains: [
{
Expand All @@ -126,6 +135,22 @@ const config: HardhatUserConfig = {
apiURL: 'https://api-sepolia-optimistic.etherscan.io/api',
browserURL: 'https://sepolia-optimism.etherscan.io'
}
},
{
network: 'zksync',
chainId: 324,
urls: {
apiURL: 'https://block-explorer-api.mainnet.zksync.io/api',
browserURL: 'https://explorer.zksync.io'
}
},
{
network: 'zksyncSepolia',
chainId: 300,
urls: {
apiURL: 'https://block-explorer-api.sepolia.zksync.dev/api',
browserURL: 'https://sepolia.explorer.zksync.io'
}
ajays97 marked this conversation as resolved.
Show resolved Hide resolved
}
]
},
Expand Down
6 changes: 6 additions & 0 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ async function main() {
case 11155420:
walletImplementationContractName = 'OpethWalletSimple';
break;
// zketh
case 324:
// tzketh
case 300:
walletImplementationContractName = 'ZkethWalletSimple';
break;
}

console.log(
Expand Down