@fuel-ts/account 0.79.0 → 0.81.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/configs.d.ts +1 -0
- package/dist/configs.d.ts.map +1 -1
- package/dist/configs.global.js +1 -0
- package/dist/configs.global.js.map +1 -1
- package/dist/configs.js +3 -0
- package/dist/configs.js.map +1 -1
- package/dist/configs.mjs +2 -0
- package/dist/configs.mjs.map +1 -1
- package/dist/index.global.js +382 -192
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +667 -554
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +416 -298
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts +0 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/fuel-graphql-subscriber.d.ts +2 -0
- package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
- package/dist/providers/provider.d.ts +13 -2
- package/dist/providers/provider.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.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 +384 -193
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +624 -516
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +388 -272
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +21 -26
package/dist/index.global.js
CHANGED
@@ -28954,7 +28954,7 @@ spurious results.`);
|
|
28954
28954
|
return {
|
28955
28955
|
FORC: "0.49.3",
|
28956
28956
|
FUEL_CORE: "0.22.1",
|
28957
|
-
FUELS: "0.
|
28957
|
+
FUELS: "0.81.0"
|
28958
28958
|
};
|
28959
28959
|
}
|
28960
28960
|
function parseVersion(version2) {
|
@@ -29013,9 +29013,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29013
29013
|
ErrorCode2["ABI_TYPES_AND_VALUES_MISMATCH"] = "abi-types-and-values-mismatch";
|
29014
29014
|
ErrorCode2["ABI_MAIN_METHOD_MISSING"] = "abi-main-method-missing";
|
29015
29015
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
29016
|
-
ErrorCode2["FRAGMENT_NOT_FOUND"] = "fragment-not-found";
|
29017
29016
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
29018
29017
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
29018
|
+
ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
|
29019
29019
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
29020
29020
|
ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
|
29021
29021
|
ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
|
@@ -29028,14 +29028,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29028
29028
|
ErrorCode2["INVALID_BECH32_ADDRESS"] = "invalid-bech32-address";
|
29029
29029
|
ErrorCode2["INVALID_EVM_ADDRESS"] = "invalid-evm-address";
|
29030
29030
|
ErrorCode2["INVALID_B256_ADDRESS"] = "invalid-b256-address";
|
29031
|
-
ErrorCode2["INVALID_URL"] = "invalid-url";
|
29032
29031
|
ErrorCode2["CHAIN_INFO_CACHE_EMPTY"] = "chain-info-cache-empty";
|
29033
29032
|
ErrorCode2["NODE_INFO_CACHE_EMPTY"] = "node-info-cache-empty";
|
29034
29033
|
ErrorCode2["MISSING_PROVIDER"] = "missing-provider";
|
29035
29034
|
ErrorCode2["INVALID_PROVIDER"] = "invalid-provider";
|
29036
29035
|
ErrorCode2["CONNECTION_REFUSED"] = "connection-refused";
|
29037
29036
|
ErrorCode2["INVALID_PUBLIC_KEY"] = "invalid-public-key";
|
29038
|
-
ErrorCode2["INSUFFICIENT_BALANCE"] = "insufficient-balance";
|
29039
29037
|
ErrorCode2["WALLET_MANAGER_ERROR"] = "wallet-manager-error";
|
29040
29038
|
ErrorCode2["HD_WALLET_ERROR"] = "hd-wallet-error";
|
29041
29039
|
ErrorCode2["MISSING_CONNECTOR"] = "missing-connector";
|
@@ -29052,7 +29050,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29052
29050
|
ErrorCode2["ELEMENT_NOT_FOUND"] = "element-not-found";
|
29053
29051
|
ErrorCode2["MISSING_REQUIRED_PARAMETER"] = "missing-required-parameter";
|
29054
29052
|
ErrorCode2["INVALID_REQUEST"] = "invalid-request";
|
29055
|
-
ErrorCode2["UNEXPECTED_HEX_VALUE"] = "unexpected-hex-value";
|
29056
29053
|
ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
|
29057
29054
|
ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
|
29058
29055
|
ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
|
@@ -29076,7 +29073,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29076
29073
|
ErrorCode2["INVALID_PASSWORD"] = "invalid-password";
|
29077
29074
|
ErrorCode2["ACCOUNT_REQUIRED"] = "account-required";
|
29078
29075
|
ErrorCode2["UNLOCKED_WALLET_REQUIRED"] = "unlocked-wallet-required";
|
29079
|
-
ErrorCode2["LATEST_BLOCK_UNAVAILABLE"] = "latest-block-unavailable";
|
29080
29076
|
ErrorCode2["ERROR_BUILDING_BLOCK_EXPLORER_URL"] = "error-building-block-explorer-url";
|
29081
29077
|
ErrorCode2["UNSUPPORTED_FUEL_CLIENT_VERSION"] = "unsupported-fuel-client-version";
|
29082
29078
|
ErrorCode2["VITEPRESS_PLUGIN_ERROR"] = "vitepress-plugin-error";
|
@@ -29088,6 +29084,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29088
29084
|
})(ErrorCode || {});
|
29089
29085
|
var _FuelError = class extends Error {
|
29090
29086
|
VERSIONS = versions;
|
29087
|
+
metadata;
|
29091
29088
|
static parse(e) {
|
29092
29089
|
const error = e;
|
29093
29090
|
if (error.code === void 0) {
|
@@ -29107,14 +29104,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29107
29104
|
return new _FuelError(error.code, error.message);
|
29108
29105
|
}
|
29109
29106
|
code;
|
29110
|
-
constructor(code, message) {
|
29107
|
+
constructor(code, message, metadata = {}) {
|
29111
29108
|
super(message);
|
29112
29109
|
this.code = code;
|
29113
29110
|
this.name = "FuelError";
|
29111
|
+
this.metadata = metadata;
|
29114
29112
|
}
|
29115
29113
|
toObject() {
|
29116
|
-
const { code, name, message, VERSIONS } = this;
|
29117
|
-
return { code, name, message, VERSIONS };
|
29114
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
29115
|
+
return { code, name, message, metadata, VERSIONS };
|
29118
29116
|
}
|
29119
29117
|
};
|
29120
29118
|
var FuelError = _FuelError;
|
@@ -31282,7 +31280,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31282
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31283
31281
|
var DEFAULT_PRECISION = 9;
|
31284
31282
|
var DEFAULT_MIN_PRECISION = 3;
|
31285
|
-
var
|
31283
|
+
var DEFAULT_DECIMAL_UNITS = 9;
|
31286
31284
|
function toFixed(value, options) {
|
31287
31285
|
const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
|
31288
31286
|
const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
|
@@ -31348,7 +31346,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31348
31346
|
}
|
31349
31347
|
format(options) {
|
31350
31348
|
const {
|
31351
|
-
units =
|
31349
|
+
units = DEFAULT_DECIMAL_UNITS,
|
31352
31350
|
precision = DEFAULT_PRECISION,
|
31353
31351
|
minPrecision = DEFAULT_MIN_PRECISION
|
31354
31352
|
} = options || {};
|
@@ -31364,7 +31362,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31364
31362
|
}
|
31365
31363
|
return formattedFixed;
|
31366
31364
|
}
|
31367
|
-
formatUnits(units =
|
31365
|
+
formatUnits(units = DEFAULT_DECIMAL_UNITS) {
|
31368
31366
|
const valueUnits = this.toString().slice(0, units * -1);
|
31369
31367
|
const valueDecimals = this.toString().slice(units * -1);
|
31370
31368
|
const length = valueDecimals.length;
|
@@ -31473,7 +31471,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31473
31471
|
// END ANCHOR: OVERRIDES to avoid losing references
|
31474
31472
|
};
|
31475
31473
|
var bn = (value, base, endian) => new BN(value, base, endian);
|
31476
|
-
bn.parseUnits = (value, units =
|
31474
|
+
bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
|
31477
31475
|
const valueToParse = value === "." ? "0." : value;
|
31478
31476
|
const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
|
31479
31477
|
const length = valueDecimals.length;
|
@@ -31607,6 +31605,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31607
31605
|
var ENCODING_V1 = "1";
|
31608
31606
|
var WORD_SIZE = 8;
|
31609
31607
|
var BYTES_32 = 32;
|
31608
|
+
var UTXO_ID_LEN = BYTES_32 + 1;
|
31610
31609
|
var ASSET_ID_LEN = BYTES_32;
|
31611
31610
|
var ADDRESS_LEN = BYTES_32;
|
31612
31611
|
var NONCE_LEN = BYTES_32;
|
@@ -31757,15 +31756,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31757
31756
|
}
|
31758
31757
|
};
|
31759
31758
|
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
31760
|
-
function findOrThrow(arr, predicate, throwFn = () => {
|
31761
|
-
throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
|
31762
|
-
}) {
|
31763
|
-
const found = arr.find(predicate);
|
31764
|
-
if (found === void 0) {
|
31765
|
-
throwFn();
|
31766
|
-
}
|
31767
|
-
return found;
|
31768
|
-
}
|
31769
31759
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31770
31760
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31771
31761
|
var rightPadToWordSize = (encoded) => {
|
@@ -31775,6 +31765,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31775
31765
|
const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
|
31776
31766
|
return concatBytes2([encoded, padding]);
|
31777
31767
|
};
|
31768
|
+
var isUint8Array = (value) => value instanceof Uint8Array;
|
31778
31769
|
var ArrayCoder = class extends Coder {
|
31779
31770
|
coder;
|
31780
31771
|
length;
|
@@ -31918,9 +31909,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31918
31909
|
__privateAdd2(this, _getPaddedData);
|
31919
31910
|
}
|
31920
31911
|
encode(value) {
|
31921
|
-
if (!Array.isArray(value)) {
|
31922
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
31923
|
-
}
|
31924
31912
|
const parts = [];
|
31925
31913
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
31926
31914
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -31947,7 +31935,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31947
31935
|
};
|
31948
31936
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
31949
31937
|
getPaddedData_fn = function(value) {
|
31950
|
-
const data = [Uint8Array
|
31938
|
+
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
31951
31939
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31952
31940
|
if (paddingLength) {
|
31953
31941
|
data.push(new Uint8Array(paddingLength));
|
@@ -31970,7 +31958,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31970
31958
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
31971
31959
|
0
|
31972
31960
|
);
|
31973
|
-
super(
|
31961
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
31974
31962
|
this.name = name;
|
31975
31963
|
this.coders = coders;
|
31976
31964
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32040,7 +32028,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32040
32028
|
return { None: [] };
|
32041
32029
|
}
|
32042
32030
|
decode(data, offset) {
|
32043
|
-
if (data.length < this.encodedLength
|
32031
|
+
if (data.length < this.encodedLength) {
|
32044
32032
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
32045
32033
|
}
|
32046
32034
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -32319,8 +32307,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32319
32307
|
this.coder = coder;
|
32320
32308
|
}
|
32321
32309
|
encode(value) {
|
32322
|
-
if (!Array.isArray(value)) {
|
32323
|
-
throw new FuelError(
|
32310
|
+
if (!Array.isArray(value) && !isUint8Array(value)) {
|
32311
|
+
throw new FuelError(
|
32312
|
+
ErrorCode.ENCODE_ERROR,
|
32313
|
+
`Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
|
32314
|
+
);
|
32324
32315
|
}
|
32325
32316
|
const parts = [];
|
32326
32317
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
@@ -32351,6 +32342,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32351
32342
|
];
|
32352
32343
|
}
|
32353
32344
|
};
|
32345
|
+
var findFunctionByName = (abi, name) => {
|
32346
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
32347
|
+
if (!fn) {
|
32348
|
+
throw new FuelError(
|
32349
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
32350
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
32351
|
+
);
|
32352
|
+
}
|
32353
|
+
return fn;
|
32354
|
+
};
|
32355
|
+
var findTypeById = (abi, typeId) => {
|
32356
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
32357
|
+
if (!type3) {
|
32358
|
+
throw new FuelError(
|
32359
|
+
ErrorCode.TYPE_NOT_FOUND,
|
32360
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
32361
|
+
);
|
32362
|
+
}
|
32363
|
+
return type3;
|
32364
|
+
};
|
32365
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
32366
|
+
var findVectorBufferArgument = (components) => {
|
32367
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
32368
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
32369
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
32370
|
+
throw new FuelError(
|
32371
|
+
ErrorCode.INVALID_COMPONENT,
|
32372
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
32373
|
+
);
|
32374
|
+
}
|
32375
|
+
return bufferTypeArgument;
|
32376
|
+
};
|
32354
32377
|
var ResolvedAbiType = class {
|
32355
32378
|
abi;
|
32356
32379
|
name;
|
@@ -32359,20 +32382,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32359
32382
|
components;
|
32360
32383
|
constructor(abi, argument) {
|
32361
32384
|
this.abi = abi;
|
32362
|
-
const type3 = findOrThrow(
|
32363
|
-
abi.types,
|
32364
|
-
(t) => t.typeId === argument.type,
|
32365
|
-
() => {
|
32366
|
-
throw new FuelError(
|
32367
|
-
ErrorCode.TYPE_NOT_FOUND,
|
32368
|
-
`Type does not exist in the provided abi: ${JSON.stringify({
|
32369
|
-
argument,
|
32370
|
-
abi: this.abi
|
32371
|
-
})}`
|
32372
|
-
);
|
32373
|
-
}
|
32374
|
-
);
|
32375
32385
|
this.name = argument.name;
|
32386
|
+
const type3 = findTypeById(abi, argument.type);
|
32376
32387
|
this.type = type3.type;
|
32377
32388
|
this.originalTypeArguments = argument.typeArguments;
|
32378
32389
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -32424,7 +32435,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32424
32435
|
)
|
32425
32436
|
};
|
32426
32437
|
}
|
32427
|
-
const argType =
|
32438
|
+
const argType = findTypeById(abi, arg.type);
|
32428
32439
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
32429
32440
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
32430
32441
|
return {
|
@@ -32441,7 +32452,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32441
32452
|
}
|
32442
32453
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32443
32454
|
args.forEach((a) => {
|
32444
|
-
const argType =
|
32455
|
+
const argType = findTypeById(abi, a.type);
|
32445
32456
|
if (genericRegEx.test(argType.type)) {
|
32446
32457
|
implicitGenericParameters.push(argType.typeId);
|
32447
32458
|
return;
|
@@ -32550,13 +32561,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32550
32561
|
return new ArrayCoder(arrayElementCoder, length);
|
32551
32562
|
}
|
32552
32563
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32553
|
-
const arg =
|
32554
|
-
if (!arg) {
|
32555
|
-
throw new FuelError(
|
32556
|
-
ErrorCode.INVALID_COMPONENT,
|
32557
|
-
`The provided Vec type is missing the 'type argument'.`
|
32558
|
-
);
|
32559
|
-
}
|
32564
|
+
const arg = findVectorBufferArgument(components);
|
32560
32565
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32561
32566
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32562
32567
|
return new VecCoder(itemCoder);
|
@@ -32623,11 +32628,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32623
32628
|
super("struct", "struct Bytes", WORD_SIZE);
|
32624
32629
|
}
|
32625
32630
|
encode(value) {
|
32626
|
-
|
32627
|
-
|
32628
|
-
}
|
32629
|
-
const bytes3 = new Uint8Array(value);
|
32630
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32631
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
32632
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
32631
32633
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32632
32634
|
}
|
32633
32635
|
decode(data, offset) {
|
@@ -32660,7 +32662,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32660
32662
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
32661
32663
|
0
|
32662
32664
|
);
|
32663
|
-
super(
|
32665
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32664
32666
|
this.name = name;
|
32665
32667
|
this.coders = coders;
|
32666
32668
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -32758,6 +32760,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32758
32760
|
return [toNumber2(bytes3), offset + this.length];
|
32759
32761
|
}
|
32760
32762
|
};
|
32763
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
32764
|
+
encode(value) {
|
32765
|
+
const result = super.encode(this.toSwayOption(value));
|
32766
|
+
return result;
|
32767
|
+
}
|
32768
|
+
toSwayOption(input) {
|
32769
|
+
if (input !== void 0) {
|
32770
|
+
return { Some: input };
|
32771
|
+
}
|
32772
|
+
return { None: [] };
|
32773
|
+
}
|
32774
|
+
decode(data, offset) {
|
32775
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
32776
|
+
return [this.toOption(decoded), newOffset];
|
32777
|
+
}
|
32778
|
+
toOption(output3) {
|
32779
|
+
if (output3 && "Some" in output3) {
|
32780
|
+
return output3.Some;
|
32781
|
+
}
|
32782
|
+
return void 0;
|
32783
|
+
}
|
32784
|
+
};
|
32761
32785
|
var RawSliceCoder2 = class extends Coder {
|
32762
32786
|
constructor() {
|
32763
32787
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -32811,6 +32835,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32811
32835
|
}
|
32812
32836
|
};
|
32813
32837
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
32838
|
+
var StrSliceCoder = class extends Coder {
|
32839
|
+
constructor() {
|
32840
|
+
super("strSlice", "str", WORD_SIZE);
|
32841
|
+
}
|
32842
|
+
encode(value) {
|
32843
|
+
const bytes3 = toUtf8Bytes(value);
|
32844
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32845
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
32846
|
+
}
|
32847
|
+
decode(data, offset) {
|
32848
|
+
if (data.length < this.encodedLength) {
|
32849
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
32850
|
+
}
|
32851
|
+
const offsetAndLength = offset + WORD_SIZE;
|
32852
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
32853
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32854
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
32855
|
+
if (bytes3.length !== length) {
|
32856
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
32857
|
+
}
|
32858
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
32859
|
+
}
|
32860
|
+
};
|
32861
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
32814
32862
|
var StringCoder2 = class extends Coder {
|
32815
32863
|
constructor(length) {
|
32816
32864
|
super("string", `str[${length}]`, length);
|
@@ -32849,7 +32897,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32849
32897
|
Object.keys(this.coders).map((fieldName) => {
|
32850
32898
|
const fieldCoder = this.coders[fieldName];
|
32851
32899
|
const fieldValue = value[fieldName];
|
32852
|
-
if (!(fieldCoder instanceof
|
32900
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
32853
32901
|
throw new FuelError(
|
32854
32902
|
ErrorCode.ENCODE_ERROR,
|
32855
32903
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -32957,6 +33005,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32957
33005
|
return new ByteCoder2();
|
32958
33006
|
case STD_STRING_CODER_TYPE:
|
32959
33007
|
return new StdStringCoder2();
|
33008
|
+
case STR_SLICE_CODER_TYPE:
|
33009
|
+
return new StrSliceCoder();
|
32960
33010
|
default:
|
32961
33011
|
break;
|
32962
33012
|
}
|
@@ -32980,13 +33030,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32980
33030
|
return new ArrayCoder(arrayElementCoder, length);
|
32981
33031
|
}
|
32982
33032
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32983
|
-
const arg =
|
32984
|
-
if (!arg) {
|
32985
|
-
throw new FuelError(
|
32986
|
-
ErrorCode.INVALID_COMPONENT,
|
32987
|
-
`The provided Vec type is missing the 'type argument'.`
|
32988
|
-
);
|
32989
|
-
}
|
33033
|
+
const arg = findVectorBufferArgument(components);
|
32990
33034
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32991
33035
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32992
33036
|
return new VecCoder2(itemCoder);
|
@@ -33001,7 +33045,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33001
33045
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
33002
33046
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
33003
33047
|
if (isOptionEnum) {
|
33004
|
-
return new
|
33048
|
+
return new OptionCoder2(enumMatch.name, coders);
|
33005
33049
|
}
|
33006
33050
|
return new EnumCoder2(enumMatch.name, coders);
|
33007
33051
|
}
|
@@ -33012,12 +33056,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33012
33056
|
);
|
33013
33057
|
return new TupleCoder2(coders);
|
33014
33058
|
}
|
33015
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
33016
|
-
throw new FuelError(
|
33017
|
-
ErrorCode.INVALID_DATA,
|
33018
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
33019
|
-
);
|
33020
|
-
}
|
33021
33059
|
throw new FuelError(
|
33022
33060
|
ErrorCode.CODER_NOT_FOUND,
|
33023
33061
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -33053,6 +33091,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33053
33091
|
var FunctionFragment = class {
|
33054
33092
|
signature;
|
33055
33093
|
selector;
|
33094
|
+
selectorBytes;
|
33095
|
+
encoding;
|
33056
33096
|
name;
|
33057
33097
|
jsonFn;
|
33058
33098
|
attributes;
|
@@ -33061,10 +33101,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33061
33101
|
jsonAbi;
|
33062
33102
|
constructor(jsonAbi, name) {
|
33063
33103
|
this.jsonAbi = jsonAbi;
|
33064
|
-
this.jsonFn =
|
33104
|
+
this.jsonFn = findFunctionByName(this.jsonAbi, name);
|
33065
33105
|
this.name = name;
|
33066
33106
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33067
33107
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
33108
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
33109
|
+
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
33068
33110
|
this.isInputDataPointer = this.#isInputDataPointer();
|
33069
33111
|
this.outputMetadata = {
|
33070
33112
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -33083,13 +33125,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33083
33125
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
33084
33126
|
}
|
33085
33127
|
#isInputDataPointer() {
|
33086
|
-
const inputTypes = this.jsonFn.inputs.map(
|
33087
|
-
(i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
|
33088
|
-
);
|
33128
|
+
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
33089
33129
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
33090
33130
|
}
|
33091
33131
|
#isOutputDataHeap() {
|
33092
|
-
const outputType =
|
33132
|
+
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33093
33133
|
return isHeapType(outputType?.type || "");
|
33094
33134
|
}
|
33095
33135
|
#getOutputEncodedLength() {
|
@@ -33109,27 +33149,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33109
33149
|
encodeArguments(values, offset = 0) {
|
33110
33150
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
33111
33151
|
const shallowCopyValues = values.slice();
|
33112
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33113
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33114
|
-
);
|
33152
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33115
33153
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
33116
33154
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
33117
33155
|
shallowCopyValues.fill(void 0, values.length);
|
33118
33156
|
}
|
33119
33157
|
const coders = nonEmptyInputs.map(
|
33120
33158
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
33121
|
-
isRightPadded: nonEmptyInputs.length > 1
|
33159
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
33160
|
+
encoding: this.encoding
|
33122
33161
|
})
|
33123
33162
|
);
|
33124
|
-
|
33125
|
-
|
33163
|
+
if (this.encoding === ENCODING_V1) {
|
33164
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
33165
|
+
}
|
33166
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
33126
33167
|
return unpackDynamicData(results, offset, results.byteLength);
|
33127
33168
|
}
|
33128
33169
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
33129
33170
|
if (args.length === inputs.length) {
|
33130
33171
|
return;
|
33131
33172
|
}
|
33132
|
-
const inputTypes = inputs.map((
|
33173
|
+
const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
|
33133
33174
|
const optionalInputs = inputTypes.filter(
|
33134
33175
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
33135
33176
|
);
|
@@ -33144,9 +33185,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33144
33185
|
}
|
33145
33186
|
decodeArguments(data) {
|
33146
33187
|
const bytes3 = arrayify(data);
|
33147
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33148
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33149
|
-
);
|
33188
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33150
33189
|
if (nonEmptyInputs.length === 0) {
|
33151
33190
|
if (bytes3.length === 0) {
|
33152
33191
|
return void 0;
|
@@ -33169,7 +33208,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33169
33208
|
}
|
33170
33209
|
const result = nonEmptyInputs.reduce(
|
33171
33210
|
(obj, input) => {
|
33172
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
33211
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
33173
33212
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
33174
33213
|
return {
|
33175
33214
|
decoded: [...obj.decoded, decodedValue],
|
@@ -33181,17 +33220,25 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33181
33220
|
return result.decoded;
|
33182
33221
|
}
|
33183
33222
|
decodeOutput(data) {
|
33184
|
-
const outputAbiType =
|
33185
|
-
this.jsonAbi.types,
|
33186
|
-
(t) => t.typeId === this.jsonFn.output.type
|
33187
|
-
);
|
33223
|
+
const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33188
33224
|
if (outputAbiType.type === "()") {
|
33189
33225
|
return [void 0, 0];
|
33190
33226
|
}
|
33191
33227
|
const bytes3 = arrayify(data);
|
33192
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
33228
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
33229
|
+
encoding: this.encoding
|
33230
|
+
});
|
33193
33231
|
return coder.decode(bytes3, 0);
|
33194
33232
|
}
|
33233
|
+
/**
|
33234
|
+
* Checks if the function is read-only i.e. it only reads from storage, does not write to it.
|
33235
|
+
*
|
33236
|
+
* @returns True if the function is read-only or pure, false otherwise.
|
33237
|
+
*/
|
33238
|
+
isReadOnly() {
|
33239
|
+
const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
|
33240
|
+
return !storageAttribute?.arguments.includes("write");
|
33241
|
+
}
|
33195
33242
|
};
|
33196
33243
|
var Interface = class {
|
33197
33244
|
functions;
|
@@ -33222,16 +33269,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33222
33269
|
}
|
33223
33270
|
decodeFunctionData(functionFragment, data) {
|
33224
33271
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
33225
|
-
if (!fragment) {
|
33226
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
33227
|
-
}
|
33228
33272
|
return fragment.decodeArguments(data);
|
33229
33273
|
}
|
33230
33274
|
encodeFunctionData(functionFragment, values, offset = 0) {
|
33231
33275
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
33232
|
-
if (!fragment) {
|
33233
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
33234
|
-
}
|
33235
33276
|
return fragment.encodeArguments(values, offset);
|
33236
33277
|
}
|
33237
33278
|
// Decode the result of a function call
|
@@ -33240,37 +33281,33 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33240
33281
|
return fragment.decodeOutput(data);
|
33241
33282
|
}
|
33242
33283
|
decodeLog(data, logId) {
|
33243
|
-
const
|
33244
|
-
|
33284
|
+
const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
|
33285
|
+
if (!loggedType) {
|
33286
|
+
throw new FuelError(
|
33287
|
+
ErrorCode.LOG_TYPE_NOT_FOUND,
|
33288
|
+
`Log type with logId '${logId}' doesn't exist in the ABI.`
|
33289
|
+
);
|
33290
|
+
}
|
33291
|
+
return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
|
33245
33292
|
encoding: this.jsonAbi.encoding
|
33246
33293
|
});
|
33247
33294
|
}
|
33248
33295
|
encodeConfigurable(name, value) {
|
33249
|
-
const configurable =
|
33250
|
-
|
33251
|
-
|
33252
|
-
|
33253
|
-
|
33254
|
-
|
33255
|
-
|
33256
|
-
);
|
33257
|
-
}
|
33258
|
-
);
|
33296
|
+
const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
|
33297
|
+
if (!configurable) {
|
33298
|
+
throw new FuelError(
|
33299
|
+
ErrorCode.CONFIGURABLE_NOT_FOUND,
|
33300
|
+
`A configurable with the '${name}' was not found in the ABI.`
|
33301
|
+
);
|
33302
|
+
}
|
33259
33303
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33260
|
-
isRightPadded: true
|
33304
|
+
isRightPadded: true,
|
33305
|
+
// TODO: Review support for configurables in v1 encoding when it becomes available
|
33306
|
+
encoding: ENCODING_V0
|
33261
33307
|
});
|
33262
33308
|
}
|
33263
33309
|
getTypeById(typeId) {
|
33264
|
-
return
|
33265
|
-
this.jsonAbi.types,
|
33266
|
-
(t) => t.typeId === typeId,
|
33267
|
-
() => {
|
33268
|
-
throw new FuelError(
|
33269
|
-
ErrorCode.TYPE_NOT_FOUND,
|
33270
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
33271
|
-
);
|
33272
|
-
}
|
33273
|
-
);
|
33310
|
+
return findTypeById(this.jsonAbi, typeId);
|
33274
33311
|
}
|
33275
33312
|
};
|
33276
33313
|
|
@@ -33960,7 +33997,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33960
33997
|
return [receiptMessageOut, o];
|
33961
33998
|
}
|
33962
33999
|
};
|
33963
|
-
var
|
34000
|
+
var getMintedAssetId = (contractId, subId) => {
|
33964
34001
|
const contractIdBytes = arrayify(contractId);
|
33965
34002
|
const subIdBytes = arrayify(subId);
|
33966
34003
|
return sha2563(concat([contractIdBytes, subIdBytes]));
|
@@ -33970,7 +34007,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33970
34007
|
super("ReceiptMint", "struct ReceiptMint", 0);
|
33971
34008
|
}
|
33972
34009
|
static getAssetId(contractId, subId) {
|
33973
|
-
return
|
34010
|
+
return getMintedAssetId(contractId, subId);
|
33974
34011
|
}
|
33975
34012
|
encode(value) {
|
33976
34013
|
const parts = [];
|
@@ -34012,7 +34049,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34012
34049
|
super("ReceiptBurn", "struct ReceiptBurn", 0);
|
34013
34050
|
}
|
34014
34051
|
static getAssetId(contractId, subId) {
|
34015
|
-
return
|
34052
|
+
return getMintedAssetId(contractId, subId);
|
34016
34053
|
}
|
34017
34054
|
encode(value) {
|
34018
34055
|
const parts = [];
|
@@ -38724,36 +38761,45 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38724
38761
|
});
|
38725
38762
|
this.stream = response.body.getReader();
|
38726
38763
|
}
|
38764
|
+
events = [];
|
38765
|
+
parsingLeftover = "";
|
38727
38766
|
async next() {
|
38728
38767
|
if (!this.stream) {
|
38729
38768
|
await this.setStream();
|
38730
38769
|
}
|
38731
38770
|
while (true) {
|
38771
|
+
if (this.events.length > 0) {
|
38772
|
+
const { data, errors } = this.events.shift();
|
38773
|
+
if (Array.isArray(errors)) {
|
38774
|
+
throw new FuelError(
|
38775
|
+
FuelError.CODES.INVALID_REQUEST,
|
38776
|
+
errors.map((err) => err.message).join("\n\n")
|
38777
|
+
);
|
38778
|
+
}
|
38779
|
+
return { value: data, done: false };
|
38780
|
+
}
|
38732
38781
|
const { value, done } = await this.stream.read();
|
38733
38782
|
if (done) {
|
38734
38783
|
return { value, done };
|
38735
38784
|
}
|
38736
|
-
const
|
38737
|
-
if (
|
38785
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
38786
|
+
if (decoded === "") {
|
38738
38787
|
continue;
|
38739
38788
|
}
|
38740
|
-
|
38741
|
-
|
38742
|
-
|
38743
|
-
|
38744
|
-
|
38745
|
-
|
38746
|
-
|
38747
|
-
|
38748
|
-
|
38749
|
-
|
38750
|
-
|
38751
|
-
|
38752
|
-
|
38753
|
-
|
38754
|
-
);
|
38755
|
-
}
|
38756
|
-
return { value: data, done: false };
|
38789
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
38790
|
+
const regex = /data:.*\n\n/g;
|
38791
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
38792
|
+
matches.forEach((match) => {
|
38793
|
+
try {
|
38794
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
38795
|
+
} catch (e) {
|
38796
|
+
throw new FuelError(
|
38797
|
+
ErrorCode.STREAM_PARSING_ERROR,
|
38798
|
+
`Error while parsing stream data response: ${text}`
|
38799
|
+
);
|
38800
|
+
}
|
38801
|
+
});
|
38802
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
38757
38803
|
}
|
38758
38804
|
}
|
38759
38805
|
/**
|
@@ -38837,8 +38883,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38837
38883
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
38838
38884
|
return {
|
38839
38885
|
type: InputType.Coin,
|
38840
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
38841
|
-
outputIndex: arrayify(value.id)
|
38886
|
+
txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
|
38887
|
+
outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
38842
38888
|
owner: hexlify(value.owner),
|
38843
38889
|
amount: bn(value.amount),
|
38844
38890
|
assetId: hexlify(value.assetId),
|
@@ -38962,7 +39008,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38962
39008
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
38963
39009
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
38964
39010
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
39011
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
38965
39012
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
39013
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
39014
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
39015
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
39016
|
+
var PANIC_REASONS = [
|
39017
|
+
"UnknownPanicReason",
|
39018
|
+
"Revert",
|
39019
|
+
"OutOfGas",
|
39020
|
+
"TransactionValidity",
|
39021
|
+
"MemoryOverflow",
|
39022
|
+
"ArithmeticOverflow",
|
39023
|
+
"ContractNotFound",
|
39024
|
+
"MemoryOwnership",
|
39025
|
+
"NotEnoughBalance",
|
39026
|
+
"ExpectedInternalContext",
|
39027
|
+
"AssetIdNotFound",
|
39028
|
+
"InputNotFound",
|
39029
|
+
"OutputNotFound",
|
39030
|
+
"WitnessNotFound",
|
39031
|
+
"TransactionMaturity",
|
39032
|
+
"InvalidMetadataIdentifier",
|
39033
|
+
"MalformedCallStructure",
|
39034
|
+
"ReservedRegisterNotWritable",
|
39035
|
+
"InvalidFlags",
|
39036
|
+
"InvalidImmediateValue",
|
39037
|
+
"ExpectedCoinInput",
|
39038
|
+
"EcalError",
|
39039
|
+
"MemoryWriteOverlap",
|
39040
|
+
"ContractNotInInputs",
|
39041
|
+
"InternalBalanceOverflow",
|
39042
|
+
"ContractMaxSize",
|
39043
|
+
"ExpectedUnallocatedStack",
|
39044
|
+
"MaxStaticContractsReached",
|
39045
|
+
"TransferAmountCannotBeZero",
|
39046
|
+
"ExpectedOutputVariable",
|
39047
|
+
"ExpectedParentInternalContext",
|
39048
|
+
"PredicateReturnedNonOne",
|
39049
|
+
"ContractIdAlreadyDeployed",
|
39050
|
+
"ContractMismatch",
|
39051
|
+
"MessageDataTooLong",
|
39052
|
+
"ArithmeticError",
|
39053
|
+
"ContractInstructionNotAllowed",
|
39054
|
+
"TransferZeroCoins",
|
39055
|
+
"InvalidInstruction",
|
39056
|
+
"MemoryNotExecutable",
|
39057
|
+
"PolicyIsNotSet",
|
39058
|
+
"PolicyNotFound",
|
39059
|
+
"TooManyReceipts",
|
39060
|
+
"BalanceOverflow",
|
39061
|
+
"InvalidBlockHeight",
|
39062
|
+
"TooManySlots"
|
39063
|
+
];
|
39064
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
38966
39065
|
|
38967
39066
|
// src/providers/utils/receipts.ts
|
38968
39067
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -39336,6 +39435,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39336
39435
|
});
|
39337
39436
|
}
|
39338
39437
|
|
39438
|
+
// src/providers/utils/extract-tx-error.ts
|
39439
|
+
var assemblePanicError = (status) => {
|
39440
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
39441
|
+
const reason = status.reason;
|
39442
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
39443
|
+
errorMessage = `${errorMessage}
|
39444
|
+
|
39445
|
+
You can read more about this error at:
|
39446
|
+
|
39447
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
39448
|
+
}
|
39449
|
+
return { errorMessage, reason };
|
39450
|
+
};
|
39451
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
39452
|
+
var assembleRevertError = (receipts, logs) => {
|
39453
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
39454
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
39455
|
+
let reason = "";
|
39456
|
+
if (revertReceipt) {
|
39457
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
39458
|
+
switch (reasonHex) {
|
39459
|
+
case FAILED_REQUIRE_SIGNAL: {
|
39460
|
+
reason = "require";
|
39461
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
39462
|
+
break;
|
39463
|
+
}
|
39464
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
39465
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39466
|
+
reason = "assert_eq";
|
39467
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
39468
|
+
break;
|
39469
|
+
}
|
39470
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
39471
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
39472
|
+
reason = "assert_ne";
|
39473
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
39474
|
+
break;
|
39475
|
+
}
|
39476
|
+
case FAILED_ASSERT_SIGNAL:
|
39477
|
+
reason = "assert";
|
39478
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
39479
|
+
break;
|
39480
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
39481
|
+
reason = "MissingOutputChange";
|
39482
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
39483
|
+
break;
|
39484
|
+
default:
|
39485
|
+
reason = "unknown";
|
39486
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
39487
|
+
}
|
39488
|
+
}
|
39489
|
+
return { errorMessage, reason };
|
39490
|
+
};
|
39491
|
+
var extractTxError = (params) => {
|
39492
|
+
const { receipts, status, logs } = params;
|
39493
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
39494
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
39495
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
39496
|
+
const metadata = {
|
39497
|
+
logs,
|
39498
|
+
receipts,
|
39499
|
+
panic: isPanic,
|
39500
|
+
revert: isRevert,
|
39501
|
+
reason
|
39502
|
+
};
|
39503
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
39504
|
+
};
|
39505
|
+
|
39339
39506
|
// src/providers/transaction-request/errors.ts
|
39340
39507
|
var ChangeOutputCollisionError = class extends Error {
|
39341
39508
|
name = "ChangeOutputCollisionError";
|
@@ -39616,8 +39783,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39616
39783
|
assetId,
|
39617
39784
|
txPointer: "0x00000000000000000000000000000000",
|
39618
39785
|
witnessIndex,
|
39619
|
-
predicate: predicate?.bytes
|
39620
|
-
predicateData: predicate?.predicateDataBytes
|
39786
|
+
predicate: predicate?.bytes
|
39621
39787
|
};
|
39622
39788
|
this.pushInput(input);
|
39623
39789
|
this.addChangeOutput(owner, assetId);
|
@@ -39649,8 +39815,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39649
39815
|
recipient: recipient.toB256(),
|
39650
39816
|
amount,
|
39651
39817
|
witnessIndex,
|
39652
|
-
predicate: predicate?.bytes
|
39653
|
-
predicateData: predicate?.predicateDataBytes
|
39818
|
+
predicate: predicate?.bytes
|
39654
39819
|
};
|
39655
39820
|
this.pushInput(input);
|
39656
39821
|
this.addChangeOutput(recipient, assetId);
|
@@ -39805,12 +39970,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39805
39970
|
* @param quantities - CoinQuantity Array.
|
39806
39971
|
*/
|
39807
39972
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39808
|
-
let idCounter = 0;
|
39809
|
-
const generateId = () => {
|
39810
|
-
const counterString = String(idCounter++);
|
39811
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39812
|
-
return id;
|
39813
|
-
};
|
39814
39973
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39815
39974
|
if ("assetId" in input) {
|
39816
39975
|
return input.assetId === assetId;
|
@@ -39820,12 +39979,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
39820
39979
|
const updateAssetInput = (assetId, quantity) => {
|
39821
39980
|
const assetInput = findAssetInput(assetId);
|
39822
39981
|
if (assetInput && "assetId" in assetInput) {
|
39823
|
-
assetInput.id =
|
39982
|
+
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
39824
39983
|
assetInput.amount = quantity;
|
39825
39984
|
} else {
|
39826
39985
|
this.addResources([
|
39827
39986
|
{
|
39828
|
-
id:
|
39987
|
+
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
39829
39988
|
amount: quantity,
|
39830
39989
|
assetId,
|
39831
39990
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -41152,14 +41311,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41152
41311
|
gqlTransaction: this.gqlTransaction,
|
41153
41312
|
...transactionSummary
|
41154
41313
|
};
|
41314
|
+
let logs = [];
|
41155
41315
|
if (this.abis) {
|
41156
|
-
|
41316
|
+
logs = getDecodedLogs(
|
41157
41317
|
transactionSummary.receipts,
|
41158
41318
|
this.abis.main,
|
41159
41319
|
this.abis.otherContractsAbis
|
41160
41320
|
);
|
41161
41321
|
transactionResult.logs = logs;
|
41162
41322
|
}
|
41323
|
+
if (transactionResult.isStatusFailure) {
|
41324
|
+
const {
|
41325
|
+
receipts,
|
41326
|
+
gqlTransaction: { status }
|
41327
|
+
} = transactionResult;
|
41328
|
+
throw extractTxError({
|
41329
|
+
receipts,
|
41330
|
+
status,
|
41331
|
+
logs
|
41332
|
+
});
|
41333
|
+
}
|
41163
41334
|
return transactionResult;
|
41164
41335
|
}
|
41165
41336
|
/**
|
@@ -41168,14 +41339,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41168
41339
|
* @param contractsAbiMap - The contracts ABI map.
|
41169
41340
|
*/
|
41170
41341
|
async wait(contractsAbiMap) {
|
41171
|
-
|
41172
|
-
if (result.isStatusFailure) {
|
41173
|
-
throw new FuelError(
|
41174
|
-
ErrorCode.TRANSACTION_FAILED,
|
41175
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
41176
|
-
);
|
41177
|
-
}
|
41178
|
-
return result;
|
41342
|
+
return this.waitForResult(contractsAbiMap);
|
41179
41343
|
}
|
41180
41344
|
};
|
41181
41345
|
|
@@ -41646,6 +41810,36 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41646
41810
|
missingContractIds
|
41647
41811
|
};
|
41648
41812
|
}
|
41813
|
+
/**
|
41814
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
41815
|
+
* @param transactionRequest - The transaction request object.
|
41816
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41817
|
+
*/
|
41818
|
+
estimateTxGasAndFee(params) {
|
41819
|
+
const { transactionRequest } = params;
|
41820
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41821
|
+
const chainInfo = this.getChain();
|
41822
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41823
|
+
transactionRequest.gasPrice = gasPrice;
|
41824
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41825
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41826
|
+
if (transactionRequest.type === TransactionType.Script) {
|
41827
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
41828
|
+
transactionRequest.gasLimit = minGas;
|
41829
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41830
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41831
|
+
);
|
41832
|
+
}
|
41833
|
+
}
|
41834
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41835
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41836
|
+
return {
|
41837
|
+
minGas,
|
41838
|
+
minFee,
|
41839
|
+
maxGas,
|
41840
|
+
maxFee
|
41841
|
+
};
|
41842
|
+
}
|
41649
41843
|
/**
|
41650
41844
|
* Executes a signed transaction without applying the states changes
|
41651
41845
|
* on the chain.
|
@@ -41693,17 +41887,16 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41693
41887
|
signatureCallback
|
41694
41888
|
} = {}) {
|
41695
41889
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41696
|
-
const
|
41697
|
-
const
|
41698
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41890
|
+
const { minGasPrice } = this.getGasConfig();
|
41891
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41699
41892
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41700
41893
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41701
41894
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41702
41895
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41896
|
+
if (isScriptTransaction) {
|
41897
|
+
txRequestClone.gasLimit = bn(0);
|
41898
|
+
}
|
41703
41899
|
if (estimatePredicates) {
|
41704
|
-
if (isScriptTransaction) {
|
41705
|
-
txRequestClone.gasLimit = bn(0);
|
41706
|
-
}
|
41707
41900
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41708
41901
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41709
41902
|
}
|
@@ -41712,36 +41905,34 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
41712
41905
|
if (signatureCallback && isScriptTransaction) {
|
41713
41906
|
await signatureCallback(txRequestClone);
|
41714
41907
|
}
|
41715
|
-
|
41716
|
-
|
41908
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41909
|
+
transactionRequest: txRequestClone
|
41910
|
+
});
|
41717
41911
|
let receipts = [];
|
41718
41912
|
let missingContractIds = [];
|
41719
41913
|
let outputVariables = 0;
|
41914
|
+
let gasUsed = bn(0);
|
41720
41915
|
if (isScriptTransaction && estimateTxDependencies) {
|
41721
41916
|
txRequestClone.gasPrice = bn(0);
|
41722
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41723
41917
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41724
41918
|
receipts = result.receipts;
|
41725
41919
|
outputVariables = result.outputVariables;
|
41726
41920
|
missingContractIds = result.missingContractIds;
|
41921
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41922
|
+
txRequestClone.gasLimit = gasUsed;
|
41923
|
+
txRequestClone.gasPrice = setGasPrice;
|
41924
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41925
|
+
transactionRequest: txRequestClone
|
41926
|
+
}));
|
41727
41927
|
}
|
41728
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41729
|
-
const usedFee = calculatePriceWithFactor(
|
41730
|
-
gasUsed,
|
41731
|
-
gasPrice,
|
41732
|
-
gasPriceFactor
|
41733
|
-
).normalizeZeroToOne();
|
41734
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41735
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41736
41928
|
return {
|
41737
41929
|
requiredQuantities: allQuantities,
|
41738
41930
|
receipts,
|
41739
41931
|
gasUsed,
|
41740
41932
|
minGasPrice,
|
41741
|
-
gasPrice,
|
41933
|
+
gasPrice: setGasPrice,
|
41742
41934
|
minGas,
|
41743
41935
|
maxGas,
|
41744
|
-
usedFee,
|
41745
41936
|
minFee,
|
41746
41937
|
maxFee,
|
41747
41938
|
estimatedInputs: txRequestClone.inputs,
|
@@ -44195,12 +44386,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44195
44386
|
};
|
44196
44387
|
|
44197
44388
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44198
|
-
var
|
44389
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44199
44390
|
var rnds8Pool = new Uint8Array(256);
|
44200
44391
|
var poolPtr = rnds8Pool.length;
|
44201
44392
|
function rng() {
|
44202
44393
|
if (poolPtr > rnds8Pool.length - 16) {
|
44203
|
-
|
44394
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
44204
44395
|
poolPtr = 0;
|
44205
44396
|
}
|
44206
44397
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44216,9 +44407,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44216
44407
|
}
|
44217
44408
|
|
44218
44409
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44219
|
-
var
|
44410
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
44220
44411
|
var native_default = {
|
44221
|
-
randomUUID:
|
44412
|
+
randomUUID: import_crypto17.default.randomUUID
|
44222
44413
|
};
|
44223
44414
|
|
44224
44415
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47637,7 +47828,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47637
47828
|
// src/predicate/predicate.ts
|
47638
47829
|
var Predicate = class extends Account {
|
47639
47830
|
bytes;
|
47640
|
-
predicateDataBytes = Uint8Array.from([]);
|
47641
47831
|
predicateData = [];
|
47642
47832
|
interface;
|
47643
47833
|
/**
|