diff --git a/random_request_cid b/random_request_cid index affa806..654ee9b 100644 --- a/random_request_cid +++ b/random_request_cid @@ -1 +1 @@ -bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se \ No newline at end of file +bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se 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/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/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()); }; diff --git a/vk.json b/vk.js similarity index 99% rename from vk.json rename to vk.js index bbd3478..8f8126e 100644 --- a/vk.json +++ b/vk.js @@ -1,4 +1,4 @@ -{ +export const vkJSON = { "randomManagerVK": { "hash": "17330540658263117468185091323910434567490388801197480248529120280889605935477", "data": "AQF3Yxe1ogZ+hbfu4kmm1zILKtgnDUzFJ4PobT/OC8/XKdlGcDR19fo1Mev11BMouhVFsKk/NcQWSOTJT2/bD5oSPQDDQHEW7dtcsgDEk4IAmp9fQAMEqwpGE78rTDId8wlOOgNvabycrSJXUWDcwdDHLcaaujHs5sa0KwQ5r0fGFEUilDaUQb09uN0hWb0bqp7YcV3P5VaTdmSIGrtBAdkMa5hTLezc09TOV2S+tJfAePr6Ma7uwP5ICiMeel0KoyRgGA8p/Q8FeEKO9SlcxsPKYYS9KDMKj2+YARLDld10EfwdrtyFFXiLDbWnMQKRU9VrfytK1p7c5oKSdW/RG4oqnqHGja+Icio73BBnzcVZAmk/sY+e76QS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