Skip to content

Commit

Permalink
Merge branch 'main' of github.com:ZkNoid/L1-lottery
Browse files Browse the repository at this point in the history
  • Loading branch information
aii23 committed Oct 11, 2024
2 parents c2acf59 + 44fa950 commit 787ba61
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion random_request_cid
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se
bafkreih6hhv5m44xz6fhklhqhcpdgd3znrs6w5332trjxb3qz5ychjy4se
1 change: 1 addition & 0 deletions random_request_cid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const cidBuffer = 'bafkreicnannsz4gqqk3ccfwfd3z2hfzonr63z3hgsplefgrmz37psay23y';
4 changes: 1 addition & 3 deletions scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -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());
};
5 changes: 1 addition & 4 deletions 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 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';
Expand All @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import * as fs from 'fs';
// import * as fs from 'fs';

import {
Field,
Expand All @@ -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
Expand Down Expand Up @@ -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());
};
2 changes: 1 addition & 1 deletion vk.json → vk.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 787ba61

Please sign in to comment.