topup

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: GPL-3.0 Imports: 22 Imported by: 0

README

Topup module

Table of Contents

Overview

Heimdall Topup is an amount which will be used to pay fees on Heimdall chain.

There are two ways to top up your account:

  1. When new validator joins, they can mention a topup amount as top-up in addition to the staked amount, which will be moved as balance on Heimdall chain to pay fees on Heimdall.
  2. A user can directly call the top-up function on the staking smart contract on Ethereum to increase top-up balance on Heimdall.

Messages

MsgTopupTx

MsgTopupTx is responsible for minting balance to an address on Heimdall based on Ethereum chain's TopUpEvent on staking manager contract.

Handler for this transaction processes top-up and increases the balance only once for any given msg.TxHash and msg.LogIndex. It throws an error if trying to process the top-up more than once.

Here is the structure for the top-up transaction message:

message MsgTopupTx {
   string proposer = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
   string user = 2 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];
   string fee = 3 [
      (gogoproto.customtype) = "cosmossdk.io/math.Int",
      (gogoproto.nullable) = false
   ];
   bytes tx_hash = 4;
   uint64 log_index = 5;
   uint64 block_number = 6;
}
MsgWithdrawFeeTx

MsgWithdrawFeeTx is responsible for withdrawing balance from Heimdall to Ethereum chain. A Validator can withdraw any amount from Heimdall.

Handler processes the withdrawal by deducting the balance from the given validator and prepares the state to send the next checkpoint. The next possible checkpoint will contain the withdrawal related state for the specific validator.

Handler gets validator information based on ValidatorAddress and processes the withdrawal.

message MsgWithdrawFeeTx {
   string proposer = 1;
   string amount = 3 [
      (gogoproto.customtype) = "cosmossdk.io/math.Int",
      (gogoproto.nullable) = false
   ];
}

Interact with the Node

Tx Commands
Topup fee
./build/heimdalld tx topup handle-topup-tx [proposer] [user] [fee] [tx_hash] [log_index] [block_number]
Withdraw fee
./build/heimdalld tx topup withdraw-fee [proposer] [amount]
CLI Query Commands

One can run the following query commands from the topup module:

  • topup-sequence - Query the sequence of a topup tx
  • is-old-tx - Check if a tx is old (already submitted)
  • dividend-account - Query a dividend account by its address
  • dividend-account-root - Query dividend account root hash
  • account-proof - Query account proof
  • verify-account-proof - Verify account proof
./build/heimdalld query topup topup-sequence [tx_hash] [log_index]
./build/heimdalld query topup is-old-tx [tx_hash] [log_index]
./build/heimdalld query topup dividend-account [address]
./build/heimdalld query topup dividend-account-root
./build/heimdalld query topup account-proof [address]
./build/heimdalld query topup verify-account-proof [address] [proof]
GRPC Endpoints

The endpoints and the params are defined in the topup/query.proto file. Please refer them for more information about the optional params.

grpcurl -plaintext -d '{"tx_hash": <>, "log_index": <>}' localhost:9090 heimdallv2.topup.Query/GetTopupTxSequence
grpcurl -plaintext -d '{"tx_hash": <>, "log_index": <>}' localhost:9090 heimdallv2.topup.Query/IsTopupTxOld
grpcurl -plaintext -d '{"address": <>}' localhost:9090 heimdallv2.topup.Query/GetDividendAccountByAddress
grpcurl -plaintext -d '{}' localhost:9090 heimdallv2.topup.Query/GetDividendAccountRootHash
grpcurl -plaintext -d '{"address": <>}' localhost:9090 heimdallv2.topup.Query/GetAccountProofByAddress
grpcurl -plaintext -d '{"address": <>, "proof": <>}' localhost:9090 heimdallv2.topup.Query/VerifyAccountProofByAddress
REST APIs

The endpoints and the params are defined in the topup/query.proto file. Please refer them for more information about the optional params.

curl localhost:1317/topup/sequence?tx_hash=<tx-hash>&log_index=<log-index>
curl localhost:1317/topup/isoldtx?tx_hash=<tx-hash>&log_index=<log-index>
curl localhost:1317/topup/dividend-account/{address}
curl localhost:1317/topup/dividend-account-root
curl localhost:1317/topup/account-proof/{address}
curl localhost:1317/topup/account-proof/{address}/verify

