@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.
- package/dist/account.d.ts +4 -4
- package/dist/account.d.ts.map +1 -1
- package/dist/index.global.js +95 -82
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +95 -82
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +95 -82
- package/dist/index.mjs.map +1 -1
- package/dist/providers/__generated__/operations.d.ts +0 -18
- package/dist/providers/__generated__/operations.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +5 -20
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/test-utils.global.js +95 -106
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +95 -82
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +95 -82
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
@@ -940,9 +940,6 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
940
940
|
first: $first
|
941
941
|
last: $last
|
942
942
|
) {
|
943
|
-
pageInfo {
|
944
|
-
...pageInfoFragment
|
945
|
-
}
|
946
943
|
edges {
|
947
944
|
node {
|
948
945
|
...coinFragment
|
@@ -950,8 +947,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
950
947
|
}
|
951
948
|
}
|
952
949
|
}
|
953
|
-
${
|
954
|
-
${CoinFragmentDoc}`;
|
950
|
+
${CoinFragmentDoc}`;
|
955
951
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
956
952
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
957
953
|
coinsToSpend(
|
@@ -1010,9 +1006,6 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1010
1006
|
first: $first
|
1011
1007
|
last: $last
|
1012
1008
|
) {
|
1013
|
-
pageInfo {
|
1014
|
-
...pageInfoFragment
|
1015
|
-
}
|
1016
1009
|
edges {
|
1017
1010
|
node {
|
1018
1011
|
...balanceFragment
|
@@ -1020,8 +1013,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
1020
1013
|
}
|
1021
1014
|
}
|
1022
1015
|
}
|
1023
|
-
${
|
1024
|
-
${BalanceFragmentDoc}`;
|
1016
|
+
${BalanceFragmentDoc}`;
|
1025
1017
|
var GetMessagesDocument = import_graphql_tag.default`
|
1026
1018
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
1027
1019
|
messages(
|
@@ -1031,9 +1023,6 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1031
1023
|
first: $first
|
1032
1024
|
last: $last
|
1033
1025
|
) {
|
1034
|
-
pageInfo {
|
1035
|
-
...pageInfoFragment
|
1036
|
-
}
|
1037
1026
|
edges {
|
1038
1027
|
node {
|
1039
1028
|
...messageFragment
|
@@ -1041,8 +1030,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
1041
1030
|
}
|
1042
1031
|
}
|
1043
1032
|
}
|
1044
|
-
${
|
1045
|
-
${MessageFragmentDoc}`;
|
1033
|
+
${MessageFragmentDoc}`;
|
1046
1034
|
var GetMessageProofDocument = import_graphql_tag.default`
|
1047
1035
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
1048
1036
|
messageProof(
|
@@ -4717,27 +4705,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4717
4705
|
* @returns A promise that resolves to the coins.
|
4718
4706
|
*/
|
4719
4707
|
async getCoins(owner, assetId, paginationArgs) {
|
4720
|
-
this.validatePaginationArgs(paginationArgs);
|
4721
4708
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4722
|
-
const {
|
4723
|
-
|
4724
|
-
} = await this.operations.getCoins({
|
4725
|
-
first: 100,
|
4709
|
+
const result = await this.operations.getCoins({
|
4710
|
+
first: 10,
|
4726
4711
|
...paginationArgs,
|
4727
4712
|
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4728
4713
|
});
|
4729
|
-
const coins = edges.map((
|
4730
|
-
|
4731
|
-
|
4732
|
-
|
4733
|
-
|
4734
|
-
|
4735
|
-
|
4714
|
+
const coins = result.coins.edges.map((edge) => edge.node);
|
4715
|
+
return coins.map((coin) => ({
|
4716
|
+
id: coin.utxoId,
|
4717
|
+
assetId: coin.assetId,
|
4718
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4719
|
+
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4720
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4721
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4736
4722
|
}));
|
4737
|
-
return {
|
4738
|
-
coins,
|
4739
|
-
pageInfo
|
4740
|
-
};
|
4741
4723
|
}
|
4742
4724
|
/**
|
4743
4725
|
* Returns resources for the given owner satisfying the spend query.
|
@@ -4947,22 +4929,17 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4947
4929
|
* @param paginationArgs - Pagination arguments (optional).
|
4948
4930
|
* @returns A promise that resolves to the balances.
|
4949
4931
|
*/
|
4950
|
-
async getBalances(owner) {
|
4951
|
-
const {
|
4952
|
-
|
4953
|
-
|
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,
|
4932
|
+
async getBalances(owner, paginationArgs) {
|
4933
|
+
const result = await this.operations.getBalances({
|
4934
|
+
first: 10,
|
4935
|
+
...paginationArgs,
|
4959
4936
|
filter: { owner: import_address3.Address.fromAddressOrString(owner).toB256() }
|
4960
4937
|
});
|
4961
|
-
const balances = edges.map((
|
4962
|
-
|
4963
|
-
|
4938
|
+
const balances = result.balances.edges.map((edge) => edge.node);
|
4939
|
+
return balances.map((balance) => ({
|
4940
|
+
assetId: balance.assetId,
|
4941
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4964
4942
|
}));
|
4965
|
-
return { balances };
|
4966
4943
|
}
|
4967
4944
|
/**
|
4968
4945
|
* Returns message for the given address.
|
@@ -4972,33 +4949,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4972
4949
|
* @returns A promise that resolves to the messages.
|
4973
4950
|
*/
|
4974
4951
|
async getMessages(address, paginationArgs) {
|
4975
|
-
this.
|
4976
|
-
|
4977
|
-
messages: { edges, pageInfo }
|
4978
|
-
} = await this.operations.getMessages({
|
4979
|
-
first: 100,
|
4952
|
+
const result = await this.operations.getMessages({
|
4953
|
+
first: 10,
|
4980
4954
|
...paginationArgs,
|
4981
4955
|
owner: import_address3.Address.fromAddressOrString(address).toB256()
|
4982
4956
|
});
|
4983
|
-
const messages = edges.map((
|
4957
|
+
const messages = result.messages.edges.map((edge) => edge.node);
|
4958
|
+
return messages.map((message) => ({
|
4984
4959
|
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4985
|
-
sender:
|
4986
|
-
recipient:
|
4987
|
-
nonce:
|
4988
|
-
amount: (0, import_math17.bn)(
|
4989
|
-
data:
|
4960
|
+
sender: message.sender,
|
4961
|
+
recipient: message.recipient,
|
4962
|
+
nonce: message.nonce,
|
4963
|
+
amount: (0, import_math17.bn)(message.amount),
|
4964
|
+
data: message.data
|
4990
4965
|
}),
|
4991
|
-
sender: import_address3.Address.fromAddressOrString(
|
4992
|
-
recipient: import_address3.Address.fromAddressOrString(
|
4993
|
-
nonce:
|
4994
|
-
amount: (0, import_math17.bn)(
|
4995
|
-
data: import_transactions20.InputMessageCoder.decodeData(
|
4996
|
-
daHeight: (0, import_math17.bn)(
|
4966
|
+
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4967
|
+
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4968
|
+
nonce: message.nonce,
|
4969
|
+
amount: (0, import_math17.bn)(message.amount),
|
4970
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4971
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4997
4972
|
}));
|
4998
|
-
return {
|
4999
|
-
messages,
|
5000
|
-
pageInfo
|
5001
|
-
};
|
5002
4973
|
}
|
5003
4974
|
/**
|
5004
4975
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -5177,18 +5148,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
5177
5148
|
}
|
5178
5149
|
return relayedTransactionStatus;
|
5179
5150
|
}
|
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
|
-
}
|
5192
5151
|
/**
|
5193
5152
|
* @hidden
|
5194
5153
|
*/
|
@@ -5589,16 +5548,52 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5589
5548
|
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5590
5549
|
* @returns A promise that resolves to an array of Coins.
|
5591
5550
|
*/
|
5592
|
-
async getCoins(assetId
|
5593
|
-
|
5551
|
+
async getCoins(assetId) {
|
5552
|
+
const coins = [];
|
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;
|
5594
5571
|
}
|
5595
5572
|
/**
|
5596
5573
|
* Retrieves messages owned by the account.
|
5597
5574
|
*
|
5598
5575
|
* @returns A promise that resolves to an array of Messages.
|
5599
5576
|
*/
|
5600
|
-
async getMessages(
|
5601
|
-
|
5577
|
+
async getMessages() {
|
5578
|
+
const messages = [];
|
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;
|
5602
5597
|
}
|
5603
5598
|
/**
|
5604
5599
|
* Retrieves the balance of the account for the given asset.
|
@@ -5617,7 +5612,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5617
5612
|
* @returns A promise that resolves to an array of Coins and their quantities.
|
5618
5613
|
*/
|
5619
5614
|
async getBalances() {
|
5620
|
-
|
5615
|
+
const balances = [];
|
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;
|
5621
5634
|
}
|
5622
5635
|
/**
|
5623
5636
|
* Funds a transaction request by adding the necessary resources.
|