keeper

package
v6.0.0-...-d56d304 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2023 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	StepSend            = 1
	StepReceive         = 2
	StepAcknowledgement = 3
)

Functions

func GetBidIDFromBytes

func GetBidIDFromBytes(bz []byte) uint64

GetAuctionIDFromBytes returns ID in uint64 format from a byte array

func GetOrderIDBytes

func GetOrderIDBytes(id uint64) []byte

GetAuctionIDBytes returns the byte representation of the ID

Types

type Keeper

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

Keeper defines the IBC Swap keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec, key storetypes.StoreKey, paramSpace paramtypes.Subspace,
	ics4Wrapper porttypes.ICS4Wrapper, channelKeeper types.ChannelKeeper, portKeeper types.PortKeeper,
	authKeeper types.AccountKeeper, bankKeeper types.BankKeeper, scopedKeeper capabilitykeeper.ScopedKeeper,
) Keeper

NewKeeper creates a new IBC transfer Keeper instance

func (Keeper) AppendAtomicOrder

func (k Keeper) AppendAtomicOrder(
	ctx sdk.Context,
	order types.Order,
) uint64

AppendAuction appends a auction in the store with a new id and update the count

func (Keeper) AuthenticateCapability

func (k Keeper) AuthenticateCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) bool

AuthenticateCapability wraps the scopedKeeper's AuthenticateCapability function

func (Keeper) BindPort

func (k Keeper) BindPort(ctx sdk.Context, portID string) error

BindPort defines a wrapper function for the ort Keeper's function in order to expose it to module's InitGenesis function

func (Keeper) CancelSwap

func (k Keeper) CancelSwap(goCtx context.Context, msg *types.CancelSwapMsg) (*types.MsgCancelSwapResponse, error)

CancelSwap is the step 10 (Cancel Request) of the atomic swap: https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap. It is executed on the Maker chain. Only the maker of the order can cancel the order.

func (Keeper) ClaimCapability

func (k Keeper) ClaimCapability(ctx sdk.Context, cap *capabilitytypes.Capability, name string) error

ClaimCapability allows the swap module that can claim a capability that IBC module passes to it

func (Keeper) EscrowAddress

EscrowAddress implements the EscrowAddress gRPC method

func (Keeper) ExportGenesis

func (k Keeper) ExportGenesis(ctx sdk.Context) *types.GenesisState

ExportGenesis exports ibc-transfer module's portID and denom trace info into its genesis state.

func (Keeper) GetAllOrder

func (k Keeper) GetAllOrder(ctx sdk.Context) (list []types.Order)

GetAllAuction returns all auction

func (Keeper) GetAllOrders

func (q Keeper) GetAllOrders(goCtx context.Context, request *types.QueryOrdersRequest) (*types.QueryOrdersResponse, error)

func (Keeper) GetAllOrdersByType

func (q Keeper) GetAllOrdersByType(ctx context.Context, request *types.QueryOrdersByRequest) (*types.QueryOrdersResponse, error)

func (Keeper) GetAtomicOrder

func (k Keeper) GetAtomicOrder(ctx sdk.Context, orderId string) (val types.Order, found bool)

GetAuction returns a auction from its id

func (Keeper) GetAtomicOrderCount

func (k Keeper) GetAtomicOrderCount(ctx sdk.Context) uint64

GetAuctionCount get the total number of auction

func (Keeper) GetAtomicOrderCountByOrderId

func (k Keeper) GetAtomicOrderCountByOrderId(ctx sdk.Context, orderId string) uint64

GetAuctionCount get the total number of auction

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) types.Params

GetParams returns the total set of ibc-transfer parameters.

func (Keeper) GetPort

func (k Keeper) GetPort(ctx sdk.Context) string

GetPort returns the portID for the swap module. Used in ExportGenesis

func (Keeper) GetPrivateOrders

func (q Keeper) GetPrivateOrders(ctx context.Context, request *types.QueryPrivateOrdersRequest) (*types.QueryOrdersResponse, error)

func (Keeper) GetSubmittedOrders

func (q Keeper) GetSubmittedOrders(ctx context.Context, request *types.QuerySubmittedOrdersRequest) (*types.QueryOrdersResponse, error)

func (Keeper) GetSwapEnabled

func (k Keeper) GetSwapEnabled(ctx sdk.Context) bool

GetSwapEnabled retrieves the send enabled boolean from the paramstore

func (Keeper) GetSwapMaxFeeRate

func (k Keeper) GetSwapMaxFeeRate(ctx sdk.Context) uint32

func (Keeper) GetTookOrders

func (q Keeper) GetTookOrders(ctx context.Context, request *types.QueryTookOrdersRequest) (*types.QueryOrdersResponse, error)

func (Keeper) InitGenesis

func (k Keeper) InitGenesis(ctx sdk.Context, state types.GenesisState)

InitGenesis initializes the ibc-transfer state and binds to PortID.

func (Keeper) IsBound

