chain

package
v0.0.11 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ValidateBtpAddress

func ValidateBtpAddress(ba BTPAddress) error

Types

type AddToBlacklistRequestEvent

type AddToBlacklistRequestEvent struct {
	Sn    *big.Int
	Net   string
	Addrs []string
}

type AssetTransferDetails

type AssetTransferDetails struct {
	Name  string
	Value *big.Int
	Fee   *big.Int
}

type BTPAddress

type BTPAddress string

func (BTPAddress) BlockChain

func (a BTPAddress) BlockChain() string

func (BTPAddress) ContractAddress

func (a BTPAddress) ContractAddress() string

func (BTPAddress) NetworkAddress

func (a BTPAddress) NetworkAddress() string

func (BTPAddress) NetworkID

func (a BTPAddress) NetworkID() string

func (BTPAddress) Protocol

func (a BTPAddress) Protocol() string

func (*BTPAddress) Set

func (a *BTPAddress) Set(v string) error

func (BTPAddress) String

func (a BTPAddress) String() string

func (BTPAddress) Type

func (a BTPAddress) Type() string

type BlacklistResponseEvent

type BlacklistResponseEvent struct {
	Sn   *big.Int
	Code int64
	Msg  string
}

type ChainAPI

type ChainAPI interface {
	// Subscription
	Subscribe(ctx context.Context) (sinkChan chan *EventLogInfo, errChan chan error, err error)

	// Account
	GetKeyPairs(num int) ([][2]string, error)
	GetKeyPairFromKeystore(keystoreFile, secretFile string) (string, string, error)

	// Transfer
	TransferBatch(coinNames []string, senderKey, recepientAddress string, amounts []*big.Int) (txnHash string, err error)
	Transfer(coinName, senderKey, recepientAddress string, amount *big.Int) (txnHash string, err error)
	WaitForTxnResult(ctx context.Context, hash string) (txnr *TxnResult, err error)
	WatchForTransferStart(ID uint64, seq int64) error
	WatchForTransferReceived(ID uint64, seq int64) error
	WatchForTransferEnd(ID uint64, seq int64) error
	Approve(coinName string, ownerKey string, amount *big.Int) (txnHash string, err error)
	GetCoinBalance(coinName string, addr string) (*CoinBalance, error)
	Reclaim(coinName string, ownerKey string, amount *big.Int) (txnHash string, err error)

	// Query
	NativeCoin() string
	NativeTokens() []string
	GetBTPAddress(addr string) string
	ChargedGasFee(txnHash string) (*big.Int, error)
	SuggestGasPrice() *big.Int

	// Configure
	SetTokenLimit(ownerKey string, coinNames []string, tokenLimits []*big.Int) (txnHash string, err error)
	AddBlackListAddress(ownerKey string, net string, addrs []string) (txnHash string, err error)
	RemoveBlackListAddress(ownerKey string, net string, addrs []string) (txnHash string, err error)
	ChangeRestriction(ownerKey string, enable bool) (txnHash string, err error)
	GetTokenLimitStatus(net, coinName string) (response bool, err error)
	GetBlackListedUsers(net string, startCursor, endCursor int) (addrs []string, err error)
	SetFeeGatheringTerm(ownerKey string, interval uint64) (hash string, err error)
	GetFeeGatheringTerm() (interval uint64, err error)

	WatchForAddToBlacklistRequest(ID uint64, seq int64) error
	WatchForRemoveFromBlacklistRequest(ID uint64, seq int64) error
	WatchForBlacklistResponse(ID uint64, seq int64) error
	WatchForSetTokenLmitRequest(ID uint64, seq int64) error
	WatchForSetTokenLmitResponse(ID uint64, seq int64) error
	GetConfigRequestEvent(evtType EventLogType, hash string) (*EventLogInfo, error)
	WatchForFeeGatheringRequest(ID uint64, addr string) error
	WatchForFeeGatheringTransferStart(ID uint64, addr string) error

	IsUserBlackListed(net, addr string) (response bool, err error)
	GetTokenLimit(coinName string) (tokenLimit *big.Int, err error)
	IsBTSOwner(addr string) (response bool, err error)
	SetFeeRatio(ownerKey string, coinName string, feeNumerator, fixedFee *big.Int) (string, error)
	GetFeeRatio(coinName string) (feeNumerator *big.Int, fixedFee *big.Int, err error)
	GetAccumulatedFees() (map[string]*big.Int, error)
}

