@solana/accounts
Advanced tools
Comparing version 2.0.0-experimental.dfb72ea to 2.0.0-experimental.e00f668
@@ -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 @@ } |
{ | ||
"name": "@solana/accounts", | ||
"version": "2.0.0-experimental.dfb72ea", | ||
"version": "2.0.0-experimental.e00f668", | ||
"description": "Helpers for representing, fetching and decoding Solana accounts", | ||
@@ -49,7 +49,8 @@ "exports": { | ||
"dependencies": { | ||
"@solana/addresses": "2.0.0-experimental.dfb72ea", | ||
"@solana/codecs-core": "2.0.0-experimental.dfb72ea", | ||
"@solana/codecs-strings": "2.0.0-experimental.dfb72ea", | ||
"@solana/rpc-spec": "2.0.0-experimental.dfb72ea", | ||
"@solana/rpc-types": "2.0.0-experimental.dfb72ea" | ||
"@solana/addresses": "2.0.0-experimental.e00f668", | ||
"@solana/codecs-core": "2.0.0-experimental.e00f668", | ||
"@solana/codecs-strings": "2.0.0-experimental.e00f668", | ||
"@solana/errors": "2.0.0-experimental.e00f668", | ||
"@solana/rpc-spec": "2.0.0-experimental.e00f668", | ||
"@solana/rpc-types": "2.0.0-experimental.e00f668" | ||
}, | ||
@@ -56,0 +57,0 @@ "bundlewatch": { |
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
845
6
+ Added@solana/addresses@2.0.0-experimental.e00f668(transitive)
+ Added@solana/assertions@2.0.0-experimental.e00f668(transitive)
+ Added@solana/codecs-core@2.0.0-experimental.e00f668(transitive)
+ Added@solana/codecs-numbers@2.0.0-experimental.e00f668(transitive)
+ Added@solana/codecs-strings@2.0.0-experimental.e00f668(transitive)
+ Added@solana/errors@2.0.0-experimental.e00f668(transitive)
+ Added@solana/rpc-spec@2.0.0-experimental.e00f668(transitive)
+ Added@solana/rpc-spec-types@2.0.0-experimental.e00f668(transitive)
+ Added@solana/rpc-types@2.0.0-experimental.e00f668(transitive)
+ Addedchalk@5.3.0(transitive)
+ Addedcommander@12.1.0(transitive)
- Removed@solana/addresses@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/assertions@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/codecs-core@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/codecs-numbers@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/codecs-strings@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/rpc-spec@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/rpc-spec-types@2.0.0-experimental.dfb72ea(transitive)
- Removed@solana/rpc-types@2.0.0-experimental.dfb72ea(transitive)