diff --git a/package.json b/package.json index 949d27d..0512cf0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "l1-lottery-contracts", - "version": "0.7.35", + "version": "0.7.36", "description": "", "author": "", "license": "Apache-2.0", @@ -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", diff --git a/random_request_cid.js b/random_request_cid.js index aa706a2..fe514ae 100644 --- a/random_request_cid.js +++ b/random_request_cid.js @@ -1 +1 @@ -export const cidBuffer = 'bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y'; \ No newline at end of file +export const cidBuffer = 'bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se' \ No newline at end of file diff --git a/scripts/deploy_1rnd_pottery.ts b/scripts/deploy_1rnd_pottery.ts index 39cf2ef..952c8d4 100644 --- a/scripts/deploy_1rnd_pottery.ts +++ b/scripts/deploy_1rnd_pottery.ts @@ -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); diff --git a/scripts/pbuy_ticket.ts b/scripts/pbuy_ticket.ts index f674c9b..0dcd453 100644 --- a/scripts/pbuy_ticket.ts +++ b/scripts/pbuy_ticket.ts @@ -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({ diff --git a/scripts/prepare_cache.ts b/scripts/prepare_cache.ts index e554e3a..03eba4b 100644 --- a/scripts/prepare_cache.ts +++ b/scripts/prepare_cache.ts @@ -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) +); diff --git a/scripts/prepare_verification_keys.ts b/scripts/prepare_verification_keys.ts index 239b38a..03838f1 100644 --- a/scripts/prepare_verification_keys.ts +++ b/scripts/prepare_verification_keys.ts @@ -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)}` +); diff --git a/scripts/publish_request.ts b/scripts/publish_request.ts index 88829ea..ac69fe5 100644 --- a/scripts/publish_request.ts +++ b/scripts/publish_request.ts @@ -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)}`); diff --git a/src/Factory.ts b/src/Factory.ts index 23700f5..98a7480 100644 --- a/src/Factory.ts +++ b/src/Factory.ts @@ -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';