@lightprotocol/stateless.js 0.14.4 → 0.15.0

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.
@@ -9697,128 +9697,23 @@ const IDL = {
9697
9697
  errors: [
9698
9698
  {
9699
9699
  code: 6000,
9700
- name: 'PublicKeyAmountMissmatch',
9701
- msg: 'public keys and amounts must be of same length',
9700
+ name: 'SignerCheckFailed',
9701
+ msg: 'Signer check failed',
9702
9702
  },
9703
9703
  {
9704
9704
  code: 6001,
9705
- name: 'ComputeInputSumFailed',
9706
- msg: 'ComputeInputSumFailed',
9705
+ name: 'CreateTransferInstructionFailed',
9706
+ msg: 'Create transfer instruction failed',
9707
9707
  },
9708
9708
  {
9709
9709
  code: 6002,
9710
- name: 'ComputeOutputSumFailed',
9711
- msg: 'ComputeOutputSumFailed',
9710
+ name: 'AccountNotFound',
9711
+ msg: 'Account not found',
9712
9712
  },
9713
9713
  {
9714
9714
  code: 6003,
9715
- name: 'ComputeCompressSumFailed',
9716
- msg: 'ComputeCompressSumFailed',
9717
- },
9718
- {
9719
- code: 6004,
9720
- name: 'ComputeDecompressSumFailed',
9721
- msg: 'ComputeDecompressSumFailed',
9722
- },
9723
- {
9724
- code: 6005,
9725
- name: 'SumCheckFailed',
9726
- msg: 'SumCheckFailed',
9727
- },
9728
- {
9729
- code: 6006,
9730
- name: 'DecompressRecipientUndefinedForDecompress',
9731
- msg: 'DecompressRecipientUndefinedForDecompress',
9732
- },
9733
- {
9734
- code: 6007,
9735
- name: 'CompressedPdaUndefinedForDecompress',
9736
- msg: 'CompressedPdaUndefinedForDecompress',
9737
- },
9738
- {
9739
- code: 6008,
9740
- name: 'DeCompressAmountUndefinedForDecompress',
9741
- msg: 'DeCompressAmountUndefinedForDecompress',
9742
- },
9743
- {
9744
- code: 6009,
9745
- name: 'CompressedPdaUndefinedForCompress',
9746
- msg: 'CompressedPdaUndefinedForCompress',
9747
- },
9748
- {
9749
- code: 6010,
9750
- name: 'DeCompressAmountUndefinedForCompress',
9751
- msg: 'DeCompressAmountUndefinedForCompress',
9752
- },
9753
- {
9754
- code: 6011,
9755
- name: 'DelegateSignerCheckFailed',
9756
- msg: 'DelegateSignerCheckFailed',
9757
- },
9758
- {
9759
- code: 6012,
9760
- name: 'MintTooLarge',
9761
- msg: 'Minted amount greater than u64::MAX',
9762
- },
9763
- {
9764
- code: 6013,
9765
- name: 'SplTokenSupplyMismatch',
9766
- msg: 'SplTokenSupplyMismatch',
9767
- },
9768
- {
9769
- code: 6014,
9770
- name: 'HeapMemoryCheckFailed',
9771
- msg: 'HeapMemoryCheckFailed',
9772
- },
9773
- {
9774
- code: 6015,
9775
- name: 'InstructionNotCallable',
9776
- msg: 'The instruction is not callable',
9777
- },
9778
- {
9779
- code: 6016,
9780
- name: 'ArithmeticUnderflow',
9781
- msg: 'ArithmeticUnderflow',
9782
- },
9783
- {
9784
- code: 6017,
9785
- name: 'HashToFieldError',
9786
- msg: 'HashToFieldError',
9787
- },
9788
- {
9789
- code: 6018,
9790
- name: 'InvalidAuthorityMint',
9791
- msg: 'Expected the authority to be also a mint authority',
9792
- },
9793
- {
9794
- code: 6019,
9795
- name: 'InvalidFreezeAuthority',
9796
- msg: 'Provided authority is not the freeze authority',
9797
- },
9798
- {
9799
- code: 6020,
9800
- name: 'InvalidDelegateIndex',
9801
- },
9802
- {
9803
- code: 6021,
9804
- name: 'TokenPoolPdaUndefined',
9805
- },
9806
- {
9807
- code: 6022,
9808
- name: 'IsTokenPoolPda',
9809
- msg: 'Compress or decompress recipient is the same account as the token pool pda.',
9810
- },
9811
- {
9812
- code: 6023,
9813
- name: 'InvalidTokenPoolPda',
9814
- },
9815
- {
9816
- code: 6024,
9817
- name: 'NoInputTokenAccountsProvided',
9818
- },
9819
- {
9820
- code: 6025,
9821
- name: 'NoInputsProvided',
9715
+ name: 'SerializationError',
9716
+ msg: 'Serialization error',
9822
9717
  },
9823
9718
  ],
9824
9719
  };
