New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@solana/accounts

Package Overview
Dependencies
Maintainers
1
Versions
1009
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@solana/accounts - npm Package Compare versions

Comparing version

to
2.1.0-canary-20250227211824

83

dist/types/account.d.ts
import type { Address } from '@solana/addresses';
import { ReadonlyUint8Array } from '@solana/codecs-core';
import type { Lamports } from '@solana/rpc-types';
/** The amount of bytes required to store the base account information without its data. */
/**
* The number of bytes required to store the {@link BaseAccount} information without its data.
*
* @example
* ```ts
* const myTotalAccountSize = myAccountDataSize + BASE_ACCOUNT_SIZE;
* ```
*/
export declare const BASE_ACCOUNT_SIZE = 128;
/** Describe the generic account details applicable to every account. */
/**
* Defines the attributes common to all Solana accounts. Namely, it contains everything stored
* on-chain except the account data itself.
*
* @interface
*
* @example
* ```ts
* const BaseAccount: BaseAccount = {
* executable: false,
* lamports: lamports(1_000_000_000n),
* programAddress: address('1111..1111'),
* space: 42n,
* };
* ```
*/
export type BaseAccount = {

@@ -13,3 +35,37 @@ readonly executable: boolean;

};
/** Defines a Solana account with its generic details and parsed or encoded data. */
/**
* Contains all the information relevant to a Solana account. It includes the account's address and
* data, as well as the properties of {@link BaseAccount}.
*
* @interface
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The nature of this account's data. It can be represented as either a
* `Uint8Array` – meaning the account is encoded – or a custom data type – meaning
* the account is decoded.
*
* @example
* ```ts
* // Encoded
* const myEncodedAccount: Account<Uint8Array, '1234..5678'> = {
* address: address('1234..5678'),
* data: new Uint8Array([1, 2, 3]),
* executable: false,
* lamports: lamports(1_000_000_000n),
* programAddress: address('1111..1111'),
* space: 42n,
* };
*
* // Decoded
* type MyAccountData = { name: string; age: number };
* const myDecodedAccount: Account<MyAccountData, '1234..5678'> = {
* address: address('1234..5678'),
* data: { name: 'Alice', age: 30 },
* executable: false,
* lamports: lamports(1_000_000_000n),
* programAddress: address('1111..1111'),
* space: 42n,
* };
* ```
*/
export type Account<TData extends Uint8Array | object, TAddress extends string = string> = BaseAccount & {

@@ -19,4 +75,23 @@ readonly address: Address<TAddress>;

};
/** Defines a Solana account with its generic details and encoded data. */
/**
* Represents an encoded account and is equivalent to an {@link Account} with `Uint8Array` account
* data.
*
* @interface
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
*
* @example
* ```ts
* {
* address: address('1234..5678'),
* data: new Uint8Array([1, 2, 3]),
* executable: false,
* lamports: lamports(1_000_000_000n),
* programAddress: address('1111..1111'),
* space: 42n,
* } satisfies EncodedAccount<'1234..5678'>;
* ```
*/
export type EncodedAccount<TAddress extends string = string> = Account<ReadonlyUint8Array, TAddress>;
//# sourceMappingURL=account.d.ts.map
import type { Decoder, ReadonlyUint8Array } from '@solana/codecs-core';
import type { Account, EncodedAccount } from './account';
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account';
/** Decodes the data of a given account using the provided decoder. */
/**
* Transforms an {@link EncodedAccount} into an {@link Account} (or a {@link MaybeEncodedAccount}
* into a {@link MaybeAccount}) by decoding the account data using the provided {@link Decoder}
* instance.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The type of this account's data.
*
* @example
* ```ts
* type MyAccountData = { name: string; age: number };
*
* const myAccount: EncodedAccount<'1234..5678'>;
* const myDecoder: Decoder<MyAccountData> = getStructDecoder([
* ['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
* ['age', getU32Decoder()],
* ]);
*
* const myDecodedAccount = decodeAccount(myAccount, myDecoder);
* myDecodedAccount satisfies Account<MyAccountData, '1234..5678'>;
* ```
*/
export declare function decodeAccount<TData extends object, TAddress extends string = string>(encodedAccount: EncodedAccount<TAddress>, decoder: Decoder<TData>): Account<TData, TAddress>;
export declare function decodeAccount<TData extends object, TAddress extends string = string>(encodedAccount: MaybeEncodedAccount<TAddress>, decoder: Decoder<TData>): MaybeAccount<TData, TAddress>;
/** Asserts that an account has been decoded. */
/**
* Asserts that an account stores decoded data, ie. not a `Uint8Array`.
*
* Note that it does not check the shape of the data matches the decoded type, only that it is not a
* `Uint8Array`.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The type of this account's data.
*
* @example
* ```ts
* type MyAccountData = { name: string; age: number };
*
* const myAccount: Account<MyAccountData | Uint8Array, '1234..5678'>;
* assertAccountDecoded(myAccount);
*
* // now the account data can be used as MyAccountData
* account.data satisfies MyAccountData;
* ```
*
* This is particularly useful for narrowing the result of fetching a JSON parsed account.
*
* ```ts
* const account: MaybeAccount<MockData | Uint8Array> = await fetchJsonParsedAccount<MockData>(
* rpc,
* '1234..5678' as Address,
* );
*
* assertAccountDecoded(account);
* // now we have a MaybeAccount<MockData>
* account satisfies MaybeAccount<MockData>;
* ```
*/
export declare function assertAccountDecoded<TData extends object, TAddress extends string = string>(account: Account<TData | Uint8Array, TAddress>): asserts account is Account<TData, TAddress>;
export declare function assertAccountDecoded<TData extends object, TAddress extends string = string>(account: MaybeAccount<TData | Uint8Array, TAddress>): asserts account is MaybeAccount<TData, TAddress>;
/** Asserts that all accounts have been decoded. */
/**
* Asserts that all input accounts store decoded data, ie. not a `Uint8Array`.
*
* As with {@link assertAccountDecoded} it does not check the shape of the data matches the decoded
* type, only that it is not a `Uint8Array`.
*
* @example
* ```ts
* type MyAccountData = { name: string; age: number };
*
* const myAccounts: Account<MyAccountData | Uint8Array, Address>[];
* assertAccountsDecoded(myAccounts);
*
* // now the account data can be used as MyAccountData
* for (const a of account) {
* account.data satisfies MyAccountData;
* }
* ```
*/
export declare function assertAccountsDecoded<TData extends object, TAddress extends string = string>(accounts: Account<ReadonlyUint8Array | TData, TAddress>[]): asserts accounts is Account<TData, TAddress>[];
export declare function assertAccountsDecoded<TData extends object, TAddress extends string = string>(accounts: MaybeAccount<ReadonlyUint8Array | TData, TAddress>[]): asserts accounts is MaybeAccount<TData, TAddress>[];
//# sourceMappingURL=decode-account.d.ts.map

