@fuel-ts/account 0.97.0 → 0.97.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/connectors/fuel-connector.d.ts.map +1 -1
  3. package/dist/index.global.js +587 -14247
  4. package/dist/index.global.js.map +1 -1
  5. package/dist/index.js +31 -29
  6. package/dist/index.js.map +1 -1
  7. package/dist/index.mjs +9 -7
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/predicate/predicate.d.ts.map +1 -1
  10. package/dist/providers/provider.d.ts.map +1 -1
  11. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  12. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  13. package/dist/providers/transaction-request/errors.d.ts.map +1 -1
  14. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  15. package/dist/providers/transaction-request/upgrade-transaction-request.d.ts.map +1 -1
  16. package/dist/providers/transaction-request/upload-transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-summary/get-transaction-summary.d.ts +6 -1
  18. package/dist/providers/transaction-summary/get-transaction-summary.d.ts.map +1 -1
  19. package/dist/providers/transaction-summary/operations.d.ts +21 -3
  20. package/dist/providers/transaction-summary/operations.d.ts.map +1 -1
  21. package/dist/test-utils/launchNode.d.ts.map +1 -1
  22. package/dist/test-utils.global.js +590 -14247
  23. package/dist/test-utils.global.js.map +1 -1
  24. package/dist/test-utils.js +30 -25
  25. package/dist/test-utils.js.map +1 -1
  26. package/dist/test-utils.mjs +12 -7
  27. package/dist/test-utils.mjs.map +1 -1
  28. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
  29. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  30. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  31. package/package.json +17 -17
@@ -329,6 +329,8 @@ var launchNode = async ({
329
329
  console.log(
330
330
  `fuel-core node under pid ${child.pid} does not exist. The node might have been killed before cleanup was called. Exiting cleanly.`
331
331
  );
332
+ } else if (error.message.includes("pid must be a positive integer")) {
333
+ process.kill(+child.pid);
332
334
  } else {
333
335
  throw e;
334
336
  }
@@ -357,6 +359,7 @@ var launchNode = async ({
357
359
  reject(new import_errors.FuelError(import_errors.FuelError.CODES.NODE_LAUNCH_FAILED, text));
358
360
  }
359
361
  });
362
+ process.setMaxListeners(100);
360
363
  process.on("exit", cleanup);
361
364
  process.on("SIGINT", cleanup);
362
365
  process.on("SIGUSR1", cleanup);
@@ -4934,7 +4937,7 @@ Supported fuel-core version: ${supportedVersion}.`
4934
4937
  createOperations() {
4935
4938
  const fetchFn = _Provider.getFetchFn(this.options);
4936
4939
  const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
4937
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4940
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4938
4941
  responseMiddleware: (response) => {
4939
4942
  if ("response" in response) {
4940
4943
  const graphQlResponse = response.response;
@@ -5185,7 +5188,8 @@ Supported fuel-core version: ${supportedVersion}.`
5185
5188
  dryRun: [{ receipts: rawReceipts, status }]
5186
5189
  } = await this.operations.dryRun({
5187
5190
  encodedTransactions: [(0, import_utils30.hexlify)(transactionRequest.toTransactionBytes())],
5188
- utxoValidation: false
5191
+ utxoValidation: false,
5192
+ gasPrice: "0"
5189
5193
  });
5190
5194
  receipts = rawReceipts.map(processGqlReceipt);
5191
5195
  dryRunStatus = status;
@@ -5199,7 +5203,8 @@ Supported fuel-core version: ${supportedVersion}.`
5199
5203
  missingContractIds.push(contractId);
5200
5204
  });
5201
5205
  const { maxFee } = await this.estimateTxGasAndFee({
5202
- transactionRequest
5206
+ transactionRequest,
5207
+ gasPrice: (0, import_math19.bn)(0)
5203
5208
  });
5204
5209
  transactionRequest.maxFee = maxFee;
5205
5210
  } else {
@@ -5335,7 +5340,7 @@ Supported fuel-core version: ${supportedVersion}.`
5335
5340
  const chainInfo = this.getChain();
5336
5341
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5337
5342
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5338
- if (!gasPrice) {
5343
+ if (!(0, import_utils30.isDefined)(gasPrice)) {
5339
5344
  gasPrice = await this.estimateGasPrice(10);
5340
5345
  }
5341
5346
  const minFee = calculateGasFee({
@@ -6757,7 +6762,7 @@ var import_address6 = require("@fuel-ts/address");
6757
6762
  var import_crypto5 = require("@fuel-ts/crypto");
6758
6763
  var import_errors21 = require("@fuel-ts/errors");
6759
6764
  var import_interfaces = require("@fuel-ts/interfaces");
6760
- var import_math22 = require("@fuel-ts/math");
6765
+ var import_math21 = require("@fuel-ts/math");
6761
6766
  var import_transactions24 = require("@fuel-ts/transactions");
6762
6767
  var import_utils37 = require("@fuel-ts/utils");
6763
6768
  var import_ramda9 = require("ramda");
@@ -6779,14 +6784,13 @@ var mergeQuantities = (...coinQuantities) => {
6779
6784
  // src/utils/formatTransferToContractScriptData.ts
6780
6785
  var import_abi_coder7 = require("@fuel-ts/abi-coder");
6781
6786
  var import_address5 = require("@fuel-ts/address");
6782
- var import_math21 = require("@fuel-ts/math");
6783
6787
  var import_utils36 = require("@fuel-ts/utils");
6784
6788
  var asm = __toESM(require("@fuels/vm-asm"));
6785
6789
  var formatTransferToContractScriptData = (transferParams) => {
6786
6790
  const numberCoder = new import_abi_coder7.BigNumberCoder("u64");
6787
6791
  return transferParams.reduce((acc, transferParam) => {
6788
6792
  const { assetId, amount, contractId } = transferParam;
6789
- const encoded = numberCoder.encode(new import_math21.BN(amount).toNumber());
6793
+ const encoded = numberCoder.encode(amount);
6790
6794
  const scriptData = (0, import_utils36.concat)([
6791
6795
  import_address5.Address.fromAddressOrString(contractId).toBytes(),
6792
6796
  encoded,
@@ -6938,9 +6942,9 @@ var Account = class extends import_interfaces.AbstractAccount {
6938
6942
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
6939
6943
  const fee = request.maxFee;
6940
6944
  const baseAssetId = this.provider.getBaseAssetId();
6941
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math22.bn)(0);
6945
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
6942
6946
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
6943
- amount: (0, import_math22.bn)(fee),
6947
+ amount: (0, import_math21.bn)(fee),
6944
6948
  assetId: baseAssetId,
6945
6949
  coinQuantities: requiredQuantities
6946
6950
  });
@@ -6948,7 +6952,7 @@ var Account = class extends import_interfaces.AbstractAccount {
6948
6952
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
6949
6953
  quantitiesDict[assetId] = {
6950
6954
  required: amount,
6951
- owned: (0, import_math22.bn)(0)
6955
+ owned: (0, import_math21.bn)(0)
6952
6956
  };
6953
6957
  });
6954
6958
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -7024,7 +7028,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7024
7028
  return request;
7025
7029
  }
7026
7030
  const { maxFee } = await this.provider.estimateTxGasAndFee({
7027
- transactionRequest: requestToReestimate
7031
+ transactionRequest: requestToReestimate,
7032
+ gasPrice
7028
7033
  });
7029
7034
  request.maxFee = maxFee;
7030
7035
  return request;
@@ -7123,7 +7128,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7123
7128
  });
7124
7129
  const quantities = [];
7125
7130
  const transferParams = contractTransferParams.map((transferParam) => {
7126
- const amount = (0, import_math22.bn)(transferParam.amount);
7131
+ const amount = (0, import_math21.bn)(transferParam.amount);
7127
7132
  const contractAddress = import_address6.Address.fromAddressOrString(transferParam.contractId);
7128
7133
  const assetId = transferParam.assetId ? (0, import_utils37.hexlify)(transferParam.assetId) : this.provider.getBaseAssetId();
7129
7134
  if (amount.lte(0)) {
@@ -7160,7 +7165,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7160
7165
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7161
7166
  );
7162
7167
  const amountDataArray = (0, import_utils37.arrayify)(
7163
- "0x".concat((0, import_math22.bn)(amount).toHex().substring(2).padStart(16, "0"))
7168
+ "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7164
7169
  );
7165
7170
  const script = new Uint8Array([
7166
7171
  ...(0, import_utils37.arrayify)(withdrawScript.bytes),
@@ -7170,7 +7175,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7170
7175
  const params = { script, ...txParams };
7171
7176
  const baseAssetId = this.provider.getBaseAssetId();
7172
7177
  let request = new ScriptTransactionRequest(params);
7173
- const quantities = [{ amount: (0, import_math22.bn)(amount), assetId: baseAssetId }];
7178
+ const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7174
7179
  const txCost = await this.getTransactionCost(request, { quantities });
7175
7180
  request = this.validateGasLimitAndMaxFee({
7176
7181
  transactionRequest: request,
@@ -7196,7 +7201,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7196
7201
  const baseAssetId = this.provider.getBaseAssetId();
7197
7202
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7198
7203
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7199
- const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math22.bn)("100000000000000000") }];
7204
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7200
7205
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
7201
7206
  if (input.type === import_transactions24.InputType.Coin) {
7202
7207
  return input.assetId === assetId;
@@ -7307,14 +7312,14 @@ var Account = class extends import_interfaces.AbstractAccount {
7307
7312
  return coins.map((coin) => ({
7308
7313
  id: (0, import_utils37.hexlify)((0, import_crypto5.randomBytes)(import_abi_coder8.UTXO_ID_LEN)),
7309
7314
  owner: this.address,
7310
- blockCreated: (0, import_math22.bn)(1),
7311
- txCreatedIdx: (0, import_math22.bn)(1),
7315
+ blockCreated: (0, import_math21.bn)(1),
7316
+ txCreatedIdx: (0, import_math21.bn)(1),
7312
7317
  ...coin
7313
7318
  }));
7314
7319
  }
7315
7320
  /** @hidden * */
7316
7321
  validateTransferAmount(amount) {
7317
- if ((0, import_math22.bn)(amount).lte(0)) {
7322
+ if ((0, import_math21.bn)(amount).lte(0)) {
7318
7323
  throw new import_errors21.FuelError(
7319
7324
  import_errors21.ErrorCode.INVALID_TRANSFER_AMOUNT,
7320
7325
  "Transfer amount must be a positive number."
@@ -7575,7 +7580,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7575
7580
  var import_crypto8 = require("@fuel-ts/crypto");
7576
7581
  var import_errors25 = require("@fuel-ts/errors");
7577
7582
  var import_hasher7 = require("@fuel-ts/hasher");
7578
- var import_math23 = require("@fuel-ts/math");
7583
+ var import_math22 = require("@fuel-ts/math");
7579
7584
  var import_utils43 = require("@fuel-ts/utils");
7580
7585
 
7581
7586
  // src/mnemonic/mnemonic.ts
@@ -10001,13 +10006,13 @@ var HDWallet = class {
10001
10006
  } else {
10002
10007
  data.set((0, import_utils43.arrayify)(this.publicKey));
10003
10008
  }
10004
- data.set((0, import_math23.toBytes)(index, 4), 33);
10009
+ data.set((0, import_math22.toBytes)(index, 4), 33);
10005
10010
  const bytes = (0, import_utils43.arrayify)((0, import_crypto8.computeHmac)("sha512", chainCode, data));
10006
10011
  const IL = bytes.slice(0, 32);
10007
10012
  const IR = bytes.slice(32);
10008
10013
  if (privateKey) {
10009
10014
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
10010
- const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
10015
+ const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
10011
10016
  return new HDWallet({
10012
10017
  privateKey: ki,
10013
10018
  chainCode: IR,
@@ -10053,7 +10058,7 @@ var HDWallet = class {
10053
10058
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
10054
10059
  const depth = (0, import_utils43.hexlify)(Uint8Array.from([this.depth]));
10055
10060
  const parentFingerprint = this.parentFingerprint;
10056
- const index = (0, import_math23.toHex)(this.index, 4);
10061
+ const index = (0, import_math22.toHex)(this.index, 4);
10057
10062
  const chainCode = this.chainCode;
10058
10063
  const key = this.privateKey != null && !isPublic ? (0, import_utils43.concat)(["0x00", this.privateKey]) : this.publicKey;
10059
10064
  const extendedKey = (0, import_utils43.arrayify)((0, import_utils43.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -10073,7 +10078,7 @@ var HDWallet = class {
10073
10078
  });
10074
10079
  }
10075
10080
  static fromExtendedKey(extendedKey) {
10076
- const decoded = (0, import_utils43.hexlify)((0, import_math23.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
10081
+ const decoded = (0, import_utils43.hexlify)((0, import_math22.toBytes)((0, import_utils43.decodeBase58)(extendedKey)));
10077
10082
  const bytes = (0, import_utils43.arrayify)(decoded);
10078
10083
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10079
10084
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -10442,7 +10447,7 @@ async function setupTestProviderAndWallets({
10442
10447
  // src/test-utils/test-message.ts
10443
10448
  var import_address8 = require("@fuel-ts/address");
10444
10449
  var import_crypto10 = require("@fuel-ts/crypto");
10445
- var import_math24 = require("@fuel-ts/math");
10450
+ var import_math23 = require("@fuel-ts/math");
10446
10451
  var import_utils46 = require("@fuel-ts/utils");
10447
10452
  var TestMessage = class {
10448
10453
  sender;
@@ -10479,7 +10484,7 @@ var TestMessage = class {
10479
10484
  sender: this.sender.toB256(),
10480
10485
  recipient: recipient?.toB256() ?? this.recipient.toB256(),
10481
10486
  nonce: this.nonce,
10482
- amount: (0, import_math24.bn)(this.amount).toNumber(),
10487
+ amount: (0, import_math23.bn)(this.amount).toNumber(),
10483
10488
  data,
10484
10489
  da_height: this.da_height
10485
10490
  };