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

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.

package/dist/account.d.ts CHANGED
@@ -2,7 +2,7 @@ import { AbstractAccount } from '@fuel-ts/interfaces';
2
2
  import type { AbstractAddress, BytesLike } from '@fuel-ts/interfaces';
3
3
  import type { BigNumberish, BN } from '@fuel-ts/math';
4
4
  import type { FuelConnector } from './connectors';
5
- import type { TransactionRequestLike, CallResult, TransactionRequest, Coin, CoinQuantityLike, CoinQuantity, Message, Resource, ExcludeResourcesOption, Provider, ScriptTransactionRequestLike, ProviderSendTxParams, TransactionResponse, EstimateTransactionParams, TransactionCost } from './providers';
5
+ import type { TransactionRequest, CoinQuantityLike, Resource, ExcludeResourcesOption, Provider, ScriptTransactionRequestLike, TransactionResponse, TransactionCost, EstimateTransactionParams, CursorPaginationArgs, TransactionRequestLike, ProviderSendTxParams, CallResult, GetCoinsResponse, GetMessagesResponse, GetBalancesResponse, Coin } from './providers';
6
6
  import { ScriptTransactionRequest } from './providers';
7
7
  export type TxParamsType = Pick<ScriptTransactionRequestLike, 'gasLimit' | 'tip' | 'maturity' | 'maxFee' | 'witnessLimit'>;
