@fuel-ts/account 0.0.0-rc-1832-20240402201930 → 0.0.0-rc-1895-20240403004459
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.global.js +164 -82
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +551 -468
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +328 -240
- package/dist/index.mjs.map +1 -1
- package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
- package/dist/providers/utils/extract-tx-error.d.ts +36 -0
- package/dist/providers/utils/extract-tx-error.d.ts.map +1 -0
- package/dist/providers/utils/index.d.ts +1 -0
- package/dist/providers/utils/index.d.ts.map +1 -1
- package/dist/test-utils.global.js +164 -82
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +511 -434
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +298 -213
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
@@ -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,
|
1
|
+
{"version":3,"file":"transaction-response.d.ts","sourceRoot":"","sources":["../../../src/providers/transaction-response/transaction-response.ts"],"names":[],"mapp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,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;IAsC/C;;;;OAIG;IACG,IAAI,CAAC,gBAAgB,GAAG,IAAI,EAChC,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;CAGhD"}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
import { FuelError } from '@fuel-ts/errors';
|
2
|
+
import type { 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"}
|
@@ -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"}
|
@@ -32050,6 +32050,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32050
32050
|
})(ErrorCode || {});
|
32051
32051
|
var _FuelError = class extends Error {
|
32052
32052
|
VERSIONS = versions;
|
32053
|
+
metadata;
|
32053
32054
|
static parse(e) {
|
32054
32055
|
const error = e;
|
32055
32056
|
if (error.code === void 0) {
|
@@ -32069,14 +32070,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32069
32070
|
return new _FuelError(error.code, error.message);
|
32070
32071
|
}
|
32071
32072
|
code;
|
32072
|
-
constructor(code, message) {
|
32073
|
+
constructor(code, message, metadata = {}) {
|
32073
32074
|
super(message);
|
32074
32075
|
this.code = code;
|
32075
32076
|
this.name = "FuelError";
|
32077
|
+
this.metadata = metadata;
|
32076
32078
|
}
|
32077
32079
|
toObject() {
|
32078
|
-
const { code, name, message, VERSIONS } = this;
|
32079
|
-
return { code, name, message, VERSIONS };
|
32080
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
32081
|
+
return { code, name, message, metadata, VERSIONS };
|
32080
32082
|
}
|
32081
32083
|
};
|
32082
32084
|
var FuelError = _FuelError;
|
@@ -35383,6 +35385,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35383
35385
|
__privateAdd2(this, _getPaddedData);
|
35384
35386
|
}
|
35385
35387
|
encode(value) {
|
35388
|
+
if (!Array.isArray(value)) {
|
35389
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
35390
|
+
}
|
35386
35391
|
const parts = [];
|
35387
35392
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
35388
35393
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -35409,7 +35414,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35409
35414
|
};
|
35410
35415
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
35411
35416
|
getPaddedData_fn = function(value) {
|
35412
|
-
const data =
|
35417
|
+
const data = [Uint8Array.from(value)];
|
35413
35418
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
35414
35419
|
if (paddingLength) {
|
35415
35420
|
data.push(new Uint8Array(paddingLength));
|
@@ -35502,7 +35507,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35502
35507
|
return { None: [] };
|
35503
35508
|
}
|
35504
35509
|
decode(data, offset) {
|
35505
|
-
if (data.length < this.encodedLength) {
|
35510
|
+
if (data.length < this.encodedLength - 1) {
|
35506
35511
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
35507
35512
|
}
|
35508
35513
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -36085,8 +36090,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36085
36090
|
super("struct", "struct Bytes", WORD_SIZE);
|
36086
36091
|
}
|
36087
36092
|
encode(value) {
|
36088
|
-
|
36089
|
-
|
36093
|
+
if (!Array.isArray(value)) {
|
36094
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
36095
|
+
}
|
36096
|
+
const bytes3 = new Uint8Array(value);
|
36097
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36090
36098
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36091
36099
|
}
|
36092
36100
|
decode(data, offset) {
|
@@ -36217,28 +36225,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36217
36225
|
return [toNumber2(bytes3), offset + this.length];
|
36218
36226
|
}
|
36219
36227
|
};
|
36220
|
-
var OptionCoder2 = class extends EnumCoder2 {
|
36221
|
-
encode(value) {
|
36222
|
-
const result = super.encode(this.toSwayOption(value));
|
36223
|
-
return result;
|
36224
|
-
}
|
36225
|
-
toSwayOption(input) {
|
36226
|
-
if (input !== void 0) {
|
36227
|
-
return { Some: input };
|
36228
|
-
}
|
36229
|
-
return { None: [] };
|
36230
|
-
}
|
36231
|
-
decode(data, offset) {
|
36232
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
36233
|
-
return [this.toOption(decoded), newOffset];
|
36234
|
-
}
|
36235
|
-
toOption(output3) {
|
36236
|
-
if (output3 && "Some" in output3) {
|
36237
|
-
return output3.Some;
|
36238
|
-
}
|
36239
|
-
return void 0;
|
36240
|
-
}
|
36241
|
-
};
|
36242
36228
|
var RawSliceCoder2 = class extends Coder {
|
36243
36229
|
constructor() {
|
36244
36230
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -36292,30 +36278,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36292
36278
|
}
|
36293
36279
|
};
|
36294
36280
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
36295
|
-
var StrSliceCoder = class extends Coder {
|
36296
|
-
constructor() {
|
36297
|
-
super("strSlice", "str", WORD_SIZE);
|
36298
|
-
}
|
36299
|
-
encode(value) {
|
36300
|
-
const bytes3 = toUtf8Bytes(value);
|
36301
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36302
|
-
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36303
|
-
}
|
36304
|
-
decode(data, offset) {
|
36305
|
-
if (data.length < this.encodedLength) {
|
36306
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
36307
|
-
}
|
36308
|
-
const offsetAndLength = offset + WORD_SIZE;
|
36309
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
36310
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
36311
|
-
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
36312
|
-
if (bytes3.length !== length) {
|
36313
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
36314
|
-
}
|
36315
|
-
return [toUtf8String(bytes3), offsetAndLength + length];
|
36316
|
-
}
|
36317
|
-
};
|
36318
|
-
__publicField4(StrSliceCoder, "memorySize", 1);
|
36319
36281
|
var StringCoder2 = class extends Coder {
|
36320
36282
|
constructor(length) {
|
36321
36283
|
super("string", `str[${length}]`, length);
|
@@ -36354,7 +36316,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36354
36316
|
Object.keys(this.coders).map((fieldName) => {
|
36355
36317
|
const fieldCoder = this.coders[fieldName];
|
36356
36318
|
const fieldValue = value[fieldName];
|
36357
|
-
if (!(fieldCoder instanceof
|
36319
|
+
if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
|
36358
36320
|
throw new FuelError(
|
36359
36321
|
ErrorCode.ENCODE_ERROR,
|
36360
36322
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -36462,8 +36424,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36462
36424
|
return new ByteCoder2();
|
36463
36425
|
case STD_STRING_CODER_TYPE:
|
36464
36426
|
return new StdStringCoder2();
|
36465
|
-
case STR_SLICE_CODER_TYPE:
|
36466
|
-
return new StrSliceCoder();
|
36467
36427
|
default:
|
36468
36428
|
break;
|
36469
36429
|
}
|
@@ -36508,7 +36468,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36508
36468
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
36509
36469
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
36510
36470
|
if (isOptionEnum) {
|
36511
|
-
return new
|
36471
|
+
return new OptionCoder(enumMatch.name, coders);
|
36512
36472
|
}
|
36513
36473
|
return new EnumCoder2(enumMatch.name, coders);
|
36514
36474
|
}
|
@@ -36519,6 +36479,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36519
36479
|
);
|
36520
36480
|
return new TupleCoder2(coders);
|
36521
36481
|
}
|
36482
|
+
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
36483
|
+
throw new FuelError(
|
36484
|
+
ErrorCode.INVALID_DATA,
|
36485
|
+
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
36486
|
+
);
|
36487
|
+
}
|
36522
36488
|
throw new FuelError(
|
36523
36489
|
ErrorCode.CODER_NOT_FOUND,
|
36524
36490
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -36554,8 +36520,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36554
36520
|
var FunctionFragment = class {
|
36555
36521
|
signature;
|
36556
36522
|
selector;
|
36557
|
-
selectorBytes;
|
36558
|
-
encoding;
|
36559
36523
|
name;
|
36560
36524
|
jsonFn;
|
36561
36525
|
attributes;
|
@@ -36568,8 +36532,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36568
36532
|
this.name = name;
|
36569
36533
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
36570
36534
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
36571
|
-
this.selectorBytes = new StdStringCoder2().encode(name);
|
36572
|
-
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
36573
36535
|
this.isInputDataPointer = this.#isInputDataPointer();
|
36574
36536
|
this.outputMetadata = {
|
36575
36537
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -36623,14 +36585,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36623
36585
|
}
|
36624
36586
|
const coders = nonEmptyInputs.map(
|
36625
36587
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
36626
|
-
isRightPadded: nonEmptyInputs.length > 1
|
36627
|
-
encoding: this.encoding
|
36588
|
+
isRightPadded: nonEmptyInputs.length > 1
|
36628
36589
|
})
|
36629
36590
|
);
|
36630
|
-
|
36631
|
-
|
36632
|
-
}
|
36633
|
-
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
36591
|
+
const coder = new TupleCoder(coders);
|
36592
|
+
const results = coder.encode(shallowCopyValues);
|
36634
36593
|
return unpackDynamicData(results, offset, results.byteLength);
|
36635
36594
|
}
|
36636
36595
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
@@ -36677,7 +36636,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36677
36636
|
}
|
36678
36637
|
const result = nonEmptyInputs.reduce(
|
36679
36638
|
(obj, input) => {
|
36680
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input
|
36639
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
36681
36640
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
36682
36641
|
return {
|
36683
36642
|
decoded: [...obj.decoded, decodedValue],
|
@@ -36697,9 +36656,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36697
36656
|
return [void 0, 0];
|
36698
36657
|
}
|
36699
36658
|
const bytes3 = arrayify(data);
|
36700
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
36701
|
-
encoding: this.encoding
|
36702
|
-
});
|
36659
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
|
36703
36660
|
return coder.decode(bytes3, 0);
|
36704
36661
|
}
|
36705
36662
|
};
|
@@ -36767,8 +36724,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36767
36724
|
}
|
36768
36725
|
);
|
36769
36726
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
36770
|
-
isRightPadded: true
|
36771
|
-
encoding: this.jsonAbi.encoding
|
36727
|
+
isRightPadded: true
|
36772
36728
|
});
|
36773
36729
|
}
|
36774
36730
|
getTypeById(typeId) {
|
@@ -42470,7 +42426,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42470
42426
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42471
42427
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42472
42428
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42429
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42473
42430
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42431
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42432
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42433
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42434
|
+
var PANIC_REASONS = [
|
42435
|
+
"UnknownPanicReason",
|
42436
|
+
"Revert",
|
42437
|
+
"OutOfGas",
|
42438
|
+
"TransactionValidity",
|
42439
|
+
"MemoryOverflow",
|
42440
|
+
"ArithmeticOverflow",
|
42441
|
+
"ContractNotFound",
|
42442
|
+
"MemoryOwnership",
|
42443
|
+
"NotEnoughBalance",
|
42444
|
+
"ExpectedInternalContext",
|
42445
|
+
"AssetIdNotFound",
|
42446
|
+
"InputNotFound",
|
42447
|
+
"OutputNotFound",
|
42448
|
+
"WitnessNotFound",
|
42449
|
+
"TransactionMaturity",
|
42450
|
+
"InvalidMetadataIdentifier",
|
42451
|
+
"MalformedCallStructure",
|
42452
|
+
"ReservedRegisterNotWritable",
|
42453
|
+
"InvalidFlags",
|
42454
|
+
"InvalidImmediateValue",
|
42455
|
+
"ExpectedCoinInput",
|
42456
|
+
"EcalError",
|
42457
|
+
"MemoryWriteOverlap",
|
42458
|
+
"ContractNotInInputs",
|
42459
|
+
"InternalBalanceOverflow",
|
42460
|
+
"ContractMaxSize",
|
42461
|
+
"ExpectedUnallocatedStack",
|
42462
|
+
"MaxStaticContractsReached",
|
42463
|
+
"TransferAmountCannotBeZero",
|
42464
|
+
"ExpectedOutputVariable",
|
42465
|
+
"ExpectedParentInternalContext",
|
42466
|
+
"PredicateReturnedNonOne",
|
42467
|
+
"ContractIdAlreadyDeployed",
|
42468
|
+
"ContractMismatch",
|
42469
|
+
"MessageDataTooLong",
|
42470
|
+
"ArithmeticError",
|
42471
|
+
"ContractInstructionNotAllowed",
|
42472
|
+
"TransferZeroCoins",
|
42473
|
+
"InvalidInstruction",
|
42474
|
+
"MemoryNotExecutable",
|
42475
|
+
"PolicyIsNotSet",
|
42476
|
+
"PolicyNotFound",
|
42477
|
+
"TooManyReceipts",
|
42478
|
+
"BalanceOverflow",
|
42479
|
+
"InvalidBlockHeight",
|
42480
|
+
"TooManySlots"
|
42481
|
+
];
|
42482
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42474
42483
|
|
42475
42484
|
// src/providers/utils/receipts.ts
|
42476
42485
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42783,6 +42792,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42783
42792
|
});
|
42784
42793
|
}
|
42785
42794
|
|
42795
|
+
// src/providers/utils/extract-tx-error.ts
|
42796
|
+
var assemblePanicError = (status) => {
|
42797
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42798
|
+
const reason = status.reason;
|
42799
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42800
|
+
errorMessage = `${errorMessage}
|
42801
|
+
|
42802
|
+
You can read more about this error at:
|
42803
|
+
|
42804
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42805
|
+
}
|
42806
|
+
return { errorMessage, reason };
|
42807
|
+
};
|
42808
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42809
|
+
var assembleRevertError = (receipts, logs) => {
|
42810
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42811
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42812
|
+
let reason = "";
|
42813
|
+
if (revertReceipt) {
|
42814
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42815
|
+
switch (reasonHex) {
|
42816
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42817
|
+
reason = "require";
|
42818
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42819
|
+
break;
|
42820
|
+
}
|
42821
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42822
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42823
|
+
reason = "assert_eq";
|
42824
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42825
|
+
break;
|
42826
|
+
}
|
42827
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42828
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42829
|
+
reason = "assert_ne";
|
42830
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42831
|
+
break;
|
42832
|
+
}
|
42833
|
+
case FAILED_ASSERT_SIGNAL:
|
42834
|
+
reason = "assert";
|
42835
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42836
|
+
break;
|
42837
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42838
|
+
reason = "MissingOutputChange";
|
42839
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42840
|
+
break;
|
42841
|
+
default:
|
42842
|
+
reason = "unknown";
|
42843
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42844
|
+
}
|
42845
|
+
}
|
42846
|
+
return { errorMessage, reason };
|
42847
|
+
};
|
42848
|
+
var extractTxError = (params) => {
|
42849
|
+
const { receipts, status, logs } = params;
|
42850
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42851
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42852
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42853
|
+
const metadata = {
|
42854
|
+
logs,
|
42855
|
+
receipts,
|
42856
|
+
panic: isPanic,
|
42857
|
+
revert: isRevert,
|
42858
|
+
reason
|
42859
|
+
};
|
42860
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42861
|
+
};
|
42862
|
+
|
42786
42863
|
// src/providers/transaction-request/errors.ts
|
42787
42864
|
var NoWitnessAtIndexError = class extends Error {
|
42788
42865
|
constructor(index) {
|
@@ -44540,14 +44617,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44540
44617
|
gqlTransaction: this.gqlTransaction,
|
44541
44618
|
...transactionSummary
|
44542
44619
|
};
|
44620
|
+
let logs = [];
|
44543
44621
|
if (this.abis) {
|
44544
|
-
|
44622
|
+
logs = getDecodedLogs(
|
44545
44623
|
transactionSummary.receipts,
|
44546
44624
|
this.abis.main,
|
44547
44625
|
this.abis.otherContractsAbis
|
44548
44626
|
);
|
44549
44627
|
transactionResult.logs = logs;
|
44550
44628
|
}
|
44629
|
+
if (transactionResult.isStatusFailure) {
|
44630
|
+
const {
|
44631
|
+
receipts,
|
44632
|
+
gqlTransaction: { status }
|
44633
|
+
} = transactionResult;
|
44634
|
+
throw extractTxError({
|
44635
|
+
receipts,
|
44636
|
+
status,
|
44637
|
+
logs
|
44638
|
+
});
|
44639
|
+
}
|
44551
44640
|
return transactionResult;
|
44552
44641
|
}
|
44553
44642
|
/**
|
@@ -44556,14 +44645,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44556
44645
|
* @param contractsAbiMap - The contracts ABI map.
|
44557
44646
|
*/
|
44558
44647
|
async wait(contractsAbiMap) {
|
44559
|
-
|
44560
|
-
if (result.isStatusFailure) {
|
44561
|
-
throw new FuelError(
|
44562
|
-
ErrorCode.TRANSACTION_FAILED,
|
44563
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44564
|
-
);
|
44565
|
-
}
|
44566
|
-
return result;
|
44648
|
+
return this.waitForResult(contractsAbiMap);
|
44567
44649
|
}
|
44568
44650
|
};
|
44569
44651
|
|