@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.

@@ -2299,6 +2299,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2299
2299
  script;
2300
2300
  /** Script input data (parameters) */
2301
2301
  scriptData;
2302
+ abis;
2302
2303
  /**
2303
2304
  * Constructor for `ScriptTransactionRequest`.
2304
2305
  *
@@ -2309,6 +2310,7 @@ var ScriptTransactionRequest = class extends BaseTransactionRequest {
2309
2310
  this.gasLimit = (0, import_math9.bn)(gasLimit);
2310
2311
  this.script = (0, import_utils15.arrayify)(script ?? returnZeroScript.bytes);
2311
2312
  this.scriptData = (0, import_utils15.arrayify)(scriptData ?? returnZeroScript.encodeScriptData());
2313
+ this.abis = rest.abis;
2312
2314
  }
2313
2315
  /**
2314
2316
  * Converts the transaction request to a `TransactionScript`.
@@ -2476,7 +2478,7 @@ var transactionRequestify = (obj) => {
2476
2478
  // src/providers/transaction-response/transaction-response.ts
2477
2479
  var import_errors12 = require("@fuel-ts/errors");
2478
2480
  var import_math13 = require("@fuel-ts/math");
2479
- var import_transactions15 = require("@fuel-ts/transactions");
2481
+ var import_transactions16 = require("@fuel-ts/transactions");
2480
2482
  var import_utils21 = require("@fuel-ts/utils");
2481
2483
 
2482
2484
  // src/providers/transaction-summary/assemble-transaction-summary.ts
@@ -3174,6 +3176,21 @@ function assembleTransactionSummary(params) {
3174
3176
  return transactionSummary;
3175
3177
  }
3176
3178
 
3179
+ // src/providers/transaction-response/getDecodedLogs.ts
3180
+ var import_abi_coder3 = require("@fuel-ts/abi-coder");
3181
+ var import_transactions15 = require("@fuel-ts/transactions");
3182
+ function getDecodedLogs(receipts, mainAbi, externalAbis = {}) {
3183
+ return receipts.reduce((logs, receipt) => {
3184
+ if (receipt.type === import_transactions15.ReceiptType.LogData || receipt.type === import_transactions15.ReceiptType.Log) {
3185
+ const interfaceToUse = new import_abi_coder3.Interface(externalAbis[receipt.id] || mainAbi);
3186
+ const data = receipt.type === import_transactions15.ReceiptType.Log ? new import_abi_coder3.BigNumberCoder("u64").encode(receipt.val0) : receipt.data;
3187
+ const [decodedLog] = interfaceToUse.decodeLog(data, receipt.val1.toNumber());
3188
+ logs.push(decodedLog);
3189
+ }
3190
+ return logs;
3191
+ }, []);
3192
+ }
3193
+
3177
3194
  // src/providers/transaction-response/transaction-response.ts
3178
3195
  var TransactionResponse = class {
3179
3196
  /** Transaction ID */
@@ -3184,15 +3201,17 @@ var TransactionResponse = class {
3184
3201
  gasUsed = (0, import_math13.bn)(0);
3185
3202
  /** The graphql Transaction with receipts object. */
3186
3203
  gqlTransaction;
3204
+ abis;
3187
3205
  /**
3188
3206
  * Constructor for `TransactionResponse`.
3189
3207
  *
3190
3208
  * @param id - The transaction ID.
3191
3209
  * @param provider - The provider.
3192
3210
  */
3193
- constructor(id, provider) {
3211
+ constructor(id, provider, abis) {
3194
3212
  this.id = id;
3195
3213
  this.provider = provider;
3214
+ this.abis = abis;
3196
3215
  }
3197
3216
  /**
3198
3217
  * Async constructor for `TransactionResponse`. This method can be used to create
@@ -3202,8 +3221,8 @@ var TransactionResponse = class {
3202
3221
  * @param id - The transaction ID.
3203
3222
  * @param provider - The provider.
3204
3223
  */
3205
- static async create(id, provider) {
3206
- const response = new TransactionResponse(id, provider);
3224
+ static async create(id, provider, abis) {
3225
+ const response = new TransactionResponse(id, provider, abis);
3207
3226
  await response.fetch();
3208
3227
  return response;
3209
3228
  }
@@ -3237,7 +3256,7 @@ var TransactionResponse = class {
3237
3256
  * @returns The decoded transaction.
3238
3257
  */
3239
3258
  decodeTransaction(transactionWithReceipts) {
3240
- return new import_transactions15.TransactionCoder().decode(
3259
+ return new import_transactions16.TransactionCoder().decode(
3241
3260
  (0, import_utils21.arrayify)(transactionWithReceipts.rawPayload),
3242
3261
  0
3243
3262
  )?.[0];
@@ -3307,6 +3326,14 @@ var TransactionResponse = class {
3307
3326
  gqlTransaction: this.gqlTransaction,
3308
3327
  ...transactionSummary
3309
3328
  };
3329
+ if (this.abis) {
3330
+ const logs = getDecodedLogs(
3331
+ transactionSummary.receipts,
3332
+ this.abis.main,
3333
+ this.abis.otherContractsAbis
3334
+ );
3335
+ transactionResult.logs = logs;
3336
+ }
3310
3337
  return transactionResult;
3311
3338
  }
3312
3339
  /**
@@ -3326,10 +3353,6 @@ var TransactionResponse = class {
3326
3353
  }
3327
3354
  };
3328
3355
 
3329
- // src/providers/transaction-response/getDecodedLogs.ts
3330
- var import_abi_coder3 = require("@fuel-ts/abi-coder");
3331
- var import_transactions16 = require("@fuel-ts/transactions");
3332
-
3333
3356
  // src/providers/utils/auto-retry-fetch.ts
3334
3357
  function getWaitDelay(options, retryAttemptNum) {
3335
3358
  const duration = options.baseDelay ?? 150;
@@ -3664,6 +3687,10 @@ var _Provider = class {
3664
3687
  await this.estimateTxDependencies(transactionRequest);
3665
3688
  }
3666
3689
  const encodedTransaction = (0, import_utils22.hexlify)(transactionRequest.toTransactionBytes());
3690
+ let abis;
3691
+ if (transactionRequest.type === import_transactions17.TransactionType.Script) {
3692
+ abis = transactionRequest.abis;
3693
+ }
3667
3694
  if (awaitExecution) {
3668
3695
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
3669
3696
  for await (const { submitAndAwait } of subscription) {
@@ -3678,14 +3705,14 @@ var _Provider = class {
3678
3705
  }
3679
3706
  }
3680
3707
  const transactionId2 = transactionRequest.getTransactionId(this.getChainId());
3681
- const response = new TransactionResponse(transactionId2, this);
3708
+ const response = new TransactionResponse(transactionId2, this, abis);
3682
3709
  await response.fetch();
3683
3710
  return response;
3684
3711
  }
3685
3712
  const {
3686
3713
  submit: { id: transactionId }
3687
3714
  } = await this.operations.submit({ encodedTransaction });
3688
- return new TransactionResponse(transactionId, this);
3715
+ return new TransactionResponse(transactionId, this, abis);
3689
3716
  }
3690
3717
  /**
3691
3718
  * Executes a transaction without actually submitting it to the chain.