@fuel-ts/account 0.92.1 → 0.94.0

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.
Files changed (87) hide show
  1. package/README.md +9 -29
  2. package/dist/account.d.ts +15 -4
  3. package/dist/account.d.ts.map +1 -1
  4. package/dist/configs.d.ts +0 -2
  5. package/dist/configs.d.ts.map +1 -1
  6. package/dist/configs.global.js +0 -2
  7. package/dist/configs.global.js.map +1 -1
  8. package/dist/configs.js +0 -6
  9. package/dist/configs.js.map +1 -1
  10. package/dist/configs.mjs +0 -4
  11. package/dist/configs.mjs.map +1 -1
  12. package/dist/connectors/fuel-connector.d.ts +24 -1
  13. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  14. package/dist/connectors/fuel.d.ts +14 -1
  15. package/dist/connectors/fuel.d.ts.map +1 -1
  16. package/dist/connectors/types/connector-metadata.d.ts.map +1 -1
  17. package/dist/connectors/utils/promises.d.ts.map +1 -1
  18. package/dist/index.global.js +1645 -985
  19. package/dist/index.global.js.map +1 -1
  20. package/dist/index.js +1034 -673
  21. package/dist/index.js.map +1 -1
  22. package/dist/index.mjs +771 -423
  23. package/dist/index.mjs.map +1 -1
  24. package/dist/predicate/predicate.d.ts +15 -9
  25. package/dist/predicate/predicate.d.ts.map +1 -1
  26. package/dist/providers/__generated__/operations.d.ts +614 -1
  27. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  28. package/dist/providers/fuel-graphql-subscriber.d.ts +3 -3
  29. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  30. package/dist/providers/provider.d.ts +19 -47
  31. package/dist/providers/provider.d.ts.map +1 -1
  32. package/dist/providers/resource-cache.d.ts +14 -0
  33. package/dist/providers/resource-cache.d.ts.map +1 -0
  34. package/dist/providers/transaction-request/blob-transaction-request.d.ts +48 -0
  35. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -0
  36. package/dist/providers/transaction-request/index.d.ts +1 -0
  37. package/dist/providers/transaction-request/index.d.ts.map +1 -1
  38. package/dist/providers/transaction-request/transaction-request.d.ts +4 -3
  39. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  40. package/dist/providers/transaction-request/types.d.ts +5 -2
  41. package/dist/providers/transaction-request/types.d.ts.map +1 -1
  42. package/dist/providers/transaction-request/utils.d.ts +9 -0
  43. package/dist/providers/transaction-request/utils.d.ts.map +1 -1
  44. package/dist/providers/transaction-response/transaction-response.d.ts +10 -5
  45. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  46. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts +1 -1
  47. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  48. package/dist/providers/transaction-summary/call.d.ts +4 -3
  49. package/dist/providers/transaction-summary/call.d.ts.map +1 -1
  50. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  51. package/dist/providers/transaction-summary/input.d.ts +6 -1
  52. package/dist/providers/transaction-summary/input.d.ts.map +1 -1
  53. package/dist/providers/transaction-summary/operations.d.ts +4 -2
  54. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  55. package/dist/providers/transaction-summary/types.d.ts +5 -2
  56. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  57. package/dist/providers/utils/gas.d.ts +6 -0
  58. package/dist/providers/utils/gas.d.ts.map +1 -1
  59. package/dist/test-utils/launchNode.d.ts +0 -16
  60. package/dist/test-utils/launchNode.d.ts.map +1 -1
  61. package/dist/test-utils/setup-test-provider-and-wallets.d.ts.map +1 -1
  62. package/dist/test-utils/test-asset-id.d.ts +8 -0
  63. package/dist/test-utils/test-asset-id.d.ts.map +1 -0
  64. package/dist/test-utils/test-message.d.ts +4 -2
  65. package/dist/test-utils/test-message.d.ts.map +1 -1
  66. package/dist/test-utils/wallet-config.d.ts +3 -3
  67. package/dist/test-utils/wallet-config.d.ts.map +1 -1
  68. package/dist/test-utils.d.ts +1 -3
  69. package/dist/test-utils.d.ts.map +1 -1
  70. package/dist/test-utils.global.js +43613 -42984
  71. package/dist/test-utils.global.js.map +1 -1
  72. package/dist/test-utils.js +1560 -1271
  73. package/dist/test-utils.js.map +1 -1
  74. package/dist/test-utils.mjs +1282 -994
  75. package/dist/test-utils.mjs.map +1 -1
  76. package/dist/wallet/base-wallet-unlocked.d.ts +1 -2
  77. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  78. package/dist/wallet/keystore-wallet.d.ts.map +1 -1
  79. package/package.json +19 -21
  80. package/dist/providers/memory-cache.d.ts +0 -11
  81. package/dist/providers/memory-cache.d.ts.map +0 -1
  82. package/dist/test-utils/asset-id.d.ts +0 -8
  83. package/dist/test-utils/asset-id.d.ts.map +0 -1
  84. package/dist/test-utils/generateTestWallet.d.ts +0 -4
  85. package/dist/test-utils/generateTestWallet.d.ts.map +0 -1
  86. package/dist/test-utils/seedTestWallet.d.ts +0 -4
  87. package/dist/test-utils/seedTestWallet.d.ts.map +0 -1
package/dist/index.mjs CHANGED
@@ -31,10 +31,10 @@ var __privateMethod = (obj, member, method) => {
31
31
  import { UTXO_ID_LEN as UTXO_ID_LEN3 } from "@fuel-ts/abi-coder";
32
32
  import { Address as Address3 } from "@fuel-ts/address";
33
33
  import { randomBytes as randomBytes2 } from "@fuel-ts/crypto";
34
- import { ErrorCode as ErrorCode15, FuelError as FuelError15 } from "@fuel-ts/errors";
34
+ import { ErrorCode as ErrorCode15, FuelError as FuelError16 } from "@fuel-ts/errors";
35
35
  import { AbstractAccount } from "@fuel-ts/interfaces";
36
36
  import { bn as bn19 } from "@fuel-ts/math";
37
- import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined2 } from "@fuel-ts/utils";
37
+ import { arrayify as arrayify14, hexlify as hexlify13, isDefined as isDefined3 } from "@fuel-ts/utils";
38
38
  import { clone as clone4 } from "ramda";
39
39
 
40
40
  // src/providers/coin-quantity.ts
@@ -74,15 +74,10 @@ var addAmountToCoinQuantities = (params) => {
74
74
 
75
75
  // src/providers/provider.ts
76
76
  import { Address as Address2 } from "@fuel-ts/address";
77
- import { ErrorCode as ErrorCode13, FuelError as FuelError13 } from "@fuel-ts/errors";
78
- import { BN, bn as bn17 } from "@fuel-ts/math";
79
- import {
80
- InputType as InputType7,
81
- TransactionType as TransactionType8,
82
- InputMessageCoder,
83
- TransactionCoder as TransactionCoder5
84
- } from "@fuel-ts/transactions";
85
- import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2 } from "@fuel-ts/utils";
77
+ import { ErrorCode as ErrorCode13, FuelError as FuelError14 } from "@fuel-ts/errors";
78
+ import { BN as BN2, bn as bn17 } from "@fuel-ts/math";
79
+ import { InputType as InputType7, InputMessageCoder, TransactionCoder as TransactionCoder5 } from "@fuel-ts/transactions";
80
+ import { arrayify as arrayify11, hexlify as hexlify12, DateTime as DateTime2, isDefined as isDefined2 } from "@fuel-ts/utils";
86
81
  import { checkFuelCoreVersionCompatibility } from "@fuel-ts/versions";
87
82
  import { equalBytes } from "@noble/curves/abstract/utils";
88
83
  import { GraphQLClient } from "graphql-request";
@@ -90,14 +85,6 @@ import { clone as clone3 } from "ramda";
90
85
 
91
86
  // src/providers/__generated__/operations.ts
92
87
  import gql from "graphql-tag";
93
- var TransactionStatusSubscriptionFragmentDoc = gql`
94
- fragment transactionStatusSubscriptionFragment on TransactionStatus {
95
- type: __typename
96
- ... on SqueezedOutStatus {
97
- reason
98
- }
99
- }
100
- `;
101
88
  var SubmittedStatusFragmentDoc = gql`
102
89
  fragment SubmittedStatusFragment on SubmittedStatus {
103
90
  type: __typename
@@ -154,6 +141,47 @@ var SuccessStatusFragmentDoc = gql`
154
141
  totalFee
155
142
  }
156
143
  ${ReceiptFragmentDoc}`;
144
+ var MalleableTransactionFieldsFragmentDoc = gql`
145
+ fragment malleableTransactionFieldsFragment on Transaction {
146
+ receiptsRoot
147
+ inputs {
148
+ type: __typename
149
+ ... on InputCoin {
150
+ txPointer
151
+ }
152
+ ... on InputContract {
153
+ txPointer
154
+ }
155
+ }
156
+ outputs {
157
+ type: __typename
158
+ ... on CoinOutput {
159
+ to
160
+ amount
161
+ assetId
162
+ }
163
+ ... on ContractOutput {
164
+ inputIndex
165
+ balanceRoot
166
+ stateRoot
167
+ }
168
+ ... on ChangeOutput {
169
+ to
170
+ amount
171
+ assetId
172
+ }
173
+ ... on VariableOutput {
174
+ to
175
+ amount
176
+ assetId
177
+ }
178
+ ... on ContractCreated {
179
+ contract
180
+ stateRoot
181
+ }
182
+ }
183
+ }
184
+ `;
157
185
  var FailureStatusFragmentDoc = gql`
