keeper

package
v0.0.0-...-1ab191f Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EmitAcknowledgementEvent

func EmitAcknowledgementEvent(ctx sdk.Context, data types.NonFungibleTokenPacketData, ack exported.Acknowledgement, err error)

EmitAcknowledgementEvent emits an event signalling a successful or failed acknowledgement and including the error details if any.

Types

type Keeper

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

Keeper defines the IBC non fungible transfer keeper

func NewKeeper

func NewKeeper(
	cdc codec.Codec,
	key storetypes.StoreKey,
	authority string,
	ics4Wrapper porttypes.ICS4Wrapper,
	channelKeeper types.ChannelKeeper,
	portKeeper types.PortKeeper,
	authKeeper types.AccountKeeper,
	nftKeeper types.NFTKeeper,
	scopedKeeper capabilitykeeper.ScopedKeeper,
) Keeper

NewKeeper creates a new IBC nft-transfer Keeper instance

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) ClaimCapability

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

ClaimCapability allows the nft-transfer module that can claim a capability that IBC module passes to it

func (Keeper) ClassHash

ClassHash implements the Query/ClassHash gRPC method

func (Keeper) ClassPathFromHash

func (k Keeper) ClassPathFromHash(ctx sdk.Context, classID string) (string, error)

ClassPathFromHash returns the full class path prefix from an ibc classId with a hash component.

func (Keeper) ClassTrace

ClassTrace implements the Query/ClassTrace gRPC method

func (Keeper) ClassTraces

ClassTraces implements the Query/ClassTraces gRPC method

func (Keeper) EscrowAddress

EscrowAddress implements the EscrowAddress gRPC method

func (Keeper) ExportGenesis

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

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

func (Keeper) GetAllClassTraces

func (k Keeper) GetAllClassTraces(ctx sdk.Context) types.Traces

GetAllClassTraces returns the trace information for all the class.

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the nft-transfer module's authority.

func (Keeper) GetClassTrace

func (k Keeper) GetClassTrace(ctx sdk.Context, classTraceHash tmbytes.HexBytes) (types.ClassTrace, bool)

GetClassTrace retrieves the full identifiers trace and base classId from the store.

func (Keeper) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params 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 nft-transfer module.

func (Keeper) GetReceiveEnabled

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

GetReceiveEnabled retrieves the receive enabled boolean from the paramstore

func (Keeper) GetSendEnabled

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

GetSendEnabled retrieves the send enabled boolean from the paramstore

func (Keeper) GetVoucherClassID

func (k Keeper) GetVoucherClassID(ctx sdk.Context, classID string) (string, error)

func (Keeper) HasClassTrace

func (k Keeper) HasClassTrace(ctx sdk.Context, classTraceHash tmbytes.HexBytes) bool

HasClassTrace checks if a the key with the given denomination trace hash exists on the store.

func (Keeper) InitGenesis

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

InitGenesis initializes the ibc nft-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) IterateClassTraces

func (k Keeper) IterateClassTraces(ctx sdk.Context, cb func(_ types.ClassTrace) bool)

IterateClassTraces iterates over the class traces in the store and performs a callback function.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) MustMarshalClassTrace

func (k Keeper) MustMarshalClassTrace(classTrace types.ClassTrace) []byte

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

func (Keeper) MustUnmarshalClassTrace

func (k Keeper) MustUnmarshalClassTrace(bz []byte) types.ClassTrace

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

func (Keeper) OnAcknowledgementPacket

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

OnAcknowledgementPacket responds to the the success or failure of a packet acknowledgement written on the receiving chain. If the acknowledgement was a success then nothing occurs. If the acknowledgement failed, then the sender is refunded their tokens using the refundPacketToken function.

func (Keeper) OnRecvPacket

func (k Keeper) OnRecvPacket(ctx sdk.Context, packet channeltypes.Packet,
	data types.NonFungibleTokenPacketData) error

OnRecvPacket processes a cross chain fungible token transfer. If the sender chain is the source of minted tokens then vouchers will be minted and sent to the receiving address. Otherwise if the sender chain is sending back tokens this chain originally transferred to it, the tokens are unescrowed and sent to the receiving address.

func (Keeper) OnTimeoutPacket

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

OnTimeoutPacket refunds the sender since the original packet sent was never received and has been timed out.

func (Keeper) Params

Params implements the Params gRPC method

func (Keeper) SendTransfer

func (k Keeper) SendTransfer(
	ctx sdk.Context,
	sourcePort,
	sourceChannel,
	classID string,
	tokenIDs []string,
	sender sdk.AccAddress,
	receiver string,
	timeoutHeight clienttypes.Height,
	timeoutTimestamp uint64,
	memo string,
) (uint64, error)

SendTransfer handles nft-transfer sending logic. A sending chain may be acting as a source or sink zone.

when a chain is sending tokens across a port and channel which are not equal to the last prefixed port and channel pair, it is acting as a source zone. when tokens are sent from a source zone, the destination port and channel will be prefixed onto the classId (once the tokens are received) adding another hop to the tokens record.

when a chain is sending tokens across a port and channel which are equal to the last prefixed port and channel pair, it is acting as a sink zone. when tokens are sent from a sink zone, the last prefixed port and channel pair on the classId is removed (once the tokens are received), undoing the last hop in the tokens record.

For example, assume these steps of transfer occur: A -> B -> C -> A -> C -> B -> A

| sender chain | receiver chain | | :-----: | -------------------------: | :------------: | :------------: | -------------------------: | :-----: | | chain | classID | (port,channel) | (port,channel) | classID | chain | | A | nftClass | (p1,c1) | (p2,c2) | p2/c2/nftClass | B | | B | p2/c2/nftClass | (p3,c3) | (p4,c4) | p4/c4/p2/c2/nftClass | C | | C | p4/c4/p2/c2/nftClass | (p5,c5) | (p6,c6) | p6/c6/p4/c4/p2/c2/nftClass | A | | A | p6/c6/p4/c4/p2/c2/nftClass | (p6,c6) | (p5,c5) | p4/c4/p2/c2/nftClass | C | | C | p4/c4/p2/c2/nftClass | (p4,c4) | (p3,c3) | p2/c2/nftClass | B | | B | p2/c2/nftClass | (p2,c2) | (p1,c1) | nftClass | A |

func (Keeper) SetClassTrace

func (k Keeper) SetClassTrace(ctx sdk.Context, classTrace types.ClassTrace)

SetClassTrace sets a new {trace hash -> class trace} pair to the store.

func (Keeper) SetEscrowAddress

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

SetEscrowAddress attempts to save a account to auth module

func (Keeper) SetParams

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

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 nft-transfer module. Used in InitGenesis

func (Keeper) Transfer

func (k Keeper) Transfer(goCtx context.Context, msg *types.MsgTransfer) (*types.MsgTransferResponse, error)

Transfer defines a rpc handler method for MsgTransfer.

func (Keeper) UnmarshalClassTrace

func (k Keeper) UnmarshalClassTrace(bz []byte) (types.ClassTrace, error)

UnmarshalClassTrace attempts to decode and return an ClassTrace object from raw encoded bytes.

func (Keeper) UpdateParams

UpdateParams defines a governance operation for updating the nft-transfer module parameters. The authority is defined in the keeper.

Jump to

Keyboard shortcuts

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