Skip to content

Commit

Permalink
correct typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ws4charlie committed Nov 29, 2024
1 parent 632ee11 commit f774c0e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/contracts/solana/instruction.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ func (inst *WhitelistInstructionParams) TokenAmount() uint64 {

// Failed always returns false for a 'whitelist_spl_mint' without checking the logs
func (inst *WhitelistInstructionParams) Failed(_ []string) bool {
return true
return false

Check warning on line 270 in pkg/contracts/solana/instruction.go

View check run for this annotation

Codecov / codecov/patch

pkg/contracts/solana/instruction.go#L269-L270

Added lines #L269 - L270 were not covered by tests
}

// ParseInstructionWhitelist tries to parse the instruction as a 'whitelist_spl_mint'.
Expand Down
44 changes: 44 additions & 0 deletions zetaclient/chains/solana/rpc/rpc_live_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,14 @@ package rpc_test

import (
"context"
"fmt"
"testing"

"github.com/gagliardetto/solana-go"
solanarpc "github.com/gagliardetto/solana-go/rpc"
"github.com/stretchr/testify/require"
"github.com/zeta-chain/node/pkg/coin"
"github.com/zeta-chain/node/zetaclient/chains/solana/observer"
"github.com/zeta-chain/node/zetaclient/chains/solana/rpc"
"github.com/zeta-chain/node/zetaclient/common"
)
Expand All @@ -17,6 +20,7 @@ func Test_SolanaRPCLive(t *testing.T) {
return
}

LiveTest_GetTransactionMessage(t)
LiveTest_GetTransactionWithVersion(t)
LiveTest_GetFirstSignatureForAddress(t)
LiveTest_GetSignaturesForAddressUntil(t)
Expand All @@ -41,6 +45,46 @@ func LiveTest_GetTransactionWithVersion(t *testing.T) {
})
}

func LiveTest_GetTransactionMessage(t *testing.T) {
// create a Solana devnet RPC client
client := solanarpc.New(solanarpc.DevNet_RPC)

// program address
gateway := solana.MustPublicKeyFromBase58("ZETAjseVjuFsxdRxo6MmTCvqFwb3ZHUx56Co3vCmGis")

// get all signatures for the address until the first signature
sig := solana.MustSignatureFromBase58(
"hrjQH7CJgZU675eDbM3JKKf3tAd3AYtKjtpdSN7bHT4FYPDsFKeJq1BMWjjYLsTJVh1xqE4YNBXwAh2sCE4nxUL",
)

txResult, err := client.GetTransaction(context.Background(), sig, &solanarpc.GetTransactionOpts{
Commitment: solanarpc.CommitmentFinalized,
MaxSupportedTransactionVersion: &solanarpc.MaxSupportedTransactionVersion0,
})
require.NoError(t, err)
require.Nil(t, txResult.Meta.Err)

// parse gateway instruction from tx result
inst, err := observer.ParseGatewayInstruction(txResult, gateway, coin.CoinType_Gas)
require.NoError(t, err)

// get the message
fmt.Printf("inst: %+v\n", inst)

// example transaction of version "0"
// https://explorer.solana.com/tx/Wqgj7hAaUUSfLzieN912G7GxyGHijzBZgY135NtuFtPRjevK8DnYjWwQZy7LAKFQZu582wsjuab2QP27VMUJzAi?cluster=devnet
txSig := solana.MustSignatureFromBase58(
"Wqgj7hAaUUSfLzieN912G7GxyGHijzBZgY135NtuFtPRjevK8DnYjWwQZy7LAKFQZu582wsjuab2QP27VMUJzAi",
)

t.Run("should get the transaction if the version is supported", func(t *testing.T) {
ctx := context.Background()
txResult, err := rpc.GetTransaction(ctx, client, txSig)
require.NoError(t, err)
require.NotNil(t, txResult)
})
}

func LiveTest_GetFirstSignatureForAddress(t *testing.T) {
// create a Solana devnet RPC client
client := solanarpc.New(solanarpc.DevNet_RPC)
Expand Down

0 comments on commit f774c0e

Please sign in to comment.