Browse Source

fix: IDL gen byte string lit parsing (#2125)

Sammy Harris 3 years ago
parent
commit
3a0deba901
2 changed files with 12 additions and 1 deletions
  1. 4 0
      CHANGELOG.md
  2. 8 1
      lang/syn/src/idl/pda.rs

+ 4 - 0
CHANGELOG.md

@@ -16,6 +16,10 @@ The minor version will be incremented upon a breaking change and the patch versi
 * spl: Add `create_metadata_accounts_v3` and `set_collection_size` wrappers ([#2119](https://github.com/coral-xyz/anchor/pull/2119))
 * spl: Add `MetadataAccount` account deserialization. ([#2014](https://github.com/coral-xyz/anchor/pull/2014)).
 
+### Fixes
+
+* lang: Fix IDL `seed` generation for byte string literals. ([#2125](https://github.com/coral-xyz/anchor/pull/2125))
+
 ## [0.25.0] - 2022-07-05
 
 ### Features

+ 8 - 1
lang/syn/src/idl/pda.rs

@@ -5,7 +5,7 @@ use crate::ConstraintSeedsGroup;
 use crate::{AccountsStruct, Field};
 use std::collections::HashMap;
 use std::str::FromStr;
-use syn::Expr;
+use syn::{Expr, ExprLit, Lit};
 
 // Parses a seeds constraint, extracting the IdlSeed types.
 //
@@ -118,6 +118,13 @@ impl<'a> PdaParser<'a> {
                 println!("WARNING: auto pda derivation not currently supported for slice literals");
                 None
             }
+            Expr::Lit(ExprLit {
+                lit: Lit::ByteStr(lit_byte_str),
+                ..
+            }) => {
+                let seed_path: SeedPath = SeedPath(lit_byte_str.token().to_string(), Vec::new());
+                self.parse_str_literal(&seed_path)
+            }
             // Unknown type. Please file an issue.
             _ => {
                 println!("WARNING: unexpected seed: {:?}", seed);