@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.js
CHANGED
@@ -940,6 +940,9 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
940
940
|
first: $first
|
941
941
|
last: $last
|
942
942
|
) {
|
943
|
+
pageInfo {
|
944
|
+
...pageInfoFragment
|
945
|
+
}
|
943
946
|
edges {
|
944
947
|
node {
|
945
948
|
...coinFragment
|
@@ -947,7 +950,8 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
947
950
|
}
|
948
951
|
}
|
949
952
|
}
|
950
|
-
${
|
953
|
+
${PageInfoFragmentDoc}
|
954
|
+
${CoinFragmentDoc}`;
|
951
955
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
952
956
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
953
957
|
coinsToSpend(
|
@@ -1006,6 +1010,9 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1006
1010
|
first: $first
|
1007
1011
|
last: $last
|
1008
1012
|
) {
|
1013
|
+
pageInfo {
|
1014
|
+
...pageInfoFragment
|
1015
|
+
}
|
1009
1016
|
edges {
|
1010
1017
|
node {
|
1011
1018
|
...balanceFragment
|
@@ -1013,7 +1020,8 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1013
1020
|
}
|
1014
1021
|
}
|
1015
1022
|
}
|
1016
|
-
${
|
1023
|
+
${PageInfoFragmentDoc}
|
1024
|
+
${BalanceFragmentDoc}`;
|
1017
1025
|
var GetMessagesDocument = import_graphql_tag.default`
|
1018
1026
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1019
1027
|
messages(
|
@@ -1023,6 +1031,9 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1023
1031
|
first: $first
|
1024
1032
|
last: $last
|
1025
1033
|
) {
|
1034
|
+
pageInfo {
|
1035
|
+
...pageInfoFragment
|
1036
|
+
}
|
1026
1037
|
edges {
|
1027
1038
|
node {
|
1028
1039
|
...messageFragment
|
@@ -1030,7 +1041,8 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1030
1041
|
}
|
1031
1042
|
}
|
1032
1043
|
}
|
1033
|
-
${
|
1044
|
+
${PageInfoFragmentDoc}
|
1045
|
+
${MessageFragmentDoc}`;
|
1034
1046
|
var GetMessageProofDocument = import_graphql_tag.default`
|
1035
1047
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1036
1048
|
messageProof(
|
@@ -4705,21 +4717,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4705
4717
|
* @returns A promise that resolves to the coins.
|
4706
4718
|
*/
|
4707
4719
|
async getCoins(owner, assetId, paginationArgs) {
|
4720
|
+
this.validatePaginationArgs(paginationArgs);
|
4708
4721
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4709
|
-
const
|
4710
|
-
|
4722
|
+
const {
|
4723
|
+
coins: { edges, pageInfo }
|
4724
|
+
} = await this.operations.getCoins({
|
4725
|
+
first: 100,
|
4711
4726
|
...paginationArgs,
|
4712
4727
|
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4713
4728
|
});
|
4714
|
-
const coins =
|
4715
|
-
|
4716
|
-
|
4717
|
-
|
4718
|
-
|
4719
|
-
|
4720
|
-
|
4721
|
-
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4729
|
+
const coins = edges.map(({ node }) => ({
|
4730
|
+
id: node.utxoId,
|
4731
|
+
assetId: node.assetId,
|
4732
|
+
amount: (0, import_math17.bn)(node.amount),
|
4733
|
+
owner: import_address3.Address.fromAddressOrString(node.owner),
|
4734
|
+
blockCreated: (0, import_math17.bn)(node.blockCreated),
|
4735
|
+
txCreatedIdx: (0, import_math17.bn)(node.txCreatedIdx)
|
4722
4736
|
}));
|
4737
|
+
return {
|
4738
|
+
coins,
|
4739
|
+
pageInfo
|
4740
|
+
};
|
4723
4741
|
}
|
4724
4742
|
/**
|
4725
4743
|
* Returns resources for the given owner satisfying the spend query.
|
@@ -4929,17 +4947,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4929
4947
|
* @param paginationArgs - Pagination arguments (optional).
|
4930
4948
|
* @returns A promise that resolves to the balances.
|
4931
4949
|
*/
|
4932
|
-
async getBalances(owner
|
4933
|
-
const
|
4934
|
-
|
4935
|
-
|
4950
|
+
async getBalances(owner) {
|
4951
|
+
const {
|
4952
|
+
balances: { edges }
|
4953
|
+
} = await this.operations.getBalances({
|
4954
|
+
/**
|
4955
|
+
* The query parameters for this method were designed to support pagination,
|
4956
|
+
* but the current Fuel-Core implementation does not support pagination yet.
|
4957
|
+
*/
|
4958
|
+
first: 1e4,
|
4936
4959
|
filter: { owner: import_address3.Address.fromAddressOrString(owner).toB256() }
|
4937
4960
|
});
|
4938
|
-
const balances =
|
4939
|
-
|
4940
|
-
|
4941
|
-
amount: (0, import_math17.bn)(balance.amount)
|
4961
|
+
const balances = edges.map(({ node }) => ({
|
4962
|
+
assetId: node.assetId,
|
4963
|
+
amount: (0, import_math17.bn)(node.amount)
|
4942
4964
|
}));
|
4965
|
+
return { balances };
|
4943
4966
|
}
|
4944
4967
|
/**
|
4945
4968
|
* Returns message for the given address.
|
@@ -4949,27 +4972,33 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4949
4972
|
* @returns A promise that resolves to the messages.
|
4950
4973
|
*/
|
4951
4974
|
async getMessages(address, paginationArgs) {
|
4952
|
-
|
4953
|
-
|
4975
|
+
this.validatePaginationArgs(paginationArgs);
|
4976
|
+
const {
|
4977
|
+
messages: { edges, pageInfo }
|
4978
|
+
} = await this.operations.getMessages({
|
4979
|
+
first: 100,
|
4954
4980
|
...paginationArgs,
|
4955
4981
|
owner: import_address3.Address.fromAddressOrString(address).toB256()
|
4956
4982
|
});
|
4957
|
-
const messages =
|
4958
|
-
return messages.map((message) => ({
|
4983
|
+
const messages = edges.map(({ node }) => ({
|
4959
4984
|
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4960
|
-
sender:
|
4961
|
-
recipient:
|
4962
|
-
nonce:
|
4963
|
-
amount: (0, import_math17.bn)(
|
4964
|
-
data:
|
4985
|
+
sender: node.sender,
|
4986
|
+
recipient: node.recipient,
|
4987
|
+
nonce: node.nonce,
|
4988
|
+
amount: (0, import_math17.bn)(node.amount),
|
4989
|
+
data: node.data
|
4965
4990
|
}),
|
4966
|
-
sender: import_address3.Address.fromAddressOrString(
|
4967
|
-
recipient: import_address3.Address.fromAddressOrString(
|
4968
|
-
nonce:
|
4969
|
-
amount: (0, import_math17.bn)(
|
4970
|
-
data: import_transactions20.InputMessageCoder.decodeData(
|
4971
|
-
daHeight: (0, import_math17.bn)(
|
4991
|
+
sender: import_address3.Address.fromAddressOrString(node.sender),
|
4992
|
+
recipient: import_address3.Address.fromAddressOrString(node.recipient),
|
4993
|
+
nonce: node.nonce,
|
4994
|
+
amount: (0, import_math17.bn)(node.amount),
|
4995
|
+
data: import_transactions20.InputMessageCoder.decodeData(node.data),
|
4996
|
+
daHeight: (0, import_math17.bn)(node.daHeight)
|
4972
4997
|
}));
|
4998
|
+
return {
|
4999
|
+
messages,
|
5000
|
+
pageInfo
|
5001
|
+
};
|
4973
5002
|
}
|
4974
5003
|
/**
|
4975
5004
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5148,6 +5177,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5148
5177
|
}
|
5149
5178
|
return relayedTransactionStatus;
|
5150
5179
|
}
|
5180
|
+
/**
|
5181
|
+
* @hidden
|
5182
|
+
*/
|
5183
|
+
validatePaginationArgs({ first, last } = {}) {
|
5184
|
+
const MAX_PAGINATION_LIMIT = 1e3;
|
5185
|
+
if ((first || 0) > MAX_PAGINATION_LIMIT || (last || 0) > MAX_PAGINATION_LIMIT) {
|
5186
|
+
throw new import_errors14.FuelError(
|
5187
|
+
import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
|
5188
|
+
"Pagination limit cannot exceed 1000 items"
|
5189
|
+
);
|
5190
|
+
}
|
5191
|
+
}
|
5151
5192
|
/**
|
5152
5193
|
* @hidden
|
5153
5194
|
*/
|
@@ -5548,52 +5589,16 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5548
5589
|
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5549
5590
|
* @returns A promise that resolves to an array of Coins.
|
5550
5591
|
*/
|
5551
|
-
async getCoins(assetId) {
|
5552
|
-
|
5553
|
-
const pageSize = 9999;
|
5554
|
-
let cursor;
|
5555
|
-
for (; ; ) {
|
5556
|
-
const pageCoins = await this.provider.getCoins(this.address, assetId, {
|
5557
|
-
first: pageSize,
|
5558
|
-
after: cursor
|
5559
|
-
});
|
5560
|
-
coins.push(...pageCoins);
|
5561
|
-
const hasNextPage = pageCoins.length >= pageSize;
|
5562
|
-
if (!hasNextPage) {
|
5563
|
-
break;
|
5564
|
-
}
|
5565
|
-
throw new import_errors16.FuelError(
|
5566
|
-
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5567
|
-
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
5568
|
-
);
|
5569
|
-
}
|
5570
|
-
return coins;
|
5592
|
+
async getCoins(assetId, paginationArgs) {
|
5593
|
+
return this.provider.getCoins(this.address, assetId, paginationArgs);
|
5571
5594
|
}
|
5572
5595
|
/**
|
5573
5596
|
* Retrieves messages owned by the account.
|
5574
5597
|
*
|
5575
5598
|
* @returns A promise that resolves to an array of Messages.
|
5576
5599
|
*/
|
5577
|
-
async getMessages() {
|
5578
|
-
|
5579
|
-
const pageSize = 9999;
|
5580
|
-
let cursor;
|
5581
|
-
for (; ; ) {
|
5582
|
-
const pageMessages = await this.provider.getMessages(this.address, {
|
5583
|
-
first: pageSize,
|
5584
|
-
after: cursor
|
5585
|
-
});
|
5586
|
-
messages.push(...pageMessages);
|
5587
|
-
const hasNextPage = pageMessages.length >= pageSize;
|
5588
|
-
if (!hasNextPage) {
|
5589
|
-
break;
|
5590
|
-
}
|
5591
|
-
throw new import_errors16.FuelError(
|
5592
|
-
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5593
|
-
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
5594
|
-
);
|
5595
|
-
}
|
5596
|
-
return messages;
|
5600
|
+
async getMessages(paginationArgs) {
|
5601
|
+
return this.provider.getMessages(this.address, paginationArgs);
|
5597
5602
|
}
|
5598
5603
|
/**
|
5599
5604
|
* Retrieves the balance of the account for the given asset.
|
@@ -5612,25 +5617,7 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5612
5617
|
* @returns A promise that resolves to an array of Coins and their quantities.
|
5613
5618
|
*/
|
5614
5619
|
async getBalances() {
|
5615
|
-
|
5616
|
-
const pageSize = 9999;
|
5617
|
-
let cursor;
|
5618
|
-
for (; ; ) {
|
5619
|
-
const pageBalances = await this.provider.getBalances(this.address, {
|
5620
|
-
first: pageSize,
|
5621
|
-
after: cursor
|
5622
|
-
});
|
5623
|
-
balances.push(...pageBalances);
|
5624
|
-
const hasNextPage = pageBalances.length >= pageSize;
|
5625
|
-
if (!hasNextPage) {
|
5626
|
-
break;
|
5627
|
-
}
|
5628
|
-
throw new import_errors16.FuelError(
|
5629
|
-
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5630
|
-
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
5631
|
-
);
|
5632
|
-
}
|
5633
|
-
return balances;
|
5620
|
+
return this.provider.getBalances(this.address);
|
5634
5621
|
}
|
5635
5622
|
/**
|
5636
5623
|
* Funds a transaction request by adding the necessary resources.
|