8
8
  export type TransferParams = {
@@ -71,13 +71,13 @@ export declare class Account extends AbstractAccount {
71
71
  * @param assetId - The asset ID of the coins to retrieve (optional).
72
72
  * @returns A promise that resolves to an array of Coins.
73
73
  */
74
- getCoins(assetId?: BytesLike): Promise<Coin[]>;
74
+ getCoins(assetId?: BytesLike, paginationArgs?: CursorPaginationArgs): Promise<GetCoinsResponse>;
75
75
  /**
76
76
  * Retrieves messages owned by the account.
77
77
  *
78
78
  * @returns A promise that resolves to an array of Messages.
79
79
  */
80
- getMessages(): Promise<Message[]>;
80
+ getMessages(paginationArgs?: CursorPaginationArgs): Promise<GetMessagesResponse>;
81
81
  /**
82
82
  * Retrieves the balance of the account for the given asset.
83
83
  *
@@ -90,7 +90,7 @@ export declare class Account extends AbstractAccount {
90
90
  *
91
91
  * @returns A promise that resolves to an array of Coins and their quantities.
92
92
  */
93
- getBalances(): Promise<CoinQuantity[]>;
93
+ getBalances(): Promise<GetBalancesResponse>;
94
94
  /**
95
95
  * Funds a transaction request by adding the necessary resources.
96
96
  *
@@ -1 +1 @@
1
- {"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../src/account.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,YAAY,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAKtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EACV,sBAAsB,EACtB,UAAU,EACV,kBAAkB,EAClB,IAAI,EACJ,gBAAgB,EAChB,YAAY,EACZ,OAAO,EACP,QAAQ,EACR,sBAAsB,EACtB,QAAQ,EACR,4BAA4B,EAC5B,oBAAoB,EACpB,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EAChB,MAAM,aAAa,CAAC;AACrB,OAAO,EAEL,wBAAwB,EAGzB,MAAM,aAAa,CAAC;AASrB,MAAM,MAAM,YAAY,GAAG,IAAI,CAC7B,4BAA4B,EAC5B,UAAU,GAAG,KAAK,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CAC5D,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG;IAC3B,WAAW,EAAE,MAAM,GAAG,eAAe,CAAC;IACtC,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAClC,eAAe,EACf,qBAAqB,GAAG,iBAAiB,GAAG,oBAAoB,GA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,CACvB,SAAS,EAAE,MAAM,GAAG,eAAe,EACnC,MAAM,EAAE,YAAY,EACpB,QAAQ,GAAE,YAAiB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAmC/B;;;;;;;OAOG;IACG,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAOnD;;;;;OAKG;IACG,eAAe,CAAC,sBAAsB,EAAE,sBAAsB,GAAG,OAAO,CAAC,MAAM,CAAC;IAUtF;;;;;;OAMG;IACG,eAAe,CACnB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,cAAc,EAAE,GAAE,oBAAyB,GAC3E,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;;;;;OAMG;IACG,mBAAmB,CACvB,sBAAsB,EAAE,sBAAsB,EAC9C,EAAE,sBAA6B,EAAE,GAAE,yBAA8B,GAChE,OAAO,CAAC,UAAU,CAAC;IAQtB;;;;;OAKG;IACH,qBAAqB,CAAC,KAAK,EAAE,aAAa,EAAE,GAAG,KAAK,CAAC,QAAQ,CAAC;IAU9D,gBAAgB;IAChB,OAAO,CAAC,sBAAsB;IAS9B,gBAAgB;YACF,0BAA0B;IAkBxC,gBAAgB;IAChB,OAAO,CAAC,yBAAyB;CAiClC"}
@@ -37366,6 +37366,9 @@ ${TransactionFragmentDoc}`;
37366
37366
  first: $first
37367
37367
  last: $last
37368
37368
  ) {
37369
+ pageInfo {
37370
+ ...pageInfoFragment
37371
+ }
37369
37372
  edges {
37370
37373
  node {
37371
37374
  ...coinFragment
@@ -37373,7 +37376,8 @@ ${TransactionFragmentDoc}`;
37373
37376
  }
37374
37377
  }
37375
37378
  }
37376
- ${CoinFragmentDoc}`;
37379
+ ${PageInfoFragmentDoc}
37380
+ ${CoinFragmentDoc}`;
37377
37381
  var GetCoinsToSpendDocument = lib_default2`
37378
37382
  query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
37379
37383
  coinsToSpend(
@@ -37432,6 +37436,9 @@ ${MessageCoinFragmentDoc}`;
37432
37436
  first: $first
37433
37437
  last: $last
37434
37438
  ) {
37439
+ pageInfo {
37440
+ ...pageInfoFragment
37441
+ }
37435
37442
  edges {
37436
37443
  node {
37437
37444
  ...balanceFragment
@@ -37439,7 +37446,8 @@ ${MessageCoinFragmentDoc}`;
37439
37446
  }
37440
37447
  }
37441
37448
  }
37442
- ${BalanceFragmentDoc}`;
37449
+ ${PageInfoFragmentDoc}
37450
+ ${BalanceFragmentDoc}`;
37443
37451
  var GetMessagesDocument = lib_default2`
37444
37452
  query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
37445
37453
  messages(
@@ -37449,6 +37457,9 @@ ${MessageCoinFragmentDoc}`;
37449
37457
  first: $first
37450
37458
  last: $last
37451
37459
  ) {
37460
+ pageInfo {
37461
+ ...pageInfoFragment
37462
+ }
37452
37463
  edges {
37453
37464
  node {
37454
37465
  ...messageFragment
@@ -37456,7 +37467,8 @@ ${MessageCoinFragmentDoc}`;
37456
37467
  }
37457
37468
  }
37458
37469
  }
37459
- ${MessageFragmentDoc}`;
37470
+ ${PageInfoFragmentDoc}
37471
+ ${MessageFragmentDoc}`;
37460
37472
  var GetMessageProofDocument = lib_default2`
37461
37473
  query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
37462
37474
  messageProof(
@@ -41098,21 +41110,27 @@ Supported fuel-core version: ${supportedVersion}.`
41098
41110
  * @returns A promise that resolves to the coins.
41099
41111
  */
41100
41112
  async getCoins(owner, assetId, paginationArgs) {
41113
+ this.validatePaginationArgs(paginationArgs);
41101
41114
  const ownerAddress = Address.fromAddressOrString(owner);
41102
- const result = await this.operations.getCoins({
41103
- first: 10,
41115
+ const {
41116
+ coins: { edges, pageInfo }
41117
+ } = await this.operations.getCoins({
41118
+ first: 100,
41104
41119
  ...paginationArgs,
41105
41120
  filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify(assetId) }
41106
41121
  });
41107
- const coins = result.coins.edges.map((edge) => edge.node);
41108
- return coins.map((coin) => ({
41109
- id: coin.utxoId,
41110
- assetId: coin.assetId,
41111
- amount: bn(coin.amount),
41112
- owner: Address.fromAddressOrString(coin.owner),
41113
- blockCreated: bn(coin.blockCreated),
41114
- txCreatedIdx: bn(coin.txCreatedIdx)
41122
+ const coins = edges.map(({ node }) => ({
41123
+ id: node.utxoId,
41124
+ assetId: node.assetId,
41125
+ amount: bn(node.amount),
41126
+ owner: Address.fromAddressOrString(node.owner),
41127
+ blockCreated: bn(node.blockCreated),
41128
+ txCreatedIdx: bn(node.txCreatedIdx)
41115
41129
  }));
41130
+ return {
41131
+ coins,
41132
+ pageInfo
41133
+ };
41116
41134
  }
41117
41135
  /**
41118
41136
  * Returns resources for the given owner satisfying the spend query.
@@ -41322,17 +41340,22 @@ Supported fuel-core version: ${supportedVersion}.`
41322
41340
  * @param paginationArgs - Pagination arguments (optional).
41323
41341
  * @returns A promise that resolves to the balances.
41324
41342
  */
41325
- async getBalances(owner, paginationArgs) {
41326
- const result = await this.operations.getBalances({
41327
- first: 10,
41328
- ...paginationArgs,
41343
+ async getBalances(owner) {
41344
+ const {
41345
+ balances: { edges }
41346
+ } = await this.operations.getBalances({
41347
+ /**
41348
+ * The query parameters for this method were designed to support pagination,
41349
+ * but the current Fuel-Core implementation does not support pagination yet.
41350
+ */
41351
+ first: 1e4,
41329
41352
  filter: { owner: Address.fromAddressOrString(owner).toB256() }
41330
41353
  });
41331
- const balances = result.balances.edges.map((edge) => edge.node);
41332
- return balances.map((balance) => ({
41333
- assetId: balance.assetId,
41334
- amount: bn(balance.amount)
41354
+ const balances = edges.map(({ node }) => ({
41355
+ assetId: node.assetId,
41356
+ amount: bn(node.amount)
41335
41357
  }));
41358
+ return { balances };
41336
41359
  }
41337
41360
  /**
41338
41361
  * Returns message for the given address.
@@ -41342,27 +41365,33 @@ Supported fuel-core version: ${supportedVersion}.`
41342
41365
  * @returns A promise that resolves to the messages.
41343
41366
  */
41344
41367
  async getMessages(address, paginationArgs) {
41345
- const result = await this.operations.getMessages({
41346
- first: 10,
41368
+ this.validatePaginationArgs(paginationArgs);
41369
+ const {
41370
+ messages: { edges, pageInfo }
41371
+ } = await this.operations.getMessages({
41372
+ first: 100,
41347
41373
  ...paginationArgs,
41348
41374
  owner: Address.fromAddressOrString(address).toB256()
41349
41375
  });
41350
- const messages = result.messages.edges.map((edge) => edge.node);
41351
- return messages.map((message) => ({
41376
+ const messages = edges.map(({ node }) => ({
41352
41377
  messageId: InputMessageCoder.getMessageId({
41353
- sender: message.sender,
41354
- recipient: message.recipient,
41355
- nonce: message.nonce,
41356
- amount: bn(message.amount),
41357
- data: message.data
41378
+ sender: node.sender,
41379
+ recipient: node.recipient,
41380
+ nonce: node.nonce,
41381
+ amount: bn(node.amount),
41382
+ data: node.data
41358
41383
  }),
41359
- sender: Address.fromAddressOrString(message.sender),
41360
- recipient: Address.fromAddressOrString(message.recipient),
41361
- nonce: message.nonce,
41362
- amount: bn(message.amount),
41363
- data: InputMessageCoder.decodeData(message.data),
41364
- daHeight: bn(message.daHeight)
41384
+ sender: Address.fromAddressOrString(node.sender),
41385
+ recipient: Address.fromAddressOrString(node.recipient),
41386
+ nonce: node.nonce,
41387
+ amount: bn(node.amount),
41388
+ data: InputMessageCoder.decodeData(node.data),
41389
+ daHeight: bn(node.daHeight)
41365
41390
  }));
41391
+ return {
41392
+ messages,
41393
+ pageInfo
41394
+ };
41366
41395
  }
41367
41396
  /**
41368
41397
  * Returns Message Proof for given transaction id and the message id from MessageOut receipt.
@@ -41541,6 +41570,18 @@ Supported fuel-core version: ${supportedVersion}.`
41541
41570
  }
41542
41571
  return relayedTransactionStatus;
41543
41572
  }
41573
+ /**
41574
+ * @hidden
41575
+ */
41576
+ validatePaginationArgs({ first, last } = {}) {
41577
+ const MAX_PAGINATION_LIMIT = 1e3;
41578
+ if ((first || 0) > MAX_PAGINATION_LIMIT || (last || 0) > MAX_PAGINATION_LIMIT) {
41579
+ throw new FuelError(
41580
+ ErrorCode.INVALID_INPUT_PARAMETERS,
41581
+ "Pagination limit cannot exceed 1000 items"
41582
+ );
41583
+ }
41584
+ }
41544
41585
  /**
41545
41586
  * @hidden
41546
41587
  */
@@ -41934,52 +41975,16 @@ Supported fuel-core version: ${supportedVersion}.`
41934
41975
  * @param assetId - The asset ID of the coins to retrieve (optional).
41935
41976
  * @returns A promise that resolves to an array of Coins.
41936
41977
  */
41937
- async getCoins(assetId) {
41938
- const coins = [];
41939
- const pageSize = 9999;
41940
- let cursor;
41941
- for (; ; ) {
41942
- const pageCoins = await this.provider.getCoins(this.address, assetId, {
41943
- first: pageSize,
41944
- after: cursor
41945
- });
41946
- coins.push(...pageCoins);
41947
- const hasNextPage = pageCoins.length >= pageSize;
41948
- if (!hasNextPage) {
41949
- break;
41950
- }
41951
- throw new FuelError(
41952
- ErrorCode.NOT_SUPPORTED,
41953
- `Wallets containing more than ${pageSize} coins exceed the current supported limit.`
41954
- );
41955
- }
41956
- return coins;
41978
+ async getCoins(assetId, paginationArgs) {
41979
+ return this.provider.getCoins(this.address, assetId, paginationArgs);
41957
41980
  }
41958
41981
  /**
41959
41982
  * Retrieves messages owned by the account.
41960
41983
  *
41961
41984
  * @returns A promise that resolves to an array of Messages.
41962
41985
  */
41963
- async getMessages() {
41964
- const messages = [];
41965
- const pageSize = 9999;
41966
- let cursor;
41967
- for (; ; ) {
41968
- const pageMessages = await this.provider.getMessages(this.address, {
41969
- first: pageSize,
41970
- after: cursor
41971
- });
41972
- messages.push(...pageMessages);
41973
- const hasNextPage = pageMessages.length >= pageSize;
41974
- if (!hasNextPage) {
41975
- break;
41976
- }
41977
- throw new FuelError(
41978
- ErrorCode.NOT_SUPPORTED,
41979
- `Wallets containing more than ${pageSize} messages exceed the current supported limit.`
41980
- );
41981
- }
41982
- return messages;
41986
+ async getMessages(paginationArgs) {
41987
+ return this.provider.getMessages(this.address, paginationArgs);
41983
41988
  }
41984
41989
  /**
41985
41990
  * Retrieves the balance of the account for the given asset.
@@ -41998,25 +42003,7 @@ Supported fuel-core version: ${supportedVersion}.`
41998
42003
  * @returns A promise that resolves to an array of Coins and their quantities.
41999
42004
  */
42000
42005
  async getBalances() {
42001
- const balances = [];
42002
- const pageSize = 9999;
42003
- let cursor;
42004
- for (; ; ) {
42005
- const pageBalances = await this.provider.getBalances(this.address, {
42006
- first: pageSize,
42007
- after: cursor
42008
- });
42009
- balances.push(...pageBalances);
42010
- const hasNextPage = pageBalances.length >= pageSize;
42011
- if (!hasNextPage) {
42012
- break;
42013
- }
42014
- throw new FuelError(
42015
- ErrorCode.NOT_SUPPORTED,
42016
- `Wallets containing more than ${pageSize} balances exceed the current supported limit.`
42017
- );
42018
- }
42019
- return balances;
42006
+ return this.provider.getBalances(this.address);
42020
42007
  }
42021
42008
  /**
42022
42009
  * Funds a transaction request by adding the necessary resources.