@fuel-ts/account 0.0.0-rc-1832-20240404064601 → 0.0.0-rc-1895-20240404064636

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.

@@ -1 +1 @@
1
- {"version":3,"file":"transaction-response.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-response/transaction-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,KAAK,EACV,kBAAkB,EAElB,cAAc,EACd,MAAM,EACP,MAAM,8BAA8B,CAAC;AAItC,cAAc;AACd,MAAM,MAAM,4BAA4B,GAAG,WAAW,CAAC;AACvD,cAAc;AACd,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC;AAC3D,cAAc;AACd,MAAM,MAAM,kCAAkC,GAAG,iBAAiB,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AACtF,cAAc;AACd,MAAM,MAAM,6BAA6B,GAAG,YAAY,CAAC;AACzD,cAAc;AACd,MAAM,MAAM,8BAA8B,GAAG,aAAa,CAAC;AAC3D,cAAc;AACd,MAAM,MAAM,2BAA2B,GAAG,UAAU,CAAC;AACrD,cAAc;AACd,MAAM,MAAM,+BAA+B,GAAG,cAAc,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAChF,cAAc;AACd,MAAM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AAM,EACV,QAAQ,EAAE,QAAQ,EAClB,IAAI,CAAC,EAAE,oBAAoB,GAC1B,OAAO,CAAC,mBAAmB,CAAC;IAM/B;;;;OAIG;IACG,KAAK,IAAI,OAAO,CAAC,cAAc,CAAC;IAwBtC;;;;;OAKG;IACH,iBAAiB,CAAC,gBAAgB,GAAG,IAAI,EAAE,uBAAuB,EAAE,cAAc;IAOlF;;;;;;OAMG;IACG,qBAAqB,CAAC,gBAAgB,GAAG,IAAI,EACjD,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,CAAC;YAgClC,mBAAmB;IAyBjC;;;;OAIG;IACG,aAAa,CAAC,gBAAgB,GAAG,IAAI,EACzC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;IAuB/C;;;;OAIG;IACG,IAAI,CAAC,gBAAgB,GAAG,IAAI,EAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAYhD"}
1
+ {"version":3,"file":"transaction-response.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-response/transaction-response.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,cAAc,EACd,YAAY,EACZ,aAAa,EACb,iBAAiB,EACjB,aAAa,EACb,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,WAAW,EACZ,MAAM,uBAAuB,CAAC;AAI/B,OAAO,KAAK,QAAQ,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAGnE,OAAO,KAAK,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAK/F,c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GqlTransactionStatusFragmentFragment } from '../__generated__/operations';
3
+ import type { TransactionResultReceipt } from '../transaction-response';
4
+ import type { FailureStatus } from '../transaction-summary';
5
+ /**
6
+ * Assembles an error message for a panic status.
7
+ * @param status - The transaction failure status.
8
+ * @returns The error message.
9
+ */
10
+ export declare const assemblePanicError: (status: FailureStatus) => {
11
+ errorMessage: string;
12
+ reason: string;
13
+ };
14
+ /**
15
+ * Assembles an error message for a revert status.
16
+ * @param receipts - The transaction result processed receipts.
17
+ * @param logs - The transaction decoded logs.
18
+ * @returns The error message.
19
+ */
20
+ export declare const assembleRevertError: (receipts: Array<TransactionResultReceipt>, logs: Array<unknown>) => {
21
+ errorMessage: string;
22
+ reason: string;
23
+ };
24
+ interface IExtractTxError {
25
+ receipts: Array<TransactionResultReceipt>;
26
+ status?: GqlTransactionStatusFragmentFragment | null;
27
+ logs: Array<unknown>;
28
+ }
29
+ /**
30
+ * Extracts the transaction error and returns a FuelError object.
31
+ * @param IExtractTxError - The parameters for extracting the error.
32
+ * @returns The FuelError object.
33
+ */
34
+ export declare const extractTxError: (params: IExtractTxError) => FuelError;
35
+ export {};
36
+ //# sourceMappingURL=extract-tx-error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"extract-tx-error.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/extract-tx-error.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAcvD,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,6BAA6B,CAAC;AACxF,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACxE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAE5D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,WAAY,aAAa;;;CASvD,CAAC;AAKF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,aACpB,MAAM,wBAAwB,CAAC,QACnC,MAAM,OAAO,CAAC;;;CAsDrB,CAAC;AAEF,UAAU,eAAe;IACvB,QAAQ,EAAE,KAAK,CAAC,wBAAwB,CAAC,CAAC;IAC1C,MAAM,CAAC,EAAE,oCAAoC,GAAG,IAAI,CAAC;IACrD,IAAI,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CACtB;AAED;;;;GAIG;AACH,eAAO,MAAM,cAAc,WAAY,eAAe,KAAG,SAoBxD,CAAC"}
@@ -3,4 +3,5 @@ export * from './block-explorer';
3
3
  export * from './gas';
4
4
  export * from './json';
5
5
  export * from './sleep';
6
+ export * from './extract-tx-error';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/providers/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,kBAAkB,CAAC;AACjC,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,oBAAoB,CAAC"}
@@ -32045,6 +32045,7 @@ This unreleased fuel-core build may include features and updates not yet support
32045
32045
  })(ErrorCode || {});
