-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
base: master
Are you sure you want to change the base?
Conversation
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? |
@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? 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 will just inscribe this list myself and maintain it if I need to. |
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. |
084173c
to
4fd430d
Compare
@casey ok made the changes and added to the new docs. |
There was a problem hiding this 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 { |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest charms. | |
Latest charms. |
### 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> | ||
|
||
|
There was a problem hiding this comment.
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.
### 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": "🔥"
}
let charms_response = | ||
server.get_json::<serde_json::Map<String, serde_json::Value>>("/r/charms"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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"); |
There was a problem hiding this comment.
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.
Any update on this? |
Returns the currently supported charms and their associated names.
Allows inscriptions to have forwards compatibility with any new charms added.