keeper

package
v10.0.0-beta.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: MIT Imports: 27 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Keeper

type Keeper struct {
	AuthKeeper types.AccountKeeper
	BankKeeper types.BankKeeper
	// contains filtered or unexported fields
}

Keeper defines the IBC fungible transfer keeper

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService corestore.KVStoreService,
	legacySubspace types.ParamSubspace,
	ics4Wrapper porttypes.ICS4Wrapper,
	channelKeeper types.ChannelKeeper,
	authKeeper types.AccountKeeper,
	bankKeeper types.BankKeeper,
	authority string,
) Keeper

NewKeeper creates a new IBC transfer Keeper instance

func (Keeper) Denom

Denom implements the Query/Denom gRPC method

func (Keeper) DenomHash

DenomHash implements the Query/DenomHash gRPC method

func (Keeper) Denoms

Denoms implements the Query/Denoms gRPC method

func (Keeper) EscrowAddress

EscrowAddress implements the EscrowAddress gRPC method

func (Keeper) EscrowCoin

func (k Keeper) EscrowCoin(ctx sdk.Context, sender, escrowAddress sdk.AccAddress, coin sdk.Coin) error

EscrowCoin will send the given coin from the provided sender to the escrow address. It will also update the total escrowed amount by adding the escrowed coin's amount to the current total escrow.

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

func (k Keeper) GetAllDenoms(ctx sdk.Context) types.Denoms

GetAllDenoms returns all the denominations.

func (Keeper) GetAllTotalEscrowed

func (k Keeper) GetAllTotalEscrowed(ctx sdk.Context) sdk.Coins

GetAllTotalEscrowed returns the escrow information for all the denominations.

func (Keeper) GetAuthority

func (k Keeper) GetAuthority() string

GetAuthority returns the transfer module's authority.

func (Keeper) GetDenom

func (k Keeper) GetDenom(ctx sdk.Context, denomHash cmtbytes.HexBytes) (types.Denom, bool)

GetDenom retrieves the denom from store given the hash of the denom.

func (Keeper) GetICS4Wrapper

func (k Keeper) GetICS4Wrapper() porttypes.ICS4Wrapper

GetICS4Wrapper returns the ICS4Wrapper.

func (Keeper) GetParams

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

GetParams returns the current transfer module parameters.

func (Keeper) GetPort

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

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

func (Keeper) GetTotalEscrowForDenom

func (k Keeper) GetTotalEscrowForDenom(ctx sdk.Context, denom string) sdk.Coin

GetTotalEscrowForDenom gets the total amount of source chain tokens that are in escrow, keyed by the denomination.

NOTE: if there is no value stored in state for the provided denom then a new Coin is returned for the denom with an initial value of zero. This accommodates callers to simply call `Add()` on the returned Coin as an empty Coin literal (e.g. sdk.Coin{}) will trigger a panic due to the absence of a denom.

func (Keeper) HasDenom

func (k Keeper) HasDenom(ctx sdk.Context, denomHash cmtbytes.HexBytes) bool

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

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

func (k Keeper) IsBlockedAddr(addr sdk.AccAddress) bool

IsBlockedAddr checks if the given address is allowed to send or receive tokens. The module account is always allowed to send and receive tokens.

func (Keeper) IterateDenoms

func (k Keeper) IterateDenoms(ctx sdk.Context, cb func(denom types.Denom) bool)

IterateDenoms iterates over the denominations in the store and performs a callback function.

func (Keeper) IterateTokensInEscrow

func (k Keeper) IterateTokensInEscrow(ctx sdk.Context, storeprefix []byte, cb func(denomEscrow sdk.Coin) bool)

IterateTokensInEscrow iterates over the denomination escrows in the store and performs a callback function. Denominations for which an invalid value (i.e. not integer) is stored, will be skipped.

func (Keeper) Logger

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

Logger returns a module-specific logger.

func (Keeper) OnAcknowledgementPacket

func (k Keeper) OnAcknowledgementPacket(
	ctx sdk.Context,
	sourcePort string,
	sourceChannel string,
	data types.FungibleTokenPacketDataV2,
	ack channeltypes.Acknowledgement,
) error

OnAcknowledgementPacket responds to the success or failure of a packet acknowledgment written on the receiving chain.

If the acknowledgement was a success then nothing occurs. Otherwise, if the acknowledgement failed, then the sender is refunded their tokens.

func (Keeper) OnRecvPacket

func (k Keeper) OnRecvPacket(
	ctx sdk.Context,
	data types.FungibleTokenPacketDataV2,
	sourcePort string,
	sourceChannel string,
	destPort string,
	destChannel string,
) 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,
	sourcePort string,
	sourceChannel string,
	data types.FungibleTokenPacketDataV2,
) error

OnTimeoutPacket processes a transfer packet timeout by refunding the tokens to the sender

func (Keeper) Params

Params implements the Query/Params gRPC method

func (Keeper) SendTransfer

