Skip to content

Commit

Permalink
Removed fs dep
Browse files Browse the repository at this point in the history
  • Loading branch information
asimaranov committed Oct 11, 2024
1 parent 6a81f1e commit 44fa950
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "l1-lottery-contracts",
"version": "0.7.25",
"version": "0.7.32",
"description": "",
"author": "",
"license": "Apache-2.0",
Expand Down
1 change: 0 additions & 1 deletion random_request_cid

This file was deleted.

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: 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());
};

0 comments on commit 44fa950

Please sign in to comment.