gagliardetto / solana-go

Go SDK library and RPC client for the Solana Blockchain
Apache License 2.0
943 stars 267 forks source link

what the mint of usdt? #147

Open yangyile1990 opened 1 year ago

yangyile1990 commented 1 year ago

func (s Solana) BalanceOfContract(addr string, contract string) (value decimal.Decimal, symbol string, erc cerror.CError) { pubKey, err := solana.PublicKeyFromBase58(addr) if err != nil { return decimal.Zero, "", cerror.NewError(cerror.CODE_ADDR_ERROR, err.Error()) } out, err := s.client.GetTokenAccountsByDelegate( context.TODO(), pubKey, &rpc.GetTokenAccountsConfig{ Mint: solana.MustPublicKeyFromBase58(contract).ToPointer(), }, &rpc.GetTokenAccountsOpts{ Commitment: rpc.CommitmentFinalized, }, ) if err != nil { return decimal.Zero, "", cerror.NewError(cerror.CODE_THIRD_REQ_ERROR, err.Error()) } fmt.Println(out) //s.client.GetTokenAccountsByOwner(context.TODO(), pubKey, &rpc.GetTokenAccountsConfig{},&rpc.GetTokenAccountsOpts{}) return decimal.Zero, "", nil }

func TestSolana_BalanceOfContract(t *testing.T) { //value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "So11111111111111111111111111111111111111112") value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "FEYFyLCFLcBNfSuaf2eXNvyY5Jpii7zg9X48Br5vyenG") //value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB") require.Nil(t, erc) require.NotEmpty(t, symbol) t.Log(value) }

        Error:          Expected nil, but got: &cerror.CError{Code:1008, Msg:"(*jsonrpc.RPCError)(0x140003942d0)({\n Code: (int) -32602,\n Message: (string) (len=34) \"Invalid param: could not find mint\",\n Data: (interface {}) <nil>\n})\n"}
yangyile1990 commented 1 year ago

func TestSolana_BalanceOfContract(t *testing.T) { //value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "So11111111111111111111111111111111111111112") //value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "FEYFyLCFLcBNfSuaf2eXNvyY5Jpii7zg9X48Br5vyenG") value, symbol, erc := caseSolana.BalanceOfContract("7xLk17EQQ5KLDLDe44wCmupJKJjTGd8hs3eSVVhCx932", "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB") require.Nil(t, erc) require.NotEmpty(t, symbol) t.Log(value) }

solana_test.go:26: 
        Error:          Expected nil, but got: &cerror.CError{Code:1008, Msg:"(*jsonrpc.RPCError)(0x140002e62d0)({\n Code: (int) -32602,\n Message: (string) (len=47) \"Invalid param: Token mint could not be unpacked\",\n Data: (interface {}) <nil>\n})\n"}
        Test:           TestSolana_BalanceOfContract

--- FAIL: TestSolana_BalanceOfContract (0.60s)

FAIL

进程 已完成,退出代码为 1

yangyile1990 commented 1 year ago

So11111111111111111111111111111111111111112 what's this?

0xvbetsun commented 1 year ago

So11111111111111111111111111111111111111112 - it is a SOL mint. And mint of USDT is Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB