Skip to content

Commit ae6d45a

Browse files
Copilot0xrinegade
andcommitted
Fix Rust code formatting using cargo fmt
Co-authored-by: 0xrinegade <[email protected]>
1 parent b239add commit ae6d45a

File tree

5 files changed

+81
-55
lines changed

5 files changed

+81
-55
lines changed

rust/src/agent/mod.rs

Lines changed: 25 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub enum AgentRegistryInstruction {
9393
/// Maximum length constants (from the on-chain program)
9494
/// These limits are enforced by the Solana AI Registries program to ensure
9595
/// efficient storage and consistent behavior across the network.
96-
///
96+
///
9797
/// **References:**
9898
/// - On-chain program constraints: [Agent Registry Program Documentation](https://docs.solana-ai-registries.org/program/agent-registry)
9999
/// - Program source: `programs/agent-registry/src/lib.rs`
@@ -337,15 +337,15 @@ impl From<AgentPatch> for AgentUpdateDetailsInput {
337337
clear_provider_url: patch.clear_provider_url,
338338
documentation_url: patch.documentation_url,
339339
clear_documentation_url: patch.clear_documentation_url,
340-
service_endpoints: patch.service_endpoints.map(|endpoints| {
341-
endpoints.into_iter().map(|e| e.into()).collect()
342-
}),
340+
service_endpoints: patch
341+
.service_endpoints
342+
.map(|endpoints| endpoints.into_iter().map(|e| e.into()).collect()),
343343
capabilities_flags: patch.capabilities_flags,
344344
supported_input_modes: patch.supported_input_modes,
345345
supported_output_modes: patch.supported_output_modes,
346-
skills: patch.skills.map(|skills| {
347-
skills.into_iter().map(|s| s.into()).collect()
348-
}),
346+
skills: patch
347+
.skills
348+
.map(|skills| skills.into_iter().map(|s| s.into()).collect()),
349349
security_info_uri: patch.security_info_uri,
350350
clear_security_info_uri: patch.clear_security_info_uri,
351351
aea_address: patch.aea_address,
@@ -762,7 +762,11 @@ pub fn create_register_agent_instruction(
762762
provider_name: args.provider_name,
763763
provider_url: args.provider_url,
764764
documentation_url: args.documentation_url,
765-
service_endpoints: args.service_endpoints.into_iter().map(|e| e.into()).collect(),
765+
service_endpoints: args
766+
.service_endpoints
767+
.into_iter()
768+
.map(|e| e.into())
769+
.collect(),
766770
capabilities_flags: args.capabilities_flags,
767771
supported_input_modes: args.supported_input_modes,
768772
supported_output_modes: args.supported_output_modes,
@@ -775,8 +779,9 @@ pub fn create_register_agent_instruction(
775779
tags: args.tags,
776780
};
777781

778-
let data = instruction.try_to_vec()
779-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
782+
let data = instruction.try_to_vec().map_err(|e| {
783+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
784+
})?;
780785

781786
Ok(Instruction {
782787
program_id: *program_id,
@@ -803,8 +808,9 @@ pub fn create_update_agent_instruction(
803808
details: patch.into(),
804809
};
805810

806-
let data = instruction.try_to_vec()
807-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
811+
let data = instruction.try_to_vec().map_err(|e| {
812+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
813+
})?;
808814

809815
Ok(Instruction {
810816
program_id: *program_id,
@@ -827,12 +833,11 @@ pub fn create_update_agent_status_instruction(
827833
AccountMeta::new_readonly(*owner, true),
828834
];
829835

830-
let instruction = AgentRegistryInstruction::UpdateAgentStatus {
831-
new_status: status,
832-
};
836+
let instruction = AgentRegistryInstruction::UpdateAgentStatus { new_status: status };
833837

834-
let data = instruction.try_to_vec()
835-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
838+
let data = instruction.try_to_vec().map_err(|e| {
839+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
840+
})?;
836841

837842
Ok(Instruction {
838843
program_id: *program_id,
@@ -856,8 +861,9 @@ pub fn create_deregister_agent_instruction(
856861

857862
let instruction = AgentRegistryInstruction::DeregisterAgent;
858863

859-
let data = instruction.try_to_vec()
860-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
864+
let data = instruction.try_to_vec().map_err(|e| {
865+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
866+
})?;
861867

862868
Ok(Instruction {
863869
program_id: *program_id,

rust/src/client.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ mod tests {
350350
}
351351

352352
/// Centralized helper for deserializing account data with Anchor discriminator handling
353-
///
353+
///
354354
/// This function abstracts the common pattern of:
355355
/// 1. Validating minimum data length (8 bytes for discriminator)
356356
/// 2. Skipping the 8-byte Anchor discriminator
@@ -367,7 +367,7 @@ where
367367

368368
// Skip the 8-byte discriminator used by Anchor
369369
let account_data = &data[8..];
370-
370+
371371
// Deserialize with type-specific error message
372372
T::try_from_slice(account_data).map_err(|e| {
373373
SdkError::DeserializationError(format!("Failed to deserialize {}: {}", type_name, e))

rust/src/mcp/mod.rs

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ pub enum McpServerRegistryInstruction {
9292
/// Maximum length constants (from the on-chain program)
9393
/// These limits are enforced by the Solana AI Registries program to ensure
9494
/// efficient storage and consistent behavior across the network.
95-
///
95+
///
9696
/// **References:**
9797
/// - On-chain program constraints: [MCP Server Registry Program Documentation](https://docs.solana-ai-registries.org/program/mcp-registry)
9898
/// - Program source: `programs/mcp-server-registry/src/lib.rs`
@@ -331,15 +331,15 @@ impl From<McpServerPatch> for McpServerUpdateDetailsInput {
331331
supports_resources: patch.supports_resources,
332332
supports_tools: patch.supports_tools,
333333
supports_prompts: patch.supports_prompts,
334-
onchain_tool_definitions: patch.onchain_tool_definitions.map(|tools| {
335-
tools.into_iter().map(|t| t.into()).collect()
336-
}),
337-
onchain_resource_definitions: patch.onchain_resource_definitions.map(|resources| {
338-
resources.into_iter().map(|r| r.into()).collect()
339-
}),
340-
onchain_prompt_definitions: patch.onchain_prompt_definitions.map(|prompts| {
341-
prompts.into_iter().map(|p| p.into()).collect()
342-
}),
334+
onchain_tool_definitions: patch
335+
.onchain_tool_definitions
336+
.map(|tools| tools.into_iter().map(|t| t.into()).collect()),
337+
onchain_resource_definitions: patch
338+
.onchain_resource_definitions
339+
.map(|resources| resources.into_iter().map(|r| r.into()).collect()),
340+
onchain_prompt_definitions: patch
341+
.onchain_prompt_definitions
342+
.map(|prompts| prompts.into_iter().map(|p| p.into()).collect()),
343343
full_capabilities_uri: patch.full_capabilities_uri,
344344
clear_full_capabilities_uri: patch.clear_full_capabilities_uri,
345345
tags: patch.tags,
@@ -726,15 +726,28 @@ pub fn create_register_mcp_server_instruction(
726726
supports_resources: args.supports_resources,
727727
supports_tools: args.supports_tools,
728728
supports_prompts: args.supports_prompts,
729-
onchain_tool_definitions: args.onchain_tool_definitions.into_iter().map(|t| t.into()).collect(),
730-
onchain_resource_definitions: args.onchain_resource_definitions.into_iter().map(|r| r.into()).collect(),
731-
onchain_prompt_definitions: args.onchain_prompt_definitions.into_iter().map(|p| p.into()).collect(),
729+
onchain_tool_definitions: args
730+
.onchain_tool_definitions
731+
.into_iter()
732+
.map(|t| t.into())
733+
.collect(),
734+
onchain_resource_definitions: args
735+
.onchain_resource_definitions
736+
.into_iter()
737+
.map(|r| r.into())
738+
.collect(),
739+
onchain_prompt_definitions: args
740+
.onchain_prompt_definitions
741+
.into_iter()
742+
.map(|p| p.into())
743+
.collect(),
732744
full_capabilities_uri: args.full_capabilities_uri,
733745
tags: args.tags,
734746
};
735747

736-
let data = instruction.try_to_vec()
737-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
748+
let data = instruction.try_to_vec().map_err(|e| {
749+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
750+
})?;
738751

739752
Ok(Instruction {
740753
program_id: *program_id,
@@ -761,8 +774,9 @@ pub fn create_update_mcp_server_instruction(
761774
details: patch.into(),
762775
};
763776

764-
let data = instruction.try_to_vec()
765-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
777+
let data = instruction.try_to_vec().map_err(|e| {
778+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
779+
})?;
766780

767781
Ok(Instruction {
768782
program_id: *program_id,
@@ -785,12 +799,11 @@ pub fn create_update_mcp_server_status_instruction(
785799
AccountMeta::new_readonly(*owner, true),
786800
];
787801

788-
let instruction = McpServerRegistryInstruction::UpdateMcpServerStatus {
789-
new_status: status,
790-
};
802+
let instruction = McpServerRegistryInstruction::UpdateMcpServerStatus { new_status: status };
791803

792-
let data = instruction.try_to_vec()
793-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
804+
let data = instruction.try_to_vec().map_err(|e| {
805+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
806+
})?;
794807

795808
Ok(Instruction {
796809
program_id: *program_id,
@@ -814,8 +827,9 @@ pub fn create_deregister_mcp_server_instruction(
814827

815828
let instruction = McpServerRegistryInstruction::DeregisterMcpServer;
816829

817-
let data = instruction.try_to_vec()
818-
.map_err(|e| SdkError::SerializationError(format!("Failed to serialize instruction: {}", e)))?;
830+
let data = instruction.try_to_vec().map_err(|e| {
831+
SdkError::SerializationError(format!("Failed to serialize instruction: {}", e))
832+
})?;
819833

820834
Ok(Instruction {
821835
program_id: *program_id,

rust/src/payments/common.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use solana_sdk::{
1010

1111
/// Payment system constants and configuration
1212
/// These values define the economic parameters of the Solana AI Registries payment system.
13-
///
13+
///
1414
/// **References:**
1515
/// - Payment program constraints: [Payment System Documentation](https://docs.solana-ai-registries.org/payment-system)
1616
/// - Program source: `programs/payment-system/src/lib.rs`

rust/tests/integration.rs

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ fn test_deserialize_helper_with_valid_data() {
7979
data_with_discriminator.extend_from_slice(&serialized);
8080

8181
// Test deserialization
82-
let result: SdkResult<TestData> = deserialize_account_data(&data_with_discriminator, "test data");
82+
let result: SdkResult<TestData> =
83+
deserialize_account_data(&data_with_discriminator, "test data");
8384
assert!(result.is_ok());
8485
let deserialized = result.unwrap();
8586
assert_eq!(deserialized.value, 12345);
@@ -127,15 +128,18 @@ fn test_service_endpoint_validation() {
127128
let builder = AgentBuilder::new("test-agent", "Test Agent");
128129

129130
// Test valid endpoint
130-
let result = builder
131-
.add_service_endpoint("https", "https://example.com/api", true);
131+
let result = builder.add_service_endpoint("https", "https://example.com/api", true);
132132
assert!(result.is_ok());
133133

134134
// Test multiple default endpoints (should fail on build)
135135
let builder = AgentBuilder::new("test-agent", "Test Agent");
136-
let builder = builder.add_service_endpoint("https", "https://example.com/api", true).unwrap();
137-
let builder = builder.add_service_endpoint("http", "http://example.com/api", true).unwrap();
138-
136+
let builder = builder
137+
.add_service_endpoint("https", "https://example.com/api", true)
138+
.unwrap();
139+
let builder = builder
140+
.add_service_endpoint("http", "http://example.com/api", true)
141+
.unwrap();
142+
139143
// The error should occur when we try to build, not when adding endpoints
140144
let result = builder.build();
141145
assert!(result.is_err());
@@ -163,7 +167,7 @@ fn test_skill_validation() {
163167
assert!(result.is_ok());
164168
builder = result.unwrap();
165169
}
166-
170+
167171
// The error should occur when we try to build, not when adding skills
168172
let result = builder.build();
169173
assert!(result.is_err());
@@ -183,7 +187,9 @@ struct MockStruct {
183187

184188
#[test]
185189
fn test_priority_multiplier_validation() {
186-
use solana_ai_registries::payments::common::{MAX_PRIORITY_MULTIPLIER, MIN_PRIORITY_MULTIPLIER};
190+
use solana_ai_registries::payments::common::{
191+
MAX_PRIORITY_MULTIPLIER, MIN_PRIORITY_MULTIPLIER,
192+
};
187193

188194
// Test valid range
189195
assert!(MIN_PRIORITY_MULTIPLIER <= MAX_PRIORITY_MULTIPLIER);
@@ -233,4 +239,4 @@ fn test_constant_documentation_exists() {
233239
assert_eq!(A2AMPL_DECIMALS, 9);
234240
assert_eq!(A2AMPL_BASE_UNIT, 1_000_000_000);
235241
assert!(AGENT_REGISTRATION_FEE > MCP_REGISTRATION_FEE);
236-
}
242+
}

0 commit comments

Comments
 (0)