32046
32046
  var _FuelError = class extends Error {
32047
32047
  VERSIONS = versions;
32048
+ metadata;
32048
32049
  static parse(e) {
32049
32050
  const error = e;
32050
32051
  if (error.code === void 0) {
@@ -32064,14 +32065,15 @@ This unreleased fuel-core build may include features and updates not yet support
32064
32065
  return new _FuelError(error.code, error.message);
32065
32066
  }
32066
32067
  code;
32067
- constructor(code, message) {
32068
+ constructor(code, message, metadata = {}) {
32068
32069
  super(message);
32069
32070
  this.code = code;
32070
32071
  this.name = "FuelError";
32072
+ this.metadata = metadata;
32071
32073
  }
32072
32074
  toObject() {
32073
- const { code, name, message, VERSIONS } = this;
32074
- return { code, name, message, VERSIONS };
32075
+ const { code, name, message, metadata, VERSIONS } = this;
32076
+ return { code, name, message, metadata, VERSIONS };
32075
32077
  }
32076
32078
  };
32077
32079
  var FuelError = _FuelError;
@@ -35378,6 +35380,9 @@ This unreleased fuel-core build may include features and updates not yet support
35378
35380
  __privateAdd2(this, _getPaddedData);
35379
35381
  }
35380
35382
  encode(value) {
35383
+ if (!Array.isArray(value)) {
35384
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
35385
+ }
35381
35386
  const parts = [];
35382
35387
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
35383
35388
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -35404,7 +35409,7 @@ This unreleased fuel-core build may include features and updates not yet support
35404
35409
  };
35405
35410
  _getPaddedData = /* @__PURE__ */ new WeakSet();
35406
35411
  getPaddedData_fn = function(value) {
35407
- const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
35412
+ const data = [Uint8Array.from(value)];
35408
35413
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
35409
35414
  if (paddingLength) {
35410
35415
  data.push(new Uint8Array(paddingLength));
@@ -35427,7 +35432,7 @@ This unreleased fuel-core build may include features and updates not yet support
35427
35432
  (max2, coder) => Math.max(max2, coder.encodedLength),
35428
35433
  0
35429
35434
  );
35430
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35435
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35431
35436
  this.name = name;
35432
35437
  this.coders = coders;
35433
35438
  this.#caseIndexCoder = caseIndexCoder;
@@ -35497,7 +35502,7 @@ This unreleased fuel-core build may include features and updates not yet support
35497
35502
  return { None: [] };
35498
35503
  }
35499
35504
  decode(data, offset) {
35500
- if (data.length < this.encodedLength) {
35505
+ if (data.length < this.encodedLength - 1) {
35501
35506
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
35502
35507
  }
35503
35508
  const [decoded, newOffset] = super.decode(data, offset);
@@ -36080,8 +36085,11 @@ This unreleased fuel-core build may include features and updates not yet support
36080
36085
  super("struct", "struct Bytes", WORD_SIZE);
36081
36086
  }
36082
36087
  encode(value) {
36083
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
36084
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36088
+ if (!Array.isArray(value)) {
36089
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36090
+ }
36091
+ const bytes3 = new Uint8Array(value);
36092
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36085
36093
  return new Uint8Array([...lengthBytes, ...bytes3]);
36086
36094
  }
36087
36095
  decode(data, offset) {
@@ -36114,7 +36122,7 @@ This unreleased fuel-core build may include features and updates not yet support
36114
36122
  (max2, coder) => Math.max(max2, coder.encodedLength),
36115
36123
  0
36116
36124
  );
36117
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36125
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36118
36126
  this.name = name;
36119
36127
  this.coders = coders;
36120
36128
  this.#caseIndexCoder = caseIndexCoder;
@@ -36212,28 +36220,6 @@ This unreleased fuel-core build may include features and updates not yet support
36212
36220
  return [toNumber2(bytes3), offset + this.length];
36213
36221
  }
36214
36222
  };
