v0_13

package
v0.13.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NULL      SwapStatus    = 0x00
	Open      SwapStatus    = 0x01
	Completed SwapStatus    = 0x02
	Expired   SwapStatus    = 0x03
	INVALID   SwapDirection = 0x00
	Incoming  SwapDirection = 0x01
	Outgoing  SwapDirection = 0x02

	CreateAtomicSwap        = "createAtomicSwap"
	ClaimAtomicSwap         = "claimAtomicSwap"
	RefundAtomicSwap        = "refundAtomicSwap"
	CalcSwapID              = "calcSwapID"
	Int64Size               = 8
	RandomNumberHashLength  = 32
	RandomNumberLength      = 32
	AddrByteCount           = 20
	MaxOtherChainAddrLength = 64
	SwapIDLength            = 32
	MaxExpectedIncomeLength = 64
)

module constants

Variables

View Source
var (
	KeyAssetParams = []byte("AssetParams")

	DefaultBnbDeputyFixedFee sdk.Int = sdk.NewInt(1000) // 0.00001 BNB
	DefaultMinAmount         sdk.Int = sdk.ZeroInt()
	DefaultMaxAmount         sdk.Int = sdk.NewInt(1000000000000) // 10,000 BNB
	DefaultMinBlockLock      uint64  = 220
	DefaultMaxBlockLock      uint64  = 270
	DefaultPreviousBlockTime         = tmtime.Canonical(time.Unix(0, 0))
)

Parameter keys

Functions

func CalculateSwapID

func CalculateSwapID(randomNumberHash []byte, sender sdk.AccAddress, senderOtherChain string) []byte

CalculateSwapID calculates the hash of a RandomNumberHash, sdk.AccAddress, and string

Types

type AssetParam

type AssetParam struct {
	Denom         string         `json:"denom" yaml:"denom"`                     // name of the asset
	CoinID        int            `json:"coin_id" yaml:"coin_id"`                 // SLIP-0044 registered coin type - see https://github.com/satoshilabs/slips/blob/master/slip-0044.md
	SupplyLimit   SupplyLimit    `json:"supply_limit" yaml:"supply_limit"`       // asset supply limit
	Active        bool           `json:"active" yaml:"active"`                   // denotes if asset is available or paused
	DeputyAddress sdk.AccAddress `json:"deputy_address" yaml:"deputy_address"`   // the address of the relayer process
	FixedFee      sdk.Int        `json:"fixed_fee" yaml:"fixed_fee"`             // the fixed fee charged by the relayer process for outgoing swaps
	MinSwapAmount sdk.Int        `json:"min_swap_amount" yaml:"min_swap_amount"` // Minimum swap amount
	MaxSwapAmount sdk.Int        `json:"max_swap_amount" yaml:"max_swap_amount"` // Maximum swap amount
	MinBlockLock  uint64         `json:"min_block_lock" yaml:"min_block_lock"`   // Minimum swap block lock
	MaxBlockLock  uint64         `json:"max_block_lock" yaml:"max_block_lock"`   // Maximum swap block lock
}

AssetParam parameters that must be specified for each bep3 asset

func NewAssetParam

func NewAssetParam(
	denom string, coinID int, limit SupplyLimit, active bool,
	deputyAddr sdk.AccAddress, fixedFee sdk.Int, minSwapAmount sdk.Int,
	maxSwapAmount sdk.Int, minBlockLock uint64, maxBlockLock uint64,
) AssetParam

NewAssetParam returns a new AssetParam

type AssetParams

type AssetParams []AssetParam

AssetParams array of AssetParam

type AssetSupplies

type AssetSupplies []AssetSupply

AssetSupplies is a slice of AssetSupply

type AssetSupply

type AssetSupply struct {
	IncomingSupply           sdk.Coin      `json:"incoming_supply"  yaml:"incoming_supply"`
	OutgoingSupply           sdk.Coin      `json:"outgoing_supply"  yaml:"outgoing_supply"`
	CurrentSupply            sdk.Coin      `json:"current_supply"  yaml:"current_supply"`
	TimeLimitedCurrentSupply sdk.Coin      `json:"time_limited_current_supply" yaml:"time_limited_current_supply"`
	TimeElapsed              time.Duration `json:"time_elapsed" yaml:"time_elapsed"`
}

AssetSupply contains information about an asset's supply

func NewAssetSupply

func NewAssetSupply(incomingSupply, outgoingSupply, currentSupply, timeLimitedSupply sdk.Coin, timeElapsed time.Duration) AssetSupply

NewAssetSupply initializes a new AssetSupply

func (AssetSupply) GetDenom

func (a AssetSupply) GetDenom() string

GetDenom getter method for the denom of the asset supply

func (AssetSupply) Validate

func (a AssetSupply) Validate() error

Validate performs a basic validation of an asset supply fields.

type AtomicSwap

type AtomicSwap struct {
	Amount              sdk.Coins        `json:"amount"  yaml:"amount"`
	RandomNumberHash    tmbytes.HexBytes `json:"random_number_hash"  yaml:"random_number_hash"`
	ExpireHeight        uint64           `json:"expire_height"  yaml:"expire_height"`
	Timestamp           int64            `json:"timestamp"  yaml:"timestamp"`
	Sender              sdk.AccAddress   `json:"sender"  yaml:"sender"`
	Recipient           sdk.AccAddress   `json:"recipient"  yaml:"recipient"`
	SenderOtherChain    string           `json:"sender_other_chain"  yaml:"sender_other_chain"`
	RecipientOtherChain string           `json:"recipient_other_chain"  yaml:"recipient_other_chain"`
	ClosedBlock         int64            `json:"closed_block"  yaml:"closed_block"`
	Status              SwapStatus       `json:"status"  yaml:"status"`
	CrossChain          bool             `json:"cross_chain"  yaml:"cross_chain"`
	Direction           SwapDirection    `json:"direction"  yaml:"direction"`
}

AtomicSwap contains the information for an atomic swap

func NewAtomicSwap

func NewAtomicSwap(amount sdk.Coins, randomNumberHash tmbytes.HexBytes, expireHeight uint64, timestamp int64,
	sender, recipient sdk.AccAddress, senderOtherChain string, recipientOtherChain string, closedBlock int64,
	status SwapStatus, crossChain bool, direction SwapDirection) AtomicSwap

NewAtomicSwap returns a new AtomicSwap

func (AtomicSwap) GetCoins

func (a AtomicSwap) GetCoins() sdk.Coins

GetCoins returns the swap's amount as sdk.Coins

func (AtomicSwap) GetSwapID

func (a AtomicSwap) GetSwapID() tmbytes.HexBytes

GetSwapID calculates the ID of an atomic swap

func (AtomicSwap) Validate

func (a AtomicSwap) Validate() error

Validate performs a basic validation of an atomic swap fields.

type AtomicSwaps

type AtomicSwaps []AtomicSwap

AtomicSwaps is a slice of AtomicSwap

type GenesisState

type GenesisState struct {
	Params            Params        `json:"params" yaml:"params"`
	AtomicSwaps       AtomicSwaps   `json:"atomic_swaps" yaml:"atomic_swaps"`
	Supplies          AssetSupplies `json:"supplies" yaml:"supplies"`
	PreviousBlockTime time.Time     `json:"previous_block_time" yaml:"previous_block_time"`
}

GenesisState - all bep3 state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

DefaultGenesisState - default GenesisState used by Cosmos Hub

func NewGenesisState

func NewGenesisState(params Params, swaps AtomicSwaps, supplies AssetSupplies, previousBlockTime time.Time) GenesisState

NewGenesisState creates a new GenesisState object

func (GenesisState) Validate

func (gs GenesisState) Validate() error

Validate validates genesis inputs. It returns error if validation of any input fails.

type Params

type Params struct {
	AssetParams AssetParams `json:"asset_params" yaml:"asset_params"`
}

Params governance parameters for bep3 module

func DefaultParams

func DefaultParams() Params

DefaultParams returns default params for bep3 module

func NewParams

func NewParams(ap AssetParams,
) Params

NewParams returns a new params object

func (Params) Validate

func (p Params) Validate() error

Validate ensure that params have valid values

type SupplyLimit

type SupplyLimit struct {
	Limit          sdk.Int       `json:"limit" yaml:"limit"`                       // the absolute supply limit for an asset
	TimeLimited    bool          `json:"time_limited" yaml:"time_limited"`         // boolean for if the supply is also limited by time
	TimePeriod     time.Duration `json:"time_period" yaml:"time_period"`           // the duration for which the supply time limit applies
	TimeBasedLimit sdk.Int       `json:"time_based_limit" yaml:"time_based_limit"` // the supply limit for an asset for each time period
}

SupplyLimit parameters that control the absolute and time-based limits for an assets's supply

type SwapDirection

type SwapDirection byte

SwapDirection is the direction of an AtomicSwap

type SwapStatus

type SwapStatus byte

func NewSwapStatusFromString

func NewSwapStatusFromString(str string) SwapStatus

NewSwapStatusFromString converts string to SwapStatus type

Jump to

Keyboard shortcuts

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