@solana/accounts
Advanced tools
Comparing version 2.0.0-experimental.b93299a to 2.0.0-experimental.bea19d2
@@ -0,1 +1,2 @@ | ||
import { SolanaError, SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, SOLANA_ERROR__ACCOUNT_NOT_FOUND, SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND } from '@solana/errors'; | ||
import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
@@ -5,4 +6,2 @@ | ||
var BASE_ACCOUNT_SIZE = 128; | ||
// src/decode-account.ts | ||
function decodeAccount(encodedAccount, decoder) { | ||
@@ -14,6 +13,6 @@ try { | ||
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) }); | ||
} catch (error) { | ||
const newError = new Error(`Failed to decode account [${encodedAccount.address}].`); | ||
newError.cause = error; | ||
throw newError; | ||
} catch (e) { | ||
throw new SolanaError(SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, { | ||
address: encodedAccount.address | ||
}); | ||
} | ||
@@ -26,3 +25,5 @@ } | ||
if (accountExists(account) && account.data instanceof Uint8Array) { | ||
throw new Error(`Expected account [${account.address}] to be decoded.`); | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, { | ||
address: account.address | ||
}); | ||
} | ||
@@ -33,4 +34,6 @@ } | ||
if (encoded.length > 0) { | ||
const encodedAddresses = encoded.map((a) => a.address).join(", "); | ||
throw new Error(`Expected accounts [${encodedAddresses}] to be decoded.`); | ||
const encodedAddresses = encoded.map((a) => a.address); | ||
throw new SolanaError(SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, { | ||
addresses: encodedAddresses | ||
}); | ||
} | ||
@@ -87,7 +90,5 @@ } | ||
} | ||
// src/maybe-account.ts | ||
function assertAccountExists(account) { | ||
if (!account.exists) { | ||
throw new Error(`Expected account [${account.address}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__ACCOUNT_NOT_FOUND, { address: account.address }); | ||
} | ||
@@ -99,3 +100,3 @@ } | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND, { addresses: missingAddresses }); | ||
} | ||
@@ -102,0 +103,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { SolanaError, SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, SOLANA_ERROR__ACCOUNT_NOT_FOUND, SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND } from '@solana/errors'; | ||
import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
@@ -5,4 +6,2 @@ | ||
var BASE_ACCOUNT_SIZE = 128; | ||
// src/decode-account.ts | ||
function decodeAccount(encodedAccount, decoder) { | ||
@@ -14,6 +13,6 @@ try { | ||
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) }); | ||
} catch (error) { | ||
const newError = new Error(`Failed to decode account [${encodedAccount.address}].`); | ||
newError.cause = error; | ||
throw newError; | ||
} catch (e) { | ||
throw new SolanaError(SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, { | ||
address: encodedAccount.address | ||
}); | ||
} | ||
@@ -26,3 +25,5 @@ } | ||
if (accountExists(account) && account.data instanceof Uint8Array) { | ||
throw new Error(`Expected account [${account.address}] to be decoded.`); | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, { | ||
address: account.address | ||
}); | ||
} | ||
@@ -33,4 +34,6 @@ } | ||
if (encoded.length > 0) { | ||
const encodedAddresses = encoded.map((a) => a.address).join(", "); | ||
throw new Error(`Expected accounts [${encodedAddresses}] to be decoded.`); | ||
const encodedAddresses = encoded.map((a) => a.address); | ||
throw new SolanaError(SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, { | ||
addresses: encodedAddresses | ||
}); | ||
} | ||
@@ -87,7 +90,5 @@ } | ||
} | ||
// src/maybe-account.ts | ||
function assertAccountExists(account) { | ||
if (!account.exists) { | ||
throw new Error(`Expected account [${account.address}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__ACCOUNT_NOT_FOUND, { address: account.address }); | ||
} | ||
@@ -99,3 +100,3 @@ } | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND, { addresses: missingAddresses }); | ||
} | ||
@@ -102,0 +103,0 @@ } |
@@ -0,1 +1,2 @@ | ||
import { SolanaError, SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, SOLANA_ERROR__ACCOUNT_NOT_FOUND, SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND } from '@solana/errors'; | ||
import { getBase64Encoder, getBase58Encoder } from '@solana/codecs-strings'; | ||
@@ -5,4 +6,2 @@ | ||
var BASE_ACCOUNT_SIZE = 128; | ||
// src/decode-account.ts | ||
function decodeAccount(encodedAccount, decoder) { | ||
@@ -14,6 +13,6 @@ try { | ||
return Object.freeze({ ...encodedAccount, data: decoder.decode(encodedAccount.data) }); | ||
} catch (error) { | ||
const newError = new Error(`Failed to decode account [${encodedAccount.address}].`); | ||
newError.cause = error; | ||
throw newError; | ||
} catch (e) { | ||
throw new SolanaError(SOLANA_ERROR__FAILED_TO_DECODE_ACCOUNT, { | ||
address: encodedAccount.address | ||
}); | ||
} | ||
@@ -26,3 +25,5 @@ } | ||
if (accountExists(account) && account.data instanceof Uint8Array) { | ||
throw new Error(`Expected account [${account.address}] to be decoded.`); | ||
throw new SolanaError(SOLANA_ERROR__EXPECTED_DECODED_ACCOUNT, { | ||
address: account.address | ||
}); | ||
} | ||
@@ -33,4 +34,6 @@ } | ||
if (encoded.length > 0) { | ||
const encodedAddresses = encoded.map((a) => a.address).join(", "); | ||
throw new Error(`Expected accounts [${encodedAddresses}] to be decoded.`); | ||
const encodedAddresses = encoded.map((a) => a.address); | ||
throw new SolanaError(SOLANA_ERROR__NOT_ALL_ACCOUNTS_DECODED, { | ||
addresses: encodedAddresses | ||
}); | ||
} | ||
@@ -87,7 +90,5 @@ } | ||
} | ||
// src/maybe-account.ts | ||
function assertAccountExists(account) { | ||
if (!account.exists) { | ||
throw new Error(`Expected account [${account.address}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__ACCOUNT_NOT_FOUND, { address: account.address }); | ||
} | ||
@@ -99,3 +100,3 @@ } | ||
const missingAddresses = missingAccounts.map((a) => a.address); | ||
throw new Error(`Expected accounts [${missingAddresses.join(", ")}] to exist.`); | ||
throw new SolanaError(SOLANA_ERROR__MULTIPLE_ACCOUNTS_NOT_FOUND, { addresses: missingAddresses }); | ||
} | ||
@@ -102,0 +103,0 @@ } |
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, Rpc, Slot } from '@solana/rpc-types'; | ||
import type { Rpc } from '@solana/rpc-spec'; | ||
import type { Commitment, Slot } from '@solana/rpc-types'; | ||
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js'; | ||
@@ -4,0 +5,0 @@ import type { GetAccountInfoApi, GetMultipleAccountsApi } from './rpc-api/index.js'; |
import type { Address } from '@solana/addresses'; | ||
import type { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData } from '@solana/rpc-types'; | ||
import type { Account, EncodedAccount } from './account.js'; | ||
import { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js'; | ||
import type { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, JsonParsedDataResponse } from './rpc-api/index.js'; | ||
import type { MaybeAccount, MaybeEncodedAccount } from './maybe-account.js'; | ||
import type { JsonParsedDataResponse } from './rpc-api/index.js'; | ||
type Base64EncodedRpcAccount = AccountInfoBase & AccountInfoWithBase64EncodedData; | ||
@@ -6,0 +7,0 @@ /** Parse an account object received from a base64-encoded RPC call into an EncodedAccount or MaybeEncodedAccount type. */ |
@@ -1,34 +0,2 @@ | ||
import { Address } from '@solana/addresses'; | ||
import type { Base58EncodedBytes, Base58EncodedDataResponse, Base64EncodedDataResponse, Base64EncodedZStdCompressedDataResponse, LamportsUnsafeBeyond2Pow53Minus1, U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
export type DataSlice = Readonly<{ | ||
offset: number; | ||
length: number; | ||
}>; | ||
export type AccountInfoBase = Readonly<{ | ||
/** indicates if the account contains a program (and is strictly read-only) */ | ||
executable: boolean; | ||
/** number of lamports assigned to this account */ | ||
lamports: LamportsUnsafeBeyond2Pow53Minus1; | ||
/** pubkey of the program this account has been assigned to */ | ||
owner: Address; | ||
/** the epoch at which this account will next owe rent */ | ||
rentEpoch: U64UnsafeBeyond2Pow53Minus1; | ||
}>; | ||
/** @deprecated */ | ||
export type AccountInfoWithBase58Bytes = Readonly<{ | ||
data: Base58EncodedBytes; | ||
}>; | ||
/** @deprecated */ | ||
export type AccountInfoWithBase58EncodedData = Readonly<{ | ||
data: Base58EncodedDataResponse; | ||
}>; | ||
export type AccountInfoWithBase64EncodedData = Readonly<{ | ||
data: Base64EncodedDataResponse; | ||
}>; | ||
export type AccountInfoWithBase64EncodedZStdCompressedData = Readonly<{ | ||
data: Base64EncodedZStdCompressedDataResponse; | ||
}>; | ||
export type AccountInfoWithJsonData = Readonly<{ | ||
data: JsonParsedDataResponse | Base64EncodedDataResponse; | ||
}>; | ||
import type { U64UnsafeBeyond2Pow53Minus1 } from '@solana/rpc-types'; | ||
export type JsonParsedDataResponse<TData = object> = Readonly<{ | ||
@@ -35,0 +3,0 @@ program: string; |
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, DataSlice } from './common.js'; | ||
type GetAccountInfoApiResponseBase = RpcResponse<AccountInfoBase | null>; | ||
import type { RpcApiMethods } from '@solana/rpc-spec'; | ||
import type { AccountInfoBase, AccountInfoWithBase58Bytes, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, Commitment, DataSlice, Slot, SolanaRpcResponse } from '@solana/rpc-types'; | ||
type GetAccountInfoApiResponseBase = SolanaRpcResponse<AccountInfoBase | null>; | ||
type NestInRpcResponseOrNull<T> = Readonly<{ | ||
@@ -15,3 +15,3 @@ value: T | null; | ||
}>; | ||
export interface GetAccountInfoApi extends IRpcApiMethods { | ||
export interface GetAccountInfoApi extends RpcApiMethods { | ||
/** | ||
@@ -18,0 +18,0 @@ * Returns all information associated with the account of provided public key |
import type { Address } from '@solana/addresses'; | ||
import type { Commitment, IRpcApiMethods, RpcResponse, Slot } from '@solana/rpc-types'; | ||
import { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, DataSlice } from './common.js'; | ||
import type { RpcApiMethods } from '@solana/rpc-spec'; | ||
import type { AccountInfoBase, AccountInfoWithBase58EncodedData, AccountInfoWithBase64EncodedData, AccountInfoWithBase64EncodedZStdCompressedData, AccountInfoWithJsonData, Commitment, DataSlice, Slot, SolanaRpcResponse } from '@solana/rpc-types'; | ||
type GetMultipleAccountsApiResponseBase = AccountInfoBase | null; | ||
@@ -15,3 +15,3 @@ type GetMultipleAccountsApiCommonConfig = Readonly<{ | ||
}>; | ||
export interface GetMultipleAccountsApi extends IRpcApiMethods { | ||
export interface GetMultipleAccountsApi extends RpcApiMethods { | ||
/** | ||
@@ -24,3 +24,3 @@ * Returns the account information for a list of Pubkeys. | ||
encoding: 'base64'; | ||
}>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
}>): SolanaRpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
getMultipleAccounts( | ||
@@ -30,3 +30,3 @@ /** An array of up to 100 Pubkeys to query */ | ||
encoding: 'base64+zstd'; | ||
}>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedZStdCompressedData | null))[]>; | ||
}>): SolanaRpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedZStdCompressedData | null))[]>; | ||
getMultipleAccounts( | ||
@@ -36,3 +36,3 @@ /** An array of up to 100 Pubkeys to query */ | ||
encoding: 'jsonParsed'; | ||
}>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithJsonData | null))[]>; | ||
}>): SolanaRpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithJsonData | null))[]>; | ||
getMultipleAccounts( | ||
@@ -42,8 +42,8 @@ /** An array of up to 100 Pubkeys to query */ | ||
encoding: 'base58'; | ||
}>): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase58EncodedData | null))[]>; | ||
}>): SolanaRpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase58EncodedData | null))[]>; | ||
getMultipleAccounts( | ||
/** An array of up to 100 Pubkeys to query */ | ||
addresses: Address[], config?: GetMultipleAccountsApiCommonConfig): RpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
addresses: Address[], config?: GetMultipleAccountsApiCommonConfig): SolanaRpcResponse<(GetMultipleAccountsApiResponseBase & (AccountInfoWithBase64EncodedData | null))[]>; | ||
} | ||
export {}; | ||
//# sourceMappingURL=getMultipleAccounts.d.ts.map |
{ | ||
"name": "@solana/accounts", | ||
"version": "2.0.0-experimental.b93299a", | ||
"version": "2.0.0-experimental.bea19d2", | ||
"description": "Helpers for representing, fetching and decoding Solana accounts", | ||
@@ -49,28 +49,9 @@ "exports": { | ||
"dependencies": { | ||
"@solana/addresses": "2.0.0-experimental.b93299a", | ||
"@solana/codecs-core": "2.0.0-experimental.b93299a", | ||
"@solana/codecs-strings": "2.0.0-experimental.b93299a", | ||
"@solana/rpc-types": "2.0.0-development" | ||
"@solana/addresses": "2.0.0-experimental.bea19d2", | ||
"@solana/codecs-core": "2.0.0-experimental.bea19d2", | ||
"@solana/codecs-strings": "2.0.0-experimental.bea19d2", | ||
"@solana/errors": "2.0.0-experimental.bea19d2", | ||
"@solana/rpc-spec": "2.0.0-experimental.bea19d2", | ||
"@solana/rpc-types": "2.0.0-experimental.bea19d2" | ||
}, | ||
"devDependencies": { | ||
"@solana/eslint-config-solana": "^1.0.2", | ||
"@swc/jest": "^0.2.29", | ||
"@types/jest": "^29.5.11", | ||
"@typescript-eslint/eslint-plugin": "^6.13.2", | ||
"@typescript-eslint/parser": "^6.3.0", | ||
"agadoo": "^3.0.0", | ||
"eslint": "^8.45.0", | ||
"eslint-plugin-sort-keys-fix": "^1.1.2", | ||
"jest": "^29.7.0", | ||
"jest-runner-eslint": "^2.1.2", | ||
"jest-runner-prettier": "^1.0.0", | ||
"prettier": "^3.1", | ||
"tsup": "^8.0.1", | ||
"typescript": "^5.2.2", | ||
"version-from-git": "^1.1.1", | ||
"build-scripts": "0.0.0", | ||
"test-config": "0.0.0", | ||
"test-matchers": "0.0.0", | ||
"tsconfig": "0.0.0" | ||
}, | ||
"bundlewatch": { | ||
@@ -86,8 +67,9 @@ "defaultCompression": "gzip", | ||
"compile:js": "tsup --config build-scripts/tsup.config.package.ts", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"publish-packages": "pnpm publish --tag experimental --access public --no-git-checks", | ||
"compile:typedefs": "tsc -p ./tsconfig.declarations.json && node node_modules/@solana/build-scripts/add-js-extension-to-types.mjs", | ||
"dev": "jest -c node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch", | ||
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || pnpm publish --tag experimental --access public --no-git-checks", | ||
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl", | ||
"style:fix": "pnpm eslint --fix src/* && pnpm prettier -w src/* package.json", | ||
"test:lint": "jest -c node_modules/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:lint": "jest -c node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent", | ||
"test:prettier": "jest -c node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent", | ||
"test:treeshakability:browser": "agadoo dist/index.browser.js", | ||
@@ -97,5 +79,5 @@ "test:treeshakability:native": "agadoo dist/index.native.js", | ||
"test:typecheck": "tsc --noEmit", | ||
"test:unit:browser": "jest -c node_modules/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
"test:unit:browser": "jest -c node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent", | ||
"test:unit:node": "jest -c node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent" | ||
} | ||
} |
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
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
162977
0
6
845
+ Added@solana/addresses@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/assertions@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/errors@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/rpc-spec@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/rpc-spec-types@2.0.0-experimental.bea19d2(transitive)
+ Added@solana/rpc-types@2.0.0-experimental.bea19d2(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addedcommander@12.1.0(transitive)
- Removed@solana/addresses@2.0.0-experimental.b93299a(transitive)
- Removed@solana/assertions@2.0.0-experimental.b93299a(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.b93299a(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.b93299a(transitive)
- Removed@solana/codecs-strings@2.0.0-experimental.b93299a(transitive)
- Removed@solana/rpc-types@2.0.0-development(transitive)