client

package
v1.3.3 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 30 Imported by: 6

Documentation

Index

Constants

View Source
const (
	ChainTypeStafi    = "stafi"
	ChainTypePolkadot = "polkadot"

	AddressTypeAccountId    = "AccountId"
	AddressTypeMultiAddress = "MultiAddress"
)
View Source
const (
	RFIS   = RSymbol("RFIS")
	RDOT   = RSymbol("RDOT")
	RKSM   = RSymbol("RKSM")
	RATOM  = RSymbol("RATOM")
	RSOL   = RSymbol("RSOL")
	RMATIC = RSymbol("RMATIC")
	RBNB   = RSymbol("RBNB")
	RETH   = RSymbol("RETH")
)

Variables

View Source
var (
	ErrorTerminated           = errors.New("terminated")
	ErrorBondEqualToUnbond    = errors.New("ErrorBondEqualToUnbond")
	ErrorDiffSmallerThanLeast = errors.New("ErrorDiffSmallerThanLeast")
	ErrorValueNotExist        = errors.New("value not exist")
)
View Source
var (
	ErrValueNotStringSlice = errors.New("value not string slice")
	ErrValueNotString      = errors.New("value not string")
	ErrValueNotFloat       = errors.New("value not float64")
	ErrValueNotMap         = errors.New("value not map")
	ErrValueNotU32         = errors.New("value not u32")
)

Functions

func ParseVecBytes added in v1.3.3

func ParseVecBytes(value interface{}) ([]types.Bytes, error)

func TransformHasher added in v1.3.0

func TransformHasher(Hasher string) types.StorageHasherV10

Types

type AccountInfo added in v1.3.3

type AccountInfo struct {
	Nonce     uint32
	Consumers uint32
	Providers uint32
	Data      struct {
		Free       types.U128
		Reserved   types.U128
		MiscFrozen types.U128
		FreeFrozen types.U128
	}
}

multiaddress account info

type BondingDuration added in v1.3.3

type BondingDuration struct {
	Symbol      RSymbol
	OldDuration types.U32
	NewDuration types.U32
}

/// symbol, old_bonding_duration, new_bonding_duration BondingDurationUpdated(RSymbol, u32, u32),

func EventBondingDurationData added in v1.3.3

func EventBondingDurationData(evt *ChainEvent) (*BondingDuration, error)

type Burned added in v1.3.3

type Burned struct {
	From   types.AccountID
	Symbol RSymbol
	Value  types.U128
}

func EventBurnedData added in v1.3.3

func EventBurnedData(evt *ChainEvent) (*Burned, error)

type ChainEvent added in v1.3.3

type ChainEvent struct {
	ModuleId       string             `json:"module_id" `
	EventId        string             `json:"event_id" `
	EventIndex     int                `json:"event_idx"`
	ExtrinsicIndex int                `json:"extrinsic_idx"`
	Params         []scale.EventParam `json:"params"`
}

type ChainExtrinsic added in v1.3.0

type ChainExtrinsic struct {
	ID                 uint            `gorm:"primary_key"`
	ExtrinsicIndex     string          `json:"extrinsic_index" sql:"default: null;size:100"`
	BlockNum           int             `json:"block_num" `
	BlockTimestamp     int             `json:"block_timestamp"`
	ExtrinsicLength    string          `json:"extrinsic_length"`
	VersionInfo        string          `json:"version_info"`
	CallCode           string          `json:"call_code"`
	CallModuleFunction string          `json:"call_module_function"  sql:"size:100"`
	CallModule         string          `json:"call_module"  sql:"size:100"`
	Params             interface{}     `json:"params" sql:"type:MEDIUMTEXT;" `
	AccountId          string          `json:"account_id"`
	Signature          string          `json:"signature"`
	Nonce              int             `json:"nonce"`
	Era                string          `json:"era"`
	ExtrinsicHash      string          `json:"extrinsic_hash" sql:"default: null" `
	IsSigned           bool            `json:"is_signed"`
	Success            bool            `json:"success"`
	Fee                decimal.Decimal `json:"fee" sql:"type:decimal(30,0);"`
	BatchIndex         int             `json:"-" gorm:"-"`
}

type Era added in v1.3.3

type Era struct {
	Type  string `json:"type"`
	Value uint32 `json:"value"`
}

type EraPayout added in v1.3.3

type EraPayout struct {
	EraIndex types.U32
	Balance  types.U128
	Balance2 types.U128
}

/ \[era_index, validator_payout, remainder\] EraPayout(EraIndex, Balance, Balance),

func EventEraPayoutData added in v1.3.3

