solanago

package
v0.0.0-...-60eaa49 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// NodeVersion is the version of geth we are using.
	NodeVersion = "1.4.17"

	// Blockchain is solanago.
	Blockchain string = "solana"

	// MainnetNetwork is the value of the network
	// in MainnetNetworkIdentifier.
	MainnetNetwork string = "mainnet"

	// TestnetNetwork is the value of the network
	// in TestnetNetworkIdentifier.
	TestnetNetwork string = "testnet"

	// DevnetNetwork is the value of the network
	// in DevnetNetworkIdentifier.
	DevnetNetwork string = "devnet"

	// Symbol is the symbol value
	// used in Currency.
	Symbol = "SOL"

	// Decimals is the decimals value
	// used in Currency.
	Decimals = 9

	// SuccessStatus is the status of any
	// Ethereum operation considered successful.
	SuccessStatus = "SUCCESS"

	// FailureStatus is the status of any
	// Ethereum operation considered unsuccessful.
	FailureStatus = "FAILURE"

	// HistoricalBalanceSupported is whether
	// historical balance is supported.
	HistoricalBalanceSupported = true

	// GenesisBlockIndex is the index of the
	// genesis block.
	GenesisBlockIndex = int64(0)

	Separator          = "__"
	WithNonceKey       = "with_nonce"
	SplSystemAccMapKey = "spl_system_acc_map"
	SplTokenAccMapKey  = "spl_token_acc_map"

	MainnetGenesisHash = "5eykt4UsFv8P8NJdTREpY1vzqKqZKvdpKuc147dw2N9d"
	TestnetGenesisHash = "4uhcVJyU9pJkvQyS88uRDiswHXSCkY3zQawwpjk2NsNY"
	DevnetGenesisHash  = "EtWTRABZaYq6iMfeYKouRu166VU2xqa1wcaWoxPkrZBG"
)
View Source
const (
	System__Transfer                  = "System__Transfer"
	System__CreateAccount             = "System__CreateAccount"
	System__Assign                    = "System__Assign"
	System__CreateNonceAccount        = "System__CreateNonceAccount"
	System__AdvanceNonce              = "System__AdvanceNonce"
	System__WithdrawFromNonce         = "System__WithdrawFromNonce"
	System__AuthorizeNonce            = "System__AuthorizeNonce"
	System__Allocate                  = "System__Allocate"
	SplToken__Transfer                = "SplToken__Transfer"
	SplToken__InitializeMint          = "SplToken__InitializeMint"
	SplToken__InitializeAccount       = "SplToken__InitializeAccount"
	SplToken__CreateToken             = "SplToken__CreateToken"
	SplToken__CreateAccount           = "SplToken__CreateAccount"
	SplToken__Approve                 = "SplToken__Approve"
	SplToken__Revoke                  = "SplToken__Revoke"
	SplToken_MintTo                   = "SplToken_MintTo"
	SplToken_Burn                     = "SplToken_Burn"
	SplToken_CloseAccount             = "SplToken_CloseAccount"
	SplToken_FreezeAccount            = "SplToken_FreezeAccount"
	SplToken__TransferChecked         = "SplToken__TransferChecked"
	SplToken__TransferNew             = "SplToken__TransferNew"
	SplToken__TransferWithSystem      = "SplToken__TransferWithSystem"
	SplAssociatedTokenAccount__Create = "SplAssociatedTokenAccount__Create"
	Unknown                           = "Unknown"
)

Variables

View Source
var (
	ErrCallParametersInvalid = errors.New("call parameters invalid")
	ErrCallOutputMarshal     = errors.New("call output marshal")
	ErrCallMethodInvalid     = errors.New("call method invalid")
)

Client errors

View Source
var (
	// MainnetGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the mainnet genesis block.
	MainnetGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  MainnetGenesisHash,
		Index: GenesisBlockIndex,
	}

	// TestnetGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the testnet genesis block.
	TestnetGenesisBlockIdentifier = &types.BlockIdentifier{
		Hash:  TestnetGenesisHash,
		Index: GenesisBlockIndex,
	}
	// TestnetGenesisBlockIdentifier is the *types.BlockIdentifier
	// of the testnet genesis block.
	DevnetGenesisHashBlockIdentifier = &types.BlockIdentifier{
		Hash:  DevnetGenesisHash,
		Index: GenesisBlockIndex,
	}

	// Currency is the *types.Currency for all
	// Ethereum networks.
	Currency = &types.Currency{
		Symbol:   Symbol,
		Decimals: Decimals,
	}

	// OperationTypes are all suppoorted operation types.
	OperationTypes = []string{
		System__Transfer,
		System__CreateAccount,
		System__Assign,
		System__CreateNonceAccount,
		System__AdvanceNonce,
		System__WithdrawFromNonce,
		System__AuthorizeNonce,
		System__Allocate,
		SplToken__Transfer,
		SplToken__InitializeMint,
		SplToken__InitializeAccount,
		SplToken__CreateToken,
		SplToken__CreateAccount,
		SplToken__Approve,
		SplToken__Revoke,
		SplToken_MintTo,
		SplToken_Burn,
		SplToken_CloseAccount,
		SplToken_FreezeAccount,
		SplToken__TransferChecked,
		SplToken__TransferNew,
		SplToken__TransferWithSystem,
		SplAssociatedTokenAccount__Create,
		Unknown,
	}

	// OperationStatuses are all supported operation statuses.
	OperationStatuses = []*types.OperationStatus{
		{
			Status:     SuccessStatus,
			Successful: true,
		},
		{
			Status:     FailureStatus,
			Successful: false,
		},
	}

	// CallMethods are all supported call methods.
	CallMethods = []string{
		"deregisterNode", "validatorExit", "getAccountInfo", "getBalance", "getBlockTime", "getClusterNodes", "getConfirmedBlock", "getConfirmedBlocks", "getConfirmedBlocksWithLimit", "getConfirmedSignaturesForAddress", "getConfirmedSignaturesForAddress2", "getConfirmedTransaction", "getEpochInfo", "getEpochSchedule", "getFeeCalculatorForBlockhash", "getFeeRateGovernor", "getFees", "getFirstAvailableBlock", "getGenesisHash", "getHealth", "getIdentity", "getInflationGovernor", "getInflationRate", "getLargestAccounts", "getLeaderSchedule", "getMinimumBalanceForRentExemption", "getMultipleAccounts", "getProgramAccounts", "getRecentBlockhash", "getSnapshotSlot", "getSignatureStatuses", "getSlot", "getSlotLeader", "getStorageTurn", "getStorageTurnRate", "getSlotsPerSegment", "getStoragePubkeysForSlot", "getSupply", "getTokenAccountBalance", "getTokenAccountsByDelegate", "getTokenAccountsByOwner", "getTokenSupply", "getTotalSupply", "getTransactionCount", "getVersion", "getVoteAccounts", "minimumLedgerSlot", "registerNode", "requestAirdrop", "sendTransaction", "simulateTransaction", "signVote",
	}
)

