@layerzerolabs/framework-solana-anchor-trait 1.2.50 → 1.2.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Cargo.toml CHANGED
@@ -4,6 +4,24 @@ version = "0.1.0"
4
4
  edition = "2021"
5
5
  description = "Trait-like instruction interfaces for Anchor Solana programs with compile-time enforcement and default implementations"
6
6
 
7
+ [workspace]
8
+ resolver = "2"
9
+ members = [
10
+ "examples/shapes/macros",
11
+ "examples/shapes/programs/ellipse",
12
+ "examples/shapes/programs/triangle",
13
+ ]
14
+
15
+ [workspace.dependencies]
16
+ anchor-lang = { version = "1.0.2" }
17
+ anchor-trait = { path = "." }
18
+ shapes-macros = { path = "examples/shapes/macros" }
19
+ mollusk-svm = { version = "0.8", features = ["inner-instructions"] }
20
+ solana-account = "3.4"
21
+ solana-instruction = "3.2"
22
+ solana-pubkey = "4.1"
23
+ solana-program-error = "3.0"
24
+
7
25
  [features]
8
26
  idl-build = []
9
27
 
@@ -11,10 +11,8 @@ use proc_macro2::TokenStream;
11
11
  use quote::{format_ident, quote};
12
12
  use syn::ItemMod;
13
13
 
14
- const OVERRIDE_CONFIG: OverrideConfig = OverrideConfig {
15
- attr_name: "shapes_instruction",
16
- domain: "Shapes",
17
- };
14
+ const OVERRIDE_CONFIG: OverrideConfig =
15
+ OverrideConfig { attr_name: "shapes_instruction", domain: "Shapes" };
18
16
 
19
17
  pub fn expand(_attr: TokenStream, item: TokenStream) -> syn::Result<TokenStream> {
20
18
  let module = syn::parse2::<ItemMod>(item)?;
@@ -23,9 +21,7 @@ pub fn expand(_attr: TokenStream, item: TokenStream) -> syn::Result<TokenStream>
23
21
  let overrides = InstructionOverrides::collect(&module, OVERRIDE_CONFIG)?;
24
22
 
25
23
  // 2. Generate instructions
26
- let codegen_ctx = CodegenContext {
27
- state_type: quote!(ShapeState),
28
- };
24
+ let codegen_ctx = CodegenContext { state_type: quote!(ShapeState) };
29
25
  let instructions = generate_instructions::<ShapesInstructionSet>(&codegen_ctx, &overrides)?;
30
26
 
31
27
  // 3. Assemble output
@@ -15,16 +15,10 @@ fn test_initialize_creates_shape_with_correct_dimensions() {
15
15
 
16
16
  mollusk.process_and_validate_instruction(
17
17
  &initialize_ix(&payer, &shape_key, 10, 6),
18
- &[
19
- (payer, payer_account()),
20
- (shape_key, Account::default()),
21
- sys_keyed(),
22
- ],
18
+ &[(payer, payer_account()), (shape_key, Account::default()), sys_keyed()],
23
19
  &[
24
20
  Check::success(),
25
- Check::account(&shape_key)
26
- .data(&shape_data(10, 6, shape_bump))
27
- .build(),
21
+ Check::account(&shape_key).data(&shape_data(10, 6, shape_bump)).build(),
28
22
  ],
29
23
  );
30
24
  }
@@ -65,10 +59,7 @@ fn test_get_dimension_returns_semi_axis_a_at_index_0() {
65
59
  &[Check::success()],
66
60
  );
67
61
 
68
- assert_eq!(
69
- u64::from_le_bytes(result.return_data[..8].try_into().unwrap()),
70
- 10
71
- );
62
+ assert_eq!(u64::from_le_bytes(result.return_data[..8].try_into().unwrap()), 10);
72
63
  }
73
64
 
74
65
  #[test]
@@ -82,10 +73,7 @@ fn test_get_dimension_returns_semi_axis_b_at_index_1() {
82
73
  &[Check::success()],
83
74
  );
