Skip to content

Commit f829a21

Browse files
wmhHunter
and
Hunter
authored
Add field to the accountInfo struct and correct the WebSocket accountInfo definition (#261)
Co-authored-by: Hunter <[email protected]>
1 parent 3786857 commit f829a21

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

rpc/client_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -2744,7 +2744,7 @@ func TestClient_GetTokenAccountBalance(t *testing.T) {
27442744
}
27452745

27462746
func TestClient_GetTokenAccountsByDelegate(t *testing.T) {
2747-
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"}]}`
2747+
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"}]}`
27482748
server, closer := mockJSONRPC(t, stdjson.RawMessage(wrapIntoRPC(responseBody)))
27492749
defer closer()
27502750
client := New(server.URL)
@@ -2800,7 +2800,7 @@ func TestClient_GetTokenAccountsByDelegate(t *testing.T) {
28002800
}
28012801

28022802
func TestClient_GetTokenAccountsByOwner(t *testing.T) {
2803-
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"}]}`
2803+
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"}]}`
28042804
server, closer := mockJSONRPC(t, stdjson.RawMessage(wrapIntoRPC(responseBody)))
28052805
defer closer()
28062806
client := New(server.URL)

rpc/types.go

+3
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,9 @@ type Account struct {
322322

323323
// The epoch at which this account will next owe rent
324324
RentEpoch *big.Int `json:"rentEpoch"`
325+
326+
// The amount of storage space required to store the token account
327+
Space uint64 `json:"space"`
325328
}
326329

327330
type DataBytesOrJSON struct {

rpc/ws/accountSubscribe.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ import (
2323

2424
type AccountResult struct {
2525
Context struct {
26-
Slot uint64
26+
Slot uint64 `json:"slot"`
2727
} `json:"context"`
28-
Value struct {
29-
rpc.Account
30-
} `json:"value"`
28+
Value *rpc.Account `json:"value"`
3129
}
3230

3331
// AccountSubscribe subscribes to an account to receive notifications

rpc/ws/client_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ func Test_AccountSubscribe(t *testing.T) {
5151
return
5252
}
5353
text.NewEncoder(os.Stdout).Encode(data, nil)
54-
fmt.Println("OpenOrders: ", data.Value.Account.Owner)
55-
fmt.Println("data: ", data.Value.Account.Data)
54+
fmt.Println("OpenOrders: ", data.Value.Owner)
55+
fmt.Println("data: ", data.Value.Data)
5656
return
5757
}
5858

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

110-
t.Log("OpenOrders: ", data.Value.Account.Owner)
111-
t.Log("data: ", data.Value.Account.Data)
110+
t.Log("OpenOrders: ", data.Value.Owner)
111+
t.Log("data: ", data.Value.Data)
112112
}
113113

114114
func Test_ProgramSubscribe(t *testing.T) {

0 commit comments

Comments
 (0)