keeper

package
v0.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var UNIVERSAL_PAYLOAD_TYPEHASH = common.HexToHash("0x1d8b43e5066bd20bfdacf7b8f4790c0309403b18434e3699ce3c5e57502ed8c4")

Functions

func AbiArgumentsForPayload

func AbiArgumentsForPayload() abi.Arguments

AbiArgumentsForPayload returns the abi.Arguments for encoding a UniversalPayload struct

func NewMsgServerImpl

func NewMsgServerImpl(keeper Keeper) types.MsgServer

NewMsgServerImpl returns an implementation of the module MsgServer interface

Types

type Keeper

type Keeper struct {
	Params collections.Item[types.Params]

	// Inbound trackers
	PendingInbounds collections.KeySet[string]

	// UniversalTx collection
	UniversalTx collections.Map[string, types.UniversalTx]

	// Module account manual nonce
	ModuleAccountNonce collections.Item[uint64]

	// GasPrices collection stores aggregated gas price data for each chain
	GasPrices collections.Map[string, types.GasPrice]
	// contains filtered or unexported fields
}

func NewKeeper

func NewKeeper(
	cdc codec.BinaryCodec,
	storeService storetypes.KVStoreService,
	logger log.Logger,
	authority string,
	evmKeeper types.EVMKeeper,
	feemarketKeeper types.FeeMarketKeeper,
	bankKeeper types.BankKeeper,
	accountKeeper types.AccountKeeper,
	uregistryKeeper types.UregistryKeeper,
	utxverifierKeeper types.UtxverifierKeeper,
	uvalidatorKeeper types.UValidatorKeeper,
) Keeper

NewKeeper creates a new Keeper instance

func (Keeper) AddPendingInbound

func (k Keeper) AddPendingInbound(ctx context.Context, inbound types.Inbound) error

AddPendingInbound adds an inbound synthetic to the pending set if not already present

func (Keeper) AllPendingInbounds

AllPendingInbounds implements types.QueryServer.

func (Keeper) CalculateGasCost

func (k Keeper) CalculateGasCost(
	baseFee sdkmath.LegacyDec,
	maxFeePerGas *big.Int,
	maxPriorityFeePerGas *big.Int,
	gasUsed uint64,
) (*big.Int, error)

CalculateGasCost calculates the gas cost based on EIP-1559 fee mechanism: 1. Effective Gas Price = min(maxFeePerGas, baseFee + maxPriorityFeePerGas) 2. Total Fee = gasUsed × Effective Gas Price Parameters: - baseFee: current network base fee - maxFeePerGas: maximum total fee user is willing to pay - maxPriorityFeePerGas: maximum tip to validator - gasUsed: amount of gas consumed

func (Keeper) CallFactoryToDeployUEA

func (k Keeper) CallFactoryToDeployUEA(
	ctx sdk.Context,
	from, factoryAddr common.Address,
	universalAccount *types.UniversalAccountId,
) (*evmtypes.MsgEthereumTxResponse, error)

CallFactoryToDeployUEA deploys a new UEA using factory contract Returns deployment response or error if deployment fails

func (Keeper) CallFactoryToGetUEAAddressForOrigin

func (k Keeper) CallFactoryToGetUEAAddressForOrigin(
	ctx sdk.Context,
	from, factoryAddr common.Address,
	universalAccount *types.UniversalAccountId,
) (common.Address, bool, error)

CallFactoryToGetUEAAddressForOrigin calls FactoryV1.getUEAForOrigin(...)

func (Keeper) CallPRC20Deposit

