Skip to content

Commit faba10f

Browse files
committed
Add CodamaPdaHelpers derive
1 parent 1b5ef07 commit faba10f

23 files changed

+1111
-1
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/target
2+
.idea

Cargo.lock

Lines changed: 202 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

codama-macros/Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,19 @@ name = "tests"
1414
path = "tests/mod.rs"
1515

1616
[dev-dependencies]
17+
solana-address = { version = "2.4.0", features = ["curve25519"] }
1718
trybuild = { version = "1.0.49", features = ["diff"] }
1819

1920
[target.'cfg(not(target_os = "solana"))'.dependencies]
2021
codama-attributes = { version = "0.8.0", path = "../codama-attributes" }
2122
codama-errors = { version = "0.8.0", path = "../codama-errors" }
2223
codama-koroks = { version = "0.8.0", path = "../codama-koroks" }
24+
codama-nodes = { version = "0.8.0", path = "../codama-nodes" }
2325
codama-stores = { version = "0.8.0", path = "../codama-stores" }
26+
codama-syn-helpers = { version = "0.8.0", path = "../codama-syn-helpers" }
2427
proc-macro2 = "1.0"
2528
quote = "1.0"
26-
syn = { version = "2.0", features = ["extra-traits"] }
29+
syn = { version = "2.0", features = ["extra-traits", "full"] }
2730

2831
[lints.rust]
2932
unexpected_cfgs = { level = "warn", check-cfg = [

codama-macros/src/lib.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ use proc_macro::TokenStream;
33
mod attributes;
44
#[cfg(not(target_os = "solana"))]
55
mod derives;
6+
#[cfg(not(target_os = "solana"))]
7+
mod pda_helpers;
68

79
fn codama_derive(input: TokenStream) -> TokenStream {
810
#[cfg(not(target_os = "solana"))]
@@ -57,6 +59,20 @@ pub fn codama_pda_derive(input: TokenStream) -> TokenStream {
5759
codama_derive(input)
5860
}
5961

62+
#[proc_macro_derive(CodamaPdaHelpers, attributes(codama))]
63+
pub fn codama_pda_helpers_derive(input: TokenStream) -> TokenStream {
64+
#[cfg(not(target_os = "solana"))]
65+
{
66+
pda_helpers::codama_pda_helpers_derive_impl(input.into())
67+
.unwrap_or_else(codama_errors::CodamaError::into_compile_error)
68+
.into()
69+
}
70+
#[cfg(target_os = "solana")]
71+
{
72+
input
73+
}
74+
}
75+
6076
#[proc_macro_derive(CodamaType, attributes(codama))]
6177
pub fn codama_type_derive(input: TokenStream) -> TokenStream {
6278
codama_derive(input)

0 commit comments

Comments
 (0)