package driver

import (
	"context"
	"time"

	"github.com/ethereum/go-ethereum/core/types"
	"github.com/tech/sendico/gateway/chain/internal/keymanager"
	"github.com/tech/sendico/gateway/chain/internal/service/gateway/rpcclient"
	"github.com/tech/sendico/gateway/chain/internal/service/gateway/shared"
	"github.com/tech/sendico/gateway/chain/storage/model"
	"github.com/tech/sendico/pkg/mlogger"
	moneyv1 "github.com/tech/sendico/pkg/proto/common/money/v1"
)

// Deps bundles dependencies shared across chain drivers.
type Deps struct {
	Logger     mlogger.Logger
	Registry   *rpcclient.Registry
	KeyManager keymanager.Manager
	RPCTimeout time.Duration
}

// Driver defines chain-specific behavior for wallet and transfer operations.
type Driver interface {
	Name() string
	FormatAddress(address string) (string, error)
	NormalizeAddress(address string) (string, error)
	Balance(ctx context.Context, deps Deps, network shared.Network, wallet *model.ManagedWallet) (*moneyv1.Money, error)
	NativeBalance(ctx context.Context, deps Deps, network shared.Network, wallet *model.ManagedWallet) (*moneyv1.Money, error)
	EstimateFee(ctx context.Context, deps Deps, network shared.Network, wallet *model.ManagedWallet, destination string, amount *moneyv1.Money) (*moneyv1.Money, error)
	SubmitTransfer(ctx context.Context, deps Deps, network shared.Network, transfer *model.Transfer, source *model.ManagedWallet, destination string) (string, error)
	AwaitConfirmation(ctx context.Context, deps Deps, network shared.Network, txHash string) (*types.Receipt, error)
}
