Skip to content

Commit

Permalink
Merge pull request ZK-solidity-army#7 from ZK-solidity-army/german
Browse files Browse the repository at this point in the history
feat(scripts): scripts added
  • Loading branch information
Spacylion authored Mar 23, 2024
2 parents 2c134e8 + e258906 commit 09a5a0e
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 43 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
node_modules
.env

# Hardhat files
/cache
/artifacts


# TypeChain files
/typechain
/typechain-types
Expand Down
2 changes: 2 additions & 0 deletions .idea/week2.iml

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

26 changes: 4 additions & 22 deletions configs/viemConfig.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,5 @@
import {createPublicClient, createWalletClient, http} from "viem";
import {sepolia} from "viem/chains";
import {privateKeyToAccount} from "viem/accounts";
import * as dotenv from "dotenv";
dotenv.config();

/** FOR READ CONTRACTS*/
export const publicClient = createPublicClient({
batch: {
multicall: true,
},
chain: sepolia,
transport: http(),
})

/** FOR WRITE CONTRACTS*/
export type HexStringType = `0x${string}`;

const privateKey: HexStringType = `0x${process.env.PRIVATE_KEY}`;
const account = privateKeyToAccount(privateKey)
export const privateClient = createWalletClient({
account,
chain: sepolia,
transport: http()
})
export const deployerPrivateKey = process.env.PRIVATE_KEY || "";
export const providerApiKey = process.env.ALCHEMY_API_KEY || "";
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"delegate": "",
"vote": "npx ts-node ./scripts/viem/CastVote.ts 0xe3c392ce25492b970775de78a157677e04a617e7 1",
"giveRightToVote": "",
"winningProposal": ""
"deploySmartcontract": "npx ts-node ./scripts/viem/Deploy.ts Prop1 Prop2 Prop3",
"castVote": "npx ts-node ./scripts/viem/CastVote.ts <address> <proposalIndex>",
"delegate": "npx ts-node ./scripts/viem/CastVote.ts <delegate_address> <proposal_index>",
"vote": "npx ts-node ./scripts/viem/CastVote.ts <address> 1",
"giveRightToVote": "npx ts-node ./scripts/viem/DelegateVote.ts <address> <address_to_whom>",
"winningProposal": "npx ts-node ./scripts/viem/GetWinningProposal.ts <address>"
},

"author": "",
"license": "ISC",
"devDependencies": {
Expand Down
8 changes: 2 additions & 6 deletions scripts/viem/CastVote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,9 @@ import {createPublicClient, createWalletClient, hexToString, http,} from "viem";
import {sepolia} from "viem/chains";
import {abi} from "../../artifacts/contracts/Ballot.sol/Ballot.json";

import * as dotenv from "dotenv";
import {privateKeyToAccount} from "viem/accounts";

dotenv.config();

const deployerPrivateKey = process.env.PRIVATE_KEY || "";
const providerApiKey = process.env.ALCHEMY_API_KEY || "";
import {privateKeyToAccount} from "viem/accounts";
import {deployerPrivateKey, providerApiKey} from "../../configs/viemConfig";

async function main() {
//RECEIVING PARAMETERS
Expand Down
2 changes: 1 addition & 1 deletion scripts/viem/Delegate.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import config from "../../config";
import {createPublicClient, createWalletClient, http} from "viem";
import {privateKeyToAccount} from "viem/accounts";
import {sepolia} from "viem/chains";

import {abi} from "../../artifacts/contracts/Ballot.sol/Ballot.json";

import config from "../../config";

async function main() {
const parameters = process.argv.slice(2);
Expand Down
7 changes: 1 addition & 6 deletions scripts/viem/Deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import {createPublicClient, createWalletClient, formatEther, hexToString, http,
import {sepolia} from "viem/chains";
import {privateKeyToAccount} from "viem/accounts";
import {abi, bytecode,} from "../../artifacts/contracts/Ballot.sol/Ballot.json";
import * as dotenv from "dotenv";

dotenv.config();

const deployerPrivateKey = process.env.PRIVATE_KEY || "";
const providerApiKey = process.env.ALCHEMY_API_KEY || "";
import {deployerPrivateKey, providerApiKey} from "../../configs/viemConfig";

async function main() {
//CREATE PUBLIC CLIENT
Expand Down
2 changes: 1 addition & 1 deletion scripts/viem/GetWinningProposal.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import config from "../../config";
import { createPublicClient, http, hexToString } from "viem";
import { sepolia } from "viem/chains";

import { abi } from "../../artifacts/contracts/Ballot.sol/Ballot.json";

import config from "../../config";

async function main() {
const parameters = process.argv.slice(2);
Expand Down

0 comments on commit 09a5a0e

Please sign in to comment.