Open
Description
Overview
Implement the saveShards
method in Python SDK to store key shards securely on Lighthouse distributed nodes. This method backs up shards on the network and allows access delegation by sharing shards to multiple addresses.
The API contract must match exactly with the JS SDK implementation.
Function Signature
async def saveShards(
address: str,
cid: str,
auth_token: str,
keyShards: List[Dict[str, str]],
shareTo: Optional[List[str]] = None
) -> Dict[str, Any]:
pass
Expected Response Format
{
"isSuccess": true,
"error": null
}
Reference (JS SDK)
- File:
/src/methods/saveShards/index.ts
- Method:
saveShards()
Key Requirements
- Perform HTTP request to Lighthouse Node’s save API endpoint.
- Include
auth_token
for authentication (received viagetAuthMessage
+ signature). - Prepare request body following same structure as JS SDK payload.
- Handle optional
shareTo
parameter for sharing shards during save operation. - Fully mirror the Lighthouse API behavior.
- Handle and parse errors from Lighthouse API into SDK-consistent response.
Suggested Python Libraries
- Use
httpx
orrequests
for asynchronous HTTP calls. - Use
pydantic
or standarddataclasses
for request/response schema validation. - Use standard Python
logging
for debugging API requests.
Deliverables
-
Fully functional
saveShards()
method. -
Unit tests for:
- Valid shard save with and without
shareTo
. - Error cases from Lighthouse API.
- Valid shard save with and without
-
Maintain full consistency in payload and response with JS SDK behavior.
Metadata
Metadata
Assignees
Labels
No labels