Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

accountInfo struct refine #261

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions rpc/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2744,7 +2744,7 @@ func TestClient_GetTokenAccountBalance(t *testing.T) {
}

func TestClient_GetTokenAccountsByDelegate(t *testing.T) {
responseBody := `{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":1,"isInitialized":true,"isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}}},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4},"pubkey":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}]}`
responseBody := `{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":"4Nd1mBQtrMJVYVfKf2PJy9NZUZdTAsp7D4xWLs4gDB4T","delegatedAmount":1,"isInitialized":true,"isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}}},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4,"space":0},"pubkey":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}]}`
server, closer := mockJSONRPC(t, stdjson.RawMessage(wrapIntoRPC(responseBody)))
defer closer()
client := New(server.URL)
Expand Down Expand Up @@ -2800,7 +2800,7 @@ func TestClient_GetTokenAccountsByDelegate(t *testing.T) {
}

func TestClient_GetTokenAccountsByOwner(t *testing.T) {
responseBody := `{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":null,"delegatedAmount":1,"isInitialized":true,"isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"}}},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4},"pubkey":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}]}`
responseBody := `{"context":{"slot":1114},"value":[{"account":{"data":{"program":"spl-token","parsed":{"accountType":"account","info":{"tokenAmount":{"amount":"1","decimals":1,"uiAmount":0.1,"uiAmountString":"0.1"},"delegate":null,"delegatedAmount":1,"isInitialized":true,"isNative":false,"mint":"3wyAj7Rt1TWVPZVteFJPLa26JmLvdb1CAKEFZm3NY75E","owner":"4Qkev8aNZcqFNSRhQzwyLMFSsi94jHqE8WNVTJzTP99F"}}},"executable":false,"lamports":1726080,"owner":"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","rentEpoch":4,"space":0},"pubkey":"CnPoSPKXu7wJqxe59Fs72tkBeALovhsCxYeFwPCQH9TD"}]}`
server, closer := mockJSONRPC(t, stdjson.RawMessage(wrapIntoRPC(responseBody)))
defer closer()
client := New(server.URL)
Expand Down
3 changes: 3 additions & 0 deletions rpc/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,9 @@ type Account struct {

// The epoch at which this account will next owe rent
RentEpoch *big.Int `json:"rentEpoch"`

// The amount of storage space required to store the token account
Space uint64 `json:"space"`
}

type DataBytesOrJSON struct {
Expand Down
6 changes: 2 additions & 4 deletions rpc/ws/accountSubscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@ import (

type AccountResult struct {
Context struct {
Slot uint64
Slot uint64 `json:"slot"`
} `json:"context"`
Value struct {
rpc.Account
} `json:"value"`
Value *rpc.Account `json:"value"`
}

// AccountSubscribe subscribes to an account to receive notifications
Expand Down
8 changes: 4 additions & 4 deletions rpc/ws/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ func Test_AccountSubscribe(t *testing.T) {
return
}
text.NewEncoder(os.Stdout).Encode(data, nil)
fmt.Println("OpenOrders: ", data.Value.Account.Owner)
fmt.Println("data: ", data.Value.Account.Data)
fmt.Println("OpenOrders: ", data.Value.Owner)
fmt.Println("data: ", data.Value.Data)
return
}

Expand Down Expand Up @@ -107,8 +107,8 @@ func Test_AccountSubscribeWithHttpHeader(t *testing.T) {
t.Errorf("encoding error: %v", err)
}

t.Log("OpenOrders: ", data.Value.Account.Owner)
t.Log("data: ", data.Value.Account.Data)
t.Log("OpenOrders: ", data.Value.Owner)
t.Log("data: ", data.Value.Data)
}

func Test_ProgramSubscribe(t *testing.T) {
Expand Down