type ChainType

type ChainType string
const (
	ICON ChainType = "ICON"
	HMNY ChainType = "HMNY"
	BSC  ChainType = "BSC"
	NEAR ChainType = "NEAR"
	SNOW ChainType = "SNOW"
)

type CoinBalance

type CoinBalance struct {
	UsableBalance     *big.Int
	LockedBalance     *big.Int
	RefundableBalance *big.Int
	UserBalance       *big.Int
	TotalBalance      *big.Int // held by BTS + by itself
}

func (*CoinBalance) String

func (cb *CoinBalance) String() string

type Config

type Config struct {
	Name                  ChainType               `json:"name"`
	URL                   string                  `json:"url"`
	ContractAddresses     map[ContractName]string `json:"contract_addresses"`
	NativeCoin            string                  `json:"native_coin"`
	NativeTokens          []string                `json:"native_tokens"`
	WrappedCoins          []string                `json:"wrapped_coins"`
	GodWalletKeystorePath string                  `json:"god_wallet_keystore_path"`
	GodWalletSecretPath   string                  `json:"god_wallet_secret_path"`
	BTSOwnerKeystorePath  string                  `json:"bts_owner_keystore_path"`
	BTSOwnerSecretPath    string                  `json:"bts_owner_secret_path"`
	NetworkID             string                  `json:"network_id"`
	GasLimit              map[GasLimitType]uint64 `json:"gas_limit"`
}

type ContractName

type ContractName string
const (
	BMC          ContractName = "BMC"
	BMCPeriphery ContractName = "BMCPeriphery"
	BTS          ContractName = "BTS"
	BTSPeriphery ContractName = "BTSPeriphery"
)

type DstAPI

type DstAPI interface {
	GetCoinBalance(coinName string, addr string) (*CoinBalance, error)
	WatchForTransferReceived(requestID uint64, seq int64) error
	GetBTPAddress(addr string) string
}

type EventLogInfo

type EventLogInfo struct {
	PID             uint64
	ContractAddress string
	EventType       EventLogType
	EventLog        interface{}
}

type EventLogType

type EventLogType string
const (
	TransferStart              EventLogType = "TransferStart"
	TransferReceived           EventLogType = "TransferReceived"
	TransferEnd                EventLogType = "TransferEnd"
	AddToBlacklistRequest      EventLogType = "AddToBlacklistRequest"
	RemoveFromBlacklistRequest EventLogType = "RemoveFromBlacklistRequest"
	BlacklistResponse          EventLogType = "BlacklistResponse"
	TokenLimitRequest          EventLogType = "TokenLimitRequest"
	TokenLimitResponse         EventLogType = "TokenLimitResponse"
	FeeGatheringRequest        EventLogType = "FeeGatheringRequest"
	Message                    EventLogType = "Message"
)

type FeeGatheringRequestEvent

type FeeGatheringRequestEvent struct {
	FeeAggregator string
	Services      []string
}

type FullConfigAPI

type FullConfigAPI interface {
	SetTokenLimit(ownerKey string, coinNames []string, tokenLimits []*big.Int) (txnHash string, err error)
	AddBlackListAddress(ownerKey string, net string, addrs []string) (txnHash string, err error)
	RemoveBlackListAddress(ownerKey string, net string, addrs []string) (txnHash string, err error)
	ChangeRestriction(ownerKey string, enable bool) (txnHash string, err error)
	GetTokenLimitStatus(net, coinName string) (response bool, err error)
	GetBlackListedUsers(net string, startCursor, endCursor int) (addrs []string, err error)
	SetFeeGatheringTerm(ownerKey string, interval uint64) (hash string, err error)
	GetFeeGatheringTerm() (interval uint64, err error)

	WatchForAddToBlacklistRequest(ID uint64, seq int64) error
	WatchForRemoveFromBlacklistRequest(ID uint64, seq int64) error
	WatchForSetTokenLmitRequest(ID uint64, seq int64) error
	GetConfigRequestEvent(evtType EventLogType, hash string) (*EventLogInfo, error)
	WatchForFeeGatheringRequest(ID uint64, addr string) error

	IsUserBlackListed(net, addr string) (response bool, err error)
	GetTokenLimit(coinName string) (tokenLimit *big.Int, err error)
	IsBTSOwner(addr string) (response bool, err error)
}

