Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions codama-attributes/src/codama_directives/account_directive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ use crate::{
};
use codama_errors::{CodamaError, CodamaResult};
use codama_nodes::{
CamelCaseString, Docs, InstructionAccountNode, InstructionInputValueNode, IsAccountSigner,
CamelCaseString, Docs, InstructionAccountNode, InstructionInputValueNode, IsSigner,
};
use codama_syn_helpers::{extensions::*, Meta};

#[derive(Debug, PartialEq)]
pub struct AccountDirective {
pub name: CamelCaseString,
pub is_writable: bool,
pub is_signer: IsAccountSigner,
pub is_signer: IsSigner,
pub is_optional: bool,
pub docs: Docs,
pub default_value: Option<Resolvable<InstructionInputValueNode>>,
Expand All @@ -29,7 +29,7 @@ impl AccountDirective {
name = name.initial_value(ident.to_string().into())
}
let mut is_writable = SetOnce::<bool>::new("writable").initial_value(false);
let mut is_signer = SetOnce::<IsAccountSigner>::new("signer").initial_value(false.into());
let mut is_signer = SetOnce::<IsSigner>::new("signer").initial_value(false.into());
let mut is_optional = SetOnce::<bool>::new("optional").initial_value(false);
let mut default_value =
SetOnce::<Resolvable<InstructionInputValueNode>>::new("default_value");
Expand All @@ -41,7 +41,7 @@ impl AccountDirective {
.each(|ref meta| match meta.path_str().as_str() {
"name" => name.set(meta.as_value()?.as_expr()?.as_string()?.into(), meta),
"writable" => is_writable.set(bool::from_meta(meta)?, meta),
"signer" => is_signer.set(IsAccountSigner::from_meta(meta)?, meta),
"signer" => is_signer.set(IsSigner::from_meta(meta)?, meta),
"optional" => is_optional.set(bool::from_meta(meta)?, meta),
"default_value" => default_value.set(
Resolvable::<InstructionInputValueNode>::from_meta(meta.as_value()?)?,
Expand Down Expand Up @@ -117,7 +117,7 @@ mod tests {
AccountDirective {
name: "payer".into(),
is_writable: true,
is_signer: IsAccountSigner::True,
is_signer: IsSigner::True,
is_optional: true,
default_value: Some(Resolvable::Resolved(PayerValueNode::new().into())),
docs: Docs::default(),
Expand All @@ -142,7 +142,7 @@ mod tests {
AccountDirective {
name: "payer".into(),
is_writable: true,
is_signer: IsAccountSigner::Either,
is_signer: IsSigner::Either,
is_optional: false,
default_value: Some(Resolvable::Resolved(PayerValueNode::new().into())),
docs: Docs::default(),
Expand All @@ -161,7 +161,7 @@ mod tests {
AccountDirective {
name: "authority".into(),
is_writable: false,
is_signer: IsAccountSigner::False,
is_signer: IsSigner::False,
is_optional: false,
default_value: None,
docs: Docs::default(),
Expand Down Expand Up @@ -189,7 +189,7 @@ mod tests {
AccountDirective {
name: "stake".into(),
is_writable: true,
is_signer: IsAccountSigner::False,
is_signer: IsSigner::False,
is_optional: false,
default_value: None,
docs: vec!["what this account is for".to_string()].into(),
Expand All @@ -208,7 +208,7 @@ mod tests {
AccountDirective {
name: "authority".into(),
is_writable: false,
is_signer: IsAccountSigner::True,
is_signer: IsSigner::True,
is_optional: false,
default_value: None,
docs: vec![
Expand Down
4 changes: 2 additions & 2 deletions codama-attributes/src/utils/from_meta.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use codama_nodes::{BytesEncoding, Docs, IsAccountSigner, OptionalAccountStrategy};
use codama_nodes::{BytesEncoding, Docs, IsSigner, OptionalAccountStrategy};
use codama_syn_helpers::{extensions::*, Meta};
use syn::Expr;

Expand All @@ -20,7 +20,7 @@ impl FromMeta for bool {
}
}

impl FromMeta for IsAccountSigner {
impl FromMeta for IsSigner {
fn from_meta(meta: &Meta) -> syn::Result<Self> {
if let Ok(value) = bool::from_meta(meta) {
return Ok(value.into());
Expand Down
6 changes: 6 additions & 0 deletions codama-nodes/src/generated/shared/is_signer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum IsSigner {
True,
False,
Either,
}
2 changes: 2 additions & 0 deletions codama-nodes/src/generated/shared/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ mod bytes_encoding;
mod default_value_strategy;
mod endianness;
mod instruction_lifecycle;
mod is_signer;
mod number_format;
mod optional_account_strategy;
mod post_offset_strategy;
Expand All @@ -12,6 +13,7 @@ pub use bytes_encoding::*;
pub use default_value_strategy::*;
pub use endianness::*;
pub use instruction_lifecycle::*;
pub use is_signer::*;
pub use number_format::*;
pub use optional_account_strategy::*;
pub use post_offset_strategy::*;
Expand Down
12 changes: 6 additions & 6 deletions codama-nodes/src/instruction_account_node.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use crate::{CamelCaseString, Docs, HasName, InstructionInputValueNode, IsAccountSigner};
use crate::{CamelCaseString, Docs, HasName, InstructionInputValueNode, IsSigner};
use codama_nodes_derive::node;

#[node]
pub struct InstructionAccountNode {
// Data.
pub name: CamelCaseString,
pub is_writable: bool,
pub is_signer: IsAccountSigner,
pub is_signer: IsSigner,
#[serde(default, skip_serializing_if = "crate::is_default")]
pub is_optional: bool,
#[serde(default, skip_serializing_if = "crate::is_default")]
Expand All @@ -21,7 +21,7 @@ impl InstructionAccountNode {
pub fn new<T, U>(name: T, is_writable: bool, is_signer: U) -> Self
where
T: Into<CamelCaseString>,
U: Into<IsAccountSigner>,
U: Into<IsSigner>,
{
Self {
name: name.into(),
Expand Down Expand Up @@ -50,7 +50,7 @@ mod tests {
let node = InstructionAccountNode::new("my_account", false, true);
assert_eq!(node.name, CamelCaseString::new("myAccount"));
assert!(!node.is_writable);
assert_eq!(node.is_signer, IsAccountSigner::True);
assert_eq!(node.is_signer, IsSigner::True);
assert!(!node.is_optional);
assert_eq!(node.docs, Docs::default());
assert_eq!(node.default_value, None);
Expand All @@ -61,14 +61,14 @@ mod tests {
let node = InstructionAccountNode {
name: "myAccount".into(),
is_writable: false,
is_signer: IsAccountSigner::Either,
is_signer: IsSigner::Either,
is_optional: true,
docs: vec!["Hello".to_string()].into(),
default_value: Some(AccountValueNode::new("myOtherAccount").into()),
};
assert_eq!(node.name, CamelCaseString::new("myAccount"));
assert!(!node.is_writable);
assert_eq!(node.is_signer, IsAccountSigner::Either);
assert_eq!(node.is_signer, IsSigner::Either);
assert!(node.is_optional);
assert_eq!(*node.docs, vec!["Hello".to_string()]);
assert_eq!(
Expand Down
12 changes: 6 additions & 6 deletions codama-nodes/src/instruction_remaining_accounts_node.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{ArgumentValueNode, Docs, IsAccountSigner, ResolverValueNode};
use crate::{ArgumentValueNode, Docs, IsSigner, ResolverValueNode};
use codama_nodes_derive::{node, node_union};

#[node]
Expand All @@ -7,7 +7,7 @@ pub struct InstructionRemainingAccountsNode {
#[serde(default, skip_serializing_if = "crate::is_default")]
pub is_optional: bool,
#[serde(default, skip_serializing_if = "crate::is_default")]
pub is_signer: IsAccountSigner,
pub is_signer: IsSigner,
#[serde(default, skip_serializing_if = "crate::is_default")]
pub is_writable: bool,
#[serde(default, skip_serializing_if = "crate::is_default")]
Expand All @@ -31,13 +31,13 @@ mod tests {
fn direct_instantiation() {
let node = InstructionRemainingAccountsNode {
is_optional: false,
is_signer: IsAccountSigner::Either,
is_signer: IsSigner::Either,
is_writable: true,
docs: vec!["This is a test".to_string()].into(),
value: ArgumentValueNode::new("myArgument").into(),
};
assert!(!node.is_optional);
assert_eq!(node.is_signer, IsAccountSigner::Either);
assert_eq!(node.is_signer, IsSigner::Either);
assert!(node.is_writable);
assert_eq!(node.docs, vec!["This is a test".to_string()].into());
assert_eq!(
Expand All @@ -50,7 +50,7 @@ mod tests {
fn to_json() {
let node = InstructionRemainingAccountsNode {
is_optional: false,
is_signer: IsAccountSigner::Either,
is_signer: IsSigner::Either,
is_writable: true,
docs: vec![].into(),
value: ArgumentValueNode::new("myArgument").into(),
Expand All @@ -70,7 +70,7 @@ mod tests {
node,
InstructionRemainingAccountsNode {
is_optional: false,
is_signer: IsAccountSigner::Either,
is_signer: IsSigner::Either,
is_writable: true,
docs: vec![].into(),
value: ArgumentValueNode::new("myArgument").into(),
Expand Down
104 changes: 0 additions & 104 deletions codama-nodes/src/shared/is_account_signer.rs

This file was deleted.

Loading
Loading