func EventEraPayoutData(evt *ChainEvent) (*EraPayout, error)

type EraUpdated added in v1.3.3

type EraUpdated struct {
	Symbol RSymbol
	OldEra uint32
	NewEra uint32
}

func EventEraUpdatedData added in v1.3.3

func EventEraUpdatedData(evt *ChainEvent) (*EraUpdated, error)

type EventMultisigExecuted added in v1.3.3

type EventMultisigExecuted struct {
	Who, ID     types.AccountID
	TimePoint   types.TimePoint
	CallHash    types.Hash
	CallHashStr string
	Result      bool
}

func EventMultisigExecutedData added in v1.3.3

func EventMultisigExecutedData(evt *ChainEvent) (*EventMultisigExecuted, error)

type EventNewMultisig added in v1.3.3

type EventNewMultisig struct {
	Who, ID     types.AccountID
	CallHash    types.Hash
	CallHashStr string
	TimePoint   *OptionTimePoint
	Approvals   []types.AccountID
}

func EventNewMultisigData added in v1.3.3

func EventNewMultisigData(evt *ChainEvent) (*EventNewMultisig, error)

type EvtExecuteBondAndSwap added in v1.3.2

type EvtExecuteBondAndSwap struct {
	AccountId     types.AccountID
	Symbol        RSymbol
	BondId        types.Hash
	Amount        types.U128
	DestRecipient types.Bytes
	DestId        types.U8
}

func ParseLiquidityBondAndSwapEvent added in v1.3.2

func ParseLiquidityBondAndSwapEvent(evt *ChainEvent) (*EvtExecuteBondAndSwap, error)

type GetLatestDealBLockParam added in v1.3.3

type GetLatestDealBLockParam struct {
	Symbol RSymbol
	Block  chan uint64
}

type GetSignaturesKey added in v1.3.3

type GetSignaturesKey struct {
	Block      uint64
	ProposalId types.Bytes
}

type GetSignaturesParam added in v1.3.3

type GetSignaturesParam struct {
	Symbol     RSymbol
	Block      uint64
	ProposalId []byte
	Signatures chan []types.Bytes
}

type GsrpcClient added in v1.3.0

type GsrpcClient struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func NewGsrpcClient added in v1.3.0

func NewGsrpcClient(chainType, endpoint, typesPath, addressType string, key *signature.KeyringPair, log Logger, stop <-chan int) (*GsrpcClient, error)

func (*GsrpcClient) AccountInfo added in v1.3.0

func (sc *GsrpcClient) AccountInfo(who []byte) (*types.AccountInfo, error)

func (*GsrpcClient) Act added in v1.3.3

func (c *GsrpcClient) Act(sym RSymbol, cycle uint32) (*MintRewardAct, error)

func (*GsrpcClient) ActLatestCycle added in v1.3.3

func (c *GsrpcClient) ActLatestCycle(sym RSymbol) (uint32, error)

func (*GsrpcClient) Address added in v1.3.0

func (sc *GsrpcClient) Address() string

func (*GsrpcClient) CurrentChainEra added in v1.3.3

func (c *GsrpcClient) CurrentChainEra(sym RSymbol) (uint32, error)

func (*GsrpcClient) CurrentEra added in v1.3.3

func (c *GsrpcClient) CurrentEra() (uint32, error)

func (*GsrpcClient) CurrentEraSnapshots added in v1.3.3

func (c *GsrpcClient) CurrentEraSnapshots(symbol RSymbol) ([]types.Hash, error)

func (*GsrpcClient) ExistentialDeposit added in v1.3.0

func (sc *GsrpcClient) ExistentialDeposit() (types.U128, error)

func (*GsrpcClient) FindCallIndex added in v1.3.0

func (sc *GsrpcClient) FindCallIndex(call string) (types.CallIndex, error)

func (*GsrpcClient) FindStorageEntryMetadata added in v1.3.0

func (sc *GsrpcClient) FindStorageEntryMetadata(module string, fn string) (types.StorageEntryMetadata, error)

func (*GsrpcClient) FlashApi added in v1.3.0

func (sc *GsrpcClient) FlashApi() (*gsrpc.RPCS, error)

func (*GsrpcClient) FreeBalance added in v1.3.0

func (sc *GsrpcClient) FreeBalance(who []byte) (types.U128, error)

func (*GsrpcClient) GetAccountInfo added in v1.3.0

func (sc *GsrpcClient) GetAccountInfo() (*types.AccountInfo, error)

func (*GsrpcClient) GetBlock added in v1.3.0

func (sc *GsrpcClient) GetBlock(blockHash string) (*rpc.Block, error)

