Documentation ¶
Index ¶
- Constants
- Variables
- func AddressFromTokenId(tokenId string) (string, error)
- func DecodeHex(hexString string) (string, error)
- type AlephiumClient
- func (s *AlephiumClient) FilterEvents(allEvents []ContractEvent, filter int) []ContractEvent
- func (c *AlephiumClient) GetBlockEvents(blockHash string) ([]ContractEvent, error)
- func (c *AlephiumClient) GetBlockHashes(height int) ([]string, error)
- func (c *AlephiumClient) GetContractState(address string) (ContractStateResponse, error)
- func (c *AlephiumClient) GetCurrentHeight() (int, error)
- func (c *AlephiumClient) GetSwapPairsContractAddresses(swapContractsLimit int) (SubContractResponse, error)
- func (c *AlephiumClient) GetTokenInfoForContractDecoded(contractAddress, blockchain string) (*dia.Asset, error)
- func (c *AlephiumClient) GetTokenPairAddresses(contractAddress string) ([]string, error)
- func (c *AlephiumClient) GetTransactionDetails(txnHash string) (TransactionDetailsResponse, error)
- type BlockEventsResponse
- type BlockHashesResponse
- type CallContractRequest
- type CallContractResult
- type Calls
- type ChainInfoResponse
- type Contract
- type ContractEvent
- type ContractStateResponse
- type Field
- type MulticallContractResponse
- type MutField
- type OutputField
- type OutputResult
- type SubContractResponse
- type TransactionDetailsResponse
Constants ¶
const ( BackendURL = "https://backend.mainnet.alephium.org" NodeURL = "https://node.mainnet.alephium.org" AYINPairContractAddress = "vyrkJHG49TXss6pGAz2dVxq5o7mBXNNXAV18nAeqVT1R" )
const ( SymbolMethod = iota NameMethod DecimalsMethod TokenPairMethod = 7 )
const ( DefaultRefreshDelay = 400 // millisec DefaultSleepBetweenContractCalls = 300 // millisec DefaultEventsLimit = 100 DefaultSwapContractsLimit = 100 )
const ( AddressTypeP2PKH = 0x00 AddressTypeP2MPKH = 0x01 AddressTypeP2SH = 0x02 AddressTypeP2C = 0x03 TotalNumberOfGroups = 4 )
const ByteVecType = "ByteVec"
const (
SwapEventIndex = 2
)
const U256Type = "U256"
Variables ¶
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 ¶
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 CallContractResult ¶
type Calls ¶
type Calls struct {
Calls []CallContractRequest `json:"calls"`
}
type ChainInfoResponse ¶
type ChainInfoResponse struct {
CurrentHeight int `json:"currentHeight"`
}
type ContractEvent ¶
type ContractStateResponse ¶
type MulticallContractResponse ¶
type MulticallContractResponse struct {
Results []CallContractResult `json:"results"`
}
type OutputField ¶
type OutputResult ¶
type OutputResult struct { Address string Results []OutputField }
type SubContractResponse ¶
type SubContractResponse struct {
SubContracts []string `json:"subContracts"`
}