36215
- var OptionCoder2 = class extends EnumCoder2 {
36216
- encode(value) {
36217
- const result = super.encode(this.toSwayOption(value));
36218
- return result;
36219
- }
36220
- toSwayOption(input) {
36221
- if (input !== void 0) {
36222
- return { Some: input };
36223
- }
36224
- return { None: [] };
36225
- }
36226
- decode(data, offset) {
36227
- const [decoded, newOffset] = super.decode(data, offset);
36228
- return [this.toOption(decoded), newOffset];
36229
- }
36230
- toOption(output3) {
36231
- if (output3 && "Some" in output3) {
36232
- return output3.Some;
36233
- }
36234
- return void 0;
36235
- }
36236
- };
36237
36223
  var RawSliceCoder2 = class extends Coder {
36238
36224
  constructor() {
36239
36225
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -36287,30 +36273,6 @@ This unreleased fuel-core build may include features and updates not yet support
36287
36273
  }
36288
36274
  };
36289
36275
  __publicField4(StdStringCoder2, "memorySize", 1);
36290
- var StrSliceCoder = class extends Coder {
36291
- constructor() {
36292
- super("strSlice", "str", WORD_SIZE);
36293
- }
36294
- encode(value) {
36295
- const bytes3 = toUtf8Bytes(value);
36296
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36297
- return new Uint8Array([...lengthBytes, ...bytes3]);
36298
- }
36299
- decode(data, offset) {
36300
- if (data.length < this.encodedLength) {
36301
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
36302
- }
36303
- const offsetAndLength = offset + WORD_SIZE;
36304
- const lengthBytes = data.slice(offset, offsetAndLength);
36305
- const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
36306
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
36307
- if (bytes3.length !== length) {
36308
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
36309
- }
36310
- return [toUtf8String(bytes3), offsetAndLength + length];
36311
- }
36312
- };
36313
- __publicField4(StrSliceCoder, "memorySize", 1);
36314
36276
  var StringCoder2 = class extends Coder {
36315
36277
  constructor(length) {
36316
36278
  super("string", `str[${length}]`, length);
@@ -36349,7 +36311,7 @@ This unreleased fuel-core build may include features and updates not yet support
36349
36311
  Object.keys(this.coders).map((fieldName) => {
36350
36312
  const fieldCoder = this.coders[fieldName];
36351
36313
  const fieldValue = value[fieldName];
36352
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
36314
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
36353
36315
  throw new FuelError(
36354
36316
  ErrorCode.ENCODE_ERROR,
36355
36317
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -36457,8 +36419,6 @@ This unreleased fuel-core build may include features and updates not yet support
36457
36419
  return new ByteCoder2();
36458
36420
  case STD_STRING_CODER_TYPE:
36459
36421
  return new StdStringCoder2();
36460
- case STR_SLICE_CODER_TYPE:
36461
- return new StrSliceCoder();
36462
36422
  default:
36463
36423
  break;
36464
36424
  }
@@ -36503,7 +36463,7 @@ This unreleased fuel-core build may include features and updates not yet support
36503
36463
  const coders = getCoders(components, { getCoder: getCoder2 });
36504
36464
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
36505
36465
  if (isOptionEnum) {
36506
- return new OptionCoder2(enumMatch.name, coders);
36466
+ return new OptionCoder(enumMatch.name, coders);
36507
36467
  }
36508
36468
  return new EnumCoder2(enumMatch.name, coders);
36509
36469
  }
@@ -36514,6 +36474,12 @@ This unreleased fuel-core build may include features and updates not yet support
36514
36474
  );
36515
36475
  return new TupleCoder2(coders);
36516
36476
  }
36477
+ if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
36478
+ throw new FuelError(
36479
+ ErrorCode.INVALID_DATA,
36480
+ "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
36481
+ );
36482
+ }
36517
36483
  throw new FuelError(
36518
36484
  ErrorCode.CODER_NOT_FOUND,
36519
36485
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -36549,8 +36515,6 @@ This unreleased fuel-core build may include features and updates not yet support
36549
36515
  var FunctionFragment = class {
36550
36516
  signature;
36551
36517
  selector;
36552
- selectorBytes;
36553
- encoding;
36554
36518
  name;
36555
36519
  jsonFn;
36556
36520
  attributes;
@@ -36563,8 +36527,6 @@ This unreleased fuel-core build may include features and updates not yet support
36563
36527
  this.name = name;
36564
36528
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
36565
36529
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
36566
- this.selectorBytes = new StdStringCoder2().encode(name);
36567
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
36568
36530
  this.isInputDataPointer = this.#isInputDataPointer();
36569
36531
  this.outputMetadata = {
36570
36532
  isHeapType: this.#isOutputDataHeap(),
@@ -36618,14 +36580,11 @@ This unreleased fuel-core build may include features and updates not yet support
36618
36580
  }
36619
36581
  const coders = nonEmptyInputs.map(
36620
36582
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
36621
- isRightPadded: nonEmptyInputs.length > 1,
36622
- encoding: this.encoding
36583
+ isRightPadded: nonEmptyInputs.length > 1
36623
36584
  })
36624
36585
  );
