@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
package/dist/index.js CHANGED
@@ -223,7 +223,7 @@ var import_address5 = require("@fuel-ts/address");
223
223
  var import_crypto2 = require("@fuel-ts/crypto");
224
224
  var import_errors20 = require("@fuel-ts/errors");
225
225
  var import_interfaces = require("@fuel-ts/interfaces");
226
- var import_math21 = require("@fuel-ts/math");
226
+ var import_math20 = require("@fuel-ts/math");
227
227
  var import_transactions24 = require("@fuel-ts/transactions");
228
228
  var import_utils34 = require("@fuel-ts/utils");
229
229
  var import_ramda9 = require("ramda");
@@ -4932,7 +4932,7 @@ Supported fuel-core version: ${supportedVersion}.`
4932
4932
  createOperations() {
4933
4933
  const fetchFn = _Provider.getFetchFn(this.options);
4934
4934
  const gqlClient = new import_graphql_request.GraphQLClient(this.urlWithoutAuth, {
4935
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4935
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4936
4936
  responseMiddleware: (response) => {
4937
4937
  if ("response" in response) {
4938
4938
  const graphQlResponse = response.response;
@@ -5183,7 +5183,8 @@ Supported fuel-core version: ${supportedVersion}.`
5183
5183
  dryRun: [{ receipts: rawReceipts, status }]
5184
5184
  } = await this.operations.dryRun({
5185
5185
  encodedTransactions: [(0, import_utils28.hexlify)(transactionRequest.toTransactionBytes())],
5186
- utxoValidation: false
5186
+ utxoValidation: false,
5187
+ gasPrice: "0"
5187
5188
  });
5188
5189
  receipts = rawReceipts.map(processGqlReceipt);
5189
5190
  dryRunStatus = status;
@@ -5197,7 +5198,8 @@ Supported fuel-core version: ${supportedVersion}.`
5197
5198
  missingContractIds.push(contractId);
5198
5199
  });
5199
5200
  const { maxFee } = await this.estimateTxGasAndFee({
5200
- transactionRequest
5201
+ transactionRequest,
5202
+ gasPrice: (0, import_math18.bn)(0)
5201
5203
  });
5202
5204
  transactionRequest.maxFee = maxFee;
5203
5205
  } else {
@@ -5333,7 +5335,7 @@ Supported fuel-core version: ${supportedVersion}.`
5333
5335
  const chainInfo = this.getChain();
