@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/test-utils.mjs
CHANGED
@@ -774,6 +774,9 @@ var GetCoinsDocument = gql`
|
|
774
774
|
first: $first
|
775
775
|
last: $last
|
776
776
|
) {
|
777
|
+
pageInfo {
|
778
|
+
...pageInfoFragment
|
779
|
+
}
|
777
780
|
edges {
|
778
781
|
node {
|
779
782
|
...coinFragment
|
@@ -781,7 +784,8 @@ var GetCoinsDocument = gql`
|
|
781
784
|
}
|
782
785
|
}
|
783
786
|
}
|
784
|
-
${
|
787
|
+
${PageInfoFragmentDoc}
|
788
|
+
${CoinFragmentDoc}`;
|
785
789
|
var GetCoinsToSpendDocument = gql`
|
786
790
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
787
791
|
coinsToSpend(
|
@@ -840,6 +844,9 @@ var GetBalancesDocument = gql`
|
|
840
844
|
first: $first
|
841
845
|
last: $last
|
842
846
|
) {
|
847
|
+
pageInfo {
|
848
|
+
...pageInfoFragment
|
849
|
+
}
|
843
850
|
edges {
|
844
851
|
node {
|
845
852
|
...balanceFragment
|
@@ -847,7 +854,8 @@ var GetBalancesDocument = gql`
|
|
847
854
|
}
|
848
855
|
}
|
849
856
|
}
|
850
|
-
${
|
857
|
+
${PageInfoFragmentDoc}
|
858
|
+
${BalanceFragmentDoc}`;
|
851
859
|
var GetMessagesDocument = gql`
|
852
860
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
853
861
|
messages(
|
@@ -857,6 +865,9 @@ var GetMessagesDocument = gql`
|
|
857
865
|
first: $first
|
858
866
|
last: $last
|
859
867
|
) {
|
868
|
+
pageInfo {
|
869
|
+
...pageInfoFragment
|
870
|
+
}
|
860
871
|
edges {
|
861
872
|
node {
|
862
873
|
...messageFragment
|
@@ -864,7 +875,8 @@ var GetMessagesDocument = gql`
|
|
864
875
|
}
|
865
876
|
}
|
866
877
|
}
|
867
|
-
${
|
878
|
+
${PageInfoFragmentDoc}
|
879
|
+
${MessageFragmentDoc}`;
|
868
880
|
var GetMessageProofDocument = gql`
|
869
881
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
870
882
|
messageProof(
|
@@ -4421,21 +4433,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4421
4433
|
* @returns A promise that resolves to the coins.
|
4422
4434
|
*/
|
4423
4435
|
async getCoins(owner, assetId, paginationArgs) {
|
4436
|
+
this.validatePaginationArgs(paginationArgs);
|
4424
4437
|
const ownerAddress = Address2.fromAddressOrString(owner);
|
4425
|
-
const
|
4426
|
-
|
4438
|
+
const {
|
4439
|
+
coins: { edges, pageInfo }
|
4440
|
+
} = await this.operations.getCoins({
|
4441
|
+
first: 100,
|
4427
4442
|
...paginationArgs,
|
4428
4443
|
filter: { owner: ownerAddress.toB256(), assetId: assetId && hexlify12(assetId) }
|
4429
4444
|
});
|
4430
|
-
const coins =
|
4431
|
-
|
4432
|
-
|
4433
|
-
|
4434
|
-
|
4435
|
-
|
4436
|
-
|
4437
|
-
txCreatedIdx: bn17(coin.txCreatedIdx)
|
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)
|
4438
4452
|
}));
|
4453
|
+
return {
|
4454
|
+
coins,
|
4455
|
+
pageInfo
|
4456
|
+
};
|
4439
4457
|
}
|
4440
4458
|
/**
|
4441
4459
|
* Returns resources for the given owner satisfying the spend query.
|
@@ -4645,17 +4663,22 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4645
4663
|
* @param paginationArgs - Pagination arguments (optional).
|
4646
4664
|
* @returns A promise that resolves to the balances.
|
4647
4665
|
*/
|
4648
|
-
async getBalances(owner
|
4649
|
-
const
|
4650
|
-
|
4651
|
-
|
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,
|
4652
4675
|
filter: { owner: Address2.fromAddressOrString(owner).toB256() }
|
4653
4676
|
});
|
4654
|
-
const balances =
|
4655
|
-
|
4656
|
-
|
4657
|
-
amount: bn17(balance.amount)
|
4677
|
+
const balances = edges.map(({ node }) => ({
|
4678
|
+
assetId: node.assetId,
|
4679
|
+
amount: bn17(node.amount)
|
4658
4680
|
}));
|
4681
|
+
return { balances };
|
4659
4682
|
}
|
4660
4683
|
/**
|
4661
4684
|
* Returns message for the given address.
|
@@ -4665,27 +4688,33 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4665
4688
|
* @returns A promise that resolves to the messages.
|
4666
4689
|
*/
|
4667
4690
|
async getMessages(address, paginationArgs) {
|
4668
|
-
|
4669
|
-
|
4691
|
+
this.validatePaginationArgs(paginationArgs);
|
4692
|
+
const {
|
4693
|
+
messages: { edges, pageInfo }
|
4694
|
+
} = await this.operations.getMessages({
|
4695
|
+
first: 100,
|
4670
4696
|
...paginationArgs,
|
4671
4697
|
owner: Address2.fromAddressOrString(address).toB256()
|
4672
4698
|
});
|
4673
|
-
const messages =
|
4674
|
-
return messages.map((message) => ({
|
4699
|
+
const messages = edges.map(({ node }) => ({
|
4675
4700
|
messageId: InputMessageCoder.getMessageId({
|
4676
|
-
sender:
|
4677
|
-
recipient:
|
4678
|
-
nonce:
|
4679
|
-
amount: bn17(
|
4680
|
-
data:
|
4701
|
+
sender: node.sender,
|
4702
|
+
recipient: node.recipient,
|
4703
|
+
nonce: node.nonce,
|
4704
|
+
amount: bn17(node.amount),
|
4705
|
+
data: node.data
|
4681
4706
|
}),
|
4682
|
-
sender: Address2.fromAddressOrString(
|
4683
|
-
recipient: Address2.fromAddressOrString(
|
4684
|
-
nonce:
|
4685
|
-
amount: bn17(
|
4686
|
-
data: InputMessageCoder.decodeData(
|
4687
|
-
daHeight: bn17(
|
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)
|
4688
4713
|
}));
|
4714
|
+
return {
|
4715
|
+
messages,
|
4716
|
+
pageInfo
|
4717
|
+
};
|
4689
4718
|
}
|
4690
4719
|
/**
|
4691
4720
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4864,6 +4893,18 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4864
4893
|
}
|
4865
4894
|
return relayedTransactionStatus;
|
4866
4895
|
}
|
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
|
+
}
|
4867
4908
|
/**
|
4868
4909
|
* @hidden
|
4869
4910
|
*/
|
@@ -5089,52 +5130,16 @@ var Account = class extends AbstractAccount {
|
|
5089
5130
|
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5090
5131
|
* @returns A promise that resolves to an array of Coins.
|
5091
5132
|
*/
|
5092
|
-
async getCoins(assetId) {
|
5093
|
-
|
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;
|
5133
|
+
async getCoins(assetId, paginationArgs) {
|
5134
|
+
return this.provider.getCoins(this.address, assetId, paginationArgs);
|
5112
5135
|
}
|
5113
5136
|
/**
|
5114
5137
|
* Retrieves messages owned by the account.
|
5115
5138
|
*
|
5116
5139
|
* @returns A promise that resolves to an array of Messages.
|
5117
5140
|
*/
|
5118
|
-
async getMessages() {
|
5119
|
-
|
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;
|
5141
|
+
async getMessages(paginationArgs) {
|
5142
|
+
return this.provider.getMessages(this.address, paginationArgs);
|
5138
5143
|
}
|
5139
5144
|
/**
|
5140
5145
|
* Retrieves the balance of the account for the given asset.
|
@@ -5153,25 +5158,7 @@ var Account = class extends AbstractAccount {
|
|
5153
5158
|
* @returns A promise that resolves to an array of Coins and their quantities.
|
5154
5159
|
*/
|
5155
5160
|
async getBalances() {
|
5156
|
-
|
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;
|
5161
|
+
return this.provider.getBalances(this.address);
|
5175
5162
|
}
|
5176
5163
|
/**
|
5177
5164
|
* Funds a transaction request by adding the necessary resources.
|