158
186
  fragment FailureStatusFragment on FailureStatus {
159
187
  type: __typename
@@ -175,6 +203,32 @@ var SqueezedOutStatusFragmentDoc = gql`
175
203
  reason
176
204
  }
177
205
  `;
206
+ var TransactionStatusSubscriptionFragmentDoc = gql`
207
+ fragment transactionStatusSubscriptionFragment on TransactionStatus {
208
+ ... on SubmittedStatus {
209
+ ...SubmittedStatusFragment
210
+ }
211
+ ... on SuccessStatus {
212
+ ...SuccessStatusFragment
213
+ transaction {
214
+ ...malleableTransactionFieldsFragment
215
+ }
216
+ }
217
+ ... on FailureStatus {
218
+ ...FailureStatusFragment
219
+ transaction {
220
+ ...malleableTransactionFieldsFragment
221
+ }
222
+ }
223
+ ... on SqueezedOutStatus {
224
+ ...SqueezedOutStatusFragment
225
+ }
226
+ }
227
+ ${SubmittedStatusFragmentDoc}
228
+ ${SuccessStatusFragmentDoc}
229
+ ${MalleableTransactionFieldsFragmentDoc}
230
+ ${FailureStatusFragmentDoc}
231
+ ${SqueezedOutStatusFragmentDoc}`;
178
232
  var TransactionStatusFragmentDoc = gql`
179
233
  fragment transactionStatusFragment on TransactionStatus {
180
234
  ... on SubmittedStatus {
@@ -515,6 +569,12 @@ var GasCostsFragmentDoc = gql`
515
569
  alocDependentCost {
516
570
  ...DependentCostFragment
517
571
  }
572
+ bldd {
573
+ ...DependentCostFragment
574
+ }
575
+ bsiz {
576
+ ...DependentCostFragment
577
+ }
518
578
  cfe {
519
579
  ...DependentCostFragment
520
580
  }
@@ -533,6 +593,9 @@ var GasCostsFragmentDoc = gql`
533
593
  csiz {
534
594
  ...DependentCostFragment
535
595
  }
596
+ ed19DependentCost {
597
+ ...DependentCostFragment
598
+ }
536
599
  k256 {
537
600
  ...DependentCostFragment
538
601
  }
@@ -1064,12 +1127,11 @@ function getSdk(requester) {
1064
1127
  import { ErrorCode, FuelError } from "@fuel-ts/errors";
1065
1128
  import { print } from "graphql";
1066
1129
  var _FuelGraphqlSubscriber = class {
1067
- constructor(options) {
1068
- this.options = options;
1130
+ constructor(stream) {
1131
+ this.stream = stream;
1069
1132
  }
1070
- stream;
1071
- async setStream() {
1072
- const { url, query, variables, fetchFn } = this.options;
1133
+ static async create(options) {
1134
+ const { url, query, variables, fetchFn } = options;
1073
1135
  const response = await fetchFn(`${url}-sub`, {
1074
1136
  method: "POST",
1075
1137
  body: JSON.stringify({
@@ -1081,14 +1143,11 @@ var _FuelGraphqlSubscriber = class {
1081
1143
  Accept: "text/event-stream"
1082
1144
  }
1083
1145
  });
1084
- this.stream = response.body.getReader();
1146
+ return new _FuelGraphqlSubscriber(response.body.getReader());
1085
1147
  }
1086
1148
  events = [];
1087
1149
  parsingLeftover = "";
1088
1150
  async next() {
1089
- if (!this.stream) {
1090
- await this.setStream();
1091
- }
1092
1151
  while (true) {
1093
1152
  if (this.events.length > 0) {
1094
1153
  const { data, errors } = this.events.shift();
@@ -1139,62 +1198,65 @@ var _FuelGraphqlSubscriber = class {
1139
1198
  var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
1140
1199
  __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1141
1200
 
1142
- // src/providers/memory-cache.ts
1201
+ // src/providers/resource-cache.ts
1143
1202
  import { ErrorCode as ErrorCode2, FuelError as FuelError2 } from "@fuel-ts/errors";
1144
1203
  import { hexlify as hexlify2 } from "@fuel-ts/utils";
1145
- var cache = {};
1146
- var DEFAULT_TTL_IN_MS = 30 * 1e3;
1147
- var MemoryCache = class {
1204
+ var cache = /* @__PURE__ */ new Map();
1205
+ var ResourceCache = class {
1148
1206
  ttl;
1149
- constructor(ttlInMs = DEFAULT_TTL_IN_MS) {
1150
- this.ttl = ttlInMs;
1151
- if (typeof ttlInMs !== "number" || this.ttl <= 0) {
1207
+ constructor(ttl) {
1208
+ this.ttl = ttl;
1209
+ if (typeof ttl !== "number" || this.ttl <= 0) {
1152
1210
  throw new FuelError2(
1153
1211
  ErrorCode2.INVALID_TTL,
1154
1212
  `Invalid TTL: ${this.ttl}. Use a value greater than zero.`
1155
1213
  );
1156
1214
  }
1157
1215
  }
1158
- get(value, isAutoExpiring = true) {
1159
- const key = hexlify2(value);
1160
- if (cache[key]) {
1161
- if (!isAutoExpiring || cache[key].expires > Date.now()) {
1162
- return cache[key].value;
1163
- }
1164
- this.del(value);
1165
- }
1166
- return void 0;
1167
- }
1168
- set(value) {
1169
- const expiresAt = Date.now() + this.ttl;
1170
- const key = hexlify2(value);
1171
- cache[key] = {
1172
- expires: expiresAt,
1173
- value
1216
+ // Add resources to the cache
1217
+ set(transactionId, resources) {
1218
+ const currentTime = Date.now();
1219
+ const existingResources = cache.get(transactionId) || {
1220
+ utxos: /* @__PURE__ */ new Set(),
1221
+ messages: /* @__PURE__ */ new Set(),
1222
+ timestamp: currentTime
1174
1223
  };
1175
- return expiresAt;
1224
+ resources.utxos.forEach((utxo) => existingResources.utxos.add(hexlify2(utxo)));
1225
+ resources.messages.forEach((message) => existingResources.messages.add(hexlify2(message)));
1226
+ cache.set(transactionId, existingResources);
1176
1227
  }
1177
- getAllData() {
1178
- return Object.keys(cache).reduce((list, key) => {
1179
- const data = this.get(key, false);
1180
- if (data) {
1181
- list.push(data);
1182
- }
1183
- return list;
1184
- }, []);
1228
+ // Remove resources from the cache for a given transaction ID
1229
+ unset(transactionId) {
1230
+ cache.delete(transactionId);
1185
1231
  }
1232
+ // Get all cached resources and remove expired ones
1186
1233
  getActiveData() {
1187
- return Object.keys(cache).reduce((list, key) => {
1188
- const data = this.get(key);
1189
- if (data) {
1190
- list.push(data);
1234
+ const allResources = { utxos: [], messages: [] };
1235
+ const currentTime = Date.now();
1236
+ cache.forEach((resource, transactionId) => {
1237
+ if (currentTime - resource.timestamp < this.ttl) {
1238
+ allResources.utxos.push(...resource.utxos);
1239
+ allResources.messages.push(...resource.messages);
1240
+ } else {
1241
+ cache.delete(transactionId);
1242
+ }
1243
+ });
1244
+ return allResources;
1245
+ }
1246
+ // Check if a UTXO ID or message nonce is already cached and not expired
1247
+ isCached(key) {
1248
+ const currentTime = Date.now();
1249
+ for (const [transactionId, resourceData] of cache.entries()) {
1250
+ if (currentTime - resourceData.timestamp > this.ttl) {
1251
+ cache.delete(transactionId);
1252
+ } else if (resourceData.utxos.has(key) || resourceData.messages.has(key)) {
1253
+ return true;
1191
1254
  }
1192
- return list;
1193
- }, []);
1255
+ }
1256
+ return false;
1194
1257
  }
1195
- del(value) {
1196
- const key = hexlify2(value);
1197
- delete cache[key];
1258
+ clear() {
1259
+ cache.clear();
1198
1260
  }
1199
1261
  };
1200
1262
 
@@ -1335,6 +1397,7 @@ import { UTXO_ID_LEN as UTXO_ID_LEN2 } from "@fuel-ts/abi-coder";
1335
1397
  import { Address, addressify } from "@fuel-ts/address";
1336
1398
  import { ZeroBytes32 as ZeroBytes324 } from "@fuel-ts/address/configs";
1337
1399
  import { randomBytes } from "@fuel-ts/crypto";
1400
+ import { FuelError as FuelError8 } from "@fuel-ts/errors";
1338
1401
  import { bn as bn8 } from "@fuel-ts/math";
1339
1402
  import {
1340
1403
  PolicyType,
@@ -1715,6 +1778,15 @@ function calculateMetadataGasForTxScript({
1715
1778
  }) {
1716
1779
  return resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1717
1780
  }
1781
+ function calculateMetadataGasForTxBlob({
1782
+ gasCosts,
1783
+ txBytesSize,
1784
+ witnessBytesSize
1785
+ }) {
1786
+ const txId = resolveGasDependentCosts(txBytesSize, gasCosts.s256);
1787
+ const blobLen = resolveGasDependentCosts(witnessBytesSize, gasCosts.s256);
1788
+ return txId.add(blobLen);
1789
+ }
1718
1790
  var calculateGasFee = (params) => {
1719
1791
  const { gas, gasPrice, priceFactor, tip } = params;
1720
1792
  return gas.mul(gasPrice).div(priceFactor).add(bn5(tip));
@@ -2291,7 +2363,7 @@ var BaseTransactionRequest = class {
2291
2363
  * @hidden
2292
2364
  */
2293
2365
  metadataGas(_gasCosts) {
2294
- throw new Error("Not implemented");
2366
+ throw new FuelError8(FuelError8.CODES.NOT_IMPLEMENTED, "Not implemented");
2295
2367
  }
2296
2368
  /**
2297
2369
  * @hidden
@@ -2366,6 +2438,7 @@ var BaseTransactionRequest = class {
2366
2438
  };
2367
2439
  updateAssetInput(baseAssetId, bn8(1e11));
2368
2440
  quantities.forEach((q) => updateAssetInput(q.assetId, q.amount));
2441
+ return this;
2369
2442
  }
2370
2443
  /**
2371
2444
  * Retrieves an array of CoinQuantity for each coin output present in the transaction.
@@ -2412,14 +2485,11 @@ var BaseTransactionRequest = class {
2412
2485
  }
2413
2486
  });
2414
2487
  }
2488
+ byteLength() {
2489
+ return this.toTransactionBytes().byteLength;
2490
+ }
2415
2491
  };
2416
2492
 
2417
- // src/providers/transaction-request/create-transaction-request.ts
2418
- import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2419
- import { bn as bn10 } from "@fuel-ts/math";
2420
- import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2421
- import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2422
-
2423
2493
  // src/providers/transaction-request/hash-transaction.ts
2424
2494
  import { ZeroBytes32 as ZeroBytes325 } from "@fuel-ts/address/configs";
2425
2495
  import { uint64ToBytesBE, sha256 } from "@fuel-ts/hasher";
@@ -2491,6 +2561,76 @@ function hashTransaction(transactionRequest, chainId) {
2491
2561
  return sha256(concatenatedData);
2492
2562
  }
2493
2563
 
2564
+ // src/providers/transaction-request/blob-transaction-request.ts
2565
+ var BlobTransactionRequest = class extends BaseTransactionRequest {
2566
+ static from(obj) {
2567
+ if (obj instanceof this) {
2568
+ return obj;
2569
+ }
2570
+ return new this(obj);
2571
+ }
2572
+ /** Type of the transaction */
2573
+ type = TransactionType.Blob;
2574
+ /** Blob ID */
2575
+ blobId;
2576
+ /** Witness index of contract bytecode to create */
2577
+ witnessIndex;
2578
+ /**
2579
+ * Creates an instance `BlobTransactionRequest`.
2580
+ *
2581
+ * @param blobTransactionRequestLike - The initial values for the instance
2582
+ */
2583
+ constructor({ witnessIndex, blobId, ...rest }) {
2584
+ super(rest);
2585
+ this.blobId = blobId;
2586
+ this.witnessIndex = witnessIndex ?? 0;
2587
+ }
2588
+ /**
2589
+ * Converts the transaction request to a `TransactionBlob`.
2590
+ *
2591
+ * @returns The transaction create object.
2592
+ */
2593
+ toTransaction() {
2594
+ const baseTransaction = this.getBaseTransaction();
2595
+ const { witnessIndex, blobId } = this;
2596
+ return {
2597
+ type: TransactionType.Blob,
2598
+ ...baseTransaction,
2599
+ blobId,
2600
+ witnessIndex
2601
+ };
2602
+ }
2603
+ /**
2604
+ * Gets the Transaction Request by hashing the transaction.
2605
+ *
2606
+ * @param chainId - The chain ID.
2607
+ *
2608
+ * @returns - A hash of the transaction, which is the transaction ID.
2609
+ */
2610
+ getTransactionId(chainId) {
2611
+ return hashTransaction(this, chainId);
2612
+ }
2613
+ /**
2614
+ * Calculates the metadata gas cost for a blob transaction.
2615
+ *
2616
+ * @param gasCosts - gas costs passed from the chain.
2617
+ * @returns metadata gas cost for the blob transaction.
2618
+ */
2619
+ metadataGas(gasCosts) {
2620
+ return calculateMetadataGasForTxBlob({
2621
+ gasCosts,
2622
+ txBytesSize: this.byteSize(),
2623
+ witnessBytesSize: this.witnesses[this.witnessIndex].length
2624
+ });
2625
+ }
2626
+ };
2627
+
2628
+ // src/providers/transaction-request/create-transaction-request.ts
2629
+ import { ZeroBytes32 as ZeroBytes326 } from "@fuel-ts/address/configs";
2630
+ import { bn as bn10 } from "@fuel-ts/math";
2631
+ import { TransactionType as TransactionType3, OutputType as OutputType4 } from "@fuel-ts/transactions";
2632
+ import { arrayify as arrayify6, hexlify as hexlify9 } from "@fuel-ts/utils";
2633
+
2494
2634
  // src/providers/transaction-request/storage-slot.ts
2495
2635
  import { arrayify as arrayify5, hexlify as hexlify8 } from "@fuel-ts/utils";
2496
2636
  var getStorageValue = (value) => {
@@ -2819,10 +2959,10 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2819
2959
  };
2820
2960
 
2821
2961
  // src/providers/transaction-request/utils.ts
2822
- import { ErrorCode as ErrorCode8, FuelError as FuelError8 } from "@fuel-ts/errors";
2962
+ import { ErrorCode as ErrorCode8, FuelError as FuelError9 } from "@fuel-ts/errors";
2823
2963
  import { TransactionType as TransactionType5 } from "@fuel-ts/transactions";
2824
2964
  var transactionRequestify = (obj) => {
2825
- if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest) {
2965
+ if (obj instanceof ScriptTransactionRequest || obj instanceof CreateTransactionRequest || obj instanceof BlobTransactionRequest) {
2826
2966
  return obj;
2827
2967
  }
2828
2968
  const { type } = obj;
@@ -2833,17 +2973,26 @@ var transactionRequestify = (obj) => {
2833
2973
  case TransactionType5.Create: {
2834
2974
  return CreateTransactionRequest.from(obj);
2835
2975
  }
2976
+ case TransactionType5.Blob: {
2977
+ return BlobTransactionRequest.from(obj);
2978
+ }
2836
2979
  default: {
2837
- throw new FuelError8(ErrorCode8.INVALID_TRANSACTION_TYPE, `Invalid transaction type: ${type}.`);
2980
+ throw new FuelError9(
2981
+ ErrorCode8.UNSUPPORTED_TRANSACTION_TYPE,
2982
+ `Unsupported transaction type: ${type}.`
2983
+ );
2838
2984
  }
2839
2985
  }
2840
2986
  };
2987
+ var isTransactionTypeScript = (request) => request.type === TransactionType5.Script;
2988
+ var isTransactionTypeCreate = (request) => request.type === TransactionType5.Create;
2989
+ var isTransactionTypeBlob = (request) => request.type === TransactionType5.Blob;
2841
2990
 
2842
2991
  // src/providers/transaction-response/transaction-response.ts
2843
- import { ErrorCode as ErrorCode12, FuelError as FuelError12 } from "@fuel-ts/errors";
2992
+ import { ErrorCode as ErrorCode12, FuelError as FuelError13 } from "@fuel-ts/errors";
2844
2993
  import { bn as bn16 } from "@fuel-ts/math";
2845
- import { TransactionCoder as TransactionCoder4 } from "@fuel-ts/transactions";
2846
- import { arrayify as arrayify10 } from "@fuel-ts/utils";
2994
+ import { OutputType as OutputType7, TransactionCoder as TransactionCoder4, TxPointerCoder } from "@fuel-ts/transactions";
2995
+ import { arrayify as arrayify10, assertUnreachable } from "@fuel-ts/utils";
2847
2996
 
2848
2997
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2849
2998
  import { bn as bn15 } from "@fuel-ts/math";
@@ -2922,7 +3071,7 @@ var calculateTXFeeForSummary = (params) => {
2922
3071
 
2923
3072
  // src/providers/transaction-summary/operations.ts
2924
3073
  import { ZeroBytes32 as ZeroBytes328 } from "@fuel-ts/address/configs";
2925
- import { ErrorCode as ErrorCode10, FuelError as FuelError10 } from "@fuel-ts/errors";
3074
+ import { ErrorCode as ErrorCode10, FuelError as FuelError11 } from "@fuel-ts/errors";
2926
3075
  import { bn as bn13 } from "@fuel-ts/math";
2927
3076
  import { ReceiptType as ReceiptType4, TransactionType as TransactionType7 } from "@fuel-ts/transactions";
2928
3077
 
@@ -2960,7 +3109,8 @@ var getFunctionCall = ({ abi, receipt }) => {
2960
3109
  };
2961
3110
 
2962
3111
  // src/providers/transaction-summary/input.ts
2963
- import { ErrorCode as ErrorCode9, FuelError as FuelError9 } from "@fuel-ts/errors";
3112
+ import { ErrorCode as ErrorCode9, FuelError as FuelError10 } from "@fuel-ts/errors";
3113
+ import { BN } from "@fuel-ts/math";
2964
3114
  import { InputType as InputType6 } from "@fuel-ts/transactions";
2965
3115
  function getInputsByTypes(inputs, types) {
2966
3116
  return inputs.filter((i) => types.includes(i.type));
@@ -2977,17 +3127,47 @@ function getInputsMessage(inputs) {
2977
3127
  function getInputsCoinAndMessage(inputs) {
2978
3128
  return getInputsByTypes(inputs, [InputType6.Coin, InputType6.Message]);
2979
3129
  }
3130
+ function isInputCoin(input) {
3131
+ return input.type === InputType6.Coin;
3132
+ }
2980
3133
  function getInputsContract(inputs) {
2981
3134
  return getInputsByType(inputs, InputType6.Contract);
2982
3135
  }
2983
- function getInputFromAssetId(inputs, assetId) {
3136
+ function findCoinInput(inputs, assetId) {
2984
3137
  const coinInputs = getInputsCoin(inputs);
2985
- const messageInputs = getInputsMessage(inputs);
2986
- const coinInput = coinInputs.find((i) => i.assetId === assetId);
2987
- const messageInput = messageInputs.find(
2988
- (_) => assetId === "0x0000000000000000000000000000000000000000000000000000000000000000"
2989
- );
2990
- return coinInput || messageInput;
3138
+ return coinInputs.find((i) => i.assetId === assetId);
3139
+ }
3140
+ function aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetID) {
3141
+ const aggregated = /* @__PURE__ */ new Map();
3142
+ getInputsCoinAndMessage(inputs).forEach((input) => {
3143
+ const assetId = isInputCoin(input) ? input.assetId : baseAssetID;
3144
+ const owner = isInputCoin(input) ? input.owner : input.recipient;
3145
+ let ownersMap = aggregated.get(assetId);
3146
+ if (!ownersMap) {
3147
+ ownersMap = /* @__PURE__ */ new Map();
3148
+ aggregated.set(assetId, ownersMap);
3149
+ }
3150
+ let ownerBalance = ownersMap.get(owner);
3151
+ if (!ownerBalance) {
3152
+ ownerBalance = new BN(0);
3153
+ ownersMap.set(owner, ownerBalance);
3154
+ }
3155
+ ownersMap.set(owner, ownerBalance.add(input.amount));
3156
+ });
3157
+ return aggregated;
3158
+ }
3159
+ function findMessageInput(inputs) {
3160
+ return getInputsMessage(inputs)?.[0];
3161
+ }
3162
+ function getInputFromAssetId(inputs, assetId, isBaseAsset = false) {
3163
+ const coinInput = findCoinInput(inputs, assetId);
3164
+ if (coinInput) {
3165
+ return coinInput;
3166
+ }
3167
+ if (isBaseAsset) {
3168
+ return findMessageInput(inputs);
3169
+ }
3170
+ return void 0;
2991
3171
  }
2992
3172
  function getInputContractFromIndex(inputs, inputIndex) {
2993
3173
  if (inputIndex == null) {
@@ -2998,7 +3178,7 @@ function getInputContractFromIndex(inputs, inputIndex) {
2998
3178
  return void 0;
2999
3179
  }
3000
3180
  if (contractInput.type !== InputType6.Contract) {
3001
- throw new FuelError9(
3181
+ throw new FuelError10(
3002
3182
  ErrorCode9.INVALID_TRANSACTION_INPUT,
3003
3183
  `Contract input should be of type 'contract'.`
3004
3184
  );
@@ -3043,6 +3223,7 @@ var TransactionTypeName = /* @__PURE__ */ ((TransactionTypeName2) => {
3043
3223
  TransactionTypeName2["Script"] = "Script";
3044
3224
  TransactionTypeName2["Upgrade"] = "Upgrade";
3045
3225
  TransactionTypeName2["Upload"] = "Upload";
3226
+ TransactionTypeName2["Blob"] = "Blob";
3046
3227
  return TransactionTypeName2;
3047
3228
  })(TransactionTypeName || {});
3048
3229
  var TransactionStatus = /* @__PURE__ */ ((TransactionStatus2) => {
@@ -3088,10 +3269,12 @@ function getTransactionTypeName(transactionType) {
3088
3269
  return "Create" /* Create */;
3089
3270
  case TransactionType7.Script:
3090
3271
  return "Script" /* Script */;
3272
+ case TransactionType7.Blob:
3273
+ return "Blob" /* Blob */;
3091
3274
  default:
3092
- throw new FuelError10(
3093
- ErrorCode10.INVALID_TRANSACTION_TYPE,
3094
- `Invalid transaction type: ${transactionType}.`
3275
+ throw new FuelError11(
3276
+ ErrorCode10.UNSUPPORTED_TRANSACTION_TYPE,
3277
+ `Unsupported transaction type: ${transactionType}.`
3095
3278
  );
3096
3279
  }
3097
3280
  }
@@ -3114,6 +3297,9 @@ function isTypeUpgrade(transactionType) {
3114
3297
  function isTypeUpload(transactionType) {
3115
3298
  return isType(transactionType, "Upload" /* Upload */);
3116
3299
  }
3300
+ function isTypeBlob(transactionType) {
3301
+ return isType(transactionType, "Blob" /* Blob */);
3302
+ }
3117
3303
  function hasSameAssetId(a) {
3118
3304
  return (b) => a.assetId === b.assetId;
3119
3305
  }
@@ -3123,41 +3309,51 @@ function getReceiptsCall(receipts) {
3123
3309
  function getReceiptsMessageOut(receipts) {
3124
3310
  return getReceiptsByType(receipts, ReceiptType4.MessageOut);
3125
3311
  }
3126
- var mergeAssets = (op1, op2) => {
3312
+ function mergeAssets(op1, op2) {
3127
3313
  const assets1 = op1.assetsSent || [];
3128
3314
  const assets2 = op2.assetsSent || [];
3129
- const filteredAssets = assets2.filter(
3130
- (asset2) => !assets1.some((asset1) => asset1.assetId === asset2.assetId)
3131
- );
3132
- const mergedAssets = assets1.map((asset1) => {
3133
- const matchingAsset = assets2.find((asset2) => asset2.assetId === asset1.assetId);
3134
- if (!matchingAsset) {
3135
- return asset1;
3315
+ const assetMap = /* @__PURE__ */ new Map();
3316
+ assets1.forEach((asset) => {
3317
+ assetMap.set(asset.assetId, { ...asset });
3318
+ });
3319
+ assets2.forEach((asset) => {
3320
+ const existingAsset = assetMap.get(asset.assetId);
3321
+ if (existingAsset) {
3322
+ existingAsset.amount = bn13(existingAsset.amount).add(asset.amount);
3323
+ } else {
3324
+ assetMap.set(asset.assetId, { ...asset });
3136
3325
  }
3137
- const mergedAmount = bn13(asset1.amount).add(matchingAsset.amount);
3138
- return { ...asset1, amount: mergedAmount };
3139
3326
  });
3140
- return mergedAssets.concat(filteredAssets);
3141
- };
3327
+ return Array.from(assetMap.values());
3328
+ }
3142
3329
  function isSameOperation(a, b) {
3143
3330
  return a.name === b.name && a.from?.address === b.from?.address && a.to?.address === b.to?.address && a.from?.type === b.from?.type && a.to?.type === b.to?.type;
3144
3331
  }
3332
+ function mergeAssetsSent(existing, toAdd) {
3333
+ if (!toAdd.assetsSent?.length) {
3334
+ return existing.assetsSent;
3335
+ }
3336
+ return existing.assetsSent?.length ? mergeAssets(existing, toAdd) : toAdd.assetsSent;
3337
+ }
3338
+ function mergeCalls(existing, toAdd) {
3339
+ if (!toAdd.calls?.length) {
3340
+ return existing.calls;
3341
+ }
3342
+ return [...existing.calls || [], ...toAdd.calls];
3343
+ }
3344
+ function mergeOperations(existing, toAdd) {
3345
+ return {
3346
+ ...existing,
3347
+ assetsSent: mergeAssetsSent(existing, toAdd),
3348
+ calls: mergeCalls(existing, toAdd)
3349
+ };
3350
+ }
3145
3351
  function addOperation(operations, toAdd) {
3146
- const allOperations = [...operations];
3147
- const index = allOperations.findIndex((op) => isSameOperation(op, toAdd));
3148
- if (allOperations[index]) {
3149
- const existentOperation = { ...allOperations[index] };
3150
- if (toAdd.assetsSent?.length) {
3151
- existentOperation.assetsSent = existentOperation.assetsSent?.length ? mergeAssets(existentOperation, toAdd) : toAdd.assetsSent;
3152
- }
3153
- if (toAdd.calls?.length) {
3154
- existentOperation.calls = [...existentOperation.calls || [], ...toAdd.calls];
3155
- }
3156
- allOperations[index] = existentOperation;
3157
- } else {
3158
- allOperations.push(toAdd);
3352
+ const existingIndex = operations.findIndex((op) => isSameOperation(op, toAdd));
3353
+ if (existingIndex === -1) {
3354
+ return [...operations, toAdd];
3159
3355
  }
3160
- return allOperations;
3356
+ return operations.map((op, index) => index === existingIndex ? mergeOperations(op, toAdd) : op);
3161
3357
  }
3162
3358
  function getReceiptsTransferOut(receipts) {
3163
3359
  return getReceiptsByType(receipts, ReceiptType4.TransferOut);
@@ -3170,7 +3366,7 @@ function getWithdrawFromFuelOperations({
3170
3366
  const messageOutReceipts = getReceiptsMessageOut(receipts);
3171
3367
  const withdrawFromFuelOperations = messageOutReceipts.reduce(
3172
3368
  (prevWithdrawFromFuelOps, receipt) => {
3173
- const input = getInputFromAssetId(inputs, baseAssetId);
3369
+ const input = getInputFromAssetId(inputs, baseAssetId, true);
3174
3370
  if (input) {
3175
3371
  const inputAddress = getInputAccountAddress(input);
3176
3372
  const newWithdrawFromFuelOps = addOperation(prevWithdrawFromFuelOps, {
@@ -3199,65 +3395,80 @@ function getWithdrawFromFuelOperations({
3199
3395
  );
3200
3396
  return withdrawFromFuelOperations;
3201
3397
  }
3398
+ function getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs) {
3399
+ const abi = abiMap?.[contractInput.contractID];
3400
+ if (!abi) {
3401
+ return [];
3402
+ }
3403
+ return [
3404
+ getFunctionCall({
3405
+ abi,
3406
+ receipt,
3407
+ rawPayload,
3408
+ maxInputs
3409
+ })
3410
+ ];
3411
+ }
3412
+ function getAssetsSent(receipt) {
3413
+ return receipt.amount?.isZero() ? void 0 : [
3414
+ {
3415
+ amount: receipt.amount,
3416
+ assetId: receipt.assetId
3417
+ }
3418
+ ];
3419
+ }
3420
+ function processCallReceipt(receipt, contractInput, inputs, abiMap, rawPayload, maxInputs, baseAssetId) {
3421
+ const assetId = receipt.assetId === ZeroBytes328 ? baseAssetId : receipt.assetId;
3422
+ const input = getInputFromAssetId(inputs, assetId, assetId === baseAssetId);
3423
+ if (!input) {
3424
+ return [];
3425
+ }
3426
+ const inputAddress = getInputAccountAddress(input);
3427
+ const calls = getContractCalls(contractInput, abiMap, receipt, rawPayload, maxInputs);
3428
+ return [
3429
+ {
3430
+ name: "Contract call" /* contractCall */,
3431
+ from: {
3432
+ type: 1 /* account */,
3433
+ address: inputAddress
3434
+ },
3435
+ to: {
3436
+ type: 0 /* contract */,
3437
+ address: receipt.to
3438
+ },
3439
+ assetsSent: getAssetsSent(receipt),
3440
+ calls
3441
+ }
3442
+ ];
3443
+ }
3202
3444
  function getContractCallOperations({
3203
3445
  inputs,
3204
3446
  outputs,
3205
3447
  receipts,
3206
3448
  abiMap,
3207
3449
  rawPayload,
3208
- maxInputs
3450
+ maxInputs,
3451
+ baseAssetId
3209
3452
  }) {
3210
3453
  const contractCallReceipts = getReceiptsCall(receipts);
3211
3454
  const contractOutputs = getOutputsContract(outputs);
3212
- const contractCallOperations = contractOutputs.reduce((prevOutputCallOps, output) => {
3455
+ return contractOutputs.flatMap((output) => {
3213
3456
  const contractInput = getInputContractFromIndex(inputs, output.inputIndex);
3214
- if (contractInput) {
3215
- const newCallOps = contractCallReceipts.reduce((prevContractCallOps, receipt) => {
3216
- if (receipt.to === contractInput.contractID) {
3217
- const input = getInputFromAssetId(inputs, receipt.assetId);
3218
- if (input) {
3219
- const inputAddress = getInputAccountAddress(input);
3220
- const calls = [];
3221
- const abi = abiMap?.[contractInput.contractID];
3222
- if (abi) {
3223
- calls.push(
3224
- getFunctionCall({
3225
- abi,
3226
- receipt,
3227
- rawPayload,
3228
- maxInputs
3229
- })
3230
- );
3231
- }
3232
- const newContractCallOps = addOperation(prevContractCallOps, {
3233
- name: "Contract call" /* contractCall */,
3234
- from: {
3235
- type: 1 /* account */,
3236
- address: inputAddress
3237
- },
3238
- to: {
3239
- type: 0 /* contract */,
3240
- address: receipt.to
3241
- },
3242
- // if no amount is forwarded to the contract, skip showing assetsSent
3243
- assetsSent: receipt.amount?.isZero() ? void 0 : [
3244
- {
3245
- amount: receipt.amount,
3246
- assetId: receipt.assetId
3247
- }
3248
- ],
3249
- calls
3250
- });
3251
- return newContractCallOps;
3252
- }
3253
- }
3254
- return prevContractCallOps;
3255
- }, prevOutputCallOps);
3256
- return newCallOps;
3457
+ if (!contractInput) {
3458
+ return [];
3257
3459
  }
3258
- return prevOutputCallOps;
3259
- }, []);
3260
- return contractCallOperations;
3460
+ return contractCallReceipts.filter((receipt) => receipt.to === contractInput.contractID).flatMap(
3461
+ (receipt) => processCallReceipt(
3462
+ receipt,
3463
+ contractInput,
3464
+ inputs,
3465
+ abiMap,
3466
+ rawPayload,
3467
+ maxInputs,
3468
+ baseAssetId
3469
+ )
3470
+ );
3471
+ });
3261
3472
  }
3262
3473
  function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
3263
3474
  const { to: toAddress, assetId, amount } = receipt;
@@ -3289,32 +3500,40 @@ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutp
3289
3500
  function getTransferOperations({
3290
3501
  inputs,
3291
3502
  outputs,
3292
- receipts
3503
+ receipts,
3504
+ baseAssetId
3293
3505
  }) {
3294
3506
  let operations = [];
3295
3507
  const coinOutputs = getOutputsCoin(outputs);
3296
3508
  const contractInputs = getInputsContract(inputs);
3297
3509
  const changeOutputs = getOutputsChange(outputs);
3298
- coinOutputs.forEach((output) => {
3299
- const { amount, assetId, to } = output;
3300
- const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
3301
- if (changeOutput) {
3510
+ const aggregated = aggregateInputsAmountsByAssetAndOwner(inputs, baseAssetId);
3511
+ coinOutputs.forEach(({ amount, assetId, to }) => {
3512
+ const txPayers = aggregated.get(assetId) || /* @__PURE__ */ new Map();
3513
+ let selectedPayer;
3514
+ let fallbackPayer;
3515
+ for (const [address, payedAmount] of txPayers) {
3516
+ if (!fallbackPayer) {
3517
+ fallbackPayer = address;
3518
+ }
3519
+ if (payedAmount.gte(amount)) {
3520
+ selectedPayer = address;
3521
+ break;
3522
+ }
3523
+ }
3524
+ selectedPayer = selectedPayer || fallbackPayer;
3525
+ if (selectedPayer) {
3302
3526
  operations = addOperation(operations, {
3303
3527
  name: "Transfer asset" /* transfer */,
3304
3528
  from: {
3305
3529
  type: 1 /* account */,
3306
- address: changeOutput.to
3530
+ address: selectedPayer
3307
3531
  },
3308
3532
  to: {
3309
3533
  type: 1 /* account */,
3310
3534
  address: to
3311
3535
  },
3312
- assetsSent: [
3313
- {
3314
- assetId,
3315
- amount
3316
- }
3317
- ]
3536
+ assetsSent: [{ assetId, amount }]
3318
3537
  });
3319
3538
  }
3320
3539
  });
@@ -3387,21 +3606,19 @@ function getOperations({
3387
3606
  baseAssetId
3388
3607
  }) {
3389
3608
  if (isTypeCreate(transactionType)) {
3390
- return [
3391
- ...getContractCreatedOperations({ inputs, outputs }),
3392
- ...getTransferOperations({ inputs, outputs, receipts })
3393
- ];
3609
+ return [...getContractCreatedOperations({ inputs, outputs })];
3394
3610
  }
3395
3611
  if (isTypeScript(transactionType)) {
3396
3612
  return [
3397
- ...getTransferOperations({ inputs, outputs, receipts }),
3613
+ ...getTransferOperations({ inputs, outputs, receipts, baseAssetId }),
3398
3614
  ...getContractCallOperations({
3399
3615
  inputs,
3400
3616
  outputs,
3401
3617
  receipts,
3402
3618
  abiMap,
3403
3619
  rawPayload,
3404
- maxInputs
3620
+ maxInputs,
3621
+ baseAssetId
3405
3622
  }),
3406
3623
  ...getWithdrawFromFuelOperations({ inputs, receipts, baseAssetId })
3407
3624
  ];
@@ -3460,7 +3677,7 @@ var extractBurnedAssetsFromReceipts = (receipts) => {
3460
3677
  };
3461
3678
 
3462
3679
  // src/providers/transaction-summary/status.ts
3463
- import { ErrorCode as ErrorCode11, FuelError as FuelError11 } from "@fuel-ts/errors";
3680
+ import { ErrorCode as ErrorCode11, FuelError as FuelError12 } from "@fuel-ts/errors";
3464
3681
  import { bn as bn14 } from "@fuel-ts/math";
3465
3682
  var getTransactionStatusName = (gqlStatus) => {
3466
3683
  switch (gqlStatus) {
@@ -3473,7 +3690,7 @@ var getTransactionStatusName = (gqlStatus) => {
3473
3690
  case "SqueezedOutStatus":
3474
3691
  return "squeezedout" /* squeezedout */;
3475
3692
  default:
3476
- throw new FuelError11(
3693
+ throw new FuelError12(
3477
3694
  ErrorCode11.INVALID_TRANSACTION_STATUS,
3478
3695
  `Invalid transaction status: ${gqlStatus}.`
3479
3696
  );
@@ -3595,6 +3812,7 @@ function assembleTransactionSummary(params) {
3595
3812
  isTypeScript: isTypeScript(transaction.type),
3596
3813
  isTypeUpgrade: isTypeUpgrade(transaction.type),
3597
3814
  isTypeUpload: isTypeUpload(transaction.type),
3815
+ isTypeBlob: isTypeBlob(transaction.type),
3598
3816
  isStatusFailure,
3599
3817
  isStatusSuccess,
3600
3818
  isStatusPending,
@@ -3620,6 +3838,36 @@ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3620
3838
  }
3621
3839
 
3622
3840
  // src/providers/transaction-response/transaction-response.ts
3841
+ function mapGqlOutputsToTxOutputs(outputs) {
3842
+ return outputs.map((o) => {
3843
+ const obj = "amount" in o ? { ...o, amount: bn16(o.amount) } : o;
3844
+ switch (obj.type) {
3845
+ case "CoinOutput":
3846
+ return { ...obj, type: OutputType7.Coin };
3847
+ case "ContractOutput":
3848
+ return {
3849
+ ...obj,
3850
+ type: OutputType7.Contract,
3851
+ inputIndex: parseInt(obj.inputIndex, 10)
3852
+ };
3853
+ case "ChangeOutput":
3854
+ return {
3855
+ ...obj,
3856
+ type: OutputType7.Change
3857
+ };
3858
+ case "VariableOutput":
3859
+ return { ...obj, type: OutputType7.Variable };
3860
+ case "ContractCreated":
3861
+ return {
3862
+ ...obj,
3863
+ type: OutputType7.ContractCreated,
3864
+ contractId: obj.contract
3865
+ };
3866
+ default:
3867
+ return assertUnreachable(obj);
3868
+ }
3869
+ });
3870
+ }
3623
3871
  var TransactionResponse = class {
3624
3872
  /** Transaction ID */
3625
3873
  id;
@@ -3629,17 +3877,20 @@ var TransactionResponse = class {
3629
3877
  gasUsed = bn16(0);
3630
3878
  /** The graphql Transaction with receipts object. */
3631
3879
  gqlTransaction;
3880
+ request;
3881
+ status;
3632
3882
  abis;
3633
3883
  /**
3634
3884
  * Constructor for `TransactionResponse`.
3635
3885
  *
3636
- * @param id - The transaction ID.
3886
+ * @param tx - The transaction ID or TransactionRequest.
3637
3887
  * @param provider - The provider.
3638
3888
  */
3639
- constructor(id, provider, abis) {
3640
- this.id = id;
3889
+ constructor(tx, provider, abis) {
3890
+ this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
3641
3891
  this.provider = provider;
3642
3892
  this.abis = abis;
3893
+ this.request = typeof tx === "string" ? void 0 : tx;
3643
3894
  }
3644
3895
  /**
3645
3896
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3654,6 +3905,54 @@ var TransactionResponse = class {
3654
3905
  await response.fetch();
3655
3906
  return response;
3656
3907
  }
3908
+ applyMalleableSubscriptionFields(transaction) {
3909
+ const status = this.status;
3910
+ if (!status) {
3911
+ return;
3912
+ }
3913
+ const tx = transaction;
3914
+ if (status.type === "SuccessStatus" || status.type === "FailureStatus") {
3915
+ tx.inputs = tx.inputs.map((input, idx) => {
3916
+ if ("txPointer" in input) {
3917
+ const correspondingInput = status.transaction.inputs?.[idx];
3918
+ return {
3919
+ ...input,
3920
+ txPointer: TxPointerCoder.decodeFromGqlScalar(correspondingInput.txPointer)
3921
+ };
3922
+ }
3923
+ return input;
3924
+ });
3925
+ tx.outputs = mapGqlOutputsToTxOutputs(status.transaction.outputs);
3926
+ if ("receiptsRoot" in status.transaction) {
3927
+ tx.receiptsRoot = status.transaction.receiptsRoot;
3928
+ }
3929
+ }
3930
+ }
3931
+ async getTransaction() {
3932
+ if (this.request) {
3933
+ const tx = this.request.toTransaction();
3934
+ this.applyMalleableSubscriptionFields(tx);
3935
+ return {
3936
+ tx,
3937
+ bytes: this.request.toTransactionBytes()
3938
+ };
3939
+ }
3940
+ const gqlTransaction = this.gqlTransaction ?? await this.fetch();
3941
+ return {
3942
+ tx: this.decodeTransaction(gqlTransaction),
3943
+ bytes: arrayify10(gqlTransaction.rawPayload)
3944
+ };
3945
+ }
3946
+ getReceipts() {
3947
+ const status = this.status ?? this.gqlTransaction?.status;
3948
+ switch (status?.type) {
3949
+ case "SuccessStatus":
3950
+ case "FailureStatus":
3951
+ return status.receipts.map(processGqlReceipt);
3952
+ default:
3953
+ return [];
3954
+ }
3955
+ }
3657
3956
  /**
3658
3957
  * Fetch the transaction with receipts from the provider.
3659
3958
  *
@@ -3664,11 +3963,12 @@ var TransactionResponse = class {
3664
3963
  transactionId: this.id
3665
3964
  });
3666
3965
  if (!response.transaction) {
3667
- const subscription = this.provider.operations.statusChange({
3966
+ const subscription = await this.provider.operations.statusChange({
3668
3967
  transactionId: this.id
3669
3968
  });
3670
3969
  for await (const { statusChange } of subscription) {
3671
3970
  if (statusChange) {
3971
+ this.status = statusChange;
3672
3972
  break;
3673
3973
  }
3674
3974
  }
@@ -3697,28 +3997,17 @@ var TransactionResponse = class {
3697
3997
  * @returns
3698
3998
  */
3699
3999
  async getTransactionSummary(contractsAbiMap) {
3700
- let transaction = this.gqlTransaction;
3701
- if (!transaction) {
3702
- transaction = await this.fetch();
3703
- }
3704
- const decodedTransaction = this.decodeTransaction(
3705
- transaction
3706
- );
3707
- let txReceipts = [];
3708
- if (transaction?.status && "receipts" in transaction.status) {
3709
- txReceipts = transaction.status.receipts;
3710
- }
3711
- const receipts = txReceipts.map(processGqlReceipt) || [];
4000
+ const { tx: transaction, bytes: transactionBytes } = await this.getTransaction();
3712
4001
  const { gasPerByte, gasPriceFactor, gasCosts, maxGasPerTx } = this.provider.getGasConfig();
3713
4002
  const gasPrice = await this.provider.getLatestGasPrice();
3714
4003
  const maxInputs = this.provider.getChain().consensusParameters.txParameters.maxInputs;
3715
4004
  const baseAssetId = this.provider.getBaseAssetId();
3716
4005
  const transactionSummary = assembleTransactionSummary({
3717
4006
  id: this.id,
3718
- receipts,
3719
- transaction: decodedTransaction,
3720
- transactionBytes: arrayify10(transaction.rawPayload),
3721
- gqlTransactionStatus: transaction.status,
4007
+ receipts: this.getReceipts(),
4008
+ transaction,
4009
+ transactionBytes,
4010
+ gqlTransactionStatus: this.status ?? this.gqlTransaction?.status,
3722
4011
  gasPerByte,
3723
4012
  gasPriceFactor,
3724
4013
  abiMap: contractsAbiMap,
@@ -3735,12 +4024,14 @@ var TransactionResponse = class {
3735
4024
  if (status && status !== "SubmittedStatus") {
3736
4025
  return;
3737
4026
  }
3738
- const subscription = this.provider.operations.statusChange({
4027
+ const subscription = await this.provider.operations.statusChange({
3739
4028
  transactionId: this.id
3740
4029
  });
3741
4030
  for await (const { statusChange } of subscription) {
4031
+ this.status = statusChange;
3742
4032
  if (statusChange.type === "SqueezedOutStatus") {
3743
- throw new FuelError12(
4033
+ this.unsetResourceCache();
4034
+ throw new FuelError13(
3744
4035
  ErrorCode12.TRANSACTION_SQUEEZED_OUT,
3745
4036
  `Transaction Squeezed Out with reason: ${statusChange.reason}`
3746
4037
  );
@@ -3749,7 +4040,6 @@ var TransactionResponse = class {
3749
4040
  break;
3750
4041
  }
3751
4042
  }
3752
- await this.fetch();
3753
4043
  }
3754
4044
  /**
3755
4045
  * Assembles the result of a transaction by retrieving the transaction summary,
@@ -3766,7 +4056,6 @@ var TransactionResponse = class {
3766
4056
  async assembleResult(contractsAbiMap) {
3767
4057
  const transactionSummary = await this.getTransactionSummary(contractsAbiMap);
3768
4058
  const transactionResult = {
3769
- gqlTransaction: this.gqlTransaction,
3770
4059
  ...transactionSummary
3771
4060
  };
3772
4061
  let logs = [];
@@ -3778,9 +4067,11 @@ var TransactionResponse = class {
3778
4067
  );
3779
4068
  transactionResult.logs = logs;
3780
4069
  }
3781
- const { gqlTransaction, receipts } = transactionResult;
3782
- if (gqlTransaction.status?.type === "FailureStatus") {
3783
- const { reason } = gqlTransaction.status;
4070
+ const { receipts } = transactionResult;
4071
+ const status = this.status ?? this.gqlTransaction?.status;
4072
+ if (status?.type === "FailureStatus") {
4073
+ this.unsetResourceCache();
4074
+ const { reason } = status;
3784
4075
  throw extractTxError({
3785
4076
  receipts,
3786
4077
  statusReason: reason,
@@ -3806,6 +4097,9 @@ var TransactionResponse = class {
3806
4097
  async wait(contractsAbiMap) {
3807
4098
  return this.waitForResult(contractsAbiMap);
3808
4099
  }
4100
+ unsetResourceCache() {
4101
+ this.provider.cache?.unset(this.id);
4102
+ }
3809
4103
  };
3810
4104
 
3811
4105
  // src/providers/utils/auto-retry-fetch.ts
@@ -3845,24 +4139,11 @@ function autoRetryFetch(fetchFn, options, retryAttemptNum = 0) {
3845
4139
  };
3846
4140
  }
3847
4141
 
3848
- // src/providers/utils/merge-quantities.ts
3849
- var mergeQuantities = (...coinQuantities) => {
3850
- const resultMap = {};
3851
- function addToMap({ amount, assetId }) {
3852
- if (resultMap[assetId]) {
3853
- resultMap[assetId] = resultMap[assetId].add(amount);
3854
- } else {
3855
- resultMap[assetId] = amount;
3856
- }
3857
- }
3858
- coinQuantities.forEach((arr) => arr.forEach(addToMap));
3859
- return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
3860
- };
3861
-
3862
4142
  // src/providers/provider.ts
3863
4143
  var MAX_RETRIES = 10;
3864
4144
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
3865
4145
  var BLOCKS_PAGE_SIZE_LIMIT = 5;
4146
+ var DEFAULT_RESOURCE_CACHE_TTL = 2e4;
3866
4147
  var processGqlChain = (chain) => {
3867
4148
  const { name, daHeight, consensusParameters, latestBlock } = chain;
3868
4149
  const {
@@ -3945,14 +4226,23 @@ var _Provider = class {
3945
4226
  __publicField(this, "cache");
3946
4227
  __publicField(this, "options", {
3947
4228
  timeout: void 0,
3948
- cacheUtxo: void 0,
4229
+ resourceCacheTTL: void 0,
3949
4230
  fetch: void 0,
3950
4231
  retryOptions: void 0
3951
4232
  });
3952
4233
  this.options = { ...this.options, ...options };
3953
4234
  this.url = url;
3954
4235
  this.operations = this.createOperations();
3955
- this.cache = options.cacheUtxo ? new MemoryCache(options.cacheUtxo) : void 0;
4236
+ const { resourceCacheTTL } = this.options;
4237
+ if (isDefined2(resourceCacheTTL)) {
4238
+ if (resourceCacheTTL !== -1) {
4239
+ this.cache = new ResourceCache(resourceCacheTTL);
4240
+ } else {
4241
+ this.cache = void 0;
4242
+ }
4243
+ } else {
4244
+ this.cache = new ResourceCache(DEFAULT_RESOURCE_CACHE_TTL);
4245
+ }
3956
4246
  }
3957
4247
  /** @hidden */
3958
4248
  static clearChainAndNodeCaches() {
@@ -3996,7 +4286,7 @@ var _Provider = class {
3996
4286
  getChain() {
3997
4287
  const chain = _Provider.chainInfoCache[this.url];
3998
4288
  if (!chain) {
3999
- throw new FuelError13(
4289
+ throw new FuelError14(
4000
4290
  ErrorCode13.CHAIN_INFO_CACHE_EMPTY,
4001
4291
  "Chain info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4002
4292
  );
@@ -4011,7 +4301,7 @@ var _Provider = class {
4011
4301
  getNode() {
4012
4302
  const node = _Provider.nodeInfoCache[this.url];
4013
4303
  if (!node) {
4014
- throw new FuelError13(
4304
+ throw new FuelError14(
4015
4305
  ErrorCode13.NODE_INFO_CACHE_EMPTY,
4016
4306
  "Node info cache is empty. Make sure you have called `Provider.create` to initialize the provider."
4017
4307
  );
@@ -4054,9 +4344,9 @@ var _Provider = class {
4054
4344
  * @returns A promise that resolves to the Chain and NodeInfo.
4055
4345
  */
4056
4346
  async fetchChainAndNodeInfo() {
4057
- const chain = await this.fetchChain();
4058
4347
  const nodeInfo = await this.fetchNode();
4059
4348
  _Provider.ensureClientVersionIsSupported(nodeInfo);
4349
+ const chain = await this.fetchChain();
4060
4350
  return {
4061
4351
  chain,
4062
4352
  nodeInfo
@@ -4090,8 +4380,8 @@ Supported fuel-core version: ${supportedVersion}.`
4090
4380
  if ("response" in response) {
4091
4381
  const graphQlResponse = response.response;
4092
4382
  if (Array.isArray(graphQlResponse?.errors)) {
4093
- throw new FuelError13(
4094
- FuelError13.CODES.INVALID_REQUEST,
4383
+ throw new FuelError14(
4384
+ FuelError14.CODES.INVALID_REQUEST,
4095
4385
  graphQlResponse.errors.map((err) => err.message).join("\n\n")
4096
4386
  );
4097
4387
  }
@@ -4102,7 +4392,7 @@ Supported fuel-core version: ${supportedVersion}.`
4102
4392
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
4103
4393
  const isSubscription = opDefinition?.operation === "subscription";
4104
4394
  if (isSubscription) {
4105
- return new FuelGraphqlSubscriber({
4395
+ return FuelGraphqlSubscriber.create({
4106
4396
  url: this.url,
4107
4397
  query,
4108
4398
  fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
@@ -4183,6 +4473,21 @@ Supported fuel-core version: ${supportedVersion}.`
4183
4473
  } = this.getChain();
4184
4474
  return baseAssetId;
4185
4475
  }
4476
+ validateTransaction(tx, consensusParameters) {
4477
+ const { maxOutputs, maxInputs } = consensusParameters.txParameters;
4478
+ if (bn17(tx.inputs.length).gt(maxInputs)) {
4479
+ throw new FuelError14(
4480
+ ErrorCode13.MAX_INPUTS_EXCEEDED,
4481
+ "The transaction exceeds the maximum allowed number of inputs."
4482
+ );
4483
+ }
4484
+ if (bn17(tx.outputs.length).gt(maxOutputs)) {
4485
+ throw new FuelError14(
4486
+ ErrorCode13.MAX_OUTPUTS_EXCEEDED,
4487
+ "The transaction exceeds the maximum allowed number of outputs."
4488
+ );
4489
+ }
4490
+ }
4186
4491
  /**
4187
4492
  * Submits a transaction to the chain to be executed.
4188
4493
  *
@@ -4194,39 +4499,23 @@ Supported fuel-core version: ${supportedVersion}.`
4194
4499
  * @returns A promise that resolves to the transaction response object.
4195
4500
  */
4196
4501
  // #region Provider-sendTransaction
4197
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution = false } = {}) {
4502
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4198
4503
  const transactionRequest = transactionRequestify(transactionRequestLike);
4199
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs);
4200
4504
  if (estimateTxDependencies) {
4201
4505
  await this.estimateTxDependencies(transactionRequest);
4202
4506
  }
