@fuel-ts/account 0.74.0 → 0.75.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.

Potentially problematic release.


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

Files changed (100) hide show
  1. package/dist/account.d.ts +4 -5
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel-connector.d.ts +2 -1
  4. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  5. package/dist/connectors/fuel.d.ts +1 -2
  6. package/dist/connectors/fuel.d.ts.map +1 -1
  7. package/dist/connectors/types/data-type.d.ts +0 -8
  8. package/dist/connectors/types/data-type.d.ts.map +1 -1
  9. package/dist/connectors/types/events.d.ts +2 -36
  10. package/dist/connectors/types/events.d.ts.map +1 -1
  11. package/dist/connectors/types/index.d.ts +0 -2
  12. package/dist/connectors/types/index.d.ts.map +1 -1
  13. package/dist/hdwallet/hdwallet.d.ts +1 -1
  14. package/dist/hdwallet/hdwallet.d.ts.map +1 -1
  15. package/dist/index.global.js +1358 -1074
  16. package/dist/index.global.js.map +1 -1
  17. package/dist/index.js +569 -426
  18. package/dist/index.js.map +1 -1
  19. package/dist/index.mjs +486 -362
  20. package/dist/index.mjs.map +1 -1
  21. package/dist/mnemonic/mnemonic.d.ts +1 -1
  22. package/dist/mnemonic/mnemonic.d.ts.map +1 -1
  23. package/dist/mnemonic/utils.d.ts +1 -1
  24. package/dist/mnemonic/utils.d.ts.map +1 -1
  25. package/dist/predicate/utils/getPredicateRoot.d.ts +1 -1
  26. package/dist/predicate/utils/getPredicateRoot.d.ts.map +1 -1
  27. package/dist/providers/assets/index.d.ts +4 -0
  28. package/dist/providers/assets/index.d.ts.map +1 -0
  29. package/dist/providers/assets/types.d.ts +36 -0
  30. package/dist/providers/assets/types.d.ts.map +1 -0
  31. package/dist/providers/assets/utils/index.d.ts +4 -0
  32. package/dist/providers/assets/utils/index.d.ts.map +1 -0
  33. package/dist/providers/assets/utils/network.d.ts +33 -0
  34. package/dist/providers/assets/utils/network.d.ts.map +1 -0
  35. package/dist/providers/assets/utils/resolveIconPaths.d.ts +14 -0
  36. package/dist/providers/assets/utils/resolveIconPaths.d.ts.map +1 -0
  37. package/dist/providers/assets/utils/url.d.ts +2 -0
  38. package/dist/providers/assets/utils/url.d.ts.map +1 -0
  39. package/dist/providers/chains.d.ts +11 -0
  40. package/dist/providers/chains.d.ts.map +1 -0
  41. package/dist/providers/coin-quantity.d.ts +1 -1
  42. package/dist/providers/coin-quantity.d.ts.map +1 -1
  43. package/dist/providers/fuel-graphql-subscriber.d.ts +13 -3
  44. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  45. package/dist/providers/index.d.ts +2 -0
  46. package/dist/providers/index.d.ts.map +1 -1
  47. package/dist/providers/memory-cache.d.ts +1 -1
  48. package/dist/providers/memory-cache.d.ts.map +1 -1
  49. package/dist/providers/message.d.ts +1 -2
  50. package/dist/providers/message.d.ts.map +1 -1
  51. package/dist/providers/provider.d.ts +17 -7
  52. package/dist/providers/provider.d.ts.map +1 -1
  53. package/dist/providers/resource.d.ts +1 -1
  54. package/dist/providers/resource.d.ts.map +1 -1
  55. package/dist/providers/transaction-request/create-transaction-request.d.ts +1 -1
  56. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  57. package/dist/providers/transaction-request/hash-transaction.d.ts.map +1 -1
  58. package/dist/providers/transaction-request/input.d.ts +1 -1
  59. package/dist/providers/transaction-request/input.d.ts.map +1 -1
  60. package/dist/providers/transaction-request/output.d.ts +1 -1
  61. package/dist/providers/transaction-request/output.d.ts.map +1 -1
  62. package/dist/providers/transaction-request/script-transaction-request.d.ts +1 -2
  63. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  64. package/dist/providers/transaction-request/storage-slot.d.ts +1 -1
  65. package/dist/providers/transaction-request/storage-slot.d.ts.map +1 -1
  66. package/dist/providers/transaction-request/transaction-request.d.ts +2 -10
  67. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  68. package/dist/providers/transaction-request/witness.d.ts +1 -1
  69. package/dist/providers/transaction-request/witness.d.ts.map +1 -1
  70. package/dist/providers/transaction-summary/operations.d.ts +0 -2
  71. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  72. package/dist/providers/transaction-summary/output.d.ts +2 -2
  73. package/dist/providers/transaction-summary/output.d.ts.map +1 -1
  74. package/dist/providers/transaction-summary/types.d.ts +0 -1
  75. package/dist/providers/transaction-summary/types.d.ts.map +1 -1
  76. package/dist/providers/utils/gas.d.ts.map +1 -1
  77. package/dist/signer/signer.d.ts +1 -1
  78. package/dist/signer/signer.d.ts.map +1 -1
  79. package/dist/test-utils/launchNode.d.ts.map +1 -1
  80. package/dist/test-utils.global.js +4010 -3792
  81. package/dist/test-utils.global.js.map +1 -1
  82. package/dist/test-utils.js +462 -402
  83. package/dist/test-utils.js.map +1 -1
  84. package/dist/test-utils.mjs +384 -336
  85. package/dist/test-utils.mjs.map +1 -1
  86. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -2
  87. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  88. package/dist/wallet/base-wallet-unlocked.d.ts +4 -4
  89. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  90. package/dist/wallet/wallet.d.ts +1 -2
  91. package/dist/wallet/wallet.d.ts.map +1 -1
  92. package/dist/wallet/wallets.d.ts +1 -1
  93. package/dist/wallet/wallets.d.ts.map +1 -1
  94. package/package.json +16 -16
  95. package/dist/connectors/types/asset.d.ts +0 -2
  96. package/dist/connectors/types/asset.d.ts.map +0 -1
  97. package/dist/connectors/types/constants.d.ts +0 -7
  98. package/dist/connectors/types/constants.d.ts.map +0 -1
  99. package/dist/connectors/types/message.d.ts +0 -15
  100. package/dist/connectors/types/message.d.ts.map +0 -1
@@ -58,19 +58,20 @@ module.exports = __toCommonJS(test_utils_exports);
58
58
 
59
59
  // src/wallet/base-wallet-unlocked.ts
60
60
  var import_hasher3 = require("@fuel-ts/hasher");
61
+ var import_utils30 = require("@fuel-ts/utils");
61
62
 
62
63
  // src/account.ts
63
64
  var import_address4 = require("@fuel-ts/address");
64
- var import_configs10 = require("@fuel-ts/address/configs");
65
+ var import_configs11 = require("@fuel-ts/address/configs");
65
66
  var import_errors15 = require("@fuel-ts/errors");
66
67
  var import_interfaces = require("@fuel-ts/interfaces");
67
68
  var import_math17 = require("@fuel-ts/math");
68
- var import_ethers21 = require("ethers");
69
+ var import_utils27 = require("@fuel-ts/utils");
69
70
 
70
71
  // src/providers/coin-quantity.ts
71
72
  var import_configs = require("@fuel-ts/address/configs");
72
73
  var import_math = require("@fuel-ts/math");
73
- var import_ethers = require("ethers");
74
+ var import_utils = require("@fuel-ts/utils");
74
75
  var coinQuantityfy = (coinQuantityLike) => {
75
76
  let assetId;
76
77
  let amount;
@@ -86,7 +87,7 @@ var coinQuantityfy = (coinQuantityLike) => {
86
87
  }
87
88
  const bnAmount = (0, import_math.bn)(amount);
88
89
  return {
89
- assetId: (0, import_ethers.hexlify)(assetId),
90
+ assetId: (0, import_utils.hexlify)(assetId),
90
91
  amount: bnAmount.lt(1) ? (0, import_math.bn)(1) : bnAmount,
91
92
  max: max2 ? (0, import_math.bn)(max2) : void 0
92
93
  };
@@ -108,8 +109,10 @@ var import_address3 = require("@fuel-ts/address");
108
109
  var import_errors13 = require("@fuel-ts/errors");
109
110
  var import_math14 = require("@fuel-ts/math");
110
111
  var import_transactions17 = require("@fuel-ts/transactions");
112
+ var import_utils22 = require("@fuel-ts/utils");
111
113
  var import_versions = require("@fuel-ts/versions");
112
- var import_ethers18 = require("ethers");
114
+ var import_utils23 = require("@noble/curves/abstract/utils");
115
+ var import_ethers2 = require("ethers");
113
116
  var import_graphql_request = require("graphql-request");
114
117
  var import_ramda3 = require("ramda");
115
118
 
@@ -918,71 +921,67 @@ function getSdk(requester) {
918
921
  // src/providers/fuel-graphql-subscriber.ts
919
922
  var import_errors = require("@fuel-ts/errors");
920
923
  var import_graphql = require("graphql");
921
- var _FuelSubscriptionStream = class {
922
- readable;
923
- writable;
924
- readableStreamController;
925
- constructor() {
926
- this.readable = new ReadableStream({
927
- start: (controller) => {
928
- this.readableStreamController = controller;
929
- }
930
- });
931
- this.writable = new WritableStream({
932
- write: (bytes) => {
933
- const text = _FuelSubscriptionStream.textDecoder.decode(bytes);
934
- if (text.startsWith("data:")) {
935
- const { data, errors } = JSON.parse(text.split("data:")[1]);
936
- if (Array.isArray(errors)) {
937
- this.readableStreamController.enqueue(
938
- new import_errors.FuelError(
939
- import_errors.FuelError.CODES.INVALID_REQUEST,
940
- errors.map((err) => err.message).join("\n\n")
941
- )
942
- );
943
- } else {
944
- this.readableStreamController.enqueue(data);
945
- }
946
- }
924
+ var _FuelGraphqlSubscriber = class {
925
+ constructor(options) {
926
+ this.options = options;
927
+ }
928
+ stream;
929
+ async setStream() {
930
+ const { url, query, variables, fetchFn } = this.options;
931
+ const response = await fetchFn(`${url}-sub`, {
932
+ method: "POST",
933
+ body: JSON.stringify({
934
+ query: (0, import_graphql.print)(query),
935
+ variables
936
+ }),
937
+ headers: {
938
+ "Content-Type": "application/json",
939
+ Accept: "text/event-stream"
947
940
  }
948
941
  });
942
+ this.stream = response.body.getReader();
949
943
  }
950
- };
951
- var FuelSubscriptionStream = _FuelSubscriptionStream;
952
- __publicField(FuelSubscriptionStream, "textDecoder", new TextDecoder());
953
- async function* fuelGraphQLSubscriber({
954
- url,
955
- variables,
956
- query,
957
- fetchFn
958
- }) {
959
- const response = await fetchFn(`${url}-sub`, {
960
- method: "POST",
961
- body: JSON.stringify({
962
- query: (0, import_graphql.print)(query),
963
- variables
964
- }),
965
- headers: {
966
- "Content-Type": "application/json",
967
- Accept: "text/event-stream"
944
+ async next() {
945
+ if (!this.stream) {
946
+ await this.setStream();
968
947
  }
969
- });
970
- const subscriptionStreamReader = response.body.pipeThrough(new FuelSubscriptionStream()).getReader();
971
- while (true) {
972
- const { value, done } = await subscriptionStreamReader.read();
973
- if (value instanceof import_errors.FuelError) {
974
- throw value;
975
- }
976
- yield value;
977
- if (done) {
978
- break;
948
+ while (true) {
949
+ const { value, done } = await this.stream.read();
950
+ if (done) {
951
+ return { value, done };
952
+ }
953
+ const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
954
+ if (!text.startsWith("data:")) {
955
+ continue;
956
+ }
957
+ const { data, errors } = JSON.parse(text.split("data:")[1]);
958
+ if (Array.isArray(errors)) {
959
+ throw new import_errors.FuelError(
960
+ import_errors.FuelError.CODES.INVALID_REQUEST,
961
+ errors.map((err) => err.message).join("\n\n")
962
+ );
963
+ }
964
+ return { value: data, done: false };
979
965
  }
980
966
  }
981
- }
967
+ /**
968
+ * Gets called when `break` is called in a `for-await-of` loop.
969
+ */
970
+ async return() {
971
+ await this.stream.cancel();
972
+ this.stream.releaseLock();
973
+ return { done: true, value: void 0 };
974
+ }
975
+ [Symbol.asyncIterator]() {
976
+ return this;
977
+ }
978
+ };
979
+ var FuelGraphqlSubscriber = _FuelGraphqlSubscriber;
980
+ __publicField(FuelGraphqlSubscriber, "textDecoder", new TextDecoder());
982
981
 
983
982
  // src/providers/memory-cache.ts
984
983
  var import_errors2 = require("@fuel-ts/errors");
985
- var import_ethers2 = require("ethers");
984
+ var import_utils2 = require("@fuel-ts/utils");
986
985
  var cache = {};
987
986
  var DEFAULT_TTL_IN_MS = 30 * 1e3;
988
987
  var MemoryCache = class {
@@ -997,7 +996,7 @@ var MemoryCache = class {
997
996
  }
998
997
  }
999
998
  get(value, isAutoExpiring = true) {
1000
- const key = (0, import_ethers2.hexlify)(value);
999
+ const key = (0, import_utils2.hexlify)(value);
1001
1000
  if (cache[key]) {
1002
1001
  if (!isAutoExpiring || cache[key].expires > Date.now()) {
1003
1002
  return cache[key].value;
@@ -1008,7 +1007,7 @@ var MemoryCache = class {
1008
1007
  }
1009
1008
  set(value) {
1010
1009
  const expiresAt = Date.now() + this.ttl;
1011
- const key = (0, import_ethers2.hexlify)(value);
1010
+ const key = (0, import_utils2.hexlify)(value);
1012
1011
  cache[key] = {
1013
1012
  expires: expiresAt,
1014
1013
  value
@@ -1034,7 +1033,7 @@ var MemoryCache = class {
1034
1033
  }, []);
1035
1034
  }
1036
1035
  del(value) {
1037
- const key = (0, import_ethers2.hexlify)(value);
1036
+ const key = (0, import_utils2.hexlify)(value);
1038
1037
  delete cache[key];
1039
1038
  }
1040
1039
  };
@@ -1044,31 +1043,31 @@ var import_configs2 = require("@fuel-ts/address/configs");
1044
1043
  var import_errors3 = require("@fuel-ts/errors");
1045
1044
  var import_math2 = require("@fuel-ts/math");
1046
1045
  var import_transactions = require("@fuel-ts/transactions");
1047
- var import_ethers3 = require("ethers");
1046
+ var import_utils3 = require("@fuel-ts/utils");
1048
1047
  var inputify = (value) => {
1049
1048
  const { type } = value;
1050
1049
  switch (value.type) {
1051
1050
  case import_transactions.InputType.Coin: {
1052
- const predicate = (0, import_ethers3.getBytesCopy)(value.predicate ?? "0x");
1053
- const predicateData = (0, import_ethers3.getBytesCopy)(value.predicateData ?? "0x");
1051
+ const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
1052
+ const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1054
1053
  return {
1055
1054
  type: import_transactions.InputType.Coin,
1056
- txID: (0, import_ethers3.hexlify)((0, import_ethers3.getBytesCopy)(value.id).slice(0, 32)),
1057
- outputIndex: (0, import_ethers3.getBytesCopy)(value.id)[32],
1058
- owner: (0, import_ethers3.hexlify)(value.owner),
1055
+ txID: (0, import_utils3.hexlify)((0, import_utils3.arrayify)(value.id).slice(0, 32)),
1056
+ outputIndex: (0, import_utils3.arrayify)(value.id)[32],
1057
+ owner: (0, import_utils3.hexlify)(value.owner),
1059
1058
  amount: (0, import_math2.bn)(value.amount),
1060
- assetId: (0, import_ethers3.hexlify)(value.assetId),
1059
+ assetId: (0, import_utils3.hexlify)(value.assetId),
1061
1060
  txPointer: {
1062
- blockHeight: (0, import_math2.toNumber)((0, import_ethers3.getBytesCopy)(value.txPointer).slice(0, 8)),
1063
- txIndex: (0, import_math2.toNumber)((0, import_ethers3.getBytesCopy)(value.txPointer).slice(8, 16))
1061
+ blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1062
+ txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1064
1063
  },
1065
1064
  witnessIndex: value.witnessIndex,
1066
1065
  maturity: value.maturity ?? 0,
1067
1066
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1068
1067
  predicateLength: predicate.length,
1069
1068
  predicateDataLength: predicateData.length,
1070
- predicate: (0, import_ethers3.hexlify)(predicate),
1071
- predicateData: (0, import_ethers3.hexlify)(predicateData)
1069
+ predicate: (0, import_utils3.hexlify)(predicate),
1070
+ predicateData: (0, import_utils3.hexlify)(predicateData)
1072
1071
  };
1073
1072
  }
1074
1073
  case import_transactions.InputType.Contract: {
@@ -1079,29 +1078,29 @@ var inputify = (value) => {
1079
1078
  balanceRoot: import_configs2.ZeroBytes32,
1080
1079
  stateRoot: import_configs2.ZeroBytes32,
1081
1080
  txPointer: {
1082
- blockHeight: (0, import_math2.toNumber)((0, import_ethers3.getBytesCopy)(value.txPointer).slice(0, 8)),
1083
- txIndex: (0, import_math2.toNumber)((0, import_ethers3.getBytesCopy)(value.txPointer).slice(8, 16))
1081
+ blockHeight: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(0, 8)),
1082
+ txIndex: (0, import_math2.toNumber)((0, import_utils3.arrayify)(value.txPointer).slice(8, 16))
1084
1083
  },
1085
- contractID: (0, import_ethers3.hexlify)(value.contractId)
1084
+ contractID: (0, import_utils3.hexlify)(value.contractId)
1086
1085
  };
1087
1086
  }
1088
1087
  case import_transactions.InputType.Message: {
1089
- const predicate = (0, import_ethers3.getBytesCopy)(value.predicate ?? "0x");
1090
- const predicateData = (0, import_ethers3.getBytesCopy)(value.predicateData ?? "0x");
1091
- const data = (0, import_ethers3.getBytesCopy)(value.data ?? "0x");
1088
+ const predicate = (0, import_utils3.arrayify)(value.predicate ?? "0x");
1089
+ const predicateData = (0, import_utils3.arrayify)(value.predicateData ?? "0x");
1090
+ const data = (0, import_utils3.arrayify)(value.data ?? "0x");
1092
1091
  return {
1093
1092
  type: import_transactions.InputType.Message,
1094
- sender: (0, import_ethers3.hexlify)(value.sender),
1095
- recipient: (0, import_ethers3.hexlify)(value.recipient),
1093
+ sender: (0, import_utils3.hexlify)(value.sender),
1094
+ recipient: (0, import_utils3.hexlify)(value.recipient),
1096
1095
  amount: (0, import_math2.bn)(value.amount),
1097
- nonce: (0, import_ethers3.hexlify)(value.nonce),
1096
+ nonce: (0, import_utils3.hexlify)(value.nonce),
1098
1097
  witnessIndex: value.witnessIndex,
1099
1098
  predicateGasUsed: (0, import_math2.bn)(value.predicateGasUsed),
1100
1099
  predicateLength: predicate.length,
1101
1100
  predicateDataLength: predicateData.length,
1102
- predicate: (0, import_ethers3.hexlify)(predicate),
1103
- predicateData: (0, import_ethers3.hexlify)(predicateData),
1104
- data: (0, import_ethers3.hexlify)(data),
1101
+ predicate: (0, import_utils3.hexlify)(predicate),
1102
+ predicateData: (0, import_utils3.hexlify)(predicateData),
1103
+ data: (0, import_utils3.hexlify)(data),
1105
1104
  dataLength: data.length
1106
1105
  };
1107
1106
  }
@@ -1119,16 +1118,16 @@ var import_configs3 = require("@fuel-ts/address/configs");
1119
1118
  var import_errors4 = require("@fuel-ts/errors");
1120
1119
  var import_math3 = require("@fuel-ts/math");
1121
1120
  var import_transactions2 = require("@fuel-ts/transactions");
1122
- var import_ethers4 = require("ethers");
1121
+ var import_utils4 = require("@fuel-ts/utils");
1123
1122
  var outputify = (value) => {
1124
1123
  const { type } = value;
1125
1124
  switch (type) {
1126
1125
  case import_transactions2.OutputType.Coin: {
1127
1126
  return {
1128
1127
  type: import_transactions2.OutputType.Coin,
1129
- to: (0, import_ethers4.hexlify)(value.to),
1128
+ to: (0, import_utils4.hexlify)(value.to),
1130
1129
  amount: (0, import_math3.bn)(value.amount),
1131
- assetId: (0, import_ethers4.hexlify)(value.assetId)
1130
+ assetId: (0, import_utils4.hexlify)(value.assetId)
1132
1131
  };
1133
1132
  }
1134
1133
  case import_transactions2.OutputType.Contract: {
@@ -1142,9 +1141,9 @@ var outputify = (value) => {
1142
1141
  case import_transactions2.OutputType.Change: {
1143
1142
  return {
1144
1143
  type: import_transactions2.OutputType.Change,
1145
- to: (0, import_ethers4.hexlify)(value.to),
1144
+ to: (0, import_utils4.hexlify)(value.to),
1146
1145
  amount: (0, import_math3.bn)(0),
1147
- assetId: (0, import_ethers4.hexlify)(value.assetId)
1146
+ assetId: (0, import_utils4.hexlify)(value.assetId)
1148
1147
  };
1149
1148
  }
1150
1149
  case import_transactions2.OutputType.Variable: {
@@ -1158,8 +1157,8 @@ var outputify = (value) => {
1158
1157
  case import_transactions2.OutputType.ContractCreated: {
1159
1158
  return {
1160
1159
  type: import_transactions2.OutputType.ContractCreated,
1161
- contractId: (0, import_ethers4.hexlify)(value.contractId),
1162
- stateRoot: (0, import_ethers4.hexlify)(value.stateRoot)
1160
+ contractId: (0, import_utils4.hexlify)(value.contractId),
1161
+ stateRoot: (0, import_utils4.hexlify)(value.stateRoot)
1163
1162
  };
1164
1163
  }
1165
1164
  default: {
@@ -1176,7 +1175,7 @@ var import_address = require("@fuel-ts/address");
1176
1175
  var import_configs6 = require("@fuel-ts/address/configs");
1177
1176
  var import_math6 = require("@fuel-ts/math");
1178
1177
  var import_transactions5 = require("@fuel-ts/transactions");
1179
- var import_ethers9 = require("ethers");
1178
+ var import_utils9 = require("@fuel-ts/utils");
1180
1179
 
1181
1180
  // src/providers/resource.ts
1182
1181
  var isCoin = (resource) => "id" in resource;
@@ -1187,7 +1186,7 @@ var import_errors5 = require("@fuel-ts/errors");
1187
1186
  var import_math4 = require("@fuel-ts/math");
1188
1187
  var import_transactions3 = require("@fuel-ts/transactions");
1189
1188
  var import_configs5 = require("@fuel-ts/transactions/configs");
1190
- var import_ethers5 = require("ethers");
1189
+ var import_utils5 = require("@fuel-ts/utils");
1191
1190
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === import_transactions3.ReceiptType.Revert && receipt.val.toString("hex") === import_configs5.FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
1192
1191
  var doesReceiptHaveMissingContractId = (receipt) => receipt.type === import_transactions3.ReceiptType.Panic && receipt.contractId !== "0x0000000000000000000000000000000000000000000000000000000000000000";
1193
1192
  var getReceiptsWithMissingData = (receipts) => receipts.reduce(
@@ -1331,7 +1330,7 @@ function assembleReceiptByType(receipt) {
1331
1330
  const recipient = hexOrZero(receipt.recipient);
1332
1331
  const nonce = hexOrZero(receipt.nonce);
1333
1332
  const amount = (0, import_math4.bn)(receipt.amount);
1334
- const data = receipt.data ? (0, import_ethers5.getBytesCopy)(receipt.data) : Uint8Array.from([]);
1333
+ const data = receipt.data ? (0, import_utils5.arrayify)(receipt.data) : Uint8Array.from([]);
1335
1334
  const digest = hexOrZero(receipt.digest);
1336
1335
  const messageId = import_transactions3.ReceiptMessageOutCoder.getMessageId({
1337
1336
  sender,
@@ -1393,7 +1392,7 @@ var import_errors6 = require("@fuel-ts/errors");
1393
1392
  // src/providers/utils/gas.ts
1394
1393
  var import_math5 = require("@fuel-ts/math");
1395
1394
  var import_transactions4 = require("@fuel-ts/transactions");
1396
- var import_ethers6 = require("ethers");
1395
+ var import_utils6 = require("@fuel-ts/utils");
1397
1396
  var calculatePriceWithFactor = (gas, gasPrice, priceFactor) => (0, import_math5.bn)(Math.ceil(gas.mul(gasPrice).toNumber() / priceFactor.toNumber()));
1398
1397
  var getGasUsedFromReceipts = (receipts) => {
1399
1398
  const scriptResult = receipts.filter(
@@ -1418,9 +1417,7 @@ function gasUsedByInputs(inputs, txBytesSize, gasCosts) {
1418
1417
  const totalGas = inputs.reduce((total, input) => {
1419
1418
  if ("predicate" in input && input.predicate && input.predicate !== "0x") {
1420
1419
  return total.add(
1421
- resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(
1422
- resolveGasDependentCosts((0, import_ethers6.getBytesCopy)(input.predicate).length, gasCosts.contractRoot)
1423
- ).add((0, import_math5.bn)(input.predicateGasUsed))
1420
+ resolveGasDependentCosts(txBytesSize, gasCosts.vmInitialization).add(resolveGasDependentCosts((0, import_utils6.arrayify)(input.predicate).length, gasCosts.contractRoot)).add((0, import_math5.bn)(input.predicateGasUsed))
1424
1421
  );
1425
1422
  }
1426
1423
  if ("witnessIndex" in input && !witnessCache.includes(input.witnessIndex)) {
@@ -1469,13 +1466,13 @@ function calculateMetadataGasForTxScript({
1469
1466
  }
1470
1467
 
1471
1468
  // src/providers/utils/json.ts
1472
- var import_ethers7 = require("ethers");
1469
+ var import_utils7 = require("@fuel-ts/utils");
1473
1470
  var import_ramda = require("ramda");
1474
1471
  function normalize(object) {
1475
1472
  Object.keys(object).forEach((key) => {
1476
1473
  switch (object[key]?.constructor.name) {
1477
1474
  case "Uint8Array":
1478
- object[key] = (0, import_ethers7.hexlify)(object[key]);
1475
+ object[key] = (0, import_utils7.hexlify)(object[key]);
1479
1476
  break;
1480
1477
  case "Array":
1481
1478
  object[key] = normalize(object[key]);
@@ -1522,11 +1519,11 @@ var NoWitnessAtIndexError = class extends Error {
1522
1519
  };
1523
1520
 
1524
1521
  // src/providers/transaction-request/witness.ts
1525
- var import_ethers8 = require("ethers");
1522
+ var import_utils8 = require("@fuel-ts/utils");
1526
1523
  var witnessify = (value) => {
1527
- const data = (0, import_ethers8.getBytesCopy)(value);
1524
+ const data = (0, import_utils8.arrayify)(value);
1528
1525
  return {
1529
- data: (0, import_ethers8.hexlify)(data),
1526
+ data: (0, import_utils8.hexlify)(data),
1530
1527
  dataLength: data.length
1531
1528
  };
1532
1529
  };
@@ -1646,7 +1643,7 @@ var BaseTransactionRequest = class {
1646
1643
  * Creates an empty witness without any side effects and returns the index
1647
1644
  */
1648
1645
  createWitness() {
1649
- this.witnesses.push((0, import_ethers9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1646
+ this.witnesses.push((0, import_utils9.concat)([import_configs6.ZeroBytes32, import_configs6.ZeroBytes32]));
1650
1647
  return this.witnesses.length - 1;
1651
1648
  }
1652
1649
  /**
@@ -1715,9 +1712,9 @@ var BaseTransactionRequest = class {
1715
1712
  const found = this.inputs.find((input) => {
1716
1713
  switch (input.type) {
1717
1714
  case import_transactions5.InputType.Coin:
1718
- return (0, import_ethers9.hexlify)(input.owner) === ownerAddress.toB256();
1715
+ return (0, import_utils9.hexlify)(input.owner) === ownerAddress.toB256();
1719
1716
  case import_transactions5.InputType.Message:
1720
- return (0, import_ethers9.hexlify)(input.recipient) === ownerAddress.toB256();
1717
+ return (0, import_utils9.hexlify)(input.recipient) === ownerAddress.toB256();
1721
1718
  default:
1722
1719
  return false;
1723
1720
  }
@@ -1883,7 +1880,7 @@ var BaseTransactionRequest = class {
1883
1880
  */
1884
1881
  addChangeOutput(to, assetId = import_configs6.BaseAssetId) {
1885
1882
  const changeOutput = this.getChangeOutputs().find(
1886
- (output) => (0, import_ethers9.hexlify)(output.assetId) === assetId
1883
+ (output) => (0, import_utils9.hexlify)(output.assetId) === assetId
1887
1884
  );
1888
1885
  if (!changeOutput) {
1889
1886
  this.pushOutput({
@@ -1996,19 +1993,27 @@ var BaseTransactionRequest = class {
1996
1993
  toJSON() {
1997
1994
  return normalizeJSON(this);
1998
1995
  }
1999
- /**
2000
- * @hidden
2001
- *
2002
- * Determines whether the transaction has a predicate input.
2003
- *
2004
- * @returns Whether the transaction has a predicate input.
2005
- */
2006
- hasPredicateInput() {
2007
- return Boolean(
2008
- this.inputs.find(
2009
- (input) => "predicate" in input && input.predicate && input.predicate !== (0, import_ethers9.getBytesCopy)("0x")
2010
- )
2011
- );
1996
+ updatePredicateInputs(inputs) {
1997
+ this.inputs.forEach((i) => {
1998
+ let correspondingInput;
1999
+ switch (i.type) {
2000
+ case import_transactions5.InputType.Coin:
2001
+ correspondingInput = inputs.find((x) => x.type === import_transactions5.InputType.Coin && x.owner === i.owner);
2002
+ break;
2003
+ case import_transactions5.InputType.Message:
2004
+ correspondingInput = inputs.find(
2005
+ (x) => x.type === import_transactions5.InputType.Message && x.sender === i.sender
2006
+ );
2007
+ break;
2008
+ default:
2009
+ return;
2010
+ }
2011
+ if (correspondingInput && "predicateGasUsed" in correspondingInput && (0, import_math6.bn)(correspondingInput.predicateGasUsed).gt(0)) {
2012
+ i.predicate = correspondingInput.predicate;
2013
+ i.predicateData = correspondingInput.predicateData;
2014
+ i.predicateGasUsed = correspondingInput.predicateGasUsed;
2015
+ }
2016
+ });
2012
2017
  }
2013
2018
  };
2014
2019
 
@@ -2016,14 +2021,15 @@ var BaseTransactionRequest = class {
2016
2021
  var import_configs8 = require("@fuel-ts/address/configs");
2017
2022
  var import_math8 = require("@fuel-ts/math");
2018
2023
  var import_transactions7 = require("@fuel-ts/transactions");
2019
- var import_ethers12 = require("ethers");
2024
+ var import_utils13 = require("@fuel-ts/utils");
2020
2025
 
2021
2026
  // src/providers/transaction-request/hash-transaction.ts
2022
2027
  var import_configs7 = require("@fuel-ts/address/configs");
2023
2028
  var import_hasher = require("@fuel-ts/hasher");
2024
2029
  var import_math7 = require("@fuel-ts/math");
2025
2030
  var import_transactions6 = require("@fuel-ts/transactions");
2026
- var import_ethers10 = require("ethers");
2031
+ var import_utils11 = require("@fuel-ts/utils");
2032
+ var import_ethers = require("ethers");
2027
2033
  var import_ramda2 = require("ramda");
2028
2034
  function hashTransaction(transactionRequest, chainId) {
2029
2035
  const transaction = transactionRequest.toTransaction();
@@ -2085,15 +2091,15 @@ function hashTransaction(transactionRequest, chainId) {
2085
2091
  transaction.witnessesCount = 0;
2086
2092
  transaction.witnesses = [];
2087
2093
  const chainIdBytes = (0, import_hasher.uint64ToBytesBE)(chainId);
2088
- const concatenatedData = (0, import_ethers10.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2089
- return (0, import_ethers10.sha256)(concatenatedData);
2094
+ const concatenatedData = (0, import_utils11.concat)([chainIdBytes, new import_transactions6.TransactionCoder().encode(transaction)]);
2095
+ return (0, import_ethers.sha256)(concatenatedData);
2090
2096
  }
2091
2097
 
2092
2098
  // src/providers/transaction-request/storage-slot.ts
2093
- var import_ethers11 = require("ethers");
2099
+ var import_utils12 = require("@fuel-ts/utils");
2094
2100
  var getStorageValue = (value) => {
2095
2101
  const v = new Uint8Array(32);
2096
- v.set((0, import_ethers11.getBytesCopy)(value));
2102
+ v.set((0, import_utils12.arrayify)(value));
2097
2103
  return v;
2098
2104
  };
2099
2105
  var storageSlotify = (storageSlot) => {
@@ -2107,8 +2113,8 @@ var storageSlotify = (storageSlot) => {
2107
2113
  value = storageSlot.value;
2108
2114
  }
2109
2115
  return {
2110
- key: (0, import_ethers11.hexlify)(key),
2111
- value: (0, import_ethers11.hexlify)(getStorageValue(value))
2116
+ key: (0, import_utils12.hexlify)(key),
2117
+ value: (0, import_utils12.hexlify)(getStorageValue(value))
2112
2118
  };
2113
2119
  };
2114
2120
 
@@ -2141,7 +2147,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2141
2147
  } = {}) {
2142
2148
  super(rest);
2143
2149
  this.bytecodeWitnessIndex = bytecodeWitnessIndex ?? 0;
2144
- this.salt = (0, import_ethers12.hexlify)(salt ?? import_configs8.ZeroBytes32);
2150
+ this.salt = (0, import_utils13.hexlify)(salt ?? import_configs8.ZeroBytes32);
2145
2151
  this.storageSlots = [...storageSlots ?? []];
2146
2152
  }
2147
2153
  /**
@@ -2159,7 +2165,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2159
2165
  bytecodeLength: baseTransaction.witnesses[bytecodeWitnessIndex].dataLength / 4,
2160
2166
  bytecodeWitnessIndex,
2161
2167
  storageSlotsCount: storageSlots.length,
2162
- salt: this.salt ? (0, import_ethers12.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2168
+ salt: this.salt ? (0, import_utils13.hexlify)(this.salt) : import_configs8.ZeroBytes32,
2163
2169
  storageSlots
2164
2170
  };
2165
2171
  }
@@ -2198,7 +2204,7 @@ var CreateTransactionRequest = class extends BaseTransactionRequest {
2198
2204
  }
2199
2205
  metadataGas(gasCosts) {
2200
2206
  return calculateMetadataGasForTxCreate({
2201
- contractBytesSize: (0, import_math8.bn)((0, import_ethers12.getBytesCopy)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2207
+ contractBytesSize: (0, import_math8.bn)((0, import_utils13.arrayify)(this.witnesses[this.bytecodeWitnessIndex] || "0x").length),
2202
2208
  gasCosts,
2203
2209
  stateRootSize: this.storageSlots.length,
2204
2210
  txBytesSize: this.byteSize()
@@ -2212,17 +2218,17 @@ var import_address2 = require("@fuel-ts/address");
2212
2218
  var import_configs9 = require("@fuel-ts/address/configs");
2213
2219
  var import_math9 = require("@fuel-ts/math");
2214
2220
  var import_transactions8 = require("@fuel-ts/transactions");
2215
- var import_ethers14 = require("ethers");
2221
+ var import_utils15 = require("@fuel-ts/utils");
2216
2222
 
2217
2223
  // src/providers/transaction-request/scripts.ts
2218
- var import_ethers13 = require("ethers");
2224
+ var import_utils14 = require("@fuel-ts/utils");
2219
2225
  var returnZeroScript = {
2220
2226
  /*
2221
2227
  Opcode::RET(REG_ZERO)
2222
2228
  Opcode::NOOP
2223
2229
  */
2224
2230
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2225
- bytes: (0, import_ethers13.getBytesCopy)("0x24000000"),
2231
+ bytes: (0, import_utils14.arrayify)("0x24000000"),
2226
2232
  encodeScriptData: () => new Uint8Array(0)
2227
2233
  };
2228
2234
  var withdrawScript = {
@@ -2236,7 +2242,7 @@ var withdrawScript = {
2236
2242
  00000000 00000000 [amount value]
2237
2243
  */
2238
2244
  // TODO: Don't use hardcoded scripts: https://github.com/FuelLabs/fuels-ts/issues/281
2239
- bytes: (0, import_ethers13.getBytesCopy)("0x5040C0105D44C0064C40001124000000"),
2245
+ bytes: (0, import_utils14.arrayify)("0x5040C0105D44C0064C40001124000000"),
2240
2246
  encodeScriptData: () => new Uint8Array(0)
2241
2247
  };
2242
2248
 
@@ -2264,8 +2270,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2264
2270
  constructor({ script, scriptData, gasLimit, ...rest } = {}) {
2265
2271
  super(rest);
2266
2272
  this.gasLimit = (0, import_math9.bn)(gasLimit);
2267
- this.script = (0, import_ethers14.getBytesCopy)(script ?? returnZeroScript.bytes);
2268
- this.scriptData = (0, import_ethers14.getBytesCopy)(scriptData ?? returnZeroScript.encodeScriptData());
2273
+ this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2274
+ this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2269
2275
  }
2270
2276
  /**
2271
2277
  * Converts the transaction request to a `TransactionScript`.
@@ -2273,8 +2279,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2273
2279
  * @returns The transaction script object.
2274
2280
  */
2275
2281
  toTransaction() {
2276
- const script = (0, import_ethers14.getBytesCopy)(this.script ?? "0x");
2277
- const scriptData = (0, import_ethers14.getBytesCopy)(this.scriptData ?? "0x");
2282
+ const script = (0, import_utils15.arrayify)(this.script ?? "0x");
2283
+ const scriptData = (0, import_utils15.arrayify)(this.scriptData ?? "0x");
2278
2284
  return {
2279
2285
  type: import_transactions8.TransactionType.Script,
2280
2286
  scriptGasLimit: this.gasLimit,
@@ -2282,8 +2288,8 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2282
2288
  scriptLength: script.length,
2283
2289
  scriptDataLength: scriptData.length,
2284
2290
  receiptsRoot: import_configs9.ZeroBytes32,
2285
- script: (0, import_ethers14.hexlify)(script),
2286
- scriptData: (0, import_ethers14.hexlify)(scriptData)
2291
+ script: (0, import_utils15.hexlify)(script),
2292
+ scriptData: (0, import_utils15.hexlify)(scriptData)
2287
2293
  };
2288
2294
  }
2289
2295
  /**
@@ -2434,15 +2440,15 @@ var transactionRequestify = (obj) => {
2434
2440
  var import_errors12 = require("@fuel-ts/errors");
2435
2441
  var import_math13 = require("@fuel-ts/math");
2436
2442
  var import_transactions15 = require("@fuel-ts/transactions");
2437
- var import_ethers17 = require("ethers");
2443
+ var import_utils21 = require("@fuel-ts/utils");
2438
2444
 
2439
2445
  // src/providers/transaction-summary/assemble-transaction-summary.ts
2440
- var import_ethers16 = require("ethers");
2446
+ var import_utils19 = require("@fuel-ts/utils");
2441
2447
 
2442
2448
  // src/providers/transaction-summary/calculate-transaction-fee.ts
2443
2449
  var import_math10 = require("@fuel-ts/math");
2444
2450
  var import_transactions10 = require("@fuel-ts/transactions");
2445
- var import_ethers15 = require("ethers");
2451
+ var import_utils16 = require("@fuel-ts/utils");
2446
2452
  var calculateTransactionFee = (params) => {
2447
2453
  const {
2448
2454
  gasUsed,
@@ -2451,7 +2457,7 @@ var calculateTransactionFee = (params) => {
2451
2457
  } = params;
2452
2458
  const gasPerByte = (0, import_math10.bn)(feeParams.gasPerByte);
2453
2459
  const gasPriceFactor = (0, import_math10.bn)(feeParams.gasPriceFactor);
2454
- const transactionBytes = (0, import_ethers15.getBytesCopy)(rawPayload);
2460
+ const transactionBytes = (0, import_utils16.arrayify)(rawPayload);
2455
2461
  const [transaction] = new import_transactions10.TransactionCoder().decode(transactionBytes, 0);
2456
2462
  if (transaction.type === import_transactions10.TransactionType.Mint) {
2457
2463
  return {
@@ -2466,7 +2472,7 @@ var calculateTransactionFee = (params) => {
2466
2472
  let gasLimit = (0, import_math10.bn)(0);
2467
2473
  if (type === import_transactions10.TransactionType.Create) {
2468
2474
  const { bytecodeWitnessIndex, storageSlots } = transaction;
2469
- const contractBytesSize = (0, import_math10.bn)((0, import_ethers15.getBytesCopy)(witnesses[bytecodeWitnessIndex].data).length);
2475
+ const contractBytesSize = (0, import_math10.bn)((0, import_utils16.arrayify)(witnesses[bytecodeWitnessIndex].data).length);
2470
2476
  metadataGas = calculateMetadataGasForTxCreate({
2471
2477
  contractBytesSize,
2472
2478
  gasCosts,
@@ -2520,6 +2526,7 @@ var fromTai64ToDate = (tai64Timestamp) => {
2520
2526
  };
2521
2527
 
2522
2528
  // src/providers/transaction-summary/operations.ts
2529
+ var import_configs10 = require("@fuel-ts/address/configs");
2523
2530
  var import_errors10 = require("@fuel-ts/errors");
2524
2531
  var import_math12 = require("@fuel-ts/math");
2525
2532
  var import_transactions13 = require("@fuel-ts/transactions");
@@ -2716,36 +2723,6 @@ function addOperation(operations, toAdd) {
2716
2723
  }
2717
2724
  return allOperations;
2718
2725
  }
2719
- function getReceiptsTransferOut(receipts) {
2720
- return getReceiptsByType(receipts, import_transactions13.ReceiptType.TransferOut);
2721
- }
2722
- function getContractTransferOperations({ receipts }) {
2723
- const transferOutReceipts = getReceiptsTransferOut(receipts);
2724
- const contractTransferOperations = transferOutReceipts.reduce(
2725
- (prevContractTransferOps, receipt) => {
2726
- const newContractTransferOps = addOperation(prevContractTransferOps, {
2727
- name: "Contract transfer" /* contractTransfer */,
2728
- from: {
2729
- type: 0 /* contract */,
2730
- address: receipt.from
2731
- },
2732
- to: {
2733
- type: 1 /* account */,
2734
- address: receipt.to
2735
- },
2736
- assetsSent: [
2737
- {
2738
- amount: receipt.amount,
2739
- assetId: receipt.assetId
2740
- }
2741
- ]
2742
- });
2743
- return newContractTransferOps;
2744
- },
2745
- []
2746
- );
2747
- return contractTransferOperations;
2748
- }
2749
2726
  function getWithdrawFromFuelOperations({
2750
2727
  inputs,
2751
2728
  receipts
@@ -2843,70 +2820,77 @@ function getContractCallOperations({
2843
2820
  }, []);
2844
2821
  return contractCallOperations;
2845
2822
  }
2823
+ function extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs) {
2824
+ const { to: toAddress, assetId, amount } = receipt;
2825
+ let { from: fromAddress } = receipt;
2826
+ const toType = contractInputs.some((input) => input.contractID === toAddress) ? 0 /* contract */ : 1 /* account */;
2827
+ if (import_configs10.ZeroBytes32 === fromAddress) {
2828
+ const change = changeOutputs.find((output) => output.assetId === assetId);
2829
+ fromAddress = change?.to || fromAddress;
2830
+ }
2831
+ const fromType = contractInputs.some((input) => input.contractID === fromAddress) ? 0 /* contract */ : 1 /* account */;
2832
+ return {
2833
+ name: "Transfer asset" /* transfer */,
2834
+ from: {
2835
+ type: fromType,
2836
+ address: fromAddress
2837
+ },
2838
+ to: {
2839
+ type: toType,
2840
+ address: toAddress
2841
+ },
2842
+ assetsSent: [
2843
+ {
2844
+ assetId: assetId.toString(),
2845
+ amount
2846
+ }
2847
+ ]
2848
+ };
2849
+ }
2846
2850
  function getTransferOperations({
2847
2851
  inputs,
2848
2852
  outputs,
2849
2853
  receipts
2850
2854
  }) {
2855
+ let operations = [];
2851
2856
  const coinOutputs = getOutputsCoin(outputs);
2852
- const [transferReceipt] = getReceiptsByType(
2857
+ const contractInputs = getInputsContract(inputs);
2858
+ const changeOutputs = getOutputsChange(outputs);
2859
+ coinOutputs.forEach((output) => {
2860
+ const { amount, assetId, to } = output;
2861
+ const changeOutput = changeOutputs.find((change) => change.assetId === assetId);
2862
+ if (changeOutput) {
2863
+ operations = addOperation(operations, {
2864
+ name: "Transfer asset" /* transfer */,
2865
+ from: {
2866
+ type: 1 /* account */,
2867
+ address: changeOutput.to
2868
+ },
2869
+ to: {
2870
+ type: 1 /* account */,
2871
+ address: to
2872
+ },
2873
+ assetsSent: [
2874
+ {
2875
+ assetId,
2876
+ amount
2877
+ }
2878
+ ]
2879
+ });
2880
+ }
2881
+ });
2882
+ const transferReceipts = getReceiptsByType(
2853
2883
  receipts,
2854
2884
  import_transactions13.ReceiptType.Transfer
2855
2885
  );
2856
- let operations = [];
2857
- if (transferReceipt) {
2858
- const changeOutputs = getOutputsChange(outputs);
2859
- changeOutputs.forEach((output) => {
2860
- const { assetId } = output;
2861
- const [contractInput] = getInputsContract(inputs);
2862
- const utxo = getInputFromAssetId(inputs, assetId);
2863
- if (utxo && contractInput) {
2864
- const inputAddress = getInputAccountAddress(utxo);
2865
- operations = addOperation(operations, {
2866
- name: "Transfer asset" /* transfer */,
2867
- from: {
2868
- type: 1 /* account */,
2869
- address: inputAddress
2870
- },
2871
- to: {
2872
- type: 0 /* contract */,
2873
- address: contractInput.contractID
2874
- },
2875
- assetsSent: [
2876
- {
2877
- assetId: assetId.toString(),
2878
- amount: transferReceipt.amount
2879
- }
2880
- ]
2881
- });
2882
- }
2883
- });
2884
- } else {
2885
- coinOutputs.forEach((output) => {
2886
- const input = getInputFromAssetId(inputs, output.assetId);
2887
- if (input) {
2888
- const inputAddress = getInputAccountAddress(input);
2889
- const operationToAdd = {
2890
- name: "Transfer asset" /* transfer */,
2891
- from: {
2892
- type: 1 /* account */,
2893
- address: inputAddress
2894
- },
2895
- to: {
2896
- type: 1 /* account */,
2897
- address: output.to.toString()
2898
- },
2899
- assetsSent: [
2900
- {
2901
- assetId: output.assetId.toString(),
2902
- amount: output.amount
2903
- }
2904
- ]
2905
- };
2906
- operations = addOperation(operations, operationToAdd);
2907
- }
2908
- });
2909
- }
2886
+ const transferOutReceipts = getReceiptsByType(
2887
+ receipts,
2888
+ import_transactions13.ReceiptType.TransferOut
2889
+ );
2890
+ [...transferReceipts, ...transferOutReceipts].forEach((receipt) => {
2891
+ const operation = extractTransferOperationFromReceipt(receipt, contractInputs, changeOutputs);
2892
+ operations = addOperation(operations, operation);
2893
+ });
2910
2894
  return operations;
2911
2895
  }
2912
2896
  function getPayProducerOperations(outputs) {
@@ -2979,7 +2963,6 @@ function getOperations({
2979
2963
  rawPayload,
2980
2964
  maxInputs
2981
2965
  }),
2982
- ...getContractTransferOperations({ receipts }),
2983
2966
  ...getWithdrawFromFuelOperations({ inputs, receipts })
2984
2967
  ];
2985
2968
  }
@@ -3108,7 +3091,7 @@ function assembleTransactionSummary(params) {
3108
3091
  gasCosts
3109
3092
  } = params;
3110
3093
  const gasUsed = getGasUsedFromReceipts(receipts);
3111
- const rawPayload = (0, import_ethers16.hexlify)(transactionBytes);
3094
+ const rawPayload = (0, import_utils19.hexlify)(transactionBytes);
3112
3095
  const operations = getOperations({
3113
3096
  transactionType: transaction.type,
3114
3097
  inputs: transaction.inputs || [],
@@ -3225,7 +3208,7 @@ var TransactionResponse = class {
3225
3208
  */
3226
3209
  decodeTransaction(transactionWithReceipts) {
3227
3210
  return new import_transactions15.TransactionCoder().decode(
3228
- (0, import_ethers17.getBytesCopy)(transactionWithReceipts.rawPayload),
3211
+ (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3229
3212
  0
3230
3213
  )?.[0];
3231
3214
  }
@@ -3251,7 +3234,7 @@ var TransactionResponse = class {
3251
3234
  id: this.id,
3252
3235
  receipts,
3253
3236
  transaction: decodedTransaction,
3254
- transactionBytes: (0, import_ethers17.getBytesCopy)(transaction.rawPayload),
3237
+ transactionBytes: (0, import_utils21.arrayify)(transaction.rawPayload),
3255
3238
  gqlTransactionStatus: transaction.status,
3256
3239
  gasPerByte,
3257
3240
  gasPriceFactor,
@@ -3541,7 +3524,7 @@ var _Provider = class {
3541
3524
  const opDefinition = query.definitions.find((x) => x.kind === "OperationDefinition");
3542
3525
  const isSubscription = opDefinition?.operation === "subscription";
3543
3526
  if (isSubscription) {
3544
- return fuelGraphQLSubscriber({
3527
+ return new FuelGraphqlSubscriber({
3545
3528
  url: this.url,
3546
3529
  query,
3547
3530
  fetchFn: (url, requestInit) => fetchFn(url, requestInit, this.options),
@@ -3575,7 +3558,7 @@ var _Provider = class {
3575
3558
  name,
3576
3559
  consensusParameters: { chainId }
3577
3560
  } = await this.getChain();
3578
- const network = new import_ethers18.Network(name, chainId.toNumber());
3561
+ const network = new import_ethers2.Network(name, chainId.toNumber());
3579
3562
  return Promise.resolve(network);
3580
3563
  }
3581
3564
  /**
@@ -3643,7 +3626,7 @@ var _Provider = class {
3643
3626
  if (estimateTxDependencies) {
3644
3627
  await this.estimateTxDependencies(transactionRequest);
3645
3628
  }
3646
- const encodedTransaction = (0, import_ethers18.hexlify)(transactionRequest.toTransactionBytes());
3629
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3647
3630
  if (awaitExecution) {
3648
3631
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3649
3632
  for await (const { submitAndAwait } of subscription) {
@@ -3674,9 +3657,9 @@ var _Provider = class {
3674
3657
  async call(transactionRequestLike, { utxoValidation, estimateTxDependencies = true } = {}) {
3675
3658
  const transactionRequest = transactionRequestify(transactionRequestLike);
3676
3659
  if (estimateTxDependencies) {
3677
- await this.estimateTxDependencies(transactionRequest);
3660
+ return this.estimateTxDependencies(transactionRequest);
3678
3661
  }
3679
- const encodedTransaction = (0, import_ethers18.hexlify)(transactionRequest.toTransactionBytes());
3662
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3680
3663
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3681
3664
  encodedTransaction,
3682
3665
  utxoValidation: utxoValidation || false
@@ -3693,7 +3676,15 @@ var _Provider = class {
3693
3676
  * @returns A promise that resolves to the estimated transaction request object.
3694
3677
  */
3695
3678
  async estimatePredicates(transactionRequest) {
3696
- const encodedTransaction = (0, import_ethers18.hexlify)(transactionRequest.toTransactionBytes());
3679
+ const shouldEstimatePredicates = Boolean(
3680
+ transactionRequest.inputs.find(
3681
+ (input) => "predicate" in input && input.predicate && !(0, import_utils23.equalBytes)((0, import_utils22.arrayify)(input.predicate), (0, import_utils22.arrayify)("0x")) && new import_math14.BN(input.predicateGasUsed).isZero()
3682
+ )
3683
+ );
3684
+ if (!shouldEstimatePredicates) {
3685
+ return transactionRequest;
3686
+ }
3687
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3697
3688
  const response = await this.operations.estimatePredicates({
3698
3689
  encodedTransaction
3699
3690
  });
@@ -3723,34 +3714,41 @@ var _Provider = class {
3723
3714
  * @returns A promise.
3724
3715
  */
3725
3716
  async estimateTxDependencies(transactionRequest) {
3726
- let missingOutputVariableCount = 0;
3727
- let missingOutputContractIdsCount = 0;
3728
- let tries = 0;
3729
3717
  if (transactionRequest.type === import_transactions17.TransactionType.Create) {
3730
- return;
3731
- }
3732
- let txRequest = transactionRequest;
3733
- if (txRequest.hasPredicateInput()) {
3734
- txRequest = await this.estimatePredicates(txRequest);
3718
+ return {
3719
+ receipts: [],
3720
+ outputVariables: 0,
3721
+ missingContractIds: []
3722
+ };
3735
3723
  }
3736
- while (tries < MAX_RETRIES) {
3724
+ await this.estimatePredicates(transactionRequest);
3725
+ let receipts = [];
3726
+ const missingContractIds = [];
3727
+ let outputVariables = 0;
3728
+ for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
3737
3729
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3738
- encodedTransaction: (0, import_ethers18.hexlify)(txRequest.toTransactionBytes()),
3730
+ encodedTransaction: (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes()),
3739
3731
  utxoValidation: false
3740
3732
  });
3741
- const receipts = gqlReceipts.map(processGqlReceipt);
3733
+ receipts = gqlReceipts.map(processGqlReceipt);
3742
3734
  const { missingOutputVariables, missingOutputContractIds } = getReceiptsWithMissingData(receipts);
3743
- missingOutputVariableCount = missingOutputVariables.length;
3744
- missingOutputContractIdsCount = missingOutputContractIds.length;
3745
- if (missingOutputVariableCount === 0 && missingOutputContractIdsCount === 0) {
3746
- return;
3735
+ const hasMissingOutputs = missingOutputVariables.length !== 0 || missingOutputContractIds.length !== 0;
3736
+ if (hasMissingOutputs) {
3737
+ outputVariables += missingOutputVariables.length;
3738
+ transactionRequest.addVariableOutputs(missingOutputVariables.length);
3739
+ missingOutputContractIds.forEach(({ contractId }) => {
3740
+ transactionRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId));
3741
+ missingContractIds.push(contractId);
3742
+ });
3743
+ } else {
3744
+ break;
3747
3745
  }
3748
- txRequest.addVariableOutputs(missingOutputVariableCount);
3749
- missingOutputContractIds.forEach(
3750
- ({ contractId }) => txRequest.addContractInputAndOutput(import_address3.Address.fromString(contractId))
3751
- );
3752
- tries += 1;
3753
3746
  }
3747
+ return {
3748
+ receipts,
3749
+ outputVariables,
3750
+ missingContractIds
3751
+ };
3754
3752
  }
3755
3753
  /**
3756
3754
  * Executes a signed transaction without applying the states changes
@@ -3765,9 +3763,9 @@ var _Provider = class {
3765
3763
  async simulate(transactionRequestLike, { estimateTxDependencies = true } = {}) {
3766
3764
  const transactionRequest = transactionRequestify(transactionRequestLike);
3767
3765
  if (estimateTxDependencies) {
3768
- await this.estimateTxDependencies(transactionRequest);
3766
+ return this.estimateTxDependencies(transactionRequest);
3769
3767
  }
3770
- const encodedTransaction = (0, import_ethers18.hexlify)(transactionRequest.toTransactionBytes());
3768
+ const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3771
3769
  const { dryRun: gqlReceipts } = await this.operations.dryRun({
3772
3770
  encodedTransaction,
3773
3771
  utxoValidation: true
@@ -3797,35 +3795,37 @@ var _Provider = class {
3797
3795
  estimatePredicates = true,
3798
3796
  resourcesOwner
3799
3797
  } = {}) {
3800
- const transactionRequest = transactionRequestify((0, import_ramda3.clone)(transactionRequestLike));
3798
+ const txRequestClone = (0, import_ramda3.clone)(transactionRequestify(transactionRequestLike));
3801
3799
  const chainInfo = this.getChain();
3802
3800
  const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
3803
- const gasPrice = (0, import_math14.max)(transactionRequest.gasPrice, minGasPrice);
3804
- const isScriptTransaction = transactionRequest.type === import_transactions17.TransactionType.Script;
3805
- if (transactionRequest.hasPredicateInput() && estimatePredicates) {
3801
+ const gasPrice = (0, import_math14.max)(txRequestClone.gasPrice, minGasPrice);
3802
+ const isScriptTransaction = txRequestClone.type === import_transactions17.TransactionType.Script;
3803
+ const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
3804
+ const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3805
+ txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
3806
+ if (estimatePredicates) {
3806
3807
  if (isScriptTransaction) {
3807
- transactionRequest.gasLimit = (0, import_math14.bn)(0);
3808
+ txRequestClone.gasLimit = (0, import_math14.bn)(0);
3809
+ }
3810
+ if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
3811
+ resourcesOwner.populateTransactionPredicateData(txRequestClone);
3808
3812
  }
3809
- await this.estimatePredicates(transactionRequest);
3813
+ await this.estimatePredicates(txRequestClone);
3810
3814
  }
3811
- const minGas = transactionRequest.calculateMinGas(chainInfo);
3812
- const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
3813
- const coinOutputsQuantities = transactionRequest.getCoinOutputsQuantities();
3814
- const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
3815
- transactionRequest.fundWithFakeUtxos(allQuantities, resourcesOwner);
3816
- let gasUsed = minGas;
3815
+ const minGas = txRequestClone.calculateMinGas(chainInfo);
3816
+ const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
3817
3817
  let receipts = [];
3818
- if (isScriptTransaction) {
3819
- transactionRequest.gasPrice = (0, import_math14.bn)(0);
3820
- transactionRequest.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3821
- const result = await this.call(transactionRequest, {
3822
- estimateTxDependencies
3823
- });
3818
+ let missingContractIds = [];
3819
+ let outputVariables = 0;
3820
+ if (isScriptTransaction && estimateTxDependencies) {
3821
+ txRequestClone.gasPrice = (0, import_math14.bn)(0);
3822
+ txRequestClone.gasLimit = (0, import_math14.bn)(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
3823
+ const result = await this.estimateTxDependencies(txRequestClone);
3824
3824
  receipts = result.receipts;
3825
- gasUsed = getGasUsedFromReceipts(receipts);
3826
- } else {
3827
- gasUsed = minGas;
3825
+ outputVariables = result.outputVariables;
3826
+ missingContractIds = result.missingContractIds;
3828
3827
  }
3828
+ const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
3829
3829
  const usedFee = calculatePriceWithFactor(
3830
3830
  gasUsed,
3831
3831
  gasPrice,
@@ -3843,7 +3843,10 @@ var _Provider = class {
3843
3843
  maxGas,
3844
3844
  usedFee,
3845
3845
  minFee,
3846
- maxFee
3846
+ maxFee,
3847
+ estimatedInputs: txRequestClone.inputs,
3848
+ outputVariables,
3849
+ missingContractIds
3847
3850
  };
3848
3851
  }
3849
3852
  async getResourcesForTransaction(owner, transactionRequestLike, forwardingQuantities = []) {
@@ -3872,7 +3875,7 @@ var _Provider = class {
3872
3875
  const result = await this.operations.getCoins({
3873
3876
  first: 10,
3874
3877
  ...paginationArgs,
3875
- filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_ethers18.hexlify)(assetId) }
3878
+ filter: { owner: ownerAddress.toB256(), assetId: assetId && (0, import_utils22.hexlify)(assetId) }
3876
3879
  });
3877
3880
  const coins = result.coins.edges.map((edge) => edge.node);
3878
3881
  return coins.map((coin) => ({
@@ -3896,19 +3899,19 @@ var _Provider = class {
3896
3899
  async getResourcesToSpend(owner, quantities, excludedIds) {
3897
3900
  const ownerAddress = import_address3.Address.fromAddressOrString(owner);
3898
3901
  const excludeInput = {
3899
- messages: excludedIds?.messages?.map((nonce) => (0, import_ethers18.hexlify)(nonce)) || [],
3900
- utxos: excludedIds?.utxos?.map((id) => (0, import_ethers18.hexlify)(id)) || []
3902
+ messages: excludedIds?.messages?.map((nonce) => (0, import_utils22.hexlify)(nonce)) || [],
3903
+ utxos: excludedIds?.utxos?.map((id) => (0, import_utils22.hexlify)(id)) || []
3901
3904
  };
3902
3905
  if (this.cache) {
3903
3906
  const uniqueUtxos = new Set(
3904
- excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_ethers18.hexlify)(id)))
3907
+ excludeInput.utxos.concat(this.cache?.getActiveData().map((id) => (0, import_utils22.hexlify)(id)))
3905
3908
  );
3906
3909
  excludeInput.utxos = Array.from(uniqueUtxos);
3907
3910
  }
3908
3911
  const coinsQuery = {
3909
3912
  owner: ownerAddress.toB256(),
3910
3913
  queryPerAsset: quantities.map(coinQuantityfy).map(({ assetId, amount, max: maxPerAsset }) => ({
3911
- assetId: (0, import_ethers18.hexlify)(assetId),
3914
+ assetId: (0, import_utils22.hexlify)(assetId),
3912
3915
  amount: amount.toString(10),
3913
3916
  max: maxPerAsset ? maxPerAsset.toString(10) : void 0
3914
3917
  })),
@@ -4011,7 +4014,7 @@ var _Provider = class {
4011
4014
  time: block.header.time,
4012
4015
  transactionIds: block.transactions.map((tx) => tx.id),
4013
4016
  transactions: block.transactions.map(
4014
- (tx) => new import_transactions17.TransactionCoder().decode((0, import_ethers18.getBytesCopy)(tx.rawPayload), 0)?.[0]
4017
+ (tx) => new import_transactions17.TransactionCoder().decode((0, import_utils22.arrayify)(tx.rawPayload), 0)?.[0]
4015
4018
  )
4016
4019
  };
4017
4020
  }
@@ -4027,7 +4030,7 @@ var _Provider = class {
4027
4030
  return null;
4028
4031
  }
4029
4032
  return new import_transactions17.TransactionCoder().decode(
4030
- (0, import_ethers18.getBytesCopy)(transaction.rawPayload),
4033
+ (0, import_utils22.arrayify)(transaction.rawPayload),
4031
4034
  0
4032
4035
  )?.[0];
4033
4036
  }
@@ -4054,7 +4057,7 @@ var _Provider = class {
4054
4057
  async getContractBalance(contractId, assetId) {
4055
4058
  const { contractBalance } = await this.operations.getContractBalance({
4056
4059
  contract: import_address3.Address.fromAddressOrString(contractId).toB256(),
4057
- asset: (0, import_ethers18.hexlify)(assetId)
4060
+ asset: (0, import_utils22.hexlify)(assetId)
4058
4061
  });
4059
4062
  return (0, import_math14.bn)(contractBalance.amount, 10);
4060
4063
  }
@@ -4068,7 +4071,7 @@ var _Provider = class {
4068
4071
  async getBalance(owner, assetId) {
4069
4072
  const { balance } = await this.operations.getBalance({
4070
4073
  owner: import_address3.Address.fromAddressOrString(owner).toB256(),
4071
- assetId: (0, import_ethers18.hexlify)(assetId)
4074
+ assetId: (0, import_utils22.hexlify)(assetId)
4072
4075
  });
4073
4076
  return (0, import_math14.bn)(balance.amount, 10);
4074
4077
  }
@@ -4257,21 +4260,66 @@ __publicField(Provider, "nodeInfoCache", {});
4257
4260
  var import_errors14 = require("@fuel-ts/errors");
4258
4261
  var import_math15 = require("@fuel-ts/math");
4259
4262
  var import_transactions18 = require("@fuel-ts/transactions");
4260
- var import_ethers19 = require("ethers");
4263
+ var import_utils25 = require("@fuel-ts/utils");
4264
+
4265
+ // src/providers/chains.ts
4266
+ var CHAIN_IDS = {
4267
+ eth: {
4268
+ sepolia: 11155111,
4269
+ foundry: 31337
4270
+ },
4271
+ fuel: {
4272
+ beta5: 0,
4273
+ devnet: 10
4274
+ }
4275
+ };
4276
+
4277
+ // src/providers/assets/index.ts
4278
+ var assets = [
4279
+ {
4280
+ name: "Ethereum",
4281
+ symbol: "ETH",
4282
+ icon: "eth.svg",
4283
+ networks: [
4284
+ {
4285
+ type: "ethereum",
4286
+ chainId: CHAIN_IDS.eth.sepolia,
4287
+ decimals: 18
4288
+ },
4289
+ {
4290
+ type: "ethereum",
4291
+ chainId: CHAIN_IDS.eth.foundry,
4292
+ decimals: 18
4293
+ },
4294
+ {
4295
+ type: "fuel",
4296
+ chainId: CHAIN_IDS.fuel.beta5,
4297
+ decimals: 9,
4298
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4299
+ },
4300
+ {
4301
+ type: "fuel",
4302
+ chainId: CHAIN_IDS.fuel.devnet,
4303
+ decimals: 9,
4304
+ assetId: "0x0000000000000000000000000000000000000000000000000000000000000000"
4305
+ }
4306
+ ]
4307
+ }
4308
+ ];
4261
4309
 
4262
4310
  // src/utils/formatTransferToContractScriptData.ts
4263
4311
  var import_abi_coder4 = require("@fuel-ts/abi-coder");
4264
4312
  var import_math16 = require("@fuel-ts/math");
4313
+ var import_utils26 = require("@fuel-ts/utils");
4265
4314
  var asm = __toESM(require("@fuels/vm-asm"));
4266
- var import_ethers20 = require("ethers");
4267
4315
  var formatTransferToContractScriptData = (params) => {
4268
4316
  const { assetId, amountToTransfer, hexlifiedContractId } = params;
4269
4317
  const numberCoder = new import_abi_coder4.U64Coder();
4270
4318
  const encoded = numberCoder.encode(new import_math16.BN(amountToTransfer).toNumber());
4271
4319
  const scriptData = Uint8Array.from([
4272
- ...(0, import_ethers20.getBytesCopy)(hexlifiedContractId),
4320
+ ...(0, import_utils26.arrayify)(hexlifiedContractId),
4273
4321
  ...encoded,
4274
- ...(0, import_ethers20.getBytesCopy)(assetId)
4322
+ ...(0, import_utils26.arrayify)(assetId)
4275
4323
  ]);
4276
4324
  return scriptData;
4277
4325
  };
@@ -4418,7 +4466,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4418
4466
  * @param assetId - The asset ID to check the balance for.
4419
4467
  * @returns A promise that resolves to the balance amount.
4420
4468
  */
4421
- async getBalance(assetId = import_configs10.BaseAssetId) {
4469
+ async getBalance(assetId = import_configs11.BaseAssetId) {
4422
4470
  const amount = await this.provider.getBalance(this.address, assetId);
4423
4471
  return amount;
4424
4472
  }
@@ -4459,7 +4507,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4459
4507
  async fund(request, coinQuantities, fee) {
4460
4508
  const updatedQuantities = addAmountToAsset({
4461
4509
  amount: (0, import_math17.bn)(fee),
4462
- assetId: import_configs10.BaseAssetId,
4510
+ assetId: import_configs11.BaseAssetId,
4463
4511
  coinQuantities
4464
4512
  });
4465
4513
  const quantitiesDict = {};
@@ -4483,8 +4531,8 @@ var Account = class extends import_interfaces.AbstractAccount {
4483
4531
  quantitiesDict[assetId].owned = quantitiesDict[assetId].owned.add(amount);
4484
4532
  cachedUtxos.push(input.id);
4485
4533
  }
4486
- } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs10.BaseAssetId]) {
4487
- quantitiesDict[import_configs10.BaseAssetId].owned = quantitiesDict[import_configs10.BaseAssetId].owned.add(input.amount);
4534
+ } else if (input.recipient === owner && input.amount && quantitiesDict[import_configs11.BaseAssetId]) {
4535
+ quantitiesDict[import_configs11.BaseAssetId].owned = quantitiesDict[import_configs11.BaseAssetId].owned.add(input.amount);
4488
4536
  cachedMessages.push(input.nonce);
4489
4537
  }
4490
4538
  }
@@ -4516,12 +4564,15 @@ var Account = class extends import_interfaces.AbstractAccount {
4516
4564
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4517
4565
  * @returns A promise that resolves to the prepared transaction request.
4518
4566
  */
4519
- async createTransfer(destination, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
4567
+ async createTransfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4520
4568
  const { minGasPrice } = this.provider.getGasConfig();
4521
4569
  const params = { gasPrice: minGasPrice, ...txParams };
4522
4570
  const request = new ScriptTransactionRequest(params);
4523
4571
  request.addCoinOutput(import_address4.Address.fromAddressOrString(destination), amount, assetId);
4524
- const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
4572
+ const { maxFee, requiredQuantities, gasUsed, estimatedInputs } = await this.provider.getTransactionCost(request, [], {
4573
+ estimateTxDependencies: true,
4574
+ resourcesOwner: this
4575
+ });
4525
4576
  request.gasPrice = (0, import_math17.bn)(txParams.gasPrice ?? minGasPrice);
4526
4577
  request.gasLimit = (0, import_math17.bn)(txParams.gasLimit ?? gasUsed);
4527
4578
  this.validateGas({
@@ -4531,6 +4582,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4531
4582
  minGasPrice
4532
4583
  });
4533
4584
  await this.fund(request, requiredQuantities, maxFee);
4585
+ request.updatePredicateInputs(estimatedInputs);
4534
4586
  return request;
4535
4587
  }
4536
4588
  /**
@@ -4542,9 +4594,9 @@ var Account = class extends import_interfaces.AbstractAccount {
4542
4594
  * @param txParams - The transaction parameters (gasLimit, gasPrice, maturity).
4543
4595
  * @returns A promise that resolves to the transaction response.
4544
4596
  */
4545
- async transfer(destination, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
4597
+ async transfer(destination, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4546
4598
  const request = await this.createTransfer(destination, amount, assetId, txParams);
4547
- return this.sendTransaction(request);
4599
+ return this.sendTransaction(request, { estimateTxDependencies: false });
4548
4600
  }
4549
4601
  /**
4550
4602
  * Transfers coins to a contract address.
@@ -4555,7 +4607,7 @@ var Account = class extends import_interfaces.AbstractAccount {
4555
4607
  * @param txParams - The optional transaction parameters.
4556
4608
  * @returns A promise that resolves to the transaction response.
4557
4609
  */
4558
- async transferToContract(contractId, amount, assetId = import_configs10.BaseAssetId, txParams = {}) {
4610
+ async transferToContract(contractId, amount, assetId = import_configs11.BaseAssetId, txParams = {}) {
4559
4611
  const contractAddress = import_address4.Address.fromAddressOrString(contractId);
4560
4612
  const { minGasPrice } = this.provider.getGasConfig();
4561
4613
  const params = { gasPrice: minGasPrice, ...txParams };
@@ -4595,20 +4647,20 @@ var Account = class extends import_interfaces.AbstractAccount {
4595
4647
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
4596
4648
  const { minGasPrice } = this.provider.getGasConfig();
4597
4649
  const recipientAddress = import_address4.Address.fromAddressOrString(recipient);
4598
- const recipientDataArray = (0, import_ethers21.getBytesCopy)(
4650
+ const recipientDataArray = (0, import_utils27.arrayify)(
4599
4651
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
4600
4652
  );
4601
- const amountDataArray = (0, import_ethers21.getBytesCopy)(
4653
+ const amountDataArray = (0, import_utils27.arrayify)(
4602
4654
  "0x".concat((0, import_math17.bn)(amount).toHex().substring(2).padStart(16, "0"))
4603
4655
  );
4604
4656
  const script = new Uint8Array([
4605
- ...(0, import_ethers21.getBytesCopy)(withdrawScript.bytes),
4657
+ ...(0, import_utils27.arrayify)(withdrawScript.bytes),
4606
4658
  ...recipientDataArray,
4607
4659
  ...amountDataArray
4608
4660
  ]);
4609
4661
  const params = { script, gasPrice: minGasPrice, ...txParams };
4610
4662
  const request = new ScriptTransactionRequest(params);
4611
- const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs10.BaseAssetId }];
4663
+ const forwardingQuantities = [{ amount: (0, import_math17.bn)(amount), assetId: import_configs11.BaseAssetId }];
4612
4664
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
4613
4665
  request,
4614
4666
  forwardingQuantities
@@ -4635,16 +4687,18 @@ var Account = class extends import_interfaces.AbstractAccount {
4635
4687
  * @param transactionRequestLike - The transaction request to be sent.
4636
4688
  * @returns A promise that resolves to the transaction response.
4637
4689
  */
4638
- async sendTransaction(transactionRequestLike, options) {
4690
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4639
4691
  if (this._connector) {
4640
4692
  return this.provider.getTransactionResponse(
4641
4693
  await this._connector.sendTransaction(this.address.toString(), transactionRequestLike)
4642
4694
  );
4643
4695
  }
4644
4696
  const transactionRequest = transactionRequestify(transactionRequestLike);
4645
- await this.provider.estimateTxDependencies(transactionRequest);
4697
+ if (estimateTxDependencies) {
4698
+ await this.provider.estimateTxDependencies(transactionRequest);
4699
+ }
4646
4700
  return this.provider.sendTransaction(transactionRequest, {
4647
- ...options,
4701
+ awaitExecution,
4648
4702
  estimateTxDependencies: false
4649
4703
  });
4650
4704
  }
@@ -4654,9 +4708,11 @@ var Account = class extends import_interfaces.AbstractAccount {
4654
4708
  * @param transactionRequestLike - The transaction request to be simulated.
4655
4709
  * @returns A promise that resolves to the call result.
4656
4710
  */
4657
- async simulateTransaction(transactionRequestLike) {
4711
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4658
4712
  const transactionRequest = transactionRequestify(transactionRequestLike);
4659
- await this.provider.estimateTxDependencies(transactionRequest);
4713
+ if (estimateTxDependencies) {
4714
+ await this.provider.estimateTxDependencies(transactionRequest);
4715
+ }
4660
4716
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
4661
4717
  }
4662
4718
  validateGas({
@@ -4685,8 +4741,8 @@ var import_address5 = require("@fuel-ts/address");
4685
4741
  var import_crypto = require("@fuel-ts/crypto");
4686
4742
  var import_hasher2 = require("@fuel-ts/hasher");
4687
4743
  var import_math18 = require("@fuel-ts/math");
4744
+ var import_utils28 = require("@fuel-ts/utils");
4688
4745
  var import_secp256k1 = require("@noble/curves/secp256k1");
4689
- var import_ethers22 = require("ethers");
4690
4746
  var Signer = class {
4691
4747
  address;
4692
4748
  publicKey;
@@ -4705,9 +4761,9 @@ var Signer = class {
4705
4761
  }
4706
4762
  }
4707
4763
  const privateKeyBytes = (0, import_math18.toBytes)(privateKey, 32);
4708
- this.privateKey = (0, import_ethers22.hexlify)(privateKeyBytes);
4709
- this.publicKey = (0, import_ethers22.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4710
- this.compressedPublicKey = (0, import_ethers22.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4764
+ this.privateKey = (0, import_utils28.hexlify)(privateKeyBytes);
4765
+ this.publicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
4766
+ this.compressedPublicKey = (0, import_utils28.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
4711
4767
  this.address = import_address5.Address.fromPublicKey(this.publicKey);
4712
4768
  }
4713
4769
  /**
@@ -4721,11 +4777,11 @@ var Signer = class {
4721
4777
  * @returns hashed signature
4722
4778
  */
4723
4779
  sign(data) {
4724
- const signature = import_secp256k1.secp256k1.sign((0, import_ethers22.getBytesCopy)(data), (0, import_ethers22.getBytesCopy)(this.privateKey));
4780
+ const signature = import_secp256k1.secp256k1.sign((0, import_utils28.arrayify)(data), (0, import_utils28.arrayify)(this.privateKey));
4725
4781
  const r = (0, import_math18.toBytes)(`0x${signature.r.toString(16)}`, 32);
4726
4782
  const s = (0, import_math18.toBytes)(`0x${signature.s.toString(16)}`, 32);
4727
4783
  s[0] |= (signature.recovery || 0) << 7;
4728
- return (0, import_ethers22.concat)([r, s]);
4784
+ return (0, import_utils28.hexlify)((0, import_utils28.concat)([r, s]));
4729
4785
  }
4730
4786
  /**
4731
4787
  * Add point on the current elliptic curve
@@ -4734,8 +4790,8 @@ var Signer = class {
4734
4790
  * @returns compressed point on the curve
4735
4791
  */
4736
4792
  addPoint(point) {
4737
- const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_ethers22.getBytesCopy)(this.compressedPublicKey));
4738
- const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_ethers22.getBytesCopy)(point));
4793
+ const p0 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(this.compressedPublicKey));
4794
+ const p1 = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(point));
4739
4795
  const result = p0.add(p1);
4740
4796
  return `0x${result.toHex(true)}`;
4741
4797
  }
@@ -4747,16 +4803,16 @@ var Signer = class {
4747
4803
  * @returns public key from signature from the
4748
4804
  */
4749
4805
  static recoverPublicKey(data, signature) {
4750
- const signedMessageBytes = (0, import_ethers22.getBytesCopy)(signature);
4806
+ const signedMessageBytes = (0, import_utils28.arrayify)(signature);
4751
4807
  const r = signedMessageBytes.slice(0, 32);
4752
4808
  const s = signedMessageBytes.slice(32, 64);
4753
4809
  const recoveryParam = (s[0] & 128) >> 7;
4754
4810
  s[0] &= 127;
4755
- const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_ethers22.hexlify)(r)), BigInt((0, import_ethers22.hexlify)(s))).addRecoveryBit(
4811
+ const sig = new import_secp256k1.secp256k1.Signature(BigInt((0, import_utils28.hexlify)(r)), BigInt((0, import_utils28.hexlify)(s))).addRecoveryBit(
4756
4812
  recoveryParam
4757
4813
  );
4758
- const publicKey = sig.recoverPublicKey((0, import_ethers22.getBytesCopy)(data)).toRawBytes(false).slice(1);
4759
- return (0, import_ethers22.hexlify)(publicKey);
4814
+ const publicKey = sig.recoverPublicKey((0, import_utils28.arrayify)(data)).toRawBytes(false).slice(1);
4815
+ return (0, import_utils28.hexlify)(publicKey);
4760
4816
  }
4761
4817
  /**
4762
4818
  * Recover the address from a signature performed with [`sign`](#sign).
@@ -4775,7 +4831,7 @@ var Signer = class {
4775
4831
  * @returns random 32-byte hashed
4776
4832
  */
4777
4833
  static generatePrivateKey(entropy) {
4778
- return entropy ? (0, import_hasher2.hash)((0, import_ethers22.concat)([(0, import_crypto.randomBytes)(32), (0, import_ethers22.getBytesCopy)(entropy)])) : (0, import_crypto.randomBytes)(32);
4834
+ return entropy ? (0, import_hasher2.hash)((0, import_utils28.concat)([(0, import_crypto.randomBytes)(32), (0, import_utils28.arrayify)(entropy)])) : (0, import_crypto.randomBytes)(32);
4779
4835
  }
4780
4836
  /**
4781
4837
  * Extended publicKey from a compact publicKey
@@ -4784,8 +4840,8 @@ var Signer = class {
4784
4840
  * @returns extended publicKey
4785
4841
  */
4786
4842
  static extendPublicKey(publicKey) {
4787
- const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_ethers22.getBytesCopy)(publicKey));
4788
- return (0, import_ethers22.hexlify)(point.toRawBytes(false).slice(1));
4843
+ const point = import_secp256k1.secp256k1.ProjectivePoint.fromHex((0, import_utils28.arrayify)(publicKey));
4844
+ return (0, import_utils28.hexlify)(point.toRawBytes(false).slice(1));
4789
4845
  }
4790
4846
  };
4791
4847
 
@@ -4793,7 +4849,7 @@ var Signer = class {
4793
4849
  var import_address6 = require("@fuel-ts/address");
4794
4850
  var import_crypto2 = require("@fuel-ts/crypto");
4795
4851
  var import_errors16 = require("@fuel-ts/errors");
4796
- var import_ethers23 = require("ethers");
4852
+ var import_utils29 = require("@fuel-ts/utils");
4797
4853
  var import_uuid = require("uuid");
4798
4854
  var DEFAULT_KDF_PARAMS_LOG_N = 13;
4799
4855
  var DEFAULT_KDF_PARAMS_R = 8;
@@ -4876,7 +4932,7 @@ async function decryptKeystoreWallet(jsonWallet, password) {
4876
4932
  );
4877
4933
  }
4878
4934
  const buffer = await (0, import_crypto2.decryptJsonWalletData)(ciphertextBuffer, key, ivBuffer);
4879
- const privateKey = (0, import_ethers23.hexlify)(buffer);
4935
+ const privateKey = (0, import_utils29.hexlify)(buffer);
4880
4936
  return privateKey;
4881
4937
  }
4882
4938
 
@@ -4921,7 +4977,7 @@ var BaseWalletUnlocked = class extends Account {
4921
4977
  */
4922
4978
  async signMessage(message) {
4923
4979
  const signedMessage = await this.signer().sign((0, import_hasher3.hashMessage)(message));
4924
- return signedMessage;
4980
+ return (0, import_utils30.hexlify)(signedMessage);
4925
4981
  }
4926
4982
  /**
4927
4983
  * Signs a transaction with the wallet's private key.
@@ -4934,7 +4990,7 @@ var BaseWalletUnlocked = class extends Account {
4934
4990
  const chainId = this.provider.getChain().consensusParameters.chainId.toNumber();
4935
4991
  const hashedTransaction = transactionRequest.getTransactionId(chainId);
4936
4992
  const signature = await this.signer().sign(hashedTransaction);
4937
- return signature;
4993
+ return (0, import_utils30.hexlify)(signature);
4938
4994
  }
4939
4995
  /**
4940
4996
  * Populates a transaction with the witnesses signature.
@@ -4954,12 +5010,14 @@ var BaseWalletUnlocked = class extends Account {
4954
5010
  * @param transactionRequestLike - The transaction request to send.
4955
5011
  * @returns A promise that resolves to the TransactionResponse object.
4956
5012
  */
4957
- async sendTransaction(transactionRequestLike, options) {
5013
+ async sendTransaction(transactionRequestLike, { estimateTxDependencies = true, awaitExecution } = {}) {
4958
5014
  const transactionRequest = transactionRequestify(transactionRequestLike);
4959
- await this.provider.estimateTxDependencies(transactionRequest);
5015
+ if (estimateTxDependencies) {
5016
+ await this.provider.estimateTxDependencies(transactionRequest);
5017
+ }
4960
5018
  return this.provider.sendTransaction(
4961
5019
  await this.populateTransactionWitnessesSignature(transactionRequest),
4962
- { ...options, estimateTxDependencies: false }
5020
+ { awaitExecution, estimateTxDependencies: false }
4963
5021
  );
4964
5022
  }
4965
5023
  /**
@@ -4968,9 +5026,11 @@ var BaseWalletUnlocked = class extends Account {
4968
5026
  * @param transactionRequestLike - The transaction request to simulate.
4969
5027
  * @returns A promise that resolves to the CallResult object.
4970
5028
  */
4971
- async simulateTransaction(transactionRequestLike) {
5029
+ async simulateTransaction(transactionRequestLike, { estimateTxDependencies = true } = {}) {
4972
5030
  const transactionRequest = transactionRequestify(transactionRequestLike);
4973
- await this.provider.estimateTxDependencies(transactionRequest);
5031
+ if (estimateTxDependencies) {
5032
+ await this.provider.estimateTxDependencies(transactionRequest);
5033
+ }
4974
5034
  return this.provider.call(
4975
5035
  await this.populateTransactionWitnessesSignature(transactionRequest),
4976
5036
  {
@@ -4991,12 +5051,14 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
4991
5051
  // src/hdwallet/hdwallet.ts
4992
5052
  var import_errors19 = require("@fuel-ts/errors");
4993
5053
  var import_math19 = require("@fuel-ts/math");
4994
- var import_ethers26 = require("ethers");
5054
+ var import_utils34 = require("@fuel-ts/utils");
5055
+ var import_ethers5 = require("ethers");
4995
5056
 
4996
5057
  // src/mnemonic/mnemonic.ts
4997
5058
  var import_crypto3 = require("@fuel-ts/crypto");
4998
5059
  var import_errors18 = require("@fuel-ts/errors");
4999
- var import_ethers25 = require("ethers");
5060
+ var import_utils32 = require("@fuel-ts/utils");
5061
+ var import_ethers4 = require("ethers");
5000
5062
 
5001
5063
  // src/wordlists/words/english.ts
5002
5064
  var english = [
@@ -7052,7 +7114,8 @@ var english = [
7052
7114
 
7053
7115
  // src/mnemonic/utils.ts
7054
7116
  var import_errors17 = require("@fuel-ts/errors");
7055
- var import_ethers24 = require("ethers");
7117
+ var import_utils31 = require("@fuel-ts/utils");
7118
+ var import_ethers3 = require("ethers");
7056
7119
  function toUtf8Bytes(stri) {
7057
7120
  const str = stri.normalize("NFKD");
7058
7121
  const result = [];
@@ -7119,14 +7182,14 @@ function entropyToMnemonicIndices(entropy) {
7119
7182
  }
7120
7183
  }
7121
7184
  const checksumBits = entropy.length / 4;
7122
- const checksum = (0, import_ethers24.getBytesCopy)((0, import_ethers24.sha256)(entropy))[0] & getUpperMask(checksumBits);
7185
+ const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy))[0] & getUpperMask(checksumBits);
7123
7186
  indices[indices.length - 1] <<= checksumBits;
7124
7187
  indices[indices.length - 1] |= checksum >> 8 - checksumBits;
7125
7188
  return indices;
7126
7189
  }
7127
7190
  function mnemonicWordsToEntropy(words, wordlist) {
7128
7191
  const size = Math.ceil(11 * words.length / 8);
7129
- const entropy = (0, import_ethers24.getBytesCopy)(new Uint8Array(size));
7192
+ const entropy = (0, import_utils31.arrayify)(new Uint8Array(size));
7130
7193
  let offset = 0;
7131
7194
  for (let i = 0; i < words.length; i += 1) {
7132
7195
  const index = wordlist.indexOf(words[i].normalize("NFKD"));
@@ -7146,7 +7209,7 @@ function mnemonicWordsToEntropy(words, wordlist) {
7146
7209
  const entropyBits = 32 * words.length / 3;
7147
7210
  const checksumBits = words.length / 3;
7148
7211
  const checksumMask = getUpperMask(checksumBits);
7149
- const checksum = (0, import_ethers24.getBytesCopy)((0, import_ethers24.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7212
+ const checksum = (0, import_utils31.arrayify)((0, import_ethers3.sha256)(entropy.slice(0, entropyBits / 8)))[0] & checksumMask;
7150
7213
  if (checksum !== (entropy[entropy.length - 1] & checksumMask)) {
7151
7214
  throw new import_errors17.FuelError(
7152
7215
  import_errors17.ErrorCode.INVALID_CHECKSUM,
@@ -7221,7 +7284,7 @@ var Mnemonic = class {
7221
7284
  static mnemonicToEntropy(phrase, wordlist = english) {
7222
7285
  const words = getWords(phrase);
7223
7286
  assertMnemonic(words);
7224
- return (0, import_ethers25.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7287
+ return (0, import_utils32.hexlify)(mnemonicWordsToEntropy(words, wordlist));
7225
7288
  }
7226
7289
  /**
7227
7290
  * @param entropy - Entropy source to the mnemonic phrase.
@@ -7229,7 +7292,7 @@ var Mnemonic = class {
7229
7292
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7230
7293
  */
7231
7294
  static entropyToMnemonic(entropy, wordlist = english) {
7232
- const entropyBytes = (0, import_ethers25.getBytesCopy)(entropy);
7295
+ const entropyBytes = (0, import_utils32.arrayify)(entropy);
7233
7296
  assertWordList(wordlist);
7234
7297
  assertEntropy(entropyBytes);
7235
7298
  return entropyToMnemonicIndices(entropyBytes).map((i) => wordlist[i]).join(" ");
@@ -7243,7 +7306,7 @@ var Mnemonic = class {
7243
7306
  assertMnemonic(getWords(phrase));
7244
7307
  const phraseBytes = toUtf8Bytes(getPhrase(phrase));
7245
7308
  const salt = toUtf8Bytes(`mnemonic${passphrase}`);
7246
- return (0, import_ethers25.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7309
+ return (0, import_ethers4.pbkdf2)(phraseBytes, salt, 2048, 64, "sha512");
7247
7310
  }
7248
7311
  /**
7249
7312
  * @param phrase - Mnemonic phrase composed by words from the provided wordlist
@@ -7298,14 +7361,14 @@ var Mnemonic = class {
7298
7361
  * @returns 64-byte array contains privateKey and chainCode as described on BIP39
7299
7362
  */
7300
7363
  static masterKeysFromSeed(seed) {
7301
- const seedArray = (0, import_ethers25.getBytesCopy)(seed);
7364
+ const seedArray = (0, import_utils32.arrayify)(seed);
7302
7365
  if (seedArray.length < 16 || seedArray.length > 64) {
7303
7366
  throw new import_errors18.FuelError(
7304
7367
  import_errors18.ErrorCode.INVALID_SEED,
7305
7368
  `Seed length should be between 16 and 64 bytes, but received ${seedArray.length} bytes.`
7306
7369
  );
7307
7370
  }
7308
- return (0, import_ethers25.getBytesCopy)((0, import_ethers25.computeHmac)("sha512", MasterSecret, seedArray));
7371
+ return (0, import_utils32.arrayify)((0, import_ethers4.computeHmac)("sha512", MasterSecret, seedArray));
7309
7372
  }
7310
7373
  /**
7311
7374
  * Get the extendKey as defined on BIP-32 from the provided seed
@@ -7316,22 +7379,22 @@ var Mnemonic = class {
7316
7379
  */
7317
7380
  static seedToExtendedKey(seed, testnet = false) {
7318
7381
  const masterKey = Mnemonic.masterKeysFromSeed(seed);
7319
- const prefix = (0, import_ethers25.getBytesCopy)(testnet ? TestnetPRV : MainnetPRV);
7382
+ const prefix = (0, import_utils32.arrayify)(testnet ? TestnetPRV : MainnetPRV);
7320
7383
  const depth = "0x00";
7321
7384
  const fingerprint = "0x00000000";
7322
7385
  const index = "0x00000000";
7323
7386
  const chainCode = masterKey.slice(32);
7324
7387
  const privateKey = masterKey.slice(0, 32);
7325
- const extendedKey = (0, import_ethers25.concat)([
7388
+ const extendedKey = (0, import_utils32.concat)([
7326
7389
  prefix,
7327
7390
  depth,
7328
7391
  fingerprint,
7329
7392
  index,
7330
7393
  chainCode,
7331
- (0, import_ethers25.concat)(["0x00", privateKey])
7394
+ (0, import_utils32.concat)(["0x00", privateKey])
7332
7395
  ]);
7333
- const checksum = (0, import_ethers25.dataSlice)((0, import_ethers25.sha256)((0, import_ethers25.sha256)(extendedKey)), 0, 4);
7334
- return (0, import_ethers25.encodeBase58)((0, import_ethers25.concat)([extendedKey, checksum]));
7396
+ const checksum = (0, import_ethers4.dataSlice)((0, import_ethers4.sha256)((0, import_ethers4.sha256)(extendedKey)), 0, 4);
7397
+ return (0, import_ethers4.encodeBase58)((0, import_utils32.concat)([extendedKey, checksum]));
7335
7398
  }
7336
7399
  /**
7337
7400
  * Create a new mnemonic using a randomly generated number as entropy.
@@ -7346,7 +7409,7 @@ var Mnemonic = class {
7346
7409
  * @returns A randomly generated mnemonic
7347
7410
  */
7348
7411
  static generate(size = 32, extraEntropy = "") {
7349
- const entropy = extraEntropy ? (0, import_ethers25.sha256)((0, import_ethers25.concat)([(0, import_crypto3.randomBytes)(size), (0, import_ethers25.getBytesCopy)(extraEntropy)])) : (0, import_crypto3.randomBytes)(size);
7412
+ 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);
7350
7413
  return Mnemonic.entropyToMnemonic(entropy);
7351
7414
  }
7352
7415
  };
@@ -7354,12 +7417,12 @@ var mnemonic_default = Mnemonic;
7354
7417
 
7355
7418
  // src/hdwallet/hdwallet.ts
7356
7419
  var HARDENED_INDEX = 2147483648;
7357
- var MainnetPRV2 = (0, import_ethers26.hexlify)("0x0488ade4");
7358
- var MainnetPUB = (0, import_ethers26.hexlify)("0x0488b21e");
7359
- var TestnetPRV2 = (0, import_ethers26.hexlify)("0x04358394");
7360
- var TestnetPUB = (0, import_ethers26.hexlify)("0x043587cf");
7420
+ var MainnetPRV2 = (0, import_utils34.hexlify)("0x0488ade4");
7421
+ var MainnetPUB = (0, import_utils34.hexlify)("0x0488b21e");
7422
+ var TestnetPRV2 = (0, import_utils34.hexlify)("0x04358394");
7423
+ var TestnetPUB = (0, import_utils34.hexlify)("0x043587cf");
7361
7424
  function base58check(data) {
7362
- return (0, import_ethers26.encodeBase58)((0, import_ethers26.concat)([data, (0, import_ethers26.dataSlice)((0, import_ethers26.sha256)((0, import_ethers26.sha256)(data)), 0, 4)]));
7425
+ 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)]));
7363
7426
  }
7364
7427
  function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7365
7428
  if (isPublic) {
@@ -7368,11 +7431,11 @@ function getExtendedKeyPrefix(isPublic = false, testnet = false) {
7368
7431
  return testnet ? TestnetPRV2 : MainnetPRV2;
7369
7432
  }
7370
7433
  function isPublicExtendedKey(extendedKey) {
7371
- return [MainnetPUB, TestnetPUB].includes((0, import_ethers26.hexlify)(extendedKey.slice(0, 4)));
7434
+ return [MainnetPUB, TestnetPUB].includes((0, import_utils34.hexlify)(extendedKey.slice(0, 4)));
7372
7435
  }
7373
7436
  function isValidExtendedKey(extendedKey) {
7374
7437
  return [MainnetPRV2, TestnetPRV2, MainnetPUB, TestnetPUB].includes(
7375
- (0, import_ethers26.hexlify)(extendedKey.slice(0, 4))
7438
+ (0, import_utils34.hexlify)(extendedKey.slice(0, 4))
7376
7439
  );
7377
7440
  }
7378
7441
  function parsePath(path2, depth = 0) {
@@ -7390,8 +7453,8 @@ function parsePath(path2, depth = 0) {
7390
7453
  var HDWallet = class {
7391
7454
  depth = 0;
7392
7455
  index = 0;
7393
- fingerprint = (0, import_ethers26.hexlify)("0x00000000");
7394
- parentFingerprint = (0, import_ethers26.hexlify)("0x00000000");
7456
+ fingerprint = (0, import_utils34.hexlify)("0x00000000");
7457
+ parentFingerprint = (0, import_utils34.hexlify)("0x00000000");
7395
7458
  privateKey;
7396
7459
  publicKey;
7397
7460
  chainCode;
@@ -7403,8 +7466,8 @@ var HDWallet = class {
7403
7466
  constructor(config) {
7404
7467
  if (config.privateKey) {
7405
7468
  const signer = new Signer(config.privateKey);
7406
- this.publicKey = (0, import_ethers26.hexlify)(signer.compressedPublicKey);
7407
- this.privateKey = (0, import_ethers26.hexlify)(config.privateKey);
7469
+ this.publicKey = (0, import_utils34.hexlify)(signer.compressedPublicKey);
7470
+ this.privateKey = (0, import_utils34.hexlify)(config.privateKey);
7408
7471
  } else {
7409
7472
  if (!config.publicKey) {
7410
7473
  throw new import_errors19.FuelError(
@@ -7412,10 +7475,10 @@ var HDWallet = class {
7412
7475
  "Both public and private Key cannot be missing. At least one should be provided."
7413
7476
  );
7414
7477
  }
7415
- this.publicKey = (0, import_ethers26.hexlify)(config.publicKey);
7478
+ this.publicKey = (0, import_utils34.hexlify)(config.publicKey);
7416
7479
  }
7417
7480
  this.parentFingerprint = config.parentFingerprint || this.parentFingerprint;
7418
- this.fingerprint = (0, import_ethers26.dataSlice)((0, import_ethers26.ripemd160)((0, import_ethers26.sha256)(this.publicKey)), 0, 4);
7481
+ this.fingerprint = (0, import_ethers5.dataSlice)((0, import_ethers5.ripemd160)((0, import_ethers5.sha256)(this.publicKey)), 0, 4);
7419
7482
  this.depth = config.depth || this.depth;
7420
7483
  this.index = config.index || this.index;
7421
7484
  this.chainCode = config.chainCode;
@@ -7431,9 +7494,9 @@ var HDWallet = class {
7431
7494
  * @returns A new instance of HDWallet on the derived index
7432
7495
  */
7433
7496
  deriveIndex(index) {
7434
- const privateKey = this.privateKey && (0, import_ethers26.getBytesCopy)(this.privateKey);
7435
- const publicKey = (0, import_ethers26.getBytesCopy)(this.publicKey);
7436
- const chainCode = (0, import_ethers26.getBytesCopy)(this.chainCode);
7497
+ const privateKey = this.privateKey && (0, import_utils34.arrayify)(this.privateKey);
7498
+ const publicKey = (0, import_utils34.arrayify)(this.publicKey);
7499
+ const chainCode = (0, import_utils34.arrayify)(this.chainCode);
7437
7500
  const data = new Uint8Array(37);
7438
7501
  if (index & HARDENED_INDEX) {
7439
7502
  if (!privateKey) {
@@ -7444,10 +7507,10 @@ var HDWallet = class {
7444
7507
  }
7445
7508
  data.set(privateKey, 1);
7446
7509
  } else {
7447
- data.set((0, import_ethers26.getBytesCopy)(this.publicKey));
7510
+ data.set((0, import_utils34.arrayify)(this.publicKey));
7448
7511
  }
7449
7512
  data.set((0, import_math19.toBytes)(index, 4), 33);
7450
- const bytes = (0, import_ethers26.getBytesCopy)((0, import_ethers26.computeHmac)("sha512", chainCode, data));
7513
+ const bytes = (0, import_utils34.arrayify)((0, import_ethers5.computeHmac)("sha512", chainCode, data));
7451
7514
  const IL = bytes.slice(0, 32);
7452
7515
  const IR = bytes.slice(32);
7453
7516
  if (privateKey) {
@@ -7461,7 +7524,7 @@ var HDWallet = class {
7461
7524
  parentFingerprint: this.fingerprint
7462
7525
  });
7463
7526
  }
7464
- const signer = new Signer((0, import_ethers26.hexlify)(IL));
7527
+ const signer = new Signer((0, import_utils34.hexlify)(IL));
7465
7528
  const Ki = signer.addPoint(publicKey);
7466
7529
  return new HDWallet({
7467
7530
  publicKey: Ki,
@@ -7496,14 +7559,12 @@ var HDWallet = class {
7496
7559
  );
7497
7560
  }
7498
7561
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
7499
- const depth = (0, import_ethers26.hexlify)(Uint8Array.from([this.depth]));
7562
+ const depth = (0, import_utils34.hexlify)(Uint8Array.from([this.depth]));
7500
7563
  const parentFingerprint = this.parentFingerprint;
7501
7564
  const index = (0, import_math19.toHex)(this.index, 4);
7502
7565
  const chainCode = this.chainCode;
7503
- const key = this.privateKey != null && !isPublic ? (0, import_ethers26.concat)(["0x00", this.privateKey]) : this.publicKey;
7504
- const extendedKey = (0, import_ethers26.getBytesCopy)(
7505
- (0, import_ethers26.concat)([prefix, depth, parentFingerprint, index, chainCode, key])
7506
- );
7566
+ const key = this.privateKey != null && !isPublic ? (0, import_utils34.concat)(["0x00", this.privateKey]) : this.publicKey;
7567
+ const extendedKey = (0, import_utils34.arrayify)((0, import_utils34.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
7507
7568
  return base58check(extendedKey);
7508
7569
  }
7509
7570
  /**
@@ -7515,13 +7576,13 @@ var HDWallet = class {
7515
7576
  static fromSeed(seed) {
7516
7577
  const masterKey = mnemonic_default.masterKeysFromSeed(seed);
7517
7578
  return new HDWallet({
7518
- chainCode: (0, import_ethers26.getBytesCopy)(masterKey.slice(32)),
7519
- privateKey: (0, import_ethers26.getBytesCopy)(masterKey.slice(0, 32))
7579
+ chainCode: (0, import_utils34.arrayify)(masterKey.slice(32)),
7580
+ privateKey: (0, import_utils34.arrayify)(masterKey.slice(0, 32))
7520
7581
  });
7521
7582
  }
7522
7583
  static fromExtendedKey(extendedKey) {
7523
- const decoded = (0, import_ethers26.toBeHex)((0, import_ethers26.decodeBase58)(extendedKey));
7524
- const bytes = (0, import_ethers26.getBytesCopy)(decoded);
7584
+ const decoded = (0, import_ethers5.toBeHex)((0, import_ethers5.decodeBase58)(extendedKey));
7585
+ const bytes = (0, import_utils34.arrayify)(decoded);
7525
7586
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
7526
7587
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
7527
7588
  throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key is not a valid extended key.");
@@ -7530,9 +7591,9 @@ var HDWallet = class {
7530
7591
  throw new import_errors19.FuelError(import_errors19.ErrorCode.HD_WALLET_ERROR, "Provided key has an invalid checksum.");
7531
7592
  }
7532
7593
  const depth = bytes[4];
7533
- const parentFingerprint = (0, import_ethers26.hexlify)(bytes.slice(5, 9));
7534
- const index = parseInt((0, import_ethers26.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7535
- const chainCode = (0, import_ethers26.hexlify)(bytes.slice(13, 45));
7594
+ const parentFingerprint = (0, import_utils34.hexlify)(bytes.slice(5, 9));
7595
+ const index = parseInt((0, import_utils34.hexlify)(bytes.slice(9, 13)).substring(2), 16);
7596
+ const chainCode = (0, import_utils34.hexlify)(bytes.slice(13, 45));
7536
7597
  const key = bytes.slice(45, 78);
7537
7598
  if (depth === 0 && parentFingerprint !== "0x00000000" || depth === 0 && index !== 0) {
7538
7599
  throw new import_errors19.FuelError(
@@ -7746,13 +7807,12 @@ var generateTestWallet = async (provider, quantities) => {
7746
7807
  };
7747
7808
 
7748
7809
  // src/test-utils/launchNode.ts
7749
- var import_configs11 = require("@fuel-ts/address/configs");
7810
+ var import_configs12 = require("@fuel-ts/address/configs");
7750
7811
  var import_math20 = require("@fuel-ts/math");
7751
- var import_utils7 = require("@fuel-ts/utils");
7812
+ var import_utils35 = require("@fuel-ts/utils");
7752
7813
  var import_cli_utils = require("@fuel-ts/utils/cli-utils");
7753
7814
  var import_child_process = require("child_process");
7754
7815
  var import_crypto5 = require("crypto");
7755
- var import_ethers27 = require("ethers");
7756
7816
  var import_fs = require("fs");
7757
7817
  var import_os = __toESM(require("os"));
7758
7818
  var import_path = __toESM(require("path"));
@@ -7807,7 +7867,7 @@ var launchNode = async ({
7807
7867
  "--poa-instant"
7808
7868
  ]);
7809
7869
  const chainConfigPath = getFlagValueFromArgs(args, "--chain");
7810
- const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils7.defaultConsensusKey;
7870
+ const consensusKey = getFlagValueFromArgs(args, "--consensus-key") || import_utils35.defaultConsensusKey;
7811
7871
  const dbTypeFlagValue = getFlagValueFromArgs(args, "--db-type");
7812
7872
  const useInMemoryDb = dbTypeFlagValue === "in-memory" || dbTypeFlagValue === void 0;
7813
7873
  const poaInstantFlagValue = getFlagValueFromArgs(args, "--poa-instant");
@@ -7833,21 +7893,21 @@ var launchNode = async ({
7833
7893
  (0, import_fs.mkdirSync)(tempDirPath, { recursive: true });
7834
7894
  }
7835
7895
  const tempChainConfigFilePath = import_path.default.join(tempDirPath, "chainConfig.json");
7836
- let chainConfig = import_utils7.defaultChainConfig;
7896
+ let chainConfig = import_utils35.defaultChainConfig;
7837
7897
  if (!process.env.GENESIS_SECRET) {
7838
7898
  const pk = Signer.generatePrivateKey();
7839
7899
  const signer = new Signer(pk);
7840
- process.env.GENESIS_SECRET = (0, import_ethers27.hexlify)(pk);
7900
+ process.env.GENESIS_SECRET = (0, import_utils35.hexlify)(pk);
7841
7901
  chainConfig = {
7842
- ...import_utils7.defaultChainConfig,
7902
+ ...import_utils35.defaultChainConfig,
7843
7903
  initial_state: {
7844
- ...import_utils7.defaultChainConfig.initial_state,
7904
+ ...import_utils35.defaultChainConfig.initial_state,
7845
7905
  coins: [
7846
- ...import_utils7.defaultChainConfig.initial_state.coins,
7906
+ ...import_utils35.defaultChainConfig.initial_state.coins,
7847
7907
  {
7848
7908
  owner: signer.address.toHexString(),
7849
7909
  amount: (0, import_math20.toHex)(1e9),
7850
- asset_id: import_configs11.BaseAssetId
7910
+ asset_id: import_configs12.BaseAssetId
7851
7911
  }
7852
7912
  ]
7853
7913
  }
@@ -7915,7 +7975,7 @@ var launchNode = async ({
7915
7975
  var generateWallets = async (count, provider) => {
7916
7976
  const wallets = [];
7917
7977
  for (let i = 0; i < count; i += 1) {
7918
- const wallet = await generateTestWallet(provider, [[1e3, import_configs11.BaseAssetId]]);
7978
+ const wallet = await generateTestWallet(provider, [[1e3, import_configs12.BaseAssetId]]);
7919
7979
  wallets.push(wallet);
7920
7980
  }
7921
7981
  return wallets;