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

Charms info recursive /r/charms #3986

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

elocremarc
Copy link
Contributor

Returns the currently supported charms and their associated names.
Allows inscriptions to have forwards compatibility with any new charms added.

@casey
Copy link
Collaborator

casey commented Oct 20, 2024

I think I understand the purpose of this PR, if we add charms, old inscriptions can still associate an emoji with new charms. However, I'm not sure I can actually think of way in which this would be useful. Can you give an example?

@elocremarc
Copy link
Contributor Author

@casey This is for a light ordinals explorer/viewer to traverse the family tree of an inscription. When you display the /r/inscription information you get the emojis but have to hardcode the updates.

Another option what if ord did some light onchain libraries in leu of recursive endpoints?
This endpoint will have to be static anyway why not just do this onchain?

If this list changes ord could just reinscribe the new library sat. Then everyone can just subscribe to that sat get the new list. Then we don't need another endpoint.

Other useful stuff in a library you guys could inscribe. Could be converting between sat notation or other sat tools. We made the sat endpoint not take notation for simplicity but it would be nice to be able have a little library to use these notations onchain. People might not implement it correct etc...

TBH I am kinda on the fence on if this PR is worth doing a recursive endpoint for.
I see both sides haha.

I will just inscribe this list myself and maintain it if I need to.

@casey
Copy link
Collaborator

casey commented Oct 22, 2024

I think this is kind of reasonable, I don't hate it. The maps seems backwards to me though, it should map charm name to current emoji.

@elocremarc
Copy link
Contributor Author

@casey ok made the changes and added to the new docs.

@raphjaph raphjaph requested a review from casey October 26, 2024 15:15
Copy link
Collaborator

@casey casey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, see comments!

@@ -1742,6 +1743,17 @@ impl Server {
})
}

async fn charms() -> ServerResult {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be:

  async fn charms() -> ServerResult<Json<BTreeMap<Charm, &'static str>>> {

charm implements serialize by delegating to Display, which is what is used in to_string.

</summary>

### Description
Latest charms.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Latest charms.
Latest charms.

Comment on lines +237 to +261
### Example
```bash
curl -s \
http://0.0.0.0:80/r/charms
```
```json
{
"coin": "🪙",
"uncommon": "🌱",
"rare": "🧿",
"epic": "🪻",
"legendary": "🌝",
"mythic": "🎃",
"nineball": "9️⃣",
"reinscription": "♻️",
"cursed": "👹",
"unbound": "🔓",
"lost": "🤔",
"vindicated": "❤️‍🔥",
"burned": "🔥"
}
```
</details>


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why we use -s and -H "Accept: application/json" for our curl examples. I don't think any of the recursive endpoints require the Accept header, and the -s will only suppress errors, which isn't useful.

Suggested change
### Example
```bash
curl -s \
http://0.0.0.0:80/r/charms
```
```json
{
"coin": "🪙",
"uncommon": "🌱",
"rare": "🧿",
"epic": "🪻",
"legendary": "🌝",
"mythic": "🎃",
"nineball": "9️⃣",
"reinscription": "♻️",
"cursed": "👹",
"unbound": "🔓",
"lost": "🤔",
"vindicated": "❤️‍🔥",
"burned": "🔥"
}
```
</details>
### Example
```bash
curl http://0.0.0.0:80/r/charms
{
  "coin": "🪙",
  "uncommon": "🌱",
  "rare": "🧿",
  "epic": "🪻",
  "legendary": "🌝",
  "mythic": "🎃",
  "nineball": "9️⃣",
  "reinscription": "♻️",
  "cursed": "👹",
  "unbound": "🔓",
  "lost": "🤔",
  "vindicated": "❤️‍🔥",
  "burned": "🔥"
}
```

Comment on lines +6256 to +6257
let charms_response =
server.get_json::<serde_json::Map<String, serde_json::Value>>("/r/charms");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
let charms_response =
server.get_json::<serde_json::Map<String, serde_json::Value>>("/r/charms");
let charms_response =
server.get_json::<BTreeMap<String, String>>("/r/charms");

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And then assert_eq against a BTreeMap built from the actual charms.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready for Review
Development

Successfully merging this pull request may close these issues.

2 participants