36625
- if (this.encoding === ENCODING_V1) {
36626
- return new TupleCoder2(coders).encode(shallowCopyValues);
36627
- }
36628
- const results = new TupleCoder(coders).encode(shallowCopyValues);
36586
+ const coder = new TupleCoder(coders);
36587
+ const results = coder.encode(shallowCopyValues);
36629
36588
  return unpackDynamicData(results, offset, results.byteLength);
36630
36589
  }
36631
36590
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -36672,7 +36631,7 @@ This unreleased fuel-core build may include features and updates not yet support
36672
36631
  }
36673
36632
  const result = nonEmptyInputs.reduce(
36674
36633
  (obj, input) => {
36675
- const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
36634
+ const coder = AbiCoder.getCoder(this.jsonAbi, input);
36676
36635
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
36677
36636
  return {
36678
36637
  decoded: [...obj.decoded, decodedValue],
@@ -36692,9 +36651,7 @@ This unreleased fuel-core build may include features and updates not yet support
36692
36651
  return [void 0, 0];
36693
36652
  }
36694
36653
  const bytes3 = arrayify(data);
36695
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
36696
- encoding: this.encoding
36697
- });
36654
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
36698
36655
  return coder.decode(bytes3, 0);
36699
36656
  }
36700
36657
  };
@@ -36756,8 +36713,7 @@ This unreleased fuel-core build may include features and updates not yet support
36756
36713
  }
36757
36714
  );
36758
36715
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
36759
- isRightPadded: true,
36760
- encoding: this.jsonAbi.encoding
36716
+ isRightPadded: true
36761
36717
  });
36762
36718
  }
36763
36719
  getTypeById(typeId) {
@@ -42459,7 +42415,60 @@ ${MessageCoinFragmentFragmentDoc}`;
42459
42415
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
42460
42416
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
42461
42417
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
42418
+ var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
42462
42419
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
42420
+ var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
42421
+ var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
42422
+ var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
42423
+ var PANIC_REASONS = [
42424
+ "UnknownPanicReason",
42425
+ "Revert",
42426
+ "OutOfGas",
42427
+ "TransactionValidity",
42428
+ "MemoryOverflow",
42429
+ "ArithmeticOverflow",
42430
+ "ContractNotFound",
42431
+ "MemoryOwnership",
42432
+ "NotEnoughBalance",
42433
+ "ExpectedInternalContext",
42434
+ "AssetIdNotFound",
42435
+ "InputNotFound",
42436
+ "OutputNotFound",
42437
+ "WitnessNotFound",
42438
+ "TransactionMaturity",
42439
+ "InvalidMetadataIdentifier",
42440
+ "MalformedCallStructure",
42441
+ "ReservedRegisterNotWritable",
42442
+ "InvalidFlags",
42443
+ "InvalidImmediateValue",
42444
+ "ExpectedCoinInput",
42445
+ "EcalError",
42446
+ "MemoryWriteOverlap",
42447
+ "ContractNotInInputs",
42448
+ "InternalBalanceOverflow",
42449
+ "ContractMaxSize",
42450
+ "ExpectedUnallocatedStack",
42451
+ "MaxStaticContractsReached",
42452
+ "TransferAmountCannotBeZero",
42453
+ "ExpectedOutputVariable",
42454
+ "ExpectedParentInternalContext",
42455
+ "PredicateReturnedNonOne",
42456
+ "ContractIdAlreadyDeployed",
42457
+ "ContractMismatch",
42458
+ "MessageDataTooLong",
42459
+ "ArithmeticError",
42460
+ "ContractInstructionNotAllowed",
42461
+ "TransferZeroCoins",
42462
+ "InvalidInstruction",
42463
+ "MemoryNotExecutable",
42464
+ "PolicyIsNotSet",
42465
+ "PolicyNotFound",
42466
+ "TooManyReceipts",
42467
+ "BalanceOverflow",
42468
+ "InvalidBlockHeight",
42469
+ "TooManySlots"
42470
+ ];
42471
+ var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
42463
42472
 
42464
42473
  // src/providers/utils/receipts.ts
42465
42474
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -42772,6 +42781,74 @@ ${MessageCoinFragmentFragmentDoc}`;
42772
42781
  });