84
75
 
85
- assert_eq!(
86
- u64::from_le_bytes(result.return_data[..8].try_into().unwrap()),
87
- 6
88
- );
76
+ assert_eq!(u64::from_le_bytes(result.return_data[..8].try_into().unwrap()), 6);
89
77
  }
90
78
 
91
79
  // ── clear ─────────────────────────────────────────────────────────────────────
@@ -102,12 +90,7 @@ fn test_clear_zeros_dimensions() {
102
90
  data: ix::Clear::DISCRIMINATOR.to_vec(),
103
91
  },
104
92
  &[(shape_key, shape_account(10, 6, shape_bump))],
105
- &[
106
- Check::success(),
107
- Check::account(&shape_key)
108
- .data(&shape_data(0, 0, shape_bump))
109
- .build(),
110
- ],
93
+ &[Check::success(), Check::account(&shape_key).data(&shape_data(0, 0, shape_bump)).build()],
111
94
  );
112
95
  }
113
96
 
@@ -130,10 +113,7 @@ fn test_compute_area_uses_ellipse_formula() {
130
113
  );
131
114
 
132
115
  // 314_159 * 10 * 6 / 400_000 = 47
133
- assert_eq!(
134
- u64::from_le_bytes(result.return_data[..8].try_into().unwrap()),
135
- 47
136
- );
116
+ assert_eq!(u64::from_le_bytes(result.return_data[..8].try_into().unwrap()), 47);
137
117
  }
138
118
 
139
119
  // ── compute_perimeter ─────────────────────────────────────────────────────────
@@ -155,10 +135,7 @@ fn test_compute_perimeter_uses_ellipse_approximation() {
155
135
  );
156
136
 
157
137
  // 314_159 * (10 + 6) / 200_000 = 25
158
- assert_eq!(
159
- u64::from_le_bytes(result.return_data[..8].try_into().unwrap()),
160
- 25
161
- );
138
+ assert_eq!(u64::from_le_bytes(result.return_data[..8].try_into().unwrap()), 25);
162
139
  }
163
140
 
164
141
  // ── scale ─────────────────────────────────────────────────────────────────────
@@ -178,9 +155,7 @@ fn test_scale_default_scales_both_axes() {
178
155
  &[(shape_key, shape_account(10, 6, shape_bump))],
179
156
  &[
180
157
  Check::success(),
181
- Check::account(&shape_key)
182
- .data(&shape_data(20, 12, shape_bump))
183
- .build(),
158
+ Check::account(&shape_key).data(&shape_data(20, 12, shape_bump)).build(),
184
159
  ],
185
160
  );
186
161
  }
@@ -202,9 +177,7 @@ fn test_reset_restores_unit_circle() {
202
177
  &[(shape_key, shape_account(30, 5, shape_bump))],
203
178
  &[
204
179
  Check::success(),
205
- Check::account(&shape_key)
206
- .data(&shape_data(10, 10, shape_bump))
207
- .build(),
180
+ Check::account(&shape_key).data(&shape_data(10, 10, shape_bump)).build(),
208
181
  ],
209
182
  );
210
183
  }
@@ -15,17 +15,8 @@ fn test_initialize_creates_shape_with_correct_dimensions() {
15
15
 
16
16
  mollusk.process_and_validate_instruction(
17
17
  &initialize_ix(&payer, &shape_key, 6, 4),
18
- &[
19
- (payer, payer_account()),
20
- (shape_key, Account::default()),
21
- sys_keyed(),
22
- ],
23
- &[
24
- Check::success(),
25
- Check::account(&shape_key)
26
- .data(&shape_data(6, 4, shape_bump))
27
- .build(),
28
- ],
18
+ &[(payer, payer_account()), (shape_key, Account::default()), sys_keyed()],
19
+ &[Check::success(), Check::account(&shape_key).data(&shape_data(6, 4, shape_bump)).build()],
29
20
  );
30
21
  }
31
22
 
@@ -96,12 +87,7 @@ fn test_clear_zeros_dimensions() {
96
87
  data: ix::Clear::DISCRIMINATOR.to_vec(),
97
88
  },
98
89
  &[(shape_key, shape_account(6, 4, shape_bump))],
99
- &[
100
- Check::success(),
101
- Check::account(&shape_key)
102
- .data(&shape_data(0, 0, shape_bump))
103
- .build(),
104
- ],
90
+ &[Check::success(), Check::account(&shape_key).data(&shape_data(0, 0, shape_bump)).build()],
105
91
  );
106
92
  }
107
93
 
@@ -123,10 +109,7 @@ fn test_compute_area_uses_triangle_formula() {
123
109
  ],
124
110
  data: ix_data(ix::ComputeArea::DISCRIMINATOR, ComputeParams {}),
125
111
  },
126
- &[
127
- (shape_key, shape_account(6, 4, shape_bump)),
128
- (verifier, verifier_account()),
129
- ],
112
+ &[(shape_key, shape_account(6, 4, shape_bump)), (verifier, verifier_account())],
130
113
  &[Check::success()],
131
114
  );
132
115
 
@@ -172,9 +155,7 @@ fn test_scale_only_changes_height_for_isoceles_triangle() {
172
155
  &[(shape_key, shape_account(6, 4, shape_bump))],
173
156
  &[
174
157
  Check::success(),
175
- Check::account(&shape_key)
176
- .data(&shape_data(6, 12, shape_bump))
177
- .build(),
158
+ Check::account(&shape_key).data(&shape_data(6, 12, shape_bump)).build(),
178
159
  ],
179
160
  );
180
161
  }
@@ -194,12 +175,7 @@ fn test_reset_sets_both_dimensions_to_one() {
194
175
  data: ix::Reset::DISCRIMINATOR.to_vec(),
195
176
  },
196
177
  &[(shape_key, shape_account(6, 4, shape_bump))],
197
- &[
198
- Check::success(),
199
- Check::account(&shape_key)
200
- .data(&shape_data(1, 1, shape_bump))
201
- .build(),
202
- ],
178
+ &[Check::success(), Check::account(&shape_key).data(&shape_data(1, 1, shape_bump)).build()],
203
179
  );
204
180
  }
205
181
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@layerzerolabs/framework-solana-anchor-trait",
3
- "version": "1.2.50",
3
+ "version": "1.2.51",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -14,10 +14,10 @@
14
14
  "rustfmt.toml"
15
15
  ],
16
16
  "devDependencies": {
17
- "@layerzerolabs/build-utils-solana": "1.2.50",
18
- "@layerzerolabs/tsup-configuration": "1.2.50",
19
- "@layerzerolabs/typescript-configuration": "1.2.50",
20
- "@layerzerolabs/vm-tooling-solana": "1.2.50"
17
+ "@layerzerolabs/vm-tooling-solana": "1.2.51",
18
+ "@layerzerolabs/typescript-configuration": "1.2.51",
19
+ "@layerzerolabs/build-utils-solana": "1.2.51",
20
+ "@layerzerolabs/tsup-configuration": "1.2.51"
21
21
  },
22
22
  "publishConfig": {
23
23
  "access": "restricted",
@@ -30,7 +30,7 @@
30
30
  ]
31
31
  },
32
32
  "scripts": {
33
- "allow-read-write": "[ -z \"$CI\" ] || sudo chmod -R a+rwx ./target ./examples/shapes/target",
33
+ "allow-read-write": "[ -z \"$CI\" ] || sudo chmod -R a+rwx ./target",
34
34
  "build": "pnpm build:lib && pnpm build:example && pnpm allow-read-write",
35
35
  "build:example": "pnpm exec lz-tool --script 'anchor build --no-idl --ignore-keys' anchor",
36
36
  "build:example:native": "pnpm exec lz-tool --docker-platform native --script 'anchor build --no-idl --ignore-keys' anchor",