settlement

package
v0.7.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package settlement handles asynchronous on-chain settlement of P2P tool invocation payments. It subscribes to ToolExecutionPaidEvent from the event bus and submits transferWithAuthorization transactions to the USDC contract.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Wallet         wallet.WalletProvider
	RPCClient      *ethclient.Client
	DBClient       *ent.Client
	ChainID        int64
	USDCAddr       common.Address
	ReceiptTimeout time.Duration // default: 2m
	MaxRetries     int           // default: 3
	Logger         *zap.SugaredLogger
}

Config holds construction parameters for a settlement Service.

type ReputationRecorder

type ReputationRecorder interface {
	RecordSuccess(ctx context.Context, peerDID string) error
	RecordFailure(ctx context.Context, peerDID string) error
}

ReputationRecorder records success/failure outcomes for reputation tracking.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service processes on-chain settlement for paid tool invocations.

func New

func New(cfg Config) *Service

New creates a settlement service with the given configuration.

func (*Service) Close

func (s *Service) Close()

Close waits for all in-flight settlement goroutines to finish.

func (*Service) SetReputationRecorder

func (s *Service) SetReputationRecorder(r ReputationRecorder)

SetReputationRecorder sets the reputation recorder for post-settlement success/failure tracking.

func (*Service) Subscribe

func (s *Service) Subscribe(bus *eventbus.Bus)

Subscribe registers the settlement service as a subscriber to ToolExecutionPaidEvent on the given event bus.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL