Skip to content

Commit

Permalink
fix: tally result index collision
Browse files Browse the repository at this point in the history
  • Loading branch information
kittybest committed Jan 8, 2025
2 parents 1db3d75 + 75bbb21 commit c0e35af
Show file tree
Hide file tree
Showing 4 changed files with 879 additions and 778 deletions.
2 changes: 1 addition & 1 deletion packages/interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
"@types/snarkjs": "^0.7.8",
"@typescript-eslint/eslint-plugin": "^7.0.0",
"@typescript-eslint/parser": "^6.19.1",
"@vitejs/plugin-react": "^4.3.1",
"@vitejs/plugin-react": "^4.3.4",
"autoprefixer": "^10.4.17",
"decompress": "^4.2.1",
"eslint": "^8.57.0",
Expand Down
3 changes: 2 additions & 1 deletion packages/subgraph/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"generate:schema": "cp ./schemas/schema.${VERSION:-v1}.graphql schema.graphql",
"prebuild": "pnpm codegen",
"build": "graph build",
"deploy": "graph deploy --node https://api.studio.thegraph.com/deploy/ maci-subgraph",
"deploy-graph": "graph deploy --node https://api.studio.thegraph.com/deploy/ maci-subgraph",
"deploy-alchemy": "graph deploy maci-subgraph --node https://subgraphs.alchemy.com/api/subgraphs/deploy/ --deploy-key 6MbYFiUNNlyLL --ipfs https://ipfs.satsuma.xyz",

Check warning on line 22 in packages/subgraph/package.json

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"Nly" should be "Only".
"create-local": "graph create --node http://localhost:8020/ maci-subgraph",
"remove-local": "graph remove --node http://localhost:8020/ maci-subgraph",
"deploy-local": "graph deploy --node http://localhost:8020/ --ipfs http://localhost:5001 maci-subgraph --network localhost",
Expand Down
6 changes: 4 additions & 2 deletions packages/subgraph/src/utils/entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,12 @@ export const createOrLoadClaim = (index: GraphBN, recipient: Bytes, amount: Grap
};

export const createOrLoadTallyResult = (index: GraphBN, result: GraphBN, tally: Bytes): TallyResult => {
let tallyResult = TallyResult.load(index.toString());
// Create composite key by combining tally address and index
const compositeId = `${tally.toHexString()}-${index.toString()}`;
let tallyResult = TallyResult.load(compositeId);

if (!tallyResult) {
tallyResult = new TallyResult(index.toString());
tallyResult = new TallyResult(compositeId);
tallyResult.result = result;
tallyResult.tally = tally;
tallyResult.save();
Expand Down
Loading

0 comments on commit c0e35af

Please sign in to comment.