Skip to content

Conversation

@tim-hm
Copy link
Contributor

@tim-hm tim-hm commented Dec 11, 2025

No description provided.

BREAKING CHANGE: Payment flow has fundamentally changed. The old  `pay_subscription()` method is removed in favor of a decoupled flow.

Replaces nilchain-based payments with Ethereum ERC-20 token burns, matching the nilauth-client-ts implementation.

New payment flow:
1. `create_payment_resource()` - returns digest for BurnWithDigest contract
2. User sends on-chain tx with digest to BurnWithDigest contract
3. `validate_payment()` - validates tx hash with nilauth service

API changes:
- Client construction now async: `new(url)` → `create(url, chain_id).await`
- `subscription_cost()` returns `u64` instead of `TokenAmount`
- Added `public_key()`, `did()`, `chain_id()` getters to trait
- Payload includes `chain_id` for cross-chain verification
- Uses RFC 8785 canonical JSON (serde_jcs) for consistent hashing

Removed:
- nilchain-client dependency
- pay_subscription() method
- PaySubscriptionError
- NillionChainClient re-export

Added:
- PaymentResource struct (digest + payload)
- create_payment_resource() method
- validate_payment() method
- ValidatePaymentError, PaymentResourceError

Migration:
```rs
// Before (v1.x)
let client = DefaultNilauthClient::new(url)?;
client.pay_subscription(&mut nilchain, module, signer, did).await?;

// After (v2.x)
let client = DefaultNilauthClient::create(url, chain_id).await?;
let resource = client.create_payment_resource(module, payer_did, subscriber_did);
// ... send resource.digest to BurnWithDigest on Ethereum ...
client.validate_payment(tx_hash, &resource.payload, signer).await?;
```
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