5334
5336
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5335
5337
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5336
- if (!gasPrice) {
5338
+ if (!(0, import_utils28.isDefined)(gasPrice)) {
5337
5339
  gasPrice = await this.estimateGasPrice(10);
5338
5340
  }
5339
5341
  const minFee = calculateGasFee({
@@ -6916,14 +6918,13 @@ var mergeQuantities = (...coinQuantities) => {
6916
6918
  // src/utils/formatTransferToContractScriptData.ts
6917
6919
  var import_abi_coder6 = require("@fuel-ts/abi-coder");
6918
6920
  var import_address4 = require("@fuel-ts/address");
6919
- var import_math20 = require("@fuel-ts/math");
6920
6921
  var import_utils33 = require("@fuel-ts/utils");
6921
6922
  var asm = __toESM(require("@fuels/vm-asm"));
6922
6923
  var formatTransferToContractScriptData = (transferParams) => {
6923
6924
  const numberCoder = new import_abi_coder6.BigNumberCoder("u64");
6924
6925
  return transferParams.reduce((acc, transferParam) => {
6925
6926
  const { assetId, amount, contractId } = transferParam;
6926
- const encoded = numberCoder.encode(new import_math20.BN(amount).toNumber());
6927
+ const encoded = numberCoder.encode(amount);
6927
6928
  const scriptData = (0, import_utils33.concat)([
6928
6929
  import_address4.Address.fromAddressOrString(contractId).toBytes(),
6929
6930
  encoded,
@@ -7075,9 +7076,9 @@ var Account = class extends import_interfaces.AbstractAccount {
7075
7076
  const { addedSignatures, estimatedPredicates, requiredQuantities, updateMaxFee, gasPrice } = params;
7076
7077
  const fee = request.maxFee;
7077
7078
  const baseAssetId = this.provider.getBaseAssetId();
7078
- const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math21.bn)(0);
7079
+ const requiredInBaseAsset = requiredQuantities.find((quantity) => quantity.assetId === baseAssetId)?.amount || (0, import_math20.bn)(0);
7079
7080
  const requiredQuantitiesWithFee = addAmountToCoinQuantities({
7080
- amount: (0, import_math21.bn)(fee),
7081
+ amount: (0, import_math20.bn)(fee),
7081
7082
  assetId: baseAssetId,
7082
7083
  coinQuantities: requiredQuantities
7083
7084
  });
@@ -7085,7 +7086,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7085
7086
  requiredQuantitiesWithFee.forEach(({ amount, assetId }) => {
7086
7087
  quantitiesDict[assetId] = {
7087
7088
  required: amount,
7088
- owned: (0, import_math21.bn)(0)
7089
+ owned: (0, import_math20.bn)(0)
7089
7090
  };
7090
7091
  });
7091
7092
  request.inputs.filter(isRequestInputResource).forEach((input) => {
@@ -7161,7 +7162,8 @@ var Account = class extends import_interfaces.AbstractAccount {
7161
7162
  return request;
7162
7163
  }
7163
7164
  const { maxFee } = await this.provider.estimateTxGasAndFee({
7164
- transactionRequest: requestToReestimate
7165
+ transactionRequest: requestToReestimate,
7166
+ gasPrice
7165
7167
  });
7166
7168
  request.maxFee = maxFee;
7167
7169
  return request;
@@ -7260,7 +7262,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7260
7262
  });
7261
7263
  const quantities = [];
7262
7264
  const transferParams = contractTransferParams.map((transferParam) => {
7263
- const amount = (0, import_math21.bn)(transferParam.amount);
7265
+ const amount = (0, import_math20.bn)(transferParam.amount);
7264
7266
  const contractAddress = import_address5.Address.fromAddressOrString(transferParam.contractId);
7265
7267
  const assetId = transferParam.assetId ? (0, import_utils34.hexlify)(transferParam.assetId) : this.provider.getBaseAssetId();
7266
7268
  if (amount.lte(0)) {
@@ -7297,7 +7299,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7297
7299
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
7298
7300
  );
7299
7301
  const amountDataArray = (0, import_utils34.arrayify)(
7300
- "0x".concat((0, import_math21.bn)(amount).toHex().substring(2).padStart(16, "0"))
7302
+ "0x".concat((0, import_math20.bn)(amount).toHex().substring(2).padStart(16, "0"))
7301
7303
  );
7302
7304
  const script = new Uint8Array([
7303
7305
  ...(0, import_utils34.arrayify)(withdrawScript.bytes),
@@ -7307,7 +7309,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7307
7309
  const params = { script, ...txParams };
7308
7310
  const baseAssetId = this.provider.getBaseAssetId();
7309
7311
  let request = new ScriptTransactionRequest(params);
7310
- const quantities = [{ amount: (0, import_math21.bn)(amount), assetId: baseAssetId }];
7312
+ const quantities = [{ amount: (0, import_math20.bn)(amount), assetId: baseAssetId }];
7311
7313
  const txCost = await this.getTransactionCost(request, { quantities });
7312
7314
  request = this.validateGasLimitAndMaxFee({
7313
7315
  transactionRequest: request,
@@ -7333,7 +7335,7 @@ var Account = class extends import_interfaces.AbstractAccount {
7333
7335
  const baseAssetId = this.provider.getBaseAssetId();
7334
7336
  const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
7335
7337
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
7336
- const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math21.bn)("100000000000000000") }];
7338
+ const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: (0, import_math20.bn)("100000000000000000") }];
7337
7339
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
7338
7340
  if (input.type === import_transactions24.InputType.Coin) {
7339
7341
  return input.assetId === assetId;
@@ -7444,14 +7446,14 @@ var Account = class extends import_interfaces.AbstractAccount {
7444
7446
  return coins.map((coin) => ({
7445
7447
  id: (0, import_utils34.hexlify)((0, import_crypto2.randomBytes)(import_abi_coder7.UTXO_ID_LEN)),
7446
7448
  owner: this.address,
7447
- blockCreated: (0, import_math21.bn)(1),
7448
- txCreatedIdx: (0, import_math21.bn)(1),
7449
+ blockCreated: (0, import_math20.bn)(1),
7450
+ txCreatedIdx: (0, import_math20.bn)(1),
7449
7451
  ...coin
7450
7452
  }));
7451
7453
  }
7452
7454
  /** @hidden * */
7453
7455
  validateTransferAmount(amount) {
7454
- if ((0, import_math21.bn)(amount).lte(0)) {
7456
+ if ((0, import_math20.bn)(amount).lte(0)) {
7455
7457
  throw new import_errors20.FuelError(
7456
7458
  import_errors20.ErrorCode.INVALID_TRANSFER_AMOUNT,
7457
7459
  "Transfer amount must be a positive number."
@@ -7507,7 +7509,7 @@ var import_utils37 = require("@fuel-ts/utils");
7507
7509
  var import_address6 = require("@fuel-ts/address");
7508
7510
  var import_crypto3 = require("@fuel-ts/crypto");
7509
7511
  var import_hasher3 = require("@fuel-ts/hasher");
7510
- var import_math22 = require("@fuel-ts/math");
7512
+ var import_math21 = require("@fuel-ts/math");
7511
7513
  var import_utils35 = require("@fuel-ts/utils");
7512
7514
  var import_secp256k1 = require("@noble/curves/secp256k1");
7513
7515
  var Signer = class {
@@ -7527,7 +7529,7 @@ var Signer = class {
7527
7529
  privateKey = `0x${privateKey}`;
7528
7530
  }
7529
7531
  }
7530
- const privateKeyBytes = (0, import_math22.toBytes)(privateKey, 32);
7532
+ const privateKeyBytes = (0, import_math21.toBytes)(privateKey, 32);
7531
7533
  this.privateKey = (0, import_utils35.hexlify)(privateKeyBytes);
7532
7534
  this.publicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, false).slice(1));
7533
7535
  this.compressedPublicKey = (0, import_utils35.hexlify)(import_secp256k1.secp256k1.getPublicKey(privateKeyBytes, true));
@@ -7545,8 +7547,8 @@ var Signer = class {
7545
7547
  */
7546
7548
  sign(data) {
7547
7549
  const signature = import_secp256k1.secp256k1.sign((0, import_utils35.arrayify)(data), (0, import_utils35.arrayify)(this.privateKey));
7548
- const r = (0, import_math22.toBytes)(`0x${signature.r.toString(16)}`, 32);
7549
- const s = (0, import_math22.toBytes)(`0x${signature.s.toString(16)}`, 32);
7550
+ const r = (0, import_math21.toBytes)(`0x${signature.r.toString(16)}`, 32);
7551
+ const s = (0, import_math21.toBytes)(`0x${signature.s.toString(16)}`, 32);
7550
7552
  s[0] |= (signature.recovery || 0) << 7;
7551
7553
  return (0, import_utils35.hexlify)((0, import_utils35.concat)([r, s]));
7552
7554
  }
@@ -7825,7 +7827,7 @@ __publicField(BaseWalletUnlocked, "defaultPath", "m/44'/1179993420'/0'/0/0");
7825
7827
  var import_crypto6 = require("@fuel-ts/crypto");
7826
7828
  var import_errors24 = require("@fuel-ts/errors");
7827
7829
  var import_hasher7 = require("@fuel-ts/hasher");
7828
- var import_math23 = require("@fuel-ts/math");
7830
+ var import_math22 = require("@fuel-ts/math");
7829
7831
  var import_utils41 = require("@fuel-ts/utils");
7830
7832
 
7831
7833
  // src/mnemonic/mnemonic.ts
@@ -10257,13 +10259,13 @@ var HDWallet = class {
10257
10259
  } else {
10258
10260
  data.set((0, import_utils41.arrayify)(this.publicKey));
10259
10261
  }
10260
- data.set((0, import_math23.toBytes)(index, 4), 33);
10262
+ data.set((0, import_math22.toBytes)(index, 4), 33);
10261
10263
  const bytes = (0, import_utils41.arrayify)((0, import_crypto6.computeHmac)("sha512", chainCode, data));
10262
10264
  const IL = bytes.slice(0, 32);
10263
10265
  const IR = bytes.slice(32);
10264
10266
  if (privateKey) {
10265
10267
  const N = "0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
10266
- const ki = (0, import_math23.bn)(IL).add(privateKey).mod(N).toBytes(32);
10268
+ const ki = (0, import_math22.bn)(IL).add(privateKey).mod(N).toBytes(32);
10267
10269
  return new HDWallet({
10268
10270
  privateKey: ki,
10269
10271
  chainCode: IR,
@@ -10309,7 +10311,7 @@ var HDWallet = class {
10309
10311
  const prefix = getExtendedKeyPrefix(this.privateKey == null || isPublic, testnet);
10310
10312
  const depth = (0, import_utils41.hexlify)(Uint8Array.from([this.depth]));
10311
10313
  const parentFingerprint = this.parentFingerprint;
10312
- const index = (0, import_math23.toHex)(this.index, 4);
10314
+ const index = (0, import_math22.toHex)(this.index, 4);
10313
10315
  const chainCode = this.chainCode;
10314
10316
  const key = this.privateKey != null && !isPublic ? (0, import_utils41.concat)(["0x00", this.privateKey]) : this.publicKey;
10315
10317
  const extendedKey = (0, import_utils41.arrayify)((0, import_utils41.concat)([prefix, depth, parentFingerprint, index, chainCode, key]));
@@ -10329,7 +10331,7 @@ var HDWallet = class {
10329
10331
  });
10330
10332
  }
10331
10333
  static fromExtendedKey(extendedKey) {
10332
- const decoded = (0, import_utils41.hexlify)((0, import_math23.toBytes)((0, import_utils41.decodeBase58)(extendedKey)));
10334
+ const decoded = (0, import_utils41.hexlify)((0, import_math22.toBytes)((0, import_utils41.decodeBase58)(extendedKey)));
10333
10335
  const bytes = (0, import_utils41.arrayify)(decoded);
10334
10336
  const validChecksum = base58check(bytes.slice(0, 78)) === extendedKey;
10335
10337
  if (bytes.length !== 82 || !isValidExtendedKey(bytes)) {
@@ -10950,7 +10952,7 @@ var import_utils45 = require("@fuel-ts/utils");
10950
10952
  // src/utils/deployScriptOrPredicate.ts
10951
10953
  var import_errors29 = require("@fuel-ts/errors");
10952
10954
  var import_hasher8 = require("@fuel-ts/hasher");
10953
- var import_math24 = require("@fuel-ts/math");
10955
+ var import_math23 = require("@fuel-ts/math");
10954
10956
  var import_utils43 = require("@fuel-ts/utils");
10955
10957
 
10956
10958
  // src/utils/predicate-script-loader-instructions.ts
@@ -11082,7 +11084,7 @@ function getPredicateScriptLoaderInstructions(originalBinary, blobId) {
11082
11084
 
11083
11085
  // src/utils/deployScriptOrPredicate.ts
11084
11086
  async function fundBlobTx(deployer, blobTxRequest) {
11085
- let totalCost = (0, import_math24.bn)(0);
11087
+ let totalCost = (0, import_math23.bn)(0);
11086
11088
  const chainInfo = deployer.provider.getChain();
11087
11089
  const gasPrice = await deployer.provider.estimateGasPrice(10);
11088
11090
  const priceFactor = chainInfo.consensusParameters.feeParameters.gasPriceFactor;