Skip to content
Open
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
44 changes: 44 additions & 0 deletions contracts/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
-include .env

.PHONY: all test clean deploy fund help install snapshot format anvil

DEFAULT_ANVIL_KEY := 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80

help:
@echo "Usage:"
@echo " make deploy [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""
@echo ""
@echo " make fund [ARGS=...]\n example: make deploy ARGS=\"--network sepolia\""

all: clean remove install update build

# Clean the repo
clean :; forge clean

# Remove modules
remove :; rm -rf .gitmodules && rm -rf .git/modules/* && rm -rf lib && touch .gitmodules && git add . && git commit -m "modules"

install :; forge install Cyfrin/[email protected] --no-commit && forge install foundry-rs/[email protected] --no-commit && forge install openzeppelin/[email protected] --no-commit && forge install transmissions11/solmate


# Update Dependencies
update:; forge update

build:; forge build

test :; forge test

snapshot :; forge snapshot

format :; forge fmt

anvil :; anvil -m 'test test test test test test test test test test test junk' --steps-tracing --block-time 1

NETWORK_ARGS := --rpc-url http://localhost:8545 --private-key $(DEFAULT_ANVIL_KEY) --broadcast

ifeq ($(findstring --network sepolia,$(ARGS)),--network sepolia)
NETWORK_ARGS := --rpc-url $(SEPOLIA_RPC_URL) --private-key $(PRIVATE_KEY) --broadcast --verify --etherscan-api-key $(ETHERSCAN_API_KEY) -vvvv
endif

deploy:
@forge script script/DeployHelloWorld.s.sol:DeployHelloWorld $(NETWORK_ARGS)

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

53 changes: 53 additions & 0 deletions contracts/broadcast/SubstakeVault.s.sol/11155111/run-latest.json

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions contracts/scripts/SubstakeVault.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const fsPromise = fs.promises;

const scrollSepoliaRPC = process.env.SCROLL_RPC;
const privateKey = process.env.PV_KEY
console.log(privateKey)

const vaultProxyabipath = "../out/SubstakeVaultProxy.sol/SubstakeVaultProxy.json";
const vaultProxyAddress = "0xC4374cC35CbB2a42B9C19495AD811C742dc9FAA9";
Expand All @@ -19,15 +20,17 @@ async function getAbi(path){
return abi;
}

const main = async () => {
// upgradeImplementation("0x");
// initializeVault()
const main = () => {
// upgradeImplementation();
console.log("hello");
initializeVault()
}

const upgradeImplementation = async (vaultImplementation) => {
const upgradeImplementation = async () => {
const PROXY_ABI = await getAbi(vaultProxyabipath);
const contract = new ethers.Contract(vaultProxyAddress, PROXY_ABI.abi, signer);
console.log("Updating implementaion.........................");
const vaultImplementation= "0x9F8a444192459a84e99290748309415f7f19bFBA";
let tx = await contract.upgradeImplementation(vaultImplementation)
await tx.wait()
.then(() => {
Expand Down Expand Up @@ -63,4 +66,6 @@ const listenToEvents = async () => {
console.log("Upgraded event fired!");
console.log(implementation);
})
}
}

main();
64 changes: 59 additions & 5 deletions frontend/package-lock.json

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

5 changes: 3 additions & 2 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,16 @@
"class-variance-authority": "^0.7.0",
"clsx": "^2.0.0",
"connectkit": "^1.5.3",
"ethers": "^6.8.1",
"ethers": "^6.9.0",
"lucide-react": "^0.293.0",
"next": "14.0.3",
"react": "^18",
"react-dom": "^18",
"sonner": "^1.2.3",
"tailwind-merge": "^2.0.0",
"tailwindcss-animate": "^1.0.7",
"wagmi": "^1.4.7"
"wagmi": "^1.4.7",
"web3modal": "^1.9.12"
},
"devDependencies": {
"@types/node": "^20",
Expand Down
37 changes: 36 additions & 1 deletion frontend/pages/application/stake.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@ import { NextPage } from "next";
import Image from "next/image";
import { useState } from "react";
import { useAccount, useBalance, useConnect } from "wagmi";
import web3modal from "web3modal";

import { Button } from "@/components/ui/button";
import { Input } from "@/components/ui/input";
import ApplicationLayout from "@/layouts/ApplicationLayout";
import { toast } from "sonner";

const { ethers, JsonRpcProvider } = require("ethers");
let fs = require("fs");
require("dotenv").config();
const fsPromise = fs.promises;

const vaultAbiPath = "../../contracts/out/SubstakeVault.sol/SubstakeVault.json";
const vaultContractAddress = "0x9F8a444192459a84e99290748309415f7f19bFBA";
const privateKey = "0x...";
const scrollSepoliaRPC = "https://rpc.scroll.network";

const StakePage: NextPage = () => {
async function getAbi(path: string) {
const data = await fsPromise.readFile(path, "utf-8");
const abi = JSON.parse(data);
return abi;
}
const [stakeValue, setStakeValue] = useState("");

const { address, isConnecting, isDisconnected } = useAccount();
Expand All @@ -24,6 +40,22 @@ const StakePage: NextPage = () => {

const _chain = chain?.name;

const stakeHandler = async () => {
const modal = new web3modal({
cacheProvider: true,
});
const connection = await modal.connect();

const provider = new JsonRpcProvider(scrollSepoliaRPC);
const signer = new ethers.Wallet(privateKey, provider);

const vaultAbi = await getAbi(vaultAbiPath);

const vaultContract = new ethers.Contract(vaultContractAddress, vaultAbi, signer);

const tx = await vaultContract.stake({ value: ethers.utils.parseEther(stakeValue) });
};

return (
<ApplicationLayout>
<div className="h-[calc(100vh-82px)] flex flex-col w-full max-w-xl mx-auto justify-center items-center px-3 sm:px-0 overflow-hidden">
Expand Down Expand Up @@ -99,7 +131,10 @@ const StakePage: NextPage = () => {
</div>

{isConnected ? (
<Button className="mt-5 rounded-xl w-full h-[52px] text-lg font-medium bg-[#9b923b] hover:bg-[#a99f44] text-white/90 transition-all uppercase">
<Button
onClick={stakeHandler}
className="mt-5 rounded-xl w-full h-[52px] text-lg font-medium bg-[#9b923b] hover:bg-[#a99f44] text-white/90 transition-all uppercase"
>
Stake
</Button>
) : (
Expand Down
Loading