kava

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2022 License: Apache-2.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// BeginBlockHashStart represents the first byte of the begin blocker tx hash
	BeginBlockHashStart = 0x0
	// EndBlockHashStart represents the first byte of the end blocker tx hash
	EndBlockHashStart = 0x1
)
View Source
const (
	// NodeVersion is the version of kava we are using
	NodeVersion = "v0.16.1"
	// Blockchain is always Kava
	Blockchain = "Kava"
	// HistoricalBalanceSupported is whether historical balance is supported.
	HistoricalBalanceSupported = true
	// IncludeMempoolCoins does not apply to rosetta-kava as it is not UTXO-based.
	IncludeMempoolCoins = false

	// SuccessStatus is the status of any
	// Kava operation considered successful.
	SuccessStatus = "success"
	// FailureStatus is the status of any
	// Kava operation considered unsuccessful.
	FailureStatus = "failure"

	// FeeOpType is used to reference fee operations
	FeeOpType = "fee"
	// TransferOpType is used to reference transfer operations
	TransferOpType = "transfer"
	// MintOpType is used to reference mint operations
	MintOpType = "mint"
	// BurnOpType is used to reference burn operations
	BurnOpType = "burn"

	// AccLiquid represents spendable coins
	AccLiquid = "liquid"
	// AccLiquidDelegated represents delgated spendable coins
	AccLiquidDelegated = "liquid_delegated"
	// AccLiquidUnbonding represents unbonding spendable coins
	AccLiquidUnbonding = "liquid_unbonding"
	// AccVesting represents vesting (non-spendable) coins
	AccVesting = "vesting"
	// AccVestingDelegated represents vesting coins that are delegated
	AccVestingDelegated = "vesting_delegated"
	// AccVestingUnbonding represents vesting coins that are unbonding
	AccVestingUnbonding = "vesting_unbonding"
)

Variables

View Source
var (
	// OperationTypes are all suppoorted operation types.
	OperationTypes = []string{
		FeeOpType,
		TransferOpType,
		MintOpType,
		BurnOpType,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*types.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     FailureStatus,
			Successful: false,
		},
	}

	// CallMethods are all supported call methods.
	CallMethods = []string{}

	// BalanceExemptions lists sub-accounts that are balance exempt
	BalanceExemptions = []*types.BalanceExemption{
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccLiquid),
			ExemptionType:     types.BalanceDynamic,
		},
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccVesting),
			ExemptionType:     types.BalanceDynamic,
		},
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccLiquidDelegated),
			ExemptionType:     types.BalanceDynamic,
		},
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccVestingDelegated),
			ExemptionType:     types.BalanceDynamic,
		},
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccLiquidUnbonding),
			ExemptionType:     types.BalanceDynamic,
		},
		&types.BalanceExemption{
			SubAccountAddress: strToPtr(AccVestingUnbonding),
			ExemptionType:     types.BalanceDynamic,
		},
	}
)
View Source
var Currencies = map[string]*types.Currency{
	"ukava": &types.Currency{
		Symbol:   "KAVA",
		Decimals: 6,
	},
	"hard": &types.Currency{
		Symbol:   "HARD",
		Decimals: 6,
	},
	"swp": &types.Currency{
		Symbol:   "SWP",
		Decimals: 6,
	},
	"usdx": &types.Currency{
		Symbol:   "USDX",
		Decimals: 6,
	},
}

Currencies represents supported kava denom to rosetta currencies

View Source
var Denoms = map[string]string{
	"KAVA": "ukava",
	"HARD": "hard",
	"SWP":  "swp",
	"USDX": "usdx",
}

Denoms represents rosetta symbol to kava denom conversion

Functions

func BeginBlockTxHash

func BeginBlockTxHash(blockHash []byte) string

BeginBlockTxHash caluclates the begin blocker transaction hash

func EndBlockTxHash

func EndBlockTxHash(blockHash []byte) string

EndBlockTxHash caluclates the end blocker transaction hash

func EventToOperations

func EventToOperations(event sdk.StringEvent, status *string, index int64) []*types.Operation

EventToOperations returns rosetta operations from a abci block event

func EventsToOperations

func EventsToOperations(events sdk.StringEvents, status *string, index int64) []*types.Operation

EventsToOperations returns rosetta operations from abci block events

func FeeToOperations

func FeeToOperations(feePayer sdk.AccAddress, amount sdk.Coins, status *string, index int64) []*types.Operation

FeeToOperations returns rosetta operations from a transaction fee

func IsRetriableError added in v0.0.4

func IsRetriableError(err error) bool

IsRetriableError returns true if the error is retriable or temporary and may succeed on new attempt

func MsgToOperations

func MsgToOperations(msg sdk.Msg, log sdk.ABCIMessageLog, status *string, index int64) []*types.Operation

MsgToOperations returns rosetta operations for a cosmos sdk or kava message

