Documentation ¶
Index ¶
- Constants
- Variables
- func AmountToUint(amount Amount) sdk.Uint
- func ConvertAndEncode(hrp string, data []byte) (string, error)
- func FloatToDec(input float64) sdk.Dec
- func FloatToUint(input float64) sdk.Uint
- func FloatToUintAndMultipleOne(input float64) sdk.Uint
- func IntToInt64(input sdk.Int) int64
- func IntToUint64(input sdk.Int) uint64
- func IsBNB(ticker Ticker) bool
- func IsBNBChain(c Chain) bool
- func IsBNBSymbol(s Symbol) bool
- func IsRune(ticker Ticker) bool
- func IsRuneSymbol(s Symbol) bool
- func RandStringBytesMask(n int) string
- func UintToFloat64(input sdk.Uint) float64
- func UintToUint64(input sdk.Uint) uint64
- type Address
- type Amount
- func (a Amount) Equals(a2 Amount) bool
- func (a Amount) Float64() float64
- func (a Amount) GreaterThen(f float64) bool
- func (a Amount) IsEmpty() bool
- func (a Amount) IsNegative() bool
- func (a Amount) IsZero() bool
- func (a Amount) LessThen(f float64) bool
- func (a Amount) Minus(a2 Amount) Amount
- func (a Amount) Plus(a2 Amount) Amount
- func (a Amount) String() string
- type Asset
- type Chain
- type ChainNetwork
- type ChainPoolInfo
- type Chains
- type Coin
- type Coins
- type Duration
- type PoolPubKey
- type PoolPubKeys
- type PubKey
- func (pubKey PubKey) Equals(pubKey1 PubKey) bool
- func (pubKey PubKey) GetAddress(chain Chain) (Address, error)
- func (pubKey PubKey) GetThorAddress() (sdk.AccAddress, error)
- func (pubKey PubKey) IsEmpty() bool
- func (pubKey PubKey) MarshalJSON() ([]byte, error)
- func (pubKey PubKey) String() string
- func (pubKey *PubKey) UnmarshalJSON(data []byte) error
- type PubKeys
- type Symbol
- type Ticker
- type Tickers
- type Tx
- type TxID
- type TxIDs
- type Txs
Constants ¶
const ( BNBSymbol = Symbol("BNB") RuneA1FSymbol = Symbol("RUNE-A1F") RuneB1ASymbol = Symbol("RUNE-B1A") )
const ( BNBTicker = Ticker("BNB") RuneTicker = Ticker("RUNE") // TODO these are not tickers, they are symbols, delete them RuneA1FTicker = Ticker("RUNE-A1F") RuneB1ATicker = Ticker("RUNE-B1A") )
const NoSigningAlgo = keys.SigningAlgo("")
const One = 100000000
One is useful type so we don't need to type 8 zero all the time
Variables ¶
var ( BNBAsset = Asset{BNBChain, "BNB", "BNB"} BTCAsset = Asset{BTCChain, "BTC", "BTC"} RuneA1FAsset = Asset{BNBChain, "RUNE-A1F", "RUNE"} // testnet RuneB1AAsset = Asset{BNBChain, "RUNE-B1A", "RUNE"} // mainnet )
var ( BNBChain = Chain("BNB") ETHChain = Chain("ETH") BTCChain = Chain("BTC") THORChain = Chain("THOR") EmptyChain = Chain("") )
var BlankTxID = TxID("0000000000000000000000000000000000000000000000000000000000000000")
var NoCoin = Coin{}
Functions ¶
func AmountToUint ¶
func ConvertAndEncode ¶
ConvertAndEncode converts from a base64 encoded byte string to base32 encoded byte string and then to bech32
func FloatToDec ¶
func FloatToUint ¶
func IntToInt64 ¶
func IntToUint64 ¶
func IsBNBChain ¶
func IsBNBSymbol ¶
func IsRuneSymbol ¶
func RandStringBytesMask ¶
RandStringBytesMask generate random string used for test purpose
Types ¶
type Address ¶
type Address string
func NewAddress ¶
NewAddress create a new Address Sample: bnb1lejrrtta9cgr49fuh7ktu3sddhe0ff7wenlpn6
type Amount ¶
type Amount string
func NewAmountFromFloat ¶
func UintToAmount ¶
func (Amount) GreaterThen ¶
func (Amount) IsNegative ¶
type Asset ¶
type Chain ¶
type Chain string
Chain is the
func (Chain) AddressPrefix ¶
func (c Chain) AddressPrefix(cn ChainNetwork) string
AddressPrefix return the address prefix used by the given network (testnet/mainnet)
func (Chain) GetSigningAlgo ¶
func (c Chain) GetSigningAlgo() keys.SigningAlgo
type ChainNetwork ¶
type ChainNetwork uint8
ChainNetwork is to indicate which chain environment we are working with
const ( // TestNetwork for test TestNet ChainNetwork = iota // ProdNetwork for main net MainNet )
func GetCurrentChainNetwork ¶
func GetCurrentChainNetwork() ChainNetwork
GetCurrentChainNetwork determinate what kind of network currently it is working with
type ChainPoolInfo ¶
type ChainPoolInfo struct { Chain Chain `json:"chain"` PubKey PubKey `json:"pub_key"` PoolAddress Address `json:"pool_address"` }
ChainPoolInfo represent the pool address specific for a chain
var EmptyChainPoolInfo ChainPoolInfo
EmptyChainPoolInfo everything is empty
func NewChainPoolInfo ¶
func NewChainPoolInfo(chain Chain, pubKey PubKey) (ChainPoolInfo, error)
NewChainPoolInfo create a new instance of ChainPoolInfo
func (ChainPoolInfo) IsEmpty ¶
func (cpi ChainPoolInfo) IsEmpty() bool
IsEmpty whether the struct is empty
type Coins ¶
type Coins []Coin
type Duration ¶
Duration embedded time.Duration so we could use string to represent duration in json file for example ,1s ,1h , 5m etc
func (Duration) MarshalJSON ¶
MarshalJSON marshal the duration to json string
func (*Duration) UnmarshalJSON ¶
UnmarshalJSON convert the json value back to time.Duration
type PoolPubKey ¶
type PoolPubKey struct { Chain Chain `json:"chain"` SeqNo uint64 `json:"seq_no"` PubKey PubKey `json:"pub_key"` Address Address `json:"address"` }
PoolPubKey is the pub key only related to a specific chain
func NewPoolPubKey ¶
func NewPoolPubKey(chain Chain, seqNo uint64, pubkey PubKey) (*PoolPubKey, error)
NewPoolPubKey create a new instance of PoolPubKey
func (*PoolPubKey) Equals ¶
func (ppk *PoolPubKey) Equals(ppk1 *PoolPubKey) bool
Equals compare two PoolPubKey to determinate whether they are representing the same address
func (PoolPubKey) GetAddress ¶
func (ppk PoolPubKey) GetAddress() (Address, error)
func (PoolPubKey) IsEmpty ¶
func (ppk PoolPubKey) IsEmpty() bool
IsEmpty check whether the given pool pub key is empty
type PoolPubKeys ¶
type PoolPubKeys []*PoolPubKey
PoolPubKeys
var EmptyPoolPubKeys PoolPubKeys
EmptyPoolPubKeys
func (PoolPubKeys) GetByChain ¶
func (poolPubKeys PoolPubKeys) GetByChain(c Chain) *PoolPubKey
GetByChain get PoolPubKey by chain,
func (PoolPubKeys) IsEmpty ¶
func (poolPubKeys PoolPubKeys) IsEmpty() bool
IsEmpty when there is no item in the list
func (PoolPubKeys) TryAddKey ¶
func (poolPubKeys PoolPubKeys) TryAddKey(k *PoolPubKey) PoolPubKeys
TryAddKey trying to add the given pool pubkey into the list,if it already exist ,then we just return the list
func (PoolPubKeys) TryRemoveKey ¶
func (poolPubKeys PoolPubKeys) TryRemoveKey(k *PoolPubKey) PoolPubKeys
TryRemoveKey trying to remove the given key from the list
type PubKey ¶
type PubKey string
PubKey used in statechain, it should be bech32 encoded string thus it will be something like thorpub1addwnpepqt7qug8vk9r3saw8n4r803ydj2g3dqwx0mvq5akhnze86fc536xcy2cr8a2 thorpub1addwnpepqdqvd4r84lq9m54m5kk9sf4k6kdgavvch723pcgadulxd6ey9u70kgjgrwl
var EmptyPubKey PubKey
EmptyPubKey
func NewPubKeyFromCrypto ¶
NewPubKeyFromCrypto
func (PubKey) GetAddress ¶
GetAddress will return an address for the given chain
func (PubKey) GetThorAddress ¶
func (pubKey PubKey) GetThorAddress() (sdk.AccAddress, error)
func (PubKey) MarshalJSON ¶
MarshalJSON to Marshals to JSON using Bech32
func (*PubKey) UnmarshalJSON ¶
UnmarshalJSON to Unmarshal from JSON assuming Bech32 encoding
type PubKeys ¶
PubKeys contains two pub keys , secp256k1 and ed25519
var EmptyPubKeys PubKeys
EmptyPubKeys
func NewPubKeys ¶
NewPubKeys create a new instance of PubKeys , which contains two keys
type Tx ¶
type Tx struct { ID TxID `json:"id"` Chain Chain `json:"chain"` FromAddress Address `json:"from_address"` ToAddress Address `json:"to_address"` Coins Coins `json:"coins"` Memo string `json:"memo"` }