Commit 9631226d authored by vicotor's avatar vicotor

update script

parent af66694a
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
/**
* @title IERC20Burnable
* @dev 扩展ERC20接口,添加销毁功能
* @dev Extends ERC20 interface with burn functionality
*/
interface IERC20Burnable is IERC20 {
function burn(uint256 amount) external;
......@@ -14,10 +16,9 @@ interface IERC20Burnable is IERC20 {
/**
* @title Bridge
* @dev 跨链桥合约,支持代币在不同区块链之间转移
* @notice 使用多签验证者机制确保跨链转移的安全性
* @dev Cross-chain bridge contract supporting token transfers between blockchains
*/
contract Bridge is Ownable {
contract Bridge is Initializable, OwnableUpgradeable, UUPSUpgradeable {
/// @dev 执行转入操作所需的最少验证者确认数量
uint256 public validRequired;
......@@ -257,13 +258,17 @@ contract Bridge is Ownable {
// ============ 构造函数 ============
/**
* @notice 初始化合约,设置初始所需确认数为1
* @param initialOwner 合约的初始所有者
*/
constructor(address initialOwner) Ownable(initialOwner) {
function _authorizeUpgrade(address newImplementation) internal override onlyOwner {
// Add any additional checks if needed
}
/// @dev Initializes the contract (replaces constructor)
/// @param initialOwner The initial owner of the contract
function initialize(address initialOwner) public initializer {
__Ownable_init();
__UUPSUpgradeable_init();
validRequired = 1;
treasury = address(0); // 初始化金库地址为0,需要后续设置
treasury = address(0); // Initialize treasury address to 0
transferOwnership(initialOwner);
}
// ============ 验证者管理函数 ============
......
require("@nomicfoundation/hardhat-toolbox");
require("@nomicfoundation/hardhat-ethers");
require("@openzeppelin/hardhat-upgrades");
require("dotenv").config()
......
This source diff could not be displayed because it is too large. You can view the blob instead.
const fs = require("fs");
const path = require("path");
const hre = require("hardhat");
const { ethers, upgrades } = require("hardhat");
const DEPLOY_FILE = path.join(__dirname, "deploy.json");
async function deploy() {
const token = await hre.ethers.getContractFactory(
const token = await ethers.getContractFactory(
"TestToken"
);
const tokenA = await token.deploy("Test Token Ali", "TTA");
......@@ -17,16 +17,18 @@ async function deploy() {
const tokenBAddr = await tokenB.getAddress();
// Deploy the contract
const factory = await hre.ethers.getContractFactory(
const factory = await ethers.getContractFactory(
"Bridge"
);
[owner] = await hre.ethers.getSigners();
[owner] = await ethers.getSigners();
const contract = await factory.deploy(owner.address);
const contract = await upgrades.deployProxy(factory, [owner.address], {
initializer: "initialize",
});
await contract.waitForDeployment();
const bridgeAddr = await contract.getAddress();
const chainId = await hre.ethers.provider.getNetwork().then(network => network.chainId);
const chainId = await ethers.provider.getNetwork().then(network => network.chainId);
await saveDeployment(chainId, tokenAAddr, tokenBAddr, bridgeAddr);
console.log("initial_height = ", contract.deploymentTransaction().blockNumber)
console.log("bridge_contract = ", bridgeAddr)
......
......@@ -3,7 +3,10 @@ const path = require("path");
const hre = require("hardhat");
var users = [
"0xCb7559B648eE663A2B0C569837F510D5f0ABAaD1"
// "0xCb7559B648eE663A2B0C569837F510D5f0ABAaD1",
// "0x05DA4f0d5348Abb139b7cD8D8896A774CaB12BA6",
// "0x2D4E6b96bD85248d13020D392e99558abFb4f74C",
"0x119BA92c15337FfB37871e44F3f9102409D95F12"
]
const DEPLOY_FILE = path.join(__dirname, "deploy.json");
......@@ -41,8 +44,6 @@ async function getDeploy(chainId) {
// Define the script
async function main() {
const chainId = await hre.ethers.provider.getNetwork().then(network => network.chainId);
const targetChainId = chainId === 6174n ? 8891 : 6174;
console.log("Current chain ID:", chainId, "Target chain ID:", targetChainId);
const curChainDeploy = await getDeploy(chainId);
for (var i = 0; i < users.length; i++) {
......
......@@ -144,8 +144,8 @@ async function setOutConfig(curTokenMap, targetTokenMap, targetChainId, bridge)
// Define the script
async function main() {
const chainId = await hre.ethers.provider.getNetwork().then(network => network.chainId);
// const targetChainId = chainId === 97n ? 10323 : 97;
const targetChainId = chainId === 6174n ? 8891 : 6174;
const targetChainId = chainId === 97n ? 10323 : 97;
// const targetChainId = chainId === 6174n ? 8891 : 6174;
console.log("Current chain ID:", chainId, "Target chain ID:", targetChainId);
const curChainDeploy = await getDeploy(chainId);
......
......@@ -131,8 +131,8 @@ async function outTransfer(bridge, token , amount, targetChainId, receiver) {
// Define the script
async function main() {
const chainId = await hre.ethers.provider.getNetwork().then(network => network.chainId);
const targetChainId = chainId === 6174n ? 8891 : 6174;
// const targetChainId = chainId === 97n ? 10323 : 97;
// const targetChainId = chainId === 6174n ? 8891 : 6174;
const targetChainId = chainId === 97n ? 10323 : 97;
console.log("Current chain ID:", chainId, "Target chain ID:", targetChainId);
const chainDeploy = await getDeploy(chainId);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment