Skip to content

Commit

Permalink
fix: missing parameter value when calling query method for getting do…
Browse files Browse the repository at this point in the history
…cuments
0xjei committed Jan 11, 2023
1 parent e0d6427 commit 38a16e6
Showing 8 changed files with 46 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy-dev.yaml
Original file line number Diff line number Diff line change
@@ -15,8 +15,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
node-version: 16
cache: yarn

- name: install dependencies
run: yarn install
4 changes: 2 additions & 2 deletions .github/workflows/test-ci-dev.yaml
Original file line number Diff line number Diff line change
@@ -14,8 +14,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
node-version: 16
cache: yarn

- name: install dependencies
run: yarn install --frozen-lockfile
4 changes: 2 additions & 2 deletions .github/workflows/test-ci-prod.yaml
Original file line number Diff line number Diff line change
@@ -16,8 +16,8 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: 16
cache: yarn
node-version: 16
cache: yarn

- name: install dependencies
run: yarn install --frozen-lockfile
54 changes: 27 additions & 27 deletions packages/backend/firestore.indexes.json
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
{
"indexes": [
"indexes": [
{
"collectionGroup": "ceremonies",
"queryScope": "COLLECTION",
"fields": [
{
"collectionGroup": "ceremonies",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "state",
"order": "ASCENDING"
},
{
"fieldPath": "endDate",
"order": "ASCENDING"
}
]
"fieldPath": "state",
"order": "ASCENDING"
},
{
"collectionGroup": "ceremonies",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "state",
"order": "ASCENDING"
},
{
"fieldPath": "startDate",
"order": "ASCENDING"
}
]
"fieldPath": "endDate",
"order": "ASCENDING"
}
],
"fieldOverrides": []
]
},
{
"collectionGroup": "ceremonies",
"queryScope": "COLLECTION",
"fields": [
{
"fieldPath": "state",
"order": "ASCENDING"
},
{
"fieldPath": "startDate",
"order": "ASCENDING"
}
]
}
],
"fieldOverrides": []
}
4 changes: 2 additions & 2 deletions packages/phase2cli/src/commands/setup.ts
Original file line number Diff line number Diff line change
@@ -201,7 +201,7 @@ const setup = async () => {
// Get current working directory.
const cwd = process.cwd()

const { firebaseApp, firebaseFunctions } = await bootstrapCommandExec()
const { firebaseApp, firebaseFunctions, firestoreDatabase } = await bootstrapCommandExec()

// Handle current authenticated user sign in.
const { user, username } = await handleCurrentAuthUserSignIn(firebaseApp)
@@ -219,7 +219,7 @@ const setup = async () => {
if (!cwdR1csFiles.length) showError(`Your working directory must contain the R1CS files for each circuit`, true)

// Ask for ceremony input data.
const ceremonyInputData = await askCeremonyInputData()
const ceremonyInputData = await askCeremonyInputData(firestoreDatabase)
const ceremonyPrefix = extractPrefix(ceremonyInputData.title)

// Check for circom compiler version and commit hash.
6 changes: 4 additions & 2 deletions packages/phase2cli/src/lib/prompts.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Dirent } from "fs"
import prompts, { Answers, Choice, PromptObject } from "prompts"
import { extractPoTFromFilename, extractPrefix } from "@zkmpc/actions"
import { Firestore } from "firebase/firestore"
import {
CeremonyInputData,
CeremonyTimeoutType,
@@ -84,11 +85,12 @@ export const getEntropyOrBeacon = async (askEntropy: boolean): Promise<string> =

/**
* Show a series of questions about the ceremony.
* @param firestore <Firestore> - the instance of the Firestore database.
* @returns <Promise<CeremonyInputData>> - the necessary information for the ceremony entered by the coordinator.
*/
export const askCeremonyInputData = async (): Promise<CeremonyInputData> => {
export const askCeremonyInputData = async (firestore: Firestore): Promise<CeremonyInputData> => {
// Get ceremonies prefixes to check for duplicates.
const ceremoniesPrefixes = await getCreatedCeremoniesPrefixes()
const ceremoniesPrefixes = await getCreatedCeremoniesPrefixes(firestore)

const noEndDateCeremonyQuestions: Array<PromptObject> = [
{
7 changes: 4 additions & 3 deletions packages/phase2cli/src/lib/queries.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { where } from "firebase/firestore"
import { Firestore, where } from "firebase/firestore"
import { queryCollection, fromQueryToFirebaseDocumentInfo, getAllCollectionDocs } from "@zkmpc/actions"
import { collections, contributionsCollectionFields } from "./constants"
import { FirebaseDocumentInfo } from "../../types/index"

/**
* Retrieve all ceremonies.
* @param firestore <Firestore> - the instance of the Firestore database.
* @returns Promise<Array<FirebaseDocumentInfo>>
*/
export const getAllCeremonies = async (): Promise<Array<FirebaseDocumentInfo>> =>
fromQueryToFirebaseDocumentInfo(await getAllCollectionDocs(`${collections.ceremonies}`)).sort(
export const getAllCeremonies = async (firestore: Firestore): Promise<Array<FirebaseDocumentInfo>> =>
fromQueryToFirebaseDocumentInfo(await getAllCollectionDocs(firestore, collections.ceremonies)).sort(
(a: FirebaseDocumentInfo, b: FirebaseDocumentInfo) => a.data.sequencePosition - b.data.sequencePosition
)

5 changes: 3 additions & 2 deletions packages/phase2cli/src/lib/utils.ts
Original file line number Diff line number Diff line change
@@ -217,11 +217,12 @@ export const simpleLoader = async (

/**
* Return the ceremonies prefixes for every ceremony.
* @param firestore <Firestore> - the instance of the Firestore database.
* @returns Promise<Array<string>>
*/
export const getCreatedCeremoniesPrefixes = async (): Promise<Array<string>> => {
export const getCreatedCeremoniesPrefixes = async (firestore: Firestore): Promise<Array<string>> => {
// Get all ceremonies documents.
const ceremonies = await getAllCeremonies()
const ceremonies = await getAllCeremonies(firestore)

let ceremoniesPrefixes = []

0 comments on commit 38a16e6

Please sign in to comment.