@lightprotocol/stateless.js 0.14.4 → 0.15.1

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.
@@ -11761,128 +11761,23 @@ const IDL = {
11761
11761
  errors: [
11762
11762
  {
11763
11763
  code: 6000,
11764
- name: 'PublicKeyAmountMissmatch',
11765
- msg: 'public keys and amounts must be of same length',
11764
+ name: 'SignerCheckFailed',
11765
+ msg: 'Signer check failed',
11766
11766
  },
11767
11767
  {
11768
11768
  code: 6001,
11769
- name: 'ComputeInputSumFailed',
11770
- msg: 'ComputeInputSumFailed',
11769
+ name: 'CreateTransferInstructionFailed',
11770
+ msg: 'Create transfer instruction failed',
11771
11771
  },
11772
11772
  {
11773
11773
  code: 6002,
11774
- name: 'ComputeOutputSumFailed',
11775
- msg: 'ComputeOutputSumFailed',
11774
+ name: 'AccountNotFound',
11775
+ msg: 'Account not found',
11776
11776
  },
11777
11777
  {
11778
11778
  code: 6003,
11779
- name: 'ComputeCompressSumFailed',
11780
- msg: 'ComputeCompressSumFailed',
11781
- },
11782
- {
11783
- code: 6004,
11784
- name: 'ComputeDecompressSumFailed',
11785
- msg: 'ComputeDecompressSumFailed',
11786
- },
11787
- {
11788
- code: 6005,
11789
- name: 'SumCheckFailed',
11790
- msg: 'SumCheckFailed',
11791
- },
11792
- {
11793
- code: 6006,
11794
- name: 'DecompressRecipientUndefinedForDecompress',
11795
- msg: 'DecompressRecipientUndefinedForDecompress',
11796
- },
11797
- {
11798
- code: 6007,
11799
- name: 'CompressedPdaUndefinedForDecompress',
11800
- msg: 'CompressedPdaUndefinedForDecompress',
11801
- },
11802
- {
11803
- code: 6008,
11804
- name: 'DeCompressAmountUndefinedForDecompress',
11805
- msg: 'DeCompressAmountUndefinedForDecompress',
11806
- },
11807
- {
11808
- code: 6009,
11809
- name: 'CompressedPdaUndefinedForCompress',
11810
- msg: 'CompressedPdaUndefinedForCompress',
11811
- },
11812
- {
11813
- code: 6010,
11814
- name: 'DeCompressAmountUndefinedForCompress',
11815
- msg: 'DeCompressAmountUndefinedForCompress',
11816
- },
11817
- {
11818
- code: 6011,
11819
- name: 'DelegateSignerCheckFailed',
11820
- msg: 'DelegateSignerCheckFailed',
11821
- },
11822
- {
11823
- code: 6012,
11824
- name: 'MintTooLarge',
11825
- msg: 'Minted amount greater than u64::MAX',
11826
- },
11827
- {
11828
- code: 6013,
11829
- name: 'SplTokenSupplyMismatch',
11830
- msg: 'SplTokenSupplyMismatch',
11831
- },
11832
- {
11833
- code: 6014,
11834
- name: 'HeapMemoryCheckFailed',
11835
- msg: 'HeapMemoryCheckFailed',
11836
- },
11837
- {
11838
- code: 6015,
11839
- name: 'InstructionNotCallable',
11840
- msg: 'The instruction is not callable',
11841
- },
11842
- {
11843
- code: 6016,
11844
- name: 'ArithmeticUnderflow',
11845
- msg: 'ArithmeticUnderflow',
11846
- },
11847
- {
11848
- code: 6017,
11849
- name: 'HashToFieldError',
11850
- msg: 'HashToFieldError',
11851
- },
11852
- {
11853
- code: 6018,
11854
- name: 'InvalidAuthorityMint',
11855
- msg: 'Expected the authority to be also a mint authority',
11856
- },
11857
- {
11858
- code: 6019,
11859
- name: 'InvalidFreezeAuthority',
11860
- msg: 'Provided authority is not the freeze authority',
11861
- },
11862
- {
11863
- code: 6020,
11864
- name: 'InvalidDelegateIndex',
11865
- },
11866
- {
11867
- code: 6021,
11868
- name: 'TokenPoolPdaUndefined',
11869
- },
11870
- {
11871
- code: 6022,
11872
- name: 'IsTokenPoolPda',
11873
- msg: 'Compress or decompress recipient is the same account as the token pool pda.',
11874
- },
11875
- {
11876
- code: 6023,
11877
- name: 'InvalidTokenPoolPda',
11878
- },
11879
- {
11880
- code: 6024,
11881
- name: 'NoInputTokenAccountsProvided',
11882
- },
11883
- {
11884
- code: 6025,
11885
- name: 'NoInputsProvided',
11779
+ name: 'SerializationError',
11780
+ msg: 'Serialization error',
11886
11781
  },
11887
11782
  ],
11888
11783
  };
