web3

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// CardanoTestNet ...
	CardanoTestNet = "CardanoTestNet"
	// CardanoMainNet ...
	CardanoMainNet = "CardanoMainNet"
	// SolanaDevNet ...
	SolanaDevNet = "SolanaDevNet"

	// NetworkMap is a map that contain network information from this blockchain supports
	NetworkMap = map[string]BlockchainNet{
		CardanoTestNet: {
			NameNet:     "CardanoTestNet",
			ApiURL:      "https://graphql-api.testnet.dandelion.link/",
			ExplorerURL: "https://explorer.cardano-testnet.iohkdev.io/en/transaction?id=%s",
		},
		SolanaDevNet: {
			NameNet:     "SolanaDevNet",
			ApiURL:      "https://api.devnet.solana.com",
			ExplorerURL: "https://explorer.solana.com/tx/%s?cluster=devnet",
		},
	}
)

Functions

This section is empty.

Types

type APICardanoClient

type APICardanoClient interface {
	// InfoByAddress ...
	InfoByAddress(ctx context.Context, address string) (AddrSumary, error)
	LastTxByAddressADA(ctx context.Context, payload PayloadReqJSONGQL) (TxByAddrADAV2, error)
}

APICardanoClient define all methods that can be used on our program

func NewAPICardanoClient

func NewAPICardanoClient(options APIClientOptions) (APICardanoClient, error)

NewAPICardanoClient is a function in charge of to proccess all logic from cardano API

More info visit here -> https://explorer-api.testnet.dandelion.link

type APIClientOptions

type APIClientOptions struct {

	// NetworkType name of network only support (CardanoTestNet|SolanaDevNet)
	NetworkType string

	// Max number of routines to use for *All methods
	MaxRoutines int

	RetryWaitMin time.Duration // Minimum time to wait
	RetryWaitMax time.Duration // Maximum time to wait
	RetryMax     int           // Maximum number of retries
	// contains filtered or unexported fields
}

APIClientOptions for management all clients

type APIError

type APIError struct {
	Response interface{}
}

APIError is used to describe errors from the API.

func (*APIError) Error

func (e *APIError) Error() string

type APISolanaClient

type APISolanaClient interface {
	// LastTxByAddress ...
	LastTxByAddress(ctx context.Context, payload PayloadReqJSONRPC) (LastTxByAddr, error)
	// InfoByTx ...
	InfoByTx(ctx context.Context, payload PayloadReqJSONRPC) (TxInfo, error)
}

func NewAPISolanaClient

func NewAPISolanaClient(options APIClientOptions) (APISolanaClient, error)

NewAPISolanaClient is a function in charge of to proccess all logic from solana API

More info visit here -> https://api.devnet.solana.com

type AddrSumary

type AddrSumary struct {
	Result Right `json:"Right"`
}

AddrSumary it`s a result for the cardano API

type Block added in v0.5.0

type Block struct {
	Number int64  `json:"number"`
	Hash   string `json:"hash"`
}

type BlockchainNet added in v0.2.0

type BlockchainNet struct {
	NameNet     string `json:"name_net,omitempty"`
	ApiURL      string `json:"api_url,omitempty"`
	ExplorerURL string `json:"explorer_url,omitempty"`
}

BlockchainNet struct that define behaivor of our logic

type CABalance

type CABalance struct {
	GetCoin string `json:"getCoin"`
}

CABalance get balance

type CAChainTip

type CAChainTip struct {
	CTBlockNo   int64  `json:"ctBlockNo"`
	CTSlotNo    int64  `json:"ctSlotNo"`
	CTBlockHash string `json:"ctBlockHash"`
}

CAChainTip get general info from Chain

type CATxList

type CATxList struct {
	CtbID         string    `json:"ctbId"`
	CtbTimeIssued int64     `json:"ctbTimeIssued"`
	CtbInputs     []CtbPut  `json:"ctbInputs"`
	CtbOutputs    []CtbPut  `json:"ctbOutputs"`
	CtbInputSum   CABalance `json:"ctbInputSum"`
	CtbOutputSum  CABalance `json:"ctbOutputSum"`
	CtbFees       CABalance `json:"ctbFees"`
}

CATxList get info from TXs

type CtbPut

type CtbPut struct {
	CtaAddress string    `json:"ctaAddress"`
	CtaAmount  CABalance `json:"ctaAmount"`
	CtaTxHash  string    `json:"ctaTxHash"`
	CtaTxIndex int64     `json:"ctaTxIndex"`
}

CtbPut general info from Put object

type Data added in v0.5.0

type Data struct {
	Utxos []Utxo `json:"utxos"`
}
type Header struct {
	NumReadonlySignedAccounts   int64 `json:"numReadonlySignedAccounts"`
	NumReadonlyUnsignedAccounts int64 `json:"numReadonlyUnsignedAccounts"`
	NumRequiredSignatures       int64 `json:"numRequiredSignatures"`
}

Header ...

type HttpRequestDoer

type HttpRequestDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

type Instruction

type Instruction struct {
	Accounts       []int64 `json:"accounts"`
	Data           string  `json:"data"`
	ProgramIDIndex int64   `json:"programIdIndex"`
}

Instruction ...

type LastTxByAddr

type LastTxByAddr struct {
	Jsonrpc string                 `json:"jsonrpc"`
	Result  []ResultTxByAddressSOL `json:"result"`
	ID      int64                  `json:"id"`
}

LastTxByAddr get last txs by address

type Message

type Message struct {
	AccountKeys     []string      `json:"accountKeys"`
	Header          Header        `json:"header"`
	Instructions    []Instruction `json:"instructions"`
	RecentBlockhash string        `json:"recentBlockhash"`
}

Message ...

type Meta

type Meta struct {
	Err               interface{}   `json:"err"`
	Fee               int64         `json:"fee"`
	InnerInstructions []interface{} `json:"innerInstructions"`
	LogMessages       []string      `json:"logMessages"`
	PostBalances      []int64       `json:"postBalances"`
	PostTokenBalances []interface{} `json:"postTokenBalances"`
	PreBalances       []int64       `json:"preBalances"`
	PreTokenBalances  []interface{} `json:"preTokenBalances"`
	Rewards           []interface{} `json:"rewards"`
	Status            Status        `json:"status"`
}

Meta object with tx information

type PayloadReqJSONGQL added in v0.5.0

type PayloadReqJSONGQL struct {
	Query     string            `json:"query,omitempty"`
	Variables map[string]string `json:"variables,omitempty"`
}

func (*PayloadReqJSONGQL) ToReader added in v0.5.0

func (p *PayloadReqJSONGQL) ToReader() *strings.Reader

ToReader convert string result to reader interfaces

type PayloadReqJSONRPC

type PayloadReqJSONRPC struct {
	Jsonrpc string        `json:"jsonrpc"`
	Method  string        `json:"method"`
	Params  []interface{} `json:"params"`
	ID      int64         `json:"id"`
}

PayloadReqJSONRPC it`s an object that define how the client can be make a simple request with JSON - RPC standard