func (*GsrpcClient) GetBlockHash added in v1.3.0

func (sc *GsrpcClient) GetBlockHash(blockNum uint64) (string, error)

func (*GsrpcClient) GetBlockNumber added in v1.3.0

func (sc *GsrpcClient) GetBlockNumber(blockHash types.Hash) (uint64, error)

func (*GsrpcClient) GetBlockTimestampAndExtrinsics added in v1.3.3

func (sc *GsrpcClient) GetBlockTimestampAndExtrinsics(height uint64) (uint64, map[int]*Transaction, error)

func (*GsrpcClient) GetChainEvents added in v1.3.0

func (sc *GsrpcClient) GetChainEvents(blockHash string) ([]*ChainEvent, error)

func (*GsrpcClient) GetConst added in v1.3.0

func (sc *GsrpcClient) GetConst(prefix, name string, res interface{}) error

func (*GsrpcClient) GetEraRate added in v1.3.3

func (sc *GsrpcClient) GetEraRate(symbol RSymbol, era uint32) (rate uint64, err error)

func (*GsrpcClient) GetEvents added in v1.3.0

func (sc *GsrpcClient) GetEvents(blockNum uint64) ([]*ChainEvent, error)

func (*GsrpcClient) GetExtrinsics added in v1.3.0

func (sc *GsrpcClient) GetExtrinsics(blockHash string) ([]*Transaction, error)

func (*GsrpcClient) GetFinalizedBlockNumber added in v1.3.0

func (sc *GsrpcClient) GetFinalizedBlockNumber() (uint64, error)

func (*GsrpcClient) GetFinalizedHead added in v1.3.0

func (sc *GsrpcClient) GetFinalizedHead() (types.Hash, error)

func (*GsrpcClient) GetHeader added in v1.3.0

func (sc *GsrpcClient) GetHeader(blockHash types.Hash) (*types.Header, error)

func (*GsrpcClient) GetHeaderLatest added in v1.3.0

func (sc *GsrpcClient) GetHeaderLatest() (*types.Header, error)

func (*GsrpcClient) GetLatestBlockNumber added in v1.3.0

func (sc *GsrpcClient) GetLatestBlockNumber() (uint64, error)

func (*GsrpcClient) GetLatestNonce added in v1.3.0

func (sc *GsrpcClient) GetLatestNonce() (types.U32, error)

func (*GsrpcClient) GetLatestRuntimeVersion added in v1.3.0

func (sc *GsrpcClient) GetLatestRuntimeVersion() (*types.RuntimeVersion, error)

func (*GsrpcClient) GetPaymentQueryInfo added in v1.3.0

func (sc *GsrpcClient) GetPaymentQueryInfo(encodedExtrinsic string) (paymentInfo *rpc.PaymentQueryInfo, err error)

func (*GsrpcClient) NewUnsignedExtrinsic added in v1.3.0

func (sc *GsrpcClient) NewUnsignedExtrinsic(callMethod string, args ...interface{}) (interface{}, error)

func (*GsrpcClient) NewVersionAccountInfo added in v1.3.0

func (sc *GsrpcClient) NewVersionAccountInfo(who []byte) (*AccountInfo, error)

func (*GsrpcClient) PublicKey added in v1.3.0

func (sc *GsrpcClient) PublicKey() []byte

func (*GsrpcClient) QueryStorage added in v1.3.0

func (sc *GsrpcClient) QueryStorage(prefix, method string, arg1, arg2 []byte, result interface{}) (bool, error)

queryStorage performs a storage lookup. Arguments may be nil, result must be a pointer.

func (*GsrpcClient) REthActLatestCycle added in v1.3.3

func (c *GsrpcClient) REthActLatestCycle() (uint32, error)

func (*GsrpcClient) RethAct added in v1.3.3

func (c *GsrpcClient) RethAct(cycle uint32) (*MintRewardAct, error)

func (*GsrpcClient) SignAndSubmitTx added in v1.3.0

func (sc *GsrpcClient) SignAndSubmitTx(ext interface{}) error

func (*GsrpcClient) SingleTransferTo added in v1.3.1

func (sc *GsrpcClient) SingleTransferTo(accountId []byte, value types.UCompact) error

func (*GsrpcClient) StakingLedger added in v1.3.0

func (sc *GsrpcClient) StakingLedger(ac types.AccountID) (*StakingLedger, error)

type Logger added in v1.3.0

type Logger interface {
	// Log a message at the given level with context key/value pairs
	Trace(msg string, ctx ...interface{})
	Debug(msg string, ctx ...interface{})
	Info(msg string, ctx ...interface{})
	Warn(msg string, ctx ...interface{})
	Error(msg string, ctx ...interface{})
}

