alephiumhelper

package
v1.4.520-3 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2024 License: GPL-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BackendURL              = "https://backend.mainnet.alephium.org"
	NodeURL                 = "https://node.mainnet.alephium.org"
	AYINPairContractAddress = "vyrkJHG49TXss6pGAz2dVxq5o7mBXNNXAV18nAeqVT1R"
)
View Source
const (
	SymbolMethod = iota
	NameMethod
	DecimalsMethod
	TokenPairMethod = 7
)
View Source
const (
	DefaultRefreshDelay              = 400 // millisec
	DefaultSleepBetweenContractCalls = 300 // millisec
	DefaultEventsLimit               = 100
	DefaultSwapContractsLimit        = 100
)
View Source
const (
	AddressTypeP2PKH  = 0x00
	AddressTypeP2MPKH = 0x01
	AddressTypeP2SH   = 0x02
	AddressTypeP2C    = 0x03

	TotalNumberOfGroups = 4
)
View Source
const ByteVecType = "ByteVec"
View Source
const (
	SwapEventIndex = 2
)
View Source
const U256Type = "U256"

Variables

View Source
var ALPHNativeToken = dia.Asset{
	Address:  "tgx7VNFoP9DJiFMFgXXtafQZkUvyEdDHT9ryamHJYrjq",
	Symbol:   "ALPH",
	Decimals: 18,
	Name:     "Alephium",
}

ALPHNativeToken: native alephium token - it has no related contract details -> https://github.com/alephium/token-list/blob/master/tokens/mainnet.json#L4-L11

Functions

func AddressFromTokenId

func AddressFromTokenId(tokenId string) (string, error)

func DecodeHex

func DecodeHex(hexString string) (string, error)

Types

type AlephiumClient

type AlephiumClient struct {
	Debug      bool
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

AlephiumClient: interaction with alephium REST API with urls from @BackendURL, @NodeURL contants

func NewAlephiumClient

func NewAlephiumClient(logger *logrus.Entry, sleepBetweenCalls time.Duration, debug bool) *AlephiumClient

NewAlephiumClient returns AlephiumClient

func (*AlephiumClient) FilterEvents

func (s *AlephiumClient) FilterEvents(allEvents []ContractEvent, filter int) []ContractEvent

func (*AlephiumClient) GetBlockEvents

func (c *AlephiumClient) GetBlockEvents(blockHash string) ([]ContractEvent, error)

GetContractEvents returns events included in a specific block from REST API

func (*AlephiumClient) GetBlockHashes

func (c *AlephiumClient) GetBlockHashes(height int) ([]string, error)

GetBlockHashes returns all block hashes at a given height from REST API

func (*AlephiumClient) GetContractState

func (c *AlephiumClient) GetContractState(address string) (ContractStateResponse, error)

func (*AlephiumClient) GetCurrentHeight

func (c *AlephiumClient) GetCurrentHeight() (int, error)

GetCurrentHeight returns the current height (block number) in Alephium network

func (*AlephiumClient) GetSwapPairsContractAddresses

func (c *AlephiumClient) GetSwapPairsContractAddresses(swapContractsLimit int) (SubContractResponse, error)

GetSwapPairsContractAddresses returns swap contract addresses for alephium

func (*AlephiumClient) GetTokenInfoForContractDecoded

func (c *AlephiumClient) GetTokenInfoForContractDecoded(contractAddress, blockchain string) (*dia.Asset, error)

GetTokenInfoForContractDecoded returns alephium token metainfo, decoded to dia.Asset struct

func (*AlephiumClient) GetTokenPairAddresses

func (c *AlephiumClient) GetTokenPairAddresses(contractAddress string) ([]string, error)

GetTokenPairAddresses returns token address pair for swap contract address

func (*AlephiumClient) GetTransactionDetails

func (c *AlephiumClient) GetTransactionDetails(txnHash string) (TransactionDetailsResponse, error)

GetSwapContractEvents returns swap event transaction details by transaction hash

type BlockEventsResponse

type BlockEventsResponse struct {
	Events []ContractEvent `json:"events"`
}

type BlockHashesResponse

type BlockHashesResponse struct {
	Headers []string `json:"headers"`
}

type CallContractRequest

type CallContractRequest struct {
	Group       int    `json:"group"`
	Address     string `json:"address"`
	MethodIndex int    `json:"methodIndex"`
}

type CallContractResult

type CallContractResult struct {
	Type      string     `json:"type"`
	Error     *string    `json:"error"`
	Returns   []Field    `json:"returns"`
	Contracts []Contract `json:"contracts"`
}

type Calls

type Calls struct {
	Calls []CallContractRequest `json:"calls"`
}

type ChainInfoResponse

type ChainInfoResponse struct {
	CurrentHeight int `json:"currentHeight"`
}

type Contract

type Contract struct {
	Address string `json:"address"`
}

type ContractEvent

type ContractEvent struct {
	TxID            string  `json:"txId"`
	ContractAddress string  `json:"contractAddress"`
	EventIndex      int     `json:"eventIndex"`
	Fields          []Field `json:"fields"`
}

type ContractStateResponse

type ContractStateResponse struct {
	Address   string     `json:"address"`
	MutFields []MutField `json:"mutFields"`
}

type Field

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

type MulticallContractResponse

type MulticallContractResponse struct {
	Results []CallContractResult `json:"results"`
}

type MutField

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

type OutputField

type OutputField struct {
	Field
	ResponseResult string
}

type OutputResult

type OutputResult struct {
	Address string
	Results []OutputField
}

type SubContractResponse

type SubContractResponse struct {
	SubContracts []string `json:"subContracts"`
}

type TransactionDetailsResponse

type TransactionDetailsResponse struct {
	Type      string `json:"type"`
	Hash      string `json:"hash"`
	BlockHash string `json:"blockHash"`
	Timestamp int64  `json:"timestamp"`
}

Jump to

Keyboard shortcuts

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