Skip to content

Commit

Permalink
feat: use weth as bold stake token
Browse files Browse the repository at this point in the history
  • Loading branch information
gzeoneth committed Nov 25, 2024
1 parent 1c2d0ab commit ddbfb34
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 3 deletions.
41 changes: 41 additions & 0 deletions scripts/ethcommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { namedAccount, namedAddress } from "./accounts";
import * as L1GatewayRouter from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/gateway/L1GatewayRouter.sol/L1GatewayRouter.json";
import * as L1AtomicTokenBridgeCreator from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/ethereum/L1AtomicTokenBridgeCreator.sol/L1AtomicTokenBridgeCreator.json";
import * as ERC20 from "@openzeppelin/contracts/build/contracts/ERC20.json";
import * as TestWETH9 from "@arbitrum/token-bridge-contracts/build/contracts/contracts/tokenbridge/test/TestWETH9.sol/TestWETH9.json";
import * as fs from "fs";
import { ARB_OWNER } from "./consts";
const path = require("path");
Expand Down Expand Up @@ -139,6 +140,14 @@ async function deployERC20Contract(deployerWallet: Wallet, decimals: number): Pr
return token.address;
}

async function deployWETHContract(deployerWallet: Wallet): Promise<string> {
const wethFactory = new ContractFactory(TestWETH9.abi, TestWETH9.bytecode, deployerWallet);
const weth = await wethFactory.deploy("Wrapped Ether", "WETH");
await weth.deployTransaction.wait();

return weth.address;
}

export const bridgeFundsCommand = {
command: "bridge-funds",
describe: "sends funds from l1 to l2",
Expand Down Expand Up @@ -415,6 +424,38 @@ export const transferERC20Command = {
},
};

export const createWETHCommand = {
command: "create-weth",
describe: "creates WETH on L1",
builder: {
deployer: {
string: true,
describe: "account (see general help)"
},
deposit: {
number: true,
describe: "amount of weth to deposit",
default: 100,
}
},
handler: async (argv: any) => {
console.log("create-weth");

const l1provider = new ethers.providers.WebSocketProvider(argv.l1url);
const deployerWallet = namedAccount(argv.deployer).connect(l1provider);

const wethAddress = await deployWETHContract(deployerWallet);
const weth = new ethers.Contract(wethAddress, TestWETH9.abi, deployerWallet);
console.log("WETH deployed at L1 address:", weth.address);

if (argv.deposit > 0) {
const amount = ethers.utils.parseEther(argv.deposit.toString());
const depositTx = await deployerWallet.sendTransaction({ to: wethAddress, value: amount, data:"0xd0e30db0" }); // deposit()
await depositTx.wait();
}
},
};

export const sendL1Command = {
command: "send-l1",
describe: "sends funds between l1 accounts",
Expand Down
2 changes: 2 additions & 0 deletions scripts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
bridgeNativeTokenToL3Command,
bridgeToL3Command,
createERC20Command,
createWETHCommand,
transferERC20Command,
sendL1Command,
sendL2Command,
Expand All @@ -38,6 +39,7 @@ async function main() {
.command(bridgeToL3Command)
.command(bridgeNativeTokenToL3Command)
.command(createERC20Command)
.command(createWETHCommand)
.command(transferERC20Command)
.command(sendL1Command)
.command(sendL2Command)
Expand Down
6 changes: 3 additions & 3 deletions test-node.bash
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ if $force_init; then
docker compose run -e CHILD_CHAIN_RPC="http://sequencer:8547" -e CHAIN_OWNER_PRIVKEY=$l2ownerKey rollupcreator deploy-cachemanager-testnode

if $boldupgrade; then
echo == Deploying BOLD stake token
stakeTokenAddress=`docker compose run scripts create-erc20 --l1 --deployer l2owner --decimals 18 | tail -n 1 | awk '{ print $NF }'`
echo == Deploying WETH as BOLD stake token
stakeTokenAddress=`docker compose run scripts create-weth --deployer l2owner --deposit 100 | tail -n 1 | awk '{ print $NF }'`
echo BOLD stake token address: $stakeTokenAddress
docker compose run scripts transfer-erc20 --token $stakeTokenAddress --l1 --amount 10000 --from l2owner --to validator
docker compose run scripts transfer-erc20 --token $stakeTokenAddress --l1 --amount 100 --from l2owner --to validator
echo == Preparing BOLD upgrade
docker compose run -e TESTNODE_MODE=true -e ROLLUP_ADDRESS=$rollupAddress -e STAKE_TOKEN=$stakeTokenAddress boldupgrader script:bold-prepare
# retry this 10 times because the staker might not have made a node yet
Expand Down

0 comments on commit ddbfb34

Please sign in to comment.