4507
+ const { consensusParameters } = this.getChain();
4508
+ this.validateTransaction(transactionRequest, consensusParameters);
4203
4509
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
4204
4510
  let abis;
4205
- if (transactionRequest.type === TransactionType8.Script) {
4511
+ if (isTransactionTypeScript(transactionRequest)) {
4206
4512
  abis = transactionRequest.abis;
4207
4513
  }
4208
- if (awaitExecution) {
4209
- const subscription = this.operations.submitAndAwait({ encodedTransaction });
4210
- for await (const { submitAndAwait } of subscription) {
4211
- if (submitAndAwait.type === "SqueezedOutStatus") {
4212
- throw new FuelError13(
4213
- ErrorCode13.TRANSACTION_SQUEEZED_OUT,
4214
- `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
4215
- );
4216
- }
4217
- if (submitAndAwait.type !== "SubmittedStatus") {
4218
- break;
4219
- }
4220
- }
4221
- const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
4222
- const response = new TransactionResponse(transactionId2, this, abis);
4223
- await response.fetch();
4224
- return response;
4225
- }
4226
4514
  const {
4227
4515
  submit: { id: transactionId }
4228
4516
  } = await this.operations.submit({ encodedTransaction });
4229
- return new TransactionResponse(transactionId, this, abis);
4517
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
4518
+ return new TransactionResponse(transactionRequest, this, abis);
4230
4519
  }
4231
4520
  /**
4232
4521
  * Executes a transaction without actually submitting it to the chain.
@@ -4263,7 +4552,7 @@ Supported fuel-core version: ${supportedVersion}.`
4263
4552
  async estimatePredicates(transactionRequest) {
4264
4553
  const shouldEstimatePredicates = Boolean(
4265
4554
  transactionRequest.inputs.find(
4266
- (input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN(input.predicateGasUsed).isZero()
4555
+ (input) => "predicate" in input && input.predicate && !equalBytes(arrayify11(input.predicate), arrayify11("0x")) && new BN2(input.predicateGasUsed).isZero()
4267
4556
  )
4268
4557
  );
4269
4558
  if (!shouldEstimatePredicates) {
@@ -4295,7 +4584,7 @@ Supported fuel-core version: ${supportedVersion}.`
4295
4584
  * @returns A promise that resolves to the estimate transaction dependencies.
4296
4585
  */
4297
4586
  async estimateTxDependencies(transactionRequest) {
4298
- if (transactionRequest.type === TransactionType8.Create) {
4587
+ if (isTransactionTypeCreate(transactionRequest)) {
4299
4588
  return {
4300
4589
  receipts: [],
4301
4590
  outputVariables: 0,
@@ -4317,7 +4606,7 @@ Supported fuel-core version: ${supportedVersion}.`
4317
4606
  dryRunStatus = status;
4318
4607
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4319
4608
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4320
- if (hasMissingOutputs) {
4609
+ if (hasMissingOutputs && isTransactionTypeScript(transactionRequest)) {
4321
4610
  outputVariables += missingOutputVariables.length;
4322
4611
  transactionRequest.addVariableOutputs(missingOutputVariables.length);
4323
4612
  missingOutputContractIds.forEach(({ contractId }) => {
@@ -4359,7 +4648,7 @@ Supported fuel-core version: ${supportedVersion}.`
4359
4648
  const allRequests = clone3(transactionRequests);
4360
4649
  const serializedTransactionsMap = /* @__PURE__ */ new Map();
4361
4650
  allRequests.forEach((req, index) => {
4362
- if (req.type === TransactionType8.Script) {
4651
+ if (isTransactionTypeScript(req)) {
4363
4652
  serializedTransactionsMap.set(index, hexlify12(req.toTransactionBytes()));
4364
4653
  }
4365
4654
  });
@@ -4385,7 +4674,7 @@ Supported fuel-core version: ${supportedVersion}.`
4385
4674
  );
4386
4675
  const hasMissingOutputs = missingOutputVariables.length > 0 || missingOutputContractIds.length > 0;
4387
4676
  const request = allRequests[requestIdx];
4388
- if (hasMissingOutputs && request?.type === TransactionType8.Script) {
4677
+ if (hasMissingOutputs && isTransactionTypeScript(request)) {
4389
4678
  result.outputVariables += missingOutputVariables.length;
4390
4679
  request.addVariableOutputs(missingOutputVariables.length);
4391
4680
  missingOutputContractIds.forEach(({ contractId }) => {
@@ -4449,7 +4738,7 @@ Supported fuel-core version: ${supportedVersion}.`
4449
4738
  tip: transactionRequest.tip
4450
4739
  }).add(1);
4451
4740
  let gasLimit = bn17(0);
4452
- if (transactionRequest.type === TransactionType8.Script) {
4741
+ if (isTransactionTypeScript(transactionRequest)) {
4453
4742
  gasLimit = transactionRequest.gasLimit;
4454
4743
  if (transactionRequest.gasLimit.eq(0)) {
4455
4744
  transactionRequest.gasLimit = minGas;
@@ -4504,6 +4793,8 @@ Supported fuel-core version: ${supportedVersion}.`
4504
4793
  return { receipts: callResult[0].receipts };
4505
4794
  }
4506
4795
  /**
4796
+ * @hidden
4797
+ *
4507
4798
  * Returns a transaction cost to enable user
4508
4799
  * to set gasLimit and also reserve balance amounts
4509
4800
  * on the transaction.
@@ -4513,23 +4804,16 @@ Supported fuel-core version: ${supportedVersion}.`
4513
4804
  *
4514
4805
  * @returns A promise that resolves to the transaction cost object.
4515
4806
  */
4516
- async getTransactionCost(transactionRequestLike, { resourcesOwner, signatureCallback, quantitiesToContract = [] } = {}) {
4807
+ async getTransactionCost(transactionRequestLike, { signatureCallback } = {}) {
4517
4808
  const txRequestClone = clone3(transactionRequestify(transactionRequestLike));
4518
- const isScriptTransaction = txRequestClone.type === TransactionType8.Script;
4519
- const baseAssetId = this.getBaseAssetId();
4520
4809
  const updateMaxFee = txRequestClone.maxFee.eq(0);
4521
- const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
4522
- const allQuantities = mergeQuantities(coinOutputsQuantities, quantitiesToContract);
4523
- txRequestClone.fundWithFakeUtxos(allQuantities, baseAssetId, resourcesOwner?.address);
4810
+ const isScriptTransaction = isTransactionTypeScript(txRequestClone);
4524
4811
  if (isScriptTransaction) {
4525
4812
  txRequestClone.gasLimit = bn17(0);
4526
4813
  }
4527
- if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
4528
- resourcesOwner.populateTransactionPredicateData(txRequestClone);
4529
- }
4530
4814
  const signedRequest = clone3(txRequestClone);
4531
4815
  let addedSignatures = 0;
4532
- if (signatureCallback && isScriptTransaction) {
4816
+ if (signatureCallback && isTransactionTypeScript(signedRequest)) {
4533
4817
  const lengthBefore = signedRequest.witnesses.length;
4534
4818
  await signatureCallback(signedRequest);
4535
4819
  addedSignatures = signedRequest.witnesses.length - lengthBefore;
@@ -4562,7 +4846,6 @@ Supported fuel-core version: ${supportedVersion}.`
4562
4846
  }));
4563
4847
  }
4564
4848
  return {
4565
- requiredQuantities: allQuantities,
4566
4849
  receipts,
4567
4850
  gasUsed,
4568
4851
  gasPrice,
@@ -4578,34 +4861,6 @@ Supported fuel-core version: ${supportedVersion}.`
4578
4861
  updateMaxFee
4579
4862
  };
4580
4863
  }
4581
- /**
4582
- * Get the required quantities and associated resources for a transaction.
4583
- *
4584
- * @param owner - address to add resources from.
4585
- * @param transactionRequestLike - transaction request to populate resources for.
4586
- * @param quantitiesToContract - quantities for the contract (optional).
4587
- *
4588
- * @returns a promise resolving to the required quantities for the transaction.
4589
- */
4590
- async getResourcesForTransaction(owner, transactionRequestLike, quantitiesToContract = []) {
4591
- const ownerAddress = Address2.fromAddressOrString(owner);
4592
- const transactionRequest = transactionRequestify(clone3(transactionRequestLike));
4593
- const transactionCost = await this.getTransactionCost(transactionRequest, {
4594
- quantitiesToContract
4595
- });
4596
- transactionRequest.addResources(
4597
- await this.getResourcesToSpend(ownerAddress, transactionCost.requiredQuantities)
4598
- );
4599
- const { requiredQuantities, ...txCost } = await this.getTransactionCost(transactionRequest, {
4600
- quantitiesToContract
4601
- });
4602
- const resources = await this.getResourcesToSpend(ownerAddress, requiredQuantities);
4603
- return {
4604
- resources,
4605
- requiredQuantities,
4606
- ...txCost
4607
- };
4608
- }
4609
4864
  /**
4610
4865
  * Returns coins for the given owner.
4611
4866
  *
@@ -4654,10 +4909,9 @@ Supported fuel-core version: ${supportedVersion}.`
4654
4909
  utxos: excludedIds?.utxos?.map((id) => hexlify12(id)) || []
4655
4910
  };
4656
4911
  if (this.cache) {
4657
- const uniqueUtxos = new Set(
4658
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => hexlify12(id)))
4659
- );
4660
- excludeInput.utxos = Array.from(uniqueUtxos);
4912
+ const cached = this.cache.getActiveData();
4913
+ excludeInput.messages.push(...cached.messages);
4914
+ excludeInput.utxos.push(...cached.utxos);
4661
4915
  }
4662
4916
  const coinsQuery = {
4663
4917
  owner: ownerAddress.toB256(),
@@ -4923,7 +5177,7 @@ Supported fuel-core version: ${supportedVersion}.`
4923
5177
  nonce
4924
5178
  };
4925
5179
  if (commitBlockId && commitBlockHeight) {
4926
- throw new FuelError13(
5180
+ throw new FuelError14(
4927
5181
  ErrorCode13.INVALID_INPUT_PARAMETERS,
4928
5182
  "commitBlockId and commitBlockHeight cannot be used together"
4929
5183
  );
@@ -5092,25 +5346,25 @@ Supported fuel-core version: ${supportedVersion}.`
5092
5346
  const { paginationLimit, inputArgs = {} } = params;
5093
5347
  const { first, last, after, before } = inputArgs;
5094
5348
  if (after && before) {
5095
- throw new FuelError13(
5349
+ throw new FuelError14(
5096
5350
  ErrorCode13.INVALID_INPUT_PARAMETERS,
5097
5351
  'Pagination arguments "after" and "before" cannot be used together'
5098
5352
  );
5099
5353
  }
5100
5354
  if ((first || 0) > paginationLimit || (last || 0) > paginationLimit) {
5101
- throw new FuelError13(
5355
+ throw new FuelError14(
5102
5356
  ErrorCode13.INVALID_INPUT_PARAMETERS,
5103
5357
  `Pagination limit for this query cannot exceed ${paginationLimit} items`
5104
5358
  );
5105
5359
  }
5106
5360
  if (first && before) {
5107
- throw new FuelError13(
5361
+ throw new FuelError14(
5108
5362
  ErrorCode13.INVALID_INPUT_PARAMETERS,
5109
5363
  'The use of pagination argument "first" with "before" is not supported'
5110
5364
  );
5111
5365
  }
5112
5366
  if (last && after) {
5113
- throw new FuelError13(
5367
+ throw new FuelError14(
5114
5368
  ErrorCode13.INVALID_INPUT_PARAMETERS,
5115
5369
  'The use of pagination argument "last" with "after" is not supported'
5116
5370
  );
@@ -5142,15 +5396,22 @@ Supported fuel-core version: ${supportedVersion}.`
5142
5396
  };
5143
5397
  var Provider = _Provider;
5144
5398
  _cacheInputs = new WeakSet();
5145
- cacheInputs_fn = function(inputs) {
5399
+ cacheInputs_fn = function(inputs, transactionId) {
5146
5400
  if (!this.cache) {
5147
5401
  return;
5148
5402
  }
5149
- inputs.forEach((input) => {
5150
- if (input.type === InputType7.Coin) {
5151
- this.cache?.set(input.id);
5152
- }
5153
- });
5403
+ const inputsToCache = inputs.reduce(
5404
+ (acc, input) => {
5405
+ if (input.type === InputType7.Coin) {
5406
+ acc.utxos.push(input.id);
5407
+ } else if (input.type === InputType7.Message) {
5408
+ acc.messages.push(input.nonce);
5409
+ }
5410
+ return acc;
5411
+ },
5412
+ { utxos: [], messages: [] }
5413
+ );
5414
+ this.cache.set(transactionId, inputsToCache);
5154
5415
  };
5155
5416
  /** @hidden */
5156
5417
  __publicField(Provider, "chainInfoCache", {});
@@ -5158,7 +5419,7 @@ __publicField(Provider, "chainInfoCache", {});
5158
5419
  __publicField(Provider, "nodeInfoCache", {});
5159
5420
 
5160
5421
  // src/providers/transaction-summary/get-transaction-summary.ts
5161
- import { ErrorCode as ErrorCode14, FuelError as FuelError14 } from "@fuel-ts/errors";
5422
+ import { ErrorCode as ErrorCode14, FuelError as FuelError15 } from "@fuel-ts/errors";
5162
5423
  import { bn as bn18 } from "@fuel-ts/math";
5163
5424
  import { TransactionCoder as TransactionCoder6 } from "@fuel-ts/transactions";
5164
5425
  import { arrayify as arrayify12 } from "@fuel-ts/utils";
@@ -5168,7 +5429,7 @@ async function getTransactionSummary(params) {
5168
5429
  transactionId: id
5169
5430
  });
5170
5431
  if (!gqlTransaction) {
5171
- throw new FuelError14(
5432
+ throw new FuelError15(
5172
5433
  ErrorCode14.TRANSACTION_NOT_FOUND,
5173
5434
  `Transaction not found for given id: ${id}.`
5174
5435
  );
@@ -5207,7 +5468,6 @@ async function getTransactionSummary(params) {
5207
5468
  baseAssetId
5208
5469
  });
5209
5470
  return {
5210
- gqlTransaction,
5211
5471
  ...transactionInfo
5212
5472
  };
5213
5473
  }
@@ -5221,6 +5481,7 @@ async function getTransactionSummaryFromRequest(params) {
5221
5481
  const gasPrice = await provider.getLatestGasPrice();
5222
5482
  const baseAssetId = provider.getBaseAssetId();
5223
5483
  const transactionSummary = assembleTransactionSummary({
5484
+ id: transactionRequest.getTransactionId(provider.getChainId()),
5224
5485
  receipts,
5225
5486
  transaction,
5226
5487
  transactionBytes,
@@ -5273,7 +5534,6 @@ async function getTransactionsSummaries(params) {
5273
5534
  baseAssetId
5274
5535
  });
5275
5536
  const output = {
5276
- gqlTransaction,
5277
5537
  ...transactionSummary
5278
5538
  };
5279
5539
  return output;
@@ -5409,15 +5669,29 @@ var rawAssets = [
5409
5669
  ];
5410
5670
  var assets = resolveIconPaths(rawAssets, fuelAssetsBaseUrl);
5411
5671
 
5672
+ // src/providers/utils/merge-quantities.ts
5673
+ var mergeQuantities = (...coinQuantities) => {
5674
+ const resultMap = {};
5675
+ function addToMap({ amount, assetId }) {
5676
+ if (resultMap[assetId]) {
5677
+ resultMap[assetId] = resultMap[assetId].add(amount);
5678
+ } else {
5679
+ resultMap[assetId] = amount;
5680
+ }
5681
+ }
5682
+ coinQuantities.forEach((arr) => arr.forEach(addToMap));
5683
+ return Object.entries(resultMap).map(([assetId, amount]) => ({ assetId, amount }));
5684
+ };
5685
+
5412
5686
  // src/utils/formatTransferToContractScriptData.ts
5413
5687
  import { BigNumberCoder as BigNumberCoder2 } from "@fuel-ts/abi-coder";
5414
- import { BN as BN2 } from "@fuel-ts/math";
5688
+ import { BN as BN3 } from "@fuel-ts/math";
5415
5689
  import { arrayify as arrayify13 } from "@fuel-ts/utils";
5416
5690
  import * as asm from "@fuels/vm-asm";
5417
5691
  var formatTransferToContractScriptData = (params) => {
5418
5692
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
5419
5693
  const numberCoder = new BigNumberCoder2("u64");
5420
- const encoded = numberCoder.encode(new BN2(amountToTransfer).toNumber());
5694
+ const encoded = numberCoder.encode(new BN3(amountToTransfer).toNumber());
5421
5695
  const scriptData = Uint8Array.from([
5422
5696
  ...arrayify13(hexlifiedContractId),
5423
5697
  ...encoded,
@@ -5446,7 +5720,7 @@ var assembleTransferToContractScript = async (params) => {
5446
5720
  };
5447
5721
 
5448
5722
  // src/account.ts
5449
- var MAX_FUNDING_ATTEMPTS = 2;
5723
+ var MAX_FUNDING_ATTEMPTS = 5;
5450
5724
  var Account = class extends AbstractAccount {
5451
5725
  /**
5452
5726
  * The address associated with the account.
@@ -5482,7 +5756,7 @@ var Account = class extends AbstractAccount {
5482
5756
  */
5483
5757
  get provider() {
5484
5758
  if (!this._provider) {
5485
- throw new FuelError15(ErrorCode15.MISSING_PROVIDER, "Provider not set");
5759
+ throw new FuelError16(ErrorCode15.MISSING_PROVIDER, "Provider not set");
5486
5760
  }
5487
5761
  return this._provider;
5488
5762
  }
@@ -5559,7 +5833,7 @@ var Account = class extends AbstractAccount {
5559
5833
  * @returns A promise that resolves to the funded transaction request.
5560
5834
  */
5561
5835
  async fund(request, params) {
5562
- const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee } = params;
5836
+ const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
5563
5837
  const fee = request.maxFee;
5564
5838
  const baseAssetId = this.provider.getBaseAssetId();
5565
5839
  const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || bn19(0);
@@ -5607,10 +5881,12 @@ var Account = class extends AbstractAccount {
5607
5881
  );
5608
5882
  }
5609
5883
  if (!updateMaxFee) {
5884
+ needsToBeFunded = false;
5610
5885
  break;
5611
5886
  }
5612
5887
  const { maxFee: newFee } = await this.provider.estimateTxGasAndFee({
5613
- transactionRequest: requestToReestimate2
5888
+ transactionRequest: requestToReestimate2,
5889
+ gasPrice
5614
5890
  });
5615
5891
  const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
5616
5892
  request.inputs,
@@ -5630,6 +5906,12 @@ var Account = class extends AbstractAccount {
5630
5906
  }
5631
5907
  fundingAttempts += 1;
5632
5908
  }
5909
+ if (needsToBeFunded) {
5910
+ throw new FuelError16(
5911
+ ErrorCode15.NOT_ENOUGH_FUNDS,
5912
+ `The account ${this.address} does not have enough base asset funds to cover the transaction execution.`
5913
+ );
5914
+ }
5633
5915
  request.updatePredicateGasUsed(estimatedPredicates);
5634
5916
  const requestToReestimate = clone4(request);
5635
5917
  if (addedSignatures) {
@@ -5731,7 +6013,7 @@ var Account = class extends AbstractAccount {
5731
6013
  */
5732
6014
  async transferToContract(contractId, amount, assetId, txParams = {}) {
5733
6015
  if (bn19(amount).lte(0)) {
5734
- throw new FuelError15(
6016
+ throw new FuelError16(
5735
6017
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5736
6018
  "Transfer amount must be a positive number."
5737
6019
  );
@@ -5749,9 +6031,8 @@ var Account = class extends AbstractAccount {
5749
6031
  scriptData
5750
6032
  });
5751
6033
  request.addContractInputAndOutput(contractAddress);
5752
- const txCost = await this.provider.getTransactionCost(request, {
5753
- resourcesOwner: this,
5754
- quantitiesToContract: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
6034
+ const txCost = await this.getTransactionCost(request, {
6035
+ quantities: [{ amount: bn19(amount), assetId: String(assetIdToTransfer) }]
5755
6036
  });
5756
6037
  request = this.validateGasLimitAndMaxFee({
5757
6038
  transactionRequest: request,
@@ -5786,8 +6067,8 @@ var Account = class extends AbstractAccount {
5786
6067
  const params = { script, ...txParams };
5787
6068
  const baseAssetId = this.provider.getBaseAssetId();
5788
6069
  let request = new ScriptTransactionRequest(params);
5789
- const quantitiesToContract = [{ amount: bn19(amount), assetId: baseAssetId }];
5790
- const txCost = await this.provider.getTransactionCost(request, { quantitiesToContract });
6070
+ const quantities = [{ amount: bn19(amount), assetId: baseAssetId }];
6071
+ const txCost = await this.getTransactionCost(request, { quantities });
5791
6072
  request = this.validateGasLimitAndMaxFee({
5792
6073
  transactionRequest: request,
5793
6074
  gasUsed: txCost.gasUsed,
@@ -5797,6 +6078,58 @@ var Account = class extends AbstractAccount {
5797
6078
  await this.fund(request, txCost);
5798
6079
  return this.sendTransaction(request);
5799
6080
  }
6081
+ /**
6082
+ * Returns a transaction cost to enable user
6083
+ * to set gasLimit and also reserve balance amounts
6084
+ * on the transaction.
6085
+ *
6086
+ * @param transactionRequestLike - The transaction request object.
6087
+ * @param transactionCostParams - The transaction cost parameters (optional).
6088
+ *
6089
+ * @returns A promise that resolves to the transaction cost object.
6090
+ */
6091
+ async getTransactionCost(transactionRequestLike, { signatureCallback, quantities = [] } = {}) {
6092
+ const txRequestClone = clone4(transactionRequestify(transactionRequestLike));
6093
+ const baseAssetId = this.provider.getBaseAssetId();
6094
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
6095
+ const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
6096
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn19("100000000000000000") }];
6097
+ const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
6098
+ if ("assetId" in input) {
6099
+ return input.assetId === assetId;
6100
+ }
6101
+ if ("recipient" in input) {
6102
+ return baseAssetId === assetId;
6103
+ }
6104
+ return false;
6105
+ });
6106
+ const updateAssetInput = (assetId, quantity) => {
6107
+ const assetInput = findAssetInput(assetId);
6108
+ const usedQuantity = quantity;
6109
+ if (assetInput && "amount" in assetInput) {
6110
+ assetInput.amount = usedQuantity;
6111
+ } else {
6112
+ txRequestClone.addResources(
6113
+ this.generateFakeResources([
6114
+ {
6115
+ amount: quantity,
6116
+ assetId
6117
+ }
6118
+ ])
6119
+ );
6120
+ }
6121
+ };
6122
+ mergeQuantities(requiredQuantities, transactionFeeForDryRun).forEach(
6123
+ ({ amount, assetId }) => updateAssetInput(assetId, amount)
6124
+ );
6125
+ const txCost = await this.provider.getTransactionCost(txRequestClone, {
6126
+ signatureCallback
6127
+ });
6128
+ return {
6129
+ ...txCost,
6130
+ requiredQuantities
6131
+ };
6132
+ }
5800
6133
  /**
5801
6134
  * Sign a message from the account via the connector.
5802
6135
  *
@@ -5807,7 +6140,7 @@ var Account = class extends AbstractAccount {
5807
6140
  */
5808
6141
  async signMessage(message) {
5809
6142
  if (!this._connector) {
5810
- throw new FuelError15(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
6143
+ throw new FuelError16(ErrorCode15.MISSING_CONNECTOR, "A connector is required to sign messages.");
5811
6144
  }
5812
6145
  return this._connector.signMessage(this.address.toString(), message);
5813
6146
  }
@@ -5819,7 +6152,7 @@ var Account = class extends AbstractAccount {
5819
6152
  */
5820
6153
  async signTransaction(transactionRequestLike) {
5821
6154
  if (!this._connector) {
5822
- throw new FuelError15(
6155
+ throw new FuelError16(
5823
6156
  ErrorCode15.MISSING_CONNECTOR,
5824
6157
  "A connector is required to sign transactions."
5825
6158
  );
@@ -5833,7 +6166,7 @@ var Account = class extends AbstractAccount {
5833
6166
  * @param sendTransactionParams - The provider send transaction parameters (optional).
5834
6167
  * @returns A promise that resolves to the transaction response.
5835
6168
  */
5836
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
6169
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
5837
6170
  if (this._connector) {
5838
6171
  return this.provider.getTransactionResponse(
5839
6172
  await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
@@ -5844,7 +6177,6 @@ var Account = class extends AbstractAccount {
5844
6177
  await this.provider.estimateTxDependencies(transactionRequest);
5845
6178
  }
5846
6179
  return this.provider.sendTransaction(transactionRequest, {
5847
- awaitExecution,
5848
6180
  estimateTxDependencies: false
5849
6181
  });
5850
6182
  }
@@ -5880,7 +6212,7 @@ var Account = class extends AbstractAccount {
5880
6212
  /** @hidden * */
5881
6213
  validateTransferAmount(amount) {
5882
6214
  if (bn19(amount).lte(0)) {
5883
- throw new FuelError15(
6215
+ throw new FuelError16(
5884
6216
  ErrorCode15.INVALID_TRANSFER_AMOUNT,
5885
6217
  "Transfer amount must be a positive number."
5886
6218
  );
@@ -5889,9 +6221,7 @@ var Account = class extends AbstractAccount {
5889
6221
  /** @hidden * */
5890
6222
  async estimateAndFundTransaction(transactionRequest, txParams) {
5891
6223
  let request = transactionRequest;
5892
- const txCost = await this.provider.getTransactionCost(request, {
5893
- resourcesOwner: this
5894
- });
6224
+ const txCost = await this.getTransactionCost(request);
5895
6225
  request = this.validateGasLimitAndMaxFee({
5896
6226
  transactionRequest: request,
5897
6227
  gasUsed: txCost.gasUsed,
@@ -5909,18 +6239,18 @@ var Account = class extends AbstractAccount {
5909
6239
  txParams: { gasLimit: setGasLimit, maxFee: setMaxFee }
5910
6240
  }) {
5911
6241
  const request = transactionRequestify(transactionRequest);
5912
- if (!isDefined2(setGasLimit)) {
6242
+ if (!isDefined3(setGasLimit)) {
5913
6243
  request.gasLimit = gasUsed;
5914
6244
  } else if (gasUsed.gt(setGasLimit)) {
5915
- throw new FuelError15(
6245
+ throw new FuelError16(
5916
6246
  ErrorCode15.GAS_LIMIT_TOO_LOW,
5917
6247
  `Gas limit '${setGasLimit}' is lower than the required: '${gasUsed}'.`
5918
6248
  );
5919
6249
  }
5920
- if (!isDefined2(setMaxFee)) {
6250
+ if (!isDefined3(setMaxFee)) {
5921
6251
  request.maxFee = maxFee;
5922
6252
  } else if (maxFee.gt(setMaxFee)) {
5923
- throw new FuelError15(
6253
+ throw new FuelError16(
5924
6254
  ErrorCode15.MAX_FEE_TOO_LOW,
5925
6255
  `Max fee '${setMaxFee}' is lower than the required: '${maxFee}'.`
5926
6256
  );
@@ -6051,11 +6381,11 @@ import {
6051
6381
  scrypt,
6052
6382
  stringFromBuffer,
6053
6383
  decryptJsonWalletData,
6054
- encryptJsonWalletData
6384
+ encryptJsonWalletData,
6385
+ randomUUID
6055
6386
  } from "@fuel-ts/crypto";
6056
- import { ErrorCode as ErrorCode16, FuelError as FuelError16 } from "@fuel-ts/errors";
6387
+ import { ErrorCode as ErrorCode16, FuelError as FuelError17 } from "@fuel-ts/errors";
6057
6388
  import { hexlify as hexlify15 } from "@fuel-ts/utils";
6058
- import { v4 as uuidv4 } from "uuid";
6059
6389
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
6060
6390
  var DEFAULT_KDF_PARAMS_R = 8;
6061
6391
  var DEFAULT_KDF_PARAMS_P = 1;
@@ -6085,7 +6415,7 @@ async function encryptKeystoreWallet(privateKey, address, password) {
6085
6415
  const macHashUint8Array = keccak256(data);
6086
6416
  const mac = stringFromBuffer(macHashUint8Array, "hex");
6087
6417
  const keystore = {
6088
- id: uuidv4(),
6418
+ id: randomUUID(),
6089
6419
  version: 3,
6090
6420
  address: removeHexPrefix(ownerAddress.toHexString()),
6091
6421
  crypto: {
@@ -6131,7 +6461,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
6131
6461
  const macHashUint8Array = keccak256(data);
6132
6462
  const macHash = stringFromBuffer(macHashUint8Array, "hex");
6133
6463
  if (mac !== macHash) {
6134
- throw new FuelError16(
6464
+ throw new FuelError17(
6135
6465
  ErrorCode16.INVALID_PASSWORD,
6136
6466
  "Failed to decrypt the keystore wallet, the provided password is incorrect."
6137
6467
  );
@@ -6214,17 +6544,16 @@ var BaseWalletUnlocked = class extends Account {
6214
6544
  *
6215
6545
  * @param transactionRequestLike - The transaction request to send.
6216
6546
  * @param estimateTxDependencies - Whether to estimate the transaction dependencies.
6217
- * @param awaitExecution - Whether to wait for the transaction to be executed.
6218
6547
  * @returns A promise that resolves to the TransactionResponse object.
6219
6548
  */
6220
- async sendTransaction(transactionRequestLike, { estimateTxDependencies = false, awaitExecution } = {}) {
6549
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = false } = {}) {
6221
6550
  const transactionRequest = transactionRequestify(transactionRequestLike);
6222
6551
  if (estimateTxDependencies) {
6223
6552
  await this.provider.estimateTxDependencies(transactionRequest);
6224
6553
  }
6225
6554
  return this.provider.sendTransaction(
6226
6555
  await this.populateTransactionWitnessesSignature(transactionRequest),
6227
- { awaitExecution, estimateTxDependencies: false }
6556
+ { estimateTxDependencies: false }
6228
6557
  );
6229
6558
  }
6230
6559
  /**
@@ -6263,14 +6592,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
6263
6592
 
6264
6593
  // src/hdwallet/hdwallet.ts
6265
6594
  import { computeHmac as computeHmac2, ripemd160 } from "@fuel-ts/crypto";
6266
- import { ErrorCode as ErrorCode19, FuelError as FuelError19 } from "@fuel-ts/errors";
6595
+ import { ErrorCode as ErrorCode19, FuelError as FuelError20 } from "@fuel-ts/errors";
6267
6596
  import { sha256 as sha2564 } from "@fuel-ts/hasher";
6268
6597
  import { bn as bn20, toBytes as toBytes2, toHex } from "@fuel-ts/math";
6269
6598
  import { arrayify as arrayify18, hexlify as hexlify18, concat as concat5, dataSlice as dataSlice2, encodeBase58 as encodeBase582, decodeBase58 } from "@fuel-ts/utils";
6270
6599
 
6271
6600
  // src/mnemonic/mnemonic.ts
6272
6601
  import { randomBytes as randomBytes5, pbkdf2, computeHmac } from "@fuel-ts/crypto";
6273
- import { ErrorCode as ErrorCode18, FuelError as FuelError18 } from "@fuel-ts/errors";
6602
+ import { ErrorCode as ErrorCode18, FuelError as FuelError19 } from "@fuel-ts/errors";
6274
6603
  import { sha256 as sha2563 } from "@fuel-ts/hasher";
6275
6604
  import { arrayify as arrayify17, hexlify as hexlify17, concat as concat4, dataSlice, encodeBase58, toUtf8Bytes } from "@fuel-ts/utils";
6276
6605
 
@@ -8333,7 +8662,7 @@ var Language = /* @__PURE__ */ ((Language2) => {
8333
8662
  })(Language || {});
8334
8663
 
8335
8664
  // src/mnemonic/utils.ts
8336
- import { ErrorCode as ErrorCode17, FuelError as FuelError17 } from "@fuel-ts/errors";
8665
+ import { ErrorCode as ErrorCode17, FuelError as FuelError18 } from "@fuel-ts/errors";
8337
8666
  import { sha256 as sha2562 } from "@fuel-ts/hasher";
8338
8667
  import { arrayify as arrayify16 } from "@fuel-ts/utils";
8339
8668
  function getLowerMask(bits) {
@@ -8382,7 +8711,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8382
8711
  for (let i = 0; i < words.length; i += 1) {
8383
8712
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
8384
8713
  if (index === -1) {
8385
- throw new FuelError17(
8714
+ throw new FuelError18(
8386
8715
  ErrorCode17.INVALID_MNEMONIC,
8387
8716
  `Invalid mnemonic: the word '${words[i]}' is not found in the provided wordlist.`
8388
8717
  );
@@ -8399,7 +8728,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
8399
8728
  const checksumMask = getUpperMask(checksumBits);
8400
8729
  const checksum = arrayify16(sha2562(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
8401
8730
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
8402
- throw new FuelError17(
8731
+ throw new FuelError18(
8403
8732
  ErrorCode17.INVALID_CHECKSUM,
8404
8733
  "Checksum validation failed for the provided mnemonic."
8405
8734
  );
@@ -8414,7 +8743,7 @@ var TestnetPRV = "0x04358394";
8414
8743
  var MNEMONIC_SIZES = [12, 15, 18, 21, 24];
8415
8744
  function assertWordList(wordlist) {
8416
8745
  if (wordlist.length !== 2048) {
8417
- throw new FuelError18(
8746
+ throw new FuelError19(
8418
8747
  ErrorCode18.INVALID_WORD_LIST,
8419
8748
  `Expected word list length of 2048, but got ${wordlist.length}.`
8420
8749
  );
@@ -8422,7 +8751,7 @@ function assertWordList(wordlist) {
8422
8751
  }
8423
8752
  function assertEntropy(entropy) {
8424
8753
  if (entropy.length % 4 !== 0 || entropy.length < 16 || entropy.length > 32) {
8425
- throw new FuelError18(
8754
+ throw new FuelError19(
8426
8755
  ErrorCode18.INVALID_ENTROPY,
8427
8756
  `Entropy should be between 16 and 32 bytes and a multiple of 4, but got ${entropy.length} bytes.`
8428
8757
  );
@@ -8433,7 +8762,7 @@ function assertMnemonic(words) {
8433
8762
  const errorMsg = `Invalid mnemonic size. Expected one of [${MNEMONIC_SIZES.join(
8434
8763
  ", "
8435
8764
  )}] words, but got ${words.length}.`;
8436
- throw new FuelError18(ErrorCode18.INVALID_MNEMONIC, errorMsg);
8765
+ throw new FuelError19(ErrorCode18.INVALID_MNEMONIC, errorMsg);
8437
8766
  }
8438
8767
  }
8439
8768
  var Mnemonic = class {
@@ -8551,7 +8880,7 @@ var Mnemonic = class {
8551
8880
  static masterKeysFromSeed(seed) {
8552
8881
  const seedArray = arrayify17(seed);
8553
8882
  if (seedArray.length < 16 || seedArray.length > 64) {
8554
- throw new FuelError18(
8883
+ throw new FuelError19(
8555
8884
  ErrorCode18.INVALID_SEED,
8556
8885
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
8557
8886
  );
@@ -8629,7 +8958,7 @@ function isValidExtendedKey(extendedKey) {
8629
8958
  function parsePath(path, depth = 0) {
8630
8959
  const components = path.split("/");
8631
8960
  if (components.length === 0 || components[0] === "m" && depth !== 0) {
8632
- throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
8961
+ throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, `invalid path - ${path}`);
8633
8962
  }
8634
8963
  if (components[0] === "m") {
8635
8964
  components.shift();
@@ -8658,7 +8987,7 @@ var HDWallet = class {
8658
8987
  this.privateKey = hexlify18(config.privateKey);
8659
8988
  } else {
8660
8989
  if (!config.publicKey) {
8661
- throw new FuelError19(
8990
+ throw new FuelError20(
8662
8991
  ErrorCode19.HD_WALLET_ERROR,
8663
8992
  "Both public and private Key cannot be missing. At least one should be provided."
8664
8993
  );
@@ -8688,7 +9017,7 @@ var HDWallet = class {
8688
9017
  const data = new Uint8Array(37);
8689
9018
  if (index & HARDENED_INDEX) {
8690
9019
  if (!privateKey) {
8691
- throw new FuelError19(
9020
+ throw new FuelError20(
8692
9021
  ErrorCode19.HD_WALLET_ERROR,
8693
9022
  "Cannot derive a hardened index without a private Key."
8694
9023
  );
@@ -8741,7 +9070,7 @@ var HDWallet = class {
8741
9070
  */
8742
9071
  toExtendedKey(isPublic = false, testnet = false) {
8743
9072
  if (this.depth >= 256) {
8744
- throw new FuelError19(
9073
+ throw new FuelError20(
8745
9074
  ErrorCode19.HD_WALLET_ERROR,
8746
9075
  `Exceeded max depth of 255. Current depth: ${this.depth}.`
8747
9076
  );
@@ -8773,10 +9102,10 @@ var HDWallet = class {
8773
9102
  const bytes = arrayify18(decoded);
8774
9103
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8775
9104
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
8776
- throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
9105
+ throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
8777
9106
  }
8778
9107
  if (!validChecksum) {
8779
- throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
9108
+ throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
8780
9109
  }
8781
9110
  const depth = bytes[4];
8782
9111
  const parentFingerprint = hexlify18(bytes.slice(5, 9));
@@ -8784,14 +9113,14 @@ var HDWallet = class {
8784
9113
  const chainCode = hexlify18(bytes.slice(13, 45));
8785
9114
  const key = bytes.slice(45, 78);
8786
9115
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
8787
- throw new FuelError19(
9116
+ throw new FuelError20(
8788
9117
  ErrorCode19.HD_WALLET_ERROR,
8789
9118
  "Inconsistency detected: Depth is zero but fingerprint/index is non-zero."
8790
9119
  );
8791
9120
  }
8792
9121
  if (isPublicExtendedKey(bytes)) {
8793
9122
  if (key[0] !== 3) {
8794
- throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
9123
+ throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid public extended key.");
8795
9124
  }
8796
9125
  return new HDWallet({
8797
9126
  publicKey: key,
@@ -8802,7 +9131,7 @@ var HDWallet = class {
8802
9131
  });
8803
9132
  }
8804
9133
  if (key[0] !== 0) {
8805
- throw new FuelError19(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
9134
+ throw new FuelError20(ErrorCode19.HD_WALLET_ERROR, "Invalid private extended key.");
8806
9135
  }
8807
9136
  return new HDWallet({
8808
9137
  privateKey: key.slice(1),
@@ -8970,7 +9299,7 @@ __publicField(Wallet, "fromEncryptedJson", WalletUnlocked.fromEncryptedJson);
8970
9299
  // src/wallet-manager/wallet-manager.ts
8971
9300
  import { Address as Address8 } from "@fuel-ts/address";
8972
9301
  import { encrypt, decrypt } from "@fuel-ts/crypto";
8973
- import { ErrorCode as ErrorCode22, FuelError as FuelError22 } from "@fuel-ts/errors";
9302
+ import { ErrorCode as ErrorCode22, FuelError as FuelError23 } from "@fuel-ts/errors";
8974
9303
  import { EventEmitter } from "events";
8975
9304
 
8976
9305
  // src/wallet-manager/storages/memory-storage.ts
@@ -8993,7 +9322,7 @@ var MemoryStorage = class {
8993
9322
 
8994
9323
  // src/wallet-manager/vaults/mnemonic-vault.ts
8995
9324
  import { Address as Address6 } from "@fuel-ts/address";
8996
- import { ErrorCode as ErrorCode20, FuelError as FuelError20 } from "@fuel-ts/errors";
9325
+ import { ErrorCode as ErrorCode20, FuelError as FuelError21 } from "@fuel-ts/errors";
8997
9326
  var _secret;
8998
9327
  var MnemonicVault = class {
8999
9328
  constructor(options) {
@@ -9049,7 +9378,7 @@ var MnemonicVault = class {
9049
9378
  }
9050
9379
  numberOfAccounts += 1;
9051
9380
  } while (numberOfAccounts < this.numberOfAccounts);
9052
- throw new FuelError20(
9381
+ throw new FuelError21(
9053
9382
  ErrorCode20.WALLET_MANAGER_ERROR,
9054
9383
  `Account with address '${address}' not found in derived wallets.`
9055
9384
  );
@@ -9064,7 +9393,7 @@ __publicField(MnemonicVault, "type", "mnemonic");
9064
9393
 
9065
9394
  // src/wallet-manager/vaults/privatekey-vault.ts
9066
9395
  import { Address as Address7 } from "@fuel-ts/address";
9067
- import { ErrorCode as ErrorCode21, FuelError as FuelError21 } from "@fuel-ts/errors";
9396
+ import { ErrorCode as ErrorCode21, FuelError as FuelError22 } from "@fuel-ts/errors";
9068
9397
  var _privateKeys;
9069
9398
  var PrivateKeyVault = class {
9070
9399
  /**
@@ -9105,7 +9434,7 @@ var PrivateKeyVault = class {
9105
9434
  (pk) => Wallet.fromPrivateKey(pk).address.equals(ownerAddress)
9106
9435
  );
9107
9436
  if (!privateKey) {
9108
- throw new FuelError21(
9437
+ throw new FuelError22(
9109
9438
  ErrorCode21.WALLET_MANAGER_ERROR,
9110
9439
  `No private key found for address '${address}'.`
9111
9440
  );
@@ -9130,7 +9459,7 @@ var ERROR_MESSAGES = {
9130
9459
  };
9131
9460
  function assert(condition, message) {
9132
9461
  if (!condition) {
9133
- throw new FuelError22(ErrorCode22.WALLET_MANAGER_ERROR, message);
9462
+ throw new FuelError23(ErrorCode22.WALLET_MANAGER_ERROR, message);
9134
9463
  }
9135
9464
  }
9136
9465
  var _vaults, _passphrase, _isLocked, _serializeVaults, serializeVaults_fn, _deserializeVaults, deserializeVaults_fn;
@@ -9356,25 +9685,25 @@ deserializeVaults_fn = function(vaults) {
9356
9685
  __publicField(WalletManager, "Vaults", [MnemonicVault, PrivateKeyVault]);
9357
9686
 
9358
9687
  // src/wallet-manager/types.ts
9359
- import { ErrorCode as ErrorCode23, FuelError as FuelError23 } from "@fuel-ts/errors";
9688
+ import { ErrorCode as ErrorCode23, FuelError as FuelError24 } from "@fuel-ts/errors";
9360
9689
  var Vault = class {
9361
9690
  constructor(_options) {
9362
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9691
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9363
9692
  }
9364
9693
  serialize() {
9365
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9694
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9366
9695
  }
9367
9696
  getAccounts() {
9368
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9697
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9369
9698
  }
9370
9699
  addAccount() {
9371
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9700
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9372
9701
  }
9373
9702
  exportAccount(_address) {
9374
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9703
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9375
9704
  }
9376
9705
  getWallet(_address) {
9377
- throw new FuelError23(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9706
+ throw new FuelError24(ErrorCode23.NOT_IMPLEMENTED, "Not implemented.");
9378
9707
  }
9379
9708
  };
9380
9709
  __publicField(Vault, "type");
@@ -9384,7 +9713,7 @@ var StorageAbstract = class {
9384
9713
  // src/predicate/predicate.ts
9385
9714
  import { Interface as Interface4 } from "@fuel-ts/abi-coder";
9386
9715
  import { Address as Address9 } from "@fuel-ts/address";
9387
- import { ErrorCode as ErrorCode24, FuelError as FuelError24 } from "@fuel-ts/errors";
9716
+ import { ErrorCode as ErrorCode24, FuelError as FuelError25 } from "@fuel-ts/errors";
9388
9717
  import { arrayify as arrayify20, hexlify as hexlify20 } from "@fuel-ts/utils";
9389
9718
 
9390
9719
  // src/predicate/utils/getPredicateRoot.ts
@@ -9411,14 +9740,14 @@ var Predicate = class extends Account {
9411
9740
  * @param bytecode - The bytecode of the predicate.
9412
9741
  * @param abi - The JSON ABI of the predicate.
9413
9742
  * @param provider - The provider used to interact with the blockchain.
9414
- * @param inputData - The predicate input data (optional).
9743
+ * @param data - The predicate input data (optional).
9415
9744
  * @param configurableConstants - Optional configurable constants for the predicate.
9416
9745
  */
9417
9746
  constructor({
9418
9747
  bytecode,
9419
9748
  abi,
9420
9749
  provider,
9421
- inputData,
9750
+ data,
9422
9751
  configurableConstants
9423
9752
  }) {
9424
9753
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
@@ -9430,8 +9759,8 @@ var Predicate = class extends Account {
9430
9759
  super(address, provider);
9431
9760
  this.bytes = predicateBytes;
9432
9761
  this.interface = predicateInterface;
9433
- if (inputData !== void 0 && inputData.length > 0) {
9434
- this.predicateData = inputData;
9762
+ if (data !== void 0 && data.length > 0) {
9763
+ this.predicateData = data;
9435
9764
  }
9436
9765
  }
9437
9766
  /**
@@ -9496,7 +9825,7 @@ var Predicate = class extends Account {
9496
9825
  if (jsonAbi) {
9497
9826
  abiInterface = new Interface4(jsonAbi);
9498
9827
  if (abiInterface.functions.main === void 0) {
9499
- throw new FuelError24(
9828
+ throw new FuelError25(
9500
9829
  ErrorCode24.ABI_MAIN_METHOD_MISSING,
9501
9830
  'Cannot use ABI without "main" function.'
9502
9831
  );
@@ -9558,23 +9887,30 @@ var Predicate = class extends Account {
9558
9887
  const mutatedBytes = bytes;
9559
9888
  try {
9560
9889
  if (!abiInterface) {
9561
- throw new Error(
9890
+ throw new FuelError25(
9891
+ ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
9562
9892
  "Cannot validate configurable constants because the Predicate was instantiated without a JSON ABI"
9563
9893
  );
9564
9894
  }
9565
9895
  if (Object.keys(abiInterface.configurables).length === 0) {
9566
- throw new Error("Predicate has no configurable constants to be set");
9896
+ throw new FuelError25(
9897
+ ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
9898
+ "Predicate has no configurable constants to be set"
9899
+ );
9567
9900
  }
9568
9901
  Object.entries(configurableConstants).forEach(([key, value]) => {
9569
9902
  if (!abiInterface?.configurables[key]) {
9570
- throw new Error(`No configurable constant named '${key}' found in the Predicate`);
9903
+ throw new FuelError25(
9904
+ ErrorCode24.CONFIGURABLE_NOT_FOUND,
9905
+ `No configurable constant named '${key}' found in the Predicate`
9906
+ );
9571
9907
  }
9572
9908
  const { offset } = abiInterface.configurables[key];
9573
9909
  const encoded = abiInterface.encodeConfigurable(key, value);
9574
9910
  mutatedBytes.set(encoded, offset);
9575
9911
  });
9576
9912
  } catch (err) {
9577
- throw new FuelError24(
9913
+ throw new FuelError25(
9578
9914
  ErrorCode24.INVALID_CONFIGURABLE_CONSTANTS,
9579
9915
  `Error setting configurable constants: ${err.message}.`
9580
9916
  );
@@ -9606,9 +9942,10 @@ var Predicate = class extends Account {
9606
9942
  };
9607
9943
 
9608
9944
  // src/connectors/fuel.ts
9609
- import { ErrorCode as ErrorCode25, FuelError as FuelError25 } from "@fuel-ts/errors";
9945
+ import { ErrorCode as ErrorCode25, FuelError as FuelError28 } from "@fuel-ts/errors";
9610
9946
 
9611
9947
  // src/connectors/fuel-connector.ts
9948
+ import { FuelError as FuelError26 } from "@fuel-ts/errors";
9612
9949
  import { EventEmitter as EventEmitter2 } from "events";
9613
9950
 
9614
9951
  // src/connectors/types/connector-types.ts
@@ -9682,7 +10019,7 @@ var FuelConnector = class extends EventEmitter2 {
9682
10019
  * @returns Always true.
9683
10020
  */
9684
10021
  async ping() {
9685
- throw new Error("Method not implemented.");
10022
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9686
10023
  }
9687
10024
  /**
9688
10025
  * Should return the current version of the connector
@@ -9691,7 +10028,7 @@ var FuelConnector = class extends EventEmitter2 {
9691
10028
  * @returns boolean - connection status.
9692
10029
  */
9693
10030
  async version() {
9694
- throw new Error("Method not implemented.");
10031
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9695
10032
  }
9696
10033
  /**
9697
10034
  * Should return true if the connector is connected
@@ -9700,7 +10037,7 @@ var FuelConnector = class extends EventEmitter2 {
9700
10037
  * @returns The connection status.
9701
10038
  */
9702
10039
  async isConnected() {
9703
- throw new Error("Method not implemented.");
10040
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9704
10041
  }
9705
10042
  /**
9706
10043
  * Should return all the accounts authorized for the
@@ -9709,7 +10046,7 @@ var FuelConnector = class extends EventEmitter2 {
9709
10046
  * @returns The accounts addresses strings
9710
10047
  */
9711
10048
  async accounts() {
9712
- throw new Error("Method not implemented.");
10049
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9713
10050
  }
9714
10051
  /**
9715
10052
  * Should start the connection process and return
@@ -9721,7 +10058,7 @@ var FuelConnector = class extends EventEmitter2 {
9721
10058
  * @returns boolean - connection status.
9722
10059
  */
9723
10060
  async connect() {
9724
- throw new Error("Method not implemented.");
10061
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9725
10062
  }
9726
10063
  /**
9727
10064
  * Should disconnect the current connection and
@@ -9731,7 +10068,7 @@ var FuelConnector = class extends EventEmitter2 {
9731
10068
  * @returns The connection status.
9732
10069
  */
9733
10070
  async disconnect() {
9734
- throw new Error("Method not implemented.");
10071
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9735
10072
  }
9736
10073
  /**
9737
10074
  * Should start the sign message process and return
@@ -9743,7 +10080,7 @@ var FuelConnector = class extends EventEmitter2 {
9743
10080
  * @returns Message signature
9744
10081
  */
9745
10082
  async signMessage(_address, _message) {
9746
- throw new Error("Method not implemented.");
10083
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9747
10084
  }
9748
10085
  /**
9749
10086
  * Should start the sign transaction process and return
@@ -9755,7 +10092,7 @@ var FuelConnector = class extends EventEmitter2 {
9755
10092
  * @returns Transaction signature
9756
10093
  */
9757
10094
  async signTransaction(_address, _transaction) {
9758
- throw new Error("Method not implemented.");
10095
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9759
10096
  }
9760
10097
  /**
9761
10098
  * Should start the send transaction process and return
@@ -9771,7 +10108,7 @@ var FuelConnector = class extends EventEmitter2 {
9771
10108
  * @returns The transaction id
9772
10109
  */
9773
10110
  async sendTransaction(_address, _transaction) {
9774
- throw new Error("Method not implemented.");
10111
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9775
10112
  }
9776
10113
  /**
9777
10114
  * Should return the current account selected inside the connector, if the account
@@ -9782,7 +10119,7 @@ var FuelConnector = class extends EventEmitter2 {
9782
10119
  * @returns The current account selected otherwise null.
9783
10120
  */
9784
10121
  async currentAccount() {
9785
- throw new Error("Method not implemented.");
10122
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9786
10123
  }
9787
10124
  /**
9788
10125
  * Should add the assets metadata to the connector and return true if the asset
@@ -9796,7 +10133,7 @@ var FuelConnector = class extends EventEmitter2 {
9796
10133
  * @returns True if the asset was added successfully
9797
10134
  */
9798
10135
  async addAssets(_assets) {
9799
- throw new Error("Method not implemented.");
10136
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9800
10137
  }
9801
10138
  /**
9802
10139
  * Should add the asset metadata to the connector and return true if the asset
@@ -9810,7 +10147,7 @@ var FuelConnector = class extends EventEmitter2 {
9810
10147
  * @returns True if the asset was added successfully
9811
10148
  */
9812
10149
  async addAsset(_asset) {
9813
- throw new Error("Method not implemented.");
10150
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9814
10151
  }
9815
10152
  /**
9816
10153
  * Should return all the assets added to the connector. If a connection is already established.
@@ -9818,7 +10155,7 @@ var FuelConnector = class extends EventEmitter2 {
9818
10155
  * @returns Array of assets metadata from the connector vinculated to the all accounts from a specific Wallet.
9819
10156
  */
9820
10157
  async assets() {
9821
- throw new Error("Method not implemented.");
10158
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9822
10159
  }
9823
10160
  /**
9824
10161
  * Should start the add network process and return true if the network was added successfully.
@@ -9829,7 +10166,7 @@ var FuelConnector = class extends EventEmitter2 {
9829
10166
  * @returns Return true if the network was added successfully
9830
10167
  */
9831
10168
  async addNetwork(_networkUrl) {
9832
- throw new Error("Method not implemented.");
10169
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9833
10170
  }
9834
10171
  /**
9835
10172
  * Should start the select network process and return true if the network has change successfully.
@@ -9840,7 +10177,7 @@ var FuelConnector = class extends EventEmitter2 {
9840
10177
  * @returns Return true if the network was added successfully
9841
10178
  */
9842
10179
  async selectNetwork(_network) {
9843
- throw new Error("Method not implemented.");
10180
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9844
10181
  }
9845
10182
  /**
9846
10183
  * Should return all the networks available from the connector. If the connection is already established.
@@ -9848,7 +10185,7 @@ var FuelConnector = class extends EventEmitter2 {
9848
10185
  * @returns Return all the networks added to the connector.
9849
10186
  */
9850
10187
  async networks() {
9851
- throw new Error("Method not implemented.");
10188
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9852
10189
  }
9853
10190
  /**
9854
10191
  * Should return the current network selected inside the connector. Even if the connection is not established.
@@ -9856,7 +10193,7 @@ var FuelConnector = class extends EventEmitter2 {
9856
10193
  * @returns Return the current network selected inside the connector.
9857
10194
  */
9858
10195
  async currentNetwork() {
9859
- throw new Error("Method not implemented.");
10196
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9860
10197
  }
9861
10198
  /**
9862
10199
  * Should add the ABI to the connector and return true if the ABI was added successfully.
@@ -9866,7 +10203,7 @@ var FuelConnector = class extends EventEmitter2 {
9866
10203
  * @returns Return true if the ABI was added successfully.
9867
10204
  */
9868
10205
  async addABI(_contractId, _abi) {
9869
- throw new Error("Method not implemented.");
10206
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9870
10207
  }
9871
10208
  /**
9872
10209
  * Should return the ABI from the connector vinculated to the all accounts from a specific Wallet.
@@ -9875,7 +10212,7 @@ var FuelConnector = class extends EventEmitter2 {
9875
10212
  * @returns The ABI if it exists, otherwise return null.
9876
10213
  */
9877
10214
  async getABI(_id) {
9878
- throw new Error("Method not implemented.");
10215
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9879
10216
  }
9880
10217
  /**
9881
10218
  * Should return true if the abi exists in the connector vinculated to the all accounts from a specific Wallet.
@@ -9884,7 +10221,7 @@ var FuelConnector = class extends EventEmitter2 {
9884
10221
  * @returns Returns true if the abi exists or false if not.
9885
10222
  */
9886
10223
  async hasABI(_id) {
9887
- throw new Error("Method not implemented.");
10224
+ throw new FuelError26(FuelError26.CODES.NOT_IMPLEMENTED, "Method not implemented.");
9888
10225
  }
9889
10226
  /**
9890
10227
  * Event listener for the connector.
@@ -9928,6 +10265,7 @@ function dispatchFuelConnectorEvent(connector) {
9928
10265
  }
9929
10266
 
9930
10267
  // src/connectors/utils/promises.ts
10268
+ import { FuelError as FuelError27 } from "@fuel-ts/errors";
9931
10269
  function deferPromise() {
9932
10270
  const defer = {};
9933
10271
  defer.promise = new Promise((resolve, reject) => {
@@ -9939,7 +10277,7 @@ function deferPromise() {
9939
10277
  async function withTimeout(promise, timeout = 1050) {
9940
10278
  const timeoutPromise = new Promise((resolve, reject) => {
9941
10279
  setTimeout(() => {
9942
- reject(new Error("Promise timed out"));
10280
+ reject(new FuelError27(FuelError27.CODES.TIMEOUT_EXCEEDED, "Promise timed out"));
9943
10281
  }, timeout);
9944
10282
  });
9945
10283
  return Promise.race([timeoutPromise, promise]);
@@ -10026,7 +10364,8 @@ var _Fuel = class extends FuelConnector {
10026
10364
  const hasConnector = await this.hasConnector();
10027
10365
  await this.pingConnector();
10028
10366
  if (!this._currentConnector || !hasConnector) {
10029
- throw new Error(
10367
+ throw new FuelError28(
10368
+ ErrorCode25.MISSING_CONNECTOR,
10030
10369
  `No connector selected for calling ${method}. Use hasConnector before executing other methods.`
10031
10370
  );
10032
10371
  }
@@ -10090,7 +10429,7 @@ var _Fuel = class extends FuelConnector {
10090
10429
  cacheTime: PING_CACHE_TIME
10091
10430
  })();
10092
10431
  } catch {
10093
- throw new Error("Current connector is not available.");
10432
+ throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Current connector is not available.");
10094
10433
  }
10095
10434
  }
10096
10435
  /**
@@ -10239,7 +10578,7 @@ var _Fuel = class extends FuelConnector {
10239
10578
  const currentNetwork = await this.currentNetwork();
10240
10579
  provider = await Provider.create(currentNetwork.url);
10241
10580
  } else {
10242
- throw new FuelError25(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
10581
+ throw new FuelError28(ErrorCode25.INVALID_PROVIDER, "Provider is not valid.");
10243
10582
  }
10244
10583
  return provider;
10245
10584
  }
@@ -10283,10 +10622,12 @@ export {
10283
10622
  BLOCKS_PAGE_SIZE_LIMIT,
10284
10623
  BaseTransactionRequest,
10285
10624
  BaseWalletUnlocked,
10625
+ BlobTransactionRequest,
10286
10626
  CHAIN_IDS,
10287
10627
  ChainName,
10288
10628
  ChangeOutputCollisionError,
10289
10629
  CreateTransactionRequest,
10630
+ DEFAULT_RESOURCE_CACHE_TTL,
10290
10631
  Fuel,
10291
10632
  FuelConnector,
10292
10633
  FuelConnectorEventType,
@@ -10320,6 +10661,7 @@ export {
10320
10661
  WalletUnlocked,
10321
10662
  addAmountToCoinQuantities,
10322
10663
  addOperation,
10664
+ aggregateInputsAmountsByAssetAndOwner,
10323
10665
  assemblePanicError,
10324
10666
  assembleReceiptByType,
10325
10667
  assembleRevertError,
@@ -10330,6 +10672,7 @@ export {
10330
10672
  cacheRequestInputsResources,
10331
10673
  cacheRequestInputsResourcesFromOwner,
10332
10674
  calculateGasFee,
10675
+ calculateMetadataGasForTxBlob,
10333
10676
  calculateMetadataGasForTxCreate,
10334
10677
  calculateMetadataGasForTxScript,
10335
10678
  calculateTXFeeForSummary,
@@ -10388,6 +10731,7 @@ export {
10388
10731
  hasSameAssetId,
10389
10732
  inputify,
10390
10733
  isCoin,
10734
+ isInputCoin,
10391
10735
  isMessage,
10392
10736
  isRawCoin,
10393
10737
  isRawMessage,
@@ -10395,7 +10739,11 @@ export {
10395
10739
  isRequestInputMessage,
10396
10740
  isRequestInputResource,
10397
10741
  isRequestInputResourceFromOwner,
10742
+ isTransactionTypeBlob,
10743
+ isTransactionTypeCreate,
10744
+ isTransactionTypeScript,
10398
10745
  isType,
10746
+ isTypeBlob,
10399
10747
  isTypeCreate,
10400
10748
  isTypeMint,
10401
10749
  isTypeScript,