Skip to content

Conversation

@joelorzet
Copy link
Collaborator

@joelorzet joelorzet commented May 22, 2025

Summary

This pull request introduces a new MCP Tool: soroban_invoke_contract_method. Also introduce the SorobanValidationService to the Stellar MCP server, enabling type-safe validation of Soroban smart contract method invocations.

Implementation Details

  • Implements comprehensive method parameter validation
  • Adds support for complex data types (structs, enums, options)
  • Enhances error handling with detailed validation messages
  • Adds test coverage for various validation scenarios
  • Implements contract interface parsing and validation

Features

Method Validation

  • Validates method parameter count and types
  • Ensures argument types match method signatures
  • Handles both required and optional parameters
  • Supports primitive and complex types

Type-Safe Validation

  • Validates method signatures against Soroban types
  • Ensures type compatibility
  • Checks argument count and order
  • Validates complex type structures

Struct Validation

  • Validates struct field presence and types
  • Handles nested struct structures
  • Supports required and optional fields
  • Maintains type relationships

Type Support

  • Primitive Types: u32, u8, String, bool
  • Complex Types: Address, structs, enums
  • Optional Types: Option<Type>
  • Custom Types: User-defined types

Error Handling

Validation Error Types

  • MISSING_STRUCT_FIELD
  • INVALID_PARAM_TYPE

Error Context

  • METHOD_PARAMETERS
  • STRUCT_FIELDS

Error Details

  • Parameter names and types
  • Expected vs provided types
  • Missing fields in structs
  • Context-specific information

Test Coverage

Successful Validation Tests

  • Simple method validation
  • Primitive type parameters
  • Struct parameter validation
  • Optional parameter handling

Error Case Tests

  • Missing arguments
  • Type mismatches
  • Invalid struct fields
  • Optional type errors

Testing

The implementation includes comprehensive test coverage:

  • Unit tests for all validation scenarios
  • Error case handling
  • Type validation
  • Struct field validation
  • Optional parameter handling

Documentation

  • Includes type definitions
  • Adds test documentation
  • Provides usage examples

joelorzet added 17 commits May 15, 2025 20:06
…oke_contract_method, outlining inputs, outputs, features, and example usage
@joelorzet joelorzet requested a review from Genebson June 23, 2025 16:34
providedNames: string[],
): ValidationError[] {
const errors: ValidationError[] = [];
const missing = expectedNames.filter(
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename this to something more readable like missing args

Comment on lines +63 to +68
const wasmFiles = stdout
.trim()
.split('\n')
.filter((file) => file.endsWith('.wasm'));

resolve(wasmFiles);
});
});
return wasmFiles;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return stdout instead of const...

Comment on lines +384 to +386
const messages = [...formattedStdout, ...formattedStderr];

return messages;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const messages = [...formattedStdout, ...formattedStderr];
return messages;
return [...formattedStdout, ...formattedStderr];

Comment on lines +458 to +463
const messages = [
...formattedStderr,
...this.formatContractDeploymentMessage(formattedStdout),
];

return messages;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const messages = [
...formattedStderr,
...this.formatContractDeploymentMessage(formattedStdout),
];
return messages;
return [
...formattedStderr,
...this.formatContractDeploymentMessage(formattedStdout),
];

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants