Skip to content

Commit

Permalink
publish most recent smart contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
mihailo-maksa committed May 30, 2024
1 parent 5e8a64f commit 46a3cc3
Show file tree
Hide file tree
Showing 179 changed files with 48,152 additions and 846 deletions.
2 changes: 2 additions & 0 deletions .env_sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DEFENDER_KEY=
DEFENDER_SECRET=
51 changes: 51 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: test

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened
- labeled

concurrency:
group: ci-${{ github.ref }}-tests
cancel-in-progress: true

env:
FOUNDRY_PROFILE: "ci"

jobs:
check:
strategy:
fail-fast: true

name: Foundry project
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
submodules: recursive

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Install deps
run: |
npm i
forge install
#- name: Run Forge build
# run: |
# forge build --sizes

- name: Run fmt check
run: |
npm run fmt:check
- name: Run Forge tests
run: |
forge test -vvv
27 changes: 27 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
node_modules
.env
coverage
coverage.json
typechain
typechain-types

# Hardhat files
cache
artifacts

# Foundry files
cache_forge
out
broadcast
cache_hardhat
artifacts
exports/abis/local.json
exports/addresses/local.json

# misc
.vscode
.idea
.DS_Store
_playground/*.json
.env_mainnet
.env_testnet
21 changes: 21 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[submodule "lib/forge-std"]
path = lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/solmate"]
path = lib/solmate
url = https://github.com/transmissions11/solmate
[submodule "lib/solady"]
path = lib/solady
url = https://github.com/Vectorized/solady
[submodule "lib/council"]
path = lib/council
url = https://github.com/delvtech/council
[submodule "lib/openzeppelin-contracts"]
path = lib/openzeppelin-contracts
url = https://github.com/OpenZeppelin/openzeppelin-contracts
[submodule "lib/openzeppelin-contracts-upgradeable"]
path = lib/openzeppelin-contracts-upgradeable
url = https://github.com/OpenZeppelin/openzeppelin-contracts-upgradeable
[submodule "lib/openzeppelin-foundry-upgrades"]
path = lib/openzeppelin-foundry-upgrades
url = https://github.com/OpenZeppelin/openzeppelin-foundry-upgrades
140 changes: 140 additions & 0 deletions _playground/DeployAtomWallet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
import { ethers } from "ethers";
require('dotenv').config();

const API_URL = "<< RPC URL>>";
const PROXY_ADDRESS = "0x0000000000000000000000000000000000000000"; // Transparent Upgradable Proxy
const CHAIN_ID = 84532; // Base Sepolia (84532), Base Mainnet (8453)

async function main() {

const private_key = process.env.PRIVATE_KEY ? String(process.env.PRIVATE_KEY) : "";

// ABI of the EthMultiVault contract (reduced)
const abi = [
{
"type": "function",
"name": "count",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "getAtomCost",
"inputs": [],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "view"
},
{
"type": "function",
"name": "createAtom",
"inputs": [
{
"name": "atomUri",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [
{
"name": "",
"type": "uint256",
"internalType": "uint256"
}
],
"stateMutability": "payable"
},
{
"type": "function",
"name": "deployAtomWallet",
"inputs": [
{
"name": "atomId",
"type": "uint256",
"internalType": "uint256"
}
],
"outputs": [
{
"name": "",
"type": "address",
"internalType": "address"
}
],
"stateMutability": "nonpayable"
},
];

// Connect to the network
let provider = new ethers.providers.JsonRpcProvider(API_URL, CHAIN_ID);

// We connect to the Contract using a Provider, so we will only
// have read-only access to the Contract
let contract = new ethers.Contract(PROXY_ADDRESS, abi, provider);

// Check the current vault counter
let counter = await contract.count();
console.log("counter:", counter.toNumber());

let vaultId = counter.toNumber() + 1;
console.log("vaultId:", vaultId);

let atomId = `atom${vaultId}`;
console.log("atomId:", atomId);

// Get the current value
let atomCost = await contract.getAtomCost();
console.log("atomCost:", atomCost.toNumber());

// Load the wallet to deploy the contract with
let wallet = new ethers.Wallet(private_key, provider);

// Create a new instance of the Contract with a Signer, which allows
// update methods
let contractWithSigner = contract.connect(wallet);

let atomURI = ethers.utils.solidityPack(["string"], [atomId]);

let tx = await contractWithSigner.createAtom(
atomURI, {
value: atomCost,
gasPrice: ethers.utils.parseUnits("0.5", "gwei"),
}
);

console.log("Tx hash:", tx.hash);

// The operation is NOT complete yet; we must wait until it is mined
await tx.wait();

console.log("tx:", tx);

let tx2 = await contractWithSigner.deployAtomWallet(
vaultId, {
gasPrice: ethers.utils.parseUnits("0.5", "gwei"),
}
);

await tx2.wait();

console.log("tx2:", tx2);
}

main()
.then(() => process.exit(0))
.catch((e) => {
console.error(e)
process.exit(1)
})
Loading

0 comments on commit 46a3cc3

Please sign in to comment.