diff --git a/.changeset/nervous-emus-move.md b/.changeset/nervous-emus-move.md new file mode 100644 index 000000000000..45900d79dc52 --- /dev/null +++ b/.changeset/nervous-emus-move.md @@ -0,0 +1,6 @@ +--- +'@solana/rpc-types': patch +'@solana/accounts': patch +--- + +Add missing `space` attribute to `AccountInfoBase` and `BaseAccount` diff --git a/packages/accounts/src/__tests__/decode-account-test.ts b/packages/accounts/src/__tests__/decode-account-test.ts index 16f8206a5a63..ff85ca29c465 100644 --- a/packages/accounts/src/__tests__/decode-account-test.ts +++ b/packages/accounts/src/__tests__/decode-account-test.ts @@ -22,6 +22,7 @@ describe('decodeAccount', () => { executable: false, lamports: 1_000_000_000n, programAddress: '9999', + space: 3n, }; // And a mock decoder. @@ -37,6 +38,7 @@ describe('decodeAccount', () => { executable: false, lamports: 1_000_000_000n, programAddress: '9999', + space: 3n, }); // And the decoder to have been called with the encoded account data. @@ -51,6 +53,7 @@ describe('decodeAccount', () => { executable: false, lamports: 1_000_000_000n, programAddress: '9999', + space: 3n, }; // And a mock decoder. diff --git a/packages/accounts/src/__tests__/fetch-account-test.ts b/packages/accounts/src/__tests__/fetch-account-test.ts index e341cce030a8..d4bd0bc0c097 100644 --- a/packages/accounts/src/__tests__/fetch-account-test.ts +++ b/packages/accounts/src/__tests__/fetch-account-test.ts @@ -23,6 +23,7 @@ describe('fetchEncodedAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }, }); @@ -38,6 +39,7 @@ describe('fetchEncodedAccount', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 6n, }); // And the getAccountInfo RPC method to have been called with the given address and an explicit base64 encoding. @@ -73,6 +75,7 @@ describe('fetchEncodedAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }, }); @@ -98,11 +101,12 @@ describe('fetchJsonParsedAccount', () => { type: 'token', }, program: 'splToken', - space: 165n, + space: 165n, // The space field is provided again on some JSON-parsed RPC response. }, executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 165n, }, }); @@ -119,6 +123,7 @@ describe('fetchJsonParsedAccount', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 165n, }); // And the getAccountInfo RPC method to have been called with the given address and an explicit jsonParsed encoding. @@ -188,6 +193,7 @@ describe('fetchEncodedAccounts', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }, }); @@ -206,6 +212,7 @@ describe('fetchEncodedAccounts', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 6n, }); // And account B is returned as a non-existing account. @@ -229,6 +236,7 @@ describe('fetchEncodedAccounts', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }, }); @@ -258,11 +266,12 @@ describe('fetchJsonParsedAccounts', () => { type: 'token', }, program: 'splToken', - space: 165n, + space: 165n, // The space field is provided again on some JSON-parsed RPC response. }, executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 165n, }, }); @@ -282,6 +291,7 @@ describe('fetchJsonParsedAccounts', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 165n, }); // And account B is returned as a non-existing account. diff --git a/packages/accounts/src/__tests__/parse-account-test.ts b/packages/accounts/src/__tests__/parse-account-test.ts index 9611c957625f..354b4be4280c 100644 --- a/packages/accounts/src/__tests__/parse-account-test.ts +++ b/packages/accounts/src/__tests__/parse-account-test.ts @@ -17,6 +17,7 @@ describe('parseBase64RpcAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }; // When we parse that RPC account using the parseBase64RpcAccount function. @@ -33,6 +34,7 @@ describe('parseBase64RpcAccount', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 6n, }); }); @@ -58,6 +60,7 @@ describe('parseBase64RpcAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }; // When we parse that RPC account using the parseBase64RpcAccount function. @@ -88,6 +91,7 @@ describe('parseBase58RpcAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }; // When we parse that RPC account using the parseBase58RpcAccount function. @@ -104,6 +108,7 @@ describe('parseBase58RpcAccount', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 6n, }); }); @@ -115,6 +120,7 @@ describe('parseBase58RpcAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }; // When we parse that RPC account using the parseBase58RpcAccount function. @@ -131,6 +137,7 @@ describe('parseBase58RpcAccount', () => { exists: true, lamports: 1_000_000_000n, programAddress: '9999', + space: 6n, }); }); @@ -156,6 +163,7 @@ describe('parseBase58RpcAccount', () => { executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 6n, }; // When we parse that RPC account using the parseBase58RpcAccount function. @@ -188,11 +196,12 @@ describe('parseJsonRpcAccount', () => { type: 'token', }, program: 'splToken', - space: 165n, + space: 165n, // The space field is provided again on some JSON-parsed RPC response. }, executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 165n, }; // When we parse that RPC account using the parseJsonRpcAccount function and a custom data type. @@ -210,6 +219,7 @@ describe('parseJsonRpcAccount', () => { exists: true, lamports: lamports(1_000_000_000n), programAddress: '9999' as Address<'9999'>, + space: 165n, } as Account); }); @@ -238,11 +248,12 @@ describe('parseJsonRpcAccount', () => { type: 'token', }, program: 'splToken', - space: 165n, + space: 165n, // The space field is provided again on some JSON-parsed RPC response. }, executable: false, lamports: 1_000_000_000n, owner: '9999', + space: 165n, }; // When we parse that RPC account using the parseJsonRpcAccount function. diff --git a/packages/accounts/src/account.ts b/packages/accounts/src/account.ts index bd57adcbfbad..ddbcd2f50977 100644 --- a/packages/accounts/src/account.ts +++ b/packages/accounts/src/account.ts @@ -10,6 +10,7 @@ export type BaseAccount = { readonly executable: boolean; readonly lamports: Lamports; readonly programAddress: Address; + readonly space: bigint; }; /** Defines a Solana account with its generic details and parsed or encoded data. */ diff --git a/packages/accounts/src/parse-account.ts b/packages/accounts/src/parse-account.ts index 62d8da356f2d..c129e0d6c4e2 100644 --- a/packages/accounts/src/parse-account.ts +++ b/packages/accounts/src/parse-account.ts @@ -76,5 +76,6 @@ function parseBaseAccount(rpcAccount: AccountInfoBase): BaseAccount { executable: rpcAccount.executable, lamports: rpcAccount.lamports, programAddress: rpcAccount.owner, + space: rpcAccount.space, }); } diff --git a/packages/library/src/__tests__/decompile-transaction-message-fetching-lookup-tables-test.ts b/packages/library/src/__tests__/decompile-transaction-message-fetching-lookup-tables-test.ts index 110b3f844791..b889bcefd2a2 100644 --- a/packages/library/src/__tests__/decompile-transaction-message-fetching-lookup-tables-test.ts +++ b/packages/library/src/__tests__/decompile-transaction-message-fetching-lookup-tables-test.ts @@ -269,6 +269,7 @@ describe('decompileTransactionMessageFetchingLookupTables', () => { exists: true, lamports: 0n as Lamports, programAddress: 'program' as Address, + space: 0n, }, { address: lookupTableAddress2, @@ -279,6 +280,7 @@ describe('decompileTransactionMessageFetchingLookupTables', () => { exists: true, lamports: 0n as Lamports, programAddress: 'program' as Address, + space: 0n, }, ]; diff --git a/packages/rpc-types/src/account-info.ts b/packages/rpc-types/src/account-info.ts index d93160b41018..4328c84f3a13 100644 --- a/packages/rpc-types/src/account-info.ts +++ b/packages/rpc-types/src/account-info.ts @@ -17,6 +17,8 @@ export type AccountInfoBase = Readonly<{ owner: Address; /** the epoch at which this account will next owe rent */ rentEpoch: bigint; + /** the size of the account data in bytes (excluding the 128 bytes of header) */ + space: bigint; }>; /** @deprecated */