Skip to content

feat: python sdk#57

Merged
lightsing merged 23 commits intodev/m2from
feat/python-sdk
Mar 11, 2026
Merged

feat: python sdk#57
lightsing merged 23 commits intodev/m2from
feat/python-sdk

Conversation

@lightsing
Copy link
Copy Markdown
Owner

No description provided.

- Add OpCode enum for binary operation codes
- Add attestation types (Pending, Bitcoin, EAS, Unknown)
- Add status enums and result types (VerifyStatus, UpgradeStatus)
- Add timestamp step types (Append, Prepend, Hash, Attestation, Fork)
- Add DigestHeader and DetachedTimestamp types
- Add error classes (UTSError, EncodeError, DecodeError, RemoteError)
- Add constants for magic bytes, attestation tags, digest lengths
- Implement Encoder class with LEB128 encoding
- Implement Decoder class with LEB128 decoding
- Support all attestation types and timestamp steps
- Add round-trip tests for encode/decode
- Add sha256, keccak256, ripemd160, sha1 hash functions
- Implement UnorderedMerkleTree with proof generation
- Add MerkleProof and SiblingNode types
- Support tree serialization/deserialization
- Add comprehensive tests for Merkle tree operations
- Add BitcoinRPC async client for JSON-RPC
- Add BitcoinBlockHeader dataclass
- Support get_block_hash and get_block_header methods
- Add async context manager support
- Add mock-based tests for RPC client
- Add EAS contract ABI definitions
- Add OnChainAttestation dataclass
- Implement read_eas_timestamp for timestamp verification
- Implement read_eas_attestation for attestation reading
- Add decode_content_hash utility
- Define EAS_SCHEMA_ID and NO_EXPIRATION constants
- Add SDK class with async context manager support
- Implement stamp() for submitting digests to calendars
- Implement verify() for timestamp verification
- Support Bitcoin and EAS attestation verification
- Add VerificationResult dataclass
- Configure default calendars and EAS addresses
- Add codec round-trip tests for encoder/decoder
- Add Merkle tree tests for proof generation
- Add Bitcoin RPC mock tests
- Total 16 passing tests
- Simplify AttestationStatus to a single dataclass
- Simplify UpgradeResult to a single dataclass
- Add upgrade() method to SDK for upgrading pending attestations
- Update public API exports in __init__.py
- Add AttestationStatusKind enum export
- Test initialization and options
- Test default calendars
- Test invalid hash algorithm error
- Test async context manager
- Test verify with pending attestation
- Test upgrade method
- Remove duplicate return statement in merkle.py
- Move Self import to top of file
- Add SDK.from_env() class method
- Fix UpgradeResult.original type to PendingAttestation
- Add Literal type for hash_algorithm parameter
- Add missing public API exports (MerkleProof, SiblingNode, sha256, keccak256)
- Add test_sdk_from_env for environment variable configuration
- Add test_sdk_from_env_defaults for default values
- Create conftest.py with common fixtures
- Add SHA256Step, SHA1Step, RIPEMD160Step, Keccak256Step exports
- Add AppendStep, PrependStep, ReverseStep, HexlifyStep exports
- Add ForkStep export
- Update __all__ list
- Add test_types.py for type validation tests
- Add test_encoder.py for encoder module tests
- Add test_decoder.py for decoder module tests
- Add test_crypto_utils.py for hash function tests
- Add test_errors.py for error class tests
- Total 121 tests passing
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Introduces an initial Python SDK (uts_sdk) intended to mirror the existing TypeScript SDK, including core types, binary codec, Merkle tree utilities, RPC/EAS integrations, and a test suite.

Changes:

  • Adds Python package scaffolding (pyproject.toml, public API exports, README) and a new async-first SDK implementation.
  • Implements core protocol types (attestations, ops, status enums, timestamp steps) plus encoder/decoder for the OpenTimestamps-compatible binary format.
  • Adds crypto utilities (hashing + Merkle tree) and RPC/EAS helpers, along with extensive pytest coverage.

Reviewed changes

Copilot reviewed 37 out of 39 changed files in this pull request and generated 18 comments.

Show a summary per file
File Description
packages/sdk-py/src/uts_sdk/sdk.py Main async SDK (stamp/verify/upgrade) and result aggregation
packages/sdk-py/src/uts_sdk/_crypto/utils.py Hash helper functions used across the SDK
packages/sdk-py/src/uts_sdk/_crypto/merkle.py Merkle tree + proof generation used by stamping
packages/sdk-py/src/uts_sdk/_codec/encoder.py Binary encoder for detached timestamps and steps
packages/sdk-py/src/uts_sdk/_codec/decoder.py Binary decoder for detached timestamps and steps
packages/sdk-py/src/uts_sdk/_rpc/bitcoin.py Bitcoin JSON-RPC client used during verification
packages/sdk-py/tests/* Unit tests for types/codec/crypto/SDK/RPC
packages/sdk-py/README.md Package documentation and usage snippet

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 39 out of 41 changed files in this pull request and generated 6 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lightsing lightsing merged commit a65f3e8 into dev/m2 Mar 11, 2026
@lightsing lightsing deleted the feat/python-sdk branch March 11, 2026 12:31
@lightsing lightsing added this to the L1 Anchoring milestone Mar 17, 2026
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.

2 participants