@fuel-ts/account 0.0.0-rc-1976-20240405090158 → 0.0.0-rc-1976-20240405092005

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;
@@ -35375,9 +35377,6 @@ This unreleased fuel-core build may include features and updates not yet support
35375
35377
  __privateAdd2(this, _getPaddedData);
35376
35378
  }
35377
35379
  encode(value) {
35378
- if (!Array.isArray(value)) {
35379
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
35380
- }
35381
35380
  const parts = [];
35382
35381
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
35383
35382
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -35404,7 +35403,7 @@ This unreleased fuel-core build may include features and updates not yet support
35404
35403
  };
35405
35404
  _getPaddedData = /* @__PURE__ */ new WeakSet();
35406
35405
  getPaddedData_fn = function(value) {
35407
- const data = [Uint8Array.from(value)];
35406
+ const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
35408
35407
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
35409
35408
  if (paddingLength) {
35410
35409
  data.push(new Uint8Array(paddingLength));
@@ -35427,7 +35426,7 @@ This unreleased fuel-core build may include features and updates not yet support
35427
35426
  (max2, coder) => Math.max(max2, coder.encodedLength),
35428
35427
  0
35429
35428
  );
35430
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35429
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
35431
35430
  this.name = name;
35432
35431
  this.coders = coders;
35433
35432
  this.#caseIndexCoder = caseIndexCoder;
@@ -35497,7 +35496,7 @@ This unreleased fuel-core build may include features and updates not yet support
35497
35496
  return { None: [] };
35498
35497
  }
35499
35498
  decode(data, offset) {
35500
- if (data.length < this.encodedLength - 1) {
35499
+ if (data.length < this.encodedLength) {
35501
35500
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
35502
35501
  }
35503
35502
  const [decoded, newOffset] = super.decode(data, offset);
@@ -36080,11 +36079,8 @@ This unreleased fuel-core build may include features and updates not yet support
36080
36079
  super("struct", "struct Bytes", WORD_SIZE);
36081
36080
  }
36082
36081
  encode(value) {
36083
- if (!Array.isArray(value)) {
36084
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36085
- }
36086
- const bytes3 = new Uint8Array(value);
36087
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36082
+ const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
36083
+ const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36088
36084
  return new Uint8Array([...lengthBytes, ...bytes3]);
36089
36085
  }
36090
36086
  decode(data, offset) {
@@ -36117,7 +36113,7 @@ This unreleased fuel-core build may include features and updates not yet support
36117
36113
  (max2, coder) => Math.max(max2, coder.encodedLength),
36118
36114
  0
36119
36115
  );
36120
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36116
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
36121
36117
  this.name = name;
36122
36118
  this.coders = coders;
36123
36119
  this.#caseIndexCoder = caseIndexCoder;
@@ -36215,6 +36211,28 @@ This unreleased fuel-core build may include features and updates not yet support
36215
36211
  return [toNumber2(bytes3), offset + this.length];
36216
36212
  }
36217
36213
  };
36214
+ var OptionCoder2 = class extends EnumCoder2 {
36215
+ encode(value) {
36216
+ const result = super.encode(this.toSwayOption(value));
36217
+ return result;
36218
+ }
36219
+ toSwayOption(input) {
36220
+ if (input !== void 0) {
36221
+ return { Some: input };
36222
+ }
36223
+ return { None: [] };
36224
+ }
36225
+ decode(data, offset) {
36226
+ const [decoded, newOffset] = super.decode(data, offset);
36227
+ return [this.toOption(decoded), newOffset];
36228
+ }
36229
+ toOption(output3) {
36230
+ if (output3 && "Some" in output3) {
36231
+ return output3.Some;
36232
+ }
36233
+ return void 0;
36234
+ }
36235
+ };
36218
36236
  var RawSliceCoder2 = class extends Coder {
36219
36237
  constructor() {
36220
36238
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -36268,6 +36286,30 @@ This unreleased fuel-core build may include features and updates not yet support
36268
36286
  }
36269
36287
  };
36270
36288
  __publicField4(StdStringCoder2, "memorySize", 1);
36289
+ var StrSliceCoder = class extends Coder {
36290
+ constructor() {
36291
+ super("strSlice", "str", WORD_SIZE);
36292
+ }
36293
+ encode(value) {
36294
+ const bytes3 = toUtf8Bytes(value);
36295
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36296
+ return new Uint8Array([...lengthBytes, ...bytes3]);
36297
+ }
36298
+ decode(data, offset) {
36299
+ if (data.length < this.encodedLength) {
36300
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
36301
+ }
36302
+ const offsetAndLength = offset + WORD_SIZE;
36303
+ const lengthBytes = data.slice(offset, offsetAndLength);
36304
+ const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
36305
+ const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
36306
+ if (bytes3.length !== length) {
36307
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
36308
+ }
36309
+ return [toUtf8String(bytes3), offsetAndLength + length];
36310
+ }
36311
+ };
36312
+ __publicField4(StrSliceCoder, "memorySize", 1);
36271
36313
  var StringCoder2 = class extends Coder {
36272
36314
  constructor(length) {
36273
36315
  super("string", `str[${length}]`, length);
@@ -36306,7 +36348,7 @@ This unreleased fuel-core build may include features and updates not yet support
36306
36348
  Object.keys(this.coders).map((fieldName) => {
36307
36349
  const fieldCoder = this.coders[fieldName];
36308
36350
  const fieldValue = value[fieldName];
36309
- if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
36351
+ if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
36310
36352
  throw new FuelError(
36311
36353
  ErrorCode.ENCODE_ERROR,
36312
36354
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -36414,6 +36456,8 @@ This unreleased fuel-core build may include features and updates not yet support
36414
36456
  return new ByteCoder2();
36415
36457
  case STD_STRING_CODER_TYPE:
36416
36458
  return new StdStringCoder2();
36459
+ case STR_SLICE_CODER_TYPE:
36460
+ return new StrSliceCoder();
36417
36461
  default:
36418
36462
  break;
36419
36463
  }
@@ -36458,7 +36502,7 @@ This unreleased fuel-core build may include features and updates not yet support
36458
36502
  const coders = getCoders(components, { getCoder: getCoder2 });
36459
36503
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
36460
36504
  if (isOptionEnum) {
36461
- return new OptionCoder(enumMatch.name, coders);
36505
+ return new OptionCoder2(enumMatch.name, coders);
36462
36506
  }
36463
36507
  return new EnumCoder2(enumMatch.name, coders);
36464
36508
  }
@@ -36469,12 +36513,6 @@ This unreleased fuel-core build may include features and updates not yet support
36469
36513
  );
36470
36514
  return new TupleCoder2(coders);
36471
36515
  }
36472
- if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
36473
- throw new FuelError(
36474
- ErrorCode.INVALID_DATA,
36475
- "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
36476
- );
36477
- }
36478
36516
  throw new FuelError(
36479
36517
  ErrorCode.CODER_NOT_FOUND,
36480
36518
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -36510,6 +36548,8 @@ This unreleased fuel-core build may include features and updates not yet support
36510
36548
  var FunctionFragment = class {
36511
36549
  signature;
36512
36550
  selector;
36551
+ selectorBytes;
36552
+ encoding;
36513
36553
  name;
36514
36554
  jsonFn;
36515
36555
  attributes;
@@ -36522,6 +36562,8 @@ This unreleased fuel-core build may include features and updates not yet support
36522
36562
  this.name = name;
36523
36563
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
36524
36564
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
36565
+ this.selectorBytes = new StdStringCoder2().encode(name);
36566
+ this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
36525
36567
  this.isInputDataPointer = this.#isInputDataPointer();
36526
36568
  this.outputMetadata = {
36527
36569
  isHeapType: this.#isOutputDataHeap(),
@@ -36575,11 +36617,14 @@ This unreleased fuel-core build may include features and updates not yet support
36575
36617
  }
36576
36618
  const coders = nonEmptyInputs.map(
36577
36619
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
36578
- isRightPadded: nonEmptyInputs.length > 1
36620
+ isRightPadded: nonEmptyInputs.length > 1,
36621
+ encoding: this.encoding
36579
36622
  })
36580
36623
  );
36581
- const coder = new TupleCoder(coders);
36582
- const results = coder.encode(shallowCopyValues);
36624
+ if (this.encoding === ENCODING_V1) {
36625
+ return new TupleCoder2(coders).encode(shallowCopyValues);
36626
+ }
36627
+ const results = new TupleCoder(coders).encode(shallowCopyValues);
36583
36628
  return unpackDynamicData(results, offset, results.byteLength);
36584
36629
  }
36585
36630
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -36626,7 +36671,7 @@ This unreleased fuel-core build may include features and updates not yet support
36626
36671
  }
36627
36672
  const result = nonEmptyInputs.reduce(
36628
36673
  (obj, input) => {
36629
- const coder = AbiCoder.getCoder(this.jsonAbi, input);
36674
+ const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
36630
36675
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
36631
36676
  return {
36632
36677
  decoded: [...obj.decoded, decodedValue],
@@ -36646,7 +36691,9 @@ This unreleased fuel-core build may include features and updates not yet support
36646
36691
  return [void 0, 0];
36647
36692
  }
36648
36693
  const bytes3 = arrayify(data);
36649
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
36694
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
36695
+ encoding: this.encoding
36696
+ });
36650
36697
  return coder.decode(bytes3, 0);
36651
36698
  }
36652
36699
  };
@@ -36708,7 +36755,8 @@ This unreleased fuel-core build may include features and updates not yet support
36708
36755
  }
36709
36756
  );
36710
36757
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
36711
- isRightPadded: true
36758
+ isRightPadded: true,
36759
+ encoding: this.jsonAbi.encoding
36712
36760
  });
36713
36761
  }
36714
36762
  getTypeById(typeId) {
@@ -42413,7 +42461,60 @@ ${MessageCoinFragmentFragmentDoc}`;
42413
42461
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
42414
42462
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
42415
42463
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
42464
+ var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
42416
42465
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
42466
+ var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
42467
+ var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
42468
+ var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
42469
+ var PANIC_REASONS = [
42470
+ "UnknownPanicReason",
42471
+ "Revert",
42472
+ "OutOfGas",
42473
+ "TransactionValidity",
42474
+ "MemoryOverflow",
42475
+ "ArithmeticOverflow",
42476
+ "ContractNotFound",
42477
+ "MemoryOwnership",
42478
+ "NotEnoughBalance",
42479
+ "ExpectedInternalContext",
42480
+ "AssetIdNotFound",
42481
+ "InputNotFound",
42482
+ "OutputNotFound",
42483
+ "WitnessNotFound",
42484
+ "TransactionMaturity",
42485
+ "InvalidMetadataIdentifier",
42486
+ "MalformedCallStructure",
42487
+ "ReservedRegisterNotWritable",
42488
+ "InvalidFlags",
42489
+ "InvalidImmediateValue",
42490
+ "ExpectedCoinInput",
42491
+ "EcalError",
42492
+ "MemoryWriteOverlap",
42493
+ "ContractNotInInputs",
42494
+ "InternalBalanceOverflow",
42495
+ "ContractMaxSize",
42496
+ "ExpectedUnallocatedStack",
42497
+ "MaxStaticContractsReached",
42498
+ "TransferAmountCannotBeZero",
42499
+ "ExpectedOutputVariable",
42500
+ "ExpectedParentInternalContext",
42501
+ "PredicateReturnedNonOne",
42502
+ "ContractIdAlreadyDeployed",
42503
+ "ContractMismatch",
42504
+ "MessageDataTooLong",
42505
+ "ArithmeticError",
42506
+ "ContractInstructionNotAllowed",
42507
+ "TransferZeroCoins",
42508
+ "InvalidInstruction",
42509
+ "MemoryNotExecutable",
42510
+ "PolicyIsNotSet",
42511
+ "PolicyNotFound",
42512
+ "TooManyReceipts",
42513
+ "BalanceOverflow",
42514
+ "InvalidBlockHeight",
42515
+ "TooManySlots"
42516
+ ];
42517
+ var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
42417
42518
 
42418
42519
  // src/providers/utils/receipts.ts
42419
42520
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -42726,6 +42827,74 @@ ${MessageCoinFragmentFragmentDoc}`;
42726
42827
  });
42727
42828
  }
42728
42829
 
42830
+ // src/providers/utils/extract-tx-error.ts
42831
+ var assemblePanicError = (status) => {
42832
+ let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
42833
+ const reason = status.reason;
42834
+ if (PANIC_REASONS.includes(status.reason)) {
42835
+ errorMessage = `${errorMessage}
42836
+
42837
+ You can read more about this error at:
42838
+
42839
+ ${PANIC_DOC_URL}#variant.${status.reason}`;
42840
+ }
42841
+ return { errorMessage, reason };
42842
+ };
42843
+ var stringify2 = (obj) => JSON.stringify(obj, null, 2);
42844
+ var assembleRevertError = (receipts, logs) => {
42845
+ let errorMessage = "The transaction reverted with an unknown reason.";
42846
+ const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
42847
+ let reason = "";
42848
+ if (revertReceipt) {
42849
+ const reasonHex = bn(revertReceipt.val).toHex();
42850
+ switch (reasonHex) {
42851
+ case FAILED_REQUIRE_SIGNAL: {
42852
+ reason = "require";
42853
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
42854
+ break;
42855
+ }
42856
+ case FAILED_ASSERT_EQ_SIGNAL: {
42857
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
42858
+ reason = "assert_eq";
42859
+ errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
42860
+ break;
42861
+ }
42862
+ case FAILED_ASSERT_NE_SIGNAL: {
42863
+ const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
42864
+ reason = "assert_ne";
42865
+ errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
42866
+ break;
42867
+ }
42868
+ case FAILED_ASSERT_SIGNAL:
42869
+ reason = "assert";
42870
+ errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
42871
+ break;
42872
+ case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
42873
+ reason = "MissingOutputChange";
42874
+ errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
42875
+ break;
42876
+ default:
42877
+ reason = "unknown";
42878
+ errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
42879
+ }
42880
+ }
42881
+ return { errorMessage, reason };
42882
+ };
42883
+ var extractTxError = (params) => {
42884
+ const { receipts, status, logs } = params;
42885
+ const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
42886
+ const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
42887
+ const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
42888
+ const metadata = {
42889
+ logs,
42890
+ receipts,
42891
+ panic: isPanic,
42892
+ revert: isRevert,
42893
+ reason
42894
+ };
42895
+ return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
42896
+ };
42897
+
42729
42898
  // src/providers/transaction-request/errors.ts
42730
42899
  var NoWitnessAtIndexError = class extends Error {
42731
42900
  constructor(index) {
@@ -44485,14 +44654,26 @@ ${MessageCoinFragmentFragmentDoc}`;
44485
44654
  gqlTransaction: this.gqlTransaction,
44486
44655
  ...transactionSummary
44487
44656
  };
44657
+ let logs = [];
44488
44658
  if (this.abis) {
44489
- const logs = getDecodedLogs(
44659
+ logs = getDecodedLogs(
44490
44660
  transactionSummary.receipts,
44491
44661
  this.abis.main,
44492
44662
  this.abis.otherContractsAbis
44493
44663
  );
44494
44664
  transactionResult.logs = logs;
44495
44665
  }
44666
+ if (transactionResult.isStatusFailure) {
44667
+ const {
44668
+ receipts,
44669
+ gqlTransaction: { status }
44670
+ } = transactionResult;
44671
+ throw extractTxError({
44672
+ receipts,
44673
+ status,
44674
+ logs
44675
+ });
44676
+ }
44496
44677
  return transactionResult;
44497
44678
  }
44498
44679
  /**
@@ -44501,14 +44682,7 @@ ${MessageCoinFragmentFragmentDoc}`;
44501
44682
  * @param contractsAbiMap - The contracts ABI map.
44502
44683
  */
44503
44684
  async wait(contractsAbiMap) {
44504
- const result = await this.waitForResult(contractsAbiMap);
44505
- if (result.isStatusFailure) {
44506
- throw new FuelError(
44507
- ErrorCode.TRANSACTION_FAILED,
44508
- `Transaction failed: ${result.gqlTransaction.status.reason}`
44509
- );
44510
- }
44511
- return result;
44685
+ return this.waitForResult(contractsAbiMap);
44512
44686
  }
44513
44687
  };
44514
44688