@fuel-ts/account 0.0.0-pr-1788-20240222094224 → 0.0.0-pr-1864-20240312141036

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of @fuel-ts/account might be problematic. Click here for more details.

Files changed (58) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/connectors/fuel-connector.d.ts +2 -1
  3. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  4. package/dist/connectors/types/data-type.d.ts +0 -8
  5. package/dist/connectors/types/data-type.d.ts.map +1 -1
  6. package/dist/connectors/types/events.d.ts +2 -36
  7. package/dist/connectors/types/events.d.ts.map +1 -1
  8. package/dist/connectors/types/index.d.ts +0 -2
  9. package/dist/connectors/types/index.d.ts.map +1 -1
  10. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  11. package/dist/index.global.js +1524 -2888
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +234 -243
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +287 -298
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  18. package/dist/mnemonic/utils.d.ts.map +1 -1
  19. package/dist/predicate/predicate.d.ts +16 -15
  20. package/dist/predicate/predicate.d.ts.map +1 -1
  21. package/dist/providers/__generated__/operations.d.ts +47 -38
  22. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  23. package/dist/providers/fuel-graphql-subscriber.d.ts +13 -3
  24. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  25. package/dist/providers/provider.d.ts +28 -12
  26. package/dist/providers/provider.d.ts.map +1 -1
  27. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  28. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  29. package/dist/providers/transaction-response/getDecodedLogs.d.ts.map +1 -1
  30. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  31. package/dist/providers/transaction-summary/assemble-transaction-summary.d.ts.map +1 -1
  32. package/dist/providers/transaction-summary/index.d.ts +0 -1
  33. package/dist/providers/transaction-summary/index.d.ts.map +1 -1
  34. package/dist/providers/transaction-summary/operations.d.ts +0 -2
  35. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  36. package/dist/providers/transaction-summary/output.d.ts +2 -2
  37. package/dist/providers/transaction-summary/output.d.ts.map +1 -1
  38. package/dist/providers/transaction-summary/types.d.ts +0 -1
  39. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  40. package/dist/providers/utils/index.d.ts +0 -1
  41. package/dist/providers/utils/index.d.ts.map +1 -1
  42. package/dist/test-utils.global.js +1498 -2850
  43. package/dist/test-utils.global.js.map +1 -1
  44. package/dist/test-utils.js +211 -199
  45. package/dist/test-utils.js.map +1 -1
  46. package/dist/test-utils.mjs +244 -240
  47. package/dist/test-utils.mjs.map +1 -1
  48. package/package.json +16 -16
  49. package/dist/connectors/types/asset.d.ts +0 -2
  50. package/dist/connectors/types/asset.d.ts.map +0 -1
  51. package/dist/connectors/types/constants.d.ts +0 -7
  52. package/dist/connectors/types/constants.d.ts.map +0 -1
  53. package/dist/connectors/types/message.d.ts +0 -15
  54. package/dist/connectors/types/message.d.ts.map +0 -1
  55. package/dist/providers/transaction-summary/date.d.ts +0 -3
  56. package/dist/providers/transaction-summary/date.d.ts.map +0 -1
  57. package/dist/providers/utils/time.d.ts +0 -40
  58. package/dist/providers/utils/time.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -75,7 +75,6 @@ __export(src_exports, {
75
75
  LocalStorage: () => LocalStorage,
76
76
  MNEMONIC_SIZES: () => MNEMONIC_SIZES,
77
77
  MemoryStorage: () => MemoryStorage,
78
- MessageTypes: () => MessageTypes,
79
78
  Mnemonic: () => mnemonic_default,
80
79
  MnemonicVault: () => MnemonicVault,
81
80
  NoWitnessAtIndexError: () => NoWitnessAtIndexError,
@@ -113,10 +112,6 @@ __export(src_exports, {
113
112
  english: () => english,
114
113
  extractBurnedAssetsFromReceipts: () => extractBurnedAssetsFromReceipts,
115
114
  extractMintedAssetsFromReceipts: () => extractMintedAssetsFromReceipts,
116
- fromDateToTai64: () => fromDateToTai64,
117
- fromTai64ToDate: () => fromTai64ToDate,
118
- fromTai64ToUnix: () => fromTai64ToUnix,
119
- fromUnixToTai64: () => fromUnixToTai64,
120
115
  gasUsedByInputs: () => gasUsedByInputs,
121
116
  getAssetEth: () => getAssetEth,
122
117
  getAssetFuel: () => getAssetFuel,
@@ -124,7 +119,6 @@ __export(src_exports, {
124
119
  getAssetWithNetwork: () => getAssetWithNetwork,
125
120
  getContractCallOperations: () => getContractCallOperations,
126
121
  getContractCreatedOperations: () => getContractCreatedOperations,
127
- getContractTransferOperations: () => getContractTransferOperations,
128
122
  getDecodedLogs: () => getDecodedLogs,
129
123
  getDefaultChainId: () => getDefaultChainId,
130
124
  getGasUsedFromReceipts: () => getGasUsedFromReceipts,
@@ -187,7 +181,7 @@ module.exports = __toCommonJS(src_exports);
187
181
 
188
182
  // src/account.ts
189
183
  var import_address4 = require("@fuel-ts/address");
190
- var import_configs10 = require("@fuel-ts/address/configs");
184
+ var import_configs11 = require("@fuel-ts/address/configs");
191
185
  var import_errors15 = require("@fuel-ts/errors");
192
186
  var import_interfaces = require("@fuel-ts/interfaces");
193
187
  var import_math17 = require("@fuel-ts/math");
@@ -237,7 +231,7 @@ var import_transactions17 = require("@fuel-ts/transactions");
237
231
  var import_utils22 = require("@fuel-ts/utils");
238
232
  var import_versions = require("@fuel-ts/versions");
239
233
  var import_utils23 = require("@noble/curves/abstract/utils");
240
- var import_ethers2 = require("ethers");
234
+ var import_ethers = require("ethers");
241
235
  var import_graphql_request = require("graphql-request");
242
236
  var import_ramda3 = require("ramda");
243
237
 
@@ -302,6 +296,9 @@ var TransactionStatusFragmentFragmentDoc = import_graphql_tag.default`
302
296
  time
303
297
  reason
304
298
  }
299
+ ... on SqueezedOutStatus {
300
+ reason
301
+ }
305
302
  }
306
303
  `;
307
304
  var TransactionFragmentFragmentDoc = import_graphql_tag.default`
@@ -1046,67 +1043,72 @@ function getSdk(requester) {
1046
1043
  // src/providers/fuel-graphql-subscriber.ts
1047
1044
  var import_errors = require("@fuel-ts/errors");
1048
1045
  var import_graphql = require("graphql");
1049
- var _FuelSubscriptionStream = class {
1050
- readable;
1051
- writable;
1052
- readableStreamController;
1053
- constructor() {
1054
- this.readable = new ReadableStream({
1055
- start: (controller) => {
1056
- this.readableStreamController = controller;
1057
- }
1058
- });
1059
- this.writable = new WritableStream({
1060
- write: (bytes) => {
1061
- const text = _FuelSubscriptionStream.textDecoder.decode(bytes);
1062
- if (text.startsWith("data:")) {
1063
- const { data, errors } = JSON.parse(text.split("data:")[1]);
1064
- if (Array.isArray(errors)) {
1065
- this.readableStreamController.enqueue(
1066
- new import_errors.FuelError(
1067
- import_errors.FuelError.CODES.INVALID_REQUEST,
1068
- errors.map((err) => err.message).join("\n\n")
1069
- )
1070
- );
1071
- } else {
1072
- this.readableStreamController.enqueue(data);
1073
- }
1074
- }
1046
+ var _FuelGraphqlSubscriber = class {
1047
+ constructor(options) {
1048
+ this.options = options;
1049
+ }
1050
+ stream;
1051
+ async setStream() {
1052
+ const { url, query, variables, fetchFn } = this.options;
1053
+ const response = await fetchFn(`${url}-sub`, {
1054
+ method: "POST",
1055
+ body: JSON.stringify({
1056
+ query: (0, import_graphql.print)(query),
1057
+ variables
1058
+ }),
1059
+ headers: {
1060
+ "Content-Type": "application/json",
1061
+ Accept: "text/event-stream"
1075
1062
  }
1076
1063
  });
1064
+ this.stream = response.body.getReader();
1077
1065
  }
1078
- };
1079
- var FuelSubscriptionStream = _FuelSubscriptionStream;
1080
- __publicField(FuelSubscriptionStream, "textDecoder", new TextDecoder());
1081
- async function* fuelGraphQLSubscriber({
1082
- url,
1083
- variables,
1084
- query,
1085
- fetchFn
1086
- }) {
1087
- const response = await fetchFn(`${url}-sub`, {
1088
- method: "POST",
1089
- body: JSON.stringify({
1090
- query: (0, import_graphql.print)(query),
1091
- variables
1092
- }),
1093
- headers: {
1094
- "Content-Type": "application/json",
1095
- Accept: "text/event-stream"
1066
+ async next() {
1067
+ if (!this.stream) {
1068
+ await this.setStream();
1096
1069
  }
1097
- });
1098
- const subscriptionStreamReader = response.body.pipeThrough(new FuelSubscriptionStream()).getReader();
1099
- while (true) {
1100
- const { value, done } = await subscriptionStreamReader.read();
1101
- if (value instanceof import_errors.FuelError) {
1102
- throw value;
1103
- }
1104
- yield value;
1105
- if (done) {
1106
- break;
1070
+ while (true) {
1071
+ const { value, done } = await this.stream.read();
1072
+ if (done) {
1073
+ return { value, done };
1074
+ }
1075
+ const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
1076
+ if (!text.startsWith("data:")) {
1077
+ continue;
1078
+ }
1079
+ let data;
1080
+ let errors;
1081
+ try {
1082
+ ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
1083
+ } catch (e) {
1084
+ throw new import_errors.FuelError(
1085
+ import_errors.ErrorCode.STREAM_PARSING_ERROR,
1086
+ `Error while parsing stream data response: ${text}`
1087
+ );
1088
+ }
1089
+ if (Array.isArray(errors)) {
1090
+ throw new import_errors.FuelError(
1091
+ import_errors.FuelError.CODES.INVALID_REQUEST,
1092
+ errors.map((err) => err.message).join("\n\n")
1093
+ );
1094
+ }
1095
+ return { value: data, done: false };
1107
1096
  }
1108
1097
  }
1109
- }
1098
+ /**
1099
+ * Gets called when `break` is called in a `for-await-of` loop.
1100
+ */
1101
+ async return() {
1102
+ await this.stream.cancel();
1103
+ this.stream.releaseLock();
1104
+ return { done: true, value: void 0 };
1105
+ }
1106
+ [Symbol.asyncIterator]() {
1107
+ return this;
1108
+ }
1109
+ };
1110
+ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
1111
+ __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
1110
1112
 
1111
1113
  // src/providers/memory-cache.ts
1112
1114
  var import_errors2 = require("@fuel-ts/errors");
@@ -1696,10 +1698,6 @@ function sleep(time) {
1696
1698
  });
1697
1699
  }
1698
1700
 
1699
- // src/providers/utils/time.ts
1700
- var fromTai64ToUnix = (tai64Timestamp) => Number(BigInt(tai64Timestamp) - BigInt(2 ** 62) - BigInt(10));
1701
- var fromUnixToTai64 = (unixTimestampMs) => (BigInt(unixTimestampMs) + BigInt(2 ** 62) + BigInt(10)).toString();
1702
-
1703
1701
  // src/providers/transaction-request/errors.ts
1704
1702
  var ChangeOutputCollisionError = class extends Error {
1705
1703
  name = "ChangeOutputCollisionError";
@@ -1953,7 +1951,7 @@ var BaseTransactionRequest = class {
1953
1951
  txPointer: "0x00000000000000000000000000000000",
1954
1952
  witnessIndex,
1955
1953
  predicate: predicate?.bytes,
1956
- predicateData: predicate?.predicateData
1954
+ predicateData: predicate?.predicateDataBytes
1957
1955
  };
1958
1956
  this.pushInput(input);
1959
1957
  this.addChangeOutput(owner, assetId);
@@ -1986,7 +1984,7 @@ var BaseTransactionRequest = class {
1986
1984
  amount,
1987
1985
  witnessIndex,
1988
1986
  predicate: predicate?.bytes,
1989
- predicateData: predicate?.predicateData
1987
+ predicateData: predicate?.predicateDataBytes
1990
1988
  };
1991
1989
  this.pushInput(input);
1992
1990
  this.addChangeOutput(recipient, assetId);
@@ -2201,8 +2199,6 @@ var BaseTransactionRequest = class {
2201
2199
  this.inputs.forEach((i) => {
2202
2200
  let correspondingInput;
2203
2201
  switch (i.type) {
2204
- case import_transactions5.InputType.Contract:
2205
- return;
2206
2202
  case import_transactions5.InputType.Coin:
2207
2203
  correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2208
2204
  break;
@@ -2212,7 +2208,7 @@ var BaseTransactionRequest = class {
2212
2208
  );
2213
2209
  break;
2214
2210
  default:
2215
- break;
2211
+ return;
2216
2212
  }
2217
2213
  if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2218
2214
  i.predicate = correspondingInput.predicate;
@@ -2235,7 +2231,6 @@ var import_hasher = require("@fuel-ts/hasher");
2235
2231
  var import_math7 = require("@fuel-ts/math");
2236
2232
  var import_transactions6 = require("@fuel-ts/transactions");
2237
2233
  var import_utils11 = require("@fuel-ts/utils");
2238
- var import_ethers = require("ethers");
2239
2234
  var import_ramda2 = require("ramda");
2240
2235
  function hashTransaction(transactionRequest, chainId) {
2241
2236
  const transaction = transactionRequest.toTransaction();
@@ -2298,7 +2293,7 @@ function hashTransaction(transactionRequest, chainId) {
2298
2293
  transaction.witnesses = [];
2299
2294
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2300
2295
  const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2301
- return (0, import_ethers.sha256)(concatenatedData);
2296
+ return (0, import_hasher.sha256)(concatenatedData);
2302
2297
  }
2303
2298
 
2304
2299
  // src/providers/transaction-request/storage-slot.ts
@@ -2724,15 +2719,8 @@ var calculateTransactionFee = (params) => {
2724
2719
  };
2725
2720
  };
2726
2721
 
2727
- // src/providers/transaction-summary/date.ts
2728
- var import_tai64 = require("tai64");
2729
- var fromTai64ToDate = (tai64Timestamp) => {
2730
- const timestamp = import_tai64.TAI64.fromString(tai64Timestamp, 10).toUnix();
2731
- return new Date(timestamp * 1e3);
2732
- };
2733
- var fromDateToTai64 = (date) => import_tai64.TAI64.fromUnix(Math.floor(date.getTime() / 1e3)).toString(10);
2734
-
2735
2722
  // src/providers/transaction-summary/operations.ts
2723
+ var import_configs10 = require("@fuel-ts/address/configs");
2736
2724
  var import_errors10 = require("@fuel-ts/errors");
2737
2725
  var import_math12 = require("@fuel-ts/math");
2738
2726
  var import_transactions13 = require("@fuel-ts/transactions");
@@ -2877,7 +2865,6 @@ var OperationName = /* @__PURE__ */ ((OperationName2) => {
2877
2865
  OperationName2["contractCreated"] = "Contract created";
2878
2866
  OperationName2["transfer"] = "Transfer asset";
2879
2867
  OperationName2["contractCall"] = "Contract call";
2880
- OperationName2["contractTransfer"] = "Contract transfer";
2881
2868
  OperationName2["receive"] = "Receive asset";
2882
2869
  OperationName2["mint"] = "Mint asset";
2883
2870
  OperationName2["predicatecall"] = "Predicate call";
@@ -2977,33 +2964,6 @@ function addOperation(operations, toAdd) {
2977
2964
  function getReceiptsTransferOut(receipts) {
2978
2965
  return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
2979
2966
  }
2980
- function getContractTransferOperations({ receipts }) {
2981
- const transferOutReceipts = getReceiptsTransferOut(receipts);
2982
- const contractTransferOperations = transferOutReceipts.reduce(
2983
- (prevContractTransferOps, receipt) => {
2984
- const newContractTransferOps = addOperation(prevContractTransferOps, {
2985
- name: "Contract transfer" /* contractTransfer */,
2986
- from: {
2987
- type: 0 /* contract */,
2988
- address: receipt.from
2989
- },
2990
- to: {
2991
- type: 1 /* account */,
2992
- address: receipt.to
2993
- },
2994
- assetsSent: [
2995
- {
2996
- amount: receipt.amount,
2997
- assetId: receipt.assetId
2998
- }
2999
- ]
3000
- });
3001
- return newContractTransferOps;
3002
- },
3003
- []
3004
- );
3005
- return contractTransferOperations;
3006
- }
3007
2967
  function getWithdrawFromFuelOperations({
3008
2968
  inputs,
3009
2969
  receipts
@@ -3101,70 +3061,77 @@ function getContractCallOperations({
3101
3061
  }, []);
3102
3062
  return contractCallOperations;
3103
3063
  }
3064
+ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
3065
+ const { to: toAddress, assetId, amount } = receipt;
3066
+ let { from: fromAddress } = receipt;
3067
+ const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
3068
+ if (import_configs10.ZeroBytes32 === fromAddress) {
3069
+ const change = changeOutputs.find((output) => output.assetId === assetId);
3070
+ fromAddress = change?.to || fromAddress;
3071
+ }
3072
+ const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
3073
+ return {
3074
+ name: "Transfer asset" /* transfer */,
3075
+ from: {
3076
+ type: fromType,
3077
+ address: fromAddress
3078
+ },
3079
+ to: {
3080
+ type: toType,
3081
+ address: toAddress
3082
+ },
3083
+ assetsSent: [
3084
+ {
3085
+ assetId: assetId.toString(),
3086
+ amount
3087
+ }
3088
+ ]
3089
+ };
3090
+ }
3104
3091
  function getTransferOperations({
3105
3092
  inputs,
3106
3093
  outputs,
3107
3094
  receipts
3108
3095
  }) {
3096
+ let operations = [];
3109
3097
  const coinOutputs = getOutputsCoin(outputs);
3110
- const [transferReceipt] = getReceiptsByType(
3098
+ const contractInputs = getInputsContract(inputs);
3099
+ const changeOutputs = getOutputsChange(outputs);
3100
+ coinOutputs.forEach((output) => {
3101
+ const { amount, assetId, to } = output;
3102
+ const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
3103
+ if (changeOutput) {
3104
+ operations = addOperation(operations, {
3105
+ name: "Transfer asset" /* transfer */,
3106
+ from: {
3107
+ type: 1 /* account */,
3108
+ address: changeOutput.to
3109
+ },
3110
+ to: {
3111
+ type: 1 /* account */,
3112
+ address: to
3113
+ },
3114
+ assetsSent: [
3115
+ {
3116
+ assetId,
3117
+ amount
3118
+ }
3119
+ ]
3120
+ });
3121
+ }
3122
+ });
3123
+ const transferReceipts = getReceiptsByType(
3111
3124
  receipts,
3112
3125
  import_transactions13.ReceiptType.Transfer
3113
3126
  );
3114
- let operations = [];
3115
- if (transferReceipt) {
3116
- const changeOutputs = getOutputsChange(outputs);
3117
- changeOutputs.forEach((output) => {
3118
- const { assetId } = output;
3119
- const [contractInput] = getInputsContract(inputs);
3120
- const utxo = getInputFromAssetId(inputs, assetId);
3121
- if (utxo && contractInput) {
3122
- const inputAddress = getInputAccountAddress(utxo);
3123
- operations = addOperation(operations, {
3124
- name: "Transfer asset" /* transfer */,
3125
- from: {
3126
- type: 1 /* account */,
3127
- address: inputAddress
3128
- },
3129
- to: {
3130
- type: 0 /* contract */,
3131
- address: contractInput.contractID
3132
- },
3133
- assetsSent: [
3134
- {
3135
- assetId: assetId.toString(),
3136
- amount: transferReceipt.amount
3137
- }
3138
- ]
3139
- });
3140
- }
3141
- });
3142
- } else {
3143
- coinOutputs.forEach((output) => {
3144
- const input = getInputFromAssetId(inputs, output.assetId);
3145
- if (input) {
3146
- const inputAddress = getInputAccountAddress(input);
3147
- const operationToAdd = {
3148
- name: "Transfer asset" /* transfer */,
3149
- from: {
3150
- type: 1 /* account */,
3151
- address: inputAddress
3152
- },
3153
- to: {
3154
- type: 1 /* account */,
3155
- address: output.to.toString()
3156
- },
3157
- assetsSent: [
3158
- {
3159
- assetId: output.assetId.toString(),
3160
- amount: output.amount
3161
- }
3162
- ]
3163
- };
3164
- operations = addOperation(operations, operationToAdd);
3165
- }
3166
- });
3167
- }
3127
+ const transferOutReceipts = getReceiptsByType(
3128
+ receipts,
3129
+ import_transactions13.ReceiptType.TransferOut
3130
+ );
3131
+ [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
3132
+ const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
3133
+ operations = addOperation(operations, operation);
3134
+ });
3168
3135
  return operations;
3169
3136
  }
3170
3137
  function getPayProducerOperations(outputs) {
@@ -3237,7 +3204,6 @@ function getOperations({
3237
3204
  rawPayload,
3238
3205
  maxInputs
3239
3206
  }),
3240
- ...getContractTransferOperations({ receipts }),
3241
3207
  ...getWithdrawFromFuelOperations({ inputs, receipts })
3242
3208
  ];
3243
3209
  }
@@ -3393,7 +3359,7 @@ function assembleTransactionSummary(params) {
3393
3359
  const burnedAssets = extractBurnedAssetsFromReceipts(receipts);
3394
3360
  let date;
3395
3361
  if (time) {
3396
- date = fromTai64ToDate(time);
3362
+ date = import_utils19.DateTime.fromTai64(time);
3397
3363
  }
3398
3364
  const transactionSummary = {
3399
3365
  id,
@@ -3528,6 +3494,12 @@ var TransactionResponse = class {
3528
3494
  transactionId: this.id
3529
3495
  });
3530
3496
  for await (const { statusChange } of subscription) {
3497
+ if (statusChange.type === "SqueezedOutStatus") {
3498
+ throw new import_errors12.FuelError(
3499
+ import_errors12.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3500
+ `Transaction Squeezed Out with reason: ${statusChange.reason}`
3501
+ );
3502
+ }
3531
3503
  if (statusChange.type !== "SubmittedStatus") {
3532
3504
  break;
3533
3505
  }
@@ -3574,7 +3546,9 @@ function getDecodedLogs(receipts, abiInterface) {
3574
3546
  logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3575
3547
  }
3576
3548
  if (r.type === import_transactions16.ReceiptType.Log) {
3577
- logs.push(abiInterface.decodeLog(new import_abi_coder3.U64Coder().encode(r.val0), r.val1.toNumber(), r.id)[0]);
3549
+ logs.push(
3550
+ abiInterface.decodeLog(new import_abi_coder3.BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3551
+ );
3578
3552
  }
3579
3553
  return logs;
3580
3554
  }, []);
@@ -3703,14 +3677,15 @@ var _Provider = class {
3703
3677
  }
3704
3678
  static getFetchFn(options) {
3705
3679
  const { retryOptions, timeout } = options;
3706
- return autoRetryFetch((...args) => {
3707
- if (options.fetch) {
3708
- return options.fetch(...args);
3709
- }
3680
+ return autoRetryFetch(async (...args) => {
3710
3681
  const url = args[0];
3711
3682
  const request = args[1];
3712
3683
  const signal = timeout ? AbortSignal.timeout(timeout) : void 0;
3713
- return fetch(url, { ...request, signal });
3684
+ let fullRequest = { ...request, signal };
3685
+ if (options.requestMiddleware) {
3686
+ fullRequest = await options.requestMiddleware(fullRequest);
3687
+ }
3688
+ return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
3714
3689
  }, retryOptions);
3715
3690
  }
3716
3691
  /**
@@ -3810,7 +3785,7 @@ var _Provider = class {
3810
3785
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
3811
3786
  const isSubscription = opDefinition?.operation === "subscription";
3812
3787
  if (isSubscription) {
3813
- return fuelGraphQLSubscriber({
3788
+ return new FuelGraphqlSubscriber({
3814
3789
  url: this.url,
3815
3790
  query,
3816
3791
  fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
@@ -3844,7 +3819,7 @@ var _Provider = class {
3844
3819
  name,
3845
3820
  consensusParameters: { chainId }
3846
3821
  } = await this.getChain();
3847
- const network = new import_ethers2.Network(name, chainId.toNumber());
3822
+ const network = new import_ethers.Network(name, chainId.toNumber());
3848
3823
  return Promise.resolve(network);
3849
3824
  }
3850
3825
  /**
@@ -3916,6 +3891,12 @@ var _Provider = class {
3916
3891
  if (awaitExecution) {
3917
3892
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3918
3893
  for await (const { submitAndAwait } of subscription) {
3894
+ if (submitAndAwait.type === "SqueezedOutStatus") {
3895
+ throw new import_errors13.FuelError(
3896
+ import_errors13.ErrorCode.TRANSACTION_SQUEEZED_OUT,
3897
+ `Transaction Squeezed Out with reason: ${submitAndAwait.reason}`
3898
+ );
3899
+ }
3919
3900
  if (submitAndAwait.type !== "SubmittedStatus") {
3920
3901
  break;
3921
3902
  }
@@ -4002,11 +3983,15 @@ var _Provider = class {
4002
3983
  async estimateTxDependencies(transactionRequest) {
4003
3984
  if (transactionRequest.type === import_transactions17.TransactionType.Create) {
4004
3985
  return {
4005
- receipts: []
3986
+ receipts: [],
3987
+ outputVariables: 0,
3988
+ missingContractIds: []
4006
3989
  };
4007
3990
  }
4008
3991
  await this.estimatePredicates(transactionRequest);
4009
3992
  let receipts = [];
3993
+ const missingContractIds = [];
3994
+ let outputVariables = 0;
4010
3995
  for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
4011
3996
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
4012
3997
  encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
@@ -4016,16 +4001,20 @@ var _Provider = class {
4016
4001
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
4017
4002
  const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
4018
4003
  if (hasMissingOutputs) {
4004
+ outputVariables += missingOutputVariables.length;
4019
4005
  transactionRequest.addVariableOutputs(missingOutputVariables.length);
4020
4006
  missingOutputContractIds.forEach(({ contractId }) => {
4021
4007
  transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
4008
+ missingContractIds.push(contractId);
4022
4009
  });
4023
4010
  } else {
4024
4011
  break;
4025
4012
  }
4026
4013
  }
4027
4014
  return {
4028
- receipts
4015
+ receipts,
4016
+ outputVariables,
4017
+ missingContractIds
4029
4018
  };
4030
4019
  }
4031
4020
  /**
@@ -4093,11 +4082,15 @@ var _Provider = class {
4093
4082
  const minGas = txRequestClone.calculateMinGas(chainInfo);
4094
4083
  const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
4095
4084
  let receipts = [];
4085
+ let missingContractIds = [];
4086
+ let outputVariables = 0;
4096
4087
  if (isScriptTransaction && estimateTxDependencies) {
4097
4088
  txRequestClone.gasPrice = (0, import_math14.bn)(0);
4098
4089
  txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
4099
4090
  const result = await this.estimateTxDependencies(txRequestClone);
4100
4091
  receipts = result.receipts;
4092
+ outputVariables = result.outputVariables;
4093
+ missingContractIds = result.missingContractIds;
4101
4094
  }
4102
4095
  const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
4103
4096
  const usedFee = calculatePriceWithFactor(
@@ -4119,7 +4112,8 @@ var _Provider = class {
4119
4112
  minFee,
4120
4113
  maxFee,
4121
4114
  estimatedInputs: txRequestClone.inputs,
4122
- estimatedOutputs: txRequestClone.outputs
4115
+ outputVariables,
4116
+ missingContractIds
4123
4117
  };
4124
4118
  }
4125
4119
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -4499,13 +4493,13 @@ var _Provider = class {
4499
4493
  * Lets you produce blocks with custom timestamps and the block number of the last block produced.
4500
4494
  *
4501
4495
  * @param amount - The amount of blocks to produce
4502
- * @param startTime - The UNIX timestamp to set for the first produced block
4496
+ * @param startTime - The UNIX timestamp (milliseconds) to set for the first produced block
4503
4497
  * @returns A promise that resolves to the block number of the last produced block.
4504
4498
  */
4505
4499
  async produceBlocks(amount, startTime) {
4506
4500
  const { produceBlocks: latestBlockHeight } = await this.operations.produceBlocks({
4507
4501
  blocksToProduce: (0, import_math14.bn)(amount).toString(10),
4508
- startTimestamp: startTime ? fromUnixToTai64(startTime) : void 0
4502
+ startTimestamp: startTime ? import_utils22.DateTime.fromUnixMilliseconds(startTime).toTai64() : void 0
4509
4503
  });
4510
4504
  return (0, import_math14.bn)(latestBlockHeight);
4511
4505
  }
@@ -4753,7 +4747,7 @@ var import_utils26 = require("@fuel-ts/utils");
4753
4747
  var asm = __toESM(require("@fuels/vm-asm"));
4754
4748
  var formatTransferToContractScriptData = (params) => {
4755
4749
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4756
- const numberCoder = new import_abi_coder4.U64Coder();
4750
+ const numberCoder = new import_abi_coder4.BigNumberCoder("u64");
4757
4751
  const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4758
4752
  const scriptData = Uint8Array.from([
4759
4753
  ...(0, import_utils26.arrayify)(hexlifiedContractId),
@@ -4905,7 +4899,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4905
4899
  * @param assetId - The asset ID to check the balance for.
4906
4900
  * @returns A promise that resolves to the balance amount.
4907
4901
  */
4908
- async getBalance(assetId = import_configs10.BaseAssetId) {
4902
+ async getBalance(assetId = import_configs11.BaseAssetId) {
4909
4903
  const amount = await this.provider.getBalance(this.address, assetId);
4910
4904
  return amount;
4911
4905
  }
@@ -4946,7 +4940,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4946
4940
  async fund(request, coinQuantities, fee) {
4947
4941
  const updatedQuantities = addAmountToAsset({
4948
4942
  amount: (0, import_math17.bn)(fee),
4949
- assetId: import_configs10.BaseAssetId,
4943
+ assetId: import_configs11.BaseAssetId,
4950
4944
  coinQuantities
4951
4945
  });
4952
4946
  const quantitiesDict = {};
@@ -4970,8 +4964,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4970
4964
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4971
4965
  cachedUtxos.push(input.id);
4972
4966
  }
4973
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs10.BaseAssetId]) {
4974
- quantitiesDict[import_configs10.BaseAssetId].owned = quantitiesDict[import_configs10.BaseAssetId].owned.add(input.amount);
4967
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
4968
+ quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
4975
4969
  cachedMessages.push(input.nonce);
4976
4970
  }
4977
4971
  }
@@ -5003,7 +4997,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5003
4997
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5004
4998
  * @returns A promise that resolves to the prepared transaction request.
5005
4999
  */
5006
- async createTransfer(destination, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
5000
+ async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5007
5001
  const { minGasPrice } = this.provider.getGasConfig();
5008
5002
  const params = { gasPrice: minGasPrice, ...txParams };
5009
5003
  const request = new ScriptTransactionRequest(params);
@@ -5033,7 +5027,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5033
5027
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
5034
5028
  * @returns A promise that resolves to the transaction response.
5035
5029
  */
5036
- async transfer(destination, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
5030
+ async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5031
+ if ((0, import_math17.bn)(amount).lte(0)) {
5032
+ throw new import_errors15.FuelError(
5033
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5034
+ "Transfer amount must be a positive number."
5035
+ );
5036
+ }
5037
5037
  const request = await this.createTransfer(destination, amount, assetId, txParams);
5038
5038
  return this.sendTransaction(request, { estimateTxDependencies: false });
5039
5039
  }
@@ -5046,7 +5046,13 @@ var Account = class extends import_interfaces.AbstractAccount {
5046
5046
  * @param txParams - The optional transaction parameters.
5047
5047
  * @returns A promise that resolves to the transaction response.
5048
5048
  */
5049
- async transferToContract(contractId, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
5049
+ async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
5050
+ if ((0, import_math17.bn)(amount).lte(0)) {
5051
+ throw new import_errors15.FuelError(
5052
+ import_errors15.ErrorCode.INVALID_TRANSFER_AMOUNT,
5053
+ "Transfer amount must be a positive number."
5054
+ );
5055
+ }
5050
5056
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
5051
5057
  const { minGasPrice } = this.provider.getGasConfig();
5052
5058
  const params = { gasPrice: minGasPrice, ...txParams };
@@ -5099,7 +5105,7 @@ var Account = class extends import_interfaces.AbstractAccount {
5099
5105
  ]);
5100
5106
  const params = { script, gasPrice: minGasPrice, ...txParams };
5101
5107
  const request = new ScriptTransactionRequest(params);
5102
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs10.BaseAssetId }];
5108
+ const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
5103
5109
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
5104
5110
  request,
5105
5111
  forwardingQuantities
@@ -5493,15 +5499,17 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
5493
5499
 
5494
5500
  // src/hdwallet/hdwallet.ts
5495
5501
  var import_errors19 = require("@fuel-ts/errors");
5502
+ var import_hasher6 = require("@fuel-ts/hasher");
5496
5503
  var import_math19 = require("@fuel-ts/math");
5497
5504
  var import_utils34 = require("@fuel-ts/utils");
5498
- var import_ethers5 = require("ethers");
5505
+ var import_ethers3 = require("ethers");
5499
5506
 
5500
5507
  // src/mnemonic/mnemonic.ts
5501
5508
  var import_crypto3 = require("@fuel-ts/crypto");
5502
5509
  var import_errors18 = require("@fuel-ts/errors");
5510
+ var import_hasher5 = require("@fuel-ts/hasher");
5503
5511
  var import_utils32 = require("@fuel-ts/utils");
5504
- var import_ethers4 = require("ethers");
5512
+ var import_ethers2 = require("ethers");
5505
5513
 
5506
5514
  // src/wordlists/words/english.ts
5507
5515
  var english = [
@@ -7563,8 +7571,8 @@ var Language = /* @__PURE__ */ ((Language2) => {
7563
7571
 
7564
7572
  // src/mnemonic/utils.ts
7565
7573
  var import_errors17 = require("@fuel-ts/errors");
7574
+ var import_hasher4 = require("@fuel-ts/hasher");
7566
7575
  var import_utils31 = require("@fuel-ts/utils");
7567
- var import_ethers3 = require("ethers");
7568
7576
  function toUtf8Bytes(stri) {
7569
7577
  const str = stri.normalize("NFKD");
7570
7578
  const result = [];
@@ -7631,7 +7639,7 @@ function entropyToMnemonicIndices(entropy) {
7631
7639
  }
7632
7640
  }
7633
7641
  const checksumBits = entropy.length / 4;
7634
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
7642
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy))[0] & getUpperMask(checksumBits);
7635
7643
  indices[indices.length - 1] <<= checksumBits;
7636
7644
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7637
7645
  return indices;
@@ -7658,7 +7666,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7658
7666
  const entropyBits = 32 * words.length / 3;
7659
7667
  const checksumBits = words.length / 3;
7660
7668
  const checksumMask = getUpperMask(checksumBits);
7661
- const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7669
+ const checksum = (0, import_utils31.arrayify)((0, import_hasher4.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7662
7670
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7663
7671
  throw new import_errors17.FuelError(
7664
7672
  import_errors17.ErrorCode.INVALID_CHECKSUM,
@@ -7755,7 +7763,7 @@ var Mnemonic = class {
7755
7763
  assertMnemonic(getWords(phrase));
7756
7764
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7757
7765
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7758
- return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7766
+ return (0, import_ethers2.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7759
7767
  }
7760
7768
  /**
7761
7769
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7817,7 +7825,7 @@ var Mnemonic = class {
7817
7825
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7818
7826
  );
7819
7827
  }
7820
- return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
7828
+ return (0, import_utils32.arrayify)((0, import_ethers2.computeHmac)("sha512", MasterSecret, seedArray));
7821
7829
  }
7822
7830
  /**
7823
7831
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7842,8 +7850,8 @@ var Mnemonic = class {
7842
7850
  chainCode,
7843
7851
  (0, import_utils32.concat)(["0x00", privateKey])
7844
7852
  ]);
7845
- const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
7846
- return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7853
+ const checksum = (0, import_ethers2.dataSlice)((0, import_hasher5.sha256)((0, import_hasher5.sha256)(extendedKey)), 0, 4);
7854
+ return (0, import_ethers2.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7847
7855
  }
7848
7856
  /**
7849
7857
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7858,7 +7866,7 @@ var Mnemonic = class {
7858
7866
  * @returns A randomly generated mnemonic
7859
7867
  */
7860
7868
  static generate(size = 32, extraEntropy = "") {
7861
- const entropy = extraEntropy ? (0, import_ethers4.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7869
+ const entropy = extraEntropy ? (0, import_hasher5.sha256)((0, import_utils32.concat)([(0, import_crypto3.randomBytes)(size), (0, import_utils32.arrayify)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7862
7870
  return Mnemonic.entropyToMnemonic(entropy);
7863
7871
  }
7864
7872
  };
@@ -7871,7 +7879,7 @@ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7871
7879
  var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7872
7880
  var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7873
7881
  function base58check(data) {
7874
- return (0, import_ethers5.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers5.dataSlice)((0, import_ethers5.sha256)((0, import_ethers5.sha256)(data)), 0, 4)]));
7882
+ return (0, import_ethers3.encodeBase58)((0, import_utils34.concat)([data, (0, import_ethers3.dataSlice)((0, import_hasher6.sha256)((0, import_hasher6.sha256)(data)), 0, 4)]));
7875
7883
  }
7876
7884
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7877
7885
  if (isPublic) {
@@ -7927,7 +7935,7 @@ var HDWallet = class {
7927
7935
  this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7928
7936
  }
7929
7937
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7930
- this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
7938
+ this.fingerprint = (0, import_ethers3.dataSlice)((0, import_ethers3.ripemd160)((0, import_hasher6.sha256)(this.publicKey)), 0, 4);
7931
7939
  this.depth = config.depth || this.depth;
7932
7940
  this.index = config.index || this.index;
7933
7941
  this.chainCode = config.chainCode;
@@ -7959,7 +7967,7 @@ var HDWallet = class {
7959
7967
  data.set((0, import_utils34.arrayify)(this.publicKey));
7960
7968
  }
7961
7969
  data.set((0, import_math19.toBytes)(index, 4), 33);
7962
- const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
7970
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers3.computeHmac)("sha512", chainCode, data));
7963
7971
  const IL = bytes.slice(0, 32);
7964
7972
  const IR = bytes.slice(32);
7965
7973
  if (privateKey) {
@@ -8030,7 +8038,7 @@ var HDWallet = class {
8030
8038
  });
8031
8039
  }
8032
8040
  static fromExtendedKey(extendedKey) {
8033
- const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
8041
+ const decoded = (0, import_ethers3.toBeHex)((0, import_ethers3.decodeBase58)(extendedKey));
8034
8042
  const bytes = (0, import_utils34.arrayify)(decoded);
8035
8043
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
8036
8044
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -8645,13 +8653,13 @@ var StorageAbstract = class {
8645
8653
  // src/predicate/predicate.ts
8646
8654
  var import_abi_coder5 = require("@fuel-ts/abi-coder");
8647
8655
  var import_address10 = require("@fuel-ts/address");
8648
- var import_configs11 = require("@fuel-ts/address/configs");
8656
+ var import_configs12 = require("@fuel-ts/address/configs");
8649
8657
  var import_errors24 = require("@fuel-ts/errors");
8650
8658
  var import_transactions19 = require("@fuel-ts/transactions");
8651
8659
  var import_utils36 = require("@fuel-ts/utils");
8652
8660
 
8653
8661
  // src/predicate/utils/getPredicateRoot.ts
8654
- var import_hasher4 = require("@fuel-ts/hasher");
8662
+ var import_hasher7 = require("@fuel-ts/hasher");
8655
8663
  var import_merkle = require("@fuel-ts/merkle");
8656
8664
  var import_utils35 = require("@fuel-ts/utils");
8657
8665
  var getPredicateRoot = (bytecode) => {
@@ -8659,34 +8667,44 @@ var getPredicateRoot = (bytecode) => {
8659
8667
  const bytes = (0, import_utils35.arrayify)(bytecode);
8660
8668
  const chunks = (0, import_utils35.chunkAndPadBytes)(bytes, chunkSize);
8661
8669
  const codeRoot = (0, import_merkle.calcRoot)(chunks.map((c) => (0, import_utils35.hexlify)(c)));
8662
- const predicateRoot = (0, import_hasher4.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8670
+ const predicateRoot = (0, import_hasher7.hash)((0, import_utils35.concat)(["0x4655454C", codeRoot]));
8663
8671
  return predicateRoot;
8664
8672
  };
8665
8673
 
8666
8674
  // src/predicate/predicate.ts
8667
8675
  var Predicate = class extends Account {
8668
8676
  bytes;
8669
- predicateData = Uint8Array.from([]);
8670
- predicateArgs = [];
8677
+ predicateDataBytes = Uint8Array.from([]);
8678
+ predicateData = [];
8671
8679
  interface;
8672
8680
  /**
8673
8681
  * Creates an instance of the Predicate class.
8674
8682
  *
8675
- * @param bytes - The bytes of the predicate.
8683
+ * @param bytecode - The bytecode of the predicate.
8684
+ * @param abi - The JSON ABI of the predicate.
8676
8685
  * @param provider - The provider used to interact with the blockchain.
8677
- * @param jsonAbi - The JSON ABI of the predicate.
8686
+ * @param inputData - The predicate input data (optional).
8678
8687
  * @param configurableConstants - Optional configurable constants for the predicate.
8679
8688
  */
8680
- constructor(bytes, provider, jsonAbi, configurableConstants) {
8689
+ constructor({
8690
+ bytecode,
8691
+ abi,
8692
+ provider,
8693
+ inputData,
8694
+ configurableConstants
8695
+ }) {
8681
8696
  const { predicateBytes, predicateInterface } = Predicate.processPredicateData(
8682
- bytes,
8683
- jsonAbi,
8697
+ bytecode,
8698
+ abi,
8684
8699
  configurableConstants
8685
8700
  );
8686
8701
  const address = import_address10.Address.fromB256(getPredicateRoot(predicateBytes));
8687
8702
  super(address, provider);
8688
8703
  this.bytes = predicateBytes;
8689
8704
  this.interface = predicateInterface;
8705
+ if (inputData !== void 0 && inputData.length > 0) {
8706
+ this.predicateData = inputData;
8707
+ }
8690
8708
  }
8691
8709
  /**
8692
8710
  * Populates the transaction data with predicate data.
@@ -8714,7 +8732,7 @@ var Predicate = class extends Account {
8714
8732
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
8715
8733
  * @returns A promise that resolves to the prepared transaction request.
8716
8734
  */
8717
- async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
8735
+ async createTransfer(destination, amount, assetId = import_configs12.BaseAssetId, txParams = {}) {
8718
8736
  const request = await super.createTransfer(destination, amount, assetId, txParams);
8719
8737
  return this.populateTransactionPredicateData(request);
8720
8738
  }
@@ -8738,18 +8756,8 @@ var Predicate = class extends Account {
8738
8756
  const transactionRequest = this.populateTransactionPredicateData(transactionRequestLike);
8739
8757
  return super.simulateTransaction(transactionRequest);
8740
8758
  }
8741
- /**
8742
- * Sets data for the predicate.
8743
- *
8744
- * @param args - Arguments for the predicate function.
8745
- * @returns The Predicate instance with updated predicate data.
8746
- */
8747
- setData(...args) {
8748
- this.predicateArgs = args;
8749
- return this;
8750
- }
8751
8759
  getPredicateData(policiesLength) {
8752
- if (!this.predicateArgs.length) {
8760
+ if (!this.predicateData.length) {
8753
8761
  return new Uint8Array();
8754
8762
  }
8755
8763
  const mainFn = this.interface?.functions.main;
@@ -8758,7 +8766,7 @@ var Predicate = class extends Account {
8758
8766
  maxInputs: this.provider.getChain().consensusParameters.maxInputs.toNumber()
8759
8767
  });
8760
8768
  const OFFSET = VM_TX_MEMORY + import_abi_coder5.SCRIPT_FIXED_SIZE + import_abi_coder5.INPUT_COIN_FIXED_SIZE + import_abi_coder5.WORD_SIZE + paddedCode.byteLength + policiesLength * import_abi_coder5.WORD_SIZE;
8761
- return mainFn?.encodeArguments(this.predicateArgs, OFFSET) || new Uint8Array();
8769
+ return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
8762
8770
  }
8763
8771
  /**
8764
8772
  * Processes the predicate data and returns the altered bytecode and interface.
@@ -8872,17 +8880,6 @@ var FuelConnectorEventTypes = /* @__PURE__ */ ((FuelConnectorEventTypes2) => {
8872
8880
  })(FuelConnectorEventTypes || {});
8873
8881
  var FuelConnectorEventType = "FuelConnector";
8874
8882
 
8875
- // src/connectors/types/data-type.ts
8876
- var MessageTypes = /* @__PURE__ */ ((MessageTypes2) => {
8877
- MessageTypes2["ping"] = "ping";
8878
- MessageTypes2["uiEvent"] = "uiEvent";
8879
- MessageTypes2["event"] = "event";
8880
- MessageTypes2["request"] = "request";
8881
- MessageTypes2["response"] = "response";
8882
- MessageTypes2["removeConnection"] = "removeConnection";
8883
- return MessageTypes2;
8884
- })(MessageTypes || {});
8885
-
8886
8883
  // src/connectors/types/local-storage.ts
8887
8884
  var LocalStorage = class {
8888
8885
  storage;
@@ -9520,7 +9517,6 @@ __publicField(Fuel, "defaultConfig", {});
9520
9517
  LocalStorage,
9521
9518
  MNEMONIC_SIZES,
9522
9519
  MemoryStorage,
9523
- MessageTypes,
9524
9520
  Mnemonic,
9525
9521
  MnemonicVault,
9526
9522
  NoWitnessAtIndexError,
@@ -9558,10 +9554,6 @@ __publicField(Fuel, "defaultConfig", {});
9558
9554
  english,
9559
9555
  extractBurnedAssetsFromReceipts,
9560
9556
  extractMintedAssetsFromReceipts,
9561
- fromDateToTai64,
9562
- fromTai64ToDate,
9563
- fromTai64ToUnix,
9564
- fromUnixToTai64,
9565
9557
  gasUsedByInputs,
9566
9558
  getAssetEth,
9567
9559
  getAssetFuel,
@@ -9569,7 +9561,6 @@ __publicField(Fuel, "defaultConfig", {});
9569
9561
  getAssetWithNetwork,
9570
9562
  getContractCallOperations,
9571
9563
  getContractCreatedOperations,
9572
- getContractTransferOperations,
9573
9564
  getDecodedLogs,
9574
9565
  getDefaultChainId,
9575
9566
  getGasUsedFromReceipts,