fix: rewrite chain_sync for correct on-chain credit settlement #76
Merged
wasabi opened 2 days ago

Summary

Rewrites the broken chain_sync.py stub into a working on-chain settlement module for credit issuance and retirement.

Changes

  • Fixed sync_credits_to_chain(): correct ERC-1155 ABI, keccak256 tokenId derivation matching Solidity contract, actual web3 issue() transactions
  • Added retire_onchain(): calls retire() on ERC-1155 contract for confirmed retirements
  • Fixed verify_chain_balance(): uses ERC-1155 balanceOf (was incorrectly using EAS contract)
  • Fixed reconcile_all(): real account addresses, correct token ID derivation
  • Wired into flows: batch_manager.issue_batch() and carbon_credits.review_retirement()
  • CLI subcommand: chain-sync with sync, retire-onchain, verify, and reconcile operations
  • Generated ABI: contracts/abis/KokonutCreditToken.json

Safety

All on-chain calls gated by CREDIT_ONCHAIN_SYNC_ENABLED env var (default false). No behavioral change for existing deployments.

Tests

15 mocked web3 tests covering minting, retirement, balance verification, reconciliation, and token ID computation.

Commits were merged into target branch
1/1
Submitter wasabi
Target main
Source fix/credit-chain-sync
Jobs
Merge Strategy
Create Merge Commit
Watchers (1)
Reference
pull request KI-76
Please wait...
Connection lost or session expired, reload to recover
Page is in error, reload to recover