Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Teyz committed Jan 8, 2025
1 parent 96af1c4 commit e01aa91
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions alchemy.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,13 @@ import (
"fmt"
)

type alchemy struct {
type AlchemyService struct {
AlchemyUrl string
Store Alchemy
}

func NewAlchemyClient(apiKey string) (*alchemy, error) {
return &alchemy{
func NewAlchemyClient(apiKey string) (*AlchemyService, error) {
return &AlchemyService{
AlchemyUrl: fmt.Sprintf("https://solana-mainnet.g.alchemy.com/v2/%s", apiKey),
}, nil
}
10 changes: 5 additions & 5 deletions solana.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
rpc "github.com/teyz/go-alchemy-sdk/rpc"
)

func (a *alchemy) GetAccountInfo(address string, encodingType rpc.EncodingType, commitment rpc.CommitmentType) (*rpc.GetAccountInfoResponse, error) {
func (a *AlchemyService) GetAccountInfo(address string, encodingType rpc.EncodingType, commitment rpc.CommitmentType) (*rpc.GetAccountInfoResponse, error) {
requestBody := &rpc.AlchemyRequest{
JsonRPC: rpc.JsonRPCVersion2_0,
Method: rpc.MethodGetAccountInfo,
Expand All @@ -36,7 +36,7 @@ func (a *alchemy) GetAccountInfo(address string, encodingType rpc.EncodingType,
return parsedResponse, nil
}

func (a *alchemy) GetBalance(address string) (*rpc.GetBalanceResponse, error) {
func (a *AlchemyService) GetBalance(address string) (*rpc.GetBalanceResponse, error) {
requestBody := &rpc.AlchemyRequest{
JsonRPC: rpc.JsonRPCVersion2_0,
Method: rpc.MethodGetBalance,
Expand All @@ -59,7 +59,7 @@ func (a *alchemy) GetBalance(address string) (*rpc.GetBalanceResponse, error) {
return parsedResponse, nil
}

func (a *alchemy) GetBlock(slotNumber uint64, commitment rpc.CommitmentType, maxSupportedTransactionVersion *uint64) (*rpc.GetBlockResponse, error) {
func (a *AlchemyService) GetBlock(slotNumber uint64, commitment rpc.CommitmentType, maxSupportedTransactionVersion *uint64) (*rpc.GetBlockResponse, error) {
requestBody := &rpc.AlchemyRequest{
JsonRPC: rpc.JsonRPCVersion2_0,
Method: rpc.MethodGetBlock,
Expand Down Expand Up @@ -90,7 +90,7 @@ func (a *alchemy) GetBlock(slotNumber uint64, commitment rpc.CommitmentType, max
return parsedResponse, nil
}

func (a *alchemy) GetTransaction(signature string, commitment rpc.CommitmentType, maxSupportedTransactionVersion *uint64) (*rpc.GetTransactionResponse, error) {
func (a *AlchemyService) GetTransaction(signature string, commitment rpc.CommitmentType, maxSupportedTransactionVersion *uint64) (*rpc.GetTransactionResponse, error) {
requestBody := &rpc.AlchemyRequest{
JsonRPC: rpc.JsonRPCVersion2_0,
Method: rpc.MethodGetTransaction,
Expand Down Expand Up @@ -140,7 +140,7 @@ func (a *alchemy) GetTransaction(signature string, commitment rpc.CommitmentType
return parsedResponse, nil
}

func (a *alchemy) RequestAirdrop(address string, lamports uint64, commitment rpc.CommitmentType) (*rpc.RequestAirdropResponse, error) {
func (a *AlchemyService) RequestAirdrop(address string, lamports uint64, commitment rpc.CommitmentType) (*rpc.RequestAirdropResponse, error) {
requestBody := &rpc.AlchemyRequest{
JsonRPC: rpc.JsonRPCVersion2_0,
Method: rpc.MethodRequestAirdrop,
Expand Down
2 changes: 1 addition & 1 deletion src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func main() {
}

test := uint64(0)
alchemy.GetTransaction("28XtqRGx5HNYe7qaZkLESD6MeGdHw2PApzBWs3dFF3bJtJ9rQfTLoMBRnpyU77cNt2tTD96bDtoLKc9FAhru4vyB", rpc.CommitmentFinalized, &test)
alchemy.Store.GetTransaction("28XtqRGx5HNYe7qaZkLESD6MeGdHw2PApzBWs3dFF3bJtJ9rQfTLoMBRnpyU77cNt2tTD96bDtoLKc9FAhru4vyB", rpc.CommitmentFinalized, &test)
//alchemy.GetAccountInfo("5eG7mnKDyi7zpb5wacK7K7GRy8pbgFKCBoL54WAe6kVj", rpc.EncodingBase58, rpc.CommitmentFinalized)
//alchemy.GetBlock(307494832, rpc.CommitmentFinalized, &test)
//alchemy.RequestAirdrop("5eG7mnKDyi7zpb5wacK7K7GRy8pbgFKCBoL54WAe6kVj", 1000000000, rpc.CommitmentFinalized)
Expand Down
2 changes: 1 addition & 1 deletion utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"reflect"
)

func (a *alchemy) makeCall(method string, requestBody interface{}, expectedResponse interface{}) (interface{}, error) {
func (a *AlchemyService) makeCall(method string, requestBody interface{}, expectedResponse interface{}) (interface{}, error) {
jsonData, err := json.Marshal(requestBody)
if err != nil {
return nil, fmt.Errorf("error marshaling request body: %w", err)
Expand Down

0 comments on commit e01aa91

Please sign in to comment.