@fuel-ts/account 0.78.0 → 0.79.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.

package/dist/index.mjs CHANGED
@@ -2356,6 +2356,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2356
2356
  script;
2357
2357
  /** Script input data (parameters) */
2358
2358
  scriptData;
2359
+ abis;
2359
2360
  /**
2360
2361
  * Constructor for `ScriptTransactionRequest`.
2361
2362
  *
@@ -2366,6 +2367,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2366
2367
  this.gasLimit = bn9(gasLimit);
2367
2368
  this.script = arrayify8(script ?? returnZeroScript.bytes);
2368
2369
  this.scriptData = arrayify8(scriptData ?? returnZeroScript.encodeScriptData());
2370
+ this.abis = rest.abis;
2369
2371
  }
2370
2372
  /**
2371
2373
  * Converts the transaction request to a `TransactionScript`.
@@ -3278,6 +3280,21 @@ function assembleTransactionSummary(params) {
3278
3280
  return transactionSummary;
3279
3281
  }
3280
3282
 
3283
+ // src/providers/transaction-response/getDecodedLogs.ts
3284
+ import { Interface as Interface3, BigNumberCoder } from "@fuel-ts/abi-coder";
3285
+ import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3286
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3287
+ return receipts.reduce((logs, receipt) => {
3288
+ if (receipt.type === ReceiptType5.LogData || receipt.type === ReceiptType5.Log) {
3289
+ const interfaceToUse = new Interface3(externalAbis[receipt.id] || mainAbi);
3290
+ const data = receipt.type === ReceiptType5.Log ? new BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3291
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3292
+ logs.push(decodedLog);
3293
+ }
3294
+ return logs;
3295
+ }, []);
3296
+ }
3297
+
3281
3298
  // src/providers/transaction-response/transaction-response.ts
3282
3299
  var TransactionResponse = class {
3283
3300
  /** Transaction ID */
@@ -3288,15 +3305,17 @@ var TransactionResponse = class {
3288
3305
  gasUsed = bn13(0);
3289
3306
  /** The graphql Transaction with receipts object. */
3290
3307
  gqlTransaction;
3308
+ abis;
3291
3309
  /**
3292
3310
  * Constructor for `TransactionResponse`.
3293
3311
  *
3294
3312
  * @param id - The transaction ID.
3295
3313
  * @param provider - The provider.
3296
3314
  */
3297
- constructor(id, provider) {
3315
+ constructor(id, provider, abis) {
3298
3316
  this.id = id;
3299
3317
  this.provider = provider;
3318
+ this.abis = abis;
3300
3319
  }
3301
3320
  /**
3302
3321
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3306,8 +3325,8 @@ var TransactionResponse = class {
3306
3325
  * @param id - The transaction ID.
3307
3326
  * @param provider - The provider.
3308
3327
  */
3309
- static async create(id, provider) {
3310
- const response = new TransactionResponse(id, provider);
3328
+ static async create(id, provider, abis) {
3329
+ const response = new TransactionResponse(id, provider, abis);
3311
3330
  await response.fetch();
3312
3331
  return response;
3313
3332
  }
@@ -3411,6 +3430,14 @@ var TransactionResponse = class {
3411
3430
  gqlTransaction: this.gqlTransaction,
3412
3431
  ...transactionSummary
3413
3432
  };
3433
+ if (this.abis) {
3434
+ const logs = getDecodedLogs(
3435
+ transactionSummary.receipts,
3436
+ this.abis.main,
3437
+ this.abis.otherContractsAbis
3438
+ );
3439
+ transactionResult.logs = logs;
3440
+ }
3414
3441
  return transactionResult;
3415
3442
  }
3416
3443
  /**
@@ -3430,23 +3457,6 @@ var TransactionResponse = class {
3430
3457
  }
3431
3458
  };
3432
3459
 
3433
- // src/providers/transaction-response/getDecodedLogs.ts
3434
- import { BigNumberCoder } from "@fuel-ts/abi-coder";
3435
- import { ReceiptType as ReceiptType5 } from "@fuel-ts/transactions";
3436
- function getDecodedLogs(receipts, abiInterface) {
3437
- return receipts.reduce((logs, r) => {
3438
- if (r.type === ReceiptType5.LogData) {
3439
- logs.push(abiInterface.decodeLog(r.data, r.val1.toNumber(), r.id)[0]);
3440
- }
3441
- if (r.type === ReceiptType5.Log) {
3442
- logs.push(
3443
- abiInterface.decodeLog(new BigNumberCoder("u64").encode(r.val0), r.val1.toNumber(), r.id)[0]
3444
- );
3445
- }
3446
- return logs;
3447
- }, []);
3448
- }
3449
-
3450
3460
  // src/providers/utils/auto-retry-fetch.ts
3451
3461
  function getWaitDelay(options, retryAttemptNum) {
3452
3462
  const duration = options.baseDelay ?? 150;
@@ -3781,6 +3791,10 @@ var _Provider = class {
3781
3791
  await this.estimateTxDependencies(transactionRequest);
3782
3792
  }
3783
3793
  const encodedTransaction = hexlify12(transactionRequest.toTransactionBytes());
3794
+ let abis;
3795
+ if (transactionRequest.type === TransactionType8.Script) {
3796
+ abis = transactionRequest.abis;
3797
+ }
3784
3798
  if (awaitExecution) {
3785
3799
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3786
3800
  for await (const { submitAndAwait } of subscription) {
@@ -3795,14 +3809,14 @@ var _Provider = class {
3795
3809
  }
3796
3810
  }
3797
3811
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3798
- const response = new TransactionResponse(transactionId2, this);
3812
+ const response = new TransactionResponse(transactionId2, this, abis);
3799
3813
  await response.fetch();
3800
3814
  return response;
3801
3815
  }
3802
3816
  const {
3803
3817
  submit: { id: transactionId }
3804
3818
  } = await this.operations.submit({ encodedTransaction });
3805
- return new TransactionResponse(transactionId, this);
3819
+ return new TransactionResponse(transactionId, this, abis);
3806
3820
  }
3807
3821
  /**
3808
3822
  * Executes a transaction without actually submitting it to the chain.
@@ -8572,7 +8586,7 @@ var StorageAbstract = class {
8572
8586
 
8573
8587
  // src/predicate/predicate.ts
8574
8588
  import {
8575
- Interface as Interface3,
8589
+ Interface as Interface4,
8576
8590
  INPUT_COIN_FIXED_SIZE,
8577
8591
  WORD_SIZE,
8578
8592
  calculateVmTxMemory as calculateVmTxMemory2,
@@ -8706,7 +8720,7 @@ var Predicate = class extends Account {
8706
8720
  let predicateBytes = arrayify20(bytes);
8707
8721
  let abiInterface;
8708
8722
  if (jsonAbi) {
8709
- abiInterface = new Interface3(jsonAbi);
8723
+ abiInterface = new Interface4(jsonAbi);
8710
8724
  if (abiInterface.functions.main === void 0) {
8711
8725
  throw new FuelError23(
8712
8726
  ErrorCode23.ABI_MAIN_METHOD_MISSING,