Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deploy.ts #16

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
47 changes: 21 additions & 26 deletions scripts/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,40 +1,35 @@
import { EasyPrivateVotingContractArtifact, EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js"
import { AccountWallet, CompleteAddress, ContractDeployer, createDebugLogger, Fr, PXE, waitForPXE, TxStatus, createPXEClient, getContractInstanceFromDeployParams, DebugLogger } from "@aztec/aztec.js";
import { EasyPrivateVotingContract } from "../src/artifacts/EasyPrivateVoting.js";
import { AccountWallet, Fr, PXE, createPXEClient, waitForPXE, getContractInstanceFromDeployParams, createDebugLogger } from "@aztec/aztec.js";
import { getSchnorrAccount } from '@aztec/accounts/schnorr';
import { AztecAddress, deriveSigningKey } from '@aztec/circuits.js';
import { TokenContract } from "@aztec/noir-contracts.js";
import { deriveSigningKey } from '@aztec/circuits.js';
import { getInitialTestAccountsWallets } from "@aztec/accounts/testing";

const setupSandbox = async () => {
const setupPXE = async () => {
const { PXE_URL = 'http://localhost:8080' } = process.env;
const pxe = await createPXEClient(PXE_URL);
await waitForPXE(pxe);
return pxe;
};

async function main() {

let pxe: PXE;
let wallets: AccountWallet[] = [];
let accounts: CompleteAddress[] = [];
let logger: DebugLogger;

logger = createDebugLogger('aztec:aztec-starter');

pxe = await setupSandbox();
wallets = await getInitialTestAccountsWallets(pxe);

let secretKey = Fr.random();
let salt = Fr.random();
const deployVotingContract = async (wallet, address) => {
return await EasyPrivateVotingContract.deploy(wallet, address).send().deployed();
};

let schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
const { address, publicKeys, partialAddress } = schnorrAccount.getCompleteAddress();
let tx = await schnorrAccount.deploy().wait();
let wallet = await schnorrAccount.getWallet();
async function main() {
const logger = createDebugLogger('aztec:optimized');
const pxe = await setupPXE();
const wallets = await getInitialTestAccountsWallets(pxe);

await EasyPrivateVotingContract.deploy(wallet, address).send().deployed()
// let token = await TokenContract.deploy(wallet, wallet.getAddress(), "Test", "TST", 18).send().deployed();
// await token.methods.mint_private(wallet.getAddress(), 100).send().wait();
const secretKey = Fr.random();
const salt = Fr.random();
const schnorrAccount = await getSchnorrAccount(pxe, secretKey, deriveSigningKey(secretKey), salt);
const { address } = schnorrAccount.getCompleteAddress();

await schnorrAccount.deploy().wait();
const wallet = await schnorrAccount.getWallet();

const votingContract = await deployVotingContract(wallet, address);
logger.info(`Voting Contract deployed at: ${votingContract.address}`);
}

main();