@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
@@ -31916,7 +31916,7 @@ spurious results.`);
|
|
31916
31916
|
return {
|
31917
31917
|
FORC: "0.49.3",
|
31918
31918
|
FUEL_CORE: "0.22.1",
|
31919
|
-
FUELS: "0.
|
31919
|
+
FUELS: "0.81.0"
|
31920
31920
|
};
|
31921
31921
|
}
|
31922
31922
|
function parseVersion(version2) {
|
@@ -31975,9 +31975,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31975
31975
|
ErrorCode2["ABI_TYPES_AND_VALUES_MISMATCH"] = "abi-types-and-values-mismatch";
|
31976
31976
|
ErrorCode2["ABI_MAIN_METHOD_MISSING"] = "abi-main-method-missing";
|
31977
31977
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
31978
|
-
ErrorCode2["FRAGMENT_NOT_FOUND"] = "fragment-not-found";
|
31979
31978
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
31980
31979
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
31980
|
+
ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
|
31981
31981
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
31982
31982
|
ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
|
31983
31983
|
ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
|
@@ -31990,14 +31990,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31990
31990
|
ErrorCode2["INVALID_BECH32_ADDRESS"] = "invalid-bech32-address";
|
31991
31991
|
ErrorCode2["INVALID_EVM_ADDRESS"] = "invalid-evm-address";
|
31992
31992
|
ErrorCode2["INVALID_B256_ADDRESS"] = "invalid-b256-address";
|
31993
|
-
ErrorCode2["INVALID_URL"] = "invalid-url";
|
31994
31993
|
ErrorCode2["CHAIN_INFO_CACHE_EMPTY"] = "chain-info-cache-empty";
|
31995
31994
|
ErrorCode2["NODE_INFO_CACHE_EMPTY"] = "node-info-cache-empty";
|
31996
31995
|
ErrorCode2["MISSING_PROVIDER"] = "missing-provider";
|
31997
31996
|
ErrorCode2["INVALID_PROVIDER"] = "invalid-provider";
|
31998
31997
|
ErrorCode2["CONNECTION_REFUSED"] = "connection-refused";
|
31999
31998
|
ErrorCode2["INVALID_PUBLIC_KEY"] = "invalid-public-key";
|
32000
|
-
ErrorCode2["INSUFFICIENT_BALANCE"] = "insufficient-balance";
|
32001
31999
|
ErrorCode2["WALLET_MANAGER_ERROR"] = "wallet-manager-error";
|
32002
32000
|
ErrorCode2["HD_WALLET_ERROR"] = "hd-wallet-error";
|
32003
32001
|
ErrorCode2["MISSING_CONNECTOR"] = "missing-connector";
|
@@ -32014,7 +32012,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32014
32012
|
ErrorCode2["ELEMENT_NOT_FOUND"] = "element-not-found";
|
32015
32013
|
ErrorCode2["MISSING_REQUIRED_PARAMETER"] = "missing-required-parameter";
|
32016
32014
|
ErrorCode2["INVALID_REQUEST"] = "invalid-request";
|
32017
|
-
ErrorCode2["UNEXPECTED_HEX_VALUE"] = "unexpected-hex-value";
|
32018
32015
|
ErrorCode2["INVALID_TRANSFER_AMOUNT"] = "invalid-transfer-amount";
|
32019
32016
|
ErrorCode2["GAS_PRICE_TOO_LOW"] = "gas-price-too-low";
|
32020
32017
|
ErrorCode2["GAS_LIMIT_TOO_LOW"] = "gas-limit-too-low";
|
@@ -32038,7 +32035,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32038
32035
|
ErrorCode2["INVALID_PASSWORD"] = "invalid-password";
|
32039
32036
|
ErrorCode2["ACCOUNT_REQUIRED"] = "account-required";
|
32040
32037
|
ErrorCode2["UNLOCKED_WALLET_REQUIRED"] = "unlocked-wallet-required";
|
32041
|
-
ErrorCode2["LATEST_BLOCK_UNAVAILABLE"] = "latest-block-unavailable";
|
32042
32038
|
ErrorCode2["ERROR_BUILDING_BLOCK_EXPLORER_URL"] = "error-building-block-explorer-url";
|
32043
32039
|
ErrorCode2["UNSUPPORTED_FUEL_CLIENT_VERSION"] = "unsupported-fuel-client-version";
|
32044
32040
|
ErrorCode2["VITEPRESS_PLUGIN_ERROR"] = "vitepress-plugin-error";
|
@@ -32050,6 +32046,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32050
32046
|
})(ErrorCode || {});
|
32051
32047
|
var _FuelError = class extends Error {
|
32052
32048
|
VERSIONS = versions;
|
32049
|
+
metadata;
|
32053
32050
|
static parse(e) {
|
32054
32051
|
const error = e;
|
32055
32052
|
if (error.code === void 0) {
|
@@ -32069,14 +32066,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32069
32066
|
return new _FuelError(error.code, error.message);
|
32070
32067
|
}
|
32071
32068
|
code;
|
32072
|
-
constructor(code, message) {
|
32069
|
+
constructor(code, message, metadata = {}) {
|
32073
32070
|
super(message);
|
32074
32071
|
this.code = code;
|
32075
32072
|
this.name = "FuelError";
|
32073
|
+
this.metadata = metadata;
|
32076
32074
|
}
|
32077
32075
|
toObject() {
|
32078
|
-
const { code, name, message, VERSIONS } = this;
|
32079
|
-
return { code, name, message, VERSIONS };
|
32076
|
+
const { code, name, message, metadata, VERSIONS } = this;
|
32077
|
+
return { code, name, message, metadata, VERSIONS };
|
32080
32078
|
}
|
32081
32079
|
};
|
32082
32080
|
var FuelError = _FuelError;
|
@@ -34765,7 +34763,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34765
34763
|
var import_bn = __toESM(require_bn(), 1);
|
34766
34764
|
var DEFAULT_PRECISION = 9;
|
34767
34765
|
var DEFAULT_MIN_PRECISION = 3;
|
34768
|
-
var
|
34766
|
+
var DEFAULT_DECIMAL_UNITS = 9;
|
34769
34767
|
function toFixed(value, options) {
|
34770
34768
|
const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
|
34771
34769
|
const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
|
@@ -34831,7 +34829,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34831
34829
|
}
|
34832
34830
|
format(options) {
|
34833
34831
|
const {
|
34834
|
-
units =
|
34832
|
+
units = DEFAULT_DECIMAL_UNITS,
|
34835
34833
|
precision = DEFAULT_PRECISION,
|
34836
34834
|
minPrecision = DEFAULT_MIN_PRECISION
|
34837
34835
|
} = options || {};
|
@@ -34847,7 +34845,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34847
34845
|
}
|
34848
34846
|
return formattedFixed;
|
34849
34847
|
}
|
34850
|
-
formatUnits(units =
|
34848
|
+
formatUnits(units = DEFAULT_DECIMAL_UNITS) {
|
34851
34849
|
const valueUnits = this.toString().slice(0, units * -1);
|
34852
34850
|
const valueDecimals = this.toString().slice(units * -1);
|
34853
34851
|
const length = valueDecimals.length;
|
@@ -34956,7 +34954,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34956
34954
|
// END ANCHOR: OVERRIDES to avoid losing references
|
34957
34955
|
};
|
34958
34956
|
var bn = (value, base, endian) => new BN(value, base, endian);
|
34959
|
-
bn.parseUnits = (value, units =
|
34957
|
+
bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
|
34960
34958
|
const valueToParse = value === "." ? "0." : value;
|
34961
34959
|
const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
|
34962
34960
|
const length = valueDecimals.length;
|
@@ -35072,6 +35070,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35072
35070
|
var ENCODING_V1 = "1";
|
35073
35071
|
var WORD_SIZE = 8;
|
35074
35072
|
var BYTES_32 = 32;
|
35073
|
+
var UTXO_ID_LEN = BYTES_32 + 1;
|
35075
35074
|
var ASSET_ID_LEN = BYTES_32;
|
35076
35075
|
var ADDRESS_LEN = BYTES_32;
|
35077
35076
|
var NONCE_LEN = BYTES_32;
|
@@ -35222,15 +35221,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35222
35221
|
}
|
35223
35222
|
};
|
35224
35223
|
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
35225
|
-
function findOrThrow(arr, predicate, throwFn = () => {
|
35226
|
-
throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
|
35227
|
-
}) {
|
35228
|
-
const found = arr.find(predicate);
|
35229
|
-
if (found === void 0) {
|
35230
|
-
throwFn();
|
35231
|
-
}
|
35232
|
-
return found;
|
35233
|
-
}
|
35234
35224
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
35235
35225
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
35236
35226
|
var rightPadToWordSize = (encoded) => {
|
@@ -35240,6 +35230,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35240
35230
|
const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
|
35241
35231
|
return concatBytes2([encoded, padding]);
|
35242
35232
|
};
|
35233
|
+
var isUint8Array = (value) => value instanceof Uint8Array;
|
35243
35234
|
var ArrayCoder = class extends Coder {
|
35244
35235
|
coder;
|
35245
35236
|
length;
|
@@ -35383,9 +35374,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35383
35374
|
__privateAdd2(this, _getPaddedData);
|
35384
35375
|
}
|
35385
35376
|
encode(value) {
|
35386
|
-
if (!Array.isArray(value)) {
|
35387
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
35388
|
-
}
|
35389
35377
|
const parts = [];
|
35390
35378
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
35391
35379
|
const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
|
@@ -35412,7 +35400,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35412
35400
|
};
|
35413
35401
|
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
35414
35402
|
getPaddedData_fn = function(value) {
|
35415
|
-
const data = [Uint8Array
|
35403
|
+
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
35416
35404
|
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
35417
35405
|
if (paddingLength) {
|
35418
35406
|
data.push(new Uint8Array(paddingLength));
|
@@ -35435,7 +35423,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35435
35423
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
35436
35424
|
0
|
35437
35425
|
);
|
35438
|
-
super(
|
35426
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
35439
35427
|
this.name = name;
|
35440
35428
|
this.coders = coders;
|
35441
35429
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -35505,7 +35493,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35505
35493
|
return { None: [] };
|
35506
35494
|
}
|
35507
35495
|
decode(data, offset) {
|
35508
|
-
if (data.length < this.encodedLength
|
35496
|
+
if (data.length < this.encodedLength) {
|
35509
35497
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
35510
35498
|
}
|
35511
35499
|
const [decoded, newOffset] = super.decode(data, offset);
|
@@ -35784,8 +35772,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35784
35772
|
this.coder = coder;
|
35785
35773
|
}
|
35786
35774
|
encode(value) {
|
35787
|
-
if (!Array.isArray(value)) {
|
35788
|
-
throw new FuelError(
|
35775
|
+
if (!Array.isArray(value) && !isUint8Array(value)) {
|
35776
|
+
throw new FuelError(
|
35777
|
+
ErrorCode.ENCODE_ERROR,
|
35778
|
+
`Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
|
35779
|
+
);
|
35789
35780
|
}
|
35790
35781
|
const parts = [];
|
35791
35782
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
@@ -35816,6 +35807,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35816
35807
|
];
|
35817
35808
|
}
|
35818
35809
|
};
|
35810
|
+
var findFunctionByName = (abi, name) => {
|
35811
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
35812
|
+
if (!fn) {
|
35813
|
+
throw new FuelError(
|
35814
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
35815
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
35816
|
+
);
|
35817
|
+
}
|
35818
|
+
return fn;
|
35819
|
+
};
|
35820
|
+
var findTypeById = (abi, typeId) => {
|
35821
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
35822
|
+
if (!type3) {
|
35823
|
+
throw new FuelError(
|
35824
|
+
ErrorCode.TYPE_NOT_FOUND,
|
35825
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
35826
|
+
);
|
35827
|
+
}
|
35828
|
+
return type3;
|
35829
|
+
};
|
35830
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
35831
|
+
var findVectorBufferArgument = (components) => {
|
35832
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
35833
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
35834
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
35835
|
+
throw new FuelError(
|
35836
|
+
ErrorCode.INVALID_COMPONENT,
|
35837
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
35838
|
+
);
|
35839
|
+
}
|
35840
|
+
return bufferTypeArgument;
|
35841
|
+
};
|
35819
35842
|
var ResolvedAbiType = class {
|
35820
35843
|
abi;
|
35821
35844
|
name;
|
@@ -35824,20 +35847,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35824
35847
|
components;
|
35825
35848
|
constructor(abi, argument) {
|
35826
35849
|
this.abi = abi;
|
35827
|
-
const type3 = findOrThrow(
|
35828
|
-
abi.types,
|
35829
|
-
(t) => t.typeId === argument.type,
|
35830
|
-
() => {
|
35831
|
-
throw new FuelError(
|
35832
|
-
ErrorCode.TYPE_NOT_FOUND,
|
35833
|
-
`Type does not exist in the provided abi: ${JSON.stringify({
|
35834
|
-
argument,
|
35835
|
-
abi: this.abi
|
35836
|
-
})}`
|
35837
|
-
);
|
35838
|
-
}
|
35839
|
-
);
|
35840
35850
|
this.name = argument.name;
|
35851
|
+
const type3 = findTypeById(abi, argument.type);
|
35841
35852
|
this.type = type3.type;
|
35842
35853
|
this.originalTypeArguments = argument.typeArguments;
|
35843
35854
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -35889,7 +35900,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35889
35900
|
)
|
35890
35901
|
};
|
35891
35902
|
}
|
35892
|
-
const argType =
|
35903
|
+
const argType = findTypeById(abi, arg.type);
|
35893
35904
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
35894
35905
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
35895
35906
|
return {
|
@@ -35906,7 +35917,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
35906
35917
|
}
|
35907
35918
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
35908
35919
|
args.forEach((a) => {
|
35909
|
-
const argType =
|
35920
|
+
const argType = findTypeById(abi, a.type);
|
35910
35921
|
if (genericRegEx.test(argType.type)) {
|
35911
35922
|
implicitGenericParameters.push(argType.typeId);
|
35912
35923
|
return;
|
@@ -36015,13 +36026,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36015
36026
|
return new ArrayCoder(arrayElementCoder, length);
|
36016
36027
|
}
|
36017
36028
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
36018
|
-
const arg =
|
36019
|
-
if (!arg) {
|
36020
|
-
throw new FuelError(
|
36021
|
-
ErrorCode.INVALID_COMPONENT,
|
36022
|
-
`The provided Vec type is missing the 'type argument'.`
|
36023
|
-
);
|
36024
|
-
}
|
36029
|
+
const arg = findVectorBufferArgument(components);
|
36025
36030
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
36026
36031
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
36027
36032
|
return new VecCoder(itemCoder);
|
@@ -36088,11 +36093,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36088
36093
|
super("struct", "struct Bytes", WORD_SIZE);
|
36089
36094
|
}
|
36090
36095
|
encode(value) {
|
36091
|
-
|
36092
|
-
|
36093
|
-
}
|
36094
|
-
const bytes3 = new Uint8Array(value);
|
36095
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36096
|
+
const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
36097
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
|
36096
36098
|
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36097
36099
|
}
|
36098
36100
|
decode(data, offset) {
|
@@ -36125,7 +36127,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36125
36127
|
(max2, coder) => Math.max(max2, coder.encodedLength),
|
36126
36128
|
0
|
36127
36129
|
);
|
36128
|
-
super(
|
36130
|
+
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
36129
36131
|
this.name = name;
|
36130
36132
|
this.coders = coders;
|
36131
36133
|
this.#caseIndexCoder = caseIndexCoder;
|
@@ -36223,6 +36225,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36223
36225
|
return [toNumber2(bytes3), offset + this.length];
|
36224
36226
|
}
|
36225
36227
|
};
|
36228
|
+
var OptionCoder2 = class extends EnumCoder2 {
|
36229
|
+
encode(value) {
|
36230
|
+
const result = super.encode(this.toSwayOption(value));
|
36231
|
+
return result;
|
36232
|
+
}
|
36233
|
+
toSwayOption(input) {
|
36234
|
+
if (input !== void 0) {
|
36235
|
+
return { Some: input };
|
36236
|
+
}
|
36237
|
+
return { None: [] };
|
36238
|
+
}
|
36239
|
+
decode(data, offset) {
|
36240
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
36241
|
+
return [this.toOption(decoded), newOffset];
|
36242
|
+
}
|
36243
|
+
toOption(output3) {
|
36244
|
+
if (output3 && "Some" in output3) {
|
36245
|
+
return output3.Some;
|
36246
|
+
}
|
36247
|
+
return void 0;
|
36248
|
+
}
|
36249
|
+
};
|
36226
36250
|
var RawSliceCoder2 = class extends Coder {
|
36227
36251
|
constructor() {
|
36228
36252
|
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
@@ -36276,6 +36300,30 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36276
36300
|
}
|
36277
36301
|
};
|
36278
36302
|
__publicField4(StdStringCoder2, "memorySize", 1);
|
36303
|
+
var StrSliceCoder = class extends Coder {
|
36304
|
+
constructor() {
|
36305
|
+
super("strSlice", "str", WORD_SIZE);
|
36306
|
+
}
|
36307
|
+
encode(value) {
|
36308
|
+
const bytes3 = toUtf8Bytes(value);
|
36309
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
36310
|
+
return new Uint8Array([...lengthBytes, ...bytes3]);
|
36311
|
+
}
|
36312
|
+
decode(data, offset) {
|
36313
|
+
if (data.length < this.encodedLength) {
|
36314
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
|
36315
|
+
}
|
36316
|
+
const offsetAndLength = offset + WORD_SIZE;
|
36317
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
36318
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
36319
|
+
const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
|
36320
|
+
if (bytes3.length !== length) {
|
36321
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
|
36322
|
+
}
|
36323
|
+
return [toUtf8String(bytes3), offsetAndLength + length];
|
36324
|
+
}
|
36325
|
+
};
|
36326
|
+
__publicField4(StrSliceCoder, "memorySize", 1);
|
36279
36327
|
var StringCoder2 = class extends Coder {
|
36280
36328
|
constructor(length) {
|
36281
36329
|
super("string", `str[${length}]`, length);
|
@@ -36314,7 +36362,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36314
36362
|
Object.keys(this.coders).map((fieldName) => {
|
36315
36363
|
const fieldCoder = this.coders[fieldName];
|
36316
36364
|
const fieldValue = value[fieldName];
|
36317
|
-
if (!(fieldCoder instanceof
|
36365
|
+
if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
|
36318
36366
|
throw new FuelError(
|
36319
36367
|
ErrorCode.ENCODE_ERROR,
|
36320
36368
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -36422,6 +36470,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36422
36470
|
return new ByteCoder2();
|
36423
36471
|
case STD_STRING_CODER_TYPE:
|
36424
36472
|
return new StdStringCoder2();
|
36473
|
+
case STR_SLICE_CODER_TYPE:
|
36474
|
+
return new StrSliceCoder();
|
36425
36475
|
default:
|
36426
36476
|
break;
|
36427
36477
|
}
|
@@ -36445,13 +36495,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36445
36495
|
return new ArrayCoder(arrayElementCoder, length);
|
36446
36496
|
}
|
36447
36497
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
36448
|
-
const arg =
|
36449
|
-
if (!arg) {
|
36450
|
-
throw new FuelError(
|
36451
|
-
ErrorCode.INVALID_COMPONENT,
|
36452
|
-
`The provided Vec type is missing the 'type argument'.`
|
36453
|
-
);
|
36454
|
-
}
|
36498
|
+
const arg = findVectorBufferArgument(components);
|
36455
36499
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
36456
36500
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
36457
36501
|
return new VecCoder2(itemCoder);
|
@@ -36466,7 +36510,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36466
36510
|
const coders = getCoders(components, { getCoder: getCoder2 });
|
36467
36511
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
36468
36512
|
if (isOptionEnum) {
|
36469
|
-
return new
|
36513
|
+
return new OptionCoder2(enumMatch.name, coders);
|
36470
36514
|
}
|
36471
36515
|
return new EnumCoder2(enumMatch.name, coders);
|
36472
36516
|
}
|
@@ -36477,12 +36521,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36477
36521
|
);
|
36478
36522
|
return new TupleCoder2(coders);
|
36479
36523
|
}
|
36480
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
36481
|
-
throw new FuelError(
|
36482
|
-
ErrorCode.INVALID_DATA,
|
36483
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
36484
|
-
);
|
36485
|
-
}
|
36486
36524
|
throw new FuelError(
|
36487
36525
|
ErrorCode.CODER_NOT_FOUND,
|
36488
36526
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
@@ -36518,6 +36556,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36518
36556
|
var FunctionFragment = class {
|
36519
36557
|
signature;
|
36520
36558
|
selector;
|
36559
|
+
selectorBytes;
|
36560
|
+
encoding;
|
36521
36561
|
name;
|
36522
36562
|
jsonFn;
|
36523
36563
|
attributes;
|
@@ -36526,10 +36566,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36526
36566
|
jsonAbi;
|
36527
36567
|
constructor(jsonAbi, name) {
|
36528
36568
|
this.jsonAbi = jsonAbi;
|
36529
|
-
this.jsonFn =
|
36569
|
+
this.jsonFn = findFunctionByName(this.jsonAbi, name);
|
36530
36570
|
this.name = name;
|
36531
36571
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
36532
36572
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
36573
|
+
this.selectorBytes = new StdStringCoder2().encode(name);
|
36574
|
+
this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
|
36533
36575
|
this.isInputDataPointer = this.#isInputDataPointer();
|
36534
36576
|
this.outputMetadata = {
|
36535
36577
|
isHeapType: this.#isOutputDataHeap(),
|
@@ -36548,13 +36590,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36548
36590
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
36549
36591
|
}
|
36550
36592
|
#isInputDataPointer() {
|
36551
|
-
const inputTypes = this.jsonFn.inputs.map(
|
36552
|
-
(i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
|
36553
|
-
);
|
36593
|
+
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
36554
36594
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
36555
36595
|
}
|
36556
36596
|
#isOutputDataHeap() {
|
36557
|
-
const outputType =
|
36597
|
+
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
36558
36598
|
return isHeapType(outputType?.type || "");
|
36559
36599
|
}
|
36560
36600
|
#getOutputEncodedLength() {
|
@@ -36574,27 +36614,28 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36574
36614
|
encodeArguments(values, offset = 0) {
|
36575
36615
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
36576
36616
|
const shallowCopyValues = values.slice();
|
36577
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
36578
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
36579
|
-
);
|
36617
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
36580
36618
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
36581
36619
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
36582
36620
|
shallowCopyValues.fill(void 0, values.length);
|
36583
36621
|
}
|
36584
36622
|
const coders = nonEmptyInputs.map(
|
36585
36623
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
36586
|
-
isRightPadded: nonEmptyInputs.length > 1
|
36624
|
+
isRightPadded: nonEmptyInputs.length > 1,
|
36625
|
+
encoding: this.encoding
|
36587
36626
|
})
|
36588
36627
|
);
|
36589
|
-
|
36590
|
-
|
36628
|
+
if (this.encoding === ENCODING_V1) {
|
36629
|
+
return new TupleCoder2(coders).encode(shallowCopyValues);
|
36630
|
+
}
|
36631
|
+
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
36591
36632
|
return unpackDynamicData(results, offset, results.byteLength);
|
36592
36633
|
}
|
36593
36634
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
36594
36635
|
if (args.length === inputs.length) {
|
36595
36636
|
return;
|
36596
36637
|
}
|
36597
|
-
const inputTypes = inputs.map((
|
36638
|
+
const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
|
36598
36639
|
const optionalInputs = inputTypes.filter(
|
36599
36640
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
36600
36641
|
);
|
@@ -36609,9 +36650,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36609
36650
|
}
|
36610
36651
|
decodeArguments(data) {
|
36611
36652
|
const bytes3 = arrayify(data);
|
36612
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
36613
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
36614
|
-
);
|
36653
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
36615
36654
|
if (nonEmptyInputs.length === 0) {
|
36616
36655
|
if (bytes3.length === 0) {
|
36617
36656
|
return void 0;
|
@@ -36634,7 +36673,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36634
36673
|
}
|
36635
36674
|
const result = nonEmptyInputs.reduce(
|
36636
36675
|
(obj, input) => {
|
36637
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, input);
|
36676
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
|
36638
36677
|
const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
|
36639
36678
|
return {
|
36640
36679
|
decoded: [...obj.decoded, decodedValue],
|
@@ -36646,17 +36685,25 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36646
36685
|
return result.decoded;
|
36647
36686
|
}
|
36648
36687
|
decodeOutput(data) {
|
36649
|
-
const outputAbiType =
|
36650
|
-
this.jsonAbi.types,
|
36651
|
-
(t) => t.typeId === this.jsonFn.output.type
|
36652
|
-
);
|
36688
|
+
const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
36653
36689
|
if (outputAbiType.type === "()") {
|
36654
36690
|
return [void 0, 0];
|
36655
36691
|
}
|
36656
36692
|
const bytes3 = arrayify(data);
|
36657
|
-
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output
|
36693
|
+
const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
|
36694
|
+
encoding: this.encoding
|
36695
|
+
});
|
36658
36696
|
return coder.decode(bytes3, 0);
|
36659
36697
|
}
|
36698
|
+
/**
|
36699
|
+
* Checks if the function is read-only i.e. it only reads from storage, does not write to it.
|
36700
|
+
*
|
36701
|
+
* @returns True if the function is read-only or pure, false otherwise.
|
36702
|
+
*/
|
36703
|
+
isReadOnly() {
|
36704
|
+
const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
|
36705
|
+
return !storageAttribute?.arguments.includes("write");
|
36706
|
+
}
|
36660
36707
|
};
|
36661
36708
|
var Interface = class {
|
36662
36709
|
functions;
|
@@ -36687,16 +36734,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36687
36734
|
}
|
36688
36735
|
decodeFunctionData(functionFragment, data) {
|
36689
36736
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
36690
|
-
if (!fragment) {
|
36691
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
36692
|
-
}
|
36693
36737
|
return fragment.decodeArguments(data);
|
36694
36738
|
}
|
36695
36739
|
encodeFunctionData(functionFragment, values, offset = 0) {
|
36696
36740
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
36697
|
-
if (!fragment) {
|
36698
|
-
throw new FuelError(ErrorCode.FRAGMENT_NOT_FOUND, "Fragment not found.");
|
36699
|
-
}
|
36700
36741
|
return fragment.encodeArguments(values, offset);
|
36701
36742
|
}
|
36702
36743
|
// Decode the result of a function call
|
@@ -36705,37 +36746,33 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
36705
36746
|
return fragment.decodeOutput(data);
|
36706
36747
|
}
|
36707
36748
|
decodeLog(data, logId) {
|
36708
|
-
const
|
36709
|
-
|
36749
|
+
const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
|
36750
|
+
if (!loggedType) {
|
36751
|
+
throw new FuelError(
|
36752
|
+
ErrorCode.LOG_TYPE_NOT_FOUND,
|
36753
|
+
`Log type with logId '${logId}' doesn't exist in the ABI.`
|
36754
|
+
);
|
36755
|
+
}
|
36756
|
+
return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
|
36710
36757
|
encoding: this.jsonAbi.encoding
|
36711
36758
|
});
|
36712
36759
|
}
|
36713
36760
|
encodeConfigurable(name, value) {
|
36714
|
-
const configurable =
|
36715
|
-
|
36716
|
-
|
36717
|
-
|
36718
|
-
|
36719
|
-
|
36720
|
-
|
36721
|
-
);
|
36722
|
-
}
|
36723
|
-
);
|
36761
|
+
const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
|
36762
|
+
if (!configurable) {
|
36763
|
+
throw new FuelError(
|
36764
|
+
ErrorCode.CONFIGURABLE_NOT_FOUND,
|
36765
|
+
`A configurable with the '${name}' was not found in the ABI.`
|
36766
|
+
);
|
36767
|
+
}
|
36724
36768
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
36725
|
-
isRightPadded: true
|
36769
|
+
isRightPadded: true,
|
36770
|
+
// TODO: Review support for configurables in v1 encoding when it becomes available
|
36771
|
+
encoding: ENCODING_V0
|
36726
36772
|
});
|
36727
36773
|
}
|
36728
36774
|
getTypeById(typeId) {
|
36729
|
-
return
|
36730
|
-
this.jsonAbi.types,
|
36731
|
-
(t) => t.typeId === typeId,
|
36732
|
-
() => {
|
36733
|
-
throw new FuelError(
|
36734
|
-
ErrorCode.TYPE_NOT_FOUND,
|
36735
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
36736
|
-
);
|
36737
|
-
}
|
36738
|
-
);
|
36775
|
+
return findTypeById(this.jsonAbi, typeId);
|
36739
36776
|
}
|
36740
36777
|
};
|
36741
36778
|
|
@@ -37425,7 +37462,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37425
37462
|
return [receiptMessageOut, o];
|
37426
37463
|
}
|
37427
37464
|
};
|
37428
|
-
var
|
37465
|
+
var getMintedAssetId = (contractId, subId) => {
|
37429
37466
|
const contractIdBytes = arrayify(contractId);
|
37430
37467
|
const subIdBytes = arrayify(subId);
|
37431
37468
|
return sha2563(concat([contractIdBytes, subIdBytes]));
|
@@ -37435,7 +37472,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37435
37472
|
super("ReceiptMint", "struct ReceiptMint", 0);
|
37436
37473
|
}
|
37437
37474
|
static getAssetId(contractId, subId) {
|
37438
|
-
return
|
37475
|
+
return getMintedAssetId(contractId, subId);
|
37439
37476
|
}
|
37440
37477
|
encode(value) {
|
37441
37478
|
const parts = [];
|
@@ -37477,7 +37514,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
37477
37514
|
super("ReceiptBurn", "struct ReceiptBurn", 0);
|
37478
37515
|
}
|
37479
37516
|
static getAssetId(contractId, subId) {
|
37480
|
-
return
|
37517
|
+
return getMintedAssetId(contractId, subId);
|
37481
37518
|
}
|
37482
37519
|
encode(value) {
|
37483
37520
|
const parts = [];
|
@@ -42189,36 +42226,45 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42189
42226
|
});
|
42190
42227
|
this.stream = response.body.getReader();
|
42191
42228
|
}
|
42229
|
+
events = [];
|
42230
|
+
parsingLeftover = "";
|
42192
42231
|
async next() {
|
42193
42232
|
if (!this.stream) {
|
42194
42233
|
await this.setStream();
|
42195
42234
|
}
|
42196
42235
|
while (true) {
|
42236
|
+
if (this.events.length > 0) {
|
42237
|
+
const { data, errors } = this.events.shift();
|
42238
|
+
if (Array.isArray(errors)) {
|
42239
|
+
throw new FuelError(
|
42240
|
+
FuelError.CODES.INVALID_REQUEST,
|
42241
|
+
errors.map((err) => err.message).join("\n\n")
|
42242
|
+
);
|
42243
|
+
}
|
42244
|
+
return { value: data, done: false };
|
42245
|
+
}
|
42197
42246
|
const { value, done } = await this.stream.read();
|
42198
42247
|
if (done) {
|
42199
42248
|
return { value, done };
|
42200
42249
|
}
|
42201
|
-
const
|
42202
|
-
if (
|
42250
|
+
const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
|
42251
|
+
if (decoded === "") {
|
42203
42252
|
continue;
|
42204
42253
|
}
|
42205
|
-
|
42206
|
-
|
42207
|
-
|
42208
|
-
|
42209
|
-
|
42210
|
-
|
42211
|
-
|
42212
|
-
|
42213
|
-
|
42214
|
-
|
42215
|
-
|
42216
|
-
|
42217
|
-
|
42218
|
-
|
42219
|
-
);
|
42220
|
-
}
|
42221
|
-
return { value: data, done: false };
|
42254
|
+
const text = `${this.parsingLeftover}${decoded}`;
|
42255
|
+
const regex = /data:.*\n\n/g;
|
42256
|
+
const matches = [...text.matchAll(regex)].flatMap((match) => match);
|
42257
|
+
matches.forEach((match) => {
|
42258
|
+
try {
|
42259
|
+
this.events.push(JSON.parse(match.replace(/^data:/, "")));
|
42260
|
+
} catch (e) {
|
42261
|
+
throw new FuelError(
|
42262
|
+
ErrorCode.STREAM_PARSING_ERROR,
|
42263
|
+
`Error while parsing stream data response: ${text}`
|
42264
|
+
);
|
42265
|
+
}
|
42266
|
+
});
|
42267
|
+
this.parsingLeftover = text.replace(matches.join(), "");
|
42222
42268
|
}
|
42223
42269
|
}
|
42224
42270
|
/**
|
@@ -42302,8 +42348,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42302
42348
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
42303
42349
|
return {
|
42304
42350
|
type: InputType.Coin,
|
42305
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
42306
|
-
outputIndex: arrayify(value.id)
|
42351
|
+
txID: hexlify(arrayify(value.id).slice(0, BYTES_32)),
|
42352
|
+
outputIndex: toNumber2(arrayify(value.id).slice(BYTES_32, UTXO_ID_LEN)),
|
42307
42353
|
owner: hexlify(value.owner),
|
42308
42354
|
amount: bn(value.amount),
|
42309
42355
|
assetId: hexlify(value.assetId),
|
@@ -42424,7 +42470,60 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42424
42470
|
var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
|
42425
42471
|
var MAX_PREDICATE_LENGTH = 1024 * 1024;
|
42426
42472
|
var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
|
42473
|
+
var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
|
42427
42474
|
var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
|
42475
|
+
var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
|
42476
|
+
var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
|
42477
|
+
var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
|
42478
|
+
var PANIC_REASONS = [
|
42479
|
+
"UnknownPanicReason",
|
42480
|
+
"Revert",
|
42481
|
+
"OutOfGas",
|
42482
|
+
"TransactionValidity",
|
42483
|
+
"MemoryOverflow",
|
42484
|
+
"ArithmeticOverflow",
|
42485
|
+
"ContractNotFound",
|
42486
|
+
"MemoryOwnership",
|
42487
|
+
"NotEnoughBalance",
|
42488
|
+
"ExpectedInternalContext",
|
42489
|
+
"AssetIdNotFound",
|
42490
|
+
"InputNotFound",
|
42491
|
+
"OutputNotFound",
|
42492
|
+
"WitnessNotFound",
|
42493
|
+
"TransactionMaturity",
|
42494
|
+
"InvalidMetadataIdentifier",
|
42495
|
+
"MalformedCallStructure",
|
42496
|
+
"ReservedRegisterNotWritable",
|
42497
|
+
"InvalidFlags",
|
42498
|
+
"InvalidImmediateValue",
|
42499
|
+
"ExpectedCoinInput",
|
42500
|
+
"EcalError",
|
42501
|
+
"MemoryWriteOverlap",
|
42502
|
+
"ContractNotInInputs",
|
42503
|
+
"InternalBalanceOverflow",
|
42504
|
+
"ContractMaxSize",
|
42505
|
+
"ExpectedUnallocatedStack",
|
42506
|
+
"MaxStaticContractsReached",
|
42507
|
+
"TransferAmountCannotBeZero",
|
42508
|
+
"ExpectedOutputVariable",
|
42509
|
+
"ExpectedParentInternalContext",
|
42510
|
+
"PredicateReturnedNonOne",
|
42511
|
+
"ContractIdAlreadyDeployed",
|
42512
|
+
"ContractMismatch",
|
42513
|
+
"MessageDataTooLong",
|
42514
|
+
"ArithmeticError",
|
42515
|
+
"ContractInstructionNotAllowed",
|
42516
|
+
"TransferZeroCoins",
|
42517
|
+
"InvalidInstruction",
|
42518
|
+
"MemoryNotExecutable",
|
42519
|
+
"PolicyIsNotSet",
|
42520
|
+
"PolicyNotFound",
|
42521
|
+
"TooManyReceipts",
|
42522
|
+
"BalanceOverflow",
|
42523
|
+
"InvalidBlockHeight",
|
42524
|
+
"TooManySlots"
|
42525
|
+
];
|
42526
|
+
var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
|
42428
42527
|
|
42429
42528
|
// src/providers/utils/receipts.ts
|
42430
42529
|
var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
|
@@ -42737,6 +42836,74 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
42737
42836
|
});
|
42738
42837
|
}
|
42739
42838
|
|
42839
|
+
// src/providers/utils/extract-tx-error.ts
|
42840
|
+
var assemblePanicError = (status) => {
|
42841
|
+
let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
|
42842
|
+
const reason = status.reason;
|
42843
|
+
if (PANIC_REASONS.includes(status.reason)) {
|
42844
|
+
errorMessage = `${errorMessage}
|
42845
|
+
|
42846
|
+
You can read more about this error at:
|
42847
|
+
|
42848
|
+
${PANIC_DOC_URL}#variant.${status.reason}`;
|
42849
|
+
}
|
42850
|
+
return { errorMessage, reason };
|
42851
|
+
};
|
42852
|
+
var stringify2 = (obj) => JSON.stringify(obj, null, 2);
|
42853
|
+
var assembleRevertError = (receipts, logs) => {
|
42854
|
+
let errorMessage = "The transaction reverted with an unknown reason.";
|
42855
|
+
const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42856
|
+
let reason = "";
|
42857
|
+
if (revertReceipt) {
|
42858
|
+
const reasonHex = bn(revertReceipt.val).toHex();
|
42859
|
+
switch (reasonHex) {
|
42860
|
+
case FAILED_REQUIRE_SIGNAL: {
|
42861
|
+
reason = "require";
|
42862
|
+
errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
|
42863
|
+
break;
|
42864
|
+
}
|
42865
|
+
case FAILED_ASSERT_EQ_SIGNAL: {
|
42866
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42867
|
+
reason = "assert_eq";
|
42868
|
+
errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
|
42869
|
+
break;
|
42870
|
+
}
|
42871
|
+
case FAILED_ASSERT_NE_SIGNAL: {
|
42872
|
+
const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
|
42873
|
+
reason = "assert_ne";
|
42874
|
+
errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
|
42875
|
+
break;
|
42876
|
+
}
|
42877
|
+
case FAILED_ASSERT_SIGNAL:
|
42878
|
+
reason = "assert";
|
42879
|
+
errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
|
42880
|
+
break;
|
42881
|
+
case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
|
42882
|
+
reason = "MissingOutputChange";
|
42883
|
+
errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
|
42884
|
+
break;
|
42885
|
+
default:
|
42886
|
+
reason = "unknown";
|
42887
|
+
errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
|
42888
|
+
}
|
42889
|
+
}
|
42890
|
+
return { errorMessage, reason };
|
42891
|
+
};
|
42892
|
+
var extractTxError = (params) => {
|
42893
|
+
const { receipts, status, logs } = params;
|
42894
|
+
const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
|
42895
|
+
const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
|
42896
|
+
const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
|
42897
|
+
const metadata = {
|
42898
|
+
logs,
|
42899
|
+
receipts,
|
42900
|
+
panic: isPanic,
|
42901
|
+
revert: isRevert,
|
42902
|
+
reason
|
42903
|
+
};
|
42904
|
+
return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
|
42905
|
+
};
|
42906
|
+
|
42740
42907
|
// src/providers/transaction-request/errors.ts
|
42741
42908
|
var NoWitnessAtIndexError = class extends Error {
|
42742
42909
|
constructor(index) {
|
@@ -43005,8 +43172,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43005
43172
|
assetId,
|
43006
43173
|
txPointer: "0x00000000000000000000000000000000",
|
43007
43174
|
witnessIndex,
|
43008
|
-
predicate: predicate?.bytes
|
43009
|
-
predicateData: predicate?.predicateDataBytes
|
43175
|
+
predicate: predicate?.bytes
|
43010
43176
|
};
|
43011
43177
|
this.pushInput(input);
|
43012
43178
|
this.addChangeOutput(owner, assetId);
|
@@ -43038,8 +43204,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43038
43204
|
recipient: recipient.toB256(),
|
43039
43205
|
amount,
|
43040
43206
|
witnessIndex,
|
43041
|
-
predicate: predicate?.bytes
|
43042
|
-
predicateData: predicate?.predicateDataBytes
|
43207
|
+
predicate: predicate?.bytes
|
43043
43208
|
};
|
43044
43209
|
this.pushInput(input);
|
43045
43210
|
this.addChangeOutput(recipient, assetId);
|
@@ -43194,12 +43359,6 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43194
43359
|
* @param quantities - CoinQuantity Array.
|
43195
43360
|
*/
|
43196
43361
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
43197
|
-
let idCounter = 0;
|
43198
|
-
const generateId = () => {
|
43199
|
-
const counterString = String(idCounter++);
|
43200
|
-
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
43201
|
-
return id;
|
43202
|
-
};
|
43203
43362
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
43204
43363
|
if ("assetId" in input) {
|
43205
43364
|
return input.assetId === assetId;
|
@@ -43209,12 +43368,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
43209
43368
|
const updateAssetInput = (assetId, quantity) => {
|
43210
43369
|
const assetInput = findAssetInput(assetId);
|
43211
43370
|
if (assetInput && "assetId" in assetInput) {
|
43212
|
-
assetInput.id =
|
43371
|
+
assetInput.id = hexlify(randomBytes22(UTXO_ID_LEN));
|
43213
43372
|
assetInput.amount = quantity;
|
43214
43373
|
} else {
|
43215
43374
|
this.addResources([
|
43216
43375
|
{
|
43217
|
-
id:
|
43376
|
+
id: hexlify(randomBytes22(UTXO_ID_LEN)),
|
43218
43377
|
amount: quantity,
|
43219
43378
|
assetId,
|
43220
43379
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -44494,14 +44653,26 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44494
44653
|
gqlTransaction: this.gqlTransaction,
|
44495
44654
|
...transactionSummary
|
44496
44655
|
};
|
44656
|
+
let logs = [];
|
44497
44657
|
if (this.abis) {
|
44498
|
-
|
44658
|
+
logs = getDecodedLogs(
|
44499
44659
|
transactionSummary.receipts,
|
44500
44660
|
this.abis.main,
|
44501
44661
|
this.abis.otherContractsAbis
|
44502
44662
|
);
|
44503
44663
|
transactionResult.logs = logs;
|
44504
44664
|
}
|
44665
|
+
if (transactionResult.isStatusFailure) {
|
44666
|
+
const {
|
44667
|
+
receipts,
|
44668
|
+
gqlTransaction: { status }
|
44669
|
+
} = transactionResult;
|
44670
|
+
throw extractTxError({
|
44671
|
+
receipts,
|
44672
|
+
status,
|
44673
|
+
logs
|
44674
|
+
});
|
44675
|
+
}
|
44505
44676
|
return transactionResult;
|
44506
44677
|
}
|
44507
44678
|
/**
|
@@ -44510,14 +44681,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44510
44681
|
* @param contractsAbiMap - The contracts ABI map.
|
44511
44682
|
*/
|
44512
44683
|
async wait(contractsAbiMap) {
|
44513
|
-
|
44514
|
-
if (result.isStatusFailure) {
|
44515
|
-
throw new FuelError(
|
44516
|
-
ErrorCode.TRANSACTION_FAILED,
|
44517
|
-
`Transaction failed: ${result.gqlTransaction.status.reason}`
|
44518
|
-
);
|
44519
|
-
}
|
44520
|
-
return result;
|
44684
|
+
return this.waitForResult(contractsAbiMap);
|
44521
44685
|
}
|
44522
44686
|
};
|
44523
44687
|
|
@@ -44988,6 +45152,36 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
44988
45152
|
missingContractIds
|
44989
45153
|
};
|
44990
45154
|
}
|
45155
|
+
/**
|
45156
|
+
* Estimates the transaction gas and fee based on the provided transaction request.
|
45157
|
+
* @param transactionRequest - The transaction request object.
|
45158
|
+
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
45159
|
+
*/
|
45160
|
+
estimateTxGasAndFee(params) {
|
45161
|
+
const { transactionRequest } = params;
|
45162
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
45163
|
+
const chainInfo = this.getChain();
|
45164
|
+
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
45165
|
+
transactionRequest.gasPrice = gasPrice;
|
45166
|
+
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
45167
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45168
|
+
if (transactionRequest.type === TransactionType.Script) {
|
45169
|
+
if (transactionRequest.gasLimit.eq(0)) {
|
45170
|
+
transactionRequest.gasLimit = minGas;
|
45171
|
+
transactionRequest.gasLimit = maxGasPerTx.sub(
|
45172
|
+
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
45173
|
+
);
|
45174
|
+
}
|
45175
|
+
}
|
45176
|
+
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
45177
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45178
|
+
return {
|
45179
|
+
minGas,
|
45180
|
+
minFee,
|
45181
|
+
maxGas,
|
45182
|
+
maxFee
|
45183
|
+
};
|
45184
|
+
}
|
44991
45185
|
/**
|
44992
45186
|
* Executes a signed transaction without applying the states changes
|
44993
45187
|
* on the chain.
|
@@ -45035,17 +45229,16 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45035
45229
|
signatureCallback
|
45036
45230
|
} = {}) {
|
45037
45231
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
45038
|
-
const
|
45039
|
-
const
|
45040
|
-
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45232
|
+
const { minGasPrice } = this.getGasConfig();
|
45233
|
+
const setGasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
45041
45234
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
45042
45235
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
45043
45236
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
45044
45237
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
45238
|
+
if (isScriptTransaction) {
|
45239
|
+
txRequestClone.gasLimit = bn(0);
|
45240
|
+
}
|
45045
45241
|
if (estimatePredicates) {
|
45046
|
-
if (isScriptTransaction) {
|
45047
|
-
txRequestClone.gasLimit = bn(0);
|
45048
|
-
}
|
45049
45242
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
45050
45243
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
45051
45244
|
}
|
@@ -45054,36 +45247,34 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
45054
45247
|
if (signatureCallback && isScriptTransaction) {
|
45055
45248
|
await signatureCallback(txRequestClone);
|
45056
45249
|
}
|
45057
|
-
|
45058
|
-
|
45250
|
+
let { maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45251
|
+
transactionRequest: txRequestClone
|
45252
|
+
});
|
45059
45253
|
let receipts = [];
|
45060
45254
|
let missingContractIds = [];
|
45061
45255
|
let outputVariables = 0;
|
45256
|
+
let gasUsed = bn(0);
|
45062
45257
|
if (isScriptTransaction && estimateTxDependencies) {
|
45063
45258
|
txRequestClone.gasPrice = bn(0);
|
45064
|
-
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
45065
45259
|
const result = await this.estimateTxDependencies(txRequestClone);
|
45066
45260
|
receipts = result.receipts;
|
45067
45261
|
outputVariables = result.outputVariables;
|
45068
45262
|
missingContractIds = result.missingContractIds;
|
45263
|
+
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
45264
|
+
txRequestClone.gasLimit = gasUsed;
|
45265
|
+
txRequestClone.gasPrice = setGasPrice;
|
45266
|
+
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
45267
|
+
transactionRequest: txRequestClone
|
45268
|
+
}));
|
45069
45269
|
}
|
45070
|
-
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
45071
|
-
const usedFee = calculatePriceWithFactor(
|
45072
|
-
gasUsed,
|
45073
|
-
gasPrice,
|
45074
|
-
gasPriceFactor
|
45075
|
-
).normalizeZeroToOne();
|
45076
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45077
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
45078
45270
|
return {
|
45079
45271
|
requiredQuantities: allQuantities,
|
45080
45272
|
receipts,
|
45081
45273
|
gasUsed,
|
45082
45274
|
minGasPrice,
|
45083
|
-
gasPrice,
|
45275
|
+
gasPrice: setGasPrice,
|
45084
45276
|
minGas,
|
45085
45277
|
maxGas,
|
45086
|
-
usedFee,
|
45087
45278
|
minFee,
|
45088
45279
|
maxFee,
|
45089
45280
|
estimatedInputs: txRequestClone.inputs,
|
@@ -47369,12 +47560,12 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47369
47560
|
};
|
47370
47561
|
|
47371
47562
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
47372
|
-
var
|
47563
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
47373
47564
|
var rnds8Pool = new Uint8Array(256);
|
47374
47565
|
var poolPtr = rnds8Pool.length;
|
47375
47566
|
function rng() {
|
47376
47567
|
if (poolPtr > rnds8Pool.length - 16) {
|
47377
|
-
|
47568
|
+
import_crypto16.default.randomFillSync(rnds8Pool);
|
47378
47569
|
poolPtr = 0;
|
47379
47570
|
}
|
47380
47571
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -47390,9 +47581,9 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
47390
47581
|
}
|
47391
47582
|
|
47392
47583
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
47393
|
-
var
|
47584
|
+
var import_crypto17 = __toESM(__require("crypto"));
|
47394
47585
|
var native_default = {
|
47395
|
-
randomUUID:
|
47586
|
+
randomUUID: import_crypto17.default.randomUUID
|
47396
47587
|
};
|
47397
47588
|
|
47398
47589
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -50372,7 +50563,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50372
50563
|
|
50373
50564
|
// src/test-utils/launchNode.ts
|
50374
50565
|
var import_child_process = __require("child_process");
|
50375
|
-
var
|
50566
|
+
var import_crypto21 = __require("crypto");
|
50376
50567
|
var import_fs2 = __require("fs");
|
50377
50568
|
var import_os = __toESM(__require("os"));
|
50378
50569
|
var import_path8 = __toESM(__require("path"));
|
@@ -50444,7 +50635,7 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
50444
50635
|
})).toString();
|
50445
50636
|
let chainConfigPathToUse;
|
50446
50637
|
const prefix = basePath || import_os.default.tmpdir();
|
50447
|
-
const suffix = basePath ? "" : (0,
|
50638
|
+
const suffix = basePath ? "" : (0, import_crypto21.randomUUID)();
|
50448
50639
|
const tempDirPath = import_path8.default.join(prefix, ".fuels", suffix);
|
50449
50640
|
if (chainConfigPath) {
|
50450
50641
|
chainConfigPathToUse = chainConfigPath;
|