@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 +4 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +82 -95
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +82 -95
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +82 -95
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +20 -2
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/assets/utils/network.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +20 -5
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -2
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +106 -95
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +82 -95
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +82 -95
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.mjs
CHANGED
@@ -779,6 +779,9 @@ var GetCoinsDocument = gql`
|
|
779
779
|
first: $first
|
780
780
|
last: $last
|
781
781
|
) {
|
782
|
+
pageInfo {
|
783
|
+
...pageInfoFragment
|
784
|
+
}
|
782
785
|
edges {
|
783
786
|
node {
|
784
787
|
...coinFragment
|
@@ -786,7 +789,8 @@ var GetCoinsDocument = gql`
|
|
786
789
|
}
|
787
790
|
}
|
788
791
|
}
|
789
|
-
${
|
792
|
+
${PageInfoFragmentDoc}
|
793
|
+
${CoinFragmentDoc}`;
|
790
794
|
var GetCoinsToSpendDocument = gql`
|
791
795
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
792
796
|
coinsToSpend(
|
@@ -845,6 +849,9 @@ var GetBalancesDocument = gql`
|
|
845
849
|
first: $first
|
846
850
|
last: $last
|
847
851
|
) {
|
852
|
+
pageInfo {
|
853
|
+
...pageInfoFragment
|
854
|
+
}
|
848
855
|
edges {
|
849
856
|
node {
|
850
857
|
...balanceFragment
|
@@ -852,7 +859,8 @@ var GetBalancesDocument = gql`
|
|
852
859
|
}
|
853
860
|
}
|
854
861
|
}
|
855
|
-
${
|
862
|
+
${PageInfoFragmentDoc}
|
863
|
+
${BalanceFragmentDoc}`;
|
856
864
|
var GetMessagesDocument = gql`
|
857
865
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
858
866
|
messages(
|
@@ -862,6 +870,9 @@ var GetMessagesDocument = gql`
|
|
862
870
|
first: $first
|
863
871
|
last: $last
|
864
872
|
) {
|
873
|
+
pageInfo {
|
874
|
+
...pageInfoFragment
|
875
|
+
}
|
865
876
|
edges {
|
866
877
|
node {
|
867
878
|
...messageFragment
|
@@ -869,7 +880,8 @@ var GetMessagesDocument = gql`
|
|
869
880
|
}
|
870
881
|
}
|
871
882
|
}
|
872
|
-
${
|
883
|
+
${PageInfoFragmentDoc}
|
884
|
+
${MessageFragmentDoc}`;
|
873
885
|
var GetMessageProofDocument = gql`
|
874
886
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
875
887
|
messageProof(
|
@@ -4563,21 +4575,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4563
4575
|
* @returns A promise that resolves to the coins.
|
4564
4576
|
*/
|
4565
4577
|
async getCoins(owner, assetId, paginationArgs) {
|
4578
|
+
this.validatePaginationArgs(paginationArgs);
|
4566
4579
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4567
|
-
const
|
4568
|
-
|
4580
|
+
const {
|
4581
|
+
coins: { edges, pageInfo }
|
4582
|
+
} = await this.operations.getCoins({
|
4583
|
+
first: 100,
|
4569
4584
|
...paginationArgs,
|
4570
4585
|
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify12(assetId) }
|
4571
4586
|
});
|
4572
|
-
const coins =
|
4573
|
-
|
4574
|
-
|
4575
|
-
|
4576
|
-
|
4577
|
-
|
4578
|
-
|
4579
|
-
txCreatedIdx: bn17(coin.txCreatedIdx)
|
4587
|
+
const coins = edges.map(({ node }) => ({
|
4588
|
+
id: node.utxoId,
|
4589
|
+
assetId: node.assetId,
|
4590
|
+
amount: bn17(node.amount),
|
4591
|
+
owner: Address2.fromAddressOrString(node.owner),
|
4592
|
+
blockCreated: bn17(node.blockCreated),
|
4593
|
+
txCreatedIdx: bn17(node.txCreatedIdx)
|
4580
4594
|
}));
|
4595
|
+
return {
|
4596
|
+
coins,
|
4597
|
+
pageInfo
|
4598
|
+
};
|
4581
4599
|
}
|
4582
4600
|
/**
|
4583
4601
|
* Returns resources for the given owner satisfying the spend query.
|
@@ -4787,17 +4805,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4787
4805
|
* @param paginationArgs - Pagination arguments (optional).
|
4788
4806
|
* @returns A promise that resolves to the balances.
|
4789
4807
|
*/
|
4790
|
-
async getBalances(owner
|
4791
|
-
const
|
4792
|
-
|
4793
|
-
|
4808
|
+
async getBalances(owner) {
|
4809
|
+
const {
|
4810
|
+
balances: { edges }
|
4811
|
+
} = await this.operations.getBalances({
|
4812
|
+
/**
|
4813
|
+
* The query parameters for this method were designed to support pagination,
|
4814
|
+
* but the current Fuel-Core implementation does not support pagination yet.
|
4815
|
+
*/
|
4816
|
+
first: 1e4,
|
4794
4817
|
filter: { owner: Address2.fromAddressOrString(owner).toB256() }
|
4795
4818
|
});
|
4796
|
-
const balances =
|
4797
|
-
|
4798
|
-
|
4799
|
-
amount: bn17(balance.amount)
|
4819
|
+
const balances = edges.map(({ node }) => ({
|
4820
|
+
assetId: node.assetId,
|
4821
|
+
amount: bn17(node.amount)
|
4800
4822
|
}));
|
4823
|
+
return { balances };
|
4801
4824
|
}
|
4802
4825
|
/**
|
4803
4826
|
* Returns message for the given address.
|
@@ -4807,27 +4830,33 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4807
4830
|
* @returns A promise that resolves to the messages.
|
4808
4831
|
*/
|
4809
4832
|
async getMessages(address, paginationArgs) {
|
4810
|
-
|
4811
|
-
|
4833
|
+
this.validatePaginationArgs(paginationArgs);
|
4834
|
+
const {
|
4835
|
+
messages: { edges, pageInfo }
|
4836
|
+
} = await this.operations.getMessages({
|
4837
|
+
first: 100,
|
4812
4838
|
...paginationArgs,
|
4813
4839
|
owner: Address2.fromAddressOrString(address).toB256()
|
4814
4840
|
});
|
4815
|
-
const messages =
|
4816
|
-
return messages.map((message) => ({
|
4841
|
+
const messages = edges.map(({ node }) => ({
|
4817
4842
|
messageId: InputMessageCoder.getMessageId({
|
4818
|
-
sender:
|
4819
|
-
recipient:
|
4820
|
-
nonce:
|
4821
|
-
amount: bn17(
|
4822
|
-
data:
|
4843
|
+
sender: node.sender,
|
4844
|
+
recipient: node.recipient,
|
4845
|
+
nonce: node.nonce,
|
4846
|
+
amount: bn17(node.amount),
|
4847
|
+
data: node.data
|
4823
4848
|
}),
|
4824
|
-
sender: Address2.fromAddressOrString(
|
4825
|
-
recipient: Address2.fromAddressOrString(
|
4826
|
-
nonce:
|
4827
|
-
amount: bn17(
|
4828
|
-
data: InputMessageCoder.decodeData(
|
4829
|
-
daHeight: bn17(
|
4849
|
+
sender: Address2.fromAddressOrString(node.sender),
|
4850
|
+
recipient: Address2.fromAddressOrString(node.recipient),
|
4851
|
+
nonce: node.nonce,
|
4852
|
+
amount: bn17(node.amount),
|
4853
|
+
data: InputMessageCoder.decodeData(node.data),
|
4854
|
+
daHeight: bn17(node.daHeight)
|
4830
4855
|
}));
|
4856
|
+
return {
|
4857
|
+
messages,
|
4858
|
+
pageInfo
|
4859
|
+
};
|
4831
4860
|
}
|
4832
4861
|
/**
|
4833
4862
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5006,6 +5035,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5006
5035
|
}
|
5007
5036
|
return relayedTransactionStatus;
|
5008
5037
|
}
|
5038
|
+
/**
|
5039
|
+
* @hidden
|
5040
|
+
*/
|
5041
|
+
validatePaginationArgs({ first, last } = {}) {
|
5042
|
+
const MAX_PAGINATION_LIMIT = 1e3;
|
5043
|
+
if ((first || 0) > MAX_PAGINATION_LIMIT || (last || 0) > MAX_PAGINATION_LIMIT) {
|
5044
|
+
throw new FuelError13(
|
5045
|
+
ErrorCode13.INVALID_INPUT_PARAMETERS,
|
5046
|
+
"Pagination limit cannot exceed 1000 items"
|
5047
|
+
);
|
5048
|
+
}
|
5049
|
+
}
|
5009
5050
|
/**
|
5010
5051
|
* @hidden
|
5011
5052
|
*/
|
@@ -5406,52 +5447,16 @@ var Account = class extends AbstractAccount {
|
|
5406
5447
|
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5407
5448
|
* @returns A promise that resolves to an array of Coins.
|
5408
5449
|
*/
|
5409
|
-
async getCoins(assetId) {
|
5410
|
-
|
5411
|
-
const pageSize = 9999;
|
5412
|
-
let cursor;
|
5413
|
-
for (; ; ) {
|
5414
|
-
const pageCoins = await this.provider.getCoins(this.address, assetId, {
|
5415
|
-
first: pageSize,
|
5416
|
-
after: cursor
|
5417
|
-
});
|
5418
|
-
coins.push(...pageCoins);
|
5419
|
-
const hasNextPage = pageCoins.length >= pageSize;
|
5420
|
-
if (!hasNextPage) {
|
5421
|
-
break;
|
5422
|
-
}
|
5423
|
-
throw new FuelError15(
|
5424
|
-
ErrorCode15.NOT_SUPPORTED,
|
5425
|
-
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
5426
|
-
);
|
5427
|
-
}
|
5428
|
-
return coins;
|
5450
|
+
async getCoins(assetId, paginationArgs) {
|
5451
|
+
return this.provider.getCoins(this.address, assetId, paginationArgs);
|
5429
5452
|
}
|
5430
5453
|
/**
|
5431
5454
|
* Retrieves messages owned by the account.
|
5432
5455
|
*
|
5433
5456
|
* @returns A promise that resolves to an array of Messages.
|
5434
5457
|
*/
|
5435
|
-
async getMessages() {
|
5436
|
-
|
5437
|
-
const pageSize = 9999;
|
5438
|
-
let cursor;
|
5439
|
-
for (; ; ) {
|
5440
|
-
const pageMessages = await this.provider.getMessages(this.address, {
|
5441
|
-
first: pageSize,
|
5442
|
-
after: cursor
|
5443
|
-
});
|
5444
|
-
messages.push(...pageMessages);
|
5445
|
-
const hasNextPage = pageMessages.length >= pageSize;
|
5446
|
-
if (!hasNextPage) {
|
5447
|
-
break;
|
5448
|
-
}
|
5449
|
-
throw new FuelError15(
|
5450
|
-
ErrorCode15.NOT_SUPPORTED,
|
5451
|
-
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
5452
|
-
);
|
5453
|
-
}
|
5454
|
-
return messages;
|
5458
|
+
async getMessages(paginationArgs) {
|
5459
|
+
return this.provider.getMessages(this.address, paginationArgs);
|
5455
5460
|
}
|
5456
5461
|
/**
|
5457
5462
|
* Retrieves the balance of the account for the given asset.
|
@@ -5470,25 +5475,7 @@ var Account = class extends AbstractAccount {
|
|
5470
5475
|
* @returns A promise that resolves to an array of Coins and their quantities.
|
5471
5476
|
*/
|
5472
5477
|
async getBalances() {
|
5473
|
-
|
5474
|
-
const pageSize = 9999;
|
5475
|
-
let cursor;
|
5476
|
-
for (; ; ) {
|
5477
|
-
const pageBalances = await this.provider.getBalances(this.address, {
|
5478
|
-
first: pageSize,
|
5479
|
-
after: cursor
|
5480
|
-
});
|
5481
|
-
balances.push(...pageBalances);
|
5482
|
-
const hasNextPage = pageBalances.length >= pageSize;
|
5483
|
-
if (!hasNextPage) {
|
5484
|
-
break;
|
5485
|
-
}
|
5486
|
-
throw new FuelError15(
|
5487
|
-
ErrorCode15.NOT_SUPPORTED,
|
5488
|
-
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
5489
|
-
);
|
5490
|
-
}
|
5491
|
-
return balances;
|
5478
|
+
return this.provider.getBalances(this.address);
|
5492
5479
|
}
|
5493
5480
|
/**
|
5494
5481
|
* Funds a transaction request by adding the necessary resources.
|