Skip to content

Add NFT record field to asset tree and comprehensive tests#3

Merged
bafu merged 3 commits intomainfrom
claude/verify-sdk-asset-tree-CYQdg
Jan 30, 2026
Merged

Add NFT record field to asset tree and comprehensive tests#3
bafu merged 3 commits intomainfrom
claude/verify-sdk-asset-tree-CYQdg

Conversation

@bafu
Copy link
Contributor

@bafu bafu commented Jan 30, 2026

Summary

This PR adds support for the nftRecord field in asset tree responses and includes comprehensive unit and integration tests for both Python and TypeScript SDKs.

Key Changes

Core Changes

  • Added nftRecord field to AssetTree type in both Python and TypeScript

    • Python: Added nft_record: str | None field to AssetTree dataclass with documentation
    • TypeScript: Added nftRecord?: string field to AssetTree interface
    • Field represents the NFT record CID when an asset has been minted as NFT
  • Updated asset tree parsing logic in Python SDK

    • Added "nftRecord" to known fields in get_asset_tree() method
    • Properly maps API response field to nft_record parameter in AssetTree constructor
    • Unknown fields continue to be stored in the extra dict

Test Coverage

  • Python unit tests (test_asset_tree.py):

    • Tests for correct parsing of nft_record field
    • Tests for handling missing nftRecord in responses
    • Tests for all known fields being properly parsed
    • Tests for unknown fields being stored in extra dict
  • Python unit tests (test_asset_search.py):

    • Comprehensive tests for asset search functionality
    • Tests for precise matches and similar matches parsing
    • Tests for input validation (threshold, sample_count)
  • Python integration tests (test_integration.py):

    • Full workflow test verifying asset tree contains correct creatorWallet and nftRecord
    • Asset search tests with real API calls
    • Tests can be run with CAPTURE_TOKEN environment variable
  • TypeScript integration tests (ts/src/integration.test.ts):

    • Parallel integration tests for TypeScript SDK
    • Tests asset tree retrieval and field verification
    • Tests asset search functionality
    • Can be run with CAPTURE_TOKEN environment variable

Implementation Details

  • The nftRecord field is optional (defaults to None/undefined) to maintain backward compatibility
  • Field is properly excluded from the extra dict to avoid duplication
  • All tests use mocked API responses for unit tests and real API calls for integration tests
  • Tests include proper error handling and validation

https://claude.ai/code/session_01S2rjj4C9JGAHGh5JU2Fofe

- Add nftRecord field to AssetTree type in both TypeScript and Python SDKs
- TypeScript: Added nftRecord?: string to AssetTree interface
- Python: Added nft_record field to AssetTree dataclass and updated
  get_asset_tree() to properly map the field from API response

Integration tests:
- Add integration test files for both SDKs to verify:
  - Asset tree returns creatorWallet and nftRecord fields correctly
  - Asset search (Verify Engine) returns precise matches and similar assets

Unit tests:
- test_asset_tree.py: Mock tests for asset tree parsing including nftRecord
- test_asset_search.py: Mock tests for asset search functionality
- test_integration.py: Live API tests (requires CAPTURE_TOKEN env var)

Tests verify asset NID bafybeif3mhxhkhfwuszl2lybtai3hz3q6naqpfisd4q55mcc7opkmiv5ei:
- creatorWallet: 0x019F590C900c78060da8597186d065ee514931BB
- nftRecord: bafkreibjj4sgpeirznei5or3lncndzije6nw4qsksoomsbu23ivp7bdwei

https://claude.ai/code/session_01S2rjj4C9JGAHGh5JU2Fofe
BREAKING CHANGE: license field type changed from string to License object

Changes:
- Add License type with name and document fields (both SDKs)
- Update AssetTree to use License object instead of string
- Add new fields from AssetTree spec:
  - usedBy: URL of website using the asset
  - integrityCid: IPFS CID of integrity proof
  - digitalSourceType: Source type (digitalCapture, trainedAlgorithmicMedia, etc.)
  - miningPreference: Mining/indexing preference
  - generatedBy: AI/algorithm info for generated content

Python client handles both license object and string for backwards compatibility:
- If API returns object: creates License(name=..., document=...)
- If API returns string: creates License(name=string_value)

Updated tests to cover:
- License object parsing
- License string backwards compatibility
- All new AssetTree spec fields

Bump version: 0.1.0 -> 0.2.0 (breaking change)

Spec: https://docs.numbersprotocol.io/introduction/numbers-protocol/defining-web3-assets/assettree

https://claude.ai/code/session_01S2rjj4C9JGAHGh5JU2Fofe
@bafu bafu merged commit 2b068ac into main Jan 30, 2026
7 checks passed
@bafu bafu deleted the claude/verify-sdk-asset-tree-CYQdg branch January 30, 2026 09:35
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