-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Labels
enhancementNew feature or requestNew feature or request
Description
Problem
When integrating multiple Nuwa SDKs (identity-kit, payment-kit, cap-kit) in an application, developers face difficulties with network configuration due to:
- Scattered configuration sources - Each SDK has its own way of determining network settings
- Inconsistent parameter naming -
rpcUrlvsroochUrl, different option structures - Implicit inference logic - Some SDKs infer network from hostnames, others require explicit config
- Missing unified chain config -
IdentityEnv.chainConfigdoesn't exist, but code assumes it does
Current State
| SDK / Module | Network Config Source | Parameter Naming |
|---|---|---|
IdentityKitWeb |
Inferred from cadopDomain + roochRpcUrl option |
network, rpcUrl |
PaymentHubClient |
Constructor params, tried env.chainConfig (doesn't exist) |
network, rpcUrl |
CapKitMcp |
capKitConfig.roochUrl |
roochUrl, network |
RoochPaymentChannelContract |
Constructor params | rpcUrl, network |
Specific Issues
-
IdentityKitWeb infers network from
cadopDomainviaresolveNetworkFromHost(), but ifroochRpcUrlpoints to mainnet whilecadopDomainis testnet, they conflict silently. -
getChainConfigFromEnv() exists in payment-kit but is not easily discoverable. Developers may incorrectly assume
env.chainConfigexists. -
No single source of truth - Applications need to configure network in multiple places and ensure consistency manually.
Impact
- Developer confusion when setting up multi-SDK integrations
- Hard-to-debug issues when configurations are inconsistent
- Increased boilerplate code in applications to keep configs in sync
Proposed Improvements
Short-term (Documentation & Conventions)
- Standardize parameter naming:
network+rpcUrlacross all SDKs - Document network configuration priority: explicit params > global config > env vars > hostname inference
- Export
getChainConfigFromEnv()prominently from payment-kit
Mid-term (SDK Enhancements)
- Add
chainConfigproperty toIdentityEnvduring bootstrap - Provide
fromEnv()factory methods in each SDK:const hub = await PaymentHubClient.fromEnv(env, { defaultAssetId }); const capKit = await CapKitMcp.fromEnv(env, { contractAddress });
- Support
NUWA_NETWORK/VITE_NUWA_NETWORKenvironment variable in all SDKs
Long-term (Optional)
- Consider creating
@nuwa-ai/sdkas unified entry point:const nuwa = await NuwaSDK.init({ network: 'main' }); const payment = nuwa.getPaymentHubClient(); const capKit = nuwa.getCapKitMcp();
Related
This issue was discovered while adding mainnet support to nuwa-client, where PaymentHubClient was incorrectly connecting to testnet despite other configs pointing to mainnet.
Labels
- enhancement
- sdk
- developer-experience
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request