Documentation ¶
Overview ¶
Please put all the test related function to here
Index ¶
- Constants
- Variables
- func ConvertAndEncode(hrp string, data []byte) (string, error)
- func FromSdkCoins(c sdk.Coins) (common.Coins, error)
- func GetRandomBNBAddress() common.Address
- func GetRandomBech32Addr() sdk.AccAddress
- func GetRandomBech32ConsensusPubKey() string
- func GetRandomTxHash() common.TxID
- func HasMajority(signers, total int) bool
- func RandStringBytesMask(n int) string
- func RegisterCodec(cdc *codec.Codec)
- func SetupConfigForTest()
- type AdminConfig
- type AdminConfigKey
- type EmptyRefundEvent
- type Event
- type EventStake
- type EventStatus
- type EventSwap
- type EventUnstake
- type Events
- type MsgAck
- type MsgAdd
- type MsgBond
- type MsgEndPool
- type MsgLeave
- type MsgNextPoolAddress
- type MsgNoOp
- type MsgOutboundTx
- type MsgSetAdminConfig
- type MsgSetPoolData
- type MsgSetStakeData
- type MsgSetTrustAccount
- type MsgSetTxIn
- type MsgSetUnStake
- type MsgSetVersion
- type MsgSwap
- type NodeAccount
- type NodeAccounts
- func (nodeAccounts NodeAccounts) After(addr common.Address) NodeAccount
- func (nodeAccounts NodeAccounts) First() NodeAccount
- func (nodeAccounts NodeAccounts) IsTrustAccount(addr sdk.AccAddress) bool
- func (nodeAccounts NodeAccounts) Len() int
- func (nodeAccounts NodeAccounts) Less(i, j int) bool
- func (nodeAccounts NodeAccounts) Swap(i, j int)
- type NodeStatus
- type Pool
- type PoolAddresses
- type PoolIndex
- type PoolStaker
- type PoolStatus
- type QueryResHeights
- type QueryResPools
- type QueryResTxOut
- type ResTxOut
- type StakeTxDetail
- type StakerPool
- type StakerPoolItem
- type StakerUnit
- type TrustAccount
- type TrustAccounts
- type TxIn
- type TxInIndex
- type TxInVoter
- func (tx *TxInVoter) Add(txIn TxIn, signer sdk.AccAddress)
- func (tx *TxInVoter) Adds(txs []TxIn, signer sdk.AccAddress)
- func (tx TxInVoter) GetTx(nodeAccounts NodeAccounts) TxIn
- func (tx TxInVoter) HasConensus(nodeAccounts NodeAccounts) bool
- func (tx TxInVoter) Key() common.TxID
- func (tx *TxInVoter) SetDone(hash common.TxID)
- func (tx TxInVoter) String() string
- func (tx TxInVoter) Valid() error
- type TxOut
- type TxOutItem
- type ValidatorMeta
- type ValidatorsResp
Constants ¶
const ( // module pooldata ModuleName = "swapservice" // StoreKey to be used when creating the KVStore StoreKey = ModuleName RouterKey = ModuleName // this was defined in your key.go file )
const ( Incomplete status = "incomplete" Done status = "done" Reverted status = "reverted" )
const ( DefaultCodespace sdk.CodespaceType = ModuleName Majority float64 = 0.6666665 )
const MaxWithdrawBasisPoints = 10000
MaxWithdrawBasisPoints
Variables ¶
var ModuleCdc = codec.New()
Functions ¶
func ConvertAndEncode ¶
ConvertAndEncode converts from a base64 encoded byte string to base32 encoded byte string and then to bech32
func FromSdkCoins ¶
FromSdkCoins convert the sdk.Coins type to our own coin type
func GetRandomBNBAddress ¶
GetRandomBNBAddress will just create a random bnb address used for test purpose
func GetRandomBech32Addr ¶
func GetRandomBech32Addr() sdk.AccAddress
GetRandomBech32Addr is an account address used for test
func GetRandomBech32ConsensusPubKey ¶
func GetRandomBech32ConsensusPubKey() string
func GetRandomTxHash ¶
GetRandomTxHash create a random txHash used for test purpose
func HasMajority ¶
func RandStringBytesMask ¶
RandStringBytesMask generate random string used for test purpose
func RegisterCodec ¶
RegisterCodec registers concrete types on the Amino codec
Types ¶
type AdminConfig ¶
type AdminConfig struct { Key AdminConfigKey `json:"key"` Value string `json:"value"` Address sdk.AccAddress `json:"address"` }
func NewAdminConfig ¶
func NewAdminConfig(key AdminConfigKey, value string, address sdk.AccAddress) AdminConfig
func (AdminConfig) DbKey ¶
func (c AdminConfig) DbKey() string
func (AdminConfig) Empty ¶
func (c AdminConfig) Empty() bool
func (AdminConfig) String ¶
func (c AdminConfig) String() string
func (AdminConfig) Valid ¶
func (c AdminConfig) Valid() error
type AdminConfigKey ¶
type AdminConfigKey string
const ( UnknownKey AdminConfigKey = "Unknown" GSLKey AdminConfigKey = "GSL" StakerAmtIntervalKey AdminConfigKey = "StakerAmtInterval" MinValidatorBondKey AdminConfigKey = "MinValidatorBond" WhiteListGasTokenKey AdminConfigKey = "WhiteListGasToken" // How much gas token we mint and send it to the newly whitelisted bep address DesireValidatorSetKey AdminConfigKey = "DesireValidatorSet" // how much validators we would like to have RotatePerBlockHeightKey AdminConfigKey = "RotatePerBlockHeight" // how many blocks we try to rotate validators ValidatorsChangeWindowKey AdminConfigKey = "ValidatorsChangeWindow" // when should we open the rotate window, nominate validators, and identify who should be out )
func GetAdminConfigKey ¶
func GetAdminConfigKey(key string) AdminConfigKey
func (AdminConfigKey) Default ¶
func (k AdminConfigKey) Default() string
func (AdminConfigKey) IsValidKey ¶
func (k AdminConfigKey) IsValidKey() bool
func (AdminConfigKey) String ¶
func (k AdminConfigKey) String() string
func (AdminConfigKey) ValidValue ¶
func (k AdminConfigKey) ValidValue(value string) error
Ensure the value for a given key is a valid
type EmptyRefundEvent ¶
type EmptyRefundEvent struct { }
func NewEmptyRefundEvent ¶
func NewEmptyRefundEvent() EmptyRefundEvent
func (EmptyRefundEvent) Type ¶
func (e EmptyRefundEvent) Type() string
type Event ¶
type Event struct { ID common.Amount `json:"id"` Type string `json:"type"` InHash common.TxID `json:"in_hash"` OutHash common.TxID `json:"out_hash"` // Should we have timestamps and addresses if they are available via the // binance API? // InStamp time.Time `json:"in_timestamp"` // OutStamp time.Time `json:"out_timestamp"` // InAddress common.Address `json:"in_address"` // OutAddress common.Address `json:"out_address"` Pool common.Ticker `json:"pool"` Event json.RawMessage `json:"event"` Status EventStatus `json:"status"` }
type EventStake ¶
type EventStake struct { RuneAmount sdk.Uint `json:"rune_amount"` TokenAmount sdk.Uint `json:"token_amount"` StakeUnits sdk.Uint `json:"stake_units"` }
func NewEventStake ¶
func NewEventStake(r, t, s sdk.Uint) EventStake
func (EventStake) Type ¶
func (e EventStake) Type() string
type EventStatus ¶
type EventStatus uint8
const ( Success EventStatus = iota Refund Pending )
func (EventStatus) MarshalJSON ¶
func (es EventStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshal EventStatus to json
func (EventStatus) String ¶
func (es EventStatus) String() string
String implement fmt.Stringer, convert from EventStatus to string
func (*EventStatus) UnmarshalJSON ¶
func (es *EventStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON deserialize from json
func (EventStatus) Valid ¶
func (es EventStatus) Valid() error
Valid is to check whether the EventStatus is valid
type EventSwap ¶
type EventSwap struct { SourceCoin common.Coin `json:"source_coin"` TargetCoin common.Coin `json:"target_coin"` PriceSlip sdk.Uint `json:"price_slip"` TradeSlip sdk.Uint `json:"trade_slip"` PoolSlip sdk.Uint `json:"pool_slip"` OutputSlip sdk.Uint `json:"output_slip"` Fee sdk.Uint `json:"fee"` }
func NewEventSwap ¶
type EventUnstake ¶
type EventUnstake struct { RuneAmount sdk.Int `json:"rune_amount"` TokenAmount sdk.Int `json:"token_amount"` StakeUnits sdk.Int `json:"stake_units"` }
func NewEventUnstake ¶
func NewEventUnstake(r, t, s sdk.Uint) EventUnstake
func (EventUnstake) Type ¶
func (e EventUnstake) Type() string
type MsgAck ¶
MsgAck is used to confirm the next pool address
func (MsgAck) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgAck) GetSigners ¶
func (msg MsgAck) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgAck) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type MsgAdd ¶
type MsgAdd struct { Ticker common.Ticker `json:"symbol"` // ticker means the symbol TokenAmount sdk.Uint `json:"token"` // the amount of token RuneAmount sdk.Uint `json:"rune"` // the amount of rune TxID common.TxID `json:"tx_id"` // the txhash that represent user send token to our pool address Signer sdk.AccAddress `json:"signer"` }
MsgAdd defines a add message
func NewMsgAdd ¶
func NewMsgAdd(ticker common.Ticker, r, token sdk.Uint, requestTxHash common.TxID, signer sdk.AccAddress) MsgAdd
NewMsgAdd is a constructor function for MsgAdd
func (MsgAdd) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgAdd) GetSigners ¶
func (msg MsgAdd) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgAdd) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type MsgBond ¶
type MsgBond struct { NodeAddress sdk.AccAddress `json:"node_address"` Bond sdk.Uint `json:"bond"` BondAddress common.Address `json:"bond_address"` RequestTxHash common.TxID `json:"request_tx_hash"` // request tx hash on binance chain Signer sdk.AccAddress `json:"signer"` }
MsgBond when a user would like to become a validator, and run a full set, they need send an `apply:bepaddress` with a bond to our pool address
func NewMsgBond ¶
func NewMsgBond(nodeAddr sdk.AccAddress, bond sdk.Uint, requestTxHash common.TxID, bondAddress common.Address, signer sdk.AccAddress) MsgBond
NewMsgBond create new MsgBond message
func (MsgBond) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgBond) GetSigners ¶
func (msg MsgBond) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgBond) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type MsgEndPool ¶
type MsgEndPool struct { Ticker common.Ticker `json:"ticker"` Requester common.Address `json:"requester"` RequestTxHash common.TxID `json:"request_tx_hash"` // request tx hash on binance chain Signer sdk.AccAddress `json:"signer"` }
func NewMsgEndPool ¶
func NewMsgEndPool(ticker common.Ticker, request common.Address, requestTxHash common.TxID, signer sdk.AccAddress) MsgEndPool
NewMsgEndPool create a new instance MsgEndPool
func (MsgEndPool) GetSignBytes ¶
func (msg MsgEndPool) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgEndPool) GetSigners ¶
func (msg MsgEndPool) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgEndPool) Route ¶
func (msg MsgEndPool) Route() string
Route should return the router key of the module
func (MsgEndPool) ValidateBasic ¶
func (msg MsgEndPool) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgLeave ¶
type MsgLeave struct { RequestTxHash common.TxID `json:"request_tx_hash"` Sender common.Address `json:"sender"` Signer sdk.AccAddress `json:"signer"` }
MsgLeave when an operator don't want to be a validator anymore
func NewMsgLeave ¶
NewMsgLeave create a new instance of MsgLeave
func (MsgLeave) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgLeave) GetSigners ¶
func (msg MsgLeave) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgLeave) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type MsgNextPoolAddress ¶
type MsgNextPoolAddress struct { RequestTxHash common.TxID NextPoolAddr common.Address Sender common.Address Signer sdk.AccAddress }
MsgNextPoolAddress is used to set the pool address of the next
func NewMsgNextPoolAddress ¶
func NewMsgNextPoolAddress(requestTxHash common.TxID, nextPoolAddr common.Address, sender common.Address, signer sdk.AccAddress) MsgNextPoolAddress
NewMsgNextPoolAddress create a new instance of MsgNextPoolAddress
func (MsgNextPoolAddress) GetSignBytes ¶
func (msg MsgNextPoolAddress) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgNextPoolAddress) GetSigners ¶
func (msg MsgNextPoolAddress) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgNextPoolAddress) Route ¶
func (msg MsgNextPoolAddress) Route() string
Route should return the router key of the module
func (MsgNextPoolAddress) Type ¶
func (msg MsgNextPoolAddress) Type() string
Type should return the action
func (MsgNextPoolAddress) ValidateBasic ¶
func (msg MsgNextPoolAddress) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgNoOp ¶
type MsgNoOp struct {
Signer sdk.AccAddress `json:"signer"`
}
MsgNoOp defines a no op message
func NewMsgNoOp ¶
func NewMsgNoOp(signer sdk.AccAddress) MsgNoOp
NewMsgNoOp is a constructor function for MsgNoOp
func (MsgNoOp) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgNoOp) GetSigners ¶
func (msg MsgNoOp) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgNoOp) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type MsgOutboundTx ¶
type MsgOutboundTx struct { Height uint64 `json:"height"` TxID common.TxID `json:"tx_id"` Sender common.Address `json:"sender"` Signer sdk.AccAddress `json:"signer"` }
MsgOutboundTx defines a MsgOutboundTx message
func NewMsgOutboundTx ¶
func NewMsgOutboundTx(txID common.TxID, height uint64, sender common.Address, signer sdk.AccAddress) MsgOutboundTx
NewMsgOutboundTx is a constructor function for MsgOutboundTx
func (MsgOutboundTx) GetSignBytes ¶
func (msg MsgOutboundTx) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgOutboundTx) GetSigners ¶
func (msg MsgOutboundTx) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgOutboundTx) Route ¶
func (msg MsgOutboundTx) Route() string
Route should return the cmname of the module
func (MsgOutboundTx) ValidateBasic ¶
func (msg MsgOutboundTx) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetAdminConfig ¶
type MsgSetAdminConfig struct { AdminConfig AdminConfig `json:"admin_config"` Signer sdk.AccAddress `json:"signer"` }
MsgSetAdminConfig defines a MsgSetAdminConfig message
func NewMsgSetAdminConfig ¶
func NewMsgSetAdminConfig(key AdminConfigKey, value string, signer sdk.AccAddress) MsgSetAdminConfig
NewMsgSetAdminConfig is a constructor function for MsgSetAdminConfig
func (MsgSetAdminConfig) GetSignBytes ¶
func (msg MsgSetAdminConfig) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetAdminConfig) GetSigners ¶
func (msg MsgSetAdminConfig) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetAdminConfig) Route ¶
func (msg MsgSetAdminConfig) Route() string
Route should return the cmname of the module
func (MsgSetAdminConfig) Type ¶
func (msg MsgSetAdminConfig) Type() string
Type should return the action
func (MsgSetAdminConfig) ValidateBasic ¶
func (msg MsgSetAdminConfig) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetPoolData ¶
type MsgSetPoolData struct { BalanceRune sdk.Uint `json:"balance_rune"` // balance rune BalanceToken sdk.Uint `json:"balance_token"` // balance of token Ticker common.Ticker `json:"symbol"` // Ticker means the token symbol Status PoolStatus `json:"status"` // pool status Signer sdk.AccAddress `json:"signer"` }
MsgSetPoolData defines a SetPoolData message We keep this for now , as a mechanism to set up a new pool when it is not in the genesis file the pool changes when stake / swap happens
func NewMsgSetPoolData ¶
func NewMsgSetPoolData(ticker common.Ticker, status PoolStatus, signer sdk.AccAddress) MsgSetPoolData
NewMsgSetPoolData is a constructor function for MsgSetPoolData
func (MsgSetPoolData) GetSignBytes ¶
func (msg MsgSetPoolData) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetPoolData) GetSigners ¶
func (msg MsgSetPoolData) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetPoolData) Route ¶
func (msg MsgSetPoolData) Route() string
Route should return the pooldata of the module
func (MsgSetPoolData) ValidateBasic ¶
func (msg MsgSetPoolData) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetStakeData ¶
type MsgSetStakeData struct { Ticker common.Ticker `json:"symbol"` // ticker means the symbol TokenAmount sdk.Uint `json:"token"` // the amount of token stake RuneAmount sdk.Uint `json:"rune"` // the amount of rune stake PublicAddress common.Address `json:"public_address"` // Staker's address on binance chain RequestTxHash common.TxID `json:"request_tx_hash"` // the txhash that represent user send token to our pool address Signer sdk.AccAddress `json:"signer"` }
MsgSetStakeData defines a SetStakeData message
func NewMsgSetStakeData ¶
func NewMsgSetStakeData(ticker common.Ticker, r, token sdk.Uint, publicAddress common.Address, requestTxHash common.TxID, signer sdk.AccAddress) MsgSetStakeData
NewMsgSetStakeData is a constructor function for MsgSetStakeData
func (MsgSetStakeData) GetSignBytes ¶
func (msg MsgSetStakeData) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetStakeData) GetSigners ¶
func (msg MsgSetStakeData) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetStakeData) Route ¶
func (msg MsgSetStakeData) Route() string
Route should return the pooldata of the module
func (MsgSetStakeData) Type ¶
func (msg MsgSetStakeData) Type() string
Type should return the action
func (MsgSetStakeData) ValidateBasic ¶
func (msg MsgSetStakeData) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetTrustAccount ¶
type MsgSetTrustAccount struct { TrustAccount TrustAccount `json:"trust_account"` Signer sdk.AccAddress `json:"signer"` }
MsgSetTrustAccount defines a MsgSetTrustAccount message
func NewMsgSetTrustAccount ¶
func NewMsgSetTrustAccount(trustAccount TrustAccount, signer sdk.AccAddress) MsgSetTrustAccount
NewMsgSetTrustAccount is a constructor function for NewMsgAddTrustAccount
func (MsgSetTrustAccount) GetSignBytes ¶
func (msg MsgSetTrustAccount) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetTrustAccount) GetSigners ¶
func (msg MsgSetTrustAccount) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetTrustAccount) Route ¶
func (msg MsgSetTrustAccount) Route() string
Route should return the cmname of the module
func (MsgSetTrustAccount) Type ¶
func (msg MsgSetTrustAccount) Type() string
Type should return the action
func (MsgSetTrustAccount) ValidateBasic ¶
func (msg MsgSetTrustAccount) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetTxIn ¶
type MsgSetTxIn struct { TxIns []TxInVoter `json:"tx_votes"` Signer sdk.AccAddress `json:"signer"` }
MsgSetTxIn defines a MsgSetTxIn message
func NewMsgSetTxIn ¶
func NewMsgSetTxIn(txs []TxInVoter, signer sdk.AccAddress) MsgSetTxIn
NewMsgSetTxIn is a constructor function for MsgSetTxIn
func (MsgSetTxIn) GetSignBytes ¶
func (msg MsgSetTxIn) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetTxIn) GetSigners ¶
func (msg MsgSetTxIn) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetTxIn) Route ¶
func (msg MsgSetTxIn) Route() string
Route should return the cmname of the module
func (MsgSetTxIn) ValidateBasic ¶
func (msg MsgSetTxIn) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetUnStake ¶
type MsgSetUnStake struct { PublicAddress common.Address `json:"public_address"` // it should be the public address WithdrawBasisPoints sdk.Uint `json:"withdraw_basis_points"` // withdraw basis points Ticker common.Ticker `json:"symbol"` // ticker token symbol RequestTxHash common.TxID `json:"request_tx_hash"` // request tx hash on binance chain Signer sdk.AccAddress `json:"signer"` }
MsgSetUnStake is used to withdraw
func NewMsgSetUnStake ¶
func NewMsgSetUnStake(publicAddress common.Address, withdrawBasisPoints sdk.Uint, ticker common.Ticker, requestTxHash common.TxID, signer sdk.AccAddress) MsgSetUnStake
NewMsgSetUnStake is a constructor function for MsgSetPoolData
func (MsgSetUnStake) GetSignBytes ¶
func (msg MsgSetUnStake) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetUnStake) GetSigners ¶
func (msg MsgSetUnStake) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetUnStake) Route ¶
func (msg MsgSetUnStake) Route() string
Route should return the pooldata of the module
func (MsgSetUnStake) ValidateBasic ¶
func (msg MsgSetUnStake) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSetVersion ¶
type MsgSetVersion struct { Version int `json:"version"` Signer sdk.AccAddress `json:"signer"` }
MsgSetVersion defines a MsgSetVersion message
func NewMsgSetVersion ¶
func NewMsgSetVersion(version int, signer sdk.AccAddress) MsgSetVersion
NewMsgSetVersion is a constructor function for NewMsgSetVersion
func (MsgSetVersion) GetSignBytes ¶
func (msg MsgSetVersion) GetSignBytes() []byte
GetSignBytes encodes the message for signing
func (MsgSetVersion) GetSigners ¶
func (msg MsgSetVersion) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSetVersion) Route ¶
func (msg MsgSetVersion) Route() string
Route should return the cmname of the module
func (MsgSetVersion) ValidateBasic ¶
func (msg MsgSetVersion) ValidateBasic() sdk.Error
ValidateBasic runs stateless checks on the message
type MsgSwap ¶
type MsgSwap struct { RequestTxHash common.TxID `json:"request_tx_hash"` // Request transaction hash on Binance chain SourceTicker common.Ticker `json:"source_symbol"` // source token TargetTicker common.Ticker `json:"target_symbol"` // target token Requester common.Address `json:"requester"` // request address on Binance chain Destination common.Address `json:"destination"` // destination , used for swap and send , the destination address we send it to Amount sdk.Uint `json:"amount"` // amount of token to swap TargetPrice sdk.Uint `json:"target_price"` Signer sdk.AccAddress `json:"signer"` }
MsgSwap defines a MsgSwap message
func NewMsgSwap ¶
func NewMsgSwap(requestTxHash common.TxID, source, target common.Ticker, amount sdk.Uint, requester, destination common.Address, targetPrice sdk.Uint, signer sdk.AccAddress) MsgSwap
NewMsgSwap is a constructor function for MsgSwap
func (MsgSwap) GetSignBytes ¶
GetSignBytes encodes the message for signing
func (MsgSwap) GetSigners ¶
func (msg MsgSwap) GetSigners() []sdk.AccAddress
GetSigners defines whose signature is required
func (MsgSwap) ValidateBasic ¶
ValidateBasic runs stateless checks on the message
type NodeAccount ¶
type NodeAccount struct { NodeAddress sdk.AccAddress `json:"node_address"` Status NodeStatus `json:"status"` Accounts TrustAccount `json:"accounts"` Bond sdk.Uint `json:"bond"` BondAddress common.Address `json:"bond_address"` // start from when this node account is in current status // StatusSince field is important , it has been used to sort node account , used for validator rotation StatusSince int64 `json:"status_since"` ObserverActive bool `json:"observer_active"` SignerActive bool `json:"signer_active"` Version common.Amount `json:"version"` }
NodeAccount represent node
func GetRandomNodeAccount ¶
func GetRandomNodeAccount(status NodeStatus) NodeAccount
GetRandomNodeAccount create a random generated node account , used for test purpose
func NewNodeAccount ¶
func NewNodeAccount(nodeAddress sdk.AccAddress, status NodeStatus, accounts TrustAccount, bond sdk.Uint, bondAddress common.Address) NodeAccount
NewNodeAccount create new instance of NodeAccount
func (NodeAccount) Equals ¶
func (n NodeAccount) Equals(n1 NodeAccount) bool
Equals compare two node account, to see whether they are equal
func (NodeAccount) IsEmpty ¶
func (n NodeAccount) IsEmpty() bool
IsEmpty decide whether NodeAccount is empty
func (NodeAccount) IsValid ¶
func (n NodeAccount) IsValid() error
IsValid check whether NodeAccount has all necessary values
func (NodeAccount) String ¶
func (n NodeAccount) String() string
String implement fmt.Stringer interface
func (*NodeAccount) UpdateStatus ¶
func (n *NodeAccount) UpdateStatus(status NodeStatus)
UpdateStatus change the status of node account, in the mean time update StatusSince field
type NodeAccounts ¶
type NodeAccounts []NodeAccount
NodeAccounts just a list of NodeAccount
func (NodeAccounts) After ¶
func (nodeAccounts NodeAccounts) After(addr common.Address) NodeAccount
func (NodeAccounts) First ¶
func (nodeAccounts NodeAccounts) First() NodeAccount
First return the first item in the slice
func (NodeAccounts) IsTrustAccount ¶
func (nodeAccounts NodeAccounts) IsTrustAccount(addr sdk.AccAddress) bool
IsTrustAccount validate whether the given account address is an observer address
func (NodeAccounts) Len ¶
func (nodeAccounts NodeAccounts) Len() int
func (NodeAccounts) Less ¶
func (nodeAccounts NodeAccounts) Less(i, j int) bool
func (NodeAccounts) Swap ¶
func (nodeAccounts NodeAccounts) Swap(i, j int)
type NodeStatus ¶
type NodeStatus uint8
NodeStatus Represent the Node status
const ( Unknown NodeStatus = iota WhiteListed Standby Ready Active Disabled )
As soon as user donate a certain amount of token(defined later) their node adddress will be whitelisted once we discover their observer had send tx in to statechain , then their status will be standby once we rotate them in , then they will be active
func (NodeStatus) MarshalJSON ¶
func (ps NodeStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshal NodeStatus to JSON in string form
func (*NodeStatus) UnmarshalJSON ¶
func (ps *NodeStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON convert string form back to NodeStatus
func (NodeStatus) Valid ¶
func (ps NodeStatus) Valid() error
type Pool ¶
type Pool struct { BalanceRune sdk.Uint `json:"balance_rune"` // how many RUNE in the pool BalanceToken sdk.Uint `json:"balance_token"` // how many token in the pool Ticker common.Ticker `json:"symbol"` // what's the token's ticker PoolUnits sdk.Uint `json:"pool_units"` // total units of the pool PoolAddress common.Address `json:"pool_address"` // bnb liquidity pool address Status PoolStatus `json:"status"` // status ExpiryInBlockHeight int64 `json:"expiry_in_block_height"` // means the pool address will be changed after these amount of blocks }
Pool is a struct that contains all the metadata of a pooldata This is the structure we will saved to the key value store
func (Pool) EnsureValidPoolStatus ¶
EnsureValidPoolStatus
func (Pool) TokenPriceInRune ¶
TokenPriceInRune is how much 1 token worth in RUNE
type PoolAddresses ¶
type PoolAddresses struct { Previous common.Address `json:"previous"` Current common.Address `json:"current"` Next common.Address `json:"next"` RotateAt int64 `json:"rotate_at"` }
func NewPoolAddresses ¶
func NewPoolAddresses(previous, current, next common.Address, rotateAt int64) PoolAddresses
NewPoolAddresses create a new instance of PoolAddress
func (PoolAddresses) IsEmpty ¶
func (pa PoolAddresses) IsEmpty() bool
IsEmpty check whether PoolAddress is empty
type PoolStaker ¶
type PoolStaker struct { Ticker common.Ticker `json:"symbol"` // ticker TotalUnits sdk.Uint `json:"total_units"` // total units in the pool Stakers []StakerUnit `json:"stakers"` // key will be staker id , which is the address on binane chain value will be UNITS }
PoolStaker
{ "p_id":"pool-BNB", "tu" : "1000", "ss" : { "bnbStaker-1":"100",, "bnbStaker-2":"100" } }
func NewPoolStaker ¶
func NewPoolStaker(ticker common.Ticker, totalUnits sdk.Uint) PoolStaker
NewPoolStaker create a new instance of PoolStaker
func (*PoolStaker) GetStakerUnit ¶
func (ps *PoolStaker) GetStakerUnit(stakerID common.Address) StakerUnit
func (*PoolStaker) RemoveStakerUnit ¶
func (ps *PoolStaker) RemoveStakerUnit(stakerID common.Address)
RemoveStakerUnit will remove the stakerunit with given staker id from the struct
func (PoolStaker) String ¶
func (ps PoolStaker) String() string
String return the human readable string of PoolStaker
func (*PoolStaker) UpsertStakerUnit ¶
func (ps *PoolStaker) UpsertStakerUnit(stakerUnit StakerUnit)
UpsertStakerUnit it check whether the given staker unit is exist in the struct if it exist then just update it , otherwise it append it
func (PoolStaker) Valid ¶
func (ps PoolStaker) Valid() error
type PoolStatus ¶
type PoolStatus int
PoolStatus is an indication of what the pool state is
const ( Enabled PoolStatus = iota Bootstrap Suspended )
| State | ADMIN-MEMO | Swapping | Staking | Withdrawing | Refunding | | ------ | ------ | ------ | ------ | ------ | ------ | | `bootstrap` | `ADMIN:POOL:BOOTSTRAP` | no | yes | yes | Refund Invalid Stakes && all Swaps | | `enabled` | `ADMIN:POOL:ENABLE` | yes | yes | yes | Refund Invalid Tx | | `suspended` | `ADMIN:POOL:SUSPEND` | no | no | no | Refund all |
func (PoolStatus) MarshalJSON ¶
func (ps PoolStatus) MarshalJSON() ([]byte, error)
MarshalJSON marshal PoolStatus to JSON in string form
func (*PoolStatus) UnmarshalJSON ¶
func (ps *PoolStatus) UnmarshalJSON(b []byte) error
UnmarshalJSON convert string form back to PoolStatus
func (PoolStatus) Valid ¶
func (ps PoolStatus) Valid() error
type QueryResHeights ¶
type QueryResHeights struct { LastBinanceHeight sdk.Uint `json:"lastobservedin"` LastSignedHeight sdk.Uint `json:"lastsignedout"` Statechain int64 `json:"statechain"` }
func (QueryResHeights) String ¶
func (h QueryResHeights) String() string
type QueryResTxOut ¶
type StakeTxDetail ¶
type StakeTxDetail struct { RequestTxHash common.TxID `json:"request_tx_hash"` // the tx hash from binance chain , represent staker send token to the pool RuneAmount sdk.Uint `json:"rune_amount"` // amount of rune that send in at the time TokenAmount sdk.Uint `json:"token_amount"` // amount of token that send in at the time }
StakeTxDetail represent all the stake activity Staker can stake on the same pool for multiple times
type StakerPool ¶
type StakerPool struct { StakerID common.Address `json:"staker_id"` // this will be staker's address on binance chain PoolUnits []*StakerPoolItem `json:"pool_and_units"` // the key of this map will be the pool id , value will bt [UNIT,RUNE,TOKEN] }
StakerPool represent staker and their activities in the pools A staker can stake on multiple pool. A Staker can stake on the same pool for multiple times json representation will be looking like
{ "staker_id": "bnbxasdfaswqerqwe", "pool_and_units": [ { "symbol": "BNB", "units": "200", "stake_details": [ { "request_tx_hash": "txhash from binance chain", "rune_amount": "100", "token_amount": "100" }, { "request_tx_hash": "another hash", "rune_amount": "100", "token_amount": "100" } ] }, { "symbol": "BTC", "units": "200", "stake_details": [ { "request_tx_hash": "txhash from binance chain", "rune_amount": "100", "token_amount": "100" }, { "request_tx_hash": "another hash", "rune_amount": "100", "token_amount": "100" } ] } ] }
func NewStakerPool ¶
func NewStakerPool(id common.Address) StakerPool
NewStakerPool create a new instance of StakerPool
func (*StakerPool) GetStakerPoolItem ¶
func (sp *StakerPool) GetStakerPoolItem(ticker common.Ticker) *StakerPoolItem
GetStakerPoolItem return the StakerPoolItem with given pool id
func (*StakerPool) RemoveStakerPoolItem ¶
func (sp *StakerPool) RemoveStakerPoolItem(ticker common.Ticker)
RemoveStakerPoolItem delete the stakerpoolitem with given pool id from the struct
func (StakerPool) String ¶
func (sp StakerPool) String() string
String return a user readable string representation of Staker Pool
func (*StakerPool) UpsertStakerPoolItem ¶
func (sp *StakerPool) UpsertStakerPoolItem(stakerPoolItem *StakerPoolItem)
UpsertStakerPoolItem if the given stakerPoolItem exist then it will update , otherwise it will add
func (StakerPool) Valid ¶
func (sp StakerPool) Valid() error
type StakerPoolItem ¶
type StakerPoolItem struct { Ticker common.Ticker `json:"symbol"` Units sdk.Uint `json:"units"` StakeDetails []StakeTxDetail `json:"stake_details"` }
StakerPoolItem represent the staker's activity in a pool Staker can stake on multiple pool
func (*StakerPoolItem) AddStakerTxDetail ¶
func (spi *StakerPoolItem) AddStakerTxDetail(requestTxHash common.TxID, runeAmount, tokenAmount sdk.Uint)
AddStakerTxDetail to the StakerPool structure
func (StakerPoolItem) Valid ¶
func (spi StakerPoolItem) Valid() error
type StakerUnit ¶
StakerUnit staker and their units in the pool
func (StakerUnit) Valid ¶
func (su StakerUnit) Valid() error
type TrustAccount ¶
type TrustAccount struct { SignerBNBAddress common.Address `json:"bnb_signer_acc"` ObserverBEPAddress sdk.AccAddress `json:"bep_observer_acc"` ValidatorBEPConsPubKey string `json:"bepv_validator_acc"` }
TrustAccount represent those accounts we can trust, and can be used to sign tx
func NewTrustAccount ¶
func NewTrustAccount(signerBNBAddress common.Address, observerBepAddress sdk.AccAddress, validatorConsPubKey string) TrustAccount
NewTrustAccount create a new instance of trust account
func (TrustAccount) Equals ¶
func (ta TrustAccount) Equals(ta1 TrustAccount) bool
Equals is used to check whether one trust account equals to another
func (TrustAccount) IsValid ¶
func (ta TrustAccount) IsValid() error
IsValid do some basic check make sure all the field has legit value
func (TrustAccount) String ¶
func (ta TrustAccount) String() string
String implement fmt.Stringer interface
type TxIn ¶
type TxIn struct { Status status `json:"status"` Done common.TxID `json:"txhash"` // completed binance chain tx hash. This is a slice to track if we've "double spent" an input Memo string `json:"memo"` // memo Coins common.Coins `json:"coins"` // coins sent in tx Sender common.Address `json:"sender"` BlockHeight sdk.Uint `json:"block_height"` Signers []sdk.AccAddress `json:"signers"` // trust accounts saw this tx ObservePoolAddress common.Address `json:"pool_address"` }
Meant to track if we have processed a specific binance tx
func (*TxIn) SetReverted ¶
func (*TxIn) Sign ¶
func (tx *TxIn) Sign(signer sdk.AccAddress)
type TxInVoter ¶
type TxInVoter struct { TxID common.TxID `json:"tx_id"` Txs []TxIn `json:"txs"` IsProcessed bool `json:"is_processed"` }
func (TxInVoter) GetTx ¶
func (tx TxInVoter) GetTx(nodeAccounts NodeAccounts) TxIn
func (TxInVoter) HasConensus ¶
func (tx TxInVoter) HasConensus(nodeAccounts NodeAccounts) bool
type TxOut ¶
type TxOut struct { Height uint64 `json:"height"` Hash common.TxID `json:"hash"` TxArray []*TxOutItem `json:"tx_array"` }
TxOut is a structure represent all the tx we need to return to client
type TxOutItem ¶
type TxOutItem struct { ToAddress common.Address `json:"to"` PoolAddress common.Address `json:"pool_address"` // TODO update common.Coins to use sdk.Coins Coins common.Coins `json:"coins"` }
TxOutItem represent an tx need to be sent to binance chain
type ValidatorMeta ¶
type ValidatorMeta struct { Nominated NodeAccount RotateAtBlockHeight int64 // indicate when we will update the validator set RotateWindowOpenAtBlockHeight int64 Queued NodeAccount }
ValidatorMeta save the meta data used for validator rotation
type ValidatorsResp ¶
type ValidatorsResp struct { ActiveNodes NodeAccounts `json:"active_nodes"` Nominated *NodeAccount `json:"nominated"` Queued *NodeAccount `json:"queued"` RotateAt uint64 `json:"rotate_at"` RotateWindowOpenAt uint64 `json:"rotate_window_open_at"` }
ValidatorsResp response data we send back to client when they ask for validator information
Source Files ¶
- codec.go
- key.go
- msg_ack.go
- msg_add.go
- msg_admin_config.go
- msg_bond.go
- msg_endpool.go
- msg_leave.go
- msg_next_pool.go
- msg_noop.go
- msg_set_pooldata.go
- msg_set_trust_account.go
- msg_stake.go
- msg_swap.go
- msg_tx_in.go
- msg_tx_outbound.go
- msg_unstake.go
- msg_version.go
- querier.go
- random_string.go
- test_common.go
- type_admin_config.go
- type_coin.go
- type_event.go
- type_event_status.go
- type_node_account.go
- type_pool.go
- type_pool_addresses.go
- type_pool_index.go
- type_pool_staker.go
- type_staker_pool.go
- type_trust_account.go
- type_tx_in.go
- type_tx_out.go
- type_validator_meta.go
- type_validators_resp.go
- types.go