func NewLog added in v1.3.0

func NewLog(field ...interface{}) Logger

type MintRewardAct added in v1.3.3

type MintRewardAct struct {
	Begin                  types.U32
	End                    types.U32
	Cycle                  types.U32
	RewardRate             types.U128
	TotalReward            types.U128
	LeftAmount             types.U128
	UserLimit              types.U128
	LockedBlocks           types.U32
	TotalRtokenAmount      types.U128
	TotalNativeTokenAmount types.U128
}

type Minted added in v1.3.3

type Minted struct {
	To     types.AccountID
	Symbol RSymbol
	Value  types.U128
}

func EventMintedData added in v1.3.3

func EventMintedData(evt *ChainEvent) (*Minted, error)

type MultiCallParam added in v1.3.3

type MultiCallParam struct {
	TimePoint *OptionTimePoint
	Opaque    []byte
	Extrinsic string
	CallHash  string
}

type MultiEventFlow added in v1.3.3

type MultiEventFlow struct {
	EventId         string
	Symbol          RSymbol
	EventData       interface{}
	Block           uint64
	Index           uint32
	Threshold       uint16
	SubAccounts     []types.Bytes
	Key             *signature.KeyringPair
	Others          []types.AccountID
	OpaqueCalls     []*MultiOpaqueCall
	PaymentInfo     *rpc.PaymentQueryInfo
	NewMulCallHashs map[string]bool
	MulExeCallHashs map[string]bool
}

type MultiOpaqueCall added in v1.3.3

type MultiOpaqueCall struct {
	Extrinsic string
	Opaque    []byte
	CallHash  string
	TimePoint *OptionTimePoint
}

type Multisig added in v1.3.3

type Multisig struct {
	When      types.TimePoint
	Deposit   types.U128
	Depositor types.AccountID
	Approvals []types.AccountID
}

type OptionTimePoint added in v1.3.3

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

func NewOptionTimePoint added in v1.3.3

func NewOptionTimePoint(value types.TimePoint) *OptionTimePoint

func NewOptionTimePointEmpty added in v1.3.3

func NewOptionTimePointEmpty() *OptionTimePoint

func (*OptionTimePoint) Decode added in v1.3.3

func (o *OptionTimePoint) Decode(decoder scale.Decoder) error

func (OptionTimePoint) Encode added in v1.3.3

func (o OptionTimePoint) Encode(encoder scale.Encoder) error

func (OptionTimePoint) IsNone added in v1.3.3

func (o OptionTimePoint) IsNone() bool

IsNone returns true if the value is missing

func (OptionTimePoint) IsSome added in v1.3.3

func (o OptionTimePoint) IsSome() bool

IsNone returns true if a value is present

func (*OptionTimePoint) SetNone added in v1.3.3

func (o *OptionTimePoint) SetNone()

SetNone removes a value and marks it as missing

func (*OptionTimePoint) SetSome added in v1.3.3

func (o *OptionTimePoint) SetSome(value types.TimePoint)

SetSome sets a value

type RFisUnbond added in v1.3.3

type RFisUnbond struct {
	From      types.AccountID
	Pool      types.Bytes
	Value     types.U128
	LeftValue types.U128
	Balance   types.U128
}

RawEvent::LiquidityUnBond(who, controller, value, left_value, balance)

func EventRFisUnbondData added in v1.3.3

func EventRFisUnbondData(evt *ChainEvent) (*RFisUnbond, error)

type RSymbol added in v1.3.3

type RSymbol string

func (*RSymbol) Decode added in v1.3.3

func (r *RSymbol) Decode(decoder scale.Decoder) error

func (RSymbol) Encode added in v1.3.3

func (r RSymbol) Encode(encoder scale.Encoder) error

func (RSymbol) ToRtokenType added in v1.3.3

func (r RSymbol) ToRtokenType() int8

used in db of rtoken-info

func (RSymbol) ToString added in v1.3.3

func (r RSymbol) ToString() string

type RateSet added in v1.3.3

type RateSet struct {
	Symbol RSymbol
	Rate   types.U64
}

RateSet(RSymbol, RateType)

func EventRateSetData added in v1.3.3

func EventRateSetData(evt *ChainEvent) (*RateSet, error)

type RdexAddLiquidity added in v1.3.3

type RdexAddLiquidity struct {
	From          types.AccountID
	Symbol        RSymbol
	FisAmount     types.U128
	RTokenAmount  types.U128
	NewTotalUnit  types.U128
	AddUnit       types.U128
	FisBalance    types.U128
	RTokenBalance types.U128
}