func (k Keeper) CallPRC20Deposit(
	ctx sdk.Context,
	prc20Address, to common.Address,
	amount *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

Calls Handler Contract to deposit prc20 tokens

func (Keeper) CallPRC20DepositAutoSwap

func (k Keeper) CallPRC20DepositAutoSwap(
	ctx sdk.Context,
	prc20Address, to common.Address,
	amount *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

Calls Handler Contract to deposit prc20 tokens

func (Keeper) CallUEADomainSeparator

func (k Keeper) CallUEADomainSeparator(
	ctx sdk.Context,
	from, ueaAddr common.Address,
) ([32]byte, error)

CallUEADomainSeparator fetches the domainSeparator from the UEA contract

func (Keeper) CallUEAExecutePayload

func (k Keeper) CallUEAExecutePayload(
	ctx sdk.Context,
	from, ueaAddr common.Address,
	universal_payload *types.UniversalPayload,
	verificationData []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallUEAExecutePayload executes a universal payload through UEA

func (Keeper) CallUEAMigrateUEA

func (k Keeper) CallUEAMigrateUEA(
	ctx sdk.Context,
	from, ueaAddr common.Address,
	migration_payload *types.MigrationPayload,
	signature []byte,
) (*evmtypes.MsgEthereumTxResponse, error)

CallUEAMigrateUEA migrates UEA through existing UEA

func (Keeper) CallUniversalCoreSetGasPrice

func (k Keeper) CallUniversalCoreSetGasPrice(
	ctx sdk.Context,
	chainID string,
	price *big.Int,
) (*evmtypes.MsgEthereumTxResponse, error)

Calls UniversalCore Contract to set gas price

func (Keeper) CreateUniversalTx

func (k Keeper) CreateUniversalTx(ctx context.Context, key string, utx types.UniversalTx) error

CreateUniversalTx stores a new UniversalTx

func (Keeper) DeductAndBurnFees

func (k Keeper) DeductAndBurnFees(ctx context.Context, from sdk.AccAddress, gasCost *big.Int) error

DeductAndBurnFees deducts gas fees from the user's smart account and burns them. The process happens in two steps: 1. Transfer coins from user account to module account 2. Burn coins from module account Returns error if either transfer or burn fails

func (Keeper) DeployUEA

func (k Keeper) DeployUEA(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId) ([]byte, error)

updateParams is for updating params collections of the module

func (Keeper) DeployUEAV2

func (k Keeper) DeployUEAV2(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId) (*evmtypes.MsgEthereumTxResponse, error)

updateParams is for updating params collections of the module

func (Keeper) ExecuteInbound

func (k Keeper) ExecuteInbound(ctx context.Context, utx types.UniversalTx) error

func (Keeper) ExecuteInboundFunds

func (k Keeper) ExecuteInboundFunds(ctx context.Context, utx types.UniversalTx) error

func (Keeper) ExecuteInboundFundsAndPayload

func (k Keeper) ExecuteInboundFundsAndPayload(ctx context.Context, utx types.UniversalTx) error

func (Keeper) ExecuteInboundGas

func (k Keeper) ExecuteInboundGas(ctx context.Context, inbound types.Inbound) error

func (Keeper) ExecuteInboundGasAndPayload

func (k Keeper) ExecuteInboundGasAndPayload(ctx context.Context, utx types.UniversalTx) error

func (Keeper) ExecutePayload

func (k Keeper) ExecutePayload(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, universalPayload *types.UniversalPayload, verificationData string) error

updateParams is for updating params collections of the module

func (Keeper) ExecutePayloadV2

func (k Keeper) ExecutePayloadV2(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, universalPayload *types.UniversalPayload, verificationData string) (*vmtypes.MsgEthereumTxResponse, error)

updateParams is for updating params collections of the module

func (*Keeper) ExportGenesis

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

ExportGenesis exports the module's state to a genesis state.

func (Keeper) GetGasPrice

func (k Keeper) GetGasPrice(ctx context.Context, chainID string) (types.GasPrice, bool, error)

func (Keeper) GetModuleAccountNonce

func (k Keeper) GetModuleAccountNonce(ctx sdk.Context) (uint64, error)

GetModuleAccountNonce returns the current module account nonce. If not set yet, it safely defaults to 0.

func (Keeper) GetPayloadHashEVM

func (k Keeper) GetPayloadHashEVM(
	ctx sdk.Context,
	from, ueaAddr common.Address,
	payload types.AbiUniversalPayload,
) (common.Hash, error)

GetPayloadHashEVM computes the EIP-712 style payload hash using the UEA contract's domainSeparator

func (*Keeper) GetUeModuleAddress

func (k *Keeper) GetUeModuleAddress(ctx context.Context) (common.Address, string)

func (Keeper) GetUniversalTx

func (k Keeper) GetUniversalTx(ctx context.Context, key string) (types.UniversalTx, bool, error)

GetUniversalTx retrieves a UniversalTx by key, returns (value, found, error)

func (Keeper) GetUniversalTxStatus

func (k Keeper) GetUniversalTxStatus(ctx context.Context, key string) (types.UniversalTxStatus, bool, error)

GetUniversalTxStatus retrieves the status of a UniversalTx

func (Keeper) HasUniversalTx

func (k Keeper) HasUniversalTx(ctx context.Context, key string) (bool, error)

HasUniversalTx checks if a UniversalTx exists

func (Keeper) IncrementModuleAccountNonce

func (k Keeper) IncrementModuleAccountNonce(ctx sdk.Context) (uint64, error)

IncrementModuleAccountNonce increases the nonce by 1 and stores it back.

func (*Keeper) InitGenesis

func (k *Keeper) InitGenesis(ctx context.Context, data *types.GenesisState) error

InitGenesis initializes the module's state from a genesis state.

func (Keeper) IsPendingInbound

func (k Keeper) IsPendingInbound(ctx context.Context, inbound types.Inbound) (bool, error)

IsPendingInbound checks if an inbound synthetic is pending

func (Keeper) Logger

func (k Keeper) Logger() log.Logger

func (Keeper) MigrateUEA

func (k Keeper) MigrateUEA(ctx context.Context, evmFrom common.Address, universalAccountId *types.UniversalAccountId, migrationPayload *types.MigrationPayload, signature string) error

updateParams is for updating params collections of the module

func (Keeper) MintPCTokensDirectly

func (k Keeper) MintPCTokensDirectly(ctx sdk.Context, recipient sdk.AccAddress, amount sdkmath.Int) error

TODO: temporary don't use in any fn

func (Keeper) RemovePendingInbound

func (k Keeper) RemovePendingInbound(ctx context.Context, inbound types.Inbound) error

RemovePendingInbound removes an inbound synthetic from the pending set

func (Keeper) SchemaBuilder

func (k Keeper) SchemaBuilder() *collections.SchemaBuilder

func (Keeper) SetGasPrice

func (k Keeper) SetGasPrice(ctx context.Context, chainID string, gasPrice types.GasPrice) error

func (Keeper) SetModuleAccountNonce

func (k Keeper) SetModuleAccountNonce(ctx sdk.Context, nonce uint64) error

SetModuleAccountNonce allows explicitly setting the nonce (optional, for migration or testing).

func (Keeper) StoreVerifiedPayloadHash

func (k Keeper) StoreVerifiedPayloadHash(
	ctx sdk.Context,
	utx types.UniversalTx,
	ueaAddr common.Address,
	ueModuleAccAddress common.Address,
) error

StoreVerifiedPayloadHash stores one payload hash for a given inbound tx

func (Keeper) UpdateParams

func (k Keeper) UpdateParams(ctx context.Context, params types.Params) error

updateParams is for updating params collections of the module

func (Keeper) UpdateUniversalTx

func (k Keeper) UpdateUniversalTx(
	ctx context.Context,
	key string,
	updateFn func(*types.UniversalTx) error,
) error

UpdateUniversalTx updates an existing UniversalTx in the store. It fetches the UniversalTx, applies the update function, and saves it back.

func (Keeper) UpdateUniversalTxStatus

func (k Keeper) UpdateUniversalTxStatus(ctx context.Context, key string, newStatus types.UniversalTxStatus) error

UpdateUniversalTxStatus sets a new status for the UniversalTx

func (Keeper) VoteGasPrice

func (k Keeper) VoteGasPrice(ctx context.Context, universalValidator sdk.ValAddress, observedChainId string, price, blockNumber uint64) error

func (Keeper) VoteInbound

func (k Keeper) VoteInbound(ctx context.Context, universalValidator sdk.ValAddress, inbound types.Inbound) error

voteInbound is for uvalidators for voting on synthetic asset inbound bridging

func (Keeper) VoteOnInboundBallot

func (k Keeper) VoteOnInboundBallot(
	ctx context.Context,
	universalValidator sdk.ValAddress,
	inbound types.Inbound,
) (isFinalized bool,
	isNew bool,
	err error)

type Querier

type Querier struct {
	Keeper
}

func NewQuerier

func NewQuerier(keeper Keeper) Querier

func (Querier) AllGasPrices

AllGasPrices implements types.QueryServer.

func (Querier) AllUniversalTx

AllUniversalTx implements types.QueryServer.

func (Querier) GasPrice

GasPrice implements types.QueryServer.

func (Querier) GetUniversalTx

GetUniversalTx implements types.QueryServer.

func (Querier) Params

Jump to

Keyboard shortcuts

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