func (k Keeper) SendTransfer(
	ctx sdk.Context,
	sourcePort,
	sourceChannel string,
	token types.Token,
	sender sdk.AccAddress,
) error

SendTransfer handles transfer sending logic. There are 2 possible cases:

1. Sender chain is acting as the source zone. The coins are transferred to an escrow address (i.e locked) on the sender chain and then transferred to the receiving chain through IBC TAO logic. It is expected that the receiving chain will mint vouchers to the receiving address.

2. Sender chain is acting as the sink zone. The coins (vouchers) are burned on the sender chain and then transferred to the receiving chain though IBC TAO logic. It is expected that the receiving chain, which had previously sent the original denomination, will unescrow the fungible token and send it to the receiving address.

Another way of thinking of source and sink zones is through the token's timeline. Each send to any chain other than the one it was previously received from is a movement forwards in the token's timeline. This causes trace to be added to the token's history and the destination port and destination channel to be prefixed to the denomination. In these instances the sender chain is acting as the source zone. When the token is sent back to the chain it previously received from, the prefix is removed. This is a backwards movement in the token's timeline and the sender chain is acting as the sink zone.

Example: These steps of transfer occur: A -> B -> C -> A -> C -> B -> A

1. A -> B : sender chain is source zone. Denom upon receiving: 'B/denom' 2. B -> C : sender chain is source zone. Denom upon receiving: 'C/B/denom' 3. C -> A : sender chain is source zone. Denom upon receiving: 'A/C/B/denom' 4. A -> C : sender chain is sink zone. Denom upon receiving: 'C/B/denom' 5. C -> B : sender chain is sink zone. Denom upon receiving: 'B/denom' 6. B -> A : sender chain is sink zone. Denom upon receiving: 'denom'

func (Keeper) SetDenom

func (k Keeper) SetDenom(ctx sdk.Context, denom types.Denom)

SetDenom sets a new {denom hash -> denom } pair to the store. This allows for reverse lookup of the denom given the hash.

func (Keeper) SetDenomMetadata

func (k Keeper) SetDenomMetadata(ctx sdk.Context, denom types.Denom)

SetDenomMetadata sets an IBC token's denomination metadata

func (Keeper) SetParams

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

SetParams sets the transfer module parameters.

func (Keeper) SetPort

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

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

func (Keeper) SetTotalEscrowForDenom

func (k Keeper) SetTotalEscrowForDenom(ctx sdk.Context, coin sdk.Coin)

SetTotalEscrowForDenom stores the total amount of source chain tokens that are in escrow. Amount is stored in state if and only if it is not equal to zero. The function will panic if the amount is negative.

func (Keeper) TokenFromCoin

func (k Keeper) TokenFromCoin(ctx sdk.Context, coin sdk.Coin) (types.Token, error)

tokenFromCoin constructs an IBC token given an SDK coin.

func (Keeper) TotalEscrowForDenom

TotalEscrowForDenom implements the TotalEscrowForDenom gRPC method.

func (Keeper) Transfer

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

Transfer defines an rpc handler method for MsgTransfer.

func (Keeper) UnescrowCoin

func (k Keeper) UnescrowCoin(ctx sdk.Context, escrowAddress, receiver sdk.AccAddress, coin sdk.Coin) error

UnescrowCoin will send the given coin from the escrow address to the provided receiver. It will also update the total escrow by deducting the unescrowed coin's amount from the current total escrow.

func (Keeper) UpdateParams

UpdateParams defines an rpc handler method for MsgUpdateParams. Updates the ibc-transfer module's parameters.

func (*Keeper) WithICS4Wrapper

func (k *Keeper) WithICS4Wrapper(wrapper porttypes.ICS4Wrapper)

WithICS4Wrapper sets the ICS4Wrapper. This function may be used after the keepers creation to set the middleware which is above this module in the IBC application stack.

type Migrator

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

Migrator is a struct for handling in-place store migrations.

func NewMigrator

func NewMigrator(keeper Keeper) Migrator

NewMigrator returns a new Migrator.

func (Migrator) MigrateDenomMetadata

func (m Migrator) MigrateDenomMetadata(ctx sdk.Context) error

MigrateDenomMetadata sets token metadata for all the IBC denom traces

func (Migrator) MigrateDenomTraceToDenom

func (m Migrator) MigrateDenomTraceToDenom(ctx sdk.Context) error

MigrateDenomTraceToDenom migrates storage from using DenomTrace to Denom.

func (Migrator) MigrateParams

func (m Migrator) MigrateParams(ctx sdk.Context) error

MigrateParams migrates the transfer module's parameters from the x/params to self store.

func (Migrator) MigrateTotalEscrowForDenom

func (m Migrator) MigrateTotalEscrowForDenom(ctx sdk.Context) error

MigrateTotalEscrowForDenom migrates the total amount of source chain tokens in escrow.

Jump to

Keyboard shortcuts

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