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

token-2022: Show all extensions #315

Merged
merged 36 commits into from
Jan 23, 2024

Conversation

joncinque
Copy link
Collaborator

Problem

Although the explorer has some support of token-2022, it doesn't show any mint or account extensions, which leads to a lot of confusion for people who create mints.

Solution

Everything is provided with JSON-parsed encoding, so:

  • create types for all of the JSON-parsed returns
  • show each extension

For the most part, each commit corresponds to an extension, except otherwise noted. I wasn't sure about the best way to display all of these, especially those with many fields, so I went with a little header line before showing each field. Let me know what you think of that.

Here are some screenshots of a mint with every extension (minus token group, group member, group pointer, and member pointer):

image

image

image

And an account with all extensions:

image

image

And in case you care, here's how you can create your own mega-token:

set -ex
solana-keygen -o mint.json --no-passphrase
mint=$(solana-keygen pubkey mint.json)
solana-keygen -o source.json --no-passphrase
source_pubkey=$(solana-keygen pubkey source.json)
spl-token -ul \
  create-token \
  --enable-close \
  --enable-freeze \
  --enable-metadata \
  --enable-non-transferable \
  --enable-permanent-delegate \
  --enable-confidential-transfers auto \
  --default-account-state initialized \
  --interest-rate 5 \
  --transfer-fee 10 11 \
  --transfer-hook $mint \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
  mint.json
spl-token -ul initialize-metadata $mint MegaToken MT https://spl.solana.com/token-2022
spl-token -ul update-metadata $mint Mega Token

spl-token -ul create-account --immutable $mint source.json
spl-token -ul enable-required-transfer-memos "$source_pubkey"
spl-token -ul enable-cpi-guard "$source_pubkey"
spl-token -ul configure-confidential-transfer-account --address "$source_pubkey"

@joncinque joncinque requested a review from mcintyre94 January 19, 2024 22:48
Copy link

vercel bot commented Jan 19, 2024

@joncinque is attempting to deploy a commit to the Solana Labs Team on Vercel.

A member of the Team first needs to authorize it.

@luke-truitt
Copy link

luke-truitt commented Jan 19, 2024

wen merge

Copy link

vercel bot commented Jan 22, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 23, 2024 9:58am

Copy link
Collaborator

@mcintyre94 mcintyre94 left a comment

Choose a reason for hiding this comment

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

Looks good!

I think longer term we might want to change how these are displayed because I think this is pushing the limits of the table really. Maybe an extensions tab or something?

I don't think any of my comments are blockers, they're mostly just nitpicks about how we're displaying certain values

I would flag the 'Additional Metadata' though because I think there's a real risk there of malicious tokens abusing it. Maybe the easiest fix for now is to make metadata the last extension displayed, and add a header above Additional Metadata?

@mcintyre94 mcintyre94 merged commit 248801a into solana-foundation:master Jan 23, 2024
4 checks passed
@joncinque joncinque deleted the tk22exts branch January 23, 2024 11:25
steveluscher pushed a commit that referenced this pull request Mar 8, 2024
#### Problem

Although the explorer has some support of token-2022, it doesn't show
any mint or account extensions, which leads to a lot of confusion for
people who create mints.

#### Solution

Everything is provided with JSON-parsed encoding, so:

* create types for all of the JSON-parsed returns
* show each extension

For the most part, each commit corresponds to an extension, except
otherwise noted. I wasn't sure about the best way to display all of
these, especially those with many fields, so I went with a little header
line before showing each field. Let me know what you think of that.

Here are some screenshots of a mint with every extension (minus token
group, group member, group pointer, and member pointer):


![image](https://github.com/solana-labs/explorer/assets/934662/7a1e46b5-acb7-49c4-ac50-5a1e647197c3)


![image](https://github.com/solana-labs/explorer/assets/934662/b5a4fb6f-1de1-4708-892f-dc7a2dd1feb2)


![image](https://github.com/solana-labs/explorer/assets/934662/b956f391-3665-4e57-9ba3-4a7a2e69afc1)

And an account with all extensions:


![image](https://github.com/solana-labs/explorer/assets/934662/62d738ec-1aa8-4d14-b41e-acd462e9020e)


![image](https://github.com/solana-labs/explorer/assets/934662/9967e50e-5bd4-43a3-947c-c79ee112d920)

And in case you care, here's how you can create your own mega-token:

```
set -ex
solana-keygen -o mint.json --no-passphrase
mint=$(solana-keygen pubkey mint.json)
solana-keygen -o source.json --no-passphrase
source_pubkey=$(solana-keygen pubkey source.json)
spl-token -ul \
  create-token \
  --enable-close \
  --enable-freeze \
  --enable-metadata \
  --enable-non-transferable \
  --enable-permanent-delegate \
  --enable-confidential-transfers auto \
  --default-account-state initialized \
  --interest-rate 5 \
  --transfer-fee 10 11 \
  --transfer-hook $mint \
  --program-id TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb \
  mint.json
spl-token -ul initialize-metadata $mint MegaToken MT https://spl.solana.com/token-2022
spl-token -ul update-metadata $mint Mega Token

spl-token -ul create-account --immutable $mint source.json
spl-token -ul enable-required-transfer-memos "$source_pubkey"
spl-token -ul enable-cpi-guard "$source_pubkey"
spl-token -ul configure-confidential-transfer-account --address "$source_pubkey"
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants