Skip to content

Commit

Permalink
add utxo keeper interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
keithsue committed Jun 12, 2024
1 parent 3099232 commit fff5b81
Showing 1 changed file with 59 additions and 2 deletions.
61 changes: 59 additions & 2 deletions x/btclightclient/keeper/utxo.go
Original file line number Diff line number Diff line change
@@ -1,20 +1,77 @@
package keeper

import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/sideprotocol/side/x/btclightclient/types"
)

type UTXOViewKeeper interface {
HasUTXO(ctx sdk.Context, hash string, vout uint64) bool
IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool

GetAllUTXOs(ctx sdk.Context) []*types.UTXO

GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO
GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO
}

type UTXOKeeper interface {
UTXOViewKeeper

LockUTXO(ctx sdk.Context, hash string, vout uint64)
SpendUTXO(ctx sdk.Context, hash string, vout uint64)
}

var _ UTXOKeeper = (*BaseUTXOKeeper)(nil)

type BaseUTXOViewKeeper struct {
k Keeper
}

func NewBaseUTXOViewKeeper(k Keeper) *BaseUTXOViewKeeper {
return &BaseUTXOViewKeeper{k}
}

func (bvk *BaseUTXOViewKeeper) HasUTXO(ctx sdk.Context, hash string, vout uint64) bool {
// TODO
return true
}

func (bvk *BaseUTXOViewKeeper) IsUTXOLocked(ctx sdk.Context, hash string, vout uint64) bool {
// TODO
return true
}

func NewBaseUTXOViewKeeper() *BaseUTXOViewKeeper {
return &BaseUTXOViewKeeper{}
func (bvk *BaseUTXOViewKeeper) GetAllUTXOs(ctx sdk.Context) []*types.UTXO {
// TODO
return nil
}

func (bvk *BaseUTXOViewKeeper) GetUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO {
// TODO
return nil
}

func (bvk *BaseUTXOViewKeeper) GetOrderedUTXOsByAddr(ctx sdk.Context, addr string) []*types.UTXO {
// TODO
return nil
}

type BaseUTXOKeeper struct {
BaseUTXOViewKeeper

k Keeper
}

func NewBaseUTXOKeeper(k Keeper) *BaseUTXOKeeper {
return &BaseUTXOKeeper{BaseUTXOViewKeeper: *NewBaseUTXOViewKeeper(k), k: k}
}

func (bk *BaseUTXOKeeper) LockUTXO(ctx sdk.Context, hash string, vout uint64) {
// TODO
}

func (bk *BaseUTXOKeeper) SpendUTXO(ctx sdk.Context, hash string, vout uint64) {
// TODO
}

0 comments on commit fff5b81

Please sign in to comment.