func ParseABCIResult

func ParseABCIResult(result *ctypes.ResultABCIQuery, err error) ([]byte, error)

ParseABCIResult returns the Value of a ABCI Query

func TxToOperations

func TxToOperations(tx authsigning.Tx, events sdk.StringEvents, logs sdk.ABCIMessageLogs, feeStatus *string, opStatus *string) []*types.Operation

TxToOperations returns rosetta operations from a transaction

Types

type AccountBalanceService

type AccountBalanceService interface {
	GetCoinsAndSequenceForSubAccount(
		ctx context.Context,
		subAccount *types.SubAccountIdentifier,
	) (sdk.Coins, uint64, error)
}

AccountBalanceService provides an interface fetch a balance from an account subtype

type BalanceServiceFactory

type BalanceServiceFactory func(ctx context.Context, addr sdk.AccAddress, blockHeader *tmtypes.Header) (AccountBalanceService, error)

BalanceServiceFactory provides an interface for creating a balance service for specifc a account and block

func NewRPCBalanceFactory

func NewRPCBalanceFactory(rpc RPCClient) BalanceServiceFactory

NewRPCBalanceFactory returns a balance service factory that uses an RPCClient to get an accounts balance

type Client

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

Client implements services.Client interface for communicating with the kava chain

func NewClient

func NewClient(rpc RPCClient, balanceServiceFactory BalanceServiceFactory) (*Client, error)

NewClient initialized a new Client with the provided rpc client

func (*Client) Account

func (c *Client) Account(ctx context.Context, address sdk.AccAddress) (authtypes.AccountI, error)

Account returns the account for the provided address at the latest block height

func (*Client) Balance

func (c *Client) Balance(
	ctx context.Context,
	accountIdentifier *types.AccountIdentifier,
	blockIdentifier *types.PartialBlockIdentifier,
	currencies []*types.Currency,
) (*types.AccountBalanceResponse, error)

Balance fetches and returns the account balance for an account

func (*Client) Block

func (c *Client) Block(
	ctx context.Context,
	blockIdentifier *types.PartialBlockIdentifier,
) (*types.BlockResponse, error)

Block returns rosetta block for an index or hash

func (*Client) EstimateGas

func (c *Client) EstimateGas(ctx context.Context, tx authsigning.Tx, adjustment float64) (uint64, error)

EstimateGas returns a gas wanted estimate from a tx with a provided adjustment

func (*Client) PostTx

func (c *Client) PostTx(ctx context.Context, txBytes []byte) (*types.TransactionIdentifier, error)

PostTx broadcasts a transaction and returns an error if it does not get into mempool

func (*Client) Status

Status fetches latest status from a kava node and returns the results

type HTTPClient

type HTTPClient struct {
	*tmhttp.HTTP
	// contains filtered or unexported fields
}

HTTPClient extends the tendermint http client to enable finding blocks by hash

func NewHTTPClient

func NewHTTPClient(remote string) (*HTTPClient, error)

NewHTTPClient returns a new HTTPClient with additional capabilities

func (*HTTPClient) Account

func (c *HTTPClient) Account(ctx context.Context, addr sdk.AccAddress, height int64) (authtypes.AccountI, error)

Account returns the Account for a given address

func (*HTTPClient) Balance

func (c *HTTPClient) Balance(ctx context.Context, addr sdk.AccAddress, height int64) (sdk.Coins, error)

Balance returns the Balance for a given address

func (*HTTPClient) Delegations

func (c *HTTPClient) Delegations(ctx context.Context, addr sdk.AccAddress, height int64) (stakingtypes.DelegationResponses, error)

Delegations returns the delegations for an acc address

func (*HTTPClient) SimulateTx

func (c *HTTPClient) SimulateTx(ctx context.Context, tx authsigning.Tx) (*sdk.SimulationResponse, error)

SimulateTx simulates a transaction and returns the response containing the gas used and result

func (*HTTPClient) UnbondingDelegations

func (c *HTTPClient) UnbondingDelegations(ctx context.Context, addr sdk.AccAddress, height int64) (stakingtypes.UnbondingDelegations, error)

UnbondingDelegations returns the unbonding delegations for an address

type RPCClient

type RPCClient interface {
	tmclient.Client

	Account(ctx context.Context, addr sdk.AccAddress, height int64) (authtypes.AccountI, error)
	Balance(ctx context.Context, addr sdk.AccAddress, height int64) (sdk.Coins, error)
	Delegations(ctx context.Context, addr sdk.AccAddress, height int64) (stakingtypes.DelegationResponses, error)
	UnbondingDelegations(ctx context.Context, addr sdk.AccAddress, height int64) (stakingtypes.UnbondingDelegations, error)
	SimulateTx(ctx context.Context, tx authsigning.Tx) (*sdk.SimulationResponse, error)
}

RPCClient represents a tendermint http client with ability to get block by hash

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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