Documentation

Index

Constants

View Source
const ConsensusVersion = 1

ConsensusVersion defines the current x/topup module consensus version.

Variables

This section is empty.

Functions

This section is empty.

Types

type AppModule

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

AppModule implements an application module for the topup module.

func NewAppModule

func NewAppModule(keeper keeper.Keeper, contractCaller helper.ContractCaller) AppModule

NewAppModule creates a new AppModule object

func (AppModule) AutoCLIOptions

func (am AppModule) AutoCLIOptions() *autocliv1.ModuleOptions

AutoCLIOptions returns the auto cli options for the module (query and tx)

func (AppModule) ConsensusVersion

func (AppModule) ConsensusVersion() uint64

ConsensusVersion implements AppModule/ConsensusVersion.

func (AppModule) DefaultGenesis

func (AppModule) DefaultGenesis(cdc codec.JSONCodec) json.RawMessage

DefaultGenesis returns default genesis state as raw bytes for the x/topup module.

func (AppModule) ExportGenesis

func (am AppModule) ExportGenesis(ctx sdk.Context, cdc codec.JSONCodec) json.RawMessage

ExportGenesis returns the exported genesis state as raw bytes for the x/topup module.

func (AppModule) GenerateGenesisState

func (am AppModule) GenerateGenesisState(simState *module.SimulationState)

GenerateGenesisState creates a randomized GenState of the x/topup module.

func (AppModule) InitGenesis

func (am AppModule) InitGenesis(ctx sdk.Context, cdc codec.JSONCodec, data json.RawMessage)

InitGenesis performs genesis initialization for the x/topup module.

func (AppModule) IsAppModule

func (am AppModule) IsAppModule()

IsAppModule implements the appmodule.AppModule interface.

func (AppModule) IsOnePerModuleType

func (am AppModule) IsOnePerModuleType()

IsOnePerModuleType implements the depinject.OnePerModuleType interface.

func (AppModule) Name

func (AppModule) Name() string

Name returns the x/topup module's name.

func (AppModule) QuerierRoute

func (AppModule) QuerierRoute() string

QuerierRoute returns the stake module's querier route name.

func (AppModule) RegisterGRPCGatewayRoutes

func (AppModule) RegisterGRPCGatewayRoutes(clientCtx client.Context, mux *gwruntime.ServeMux)

RegisterGRPCGatewayRoutes registers the gRPC Gateway routes for the x/topup module.

func (AppModule) RegisterInterfaces

func (AppModule) RegisterInterfaces(registry codectypes.InterfaceRegistry)

RegisterInterfaces registers interfaces and implementations of the x/topup module.

func (AppModule) RegisterLegacyAminoCodec

func (AppModule) RegisterLegacyAminoCodec(cdc *codec.LegacyAmino)

RegisterLegacyAminoCodec registers the x/topup module's types on the LegacyAmino codec.

func (AppModule) RegisterServices

func (am AppModule) RegisterServices(cfg module.Configurator)

RegisterServices registers module services.

func (AppModule) RegisterSideMsgServices

func (am AppModule) RegisterSideMsgServices(sideCfg sidetxs.SideTxConfigurator)

RegisterSideMsgServices registers side handler module services.

func (AppModule) RegisterStoreDecoder

func (am AppModule) RegisterStoreDecoder(_ simulation.StoreDecoderRegistry)

RegisterStoreDecoder registers a decoder for x/topup module's types

func (AppModule) ValidateGenesis

func (AppModule) ValidateGenesis(cdc codec.JSONCodec, _ client.TxEncodingConfig, bz json.RawMessage) error

ValidateGenesis performs genesis state validation for the x/topup module.

func (AppModule) WeightedOperations

func (am AppModule) WeightedOperations(_ module.SimulationState) []simulation.WeightedOperation

WeightedOperations returns the all the gov module operations with their respective weights.

Directories

Path Synopsis
Package testutil is a generated GoMock package.
Package testutil is a generated GoMock package.
Package types is a reverse proxy.
Package types is a reverse proxy.

Jump to

Keyboard shortcuts

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