@@ -6,3 +6,7 @@ import type { Address } from '@solana/addresses';

import type { GetAccountInfoApi, GetMultipleAccountsApi } from './rpc-api';
/** Optional configuration for fetching a singular account. */
/**
* Optional configuration for fetching a singular account.
*
* @interface
*/
export type FetchAccountConfig = {

@@ -13,7 +17,55 @@ abortSignal?: AbortSignal;

};
/** Fetch a base64-encoded account that may or may not exist using an RPC client. */
/**
* Fetches a {@link MaybeEncodedAccount} from the provided RPC client and address.
*
* It uses the {@link GetAccountInfoApi.getAccountInfo | getAccountInfo} RPC method under the hood
* with base64 encoding and an additional configuration object can be provided to customize the
* behavior of the RPC call.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
*
* @example
* ```ts
* const myAddress = address('1234..5678');
* const myAccount: MaybeEncodedAccount<'1234..5678'> = await fetchEncodedAccount(rpc, myAddress);
*
* // With custom configuration.
* const myAccount: MaybeEncodedAccount<'1234..5678'> = await fetchEncodedAccount(rpc, myAddress, {
* abortSignal: myAbortController.signal,
* commitment: 'confirmed',
* });
* ```
*/
export declare function fetchEncodedAccount<TAddress extends string = string>(rpc: Rpc<GetAccountInfoApi>, address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeEncodedAccount<TAddress>>;
/** Fetch a json-parsed account that may or may not exist using an RPC client. */
/**
* Fetches a {@link MaybeAccount} from the provided RPC client and address by using
* {@link GetAccountInfoApi.getAccountInfo | getAccountInfo} under the hood with the `jsonParsed`
* encoding.
*
* It may also return a {@link MaybeEncodedAccount} if the RPC client does not know how to parse the
* account at the requested address. In any case, the expected data type should be explicitly
* provided as the first type parameter.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The expected type of this account's data.
*
* @example
* ```ts
* type TokenData = { mint: Address; owner: Address };
* const myAccount = await fetchJsonParsedAccount<TokenData>(rpc, myAddress);
* myAccount satisfies MaybeAccount<TokenData> | MaybeEncodedAccount;
*
* // With custom configuration.
* const myAccount = await fetchJsonParsedAccount<TokenData>(rpc, myAddress, {
* abortSignal: myAbortController.signal,
* commitment: 'confirmed',
* });
* ```
*/
export declare function fetchJsonParsedAccount<TData extends object, TAddress extends string = string>(rpc: Rpc<GetAccountInfoApi>, address: Address<TAddress>, config?: FetchAccountConfig): Promise<MaybeAccount<TData, TAddress> | MaybeEncodedAccount<TAddress>>;
/** Optional configuration for fetching multiple accounts. */
/**
* Optional configuration for fetching multiple accounts.
*
* @interface
*/
export type FetchAccountsConfig = {

@@ -24,3 +76,28 @@ abortSignal?: AbortSignal;

};
/** Fetch multiple base64-encoded accounts that may or may not exist using an RPC client. */
/**
* Fetches an array of {@link MaybeEncodedAccount | MaybeEncodedAccounts} from the provided RPC
* client and an array of addresses.
*
* It uses the {@link GetMultipleAccountsApi#getMultipleAccounts | getMultipleAccounts} RPC method
* under the hood with base64 encodings and an additional configuration object can be provided to
* customize the behavior of the RPC call.
*
* @typeParam TAddresses - Supply an array of string literals to define accounts having particular
* addresses.
*
* @example
* ```ts
* const myAddressA = address('1234..5678');
* const myAddressB = address('8765..4321');
* const [myAccountA, myAccountB] = await fetchEncodedAccounts(rpc, [myAddressA, myAddressB]);
* myAccountA satisfies MaybeEncodedAccount<'1234..5678'>;
* myAccountB satisfies MaybeEncodedAccount<'8765..4321'>;
*
* // With custom configuration.
* const [myAccountA, myAccountB] = await fetchEncodedAccounts(rpc, [myAddressA, myAddressB], {
* abortSignal: myAbortController.signal,
* commitment: 'confirmed',
* });
* ```
*/
export declare function fetchEncodedAccounts<TAddresses extends string[] = string[], TWrappedAddresses extends {

@@ -31,3 +108,25 @@ [P in keyof TAddresses]: Address<TAddresses[P]>;

}>(rpc: Rpc<GetMultipleAccountsApi>, addresses: TWrappedAddresses, config?: FetchAccountsConfig): Promise<{ [P in keyof TAddresses]: MaybeEncodedAccount<TAddresses[P]>; }>;
/** Fetch multiple json-parsed accounts that may or may not exist using an RPC client. */
/**
* Fetches an array of {@link MaybeAccount | MaybeAccounts} from a provided RPC client and an array
* of addresses.
*
* It uses the {@link GetMultipleAccountsApi#getMultipleAccounts | getMultipleAccounts} RPC method
* under the hood with the `jsonParsed` encoding. It may also return a
* {@link MaybeEncodedAccount} instead of the expected {@link MaybeAccount} if the RPC client does
* not know how to parse some of the requested accounts. In any case, the array of expected data
* types should be explicitly provided as the first type parameter.
*
* @typeParam TAddresses - Supply an array of string literals to define accounts having particular
* addresses.
* @typeParam TData - The expected types of these accounts' data.
* @example
* ```ts
* type TokenData = { mint: Address; owner: Address };
* type MintData = { supply: bigint };
* const [myAccountA, myAccountB] = await fetchJsonParsedAccounts<[TokenData, MintData]>(rpc, [myAddressA, myAddressB]);
* myAccountA satisfies MaybeAccount<TokenData> | MaybeEncodedAccount;
* myAccountB satisfies MaybeAccount<MintData> | MaybeEncodedAccount;
* ```
*/
export declare function fetchJsonParsedAccounts<TData extends object[], TAddresses extends string[] = string[], TWrappedAddresses extends {

@@ -34,0 +133,0 @@ [P in keyof TAddresses]: Address<TAddresses[P]>;

@@ -0,1 +1,36 @@

/**
* This package contains types and helper methods for representing, fetching and decoding Solana
* accounts. It can be used standalone, but it is also exported as part of Kit
* [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).
*
* It provides a unified definition of a Solana account regardless of how it was retrieved and can
* represent both encoded and decoded accounts. It also introduces the concept of a
* {@link MaybeAccount} which represents a fetched account that may or may not exist on-chain whilst
* keeping track of its address in both cases.
*
* Helper functions are provided for fetching, parsing and decoding accounts as well as asserting
* that an account exists.
*
* @packageDocumentation
* @example
* ```ts
* // Fetch.
* const myAddress = address('1234..5678');
* const myAccount = await fetchEncodedAccount(rpc, myAddress);
* myAccount satisfies MaybeEncodedAccount<'1234..5678'>;
*
* // Assert.
* assertAccountExists(myAccount);
* myAccount satisfies EncodedAccount<'1234..5678'>;
*
* // Decode.
* type MyAccountData = { name: string; age: number };
* const myDecoder: Decoder<MyAccountData> = getStructDecoder([
* ['name', addDecoderSizePrefix(getUtf8Decoder(), getU32Decoder())],
* ['age', getU32Decoder()],
* ]);
* const myDecodedAccount = decodeAccount(myAccount, myDecoder);
* myDecodedAccount satisfies Account<MyAccountData, '1234..5678'>;
* ```
*/
export * from './account';

@@ -2,0 +37,0 @@ export * from './decode-account';

import { Address } from '@solana/addresses';
import { Account } from './account';
/** Defines a Solana account that may or may not exist after having tried to fetch it. */
/**
* Represents an account that may or may not exist on-chain.
*
* When the account exists, it is represented as an {@link Account} type with an additional `exists`
* attribute set to `true`. When it does not exist, it is represented by an object containing only
* the address of the account and an `exists` attribute set to `false`.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The nature of this account's data. It can be represented as either a
* `Uint8Array` &ndash; meaning the account is encoded &ndash; or a custom data type &ndash; meaning
* the account is decoded.
*
* @example
* ```ts
* // Account exists
* const myExistingAccount: MaybeAccount<MyAccountData, '1234..5678'> = {
* exists: true,
* address: address('1234..5678'),
* data: { name: 'Alice', age: 30 },
* // ...
* };
*
* // Account does not exist
* const myMissingAccount: MaybeAccount<MyAccountData, '8765..4321'> = {
* exists: false,
* address: address('8765..4321'),
* };
* ```
*/
export type MaybeAccount<TData extends Uint8Array | object, TAddress extends string = string> = {

@@ -10,9 +38,71 @@ readonly address: Address<TAddress>;

});
/** Defines a Solana account with encoded data that may or may not exist after having tried to fetch it. */
/**
* Represents an encoded account that may or may not exist on-chain.
*
* When the account exists, it is represented as an {@link Account} type having its `TData` type
* parameter set to `Uint8Array` with an additional `exists` attribute set to `true`. When it does
* not exist, it is represented by an object containing only the address of the account and an
* `exists` attribute set to `false`.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
*
* @example
* ```ts
* // Encoded account exists
* const myExistingAccount: MaybeEncodedAccount<'1234..5678'> = {
* exists: true,
* address: address('1234..5678'),
* data: new Uint8Array([1, 2, 3]),
* // ...
* };
*
* // Encoded account does not exist
* const myMissingAccount: MaybeEncodedAccount<'8765..4321'> = {
* exists: false,
* address: address('8765..4321'),
* };
* ```
*/
export type MaybeEncodedAccount<TAddress extends string = string> = MaybeAccount<Uint8Array, TAddress>;
/** Asserts that an account that may or may not exists, actually exists. */
/**
* Given a {@link MaybeAccount}, asserts that the account exists and allows it to be used as an
* {@link Account} type going forward.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The nature of this account's data. It can be represented as either a
* `Uint8Array` &ndash; meaning the account is encoded &ndash; or a custom data type &ndash; meaning
* the account is decoded.
*
* @example
* ```ts
* const myAccount: MaybeEncodedAccount<'1234..5678'>;
* assertAccountExists(myAccount);
*
* // Now we can use myAccount as an `EncodedAccount`
* myAccount satisfies EncodedAccount<'1234..5678'>;
* ```
*/
export declare function assertAccountExists<TData extends Uint8Array | object, TAddress extends string = string>(account: MaybeAccount<TData, TAddress>): asserts account is Account<TData, TAddress> & {
exists: true;
};
/** Asserts that all accounts that may or may not exist, actually all exist. */
/**
* Given an array of {@link MaybeAccount | MaybeAccounts}, asserts that all the accounts exist and
* allows them to be used as an array of {@link Account | Accounts} going forward.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The nature of this account's data. It can be represented as either a
* `Uint8Array` &ndash; meaning the account is encoded &ndash; or a custom data type &ndash; meaning
* the account is decoded.
*
* @example
* ```ts
* const myAccounts: MaybeEncodedAccount<Address>[];
* assertAccountsExist(myAccounts);
*
* // Now we can use them as an array of `EncodedAccounts`
* for (const a of myAccounts) {
* a satisfies EncodedAccount<Address>;
* }
* ```
*/
export declare function assertAccountsExist<TData extends Uint8Array | object, TAddress extends string = string>(accounts: MaybeAccount<TData, TAddress>[]): asserts accounts is (Account<TData, TAddress> & {

@@ -19,0 +109,0 @@ exists: true;

@@ -7,7 +7,31 @@ import type { Address } from '@solana/addresses';

type Base64EncodedRpcAccount = AccountInfoBase & AccountInfoWithBase64EncodedData;
/** Parse an account object received from a base64-encoded RPC call into an EncodedAccount or MaybeEncodedAccount type. */
/**
* Parses a base64-encoded account provided by the RPC client into an {@link EncodedAccount} type or
* a {@link MaybeEncodedAccount} type if the raw data can be set to `null`.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
*
* @example
* ```ts
* const myAddress = address('1234..5678');
* const myRpcAccount = await rpc.getAccountInfo(myAddress, { encoding: 'base64' }).send();
* const myAccount: MaybeEncodedAccount<'1234..5678'> = parseBase64RpcAccount(myRpcAccount);
* ```
*/
export declare function parseBase64RpcAccount<TAddress extends string = string>(address: Address<TAddress>, rpcAccount: Base64EncodedRpcAccount): EncodedAccount<TAddress>;
export declare function parseBase64RpcAccount<TAddress extends string = string>(address: Address<TAddress>, rpcAccount: Base64EncodedRpcAccount | null): MaybeEncodedAccount<TAddress>;
type Base58EncodedRpcAccount = AccountInfoBase & (AccountInfoWithBase58Bytes | AccountInfoWithBase58EncodedData);
/** Parse an account object received from a base58-encoded RPC call into an EncodedAccount or MaybeEncodedAccount type. */
/**
* Parses a base58-encoded account provided by the RPC client into an {@link EncodedAccount} type or
* a {@link MaybeEncodedAccount} type if the raw data can be set to `null`.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
*
* @example
* ```ts
* const myAddress = address('1234..5678');
* const myRpcAccount = await rpc.getAccountInfo(myAddress, { encoding: 'base58' }).send();
* const myAccount: MaybeEncodedAccount<'1234..5678'> = parseBase58RpcAccount(myRpcAccount);
* ```
*/
export declare function parseBase58RpcAccount<TAddress extends string = string>(address: Address<TAddress>, rpcAccount: Base58EncodedRpcAccount): EncodedAccount<TAddress>;

@@ -18,3 +42,16 @@ export declare function parseBase58RpcAccount<TAddress extends string = string>(address: Address<TAddress>, rpcAccount: Base58EncodedRpcAccount | null): MaybeEncodedAccount<TAddress>;

};
/** Parse an account object received from a json-parsed RPC call into an Account or MaybeAccount type. */
/**
* Parses an arbitrary `jsonParsed` account provided by the RPC client into an {@link Account} type
* or a {@link MaybeAccount} type if the raw data can be set to `null`.
*
* The expected data type should be explicitly provided as the first type parameter.
*
* @typeParam TAddress - Supply a string literal to define an account having a particular address.
* @typeParam TData - The expected type of this account's data.
*
* @example
* ```ts
* const myAccount: Account<MyData> = parseJsonRpcAccount<MyData>(myJsonRpcAccount);
* ```
*/
export declare function parseJsonRpcAccount<TData extends object, TAddress extends string = string>(address: Address<TAddress>, rpcAccount: JsonParsedRpcAccount): Account<TData, TAddress>;

@@ -21,0 +58,0 @@ export declare function parseJsonRpcAccount<TData extends object, TAddress extends string = string>(address: Address<TAddress>, rpcAccount: JsonParsedRpcAccount | null): MaybeAccount<TData, TAddress>;

18

package.json
{
"name": "@solana/accounts",
"version": "2.1.0-canary-20241211084732",
"version": "2.1.0-canary-20250227211824",
"description": "Helpers for representing, fetching and decoding Solana accounts",

@@ -47,6 +47,6 @@ "exports": {

"type": "git",
"url": "https://github.com/solana-labs/solana-web3.js"
"url": "https://github.com/anza-xyz/kit"
},
"bugs": {
"url": "http://github.com/solana-labs/solana-web3.js/issues"
"url": "https://github.com/anza-xyz/kit/issues"
},

@@ -58,8 +58,8 @@ "browserslist": [

"dependencies": {
"@solana/addresses": "2.1.0-canary-20241211084732",
"@solana/codecs-core": "2.1.0-canary-20241211084732",
"@solana/errors": "2.1.0-canary-20241211084732",
"@solana/codecs-strings": "2.1.0-canary-20241211084732",
"@solana/rpc-spec": "2.1.0-canary-20241211084732",
"@solana/rpc-types": "2.1.0-canary-20241211084732"
"@solana/codecs-core": "2.1.0-canary-20250227211824",
"@solana/codecs-strings": "2.1.0-canary-20250227211824",
"@solana/addresses": "2.1.0-canary-20250227211824",
"@solana/errors": "2.1.0-canary-20250227211824",
"@solana/rpc-spec": "2.1.0-canary-20250227211824",
"@solana/rpc-types": "2.1.0-canary-20250227211824"
},

@@ -66,0 +66,0 @@ "peerDependencies": {

@@ -8,9 +8,9 @@ [![npm][npm-image]][npm-url]

[code-style-prettier-url]: https://github.com/prettier/prettier
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/accounts/next.svg?style=flat
[npm-image]: https://img.shields.io/npm/v/@solana/accounts/next.svg?style=flat
[npm-url]: https://www.npmjs.com/package/@solana/accounts/v/next
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/accounts?style=flat
[npm-image]: https://img.shields.io/npm/v/@solana/accounts?style=flat
[npm-url]: https://www.npmjs.com/package/@solana/accounts
# @solana/accounts
This package contains types and helper methods for representing, fetching and decoding Solana accounts. It can be used standalone, but it is also exported as part of the Solana JavaScript SDK [`@solana/web3.js@next`](https://github.com/solana-labs/solana-web3.js/tree/master/packages/library).
This package contains types and helper methods for representing, fetching and decoding Solana accounts. It can be used standalone, but it is also exported as part of Kit [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).

@@ -24,3 +24,3 @@ It provides a unified definition of a Solana account regardless of how it was retrieved and can represent both encoded and decoded accounts. It also introduces the concept of a `MaybeAccount` which represents a fetched account that may or may not exist on-chain whilst keeping track of its address in both cases.

const myAddress = address('1234..5678');
const myAccount = fetchAccount(rpc, myAddress);
const myAccount = await fetchEncodedAccount(rpc, myAddress);
myAccount satisfies MaybeEncodedAccount<'1234..5678'>;

@@ -53,2 +53,3 @@

programAddress: address('1111..1111'),
space: 42n,
};

@@ -77,2 +78,3 @@ ```

programAddress: address('1111..1111'),
space: 42n,
};

@@ -88,2 +90,3 @@

programAddress: address('1111..1111'),
space: 42n,
};

@@ -108,5 +111,3 @@ ```

data: { name: 'Alice', age: 30 },
executable: false,
lamports: lamports(1_000_000_000n),
programAddress: address('1111..1111'),
// ...
};

@@ -113,0 +114,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet