@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/test-utils.js
CHANGED
@@ -811,9 +811,6 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
811
811
|
first: $first
|
812
812
|
last: $last
|
813
813
|
) {
|
814
|
-
pageInfo {
|
815
|
-
...pageInfoFragment
|
816
|
-
}
|
817
814
|
edges {
|
818
815
|
node {
|
819
816
|
...coinFragment
|
@@ -821,8 +818,7 @@ var GetCoinsDocument = import_graphql_tag.default`
|
|
821
818
|
}
|
822
819
|
}
|
823
820
|
}
|
824
|
-
${
|
825
|
-
${CoinFragmentDoc}`;
|
821
|
+
${CoinFragmentDoc}`;
|
826
822
|
var GetCoinsToSpendDocument = import_graphql_tag.default`
|
827
823
|
query getCoinsToSpend($owner: Address!, $queryPerAsset: [SpendQueryElementInput!]!, $excludedIds: ExcludeInput) {
|
828
824
|
coinsToSpend(
|
@@ -881,9 +877,6 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
881
877
|
first: $first
|
882
878
|
last: $last
|
883
879
|
) {
|
884
|
-
pageInfo {
|
885
|
-
...pageInfoFragment
|
886
|
-
}
|
887
880
|
edges {
|
888
881
|
node {
|
889
882
|
...balanceFragment
|
@@ -891,8 +884,7 @@ var GetBalancesDocument = import_graphql_tag.default`
|
|
891
884
|
}
|
892
885
|
}
|
893
886
|
}
|
894
|
-
${
|
895
|
-
${BalanceFragmentDoc}`;
|
887
|
+
${BalanceFragmentDoc}`;
|
896
888
|
var GetMessagesDocument = import_graphql_tag.default`
|
897
889
|
query getMessages($owner: Address!, $after: String, $before: String, $first: Int, $last: Int) {
|
898
890
|
messages(
|
@@ -902,9 +894,6 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
902
894
|
first: $first
|
903
895
|
last: $last
|
904
896
|
) {
|
905
|
-
pageInfo {
|
906
|
-
...pageInfoFragment
|
907
|
-
}
|
908
897
|
edges {
|
909
898
|
node {
|
910
899
|
...messageFragment
|
@@ -912,8 +901,7 @@ var GetMessagesDocument = import_graphql_tag.default`
|
|
912
901
|
}
|
913
902
|
}
|
914
903
|
}
|
915
|
-
${
|
916
|
-
${MessageFragmentDoc}`;
|
904
|
+
${MessageFragmentDoc}`;
|
917
905
|
var GetMessageProofDocument = import_graphql_tag.default`
|
918
906
|
query getMessageProof($transactionId: TransactionId!, $nonce: Nonce!, $commitBlockId: BlockId, $commitBlockHeight: U32) {
|
919
907
|
messageProof(
|
@@ -4451,27 +4439,21 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4451
4439
|
* @returns A promise that resolves to the coins.
|
4452
4440
|
*/
|
4453
4441
|
async getCoins(owner, assetId, paginationArgs) {
|
4454
|
-
this.validatePaginationArgs(paginationArgs);
|
4455
4442
|
const ownerAddress = import_address3.Address.fromAddressOrString(owner);
|
4456
|
-
const {
|
4457
|
-
|
4458
|
-
} = await this.operations.getCoins({
|
4459
|
-
first: 100,
|
4443
|
+
const result = await this.operations.getCoins({
|
4444
|
+
first: 10,
|
4460
4445
|
...paginationArgs,
|
4461
4446
|
filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils23.hexlify)(assetId) }
|
4462
4447
|
});
|
4463
|
-
const coins = edges.map((
|
4464
|
-
|
4465
|
-
|
4466
|
-
|
4467
|
-
|
4468
|
-
|
4469
|
-
|
4448
|
+
const coins = result.coins.edges.map((edge) => edge.node);
|
4449
|
+
return coins.map((coin) => ({
|
4450
|
+
id: coin.utxoId,
|
4451
|
+
assetId: coin.assetId,
|
4452
|
+
amount: (0, import_math17.bn)(coin.amount),
|
4453
|
+
owner: import_address3.Address.fromAddressOrString(coin.owner),
|
4454
|
+
blockCreated: (0, import_math17.bn)(coin.blockCreated),
|
4455
|
+
txCreatedIdx: (0, import_math17.bn)(coin.txCreatedIdx)
|
4470
4456
|
}));
|
4471
|
-
return {
|
4472
|
-
coins,
|
4473
|
-
pageInfo
|
4474
|
-
};
|
4475
4457
|
}
|
4476
4458
|
/**
|
4477
4459
|
* Returns resources for the given owner satisfying the spend query.
|
@@ -4681,22 +4663,17 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4681
4663
|
* @param paginationArgs - Pagination arguments (optional).
|
4682
4664
|
* @returns A promise that resolves to the balances.
|
4683
4665
|
*/
|
4684
|
-
async getBalances(owner) {
|
4685
|
-
const {
|
4686
|
-
|
4687
|
-
|
4688
|
-
/**
|
4689
|
-
* The query parameters for this method were designed to support pagination,
|
4690
|
-
* but the current Fuel-Core implementation does not support pagination yet.
|
4691
|
-
*/
|
4692
|
-
first: 1e4,
|
4666
|
+
async getBalances(owner, paginationArgs) {
|
4667
|
+
const result = await this.operations.getBalances({
|
4668
|
+
first: 10,
|
4669
|
+
...paginationArgs,
|
4693
4670
|
filter: { owner: import_address3.Address.fromAddressOrString(owner).toB256() }
|
4694
4671
|
});
|
4695
|
-
const balances = edges.map((
|
4696
|
-
|
4697
|
-
|
4672
|
+
const balances = result.balances.edges.map((edge) => edge.node);
|
4673
|
+
return balances.map((balance) => ({
|
4674
|
+
assetId: balance.assetId,
|
4675
|
+
amount: (0, import_math17.bn)(balance.amount)
|
4698
4676
|
}));
|
4699
|
-
return { balances };
|
4700
4677
|
}
|
4701
4678
|
/**
|
4702
4679
|
* Returns message for the given address.
|
@@ -4706,33 +4683,27 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4706
4683
|
* @returns A promise that resolves to the messages.
|
4707
4684
|
*/
|
4708
4685
|
async getMessages(address, paginationArgs) {
|
4709
|
-
this.
|
4710
|
-
|
4711
|
-
messages: { edges, pageInfo }
|
4712
|
-
} = await this.operations.getMessages({
|
4713
|
-
first: 100,
|
4686
|
+
const result = await this.operations.getMessages({
|
4687
|
+
first: 10,
|
4714
4688
|
...paginationArgs,
|
4715
4689
|
owner: import_address3.Address.fromAddressOrString(address).toB256()
|
4716
4690
|
});
|
4717
|
-
const messages = edges.map((
|
4691
|
+
const messages = result.messages.edges.map((edge) => edge.node);
|
4692
|
+
return messages.map((message) => ({
|
4718
4693
|
messageId: import_transactions20.InputMessageCoder.getMessageId({
|
4719
|
-
sender:
|
4720
|
-
recipient:
|
4721
|
-
nonce:
|
4722
|
-
amount: (0, import_math17.bn)(
|
4723
|
-
data:
|
4694
|
+
sender: message.sender,
|
4695
|
+
recipient: message.recipient,
|
4696
|
+
nonce: message.nonce,
|
4697
|
+
amount: (0, import_math17.bn)(message.amount),
|
4698
|
+
data: message.data
|
4724
4699
|
}),
|
4725
|
-
sender: import_address3.Address.fromAddressOrString(
|
4726
|
-
recipient: import_address3.Address.fromAddressOrString(
|
4727
|
-
nonce:
|
4728
|
-
amount: (0, import_math17.bn)(
|
4729
|
-
data: import_transactions20.InputMessageCoder.decodeData(
|
4730
|
-
daHeight: (0, import_math17.bn)(
|
4700
|
+
sender: import_address3.Address.fromAddressOrString(message.sender),
|
4701
|
+
recipient: import_address3.Address.fromAddressOrString(message.recipient),
|
4702
|
+
nonce: message.nonce,
|
4703
|
+
amount: (0, import_math17.bn)(message.amount),
|
4704
|
+
data: import_transactions20.InputMessageCoder.decodeData(message.data),
|
4705
|
+
daHeight: (0, import_math17.bn)(message.daHeight)
|
4731
4706
|
}));
|
4732
|
-
return {
|
4733
|
-
messages,
|
4734
|
-
pageInfo
|
4735
|
-
};
|
4736
4707
|
}
|
4737
4708
|
/**
|
4738
4709
|
* Returns Message Proof for given transaction id and the message id from MessageOut receipt.
|
@@ -4911,18 +4882,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
4911
4882
|
}
|
4912
4883
|
return relayedTransactionStatus;
|
4913
4884
|
}
|
4914
|
-
/**
|
4915
|
-
* @hidden
|
4916
|
-
*/
|
4917
|
-
validatePaginationArgs({ first, last } = {}) {
|
4918
|
-
const MAX_PAGINATION_LIMIT = 1e3;
|
4919
|
-
if ((first || 0) > MAX_PAGINATION_LIMIT || (last || 0) > MAX_PAGINATION_LIMIT) {
|
4920
|
-
throw new import_errors14.FuelError(
|
4921
|
-
import_errors14.ErrorCode.INVALID_INPUT_PARAMETERS,
|
4922
|
-
"Pagination limit cannot exceed 1000 items"
|
4923
|
-
);
|
4924
|
-
}
|
4925
|
-
}
|
4926
4885
|
/**
|
4927
4886
|
* @hidden
|
4928
4887
|
*/
|
@@ -5148,16 +5107,52 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5148
5107
|
* @param assetId - The asset ID of the coins to retrieve (optional).
|
5149
5108
|
* @returns A promise that resolves to an array of Coins.
|
5150
5109
|
*/
|
5151
|
-
async getCoins(assetId
|
5152
|
-
|
5110
|
+
async getCoins(assetId) {
|
5111
|
+
const coins = [];
|
5112
|
+
const pageSize = 9999;
|
5113
|
+
let cursor;
|
5114
|
+
for (; ; ) {
|
5115
|
+
const pageCoins = await this.provider.getCoins(this.address, assetId, {
|
5116
|
+
first: pageSize,
|
5117
|
+
after: cursor
|
5118
|
+
});
|
5119
|
+
coins.push(...pageCoins);
|
5120
|
+
const hasNextPage = pageCoins.length >= pageSize;
|
5121
|
+
if (!hasNextPage) {
|
5122
|
+
break;
|
5123
|
+
}
|
5124
|
+
throw new import_errors16.FuelError(
|
5125
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5126
|
+
`Wallets containing more than ${pageSize} coins exceed the current supported limit.`
|
5127
|
+
);
|
5128
|
+
}
|
5129
|
+
return coins;
|
5153
5130
|
}
|
5154
5131
|
/**
|
5155
5132
|
* Retrieves messages owned by the account.
|
5156
5133
|
*
|
5157
5134
|
* @returns A promise that resolves to an array of Messages.
|
5158
5135
|
*/
|
5159
|
-
async getMessages(
|
5160
|
-
|
5136
|
+
async getMessages() {
|
5137
|
+
const messages = [];
|
5138
|
+
const pageSize = 9999;
|
5139
|
+
let cursor;
|
5140
|
+
for (; ; ) {
|
5141
|
+
const pageMessages = await this.provider.getMessages(this.address, {
|
5142
|
+
first: pageSize,
|
5143
|
+
after: cursor
|
5144
|
+
});
|
5145
|
+
messages.push(...pageMessages);
|
5146
|
+
const hasNextPage = pageMessages.length >= pageSize;
|
5147
|
+
if (!hasNextPage) {
|
5148
|
+
break;
|
5149
|
+
}
|
5150
|
+
throw new import_errors16.FuelError(
|
5151
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5152
|
+
`Wallets containing more than ${pageSize} messages exceed the current supported limit.`
|
5153
|
+
);
|
5154
|
+
}
|
5155
|
+
return messages;
|
5161
5156
|
}
|
5162
5157
|
/**
|
5163
5158
|
* Retrieves the balance of the account for the given asset.
|
@@ -5176,7 +5171,25 @@ var Account = class extends import_interfaces.AbstractAccount {
|
|
5176
5171
|
* @returns A promise that resolves to an array of Coins and their quantities.
|
5177
5172
|
*/
|
5178
5173
|
async getBalances() {
|
5179
|
-
|
5174
|
+
const balances = [];
|
5175
|
+
const pageSize = 9999;
|
5176
|
+
let cursor;
|
5177
|
+
for (; ; ) {
|
5178
|
+
const pageBalances = await this.provider.getBalances(this.address, {
|
5179
|
+
first: pageSize,
|
5180
|
+
after: cursor
|
5181
|
+
});
|
5182
|
+
balances.push(...pageBalances);
|
5183
|
+
const hasNextPage = pageBalances.length >= pageSize;
|
5184
|
+
if (!hasNextPage) {
|
5185
|
+
break;
|
5186
|
+
}
|
5187
|
+
throw new import_errors16.FuelError(
|
5188
|
+
import_errors16.ErrorCode.NOT_SUPPORTED,
|
5189
|
+
`Wallets containing more than ${pageSize} balances exceed the current supported limit.`
|
5190
|
+
);
|
5191
|
+
}
|
5192
|
+
return balances;
|
5180
5193
|
}
|
5181
5194
|
/**
|
5182
5195
|
* Funds a transaction request by adding the necessary resources.
|