type GasLimitType

type GasLimitType string
const (
	TransferNativeCoinIntraChainGasLimit GasLimitType = "TransferNativeCoinIntraChainGasLimit"
	TransferTokenIntraChainGasLimit      GasLimitType = "TransferTokenIntraChainGasLimit"
	ApproveTokenInterChainGasLimit       GasLimitType = "ApproveTokenInterChainGasLimit"
	TransferCoinInterChainGasLimit       GasLimitType = "TransferCoinInterChainGasLimit"
	TransferBatchCoinInterChainGasLimit  GasLimitType = "TransferBatchCoinInterChainGasLimit"
	DefaultGasLimit                      GasLimitType = "DefaultGasLimit"
)

type RemoveFromBlacklistRequestEvent

type RemoveFromBlacklistRequestEvent struct {
	Sn    *big.Int
	Net   string
	Addrs []string
}

type SrcAPI

type SrcAPI interface {
	Transfer(coinName, senderKey, recepientAddress string, amount *big.Int) (txnHash string, err error)
	TransferBatch(coinNames []string, senderKey, recepientAddress string, amounts []*big.Int) (txnHash string, err error)
	WaitForTxnResult(ctx context.Context, hash string) (txnr *TxnResult, err error)
	WatchForTransferStart(requestID uint64, seq int64) error
	WatchForTransferEnd(ID uint64, seq int64) error
	WatchForFeeGatheringTransferStart(ID uint64, addr string) error
	Approve(coinName string, ownerKey string, amount *big.Int) (txnHash string, err error)
	GetCoinBalance(coinName string, addr string) (*CoinBalance, error)
	Reclaim(coinName string, ownerKey string, amount *big.Int) (txnHash string, err error)

	NativeCoin() string
	NativeTokens() []string
	GetBTPAddress(addr string) string
	ChargedGasFee(txnHash string) (*big.Int, error)
	SuggestGasPrice() *big.Int
}

type StandardConfigAPI

type StandardConfigAPI interface {
	IsUserBlackListed(net, addr string) (response bool, err error)
	GetTokenLimit(coinName string) (tokenLimit *big.Int, err error)
	IsBTSOwner(addr string) (response bool, err error)
	SetFeeRatio(ownerKey string, coinName string, feeNumerator, fixedFee *big.Int) (string, error)
	GetFeeRatio(coinName string) (feeNumerator *big.Int, fixedFee *big.Int, err error)
	GetAccumulatedFees() (map[string]*big.Int, error)

	WatchForBlacklistResponse(ID uint64, seq int64) error
	WatchForSetTokenLmitResponse(ID uint64, seq int64) error
}

type TokenLimitRequestEvent

type TokenLimitRequestEvent struct {
	Sn          *big.Int
	TokenLimits []*big.Int
	CoinNames   []string
}

type TokenLimitResponseEvent

type TokenLimitResponseEvent struct {
	Sn   *big.Int
	Code int64
	Msg  string
}

type TransferEndEvent

type TransferEndEvent struct {
	From     string
	Sn       *big.Int
	Code     *big.Int
	Response string
}

type TransferReceivedEvent

type TransferReceivedEvent struct {
	From   string
	To     string
	Sn     *big.Int
	Assets []AssetTransferDetails
}

type TransferStartEvent

type TransferStartEvent struct {
	From   string
	To     string
	Sn     *big.Int
	Assets []AssetTransferDetails
}

type TxnResult

type TxnResult struct {
	StatusCode int
	ElInfo     []*EventLogInfo
	Raw        interface{}
}

Jump to

Keyboard shortcuts

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