@@ -10607,6 +10502,10 @@ const TokenBalanceListResult = type({
10607
10502
  tokenBalances: array(TokenBalanceResult),
10608
10503
  cursor: nullable(string()),
10609
10504
  });
10505
+ const TokenBalanceListResultV2 = type({
10506
+ items: array(TokenBalanceResult),
10507
+ cursor: nullable(string()),
10508
+ });
10610
10509
  const CompressedMintTokenHoldersResult = type({
10611
10510
  cursor: nullable(string()),
10612
10511
  items: array(type({
@@ -11064,8 +10963,10 @@ class Rpc extends web3_js.Connection {
11064
10963
  return { amount: bn(res.result.value.amount) };
11065
10964
  }
11066
10965
  /**
10966
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
10967
+ *
11067
10968
  * Fetch all the compressed token balances owned by the specified public
11068
- * key. Can filter by mint
10969
+ * key. Can filter by mint. Returns without context.
11069
10970
  */
11070
10971
  async getCompressedTokenBalancesByOwner(owner, options) {
11071
10972
  var _a, _b;
@@ -11092,6 +10993,38 @@ class Rpc extends web3_js.Connection {
11092
10993
  cursor: res.result.value.cursor,
11093
10994
  };
11094
10995
  }
10996
+ /**
10997
+ * Fetch the compressed token balances owned by the specified public
10998
+ * key. Paginated. Can filter by mint. Returns with context.
10999
+ */
11000
+ async getCompressedTokenBalancesByOwnerV2(owner, options) {
11001
+ var _a, _b;
11002
+ if (!options)
11003
+ options = {};
11004
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedTokenBalancesByOwnerV2', {
11005
+ owner: owner.toBase58(),
11006
+ mint: (_a = options.mint) === null || _a === void 0 ? void 0 : _a.toBase58(),
11007
+ limit: (_b = options.limit) === null || _b === void 0 ? void 0 : _b.toNumber(),
11008
+ cursor: options.cursor,
11009
+ });
11010
+ const res = create(unsafeRes, jsonRpcResultAndContext(TokenBalanceListResultV2));
11011
+ if ('error' in res) {
11012
+ throw new web3_js.SolanaJSONRPCError(res.error, `failed to get compressed token balances for owner ${owner.toBase58()}`);
11013
+ }
11014
+ if (res.result.value === null) {
11015
+ throw new Error(`failed to get compressed token balances for owner ${owner.toBase58()}`);
11016
+ }
11017
+ const maybeFiltered = options.mint
11018
+ ? res.result.value.items.filter(tokenBalance => tokenBalance.mint.toBase58() === options.mint.toBase58())
11019
+ : res.result.value.items;
11020
+ return {
11021
+ context: res.result.context,
11022
+ value: {
11023
+ items: maybeFiltered,
11024
+ cursor: res.result.value.cursor,
11025
+ },
11026
+ };
11027
+ }
11095
11028
  /**
11096
11029
  * Returns confirmed compression signatures for transactions involving the specified
11097
11030
  * account hash forward in time from genesis to the most recent confirmed
@@ -11161,8 +11094,13 @@ class Rpc extends web3_js.Connection {
11161
11094
  *
11162
11095
  * @param address queried compressed account address
11163
11096
  */
11164
- async getCompressionSignaturesForAddress(address) {
11165
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', { address: address.toBase58() });
11097
+ async getCompressionSignaturesForAddress(address, options) {
11098
+ var _a;
11099
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', {
11100
+ address: address.toBase58(),
11101
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
11102
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
11103
+ });
11166
11104
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
11167
11105
  if ('error' in res) {
11168
11106
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for address ${address.toBase58()}`);
@@ -11179,8 +11117,13 @@ class Rpc extends web3_js.Connection {
11179
11117
  *
11180
11118
  * @param owner queried owner public key
11181
11119
  */
11182
- async getCompressionSignaturesForOwner(owner) {
11183
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', { owner: owner.toBase58() });
11120
+ async getCompressionSignaturesForOwner(owner, options) {
11121
+ var _a;
11122
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', {
11123
+ owner: owner.toBase58(),
11124
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
11125
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
11126
+ });
11184
11127
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
11185
11128
  if ('error' in res) {
11186
11129
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -11190,14 +11133,18 @@ class Rpc extends web3_js.Connection {
11190
11133
  }
11191
11134
  return res.result.value;
11192
11135
  }
11193
- /// TODO(photon): needs mint
11194
11136
  /**
11195
11137
  * Returns confirmed signatures for compression transactions involving the
11196
11138
  * specified token account owner forward in time from genesis to the most
11197
11139
  * recent confirmed block
11198
11140
  */
11199
- async getCompressionSignaturesForTokenOwner(owner) {
11200
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', { owner: owner.toBase58() });
11141
+ async getCompressionSignaturesForTokenOwner(owner, options) {
11142
+ var _a;
11143
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', {
11144
+ owner: owner.toBase58(),
11145
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
11146
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
11147
+ });
11201
11148
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
11202
11149
  if ('error' in res) {
11203
11150
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -11275,8 +11222,8 @@ class Rpc extends web3_js.Connection {
11275
11222
  /**
11276
11223
  * Fetch all non-voting signatures
11277
11224
  */
11278
- async getLatestNonVotingSignatures(limit) {
11279
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit });
11225
+ async getLatestNonVotingSignatures(limit, cursor) {
11226
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit, cursor });
11280
11227
  const res = create(unsafeRes, jsonRpcResultAndContext(LatestNonVotingSignaturesResult));
11281
11228
  if ('error' in res) {
11282
11229
  throw new web3_js.SolanaJSONRPCError(res.error, 'failed to get latest non-voting signatures');
@@ -14238,8 +14185,9 @@ class TestRpc extends web3_js.Connection {
14238
14185
  return { amount: bn(account.parsed.amount) };
14239
14186
  }
14240
14187
  /**
14188
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2}.
14241
14189
  * Fetch all the compressed token balances owned by the specified public
14242
- * key. Can filter by mint
14190
+ * key. Can filter by mint.
14243
14191
  */
14244
14192
  async getCompressedTokenBalancesByOwner(publicKey, options) {
14245
14193
  const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
@@ -14251,6 +14199,23 @@ class TestRpc extends web3_js.Connection {
14251
14199
  cursor: null,
14252
14200
  };
14253
14201
  }
14202
+ /**
14203
+ * Fetch all the compressed token balances owned by the specified public
14204
+ * key. Can filter by mint. Uses context.
14205
+ */
14206
+ async getCompressedTokenBalancesByOwnerV2(publicKey, options) {
14207
+ const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
14208
+ return {
14209
+ context: { slot: 1 },
14210
+ value: {
14211
+ items: accounts.items.map(account => ({
14212
+ balance: bn(account.parsed.amount),
14213
+ mint: account.parsed.mint,
14214
+ })),
14215
+ cursor: null,
14216
+ },
14217
+ };
14218
+ }
14254
14219
  /**
14255
14220
  * Returns confirmed signatures for transactions involving the specified
14256
14221
  * account hash forward in time from genesis to the most recent confirmed
@@ -14258,14 +14223,14 @@ class TestRpc extends web3_js.Connection {
14258
14223
  *
14259
14224
  * @param hash queried account hash
14260
14225
  */
14261
- async getCompressionSignaturesForAccount(hash) {
14226
+ async getCompressionSignaturesForAccount(_hash) {
14262
14227
  throw new Error('getCompressionSignaturesForAccount not implemented in test-rpc');
14263
14228
  }
14264
14229
  /**
14265
14230
  * Fetch a confirmed or finalized transaction from the cluster. Return with
14266
14231
  * CompressionInfo
14267
14232
  */
14268
- async getTransactionWithCompressionInfo(signature) {
14233
+ async getTransactionWithCompressionInfo(_signature) {
14269
14234
  throw new Error('getCompressedTransaction not implemented in test-rpc');
14270
14235
  }
14271
14236
  /**
@@ -14275,7 +14240,7 @@ class TestRpc extends web3_js.Connection {
14275
14240
  *
14276
14241
  * @param address queried compressed account address
14277
14242
  */
14278
- async getCompressionSignaturesForAddress(_address) {
14243
+ async getCompressionSignaturesForAddress(_address, _options) {
14279
14244
  throw new Error('getSignaturesForAddress3 not implemented');
14280
14245
  }
14281
14246
  /**
@@ -14285,7 +14250,7 @@ class TestRpc extends web3_js.Connection {
14285
14250
  *
14286
14251
  * @param owner queried owner public key
14287
14252
  */
14288
- async getCompressionSignaturesForOwner(owner) {
14253
+ async getCompressionSignaturesForOwner(_owner, _options) {
14289
14254
  throw new Error('getSignaturesForOwner not implemented');
14290
14255
  }
14291
14256
  /**
@@ -14293,7 +14258,7 @@ class TestRpc extends web3_js.Connection {
14293
14258
  * specified token account owner forward in time from genesis to the most
14294
14259
  * recent confirmed block
14295
14260
  */
14296
- async getCompressionSignaturesForTokenOwner(owner) {
14261
+ async getCompressionSignaturesForTokenOwner(_owner, _options) {
14297
14262
  throw new Error('getSignaturesForTokenOwner not implemented');
14298
14263
  }
14299
14264
  /**
@@ -14537,6 +14502,7 @@ exports.SlotResult = SlotResult;
14537
14502
  exports.TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD = TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD;
14538
14503
  exports.TestRpc = TestRpc;
14539
14504
  exports.TokenBalanceListResult = TokenBalanceListResult;
14505
+ exports.TokenBalanceListResultV2 = TokenBalanceListResultV2;
14540
14506
  exports.TokenBalanceResult = TokenBalanceResult;
14541
14507
  exports.TokenDataResult = TokenDataResult;
14542
14508
  exports.UTXO_MERGE_MAXIMUM = UTXO_MERGE_MAXIMUM;