AddLiquidity: (account, symbol, fis amount, rToken amount, new total unit, add lp unit, fis balance, rtoken balance) AddLiquidity(AccountId, RSymbol, u128, u128, u128, u128, u128, u128),

func EventRdexAddLiquidityData added in v1.3.3

func EventRdexAddLiquidityData(evt *ChainEvent) (*RdexAddLiquidity, error)

type RdexRemoveLiquidity added in v1.3.3

type RdexRemoveLiquidity struct {
	From               types.AccountID
	Symbol             RSymbol
	RemoveUnit         types.U128
	SwapUnit           types.U128
	RemoveFisAmount    types.U128
	RemoveRTokenAmount types.U128
	InputIsFis         bool
	FisBalance         types.U128
	RTokenBalance      types.U128
}

RemoveLiquidity: (account, symbol, rm unit, swap unit, rm fis amount, rm rToken amount, input is fis, fis balance, rtoken balance) RemoveLiquidity(AccountId, RSymbol, u128, u128, u128, u128, bool, u128, u128),

func EventRdexRemoveLiquidityData added in v1.3.3

func EventRdexRemoveLiquidityData(evt *ChainEvent) (*RdexRemoveLiquidity, error)

type RdexSwap added in v1.3.3

type RdexSwap struct {
	From          types.AccountID
	Symbol        RSymbol
	InputAmount   types.U128
	OutputAmount  types.U128
	FeeAmount     types.U128
	InputIsFis    bool
	FisBalance    types.U128
	RTokenBalance types.U128
}

Swap: (account, symbol, input amount, output amount, fee amount, input is fis, fis balance, rtoken balance) Swap(AccountId, RSymbol, u128, u128, u128, bool, u128, u128),

func EventRdexSwapData added in v1.3.3

func EventRdexSwapData(evt *ChainEvent) (*RdexSwap, error)

type Receive added in v1.3.3

type Receive struct {
	Recipient []byte
	Value     types.UCompact
}

type StakingLedger added in v1.3.3

type StakingLedger struct {
	Stash          types.AccountID
	Total          types.UCompact
	Active         types.UCompact
	Unlocking      []UnlockChunk
	ClaimedRewards []uint32
}

type SubmitSignatureParams added in v1.3.3

type SubmitSignatureParams struct {
	Symbol     RSymbol
	Block      types.U64
	ProposalId types.Bytes
	Signature  types.Bytes
}

type TransInfo added in v1.3.3

type TransInfo struct {
	Account  types.AccountID
	Receiver []byte
	Value    types.U128
	IsDeal   bool `json:"is_deal"`
}

type TransInfoKey added in v1.3.3

type TransInfoKey struct {
	Symbol RSymbol
	Block  uint64
}

type TransInfoList added in v1.3.3

type TransInfoList struct {
	Block      uint64
	DestSymbol RSymbol
	List       []TransInfo
}

type TransInfoSingle added in v1.3.3

type TransInfoSingle struct {
	Block      uint64
	Index      uint32
	DestSymbol RSymbol
	Info       TransInfo
}

type TransResultWithBlock added in v1.3.3

type TransResultWithBlock struct {
	Symbol RSymbol
	Block  uint64
}

type TransResultWithIndex added in v1.3.3

type TransResultWithIndex struct {
	Symbol RSymbol
	Block  uint64
	Index  uint32
}

type Transaction added in v1.3.3

type Transaction struct {
	ExtrinsicHash  string
	CallModuleName string
	CallName       string
	Address        interface{}
	Params         []commonTypes.ExtrinsicParam
}

type Transfer added in v1.3.3

type Transfer struct {
	From   types.AccountID
	To     types.AccountID
	Symbol RSymbol
	Value  types.U128
}

func EventTransferData added in v1.3.3

func EventTransferData(evt *ChainEvent) (*Transfer, error)

type Unbond added in v1.3.3

type Unbond struct {
	From      types.AccountID
	Symbol    RSymbol
	Pool      types.Bytes
	Value     types.U128
	LeftValue types.U128
	Balance   types.U128
	Recipient types.Bytes
}

LiquidityUnBond(AccountId, RSymbol, Vec<u8>, u128, u128, u128, Vec<u8>), RawEvent::LiquidityUnBond(who, symbol, pool, value, left_value, balance, recipient)

func EventUnbondData added in v1.3.3

func EventUnbondData(evt *ChainEvent) (*Unbond, error)

type UnlockChunk added in v1.3.3

type UnlockChunk struct {
	Value types.UCompact
	Era   types.UCompact
}

Jump to

Keyboard shortcuts

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