@fuel-ts/account 0.97.0 → 0.97.2

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 (34) 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 +588 -14248
  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 +3 -1
  22. package/dist/test-utils/launchNode.d.ts.map +1 -1
  23. package/dist/test-utils/test-coin.d.ts +1 -0
  24. package/dist/test-utils/test-coin.d.ts.map +1 -0
  25. package/dist/test-utils.global.js +9958 -24049
  26. package/dist/test-utils.global.js.map +1 -1
  27. package/dist/test-utils.js +67 -30
  28. package/dist/test-utils.js.map +1 -1
  29. package/dist/test-utils.mjs +49 -12
  30. package/dist/test-utils.mjs.map +1 -1
  31. package/dist/utils/formatTransferToContractScriptData.d.ts +1 -1
  32. package/dist/utils/formatTransferToContractScriptData.d.ts.map +1 -1
  33. package/dist/wallet/base-wallet-unlocked.d.ts.map +1 -1
  34. package/package.json +18 -18
@@ -154,7 +154,11 @@ var extractRemainingArgs = (args, flagsToRemove) => {
154
154
  });
155
155
  return newArgs;
156
156
  };
157
- function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
157
+ function getFinalStateConfigJSON({
158
+ stateConfig,
159
+ chainConfig,
160
+ includeInitialState = false
161
+ }) {
158
162
  const defaultCoins = defaultSnapshotConfigs.stateConfig.coins.map((coin) => ({
159
163
  ...coin,
160
164
  amount: "18446744073709551615"
@@ -165,6 +169,26 @@ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
165
169
  }));
166
170
  const coins = defaultCoins.concat(stateConfig.coins.map((coin) => ({ ...coin, amount: coin.amount.toString() }))).filter((coin, index, self) => self.findIndex((c) => c.tx_id === coin.tx_id) === index);
167
171
  const messages = defaultMessages.concat(stateConfig.messages.map((msg) => ({ ...msg, amount: msg.amount.toString() }))).filter((msg, index, self) => self.findIndex((m) => m.nonce === msg.nonce) === index);
172
+ if (includeInitialState) {
173
+ coins.push({
174
+ tx_id: "0x0000000000000000000000000000000000000000000000000000000000000001",
175
+ output_index: 0,
176
+ tx_pointer_block_height: 0,
177
+ tx_pointer_tx_idx: 0,
178
+ owner: "0x94ffcc53b892684acefaebc8a3d4a595e528a8cf664eeb3ef36f1020b0809d0d",
179
+ amount: "18446744073709551615",
180
+ asset_id: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
181
+ });
182
+ coins.push({
183
+ tx_id: "0x0000000000000000000000000000000000000000000000000000000000000002",
184
+ output_index: 0,
185
+ tx_pointer_block_height: 0,
186
+ tx_pointer_tx_idx: 0,
187
+ owner: "0x09c0b2d1a486c439a87bcba6b46a7a1a23f3897cc83a94521a96da5c23bc58db",
188
+ amount: "18446744073709551615",
189
+ asset_id: "0xf8f8b6283d7fa5b672b530cbb84fcccb4ff8dc40f8176ef4544ddb1f1952ad07"
190
+ });
191
+ }
168
192
  if (!process.env.GENESIS_SECRET) {
169
193
  const pk = Signer.generatePrivateKey();
170
194
  const signer = new Signer(pk);
@@ -174,7 +198,7 @@ function getFinalStateConfigJSON({ stateConfig, chainConfig }) {
174
198
  owner: signer.address.toHexString(),
175
199
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
176
200
  amount: "18446744073709551615",
177
- asset_id: chainConfig.consensus_parameters.V1.base_asset_id,
201
+ asset_id: chainConfig.consensus_parameters.V2.base_asset_id,
178
202
  output_index: 0,
179
203
  tx_pointer_block_height: 0,
180
204
  tx_pointer_tx_idx: 0
@@ -195,7 +219,8 @@ var launchNode = async ({
195
219
  fuelCorePath = process.env.FUEL_CORE_PATH || void 0,
196
220
  loggingEnabled = true,
197
221
  basePath,
198
- snapshotConfig = defaultSnapshotConfigs
222
+ snapshotConfig = defaultSnapshotConfigs,
223
+ includeInitialState = false
199
224
  } = {}) => (
200
225
  // eslint-disable-next-line no-async-promise-executor
201
226
  new Promise(async (resolve, reject) => {
@@ -235,7 +260,14 @@ var launchNode = async ({
235
260
  const stateConfigPath = path.join(tempDir, metadata.table_encoding.Json.filepath);
236
261
  const stateTransitionPath = path.join(tempDir, "state_transition_bytecode.wasm");
237
262
  writeFileSync(chainConfigPath, JSON.stringify(snapshotConfig.chainConfig), "utf8");
238
- writeFileSync(stateConfigPath, getFinalStateConfigJSON(snapshotConfig), "utf8");
263
+ writeFileSync(
264
+ stateConfigPath,
265
+ getFinalStateConfigJSON({
266
+ ...snapshotConfig,
267
+ includeInitialState
268
+ }),
269
+ "utf8"
270
+ );
239
271
  writeFileSync(metadataPath, JSON.stringify(metadata), "utf8");
240
272
  writeFileSync(stateTransitionPath, JSON.stringify(""));
241
273
  snapshotDirToUse = tempDir;
@@ -291,6 +323,8 @@ var launchNode = async ({
291
323
  console.log(
292
324
  `fuel-core node under pid ${child.pid} does not exist. The node might have been killed before cleanup was called. Exiting cleanly.`
293
325
  );
326
+ } else if (error.message.includes("pid must be a positive integer")) {
327
+ process.kill(+child.pid);
294
328
  } else {
295
329
  throw e;
296
330
  }
@@ -319,6 +353,7 @@ var launchNode = async ({
319
353
  reject(new FuelError(FuelError.CODES.NODE_LAUNCH_FAILED, text));
320
354
  }
321
355
  });
356
+ process.setMaxListeners(100);
322
357
  process.on("exit", cleanup);
323
358
  process.on("SIGINT", cleanup);
324
359
  process.on("SIGUSR1", cleanup);
@@ -4913,7 +4948,7 @@ Supported fuel-core version: ${supportedVersion}.`
4913
4948
  createOperations() {
4914
4949
  const fetchFn = _Provider.getFetchFn(this.options);
4915
4950
  const gqlClient = new GraphQLClient(this.urlWithoutAuth, {
4916
- fetch: (url, requestInit) => fetchFn(url, requestInit, this.options),
4951
+ fetch: (input, requestInit) => fetchFn(input.toString(), requestInit || {}, this.options),
4917
4952
  responseMiddleware: (response) => {
4918
4953
  if ("response" in response) {
4919
4954
  const graphQlResponse = response.response;
@@ -5164,7 +5199,8 @@ Supported fuel-core version: ${supportedVersion}.`
5164
5199
  dryRun: [{ receipts: rawReceipts, status }]
5165
5200
  } = await this.operations.dryRun({
5166
5201
  encodedTransactions: [hexlify17(transactionRequest.toTransactionBytes())],
5167
- utxoValidation: false
5202
+ utxoValidation: false,
5203
+ gasPrice: "0"
5168
5204
  });
5169
5205
  receipts = rawReceipts.map(processGqlReceipt);
5170
5206
  dryRunStatus = status;
@@ -5178,7 +5214,8 @@ Supported fuel-core version: ${supportedVersion}.`
5178
5214
  missingContractIds.push(contractId);
5179
5215
  });
5180
5216
  const { maxFee } = await this.estimateTxGasAndFee({
5181
- transactionRequest
5217
+ transactionRequest,
5218
+ gasPrice: bn17(0)
5182
5219
  });
5183
5220
  transactionRequest.maxFee = maxFee;
5184
5221
  } else {
@@ -5314,7 +5351,7 @@ Supported fuel-core version: ${supportedVersion}.`
5314
5351
  const chainInfo = this.getChain();
5315
5352
  const { gasPriceFactor, maxGasPerTx } = this.getGasConfig();
5316
5353
  const minGas = transactionRequest.calculateMinGas(chainInfo);
5317
- if (!gasPrice) {
5354
+ if (!isDefined2(gasPrice)) {
5318
5355
  gasPrice = await this.estimateGasPrice(10);
5319
5356
  }
5320
5357
  const minFee = calculateGasFee({
@@ -6758,14 +6795,13 @@ var mergeQuantities = (...coinQuantities) => {
6758
6795
  // src/utils/formatTransferToContractScriptData.ts
6759
6796
  import { ASSET_ID_LEN, BigNumberCoder as BigNumberCoder2, CONTRACT_ID_LEN, WORD_SIZE } from "@fuel-ts/abi-coder";
6760
6797
  import { Address as Address4 } from "@fuel-ts/address";
6761
- import { BN as BN3 } from "@fuel-ts/math";
6762
6798
  import { arrayify as arrayify15, concat as concat4 } from "@fuel-ts/utils";
6763
6799
  import * as asm from "@fuels/vm-asm";
6764
6800
  var formatTransferToContractScriptData = (transferParams) => {
6765
6801
  const numberCoder = new BigNumberCoder2("u64");
6766
6802
  return transferParams.reduce((acc, transferParam) => {
6767
6803
  const { assetId, amount, contractId } = transferParam;
6768
- const encoded = numberCoder.encode(new BN3(amount).toNumber());
6804
+ const encoded = numberCoder.encode(amount);
6769
6805
  const scriptData = concat4([
6770
6806
  Address4.fromAddressOrString(contractId).toBytes(),
6771
6807
  encoded,
@@ -7003,7 +7039,8 @@ var Account = class extends AbstractAccount {
7003
7039
  return request;
7004
7040
  }
7005
7041
  const { maxFee } = await this.provider.estimateTxGasAndFee({
7006
- transactionRequest: requestToReestimate
7042
+ transactionRequest: requestToReestimate,
7043
+ gasPrice
7007
7044
  });
7008
7045
  request.maxFee = maxFee;
7009
7046
  return request;
@@ -10380,7 +10417,7 @@ async function setupTestProviderAndWallets({
10380
10417
  } = {}) {
10381
10418
  Symbol.dispose ??= Symbol("Symbol.dispose");
10382
10419
  const walletsConfig = new WalletsConfig(
10383
- nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V1?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V1.base_asset_id,
10420
+ nodeOptions.snapshotConfig?.chainConfig?.consensus_parameters?.V2?.base_asset_id ?? defaultSnapshotConfigs3.chainConfig.consensus_parameters.V2.base_asset_id,
10384
10421
  {
10385
10422
  ...defaultWalletConfigOptions,
10386
10423
  ...walletsConfigOptions