@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.
@@ -11727,128 +11727,23 @@ const IDL = {
11727
11727
  errors: [
11728
11728
  {
11729
11729
  code: 6000,
11730
- name: 'PublicKeyAmountMissmatch',
11731
- msg: 'public keys and amounts must be of same length',
11730
+ name: 'SignerCheckFailed',
11731
+ msg: 'Signer check failed',
11732
11732
  },
11733
11733
  {
11734
11734
  code: 6001,
11735
- name: 'ComputeInputSumFailed',
11736
- msg: 'ComputeInputSumFailed',
11735
+ name: 'CreateTransferInstructionFailed',
11736
+ msg: 'Create transfer instruction failed',
11737
11737
  },
11738
11738
  {
11739
11739
  code: 6002,
11740
- name: 'ComputeOutputSumFailed',
11741
- msg: 'ComputeOutputSumFailed',
11740
+ name: 'AccountNotFound',
11741
+ msg: 'Account not found',
11742
11742
  },
11743
11743
  {
11744
11744
  code: 6003,
11745
- name: 'ComputeCompressSumFailed',
11746
- msg: 'ComputeCompressSumFailed',
11747
- },
11748
- {
11749
- code: 6004,
11750
- name: 'ComputeDecompressSumFailed',
11751
- msg: 'ComputeDecompressSumFailed',
11752
- },
11753
- {
11754
- code: 6005,
11755
- name: 'SumCheckFailed',
11756
- msg: 'SumCheckFailed',
11757
- },
11758
- {
11759
- code: 6006,
11760
- name: 'DecompressRecipientUndefinedForDecompress',
11761
- msg: 'DecompressRecipientUndefinedForDecompress',
11762
- },
11763
- {
11764
- code: 6007,
11765
- name: 'CompressedPdaUndefinedForDecompress',
11766
- msg: 'CompressedPdaUndefinedForDecompress',
11767
- },
11768
- {
11769
- code: 6008,
11770
- name: 'DeCompressAmountUndefinedForDecompress',
11771
- msg: 'DeCompressAmountUndefinedForDecompress',
11772
- },
11773
- {
11774
- code: 6009,
11775
- name: 'CompressedPdaUndefinedForCompress',
11776
- msg: 'CompressedPdaUndefinedForCompress',
11777
- },
11778
- {
11779
- code: 6010,
11780
- name: 'DeCompressAmountUndefinedForCompress',
11781
- msg: 'DeCompressAmountUndefinedForCompress',
11782
- },
11783
- {
11784
- code: 6011,
11785
- name: 'DelegateSignerCheckFailed',
11786
- msg: 'DelegateSignerCheckFailed',
11787
- },
11788
- {
11789
- code: 6012,
11790
- name: 'MintTooLarge',
11791
- msg: 'Minted amount greater than u64::MAX',
11792
- },
11793
- {
11794
- code: 6013,
11795
- name: 'SplTokenSupplyMismatch',
11796
- msg: 'SplTokenSupplyMismatch',
11797
- },
11798
- {
11799
- code: 6014,
11800
- name: 'HeapMemoryCheckFailed',
11801
- msg: 'HeapMemoryCheckFailed',
11802
- },
11803
- {
11804
- code: 6015,
11805
- name: 'InstructionNotCallable',
11806
- msg: 'The instruction is not callable',
11807
- },
11808
- {
11809
- code: 6016,
11810
- name: 'ArithmeticUnderflow',
11811
- msg: 'ArithmeticUnderflow',
11812
- },
11813
- {
11814
- code: 6017,
11815
- name: 'HashToFieldError',
11816
- msg: 'HashToFieldError',
11817
- },
11818
- {
11819
- code: 6018,
11820
- name: 'InvalidAuthorityMint',
11821
- msg: 'Expected the authority to be also a mint authority',
11822
- },
11823
- {
11824
- code: 6019,
11825
- name: 'InvalidFreezeAuthority',
11826
- msg: 'Provided authority is not the freeze authority',
11827
- },
11828
- {
11829
- code: 6020,
11830
- name: 'InvalidDelegateIndex',
11831
- },
11832
- {
11833
- code: 6021,
11834
- name: 'TokenPoolPdaUndefined',
11835
- },
11836
- {
11837
- code: 6022,
11838
- name: 'IsTokenPoolPda',
11839
- msg: 'Compress or decompress recipient is the same account as the token pool pda.',
11840
- },
11841
- {
11842
- code: 6023,
11843
- name: 'InvalidTokenPoolPda',
11844
- },
11845
- {
11846
- code: 6024,
11847
- name: 'NoInputTokenAccountsProvided',
11848
- },
11849
- {
11850
- code: 6025,
11851
- name: 'NoInputsProvided',
11745
+ name: 'SerializationError',
11746
+ msg: 'Serialization error',
11852
11747
  },
11853
11748
  ],
11854
11749
  };