func (k Keeper) IsBound(ctx sdk.Context, portID string) bool

IsBound checks if the transfer module is already bound to the desired port

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) MakeSwap

func (k Keeper) MakeSwap(goCtx context.Context, msg *types.MakeSwapMsg) (*types.MsgMakeSwapResponse, error)

MakeSwap is called when the maker wants to make atomic swap. The method create new order and lock tokens. This is the step 1 (Create order & Lock Token) of the atomic swap: https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap

func (Keeper) MarshalOrder

func (k Keeper) MarshalOrder(order types.Order) ([]byte, error)

MarshalOrder attempts to encode an LimitOrder object and returns the raw encoded bytes.

func (Keeper) MoveOrderToBottom

func (k Keeper) MoveOrderToBottom(ctx sdk.Context, orderId string) error

func (Keeper) MustMarshalOrder

func (k Keeper) MustMarshalOrder(order types.Order) []byte

MustMarshalOrder attempts to encode an LimitOrder object and returns the raw encoded bytes. It panics on error.

func (Keeper) MustUnmarshalOrder

func (k Keeper) MustUnmarshalOrder(bz []byte) types.Order

MustUnmarshalOrder attempts to decode and return an LimitOrder object from raw encoded bytes. It panics on error.

func (Keeper) OnAcknowledgementPacket

func (k Keeper) OnAcknowledgementPacket(ctx sdk.Context, packet channeltypes.Packet, data *types.AtomicSwapPacketData, ack channeltypes.Acknowledgement) error

func (Keeper) OnReceivedCancel

func (k Keeper) OnReceivedCancel(ctx sdk.Context, packet channeltypes.Packet, msg *types.CancelSwapMsg) (string, error)

OnReceivedCancel is the step 12 (Cancel Order) of the atomic swap: https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap. This step is executed on the Taker chain.

func (Keeper) OnReceivedMake

func (k Keeper) OnReceivedMake(ctx sdk.Context, packet channeltypes.Packet, orderId, path string, msg *types.MakeSwapMsg) (string, error)

OnReceivedMake is the step 3.1 (Save order) from the atomic swap: https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap The step is executed on the Taker chain.

func (Keeper) OnReceivedTake

func (k Keeper) OnReceivedTake(ctx sdk.Context, packet channeltypes.Packet, msg *types.TakeSwapMsg) (string, error)

OnReceivedTake is step 7.1 (Transfer Make Token) of the atomic swap: https://github.com/cosmos/ibc/tree/main/spec/app/ics-100-atomic-swap The step is executed on the Maker chain.

func (Keeper) OnRecvPacket

func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet, data types.AtomicSwapPacketData) ([]byte, error)

func (Keeper) OnTimeoutPacket

func (k Keeper) OnTimeoutPacket(ctx sdk.Context, packet channeltypes.Packet, data *types.AtomicSwapPacketData) error

func (Keeper) Params

Params implements the Query/Params gRPC method

func (Keeper) RemoveOrder

func (k Keeper) RemoveOrder(ctx sdk.Context, orderId string)

RemoveAuction removes a auction from the store

func (Keeper) SendSwapPacket

func (k Keeper) SendSwapPacket(
	ctx sdk.Context,
	sourcePort,
	sourceChannel string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	swapPacket types.AtomicSwapPacketData,
) (*uint64, error)

func (Keeper) SetAtomicOrder

func (k Keeper) SetAtomicOrder(ctx sdk.Context, order types.Order)

SetAuction set a specific auction in the store

func (Keeper) SetAtomicOrderCount

func (k Keeper) SetAtomicOrderCount(ctx sdk.Context, count uint64)

SetAuctionCount set the total number of auction

func (Keeper) SetAtomicOrderCountToOrderID

func (k Keeper) SetAtomicOrderCountToOrderID(ctx sdk.Context, orderId string, count uint64)

SetAuctionCount set the total number of auction

func (Keeper) SetParams

func (k Keeper) SetParams(ctx sdk.Context, params types.Params)

SetParams sets the total set of ibc-transfer parameters.

func (Keeper) SetPort

func (k Keeper) SetPort(ctx sdk.Context, portID string)

SetPort sets the portID for the swap module. Used in InitGenesis

func (Keeper) TakeSwap

func (k Keeper) TakeSwap(goCtx context.Context, msg *types.TakeSwapMsg) (*types.MsgTakeSwapResponse, error)

TakeSwap is the step 5 (Lock Order & Lock Token) of the atomic swap: https://github.com/liangping/ibc/blob/atomic-swap/spec/app/ics-100-atomic-swap/ibcswap.png This method lock the order (set a value to the field "Taker") and lock Token

func (Keeper) TrimExcessOrders

func (k Keeper) TrimExcessOrders(ctx sdk.Context)

func (Keeper) Unmarshal

func (k Keeper) Unmarshal(bz []byte) (types.Order, error)

Unmarshal attempts to decode and return an LimitOrder object from raw encoded bytes.

Jump to

Keyboard shortcuts

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