types

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const ModuleName = "swap-middleware"

ModuleName defines the name for the swap middleware.

Variables

View Source
var (
	ErrInvalidSwapMetadata = sdkerrors.Register(ModuleName, 2, "invalid swap metadata")
	ErrSwapFailed          = sdkerrors.Register(ModuleName, 3, "ibc swap failed")
	ErrMsgHandlerInvalid   = sdkerrors.Register(ModuleName, 4, "msg service handler not found")
)

Functions

This section is empty.

Types

type BankKeeper

type BankKeeper interface {
	SendCoins(ctx sdk.Context, fromAddr, toAddr sdk.AccAddress, amt sdk.Coins) error
	BurnCoins(ctx sdk.Context, moduleName string, amt sdk.Coins) error
	SendCoinsFromAccountToModule(ctx sdk.Context, senderAddr sdk.AccAddress, recipientModule string, amt sdk.Coins) error
}

BankKeeper defines the expected interface that the swap middleware needs in order to facilitate refunds.

type JSONObject

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

JSONObject is a wrapper type to allow either a primitive type or a JSON object. In the case the value is a JSON object, OrderedMap type is used so that key order is retained across Unmarshal/Marshal.

func NewJSONObject

func NewJSONObject(object bool, primitive []byte, orderedMap orderedmap.OrderedMap) *JSONObject

NewJSONObject is a constructor used for tests. The usage of JSONObject in the middleware is only json Marshal/Unmarshal

func (*JSONObject) MarshalJSON

func (o *JSONObject) MarshalJSON() ([]byte, error)

MarshalJSON overrides the default json.Marshal behavior

func (*JSONObject) UnmarshalJSON

func (o *JSONObject) UnmarshalJSON(b []byte) error

UnmarshalJSON overrides the default json.Unmarshal behavior

type PacketMetadata

type PacketMetadata struct {
	Swap *SwapMetadata `json:"swap"`
}

PacketMetadata wraps the SwapMetadata. The root key in the incoming ICS20 transfer packet's memo needs to be set to the same value as the json tag in order for the swap middleware to process the swap.

type ProcessedKey

type ProcessedKey struct{}

ProcessedKey is used to signal to the swap middleware that a packet has already been processed by some other middleware and so invoking the transfer modules OnRecvPacket callback should be avoided.

type SwapMetadata

type SwapMetadata struct {
	*dextypes.MsgPlaceLimitOrder
	// If a value is provided for NeutronRefundAddress and the swap fails the Transfer.Amount will be moved to this address for later recovery.
	// If no NeutronRefundAddress is provided and a swap fails we will fail the ibc transfer and tokens will be refunded on the source chain.
	NeutronRefundAddress string `json:"refund-address,omitempty"`

	// Using JSONObject so that objects for next property will not be mutated by golang's lexicographic key sort on map keys during Marshal.
	// Supports primitives for Unmarshal/Marshal so that an escaped JSON-marshaled string is also valid.
	Next *JSONObject `json:"next,omitempty"`
}

SwapMetadata defines the parameters necessary to perform a swap utilizing the memo field from an incoming ICS20 transfer packet. The next field is a string so that you can nest any arbitrary metadata to be handled further in the middleware stack or on the counterparty.

func (SwapMetadata) ContainsPFM

func (sm SwapMetadata) ContainsPFM() bool

ContainsPFM checks if the Swapetadata is wrapping packet-forward-middleware

func (SwapMetadata) Validate

func (sm SwapMetadata) Validate() error

Validate ensures that all the required fields are present in the SwapMetadata and contain valid values.

Jump to

Keyboard shortcuts

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