-
Notifications
You must be signed in to change notification settings - Fork 464
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
Create new endpoint for stamp meta data #1235
Create new endpoint for stamp meta data #1235
Comments
@Jeremy-Gitcoin ok, this issue makes sense. |
@nutrina and I discussed this a bit. We're going to try building the static platform info into a JSON file and serving it out of the /public folder of the Passport repo. Then we'll provide a scorer API endpoint that fetches, ideally caches, and returns this metadata with an indication of whether a particular address has a stamp or not. @erichfi The suggested response data doesn't quite line up with our data structure, since we have multiple stamps per platform. I'm assuming we'll return all this data--icon, platform, description, connectMessage--once per platform, and then include a stamps array. Something like
Let me know if you're looking for something different! |
@erichfi We discussed this further in our engineering meeting. We're thinking we'll do the following: On the existing
We'll also add an endpoint at
We figure that devs can get data for their UI by either 1. using includeMetadata with the /stamps/{address} endpoint, if they only care about the stamps that a use has or 2. using the data at /stamp-metadata, potentially combining it with the existing data at the /stamps/{address} endpoint, if they want to show info for all possible stamps. Let me know what you think! |
I've tested this in Postman on review, there's nothing in the UI to review. If we want to solicit feedback on the format of the response for /stamp-metadata and /stamp/address (when include_metadata=true), that's available in the docs here https://api.review.scorer.gitcoin.co/docs |
All of this looks good and definitely works in the way we discussed. One note, which is just something for y'all to consider: We're structuring the response as an array of objects, which is typical for APIs but does require an added, annoying step for anyone integration: nested looping. For someone using this metadata to display stamp data in their UI, they're going to first get the list of stamps for a given address (using // stamps is the `items` array in the response from /registry/stamps/{address}
function renderStamps({ stamps }) {
return stamps.map(stamp => {
<p>{stamp.credential.provider}</p>
})
} Now, to actually use the metadata here, I have to separately loop through the entire metadata response to find the object for the current stamp, for every single stamp an address holds (i.e. nested loop): // stamps is the `items` array in the response from /registry/stamps/{address}
function renderStamps({ stamps }) {
return stamps.map(function(stamp) {
let provider = stamp.credential.provider
// metadata is the array of objects returned by /registry/stamp-metadata
// This is the loop (.find()) inside the loop (.map())
let stampData = metadata.find(metadatum => metadatum.id === provider)
return (
<div>
<h3>{stampData.name}</h3>
<p>{stampData.description}</p>
</div>
)
})
} It's maybe not a huge deal, but if we structured the response as an object where the key is the // stamps is the `items` array in the response from /registry/stamps/{address}
function renderStamps({ stamps }) {
return stamps.map(stamp => {
<div>
<h3>{metadata[stamp.credential.provider].name}</h3>
<p>{metadata[stamp.credential.provider].description}</p>
</div>
})
} |
Hey @0xZakk! Thanks so much for taking a look at this and experimenting with it! I figured consumers of this data would either:
Doing anything more complex than either of those base use-cases requires some sort of messing with the data from one or both of these endpoints to get what you want. It's sort of weird because we're reporting stamps, but the metadata is mostly about the platforms and groups of the stamps. In other words, in your last example, if you care about showing e.g. 1 card per platform, you'd have to collate those stamps by platform (and maybe group, e.g. the "Transactions" group in the ETH platform). It's not super straight forward because of the nested data structure of our stamps. Does that make sense? We could still make /stamp-metadata return an object, then people could just Object.values() it if they just want the list like we have now. That would likely make it easier on some integrators. But I wanted to make sure we're aligned on the rest of this! |
ah okay! That's great. I don't think I knew about |
Yeah! It's in the docs under the same old /stamps/{address} endpoint https://api.staging.scorer.gitcoin.co/docs#/Score%20your%20passport/registry_api_v1_get_passport_stamps |
@0xZakk I went ahead and released this, but I've marked it as beta in the docs. Do you think the requests/responses for Let me know if you want any changes! Do you still think we should switch it over to be an object instead of a list? |
@lucianHymer thank you for checking! I think this is great |
User Story:
As a developer / integratooor
I want to be able to display the passport stamps a user
So that I can include the stamps within my own dApp such as a user profile
Acceptance Criteria
GIVEN I query a new API endpoint - /registry/stamp-display/{address}
WHEN a wallet has a set of stamps
THEN I receive all stamp metadata to display the stamp including whether the user has the stamp or not
Return the following Meta data by stamp (basically everything in PLATFORMS: PlatformSpec[])
And
Product & Design Links:
Tech Details:
This should be future proof to include new data when we add/update the stamp data
Open Questions:
Notes/Assumptions:
From Dennison @ Tally (via Telegram)
Basically, if we return a users Stamps, we would love all the metadata of the stamp: Avatar, information about it, callback url, etc…
Because otherwise it’s not really possible for us to show a list of stamps, because we don’t have any context to show the user what they are.
Also t would be nice to be able to show which stamps the user DOES NOT have.
This also relates to #1124
The text was updated successfully, but these errors were encountered: