From 6a81f1ea5ad0678e49d2ae99df8be0592c42235b Mon Sep 17 00:00:00 2001 From: asimaranov Date: Fri, 11 Oct 2024 12:08:55 +0700 Subject: [PATCH 1/2] Added direct vk import --- src/Factory.ts | 5 +---- vk.json => vk.js | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) rename vk.json => vk.js (99%) diff --git a/src/Factory.ts b/src/Factory.ts index 6c83194..23700f5 100644 --- a/src/Factory.ts +++ b/src/Factory.ts @@ -16,7 +16,7 @@ import { Cache, UInt32, } from 'o1js'; -import fs from 'fs'; +import { vkJSON } from '../vk'; import { BLOCK_PER_ROUND } from './constants.js'; import { MerkleMap20 } from './Structs/CustomMerkleMap.js'; import { RandomManager } from './Random/RandomManager.js'; @@ -36,9 +36,6 @@ const emptyMerkleMapRoot = new MerkleMap().getRoot(); // cache: Cache.FileSystem('cache'), // }); -let vkString = fs.readFileSync('./vk.json').toString(); -let vkJSON = JSON.parse(vkString); - const randomManagerVK = { hash: Field(vkJSON.randomManagerVK.hash), data: vkJSON.randomManagerVK.data, diff --git a/vk.json b/vk.js similarity index 99% rename from vk.json rename to vk.js index 1c0fac1..856fbc9 100644 --- a/vk.json +++ b/vk.js @@ -1,4 +1,4 @@ -{ +export const vkJSON = { "randomManagerVK": { "hash": "152094078362964014992263532489384152720552140917677915980555604386584279732", "data": "AQEM6dD1fga7onkP4y/6LCgbsBqZ1JW+e2SHArm0BHtCIuakkZtkcZ8wRadhA6bNkxq8EwIXZyMxnk9dPdefT948Ev2boBYXuK7BA9ImuNjQXjAJtbxYhOyLH9vIDYQi+RDVxQKABdI3Oq/3eN2mGoxYlrsJDXVpE50iR59+w+9gNohKjmE4GSo+NGgKjyRI8GNC5JxC4rbTaJghhQo4k9APej2bxpyTGHnm1jjl2SLmDzqByIX1vQdeX2u+LCyj8A39wDc9fsQu3QAv8keABbZ3WXwoGF3RaFNJB+eEv51lIohiOeqpk0r4V07U6jVVypHurCKI/28LPc22YUpCVSYky++Q1WqcT1fvHtZA2e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TXbhJ2E4H6CozzgvI20uhY4tuKyH1iON0/2b054Oeohf4mO026unOsFimYSz2HVirJ5AmtkklA0izVq+tcmteLVB58B2civG2qlg0WmphR3PnzzqS1Kiq4n4xB+4Ql6t3De5JxZGCsiHegSj7Ih7ZU0DWR2E0UVDaiG8NTINLAgSGkrvCYyOlKW9pxa+sZPZcIkjn4xmu7ZK1VPE9ICyG95p+SFG1wa6ZMehILUPcOm/NSXuQh665MZ16/W3Q1wwh9Lt56fv1e+sr5M4w/o/PlE8Z4EKFFCO1oxS8IUBPxtbpBYxnQkdpV8BjlsCwjB5xjie+7305bEdyLRk+krYYmjf3qHK27gXJvqcFz2gTxVgu9yYp91JBFnkCCDYyPcgHBS8jkFybsq82EdSH0aLF0MoCNsEbOnbMNVgxIfCgAsmGiGLPCM9DpX5DlFRPfVOQ1/gOrKWe1xhl3afTGQPDG7WtgdrRx+D0XxXR0hCMlAMWAQUDPjTy8ZbKy8As40GNl/SzOxGJhRdsuQEMyQ9E6IzFKiOKizEpe+wCbkOgc+kuK+/eyg9aaRc4NjLrm07KXgKw8sBl8YVO6N9UcWL8oLSwdMn8HdxwgpUaTtiB+dLWSOp7rG1wma43xPYaoOWokyphJCnakyqSMlWlrnlDaqiT7UCKjR3pmMe9i9tQH282chDE0e0+Vv3UksjGZILEMGNPQn7vYQlRj5upO9C3tJaxQKiLlr0H+ZSatKibPM3VIMyWKtXp7pnSw2ZeEdBwFI3fPG4Y0sn2xm1MPjrXs11fR1jfMqOTB8Bofd2hdmSuEmfm787wDTAi5AcvdwTcHK82JWesLjMpPXbEKKE9JdYP0f8ls2EC7UJFZTB1bibZRy3/WbcPYqrCiONekKnTKvLIQcxgFzSgQeUDB8eNV4t1EJRS0LZxerkeLmMQY=" From 44fa950474c3156f576786d859f54f0e6f570ae3 Mon Sep 17 00:00:00 2001 From: asimaranov Date: Fri, 11 Oct 2024 14:11:54 +0700 Subject: [PATCH 2/2] Removed fs dep --- package.json | 2 +- random_request_cid | 1 - random_request_cid.js | 1 + scripts/utils.ts | 4 +--- src/util.ts | 5 ++--- 5 files changed, 5 insertions(+), 8 deletions(-) delete mode 100644 random_request_cid create mode 100644 random_request_cid.js diff --git a/package.json b/package.json index 41c526c..bbab2da 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "l1-lottery-contracts", - "version": "0.7.25", + "version": "0.7.32", "description": "", "author": "", "license": "Apache-2.0", diff --git a/random_request_cid b/random_request_cid deleted file mode 100644 index c13f9ac..0000000 --- a/random_request_cid +++ /dev/null @@ -1 +0,0 @@ -bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y \ No newline at end of file diff --git a/random_request_cid.js b/random_request_cid.js new file mode 100644 index 0000000..aa706a2 --- /dev/null +++ b/random_request_cid.js @@ -0,0 +1 @@ +export const cidBuffer = 'bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y'; \ No newline at end of file diff --git a/scripts/utils.ts b/scripts/utils.ts index 16668e4..0f87228 100644 --- a/scripts/utils.ts +++ b/scripts/utils.ts @@ -1,7 +1,6 @@ import dotenv from 'dotenv'; dotenv.config(); import { Cache, Field, Mina, PrivateKey, PublicKey } from 'o1js'; -import * as fs from 'fs'; import { LotteryAction, TicketReduceProgram, @@ -16,6 +15,7 @@ import { ZkOnCoordinatorAddress } from '../src/constants.js'; import { RandomManagerManager } from '../src/StateManager/RandomManagerManager.js'; import { FactoryManager } from '../src/StateManager/FactoryStateManager.js'; import { PlotteryFactory } from '../src/Factory.js'; +import { cidBuffer } from '../random_request_cid.js'; export const configDefaultInstance = (): { transactionFee: number } => { const transactionFee = 100_000_000; @@ -198,7 +198,5 @@ export const getIPFSCID = (): { hashPart1: Field; hashPart2: Field } => { return { hashPart1, hashPart2 }; } - let cidBuffer = fs.readFileSync('./random_request_cid'); - return segmentHash(cidBuffer.toString()); }; diff --git a/src/util.ts b/src/util.ts index 1994074..1b9fc70 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,4 +1,4 @@ -import * as fs from 'fs'; +// import * as fs from 'fs'; import { Field, @@ -15,6 +15,7 @@ import { import { MerkleMap20 } from './Structs/CustomMerkleMap.js'; // import { PackedUInt32Factory } from 'o1js-pack'; import { StringCircuitValue } from 'zkon-zkapp'; +import { cidBuffer } from '../random_request_cid.js'; const MAX_BITS_PER_FIELD = 254n; const L = 7; // 7 32-bit uints fit in one Field @@ -197,7 +198,5 @@ export const getIPFSCID = (): { hashPart1: Field; hashPart2: Field } => { return { hashPart1, hashPart2 }; } - let cidBuffer = fs.readFileSync('./random_request_cid'); - return segmentHash(cidBuffer.toString()); };