@solana/plugin-interfaces 7.0.0 → 7.1.0-canary-20260812151931
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -0
- package/dist/types/fetch-accounts.d.ts +40 -0
- package/dist/types/fetch-accounts.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/package.json +9 -8
- package/src/fetch-accounts.ts +40 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -138,6 +138,25 @@ function accountCreationPlugin() {
|
|
|
138
138
|
}
|
|
139
139
|
```
|
|
140
140
|
|
|
141
|
+
### `ClientWithFetchAccounts`
|
|
142
|
+
|
|
143
|
+
Represents a client that can fetch the encoded content of accounts from their addresses. Different implementations may fetch accounts differently — for example, by calling the `getAccountInfo` and/or `getMultipleAccounts` RPC methods, or by using a locally cached value. The returned array matches the provided addresses in both length and order, using `MaybeEncodedAccount` to represent accounts that may not exist.
|
|
144
|
+
|
|
145
|
+
```ts
|
|
146
|
+
import { extendClient } from '@solana/plugin-core';
|
|
147
|
+
import { ClientWithFetchAccounts } from '@solana/plugin-interfaces';
|
|
148
|
+
|
|
149
|
+
function accountLoaderPlugin() {
|
|
150
|
+
return <T extends ClientWithFetchAccounts>(client: T) =>
|
|
151
|
+
extendClient(client, {
|
|
152
|
+
loadExistingAccounts: async (addresses: Address[]) => {
|
|
153
|
+
const accounts = await client.fetchAccounts(addresses);
|
|
154
|
+
return accounts.filter(account => account.exists);
|
|
155
|
+
},
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
141
160
|
### `ClientWithRpc<TRpcMethods>`
|
|
142
161
|
|
|
143
162
|
Represents a client with access to a Solana RPC endpoint.
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FetchAccountsConfig, MaybeEncodedAccount } from '@solana/accounts';
|
|
2
|
+
import { Address } from '@solana/addresses';
|
|
3
|
+
/**
|
|
4
|
+
* Represents a client that can fetch the content of accounts from their addresses.
|
|
5
|
+
*
|
|
6
|
+
* Different implementations may fetch accounts differently — for example, by calling the
|
|
7
|
+
* `getAccountInfo` and/or `getMultipleAccounts` RPC methods, by reading from a local validator,
|
|
8
|
+
* or by using a locally cached value.
|
|
9
|
+
*
|
|
10
|
+
* Note that this interface only fetches encoded accounts. Callers that need decoded accounts should
|
|
11
|
+
* decode the returned {@link MaybeEncodedAccount | MaybeEncodedAccounts} themselves using the codec
|
|
12
|
+
* of their choice.
|
|
13
|
+
*
|
|
14
|
+
* If you have a raw `Rpc` object instead of a client, you can construct a client implementing this
|
|
15
|
+
* interface using the {@link createClientWithFetchAccountsFromRpc} helper from `@solana/kit`.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* async function fetchProgramAddresses(client: ClientWithFetchAccounts, addresses: Address[]) {
|
|
20
|
+
* const accounts = await client.fetchAccounts(addresses);
|
|
21
|
+
* return accounts.filter(account => account.exists).map(account => account.programAddress);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export type ClientWithFetchAccounts = {
|
|
26
|
+
/**
|
|
27
|
+
* Fetches the encoded content of the accounts at the provided addresses.
|
|
28
|
+
*
|
|
29
|
+
* The returned array matches the provided addresses in both length and order. Each item is a
|
|
30
|
+
* {@link MaybeEncodedAccount} so that missing accounts can be represented whilst keeping track
|
|
31
|
+
* of their address.
|
|
32
|
+
*
|
|
33
|
+
* @param addresses - The addresses of the accounts to fetch.
|
|
34
|
+
* @param config - Optional configuration for the fetch.
|
|
35
|
+
* @returns A promise resolving to an array of {@link MaybeEncodedAccount | MaybeEncodedAccounts}
|
|
36
|
+
* in the same order as the provided addresses.
|
|
37
|
+
*/
|
|
38
|
+
fetchAccounts: (addresses: Address[], config?: FetchAccountsConfig) => Promise<MaybeEncodedAccount[]>;
|
|
39
|
+
};
|
|
40
|
+
//# sourceMappingURL=fetch-accounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetch-accounts.d.ts","sourceRoot":"","sources":["../../src/fetch-accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAClC;;;;;;;;;;;OAWG;IACH,aAAa,EAAE,CAAC,SAAS,EAAE,OAAO,EAAE,EAAE,MAAM,CAAC,EAAE,mBAAmB,KAAK,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAAC;CACzG,CAAC"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,cAAc,WAAW,CAAC;AAC1B,cAAc,kBAAkB,CAAC;AACjC,cAAc,qBAAqB,CAAC;AACpC,cAAc,uBAAuB,CAAC;AACtC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,OAAO,CAAC;AACtB,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@solana/plugin-interfaces",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.1.0-canary-20260812151931",
|
|
4
4
|
"description": "TypeScript interfaces for building pluggable Solana clients",
|
|
5
5
|
"homepage": "https://www.solanakit.com/api#solanaplugin-interfaces",
|
|
6
6
|
"types": "./dist/types/index.d.ts",
|
|
@@ -29,13 +29,14 @@
|
|
|
29
29
|
"maintained node versions"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@solana/
|
|
33
|
-
"@solana/
|
|
34
|
-
"@solana/instruction-plans": "7.
|
|
35
|
-
"@solana/
|
|
36
|
-
"@solana/rpc-
|
|
37
|
-
"@solana/
|
|
38
|
-
"@solana/rpc-types": "7.
|
|
32
|
+
"@solana/accounts": "7.1.0-canary-20260812151931",
|
|
33
|
+
"@solana/addresses": "7.1.0-canary-20260812151931",
|
|
34
|
+
"@solana/instruction-plans": "7.1.0-canary-20260812151931",
|
|
35
|
+
"@solana/keys": "7.1.0-canary-20260812151931",
|
|
36
|
+
"@solana/rpc-spec": "7.1.0-canary-20260812151931",
|
|
37
|
+
"@solana/rpc-subscriptions-spec": "7.1.0-canary-20260812151931",
|
|
38
|
+
"@solana/rpc-types": "7.1.0-canary-20260812151931",
|
|
39
|
+
"@solana/signers": "7.1.0-canary-20260812151931"
|
|
39
40
|
},
|
|
40
41
|
"peerDependencies": {
|
|
41
42
|
"typescript": ">=5.4.0"
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { FetchAccountsConfig, MaybeEncodedAccount } from '@solana/accounts';
|
|
2
|
+
import { Address } from '@solana/addresses';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a client that can fetch the content of accounts from their addresses.
|
|
6
|
+
*
|
|
7
|
+
* Different implementations may fetch accounts differently — for example, by calling the
|
|
8
|
+
* `getAccountInfo` and/or `getMultipleAccounts` RPC methods, by reading from a local validator,
|
|
9
|
+
* or by using a locally cached value.
|
|
10
|
+
*
|
|
11
|
+
* Note that this interface only fetches encoded accounts. Callers that need decoded accounts should
|
|
12
|
+
* decode the returned {@link MaybeEncodedAccount | MaybeEncodedAccounts} themselves using the codec
|
|
13
|
+
* of their choice.
|
|
14
|
+
*
|
|
15
|
+
* If you have a raw `Rpc` object instead of a client, you can construct a client implementing this
|
|
16
|
+
* interface using the {@link createClientWithFetchAccountsFromRpc} helper from `@solana/kit`.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* async function fetchProgramAddresses(client: ClientWithFetchAccounts, addresses: Address[]) {
|
|
21
|
+
* const accounts = await client.fetchAccounts(addresses);
|
|
22
|
+
* return accounts.filter(account => account.exists).map(account => account.programAddress);
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export type ClientWithFetchAccounts = {
|
|
27
|
+
/**
|
|
28
|
+
* Fetches the encoded content of the accounts at the provided addresses.
|
|
29
|
+
*
|
|
30
|
+
* The returned array matches the provided addresses in both length and order. Each item is a
|
|
31
|
+
* {@link MaybeEncodedAccount} so that missing accounts can be represented whilst keeping track
|
|
32
|
+
* of their address.
|
|
33
|
+
*
|
|
34
|
+
* @param addresses - The addresses of the accounts to fetch.
|
|
35
|
+
* @param config - Optional configuration for the fetch.
|
|
36
|
+
* @returns A promise resolving to an array of {@link MaybeEncodedAccount | MaybeEncodedAccounts}
|
|
37
|
+
* in the same order as the provided addresses.
|
|
38
|
+
*/
|
|
39
|
+
fetchAccounts: (addresses: Address[], config?: FetchAccountsConfig) => Promise<MaybeEncodedAccount[]>;
|
|
40
|
+
};
|