@fuel-ts/account 0.0.0-rc-2408-20240620151941 → 0.0.0-rc-2366-20240620152942

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.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

@@ -774,9 +774,6 @@ var GetCoinsDocument = gql`
774
774
  first: $first
775
775
  last: $last
776
776
  ) {
777
- pageInfo {
778
- ...pageInfoFragment
779
- }
780
777
  edges {
781
778
  node {
782
779
  ...coinFragment
@@ -784,8 +781,7 @@ var GetCoinsDocument = gql`
784
781
  }
785
782
  }
786
783
  }
787
- ${PageInfoFragmentDoc}
788
- ${CoinFragmentDoc}`;
784
+ ${CoinFragmentDoc}`;
789
785
  var GetCoinsToSpendDocument = gql`
790
786
  query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
791
787
  coinsToSpend(
@@ -844,9 +840,6 @@ var GetBalancesDocument = gql`
844
840
  first: $first
845
841
  last: $last
846
842
  ) {
847
- pageInfo {
848
- ...pageInfoFragment
849
- }
850
843
  edges {
851
844
  node {
852
845
  ...balanceFragment
@@ -854,8 +847,7 @@ var GetBalancesDocument = gql`
854
847
  }
855
848
  }
856
849
  }
857
- ${PageInfoFragmentDoc}
858
- ${BalanceFragmentDoc}`;
850
+ ${BalanceFragmentDoc}`;
859
851
  var GetMessagesDocument = gql`
860
852
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
861
853
  messages(
@@ -865,9 +857,6 @@ var GetMessagesDocument = gql`
865
857
  first: $first
866
858
  last: $last
867
859
  ) {
868
- pageInfo {
869
- ...pageInfoFragment
870
- }
871
860
  edges {
872
861
  node {
873
862
  ...messageFragment
@@ -875,8 +864,7 @@ var GetMessagesDocument = gql`
875
864
  }
876
865
  }
877
866
  }
878
- ${PageInfoFragmentDoc}
879
- ${MessageFragmentDoc}`;
867
+ ${MessageFragmentDoc}`;
880
868
  var GetMessageProofDocument = gql`
881
869
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
882
870
  messageProof(
@@ -4433,27 +4421,21 @@ Supported fuel-core version: ${supportedVersion}.`
4433
4421
  * @returns A promise that resolves to the coins.
4434
4422
  */
4435
4423
  async getCoins(owner, assetId, paginationArgs) {
4436
- this.validatePaginationArgs(paginationArgs);
4437
4424
  const ownerAddress = Address2.fromAddressOrString(owner);
4438
- const {
4439
- coins: { edges, pageInfo }
4440
- } = await this.operations.getCoins({
4441
- first: 100,
4425
+ const result = await this.operations.getCoins({
4426
+ first: 10,
4442
4427
  ...paginationArgs,
4443
4428
  filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify12(assetId) }
4444
4429
  });
4445
- const coins = edges.map(({ node }) => ({
4446
- id: node.utxoId,
4447
- assetId: node.assetId,
4448
- amount: bn17(node.amount),
4449
- owner: Address2.fromAddressOrString(node.owner),
4450
- blockCreated: bn17(node.blockCreated),
4451
- txCreatedIdx: bn17(node.txCreatedIdx)
4430
+ const coins = result.coins.edges.map((edge) => edge.node);
4431
+ return coins.map((coin) => ({
4432
+ id: coin.utxoId,
4433
+ assetId: coin.assetId,
4434
+ amount: bn17(coin.amount),
4435
+ owner: Address2.fromAddressOrString(coin.owner),
4436
+ blockCreated: bn17(coin.blockCreated),
4437
+ txCreatedIdx: bn17(coin.txCreatedIdx)
4452
4438
  }));
4453
- return {
4454
- coins,
4455
- pageInfo
4456
- };
4457
4439
  }
4458
4440
  /**
4459
4441
  * Returns resources for the given owner satisfying the spend query.
@@ -4663,22 +4645,17 @@ Supported fuel-core version: ${supportedVersion}.`
4663
4645
  * @param paginationArgs - Pagination arguments (optional).
4664
4646
  * @returns A promise that resolves to the balances.
4665
4647
  */
4666
- async getBalances(owner) {
4667
- const {
4668
- balances: { edges }
4669
- } = await this.operations.getBalances({
4670
- /**
4671
- * The query parameters for this method were designed to support pagination,
4672
- * but the current Fuel-Core implementation does not support pagination yet.
4673
- */
4674
- first: 1e4,
4648
+ async getBalances(owner, paginationArgs) {
4649
+ const result = await this.operations.getBalances({
4650
+ first: 10,
4651
+ ...paginationArgs,
4675
4652
  filter: { owner: Address2.fromAddressOrString(owner).toB256() }
4676
4653
  });
4677
- const balances = edges.map(({ node }) => ({
4678
- assetId: node.assetId,
4679
- amount: bn17(node.amount)
4654
+ const balances = result.balances.edges.map((edge) => edge.node);
4655
+ return balances.map((balance) => ({
4656
+ assetId: balance.assetId,
4657
+ amount: bn17(balance.amount)
4680
4658
  }));
4681
- return { balances };
4682
4659
  }
4683
4660
  /**
4684
4661
  * Returns message for the given address.
@@ -4688,33 +4665,27 @@ Supported fuel-core version: ${supportedVersion}.`
4688
4665
  * @returns A promise that resolves to the messages.
4689
4666
  */
4690
4667
  async getMessages(address, paginationArgs) {
4691
- this.validatePaginationArgs(paginationArgs);
4692
- const {
4693
- messages: { edges, pageInfo }
4694
- } = await this.operations.getMessages({
4695
- first: 100,
4668
+ const result = await this.operations.getMessages({
4669
+ first: 10,
4696
4670
  ...paginationArgs,
4697
4671
  owner: Address2.fromAddressOrString(address).toB256()
4698
4672
  });
4699
- const messages = edges.map(({ node }) => ({
4673
+ const messages = result.messages.edges.map((edge) => edge.node);
4674
+ return messages.map((message) => ({
4700
4675
  messageId: InputMessageCoder.getMessageId({
4701
- sender: node.sender,
4702
- recipient: node.recipient,
4703
- nonce: node.nonce,
4704
- amount: bn17(node.amount),
4705
- data: node.data
4676
+ sender: message.sender,
4677
+ recipient: message.recipient,
4678
+ nonce: message.nonce,
4679
+ amount: bn17(message.amount),
4680
+ data: message.data
4706
4681
  }),
4707
- sender: Address2.fromAddressOrString(node.sender),
4708
- recipient: Address2.fromAddressOrString(node.recipient),
4709
- nonce: node.nonce,
4710
- amount: bn17(node.amount),
4711
- data: InputMessageCoder.decodeData(node.data),
4712
- daHeight: bn17(node.daHeight)
4682
+ sender: Address2.fromAddressOrString(message.sender),
4683
+ recipient: Address2.fromAddressOrString(message.recipient),
4684
+ nonce: message.nonce,
4685
+ amount: bn17(message.amount),
4686
+ data: InputMessageCoder.decodeData(message.data),
4687
+ daHeight: bn17(message.daHeight)
4713
4688
  }));
4714
- return {
4715
- messages,
4716
- pageInfo
4717
- };
4718
4689
  }
4719
4690
  /**
4720
4691
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -4893,18 +4864,6 @@ Supported fuel-core version: ${supportedVersion}.`
4893
4864
  }
4894
4865
  return relayedTransactionStatus;
4895
4866
  }
4896
- /**
4897
- * @hidden
4898
- */
4899
- validatePaginationArgs({ first, last } = {}) {
4900
- const MAX_PAGINATION_LIMIT = 1e3;
4901
- if ((first || 0) > MAX_PAGINATION_LIMIT || (last || 0) > MAX_PAGINATION_LIMIT) {
4902
- throw new FuelError13(
4903
- ErrorCode13.INVALID_INPUT_PARAMETERS,
4904
- "Pagination limit cannot exceed 1000 items"
4905
- );
4906
- }
4907
- }
4908
4867
  /**
4909
4868
  * @hidden
4910
4869
  */
@@ -5130,16 +5089,52 @@ var Account = class extends AbstractAccount {
5130
5089
  * @param assetId - The asset ID of the coins to retrieve (optional).
5131
5090
  * @returns A promise that resolves to an array of Coins.
5132
5091
  */
5133
- async getCoins(assetId, paginationArgs) {
5134
- return this.provider.getCoins(this.address, assetId, paginationArgs);
5092
+ async getCoins(assetId) {
5093
+ const coins = [];
5094
+ const pageSize = 9999;
5095
+ let cursor;
5096
+ for (; ; ) {
5097
+ const pageCoins = await this.provider.getCoins(this.address, assetId, {
5098
+ first: pageSize,
5099
+ after: cursor
5100
+ });
5101
+ coins.push(...pageCoins);
5102
+ const hasNextPage = pageCoins.length >= pageSize;
5103
+ if (!hasNextPage) {
5104
+ break;
5105
+ }
5106
+ throw new FuelError15(
5107
+ ErrorCode15.NOT_SUPPORTED,
5108
+ `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
5109
+ );
5110
+ }
5111
+ return coins;
5135
5112
  }
5136
5113
  /**
5137
5114
  * Retrieves messages owned by the account.
5138
5115
  *
5139
5116
  * @returns A promise that resolves to an array of Messages.
5140
5117
  */
5141
- async getMessages(paginationArgs) {
5142
- return this.provider.getMessages(this.address, paginationArgs);
5118
+ async getMessages() {
5119
+ const messages = [];
5120
+ const pageSize = 9999;
5121
+ let cursor;
5122
+ for (; ; ) {
5123
+ const pageMessages = await this.provider.getMessages(this.address, {
5124
+ first: pageSize,
5125
+ after: cursor
5126
+ });
5127
+ messages.push(...pageMessages);
5128
+ const hasNextPage = pageMessages.length >= pageSize;
5129
+ if (!hasNextPage) {
5130
+ break;
5131
+ }
5132
+ throw new FuelError15(
5133
+ ErrorCode15.NOT_SUPPORTED,
5134
+ `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
5135
+ );
5136
+ }
5137
+ return messages;
5143
5138
  }
5144
5139
  /**
5145
5140
  * Retrieves the balance of the account for the given asset.
@@ -5158,7 +5153,25 @@ var Account = class extends AbstractAccount {
5158
5153
  * @returns A promise that resolves to an array of Coins and their quantities.
5159
5154
  */
5160
5155
  async getBalances() {
5161
- return this.provider.getBalances(this.address);
5156
+ const balances = [];
5157
+ const pageSize = 9999;
5158
+ let cursor;
5159
+ for (; ; ) {
5160
+ const pageBalances = await this.provider.getBalances(this.address, {
5161
+ first: pageSize,
5162
+ after: cursor
5163
+ });
5164
+ balances.push(...pageBalances);
5165
+ const hasNextPage = pageBalances.length >= pageSize;
5166
+ if (!hasNextPage) {
5167
+ break;
5168
+ }
5169
+ throw new FuelError15(
5170
+ ErrorCode15.NOT_SUPPORTED,
5171
+ `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
5172
+ );
5173
+ }
5174
+ return balances;
5162
5175
  }
5163
5176
  /**
5164
5177
  * Funds a transaction request by adding the necessary resources.