Skip to content

Commit

Permalink
add initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
samuelvanderwaal committed Oct 21, 2021
0 parents commit 6a24d52
Show file tree
Hide file tree
Showing 7 changed files with 314 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/binaries
176 changes: 176 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "wtf-is"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
phf = { version = "0.10", features = ["macros"] }
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# WTF Is

I was tired of looking up Metaplex Token Metadata program errors.

```bash
wtf-is <hex_code_no_prefix>
```

Example:

```bash
$ wtf-is 37
> 0x37: CannotUnverifyAnotherCreator: You cannot unilaterally unverify another creator
```

6 changes: 6 additions & 0 deletions build-linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name=$(awk -F'[ ="]+' '$1 == "name" { print $2 }' Cargo.toml)
version=$(awk -F'[ ="]+' '$1 == "version" { print $2 }' Cargo.toml)
cargo build --release
cp ./target/release/$name ./binaries/$name-$version-x86_64-unknown-linux-gnu
cargo build --release --target x86_64-unknown-linux-musl
cp ./target/x86_64-unknown-linux-musl/release/$name ./binaries/$name-$version-x86_64-unknown-linux-musl
77 changes: 77 additions & 0 deletions src/errors.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
use phf::phf_map;

pub static ERRORS: phf::Map<&'static str, &'static str> = phf_map! {
"0" => "InstructionUnpackError: Failed to unpack instruction data",
"1" => "InstructionPackError: Failed to pack instruction data",
"2" => "NotRentExempt: Lamport balance below rent-exempt threshold",
"3" => "AlreadyInitialized: Already initialized",
"4" => "Uninitialized: Uninitialized",
"5" => "InvalidMetadataKey: Metadata's key must match seed of ['metadata', program id, mint] provided",
"6" => "InvalidEditionKey: Edition's key must match seed of ['metadata', program id, name, 'edition'] provided",
"7" => "UpdateAuthorityIncorrect: Update Authority given does not match",
"8" => "UpdateAuthorityIsNotSigner: Update Authority needs to be signer to update metadata",
"9" => "NotMintAuthority: You must be the mint authority and signer on this transaction",
"A" => "InvalidMintAuthority: Mint authority provided does not match the authority on the mint",
"B" => "NameTooLong: Name too long",
"C" => "SymbolTooLong: Symbol too long",
"D" => "UriTooLong: URI too long",
"E" => "UpdateAuthorityMustBeEqualToMetadataAuthorityAndSigner: Update authority must be equivalent to the metadata's authority and also signer of this transaction",
"F" => "MintMismatch: Mint given does not match mint on Metadata",
"10" => "EditionsMustHaveExactlyOneToken: Editions must have exactly one token",
"11" => "MaxEditionsMintedAlready: Maximum editions printed already",
"12" => "TokenMintToFailed: Token mint to failed",
"13" => "MasterRecordMismatch: The master edition record passed must match the master record on the edition given",
"14" => "DestinationMintMismatch: The destination account does not have the right mint",
"15" => "EditionAlreadyMinted: An edition can only mint one of its kind!",
"16" => "PrintingMintDecimalsShouldBeZero: Printing mint decimals should be zero",
"17" => "OneTimePrintingAuthorizationMintDecimalsShouldBeZero: OneTimePrintingAuthorization mint decimals should be zero",
"18" => "EditionMintDecimalsShouldBeZero: EditionMintDecimalsShouldBeZero",
"19" => "TokenBurnFailed: Token burn failed",
"1A" => "TokenAccountOneTimeAuthMintMismatch: The One Time authorization mint does not match that on the token account!",
"1B" => "DerivedKeyInvalid: Derived key invalid",
"1C" => "PrintingMintMismatch: The Printing mint does not match that on the master edition!",
"1D" => "OneTimePrintingAuthMintMismatch: The One Time Printing Auth mint does not match that on the master edition!",
"1E" => "TokenAccountMintMismatch: The mint of the token account does not match the Printing mint!",
"1F" => "TokenAccountMintMismatchV2: The mint of the token account does not match the master metadata mint!",
"20" => "NotEnoughTokens: Not enough tokens to mint a limited edition",
"21" => "PrintingMintAuthorizationAccountMismatch: The mint on your authorization token holding account does not match your Printing mint!",
"22" => "AuthorizationTokenAccountOwnerMismatch: The authorization token account has a different owner than the update authority for the master edition!",
"23" => "Disabled: This feature is currently disabled.",
"24" => "CreatorsTooLong: Creators list too long",
"25" => "CreatorsMustBeAtleastOne: Creators must be at least one if set",
"26" => "MustBeOneOfCreators: If using a creators array, you must be one of the creators listed",
"27" => "NoCreatorsPresentOnMetadata: This metadata does not have creators",
"28" => "CreatorNotFound: This creator address was not found",
"29" => "InvalidBasisPoints: Basis points cannot be more than 10000",
"2A" => "PrimarySaleCanOnlyBeFlippedToTrue: Primary sale can only be flipped to true and is immutable",
"2B" => "OwnerMismatch: Owner does not match that on the account given",
"2C" => "NoBalanceInAccountForAuthorization: This account has no tokens to be used for authorization",
"2D" => "ShareTotalMustBe100: Share total must equal 100 for creator array",
"2E" => "ReservationExists: This reservation list already exists!",
"2F" => "ReservationDoesNotExist: This reservation list does not exist!",
"30" => "ReservationNotSet: This reservation list exists but was never set with reservations",
"31" => "ReservationAlreadyMade: This reservation list has already been set!",
"32" => "BeyondMaxAddressSize: Provided more addresses than max allowed in single reservation",
"33" => "NumericalOverflowError: NumericalOverflowError",
"34" => "ReservationBreachesMaximumSupply: This reservation would go beyond the maximum supply of the master edition!",
"35" => "AddressNotInReservation: Address not in reservation!",
"36" => "CannotVerifyAnotherCreator: You cannot unilaterally verify another creator, they must sign",
"37" => "CannotUnverifyAnotherCreator: You cannot unilaterally unverify another creator",
"38" => "SpotMismatch: In initial reservation setting, spots remaining should equal total spots",
"39" => "IncorrectOwner: Incorrect account owner",
"3A" => "PrintingWouldBreachMaximumSupply: printing these tokens would breach the maximum supply limit of the master edition",
"3B" => "DataIsImmutable: Data is immutable",
"3C" => "DuplicateCreatorAddress: No duplicate creator addresses",
"3D" => "ReservationSpotsRemainingShouldMatchTotalSpotsAtStart: Reservation spots remaining should match total spots when first being created",
"3E" => "InvalidTokenProgram: Invalid token program",
"3F" => "DataTypeMismatch: Data type mismatch",
"40" => "BeyondAlottedAddressSize: Beyond alotted address size in reservation!",
"41" => "ReservationNotComplete: The reservation has only been partially alotted",
"42" => "TriedToReplaceAnExistingReservation: You cannot splice over an existing reservation!",
"43" => "InvalidOperation: Invalid operation",
"44" => "InvalidOwner: Invalid Owner",
"45" => "PrintingMintSupplyMustBeZeroForConversion: Printing mint supply must be zero for conversion",
"46" => "OneTimeAuthMintSupplyMustBeZeroForConversion: One Time Auth mint supply must be zero for conversion",
"47" => "InvalidEditionIndex: You tried to insert one edition too many into an edition mark pda",
"48" => "ReservationArrayShouldBeSizeOne: In the legacy system the reservation needs to be of size one for cpu limit reasons",
};
29 changes: 29 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use std::env::args;

mod errors;

fn main() {
let hex_code = args().skip(1).next();

match hex_code {
Some(code) => {
let code = code.to_uppercase();
let message = parse(&code);
println!("0x{}: {}", code, message);
}
None => {
println!("No hex code provided!");
std::process::exit(1);
}
}
}

pub fn parse(hex_code: &str) -> &str {
match errors::ERRORS.get(hex_code).cloned() {
Some(e) => return e,
None => {
println!("No match found for that code!");
std::process::exit(1);
}
}
}

0 comments on commit 6a24d52

Please sign in to comment.