Skip to content

Commit 5b8186f

Browse files
authored
Add support to Anchor idl build for account types (#54)
* Add support to anchor idl-build feature * Add changeset * Update cargo lock file
1 parent e3e4099 commit 5b8186f

File tree

7 files changed

+153
-6
lines changed

7 files changed

+153
-6
lines changed

.changeset/proud-mugs-thank.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@kinobi-so/renderers-rust': patch
3+
---
4+
5+
Add support to Anchor idl build for account types

packages/renderers-rust/e2e/memo/Cargo.lock

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

packages/renderers-rust/e2e/memo/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[features]
77
anchor = ["dep:anchor-lang"]
8+
anchor-idl-build = ["anchor", "anchor-lang?/idl-build"]
89
serde = ["dep:serde", "dep:serde_with"]
910
test-sbf = []
1011

packages/renderers-rust/e2e/system/Cargo.lock

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

packages/renderers-rust/e2e/system/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ edition = "2021"
55

66
[features]
77
anchor = ["dep:anchor-lang"]
8+
anchor-idl-build = ["anchor", "anchor-lang?/idl-build"]
89
serde = ["dep:serde", "dep:serde_with"]
910
test-sbf = []
1011

packages/renderers-rust/e2e/system/src/generated/accounts/nonce.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,11 @@ impl anchor_lang::Owner for Nonce {
6666
crate::SYSTEM_ID
6767
}
6868
}
69+
70+
#[cfg(feature = "anchor-idl-build")]
71+
impl anchor_lang::IdlBuild for Nonce {}
72+
73+
#[cfg(feature = "anchor-idl-build")]
74+
impl anchor_lang::Discriminator for Nonce {
75+
const DISCRIMINATOR: [u8; 8] = [0; 8];
76+
}

packages/renderers-rust/public/templates/accountsPage.njk

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,16 @@ impl anchor_lang::Owner for {{ account.name | pascalCase }} {
145145
}
146146
}
147147

148+
#[cfg(feature = "anchor-idl-build")]
149+
impl anchor_lang::IdlBuild for {{ account.name | pascalCase }} {}
150+
151+
{#
152+
This is not used for the IDL generation since default `IdlBuild` impl doesn't include
153+
the type in the IDL but it stil needs to be added in order to make compilation work.
154+
#}
155+
#[cfg(feature = "anchor-idl-build")]
156+
impl anchor_lang::Discriminator for {{ account.name | pascalCase }} {
157+
const DISCRIMINATOR: [u8; 8] = [0; 8];
158+
}
159+
148160
{% endblock %}

0 commit comments

Comments
 (0)