@@ -12677,6 +12572,10 @@ const TokenBalanceListResult = type({
12677
12572
  tokenBalances: array(TokenBalanceResult),
12678
12573
  cursor: nullable(string()),
12679
12574
  });
12575
+ const TokenBalanceListResultV2 = type({
12576
+ items: array(TokenBalanceResult),
12577
+ cursor: nullable(string()),
12578
+ });
12680
12579
  const CompressedMintTokenHoldersResult = type({
12681
12580
  cursor: nullable(string()),
12682
12581
  items: array(type({
@@ -13133,8 +13032,10 @@ class Rpc extends Connection {
13133
13032
  return { amount: bn(res.result.value.amount) };
13134
13033
  }
13135
13034
  /**
13035
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
13036
+ *
13136
13037
  * Fetch all the compressed token balances owned by the specified public
13137
- * key. Can filter by mint
13038
+ * key. Can filter by mint. Returns without context.
13138
13039
  */
13139
13040
  async getCompressedTokenBalancesByOwner(owner, options) {
13140
13041
  if (!options)
@@ -13160,6 +13061,37 @@ class Rpc extends Connection {
13160
13061
  cursor: res.result.value.cursor,
13161
13062
  };
13162
13063
  }
13064
+ /**
13065
+ * Fetch the compressed token balances owned by the specified public
13066
+ * key. Paginated. Can filter by mint. Returns with context.
13067
+ */
13068
+ async getCompressedTokenBalancesByOwnerV2(owner, options) {
13069
+ if (!options)
13070
+ options = {};
13071
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedTokenBalancesByOwnerV2', {
13072
+ owner: owner.toBase58(),
13073
+ mint: options.mint?.toBase58(),
13074
+ limit: options.limit?.toNumber(),
13075
+ cursor: options.cursor,
13076
+ });
13077
+ const res = create(unsafeRes, jsonRpcResultAndContext(TokenBalanceListResultV2));
13078
+ if ('error' in res) {
13079
+ throw new SolanaJSONRPCError(res.error, `failed to get compressed token balances for owner ${owner.toBase58()}`);
13080
+ }
13081
+ if (res.result.value === null) {
13082
+ throw new Error(`failed to get compressed token balances for owner ${owner.toBase58()}`);
13083
+ }
13084
+ const maybeFiltered = options.mint
13085
+ ? res.result.value.items.filter(tokenBalance => tokenBalance.mint.toBase58() === options.mint.toBase58())
13086
+ : res.result.value.items;
13087
+ return {
13088
+ context: res.result.context,
13089
+ value: {
13090
+ items: maybeFiltered,
13091
+ cursor: res.result.value.cursor,
13092
+ },
13093
+ };
13094
+ }
13163
13095
  /**
13164
13096
  * Returns confirmed compression signatures for transactions involving the specified
13165
13097
  * account hash forward in time from genesis to the most recent confirmed
@@ -13229,8 +13161,12 @@ class Rpc extends Connection {
13229
13161
  *
13230
13162
  * @param address queried compressed account address
13231
13163
  */
13232
- async getCompressionSignaturesForAddress(address) {
13233
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', { address: address.toBase58() });
13164
+ async getCompressionSignaturesForAddress(address, options) {
13165
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', {
13166
+ address: address.toBase58(),
13167
+ cursor: options?.cursor,
13168
+ limit: options?.limit?.toNumber(),
13169
+ });
13234
13170
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13235
13171
  if ('error' in res) {
13236
13172
  throw new SolanaJSONRPCError(res.error, `failed to get signatures for address ${address.toBase58()}`);
@@ -13247,8 +13183,12 @@ class Rpc extends Connection {
13247
13183
  *
13248
13184
  * @param owner queried owner public key
13249
13185
  */
13250
- async getCompressionSignaturesForOwner(owner) {
13251
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', { owner: owner.toBase58() });
13186
+ async getCompressionSignaturesForOwner(owner, options) {
13187
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', {
13188
+ owner: owner.toBase58(),
13189
+ cursor: options?.cursor,
13190
+ limit: options?.limit?.toNumber(),
13191
+ });
13252
13192
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13253
13193
  if ('error' in res) {
13254
13194
  throw new SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -13258,14 +13198,17 @@ class Rpc extends Connection {
13258
13198
  }
13259
13199
  return res.result.value;
13260
13200
  }
13261
- /// TODO(photon): needs mint
13262
13201
  /**
13263
13202
  * Returns confirmed signatures for compression transactions involving the
13264
13203
  * specified token account owner forward in time from genesis to the most
13265
13204
  * recent confirmed block
13266
13205
  */
13267
- async getCompressionSignaturesForTokenOwner(owner) {
13268
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', { owner: owner.toBase58() });
13206
+ async getCompressionSignaturesForTokenOwner(owner, options) {
13207
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', {
13208
+ owner: owner.toBase58(),
13209
+ cursor: options?.cursor,
13210
+ limit: options?.limit?.toNumber(),
13211
+ });
13269
13212
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13270
13213
  if ('error' in res) {
13271
13214
  throw new SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -13315,6 +13258,9 @@ class Rpc extends Connection {
13315
13258
  }
13316
13259
  return res.result;
13317
13260
  }
13261
+ /**
13262
+ * Fetch all the compressed token holders for a given mint. Paginated.
13263
+ */
13318
13264
  async getCompressedMintTokenHolders(mint, options) {
13319
13265
  const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedMintTokenHolders', {
13320
13266
  mint: mint.toBase58(),
@@ -13342,8 +13288,8 @@ class Rpc extends Connection {
13342
13288
  /**
13343
13289
  * Fetch all non-voting signatures
13344
13290
  */
13345
- async getLatestNonVotingSignatures(limit) {
13346
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit });
13291
+ async getLatestNonVotingSignatures(limit, cursor) {
13292
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit, cursor });
13347
13293
  const res = create(unsafeRes, jsonRpcResultAndContext(LatestNonVotingSignaturesResult));
13348
13294
  if ('error' in res) {
13349
13295
  throw new SolanaJSONRPCError(res.error, 'failed to get latest non-voting signatures');
@@ -17281,8 +17227,9 @@ class TestRpc extends Connection {
17281
17227
  return { amount: bn(account.parsed.amount) };
17282
17228
  }
17283
17229
  /**
17230
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2}.
17284
17231
  * Fetch all the compressed token balances owned by the specified public
17285
- * key. Can filter by mint
17232
+ * key. Can filter by mint.
17286
17233
  */
17287
17234
  async getCompressedTokenBalancesByOwner(publicKey, options) {
17288
17235
  const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
@@ -17294,6 +17241,23 @@ class TestRpc extends Connection {
17294
17241
  cursor: null,
17295
17242
  };
17296
17243
  }
17244
+ /**
17245
+ * Fetch all the compressed token balances owned by the specified public
17246
+ * key. Can filter by mint. Uses context.
17247
+ */
17248
+ async getCompressedTokenBalancesByOwnerV2(publicKey, options) {
17249
+ const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
17250
+ return {
17251
+ context: { slot: 1 },
17252
+ value: {
17253
+ items: accounts.items.map(account => ({
17254
+ balance: bn(account.parsed.amount),
17255
+ mint: account.parsed.mint,
17256
+ })),
17257
+ cursor: null,
17258
+ },
17259
+ };
17260
+ }
17297
17261
  /**
17298
17262
  * Returns confirmed signatures for transactions involving the specified
17299
17263
  * account hash forward in time from genesis to the most recent confirmed
@@ -17301,14 +17265,14 @@ class TestRpc extends Connection {
17301
17265
  *
17302
17266
  * @param hash queried account hash
17303
17267
  */
17304
- async getCompressionSignaturesForAccount(hash) {
17268
+ async getCompressionSignaturesForAccount(_hash) {
17305
17269
  throw new Error('getCompressionSignaturesForAccount not implemented in test-rpc');
17306
17270
  }
17307
17271
  /**
17308
17272
  * Fetch a confirmed or finalized transaction from the cluster. Return with
17309
17273
  * CompressionInfo
17310
17274
  */
17311
- async getTransactionWithCompressionInfo(signature) {
17275
+ async getTransactionWithCompressionInfo(_signature) {
17312
17276
  throw new Error('getCompressedTransaction not implemented in test-rpc');
17313
17277
  }
17314
17278
  /**
@@ -17318,7 +17282,7 @@ class TestRpc extends Connection {
17318
17282
  *
17319
17283
  * @param address queried compressed account address
17320
17284
  */
17321
- async getCompressionSignaturesForAddress(_address) {
17285
+ async getCompressionSignaturesForAddress(_address, _options) {
17322
17286
  throw new Error('getSignaturesForAddress3 not implemented');
17323
17287
  }
17324
17288
  /**
@@ -17328,7 +17292,7 @@ class TestRpc extends Connection {
17328
17292
  *
17329
17293
  * @param owner queried owner public key
17330
17294
  */
17331
- async getCompressionSignaturesForOwner(owner) {
17295
+ async getCompressionSignaturesForOwner(_owner, _options) {
17332
17296
  throw new Error('getSignaturesForOwner not implemented');
17333
17297
  }
17334
17298
  /**
@@ -17336,7 +17300,7 @@ class TestRpc extends Connection {
17336
17300
  * specified token account owner forward in time from genesis to the most
17337
17301
  * recent confirmed block
17338
17302
  */
17339
- async getCompressionSignaturesForTokenOwner(owner) {
17303
+ async getCompressionSignaturesForTokenOwner(_owner, _options) {
17340
17304
  throw new Error('getSignaturesForTokenOwner not implemented');
17341
17305
  }
17342
17306
  /**
@@ -17528,5 +17492,5 @@ class TestRpc extends Connection {
17528
17492
  }
17529
17493
  }
17530
17494
 
17531
- export { ADDRESS_QUEUE_ROLLOVER_FEE, ADDRESS_TREE_NETWORK_FEE, ALICE, IDL$2 as AccountCompressionIDL, AccountProofResult, BOB, BalanceResult, CHARLIE, CompressedAccountResult, CompressedAccountsByOwnerResult, CompressedMintTokenHoldersResult, CompressedTokenAccountResult, CompressedTokenAccountsByOwnerOrDelegateResult, CompressedTransactionResult, CreateUtxoError, CreateUtxoErrorCode, DAVE, DEFAULT_MERKLE_TREE_HEIGHT, DEFAULT_MERKLE_TREE_ROOTS, DEFAULT_ZERO, FIELD_SIZE, HIGHEST_ADDRESS_PLUS_ONE, HashError, HashErrorCode, HealthResult, IndexedArray, IndexedElement, IndexedElementBundle, LatestNonVotingSignaturesResult, LatestNonVotingSignaturesResultPaginated, IDL as LightCompressedTokenIDL, IDL$1 as LightRegistryIDL, IDL$3 as LightSystemIDL, LightSystemProgram, LookupTableError, LookupTableErrorCode, MerkeProofResult, MerkleTree, MerkleTreeError, MerkleTreeErrorCode, MultipleCompressedAccountsResult, MultipleMerkleProofsResult, NativeBalanceResult, NewAddressProofResult, ProofError, ProofErrorCode, Rpc, RpcError, RpcErrorCode, STATE_MERKLE_TREE_NETWORK_FEE, STATE_MERKLE_TREE_ROLLOVER_FEE, SelectInUtxosError, SelectInUtxosErrorCode, SignatureListResult, SignatureListWithCursorResult, SlotResult, TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD, TestRpc, TokenBalanceListResult, TokenBalanceResult, TokenDataResult, UTXO_MERGE_MAXIMUM, UTXO_MERGE_THRESHOLD, UtilsError, UtilsErrorCode, UtxoError, UtxoErrorCode, ValidityProofResult, accountCompressionProgram, addressQueue, addressTree, airdropSol, bn, bufToDecStr, buildAndSignTx, buildTx, byteArrayToKeypair, checkValidityProofShape, compress, confirmConfig, confirmTransaction, confirmTx, convertMerkleProofsWithContextToHex, convertNonInclusionMerkleProofInputsToHex, createAccount, createAccountWithLamports, createBN254, createCompressedAccount, createCompressedAccountWithMerkleContext, createMerkleContext, createRpc, createRpcResult, decompress, dedupeSigner, defaultStaticAccounts, defaultStaticAccountsStruct, defaultTestStateTreeAccounts, deriveAddress, deriveAddressSeed, encodeBN254toBase58, getAccountCompressionAuthority, getConnection, getIndexOrAdd, getParsedEvents, getRegisteredProgramPda, getTestKeypair, getTestRpc, hashToBn254FieldSizeBe, hashvToBn254FieldSizeBe, jsonRpcResult, jsonRpcResultAndContext, lightProgram, merkletreePubkey, negateAndCompressProof, newAccountWithLamports, noopProgram, nullifierQueuePubkey, packCompressedAccounts, packNewAddressParams, padOutputStateMerkleTrees, parseAccountData, parseEvents, parsePublicTransactionEventWithIdl, pipe, placeholderValidityProof, proofFromJsonStruct, proverRequest, pushUniqueItems, rpcRequest, selectMinCompressedSolAccountsForTransfer, sendAndConfirmTx, sleep, sumUpLamports, toAccountMetas, toArray$1 as toArray, toCamelCase, toHex, toUnixTimestamp, transfer, useWallet, validateSameOwner, validateSufficientBalance };
17495
+ export { ADDRESS_QUEUE_ROLLOVER_FEE, ADDRESS_TREE_NETWORK_FEE, ALICE, IDL$2 as AccountCompressionIDL, AccountProofResult, BOB, BalanceResult, CHARLIE, CompressedAccountResult, CompressedAccountsByOwnerResult, CompressedMintTokenHoldersResult, CompressedTokenAccountResult, CompressedTokenAccountsByOwnerOrDelegateResult, CompressedTransactionResult, CreateUtxoError, CreateUtxoErrorCode, DAVE, DEFAULT_MERKLE_TREE_HEIGHT, DEFAULT_MERKLE_TREE_ROOTS, DEFAULT_ZERO, FIELD_SIZE, HIGHEST_ADDRESS_PLUS_ONE, HashError, HashErrorCode, HealthResult, IndexedArray, IndexedElement, IndexedElementBundle, LatestNonVotingSignaturesResult, LatestNonVotingSignaturesResultPaginated, IDL as LightCompressedTokenIDL, IDL$1 as LightRegistryIDL, IDL$3 as LightSystemIDL, LightSystemProgram, LookupTableError, LookupTableErrorCode, MerkeProofResult, MerkleTree, MerkleTreeError, MerkleTreeErrorCode, MultipleCompressedAccountsResult, MultipleMerkleProofsResult, NativeBalanceResult, NewAddressProofResult, ProofError, ProofErrorCode, Rpc, RpcError, RpcErrorCode, STATE_MERKLE_TREE_NETWORK_FEE, STATE_MERKLE_TREE_ROLLOVER_FEE, SelectInUtxosError, SelectInUtxosErrorCode, SignatureListResult, SignatureListWithCursorResult, SlotResult, TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD, TestRpc, TokenBalanceListResult, TokenBalanceListResultV2, TokenBalanceResult, TokenDataResult, UTXO_MERGE_MAXIMUM, UTXO_MERGE_THRESHOLD, UtilsError, UtilsErrorCode, UtxoError, UtxoErrorCode, ValidityProofResult, accountCompressionProgram, addressQueue, addressTree, airdropSol, bn, bufToDecStr, buildAndSignTx, buildTx, byteArrayToKeypair, checkValidityProofShape, compress, confirmConfig, confirmTransaction, confirmTx, convertMerkleProofsWithContextToHex, convertNonInclusionMerkleProofInputsToHex, createAccount, createAccountWithLamports, createBN254, createCompressedAccount, createCompressedAccountWithMerkleContext, createMerkleContext, createRpc, createRpcResult, decompress, dedupeSigner, defaultStaticAccounts, defaultStaticAccountsStruct, defaultTestStateTreeAccounts, deriveAddress, deriveAddressSeed, encodeBN254toBase58, getAccountCompressionAuthority, getConnection, getIndexOrAdd, getParsedEvents, getRegisteredProgramPda, getTestKeypair, getTestRpc, hashToBn254FieldSizeBe, hashvToBn254FieldSizeBe, jsonRpcResult, jsonRpcResultAndContext, lightProgram, merkletreePubkey, negateAndCompressProof, newAccountWithLamports, noopProgram, nullifierQueuePubkey, packCompressedAccounts, packNewAddressParams, padOutputStateMerkleTrees, parseAccountData, parseEvents, parsePublicTransactionEventWithIdl, pipe, placeholderValidityProof, proofFromJsonStruct, proverRequest, pushUniqueItems, rpcRequest, selectMinCompressedSolAccountsForTransfer, sendAndConfirmTx, sleep, sumUpLamports, toAccountMetas, toArray$1 as toArray, toCamelCase, toHex, toUnixTimestamp, transfer, useWallet, validateSameOwner, validateSufficientBalance };
17532
17496
  //# sourceMappingURL=index.js.map