func (*PayloadReqJSONRPC) ToReader

func (p *PayloadReqJSONRPC) ToReader() *strings.Reader

ToReader convert string result to reader interfaces

type Put added in v0.5.0

type Put struct {
	Address string `json:"address"`
	Value   string `json:"value"`
}

type ResultTxByAddressSOL

type ResultTxByAddressSOL struct {
	BlockTime          int64       `json:"blockTime"`
	ConfirmationStatus string      `json:"confirmationStatus"`
	Err                interface{} `json:"err"`
	Memo               interface{} `json:"memo"`
	Signature          string      `json:"signature"`
	Slot               int64       `json:"slot"`
}

ResultTxByAddressSOL result object from getSignaturesForAddress method json-rpc

func (*ResultTxByAddressSOL) ToJSON

func (r *ResultTxByAddressSOL) ToJSON() string

type ResultTxInfo

type ResultTxInfo struct {
	BlockTime   int64       `json:"blockTime"`
	Meta        Meta        `json:"meta"`
	Slot        int64       `json:"slot"`
	Transaction Transaction `json:"transaction"`
}

ResultTxInfo return result information by an specific TX

type Right struct {
	CAAddress     string     `json:"caAddress"`
	CAType        string     `json:"caType"`
	CAChainTip    CAChainTip `json:"caChainTip"`
	CATxNum       int64      `json:"caTxNum"`
	CABalance     CABalance  `json:"caBalance"`
	CATotalInput  CABalance  `json:"caTotalInput"`
	CATotalOutput CABalance  `json:"caTotalOutput"`
	CATotalFee    CABalance  `json:"caTotalFee"`
	CATxList      []CATxList `json:"caTxList"`
}

Right main object

func (*Right) ToJSON

func (r *Right) ToJSON() string

ToJSON convert to JSON this struct

type Status

type Status struct {
	Ok interface{} `json:"Ok"`
}

type Transaction

type Transaction struct {
	Message    Message  `json:"message"`
	Signatures []string `json:"signatures"`
}

Transaction ...

type TransactionADA added in v0.5.0

type TransactionADA struct {
	Block       Block  `json:"block"`
	Fee         int64  `json:"fee"`
	TotalOutput string `json:"totalOutput"`
	IncludedAt  string `json:"includedAt"`
	Inputs      []Put  `json:"inputs"`
	Outputs     []Put  `json:"outputs"`
}

type TxByAddrADAV2 added in v0.5.0

type TxByAddrADAV2 struct {
	Data Data `json:"data"`
}

func (*TxByAddrADAV2) ToJSON added in v0.5.0

func (r *TxByAddrADAV2) ToJSON() string

type TxInfo

type TxInfo struct {
	Jsonrpc string       `json:"jsonrpc"`
	Result  ResultTxInfo `json:"result"`
	ID      int64        `json:"id"`
}

TxInfo return information related to a TX

func (*TxInfo) ToJSON

func (r *TxInfo) ToJSON() string

type Utxo added in v0.5.0

type Utxo struct {
	Value       string         `json:"value"`
	TxHash      string         `json:"txHash"`
	Transaction TransactionADA `json:"transaction"`
}

Jump to

Keyboard shortcuts

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