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

New zklink #110

Merged
merged 3 commits into from
Sep 12, 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
26 changes: 9 additions & 17 deletions contracts/Arbitrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,15 @@ contract Arbitrator is IArbitrator, OwnableUpgradeable, UUPSUpgradeable, Reentra
bytes calldata _adapterParams
) external payable nonReentrant onlyRelayer {
bytes32 _finalizeMessageHash = keccak256(abi.encode(_value, _callData));
if (_gateway == primaryChainGateway) {
require(_finalizeMessageHash == primaryChainMessageHashQueue.popFront(), "Invalid finalize message hash");
// Unpack destination chain and final callData
(IL1Gateway secondaryChainGateway, bytes memory finalCallData) = abi.decode(_callData, (IL1Gateway, bytes));
require(secondaryChainGateways[secondaryChainGateway], "Invalid secondary chain gateway");
// Forward fee to send message
secondaryChainGateway.sendMessage{value: msg.value + _value}(_value, finalCallData, _adapterParams);
} else {
require(secondaryChainGateways[_gateway], "Not secondary chain gateway");
require(
_finalizeMessageHash == secondaryChainMessageHashQueues[_gateway].popFront(),
"Invalid finalize message hash"
);
// Forward fee to send message
primaryChainGateway.sendMessage{value: msg.value + _value}(_value, _callData, _adapterParams);
}
emit MessageForwarded(_gateway, _value, _callData);
require(secondaryChainGateways[_gateway], "Not secondary chain gateway");
require(
_finalizeMessageHash == secondaryChainMessageHashQueues[_gateway].popFront(),
"Invalid finalize message hash"
);
// Forward fee to send message
IL1Gateway targetGateway = primaryChainGateway;
targetGateway.sendMessage{value: msg.value + _value}(_value, _callData, _adapterParams);
emit MessageForwarded(targetGateway, _value, _callData);
}

function claimMessage(
Expand Down
8 changes: 4 additions & 4 deletions examples/optimism/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion examples/optimism/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"scripts": {},
"devDependencies": {
"@eth-optimism/sdk": "0.0.0-sc-sdk-fps-mainnet-20240610215134",
"@eth-optimism/sdk": "^3.3.2",
"@nomiclabs/hardhat-ethers": "^2.0.2",
"ethers": "^5.7.2",
"hardhat": "^2.9.1"
Expand Down
4 changes: 4 additions & 0 deletions examples/zklinkNova/.env-sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

# Duplicate this file as .env here

# Your Private key

DEVNET_PRIVKEY="0x your key here"

# This is zkLink Sepolia Testnet

ZKLINK_NOVA_RPC="https://sepolia.rpc.zklink.io"
Expand Down
1 change: 1 addition & 0 deletions examples/zklinkNova/hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ require('@nomicfoundation/hardhat-toolbox');
require('./scripts/getTxStatus');
require('./scripts/decodeRawTx');
require('./scripts/printGovernanceCall');
require('./scripts/sendRawTx');

const BaseConfig = require('../../hardhat.base.config');

Expand Down
28 changes: 28 additions & 0 deletions examples/zklinkNova/scripts/sendRawTx.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const { ethers } = require('ethers');
const { task, types } = require('hardhat/config');

require('dotenv').config();

task('sendRawTx', 'Send raw tx to nova')
.addParam('to', 'The to address', undefined, types.string)
.addParam('data', 'The call data', undefined, types.string)
.addOptionalParam('value', 'The call value(unit: ether)', '0', types.string)
.addOptionalParam('gasPrice', 'The gas price(unit: gwei)', '0', types.string)
.setAction(async taskArgs => {
const to = taskArgs.to;
const data = taskArgs.data;
const value = ethers.parseEther(taskArgs.value);
const gasPrice = ethers.parseUnits(taskArgs.gasPrice, 'gwei');

const provider = new ethers.JsonRpcProvider(process.env.ZKLINK_NOVA_RPC);
const wallet = new ethers.Wallet(process.env.DEVNET_PRIVKEY, provider);
const tx = await wallet.sendTransaction({
to,
data,
value,
gasPrice,
});
console.log(`The tx hash: ${tx.hash}`);
const txReceipt = await tx.wait(1);
console.log(`The tx status: ${txReceipt.status}`);
});
Loading