Functions

func Contains

func Contains(s []string, str string) bool

func EncodeBig

func EncodeBig(bigint *big.Int) string

func GetRosOperationsFromTx

func GetRosOperationsFromTx(tx solPTypes.ParsedTransaction, status string) []*types.Operation

func GetTxFromStr

func GetTxFromStr(t string) (solPTypes.Transaction, error)

func IsBalanceChanging

func IsBalanceChanging(opType string) bool

func ValueToBaseAmount

func ValueToBaseAmount(valueStr string) uint64

Types

type Client

type Client struct {
	Rpc *ss.Client
}

func NewClient

func NewClient(url string) (*Client, error)

NewClient creates a Client that from the provided url and params.

func (*Client) Balance

Balance returns the balance of a *RosettaTypes.AccountIdentifier at a *RosettaTypes.PartialBlockIdentifier.

We must use graphql to get the balance atomically (the rpc method for balance does not allow for querying by block hash nor return the block hash where the balance was fetched).

func (*Client) Block

func (ec *Client) Block(
	ctx context.Context,
	blockIdentifier *RosettaTypes.PartialBlockIdentifier,
) (*RosettaTypes.Block, error)

Block returns a populated block at the *RosettaTypes.PartialBlockIdentifier. If neither the hash or index is populated in the *RosettaTypes.PartialBlockIdentifier, the current block is returned.

func (*Client) BlockTransaction

func (ec *Client) BlockTransaction(
	ctx context.Context,
	blockTransactionRequest *RosettaTypes.BlockTransactionRequest,
) (*RosettaTypes.Transaction, error)

func (*Client) Call

Call handles calls to the /call endpoint.

func (*Client) Close

func (ec *Client) Close()

Close shuts down the RPC client connection.

func (*Client) GetTokenAccountByMint

func (ec *Client) GetTokenAccountByMint(ctx context.Context, owner string, mint string) (string, error)

func (*Client) Status

Status returns geth status information for determining node healthiness.

type GetConfirmedBlockResult

type GetConfirmedBlockResult struct {
	Blockhash         solana.PublicKey             `json:"blockhash"`
	PreviousBlockhash solana.PublicKey             `json:"previousBlockhash"` // could be zeroes if ledger was clean-up and this is unavailable
	ParentSlot        bin.Uint64                   `json:"parentSlot"`
	Transactions      []dfuserpc.TransactionParsed `json:"transactions"`
	Rewards           []dfuserpc.BlockReward       `json:"rewards"`
	BlockTime         bin.Uint64                   `json:"blockTime,omitempty"`
}

type OpMetaTokenAmount

type OpMetaTokenAmount struct {
	Amount   string  `json:"amount,omitempty"`
	Decimals uint64  `json:"decimals,omitempty"`
	UiAmount float64 `json:"uiAmount,omitempty"`
}

type ParsedInstructionMeta

type ParsedInstructionMeta struct {
	Authority    string            `json:"authority,omitempty"`
	NewAuthority string            `json:"newAuthority,omitempty"`
	Source       string            `json:"source,omitempty"`
	Owner        string            `json:"owner,omitempty"`
	Account      string            `json:"account,omitempty"`
	Destination  string            `json:"destination,omitempty"`
	NewAccount   string            `json:"newAccount,omitempty"`
	Mint         string            `json:"mint,omitempty"`
	Decimals     uint8             `json:"decimals,omitempty"`
	TokenAmount  OpMetaTokenAmount `json:"tokenAmount,omitempty"`
	Amount       uint64            `json:"amount,omitempty"`
	Lamports     uint64            `json:"lamports,omitempty"`
	Space        uint64            `json:"space,omitempty"`
}

type SplAccounts

type SplAccounts struct {
	Source      string `json:"source"`
	Destination string `json:"destination"`
	Mint        string `json:"mint"`
}

type TokenParsed

type TokenParsed struct {
	Decimals        uint64
	Amount          uint64
	MintAutority    solana.PublicKey
	FreezeAuthority solana.PublicKey
	AuthorityType   solana.PublicKey
	NewAuthority    solana.PublicKey
	M               byte
}

type WithNonce

type WithNonce struct {
	Account   string `json:"account"`
	Authority string `json:"authority,omitempty"`
}

func GetWithNonce

func GetWithNonce(m map[string]interface{}) (WithNonce, bool)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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