Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dashboard: List on-chain groups starting from the most recently created #433

Closed
aguzmant103 opened this issue Mar 7, 2024 · 11 comments
Closed
Assignees
Labels
good first issue Good for newcomers refactoring ♻️ A code change that neither fixes a bug nor adds a feature

Comments

@aguzmant103
Copy link
Collaborator

More context:
#344

@aguzmant103 aguzmant103 converted this from a draft issue Mar 7, 2024
@aguzmant103 aguzmant103 added the good first issue Good for newcomers label Mar 7, 2024
@aguzmant103 aguzmant103 moved this to 📋 Backlog in Bandada Board Mar 7, 2024
@aguzmant103 aguzmant103 added the refactoring ♻️ A code change that neither fixes a bug nor adds a feature label Mar 7, 2024
@vplasencia vplasencia moved this to 📋 Backlog in Bandada Board Mar 17, 2024
@waddaboo
Copy link
Collaborator

Hi, I would like to take on this issue :)

@vplasencia
Copy link
Member

Hey @waddaboo! Great, thanks. Do you want me to assign you this issue?

@waddaboo
Copy link
Collaborator

Yes, please. I have completed it, just that currently I'm unable to setup my local api key to test it out.

@vplasencia
Copy link
Member

Hey @waddaboo great, thanks. What is the error you are getting?

@waddaboo
Copy link
Collaborator

waddaboo commented Apr 24, 2024

I have been trying to sign in to my local bandada with Coinbase Wallet but it didn't prompt the QR code for most of the time, and even for the times that it did, it always ends with "error signing message".

@vplasencia
Copy link
Member

Hey @waddaboo

It looks like connecting with Coinbase Wallet is not working properly. Sorry about that. Here is the issue: #487

Can you try with Metamask?

@waddaboo
Copy link
Collaborator

It looks like connecting with Coinbase Wallet is not working properly. Sorry about that. Here is the issue: #487

Managed to login in bandada.pse.dev, but only on mobile. Thought it was error on my machine haha.

Can you try with Metamask?

Tried Metamask but nothing popup after clicking as well.

@waddaboo
Copy link
Collaborator

Hey @vplasencia, I found out in order for on-chain groups to sort by most recent created, some changes must be made at @semaphore-protocol/data, specifically here at getGroups so that it can return the timestamp for sorting use.

const config: AxiosRequestConfig = {
    method: "post",
    data: JSON.stringify({
        query: `{
            groups ${filtersQuery} {
                id
                merkleTree {
                    root
                    depth
                    size
                }
                admin
                ${
                    members === true
                        ? `members(orderBy: index) {
                    identityCommitment
                }`
                        : ""
                }
                ${
                    validatedProofs === true
                        ? `validatedProofs(orderBy: timestamp) {
                    message
                    merkleTreeRoot
                    merkleTreeDepth
                    scope
                    nullifier
                    points
                    timestamp
                }`
                        : ""
                }
            }
        }`
    })
}

Any suggestion on how should this proceed?

@vplasencia
Copy link
Member

Hey @waddaboo! There are some ways to solve this without modifying the Semaphore package. Here are two options:

1- Recreate the same that function is doing under the hood. This way you have full control of the code and can modify what you want.

2- Run yarn patch @semaphore-protocol/data and then go to the files specified in the console log and modify the files, then run what appears in the console log to save the changes.

The change would be adding:

orderBy:timestamp, orderDirection:desc

After running the second command to save the changes, you should see a new file inside the .yarn/patches folder with @semaphore-protocol/data as part of the name. That file would have the changes.

Let us know if you have more questions.

@vplasencia
Copy link
Member

vplasencia commented Apr 29, 2024

The 2nd idea should be faster. Steps:

1- Go inside apps/dashboard cd apps/dashboard and run yarn patch @semaphore-protocol/data

2- Open the folder linked in the console.

You can now edit the following folder: ...

3- Modify the files:

  • dist/index.mjs line 1140:
filtersQuery = "(orderBy:timestamp, orderDirection:desc, where: {".concat(filterFragments.join(", "), "})");
  • dist/index.node.js line 1148:
filtersQuery = "(orderBy:timestamp, orderDirection:desc, where: {".concat(filterFragments.join(", "), "})");

4- Save changes by running the command specified in the console:

yarn patch-commit -s ...

You will see a new file inside .yarn/patches with @semaphore-protocol/data as part of the name. The file should contain something like:

diff --git a/dist/index.mjs b/dist/index.mjs
index 614a9093f82e9ae8e9219b65af0a8e93ea992560..2e432b004bd8718bb16c84ef7c53cdda14808ef5 100644
--- a/dist/index.mjs
+++ b/dist/index.mjs
@@ -1137,7 +1137,7 @@ var SemaphoreSubgraph = /** @class */ (function () {
                                 filterFragments.push("timestamp_lte: \"".concat(jsDateToGraphqlDate(timestampLte), "\""));
                             }
                             if (filterFragments.length > 0) {
-                                filtersQuery = "(where: {".concat(filterFragments.join(", "), "})");
+                                filtersQuery = "(orderBy:timestamp, orderDirection:desc, where: {".concat(filterFragments.join(", "), "})");
                             }
                         }
                         config = {
diff --git a/dist/index.node.js b/dist/index.node.js
index 29640ebef31511af5ee5ff7e970c74e1fa0bc98e..6ae2e5f15d47f1be7b90cd347adfd3b35d1ce7e8 100644
--- a/dist/index.node.js
+++ b/dist/index.node.js
@@ -1145,7 +1145,7 @@ var SemaphoreSubgraph = /** @class */ (function () {
                                 filterFragments.push("timestamp_lte: \"".concat(jsDateToGraphqlDate(timestampLte), "\""));
                             }
                             if (filterFragments.length > 0) {
-                                filtersQuery = "(where: {".concat(filterFragments.join(", "), "})");
+                                filtersQuery = "(orderBy:timestamp, orderDirection:desc, where: {".concat(filterFragments.join(", "), "})");
                             }
                         }
                         config = {

5- Inside the bandada project, in the root project folder, run yarn.

@waddaboo
Copy link
Collaborator

waddaboo commented Apr 29, 2024

Hey @vplasencia thanks for the detailed step-by-step guide! It's very helpful!

@github-project-automation github-project-automation bot moved this from 📋 Backlog to ✅ Done in Bandada Board Apr 30, 2024
@0xjei 0xjei moved this from 📋 Backlog to ✅ Done in Bandada Board May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers refactoring ♻️ A code change that neither fixes a bug nor adds a feature
Projects
Status: ✅ Done
Development

No branches or pull requests

3 participants