Documentation
¶
Index ¶
- Constants
- func AddressFromPubKey(publicKey solana.PublicKey) string
- func GenerateNewKeypair() (*solana.PrivateKey, solana.PublicKey)
- func GetAccountInfo(sdkClient *rpc.Client, tokenAccount solana.PublicKey) (*rpc.GetAccountInfoResult, error)
- func GetSuggestedPriorityFee(fees []PrioritizationFee) uint64
- func GetTokenSupply(sdkClient *rpc.Client, mintPubkey solana.PublicKey) (*rpc.GetTokenSupplyResult, error)
- func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
- func PrivateKeyFromBase58(privateKeyBase58 string) (*solana.PrivateKey, error)
- func PrivateKeyFromByteList(privateKeyByteList []byte) (*solana.PrivateKey, error)
- func PrivateKeyFromHex(privateKeyHex string) (*solana.PrivateKey, error)
- func PrivateKeyHexToPrivateKey(privateKeyHex string) (*ed25519.PrivateKey, error)
- func PrivateKeyHexToPubKey(privateKeyHex string) (*ed25519.PublicKey, error)
- func PrivateKeyToBase58(privateKey *solana.PrivateKey) string
- func PrivateKeyToPubKey(privateKey *ed25519.PrivateKey) (*ed25519.PublicKey, error)
- func PubKeyHexToAddress(pubKeyHex string) (string, error)
- func PubKeyHexToAddressSDK(publicKeyHex string) (string, error)
- func PubKeyHexToPubKey(publicKeyHex string) (*ed25519.PublicKey, error)
- func PubKeyToAddress(publicKey *ed25519.PublicKey) (string, error)
- func PubKeyToPubKeyHex(publicKey *ed25519.PublicKey) (string, error)
- func PublicKeyFromBase58(publicKeyBase58 string) (solana.PublicKey, error)
- func PublicKeyFromPrivateKey(privateKey *solana.PrivateKey) solana.PublicKey
- func PublicKeyToBase58(publicKey solana.PublicKey) string
- type AccountInfo
- type AccountsInfo
- type BlockHeightResponse
- type BlockResult
- type ChainAdaptor
- func (c *ChainAdaptor) BuildSignedTransaction(ctx context.Context, request *walletapi.SignedTransactionRequest) (*walletapi.SignedTransactionResponse, error)
- func (c *ChainAdaptor) BuildTransactionSchema(ctx context.Context, request *walletapi.TransactionSchemaRequest) (*walletapi.TransactionSchemaResponse, error)
- func (c *ChainAdaptor) BuildUnSignTransaction(ctx context.Context, request *walletapi.UnSignTransactionRequest) (*walletapi.UnSignTransactionResponse, error)
- func (c *ChainAdaptor) ConvertAddresses(ctx context.Context, req *walletapi.ConvertAddressesRequest) (*walletapi.ConvertAddressesResponse, error)
- func (c *ChainAdaptor) GetAccountBalance(ctx context.Context, req *walletapi.AccountBalanceRequest) (*walletapi.AccountBalanceResponse, error)
- func (c *ChainAdaptor) GetAddressApproveList(ctx context.Context, request *walletapi.AddressApproveListRequest) (*walletapi.AddressApproveListResponse, error)
- func (c *ChainAdaptor) GetBlock(ctx context.Context, req *walletapi.BlockRequest) (*walletapi.BlockResponse, error)
- func (c *ChainAdaptor) GetLastestBlock(ctx context.Context, req *walletapi.LastestBlockRequest) (*walletapi.LastestBlockResponse, error)
- func (c *ChainAdaptor) GetTransactionByAddress(ctx context.Context, req *walletapi.TransactionByAddressRequest) (*walletapi.TransactionByAddressResponse, error)
- func (c *ChainAdaptor) GetTransactionByHash(ctx context.Context, req *walletapi.TransactionByHashRequest) (*walletapi.TransactionByHashResponse, error)
- func (c *ChainAdaptor) SendTransaction(ctx context.Context, req *walletapi.SendTransactionsRequest) (*walletapi.SendTransactionResponse, error)
- func (c *ChainAdaptor) ValidAddresses(ctx context.Context, req *walletapi.ValidAddressesRequest) (*walletapi.ValidAddressesResponse, error)
- type CommitmentType
- type CreateNonceAccountRequest
- type CreateNonceAccountResponse
- type GetAccountInfoResponse
- type GetBalanceResponse
- type GetBlockRequest
- type GetBlockResponse
- type GetBlocksWithLimitResponse
- type GetFeeForMessageRequest
- type GetFeeForMessageResponse
- type GetHealthResponse
- type GetLatestBlockhashResponse
- type GetSignaturesRequest
- type GetSignaturesResponse
- type GetSlotRequest
- type GetSlotResponse
- type GetTransactionResponse
- type Instruction
- type LoadedAddresses
- type PrioritizationFee
- type RPCError
- type SendTransactionRequest
- type SendTransactionResponse
- type SignatureInfo
- type SimulateRequest
- type SimulateResult
- type SimulateTransactionResponse
- type SolClient
- type SolData
- type Status
- type Transaction
- type TransactionDetail
- type TransactionDetailsType
- type TransactionHeader
- type TransactionMessage
- type TransactionMeta
- type TransactionResult
- type TransactionVersion
- type TxStructure
Constants ¶
View Source
const ( HealthOk = "ok" HealthBehind = "behind" HealthUnknown = "unknown" )
View Source
const (
ChainID string = "DappLinkSolana"
)
View Source
const (
MaxBlockRange = 1000
)
Variables ¶
This section is empty.
Functions ¶
func AddressFromPubKey ¶
func GenerateNewKeypair ¶
func GenerateNewKeypair() (*solana.PrivateKey, solana.PublicKey)
func GetAccountInfo ¶
func GetAccountInfo(sdkClient *rpc.Client, tokenAccount solana.PublicKey) (*rpc.GetAccountInfoResult, error)
GetAccountInfo retrieves account information for a given token account
func GetSuggestedPriorityFee ¶
func GetSuggestedPriorityFee(fees []PrioritizationFee) uint64
func GetTokenSupply ¶
func GetTokenSupply(sdkClient *rpc.Client, mintPubkey solana.PublicKey) (*rpc.GetTokenSupplyResult, error)
GetTokenSupply retrieves the token supply for a given mint public key
func NewChainAdaptor ¶
func NewChainAdaptor(conf *config.Config) (chain.IChainAdaptor, error)
func PrivateKeyFromBase58 ¶
func PrivateKeyFromBase58(privateKeyBase58 string) (*solana.PrivateKey, error)
func PrivateKeyFromByteList ¶
func PrivateKeyFromByteList(privateKeyByteList []byte) (*solana.PrivateKey, error)
func PrivateKeyFromHex ¶
func PrivateKeyFromHex(privateKeyHex string) (*solana.PrivateKey, error)
func PrivateKeyHexToPrivateKey ¶
func PrivateKeyHexToPrivateKey(privateKeyHex string) (*ed25519.PrivateKey, error)
func PrivateKeyHexToPubKey ¶
func PrivateKeyToBase58 ¶
func PrivateKeyToBase58(privateKey *solana.PrivateKey) string
func PrivateKeyToPubKey ¶
func PrivateKeyToPubKey(privateKey *ed25519.PrivateKey) (*ed25519.PublicKey, error)
func PubKeyHexToAddress ¶
func PubKeyHexToAddressSDK ¶
func PublicKeyFromBase58 ¶
func PublicKeyFromPrivateKey ¶
func PublicKeyFromPrivateKey(privateKey *solana.PrivateKey) solana.PublicKey
func PublicKeyToBase58 ¶
Types ¶
type AccountInfo ¶
type AccountInfo struct {
// account now balance
Lamports uint64 `json:"lamports"`
Owner string `json:"owner"`
// slice index = 0, data
// slice index = 1, encode = base58, and other
Data []string `json:"data"`
Executable bool `json:"executable"`
RentEpoch uint64 `json:"rentEpoch"`
Space uint64 `json:"space"`
}
type AccountsInfo ¶
type BlockHeightResponse ¶
type BlockResult ¶
type BlockResult struct {
ParentSlot uint64 `json:"parentSlot"`
BlockTime int64 `json:"blockTime"`
BlockHeight uint64 `json:"blockHeight"`
BlockHash string `json:"blockhash"`
PreviousBlockhash string `json:"previousBlockhash"`
Signatures []string `json:"signatures"`
Transactions []TransactionDetail `json:"transactions"`
}
type ChainAdaptor ¶
type ChainAdaptor struct {
// contains filtered or unexported fields
}
func (*ChainAdaptor) BuildSignedTransaction ¶
func (c *ChainAdaptor) BuildSignedTransaction(ctx context.Context, request *walletapi.SignedTransactionRequest) (*walletapi.SignedTransactionResponse, error)
func (*ChainAdaptor) BuildTransactionSchema ¶
func (c *ChainAdaptor) BuildTransactionSchema(ctx context.Context, request *walletapi.TransactionSchemaRequest) (*walletapi.TransactionSchemaResponse, error)
func (*ChainAdaptor) BuildUnSignTransaction ¶
func (c *ChainAdaptor) BuildUnSignTransaction(ctx context.Context, request *walletapi.UnSignTransactionRequest) (*walletapi.UnSignTransactionResponse, error)
func (*ChainAdaptor) ConvertAddresses ¶
func (c *ChainAdaptor) ConvertAddresses(ctx context.Context, req *walletapi.ConvertAddressesRequest) (*walletapi.ConvertAddressesResponse, error)
func (*ChainAdaptor) GetAccountBalance ¶
func (c *ChainAdaptor) GetAccountBalance(ctx context.Context, req *walletapi.AccountBalanceRequest) (*walletapi.AccountBalanceResponse, error)
func (*ChainAdaptor) GetAddressApproveList ¶
func (c *ChainAdaptor) GetAddressApproveList(ctx context.Context, request *walletapi.AddressApproveListRequest) (*walletapi.AddressApproveListResponse, error)
func (*ChainAdaptor) GetBlock ¶
func (c *ChainAdaptor) GetBlock(ctx context.Context, req *walletapi.BlockRequest) (*walletapi.BlockResponse, error)
func (*ChainAdaptor) GetLastestBlock ¶
func (c *ChainAdaptor) GetLastestBlock(ctx context.Context, req *walletapi.LastestBlockRequest) (*walletapi.LastestBlockResponse, error)
func (*ChainAdaptor) GetTransactionByAddress ¶
func (c *ChainAdaptor) GetTransactionByAddress(ctx context.Context, req *walletapi.TransactionByAddressRequest) (*walletapi.TransactionByAddressResponse, error)
func (*ChainAdaptor) GetTransactionByHash ¶
func (c *ChainAdaptor) GetTransactionByHash(ctx context.Context, req *walletapi.TransactionByHashRequest) (*walletapi.TransactionByHashResponse, error)
func (*ChainAdaptor) SendTransaction ¶
func (c *ChainAdaptor) SendTransaction(ctx context.Context, req *walletapi.SendTransactionsRequest) (*walletapi.SendTransactionResponse, error)
func (*ChainAdaptor) ValidAddresses ¶
func (c *ChainAdaptor) ValidAddresses(ctx context.Context, req *walletapi.ValidAddressesRequest) (*walletapi.ValidAddressesResponse, error)
type CommitmentType ¶
type CommitmentType string
const ( // Finalized Confirmed Processed // Finalized wait 32 slot Finalized CommitmentType = "finalized" // Confirmed wait 2-3 slot Confirmed CommitmentType = "confirmed" // Processed wait 0 slot Processed CommitmentType = "processed" )
type CreateNonceAccountRequest ¶
type CreateNonceAccountRequest struct {
// payer privateKey
Payer solana.PrivateKey
// nonce account Auth, PublicKey
Authority solana.PublicKey
}
type GetAccountInfoResponse ¶
type GetAccountInfoResponse struct {
JsonRPC string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result struct {
Context struct {
// now slot
Slot uint64 `json:"slot"`
} `json:"context"`
Value AccountInfo `json:"value"`
} `json:"result"`
}
type GetBalanceResponse ¶
type GetBlockRequest ¶
type GetBlockRequest struct {
// slot status
// Finalized Confirmed Processed
Commitment CommitmentType `json:"commitment,omitempty"`
// "json", "jsonParsed", "base58", "base64"
Encoding string `json:"encoding"`
// max version
// Legacy = 0, no other version
MaxSupportedTransactionVersion int `json:"maxSupportedTransactionVersion"`
// "full", "accounts", "signatures", "none"
TransactionDetails string `json:"transactionDetails"`
// contain rewards
Rewards bool `json:"rewards"`
}
type GetBlockResponse ¶
type GetBlockResponse struct {
JsonRPC string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result BlockResult `json:"result"`
}
type GetBlocksWithLimitResponse ¶
type GetBlocksWithLimitResponse struct {
JsonRPC string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result []uint64 `json:"result"`
}
GetBlocksWithLimitResponse represents the response structure
type GetFeeForMessageRequest ¶
type GetHealthResponse ¶
type GetLatestBlockhashResponse ¶
type GetLatestBlockhashResponse struct {
JsonRPC string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result struct {
Context struct {
Slot uint64 `json:"slot"`
} `json:"context"`
Value struct {
Blockhash string `json:"blockhash"`
LastValidBlockHeight uint64 `json:"lastValidBlockHeight"`
} `json:"value"`
} `json:"result"`
}
type GetSignaturesRequest ¶
type GetSignaturesResponse ¶
type GetSignaturesResponse struct {
Jsonrpc string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result []SignatureInfo `json:"result"`
}
type GetSlotRequest ¶
type GetSlotRequest struct {
Commitment CommitmentType `json:"commitment,omitempty"`
}
type GetSlotResponse ¶
type GetTransactionResponse ¶
type GetTransactionResponse struct {
Jsonrpc string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result TransactionResult `json:"result"`
}
type Instruction ¶
type LoadedAddresses ¶
type PrioritizationFee ¶
type SendTransactionRequest ¶
type SendTransactionRequest struct {
Encoding string `json:"encoding,omitempty"`
Commitment string `json:"commitment,omitempty"`
SkipPreflight bool `json:"skipPreflight,omitempty"`
PreflightCommitment string `json:"preflightCommitment,omitempty"`
MaxRetries uint64 `json:"maxRetries,omitempty"`
MinContextSlot uint64 `json:"minContextSlot,omitempty"`
}
type SendTransactionResponse ¶
type SignatureInfo ¶
type SimulateRequest ¶
type SimulateRequest struct {
Commitment string `json:"commitment,omitempty"`
SigVerify bool `json:"sigVerify,omitempty"`
ReplaceRecentBlockhash bool `json:"replaceRecentBlockhash,omitempty"`
MinContextSlot uint64 `json:"minContextSlot,omitempty"`
Encoding string `json:"encoding,omitempty"`
Accounts *AccountsInfo `json:"accounts,omitempty"`
}
type SimulateResult ¶
type SimulateResult struct {
Err interface{} `json:"err"`
Logs []string `json:"logs"`
UnitsConsumed uint64 `json:"unitsConsumed"`
Accounts []struct {
Executable bool `json:"executable"`
Lamports uint64 `json:"lamports"`
Owner string `json:"owner"`
RentEpoch uint64 `json:"rentEpoch"`
Data []string `json:"data"`
} `json:"accounts,omitempty"`
ReturnData *struct {
ProgramId string `json:"programId"`
Data []string `json:"data"`
} `json:"returnData,omitempty"`
InnerInstructions []struct {
Index uint16 `json:"index"`
Instructions []struct {
ProgramIdIndex uint8 `json:"programIdIndex"`
Accounts []uint8 `json:"accounts"`
Data string `json:"data"`
} `json:"instructions"`
} `json:"innerInstructions,omitempty"`
}
type SimulateTransactionResponse ¶
type SimulateTransactionResponse struct {
Jsonrpc string `json:"jsonrpc"`
ID int `json:"id"`
Error *RPCError `json:"error,omitempty"`
Result SimulateResult `json:"result"`
}
type SolClient ¶
type SolClient interface {
GetHealth() (string, error)
GetAccountInfo(inputAddr string) (*AccountInfo, error)
GetBalance(inputAddr string) (uint64, error)
GetLatestBlockhash(commitmentType CommitmentType) (string, error)
SendTransaction(
signedTx string,
config *SendTransactionRequest,
) (string, error)
SimulateTransaction(
signedTx string,
config *SimulateRequest,
) (*SimulateResult, error)
GetFeeForMessage(message string) (uint64, error)
GetRecentPrioritizationFees() ([]PrioritizationFee, error)
GetSlot(commitment CommitmentType) (uint64, error)
GetBlocksWithLimit(startSlot uint64, limit uint64) ([]uint64, error)
GetBlockBySlot(slot uint64, detailType TransactionDetailsType) (*BlockResult, error)
GetTransaction(signature string) (*TransactionResult, error)
GetTransactionRange(signatures []string) ([]*TransactionResult, error)
GetTxForAddress(
address string,
commitment CommitmentType,
limit uint64,
beforeSignature string,
untilSignature string,
) ([]SignatureInfo, error)
}
func NewSolHttpClient ¶
type SolData ¶
type SolData struct {
SolDataCli *solscan.ChainExplorerAdaptor
}
func NewSolScanClient ¶
func (*SolData) GetTxByAddress ¶
func (ss *SolData) GetTxByAddress(page, pagesize uint64, address string, action account.ActionType) (*account.TransactionResponse[account.AccountTxResponse], error)
type Transaction ¶
type Transaction struct {
Message TransactionMessage `json:"message"`
Signatures []string `json:"signatures"`
}
type TransactionDetail ¶
type TransactionDetail struct {
Signature string `json:"signature"`
Slot uint64 `json:"slot"`
BlockTime int64 `json:"blockTime"`
Meta *TransactionMeta `json:"meta"`
// "version": "legacy" or "version": 0
Version any `json:"version"`
Message interface{} `json:"message"` // 使用 interface{} 因为可能为 null
RecentBlockhash string `json:"recentBlockhash"`
}
type TransactionDetailsType ¶
type TransactionDetailsType string
const ( Full TransactionDetailsType = "full" Accounts TransactionDetailsType = "accounts" Signatures TransactionDetailsType = "signatures" None TransactionDetailsType = "none" )
type TransactionHeader ¶
type TransactionMessage ¶
type TransactionMessage struct {
AccountKeys []string `json:"accountKeys"`
AddressTableLookups []interface{} `json:"addressTableLookups"`
Header TransactionHeader `json:"header"`
Instructions []Instruction `json:"instructions"`
RecentBlockhash string `json:"recentBlockhash"`
}
type TransactionMeta ¶
type TransactionMeta struct {
Err interface{} `json:"err"`
Fee uint64 `json:"fee"`
PreBalances []uint64 `json:"preBalances"`
PostBalances []uint64 `json:"postBalances"`
InnerInstructions []interface{} `json:"innerInstructions"`
PreTokenBalances []interface{} `json:"preTokenBalances"`
PostTokenBalances []interface{} `json:"postTokenBalances"`
LogMessages []string `json:"logMessages"`
LoadedAddresses LoadedAddresses `json:"loadedAddresses"`
Status struct {
Ok interface{} `json:"Ok"`
} `json:"status"`
Rewards interface{} `json:"rewards"`
ComputeUnitsConsumed uint64 `json:"computeUnitsConsumed"`
}
type TransactionResult ¶
type TransactionResult struct {
Slot uint64 `json:"slot"`
Version any `json:"version"`
BlockTime *int64 `json:"blockTime"`
Transaction Transaction `json:"transaction"`
Meta TransactionMeta `json:"meta"`
}
type TransactionVersion ¶
type TransactionVersion struct {
// contains filtered or unexported fields
}
type TxStructure ¶
type TxStructure struct {
Nonce string `json:"nonce"`
GasPrice string `json:"gas_price"`
GasTipCap string `json:"gas_tip_cap"`
GasFeeCap string `json:"gas_fee_cap"`
Gas uint64 `json:"gas"`
ContractAddress string `json:"contract_address"`
FromAddress string `json:"from_address"`
ToAddress string `json:"to_address"`
TokenId string `json:"token_id"`
Value string `json:"value"`
Signature string `json:"signature,omitempty"`
}
Click to show internal directories.
Click to hide internal directories.