Skip to content

Commit

Permalink
Updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
aii23 committed Oct 13, 2024
1 parent 787ba61 commit fc121b6
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 27 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "l1-lottery-contracts",
"version": "0.7.35",
"version": "0.7.36",
"description": "",
"author": "",
"license": "Apache-2.0",
Expand Down Expand Up @@ -34,7 +34,8 @@
"token_prepare": "node build-mina-fungible-token.js && cd node_modules/mina-fungible-token && npm run build",
"deploy": "npm run build && node build/scripts/deploy.js",
"publish_ipfs_request": "npm run build && node build/scripts/publish_request.js",
"prepare_for_deploy": "npm run build && node build/scripts/publish_request.js && node build/scripts/prepare_verification_keys.js ** npm run build"
"prepare_for_deploy": "npm run build && node build/scripts/publish_request.js && node build/scripts/prepare_verification_keys.js ** npm run build",
"deploy_factory": "npm run prepare_for_deploy && node build/scripts/deploy_factory.js"
},
"devDependencies": {
"@babel/preset-env": "^7.16.4",
Expand Down
2 changes: 1 addition & 1 deletion random_request_cid.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const cidBuffer = 'bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y';
export const cidBuffer = 'bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se'
2 changes: 1 addition & 1 deletion scripts/deploy_1rnd_pottery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ for (let round = +from; round <= +to; round++) {
console.log(
`Deploying plottery: ${plotteryAddress.toBase58()} and random manager: ${randomManagerAddress.toBase58()} for round ${round}`
);
let tx = Mina.transaction(
let tx = await Mina.transaction(
{ sender: deployer, fee: 10 * transactionFee },
async () => {
AccountUpdate.fundNewAccount(deployer);
Expand Down
21 changes: 18 additions & 3 deletions scripts/pbuy_ticket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,32 @@ const factoryManager = await getFedFactoryManager(factory);

const ticket = Ticket.from([1, 1, 1, 1, 1, 1], deployer, 1);

console.log(`Current round: ${currentRound}`);

const plottery = factoryManager.plotteryManagers[+currentRound].contract;

// compile the contract to create prover keys
console.log('compile the DP');
await DistributionProgram.compile({ cache: Cache.FileSystem('../cache') });
const dpResult = await DistributionProgram.compile({
cache: Cache.FileSystem('../cache'),
});
console.log(`DP verification key: ${dpResult.verificationKey.hash.toString()}`);

console.log('compile reduce proof');
await TicketReduceProgram.compile({ cache: Cache.FileSystem('../cache') });
const ticketReduceResult = await TicketReduceProgram.compile({
cache: Cache.FileSystem('../cache'),
});
console.log(
`Ticket Reduce Result: ${ticketReduceResult.verificationKey.hash.toString()}`
);

console.log('compile the Lottery');
await PLottery.compile({
const plotteryResult = await PLottery.compile({
cache: Cache.FileSystem('../cache'),
});
console.log(
`Plottery Result: ${plotteryResult.verificationKey.hash.toString()}`
);

await fetchAccount({ publicKey: plottery.address });
await fetchAccount({
Expand Down
32 changes: 16 additions & 16 deletions scripts/prepare_cache.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
// import path from 'path';
// import { readdir, stat, copyFile, writeFile } from 'fs/promises';
import path from 'path';
import { readdir, stat, copyFile, writeFile } from 'fs/promises';

// // #TODO should be updated with current cache structure
// #TODO should be updated with current cache structure

// const directory = 'cache';
const directory = 'cache';

// const files = await readdir(directory);
// const stats = await Promise.all(
// files.map((file) => stat(path.join(directory, file)))
// );
const files = await readdir(directory);
const stats = await Promise.all(
files.map((file) => stat(path.join(directory, file)))
);

// const filesToInclude = files.filter((x, i) => stats[i].size < 100_000_000);
const filesToInclude = files.filter((x, i) => stats[i].size < 100_000_000);

// for (let fileToInclude of filesToInclude) {
// await copyFile(`cache/${fileToInclude}`, `cache_frontend/${fileToInclude}`);
// }
for (let fileToInclude of filesToInclude) {
await copyFile(`cache/${fileToInclude}`, `cache_frontend/${fileToInclude}`);
}

// await writeFile(
// 'cache_frontend/cache_list.json',
// JSON.stringify(filesToInclude, null, 2)
// );
await writeFile(
'cache_frontend/cache_list.json',
JSON.stringify(filesToInclude, null, 2)
);
5 changes: 4 additions & 1 deletion scripts/prepare_verification_keys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@ const result = {

console.log(result);

fs.writeFileSync('vk.json', JSON.stringify(result, null, 2));
fs.writeFileSync(
'vk.js',
`export const vkJSON = ${JSON.stringify(result, null, 2)}`
);
7 changes: 5 additions & 2 deletions scripts/publish_request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ const json = {
let response = await pinata.upload.json(json);

console.log(response.IpfsHash);
writeFileSync('./random_request_cid', response.IpfsHash.toString());
writeFileSync(
'./random_request_cid.js',
`export const cidBuffer = '${response.IpfsHash.toString()}'`
);

writeFileSync('./random_request_file', JSON.stringify(json, null, 2));
writeFileSync('./random_request_file', `${JSON.stringify(json, null, 2)}`);
2 changes: 1 addition & 1 deletion src/Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
Cache,
UInt32,
} from 'o1js';
import { vkJSON } from '../vk';
import { vkJSON } from '../vk.js';
import { BLOCK_PER_ROUND } from './constants.js';
import { MerkleMap20 } from './Structs/CustomMerkleMap.js';
import { RandomManager } from './Random/RandomManager.js';
Expand Down

0 comments on commit fc121b6

Please sign in to comment.