42773
42782
  }
42774
42783
 
42784
+ // src/providers/utils/extract-tx-error.ts
42785
+ var assemblePanicError = (status) => {
42786
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
42787
+ const reason = status.reason;
42788
+ if (PANIC_REASONS.includes(status.reason)) {
42789
+ errorMessage = `${errorMessage}
42790
+
42791
+ You can read more about this error at:
42792
+
42793
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
42794
+ }
42795
+ return { errorMessage, reason };
42796
+ };
42797
+ var stringify2 = (obj) => JSON.stringify(obj, null, 2);
42798
+ var assembleRevertError = (receipts, logs) => {
42799
+ let errorMessage = "The transaction reverted with an unknown reason.";
42800
+ const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
42801
+ let reason = "";
42802
+ if (revertReceipt) {
42803
+ const reasonHex = bn(revertReceipt.val).toHex();
42804
+ switch (reasonHex) {
42805
+ case FAILED_REQUIRE_SIGNAL: {
42806
+ reason = "require";
42807
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
42808
+ break;
42809
+ }
42810
+ case FAILED_ASSERT_EQ_SIGNAL: {
42811
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
42812
+ reason = "assert_eq";
42813
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
42814
+ break;
42815
+ }
42816
+ case FAILED_ASSERT_NE_SIGNAL: {
42817
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
42818
+ reason = "assert_ne";
42819
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
42820
+ break;
42821
+ }
42822
+ case FAILED_ASSERT_SIGNAL:
42823
+ reason = "assert";
42824
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
42825
+ break;
42826
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
42827
+ reason = "MissingOutputChange";
42828
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
42829
+ break;
42830
+ default:
42831
+ reason = "unknown";
42832
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
42833
+ }
42834
+ }
42835
+ return { errorMessage, reason };
42836
+ };
42837
+ var extractTxError = (params) => {
42838
+ const { receipts, status, logs } = params;
42839
+ const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
42840
+ const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
42841
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
42842
+ const metadata = {
42843
+ logs,
42844
+ receipts,
42845
+ panic: isPanic,
42846
+ revert: isRevert,
42847
+ reason
42848
+ };
42849
+ return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
42850
+ };
42851
+
42775
42852
  // src/providers/transaction-request/errors.ts
42776
42853
  var NoWitnessAtIndexError = class extends Error {
42777
42854
  constructor(index) {
@@ -44529,14 +44606,26 @@ ${MessageCoinFragmentFragmentDoc}`;
44529
44606
  gqlTransaction: this.gqlTransaction,
44530
44607
  ...transactionSummary
44531
44608
  };
44609
+ let logs = [];
44532
44610
  if (this.abis) {
44533
- const logs = getDecodedLogs(
44611
+ logs = getDecodedLogs(
44534
44612
  transactionSummary.receipts,
44535
44613
  this.abis.main,
44536
44614
  this.abis.otherContractsAbis
44537
44615
  );
44538
44616
  transactionResult.logs = logs;
44539
44617
  }
44618
+ if (transactionResult.isStatusFailure) {
44619
+ const {
44620
+ receipts,
44621
+ gqlTransaction: { status }
44622
+ } = transactionResult;
44623
+ throw extractTxError({
44624
+ receipts,
44625
+ status,
44626
+ logs
44627
+ });
44628
+ }
44540
44629
  return transactionResult;
44541
44630
  }
44542
44631
  /**
@@ -44545,14 +44634,7 @@ ${MessageCoinFragmentFragmentDoc}`;
44545
44634
  * @param contractsAbiMap - The contracts ABI map.
44546
44635
  */
44547
44636
  async wait(contractsAbiMap) {
44548
- const result = await this.waitForResult(contractsAbiMap);
44549
- if (result.isStatusFailure) {
44550
- throw new FuelError(
44551
- ErrorCode.TRANSACTION_FAILED,
44552
- `Transaction failed: ${result.gqlTransaction.status.reason}`
44553
- );
44554
- }
44555
- return result;
44637
+ return this.waitForResult(contractsAbiMap);
44556
44638
  }
44557
44639
  };
44558
44640