rm built stuff

This commit is contained in:
Moon Man 2023-08-20 15:23:22 -04:00
parent cb0cf6e6c6
commit afdab1cd64
2 changed files with 1 additions and 47 deletions

1
.gitignore vendored
View File

@ -1,3 +1,4 @@
node_modules node_modules
.env .env
.env.* .env.*
dist

47
dist/index.js vendored
View File

@ -1,47 +0,0 @@
// SPDX-License-Identifier: MIT
import optimismSDK from "@eth-optimism/sdk";
import ethers from "ethers";
import fs from "fs/promises";
import dotenv from "dotenv";
const env = process.env.NODE_ENV || "local";
dotenv.config({ path: `../10grans-ng/.env.${env}` });
const ABI = ["function balanceOf(address owner) view returns (uint)"];
const wei = process.argv[2];
const l1Addr = (await fs.readFile(`../10grans-ng/.l1-token-address.${env}`, "utf-8")).trim();
const l2Addr = (await fs.readFile(`../10grans-ng/.l2-token-address.${env}`, "utf-8")).trim();
const l1ApiUrl = process.env.L1_RPC_URL;
const l1RpcProvider = new ethers.providers.JsonRpcProvider(l1ApiUrl);
const l1ChainId = (await l1RpcProvider.getNetwork()).chainId;
const l1PrivateKey = ethers.utils.HDNode.fromMnemonic(process.env.MNEMONIC).derivePath(ethers.utils.defaultPath).privateKey;
const l1Wallet = new ethers.Wallet(l1PrivateKey, l1RpcProvider);
const l1Artifacts = JSON.parse(await fs.readFile("../10grans-ng/artifacts/contracts/L1Token.sol/L1Token.json", "utf-8"));
const l1Token = new ethers.Contract(l1Addr, ABI, l1RpcProvider);
const l2ApiUrl = process.env.L2_RPC_URL;
const l2RpcProvider = new ethers.providers.JsonRpcProvider(l2ApiUrl);
const l2ChainId = (await l2RpcProvider.getNetwork()).chainId;
const l2Wallet = new ethers.Wallet(l1PrivateKey, l2RpcProvider);
const l2Artifacts = JSON.parse(await fs.readFile("../10grans-ng/artifacts/contracts/L2Token.sol/L2Token.json", "utf-8"));
const l2Token = new ethers.Contract(l2Addr, ABI, l2RpcProvider);
let l1Balance = await l1Token.balanceOf(l1Wallet.address);
console.log(`BEFORE L1 wallet balance: ${l1Balance}`);
let l2Balance = await l2Token.balanceOf(l1Wallet.address);
console.log(`BEFORE L2 wallet balance: ${l2Balance}`);
const crossChainMessenger = new optimismSDK.CrossChainMessenger({
l1ChainId: l1ChainId,
l2ChainId: l2ChainId,
l1SignerOrProvider: l1Wallet,
l2SignerOrProvider: l2Wallet
});
console.log("Approving transfer...");
const depositTx1 = await crossChainMessenger.approveERC20(l1Token.address, l2Addr, wei);
await depositTx1.wait();
const blockNumber = await l2RpcProvider.getBlockNumber();
console.log("Depositing...");
const depositTx2 = await crossChainMessenger.depositERC20(l1Token.address, l2Addr, wei);
await depositTx2.wait();
console.log("Waiting for response, could take a while...");
await crossChainMessenger.waitForMessageStatus(depositTx2.hash, optimismSDK.MessageStatus.RELAYED, { fromBlockOrBlockHash: blockNumber });
l1Balance = await l1Token.balanceOf(l1Wallet.address);
console.log(`AFTER L1 wallet balance: ${l1Balance}`);
l2Balance = await l2Token.balanceOf(l1Wallet.address);
console.log(`AFTER L2 wallet balance: ${l2Balance}`);