@@ -12637,6 +12532,10 @@ const TokenBalanceListResult = type({
12637
12532
  tokenBalances: array(TokenBalanceResult),
12638
12533
  cursor: nullable(string()),
12639
12534
  });
12535
+ const TokenBalanceListResultV2 = type({
12536
+ items: array(TokenBalanceResult),
12537
+ cursor: nullable(string()),
12538
+ });
12640
12539
  const CompressedMintTokenHoldersResult = type({
12641
12540
  cursor: nullable(string()),
12642
12541
  items: array(type({
@@ -13094,8 +12993,10 @@ class Rpc extends web3_js.Connection {
13094
12993
  return { amount: bn(res.result.value.amount) };
13095
12994
  }
13096
12995
  /**
12996
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2} instead.
12997
+ *
13097
12998
  * Fetch all the compressed token balances owned by the specified public
13098
- * key. Can filter by mint
12999
+ * key. Can filter by mint. Returns without context.
13099
13000
  */
13100
13001
  async getCompressedTokenBalancesByOwner(owner, options) {
13101
13002
  var _a, _b;
@@ -13122,6 +13023,38 @@ class Rpc extends web3_js.Connection {
13122
13023
  cursor: res.result.value.cursor,
13123
13024
  };
13124
13025
  }
13026
+ /**
13027
+ * Fetch the compressed token balances owned by the specified public
13028
+ * key. Paginated. Can filter by mint. Returns with context.
13029
+ */
13030
+ async getCompressedTokenBalancesByOwnerV2(owner, options) {
13031
+ var _a, _b;
13032
+ if (!options)
13033
+ options = {};
13034
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressedTokenBalancesByOwnerV2', {
13035
+ owner: owner.toBase58(),
13036
+ mint: (_a = options.mint) === null || _a === void 0 ? void 0 : _a.toBase58(),
13037
+ limit: (_b = options.limit) === null || _b === void 0 ? void 0 : _b.toNumber(),
13038
+ cursor: options.cursor,
13039
+ });
13040
+ const res = create(unsafeRes, jsonRpcResultAndContext(TokenBalanceListResultV2));
13041
+ if ('error' in res) {
13042
+ throw new web3_js.SolanaJSONRPCError(res.error, `failed to get compressed token balances for owner ${owner.toBase58()}`);
13043
+ }
13044
+ if (res.result.value === null) {
13045
+ throw new Error(`failed to get compressed token balances for owner ${owner.toBase58()}`);
13046
+ }
13047
+ const maybeFiltered = options.mint
13048
+ ? res.result.value.items.filter(tokenBalance => tokenBalance.mint.toBase58() === options.mint.toBase58())
13049
+ : res.result.value.items;
13050
+ return {
13051
+ context: res.result.context,
13052
+ value: {
13053
+ items: maybeFiltered,
13054
+ cursor: res.result.value.cursor,
13055
+ },
13056
+ };
13057
+ }
13125
13058
  /**
13126
13059
  * Returns confirmed compression signatures for transactions involving the specified
13127
13060
  * account hash forward in time from genesis to the most recent confirmed
@@ -13191,8 +13124,13 @@ class Rpc extends web3_js.Connection {
13191
13124
  *
13192
13125
  * @param address queried compressed account address
13193
13126
  */
13194
- async getCompressionSignaturesForAddress(address) {
13195
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', { address: address.toBase58() });
13127
+ async getCompressionSignaturesForAddress(address, options) {
13128
+ var _a;
13129
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForAddress', {
13130
+ address: address.toBase58(),
13131
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
13132
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
13133
+ });
13196
13134
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13197
13135
  if ('error' in res) {
13198
13136
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for address ${address.toBase58()}`);
@@ -13209,8 +13147,13 @@ class Rpc extends web3_js.Connection {
13209
13147
  *
13210
13148
  * @param owner queried owner public key
13211
13149
  */
13212
- async getCompressionSignaturesForOwner(owner) {
13213
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', { owner: owner.toBase58() });
13150
+ async getCompressionSignaturesForOwner(owner, options) {
13151
+ var _a;
13152
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForOwner', {
13153
+ owner: owner.toBase58(),
13154
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
13155
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
13156
+ });
13214
13157
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13215
13158
  if ('error' in res) {
13216
13159
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -13220,14 +13163,18 @@ class Rpc extends web3_js.Connection {
13220
13163
  }
13221
13164
  return res.result.value;
13222
13165
  }
13223
- /// TODO(photon): needs mint
13224
13166
  /**
13225
13167
  * Returns confirmed signatures for compression transactions involving the
13226
13168
  * specified token account owner forward in time from genesis to the most
13227
13169
  * recent confirmed block
13228
13170
  */
13229
- async getCompressionSignaturesForTokenOwner(owner) {
13230
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', { owner: owner.toBase58() });
13171
+ async getCompressionSignaturesForTokenOwner(owner, options) {
13172
+ var _a;
13173
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getCompressionSignaturesForTokenOwner', {
13174
+ owner: owner.toBase58(),
13175
+ cursor: options === null || options === void 0 ? void 0 : options.cursor,
13176
+ limit: (_a = options === null || options === void 0 ? void 0 : options.limit) === null || _a === void 0 ? void 0 : _a.toNumber(),
13177
+ });
13231
13178
  const res = create(unsafeRes, jsonRpcResultAndContext(SignatureListWithCursorResult));
13232
13179
  if ('error' in res) {
13233
13180
  throw new web3_js.SolanaJSONRPCError(res.error, `failed to get signatures for owner ${owner.toBase58()}`);
@@ -13305,8 +13252,8 @@ class Rpc extends web3_js.Connection {
13305
13252
  /**
13306
13253
  * Fetch all non-voting signatures
13307
13254
  */
13308
- async getLatestNonVotingSignatures(limit) {
13309
- const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit });
13255
+ async getLatestNonVotingSignatures(limit, cursor) {
13256
+ const unsafeRes = await rpcRequest(this.compressionApiEndpoint, 'getLatestNonVotingSignatures', { limit, cursor });
13310
13257
  const res = create(unsafeRes, jsonRpcResultAndContext(LatestNonVotingSignaturesResult));
13311
13258
  if ('error' in res) {
13312
13259
  throw new web3_js.SolanaJSONRPCError(res.error, 'failed to get latest non-voting signatures');
@@ -17218,8 +17165,9 @@ class TestRpc extends web3_js.Connection {
17218
17165
  return { amount: bn(account.parsed.amount) };
17219
17166
  }
17220
17167
  /**
17168
+ * @deprecated use {@link getCompressedTokenBalancesByOwnerV2}.
17221
17169
  * Fetch all the compressed token balances owned by the specified public
17222
- * key. Can filter by mint
17170
+ * key. Can filter by mint.
17223
17171
  */
17224
17172
  async getCompressedTokenBalancesByOwner(publicKey, options) {
17225
17173
  const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
@@ -17231,6 +17179,23 @@ class TestRpc extends web3_js.Connection {
17231
17179
  cursor: null,
17232
17180
  };
17233
17181
  }
17182
+ /**
17183
+ * Fetch all the compressed token balances owned by the specified public
17184
+ * key. Can filter by mint. Uses context.
17185
+ */
17186
+ async getCompressedTokenBalancesByOwnerV2(publicKey, options) {
17187
+ const accounts = await getCompressedTokenAccountsByOwnerTest(this, publicKey, options.mint);
17188
+ return {
17189
+ context: { slot: 1 },
17190
+ value: {
17191
+ items: accounts.items.map(account => ({
17192
+ balance: bn(account.parsed.amount),
17193
+ mint: account.parsed.mint,
17194
+ })),
17195
+ cursor: null,
17196
+ },
17197
+ };
17198
+ }
17234
17199
  /**
17235
17200
  * Returns confirmed signatures for transactions involving the specified
17236
17201
  * account hash forward in time from genesis to the most recent confirmed
@@ -17238,14 +17203,14 @@ class TestRpc extends web3_js.Connection {
17238
17203
  *
17239
17204
  * @param hash queried account hash
17240
17205
  */
17241
- async getCompressionSignaturesForAccount(hash) {
17206
+ async getCompressionSignaturesForAccount(_hash) {
17242
17207
  throw new Error('getCompressionSignaturesForAccount not implemented in test-rpc');
17243
17208
  }
17244
17209
  /**
17245
17210
  * Fetch a confirmed or finalized transaction from the cluster. Return with
17246
17211
  * CompressionInfo
17247
17212
  */
17248
- async getTransactionWithCompressionInfo(signature) {
17213
+ async getTransactionWithCompressionInfo(_signature) {
17249
17214
  throw new Error('getCompressedTransaction not implemented in test-rpc');
17250
17215
  }
17251
17216
  /**
@@ -17255,7 +17220,7 @@ class TestRpc extends web3_js.Connection {
17255
17220
  *
17256
17221
  * @param address queried compressed account address
17257
17222
  */
17258
- async getCompressionSignaturesForAddress(_address) {
17223
+ async getCompressionSignaturesForAddress(_address, _options) {
17259
17224
  throw new Error('getSignaturesForAddress3 not implemented');
17260
17225
  }
17261
17226
  /**
@@ -17265,7 +17230,7 @@ class TestRpc extends web3_js.Connection {
17265
17230
  *
17266
17231
  * @param owner queried owner public key
17267
17232
  */
17268
- async getCompressionSignaturesForOwner(owner) {
17233
+ async getCompressionSignaturesForOwner(_owner, _options) {
17269
17234
  throw new Error('getSignaturesForOwner not implemented');
17270
17235
  }
17271
17236
  /**
@@ -17273,7 +17238,7 @@ class TestRpc extends web3_js.Connection {
17273
17238
  * specified token account owner forward in time from genesis to the most
17274
17239
  * recent confirmed block
17275
17240
  */
17276
- async getCompressionSignaturesForTokenOwner(owner) {
17241
+ async getCompressionSignaturesForTokenOwner(_owner, _options) {
17277
17242
  throw new Error('getSignaturesForTokenOwner not implemented');
17278
17243
  }
17279
17244
  /**
@@ -17517,6 +17482,7 @@ exports.SlotResult = SlotResult;
17517
17482
  exports.TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD = TRANSACTION_MERKLE_TREE_ROLLOVER_THRESHOLD;
17518
17483
  exports.TestRpc = TestRpc;
17519
17484
  exports.TokenBalanceListResult = TokenBalanceListResult;
17485
+ exports.TokenBalanceListResultV2 = TokenBalanceListResultV2;
17520
17486
  exports.TokenBalanceResult = TokenBalanceResult;
17521
17487
  exports.TokenDataResult = TokenDataResult;
17522
17488
  exports.UTXO_MERGE_MAXIMUM = UTXO_MERGE_MAXIMUM;