@solana/accounts
Advanced tools
Comparing version 2.0.0-experimental.ed98b3d to 2.0.0-experimental.ef2569b
@@ -75,5 +75,12 @@ import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
} | ||
function assertAccountsExist(accounts) { | ||
const missingAccounts = accounts.filter((a) => !a.exists); | ||
if (missingAccounts.length > 0) { | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
} | ||
} | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, assertAccountsExist, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.browser.js.map |
@@ -75,5 +75,12 @@ import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
} | ||
function assertAccountsExist(accounts) { | ||
const missingAccounts = accounts.filter((a) => !a.exists); | ||
if (missingAccounts.length > 0) { | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
} | ||
} | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, assertAccountsExist, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.native.js.map |
@@ -75,5 +75,12 @@ import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
} | ||
function assertAccountsExist(accounts) { | ||
const missingAccounts = accounts.filter((a) => !a.exists); | ||
if (missingAccounts.length > 0) { | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
} | ||
} | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
export { BASE_ACCOUNT_SIZE, assertAccountExists, assertAccountsExist, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, fetchJsonParsedAccount, fetchJsonParsedAccounts, parseBase58RpcAccount, parseBase64RpcAccount, parseJsonRpcAccount }; | ||
//# sourceMappingURL=out.js.map | ||
//# sourceMappingURL=index.node.js.map |
@@ -16,2 +16,6 @@ import { Address } from '@solana/addresses'; | ||
}; | ||
/** Asserts that all accounts that may or may not exist, actually all exist. */ | ||
export declare function assertAccountsExist<TData extends object | Uint8Array, TAddress extends string = string>(accounts: MaybeAccount<TData, TAddress>[]): asserts accounts is (Account<TData, TAddress> & { | ||
exists: true; | ||
})[]; | ||
//# sourceMappingURL=maybe-account.d.ts.map |
{ | ||
"name": "@solana/accounts", | ||
"version": "2.0.0-experimental.ed98b3d", | ||
"version": "2.0.0-experimental.ef2569b", | ||
"description": "Helpers for representing, fetching and decoding Solana accounts", | ||
@@ -49,8 +49,8 @@ "exports": { | ||
"dependencies": { | ||
"@solana/codecs-core": "2.0.0-experimental.ed98b3d", | ||
"@solana/addresses": "2.0.0-experimental.ed98b3d", | ||
"@solana/codecs-strings": "2.0.0-experimental.ed98b3d", | ||
"@solana/rpc-core": "2.0.0-experimental.ed98b3d", | ||
"@solana/rpc-transport": "2.0.0-experimental.ed98b3d", | ||
"@solana/rpc-types": "2.0.0-experimental.ed98b3d" | ||
"@solana/codecs-core": "2.0.0-experimental.ef2569b", | ||
"@solana/addresses": "2.0.0-experimental.ef2569b", | ||
"@solana/codecs-strings": "2.0.0-experimental.ef2569b", | ||
"@solana/rpc-core": "2.0.0-experimental.ef2569b", | ||
"@solana/rpc-transport": "2.0.0-experimental.ef2569b", | ||
"@solana/rpc-types": "2.0.0-experimental.ef2569b" | ||
}, | ||
@@ -57,0 +57,0 @@ "devDependencies": { |
@@ -150,2 +150,17 @@ [![npm][npm-image]][npm-url] | ||
### `assertAccountsExist()` | ||
Given an array of `MaybeAccount`s, this function asserts that all the accounts | ||
exist and allows them to be used as an array of `Account`s going forward. | ||
```ts | ||
const myAccounts: MaybeEncodedAccount<Address>[]; | ||
assertAccountsExist(myAccounts); | ||
// Now we can use them as an array of accounts | ||
for (const a of myAccounts) { | ||
a satisfies EncodedAccount<Address>; | ||
} | ||
``` | ||
### `parseBase64RpcAccount()` | ||
@@ -152,0 +167,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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
132630
639
270
+ Added@solana/addresses@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/assertions@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/rpc-core@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/rpc-transport@2.0.0-experimental.ef2569b(transitive)
+ Added@solana/rpc-types@2.0.0-experimental.ef2569b(transitive)
- Removed@solana/addresses@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/assertions@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/codecs-strings@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/rpc-core@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/rpc-transport@2.0.0-experimental.ed98b3d(transitive)
- Removed@solana/rpc-types@2.0.0-experimental.ed98b3d(transitive)