@fuel-ts/account 0.0.0-rc-1832-20240415161726 → 0.0.0-rc-2040-20240415161844
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of @fuel-ts/account might be problematic. Click here for more details.
- package/dist/index.global.js +84 -88
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +2 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -5
- 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/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/test-utils.global.js +84 -87
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +2 -4
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +2 -4
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -29015,6 +29015,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
29015
29015
|
ErrorCode2["INVALID_COMPONENT"] = "invalid-component";
|
29016
29016
|
ErrorCode2["CONFIGURABLE_NOT_FOUND"] = "configurable-not-found";
|
29017
29017
|
ErrorCode2["TYPE_NOT_FOUND"] = "type-not-found";
|
29018
|
+
ErrorCode2["LOG_TYPE_NOT_FOUND"] = "log-type-not-found";
|
29018
29019
|
ErrorCode2["TYPE_NOT_SUPPORTED"] = "type-not-supported";
|
29019
29020
|
ErrorCode2["INVALID_DECODE_VALUE"] = "invalid-decode-value";
|
29020
29021
|
ErrorCode2["JSON_ABI_ERROR"] = "json-abi-error";
|
@@ -31279,7 +31280,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31279
31280
|
var import_bn = __toESM(require_bn(), 1);
|
31280
31281
|
var DEFAULT_PRECISION = 9;
|
31281
31282
|
var DEFAULT_MIN_PRECISION = 3;
|
31282
|
-
var
|
31283
|
+
var DEFAULT_DECIMAL_UNITS = 9;
|
31283
31284
|
function toFixed(value, options) {
|
31284
31285
|
const { precision = DEFAULT_PRECISION, minPrecision = DEFAULT_MIN_PRECISION } = options || {};
|
31285
31286
|
const [valueUnits = "0", valueDecimals = "0"] = String(value || "0.0").split(".");
|
@@ -31345,7 +31346,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31345
31346
|
}
|
31346
31347
|
format(options) {
|
31347
31348
|
const {
|
31348
|
-
units =
|
31349
|
+
units = DEFAULT_DECIMAL_UNITS,
|
31349
31350
|
precision = DEFAULT_PRECISION,
|
31350
31351
|
minPrecision = DEFAULT_MIN_PRECISION
|
31351
31352
|
} = options || {};
|
@@ -31361,7 +31362,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31361
31362
|
}
|
31362
31363
|
return formattedFixed;
|
31363
31364
|
}
|
31364
|
-
formatUnits(units =
|
31365
|
+
formatUnits(units = DEFAULT_DECIMAL_UNITS) {
|
31365
31366
|
const valueUnits = this.toString().slice(0, units * -1);
|
31366
31367
|
const valueDecimals = this.toString().slice(units * -1);
|
31367
31368
|
const length = valueDecimals.length;
|
@@ -31470,7 +31471,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31470
31471
|
// END ANCHOR: OVERRIDES to avoid losing references
|
31471
31472
|
};
|
31472
31473
|
var bn = (value, base, endian) => new BN(value, base, endian);
|
31473
|
-
bn.parseUnits = (value, units =
|
31474
|
+
bn.parseUnits = (value, units = DEFAULT_DECIMAL_UNITS) => {
|
31474
31475
|
const valueToParse = value === "." ? "0." : value;
|
31475
31476
|
const [valueUnits = "0", valueDecimals = "0"] = valueToParse.split(".");
|
31476
31477
|
const length = valueDecimals.length;
|
@@ -31754,15 +31755,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31754
31755
|
}
|
31755
31756
|
};
|
31756
31757
|
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
31757
|
-
function findOrThrow(arr, predicate, throwFn = () => {
|
31758
|
-
throw new FuelError(ErrorCode.ELEMENT_NOT_FOUND, "Element not found in the array.");
|
31759
|
-
}) {
|
31760
|
-
const found = arr.find(predicate);
|
31761
|
-
if (found === void 0) {
|
31762
|
-
throwFn();
|
31763
|
-
}
|
31764
|
-
return found;
|
31765
|
-
}
|
31766
31758
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31767
31759
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31768
31760
|
var rightPadToWordSize = (encoded) => {
|
@@ -31772,6 +31764,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31772
31764
|
const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
|
31773
31765
|
return concatBytes2([encoded, padding]);
|
31774
31766
|
};
|
31767
|
+
var isUint8Array = (value) => value instanceof Uint8Array;
|
31775
31768
|
var ArrayCoder = class extends Coder {
|
31776
31769
|
coder;
|
31777
31770
|
length;
|
@@ -32313,8 +32306,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32313
32306
|
this.coder = coder;
|
32314
32307
|
}
|
32315
32308
|
encode(value) {
|
32316
|
-
if (!Array.isArray(value)) {
|
32317
|
-
throw new FuelError(
|
32309
|
+
if (!Array.isArray(value) && !isUint8Array(value)) {
|
32310
|
+
throw new FuelError(
|
32311
|
+
ErrorCode.ENCODE_ERROR,
|
32312
|
+
`Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
|
32313
|
+
);
|
32318
32314
|
}
|
32319
32315
|
const parts = [];
|
32320
32316
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
@@ -32345,6 +32341,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32345
32341
|
];
|
32346
32342
|
}
|
32347
32343
|
};
|
32344
|
+
var findFunctionByName = (abi, name) => {
|
32345
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
32346
|
+
if (!fn) {
|
32347
|
+
throw new FuelError(
|
32348
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
32349
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
32350
|
+
);
|
32351
|
+
}
|
32352
|
+
return fn;
|
32353
|
+
};
|
32354
|
+
var findTypeById = (abi, typeId) => {
|
32355
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
32356
|
+
if (!type3) {
|
32357
|
+
throw new FuelError(
|
32358
|
+
ErrorCode.TYPE_NOT_FOUND,
|
32359
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
32360
|
+
);
|
32361
|
+
}
|
32362
|
+
return type3;
|
32363
|
+
};
|
32364
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
32365
|
+
var findVectorBufferArgument = (components) => {
|
32366
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
32367
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
32368
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
32369
|
+
throw new FuelError(
|
32370
|
+
ErrorCode.INVALID_COMPONENT,
|
32371
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
32372
|
+
);
|
32373
|
+
}
|
32374
|
+
return bufferTypeArgument;
|
32375
|
+
};
|
32348
32376
|
var ResolvedAbiType = class {
|
32349
32377
|
abi;
|
32350
32378
|
name;
|
@@ -32353,20 +32381,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32353
32381
|
components;
|
32354
32382
|
constructor(abi, argument) {
|
32355
32383
|
this.abi = abi;
|
32356
|
-
const type3 = findOrThrow(
|
32357
|
-
abi.types,
|
32358
|
-
(t) => t.typeId === argument.type,
|
32359
|
-
() => {
|
32360
|
-
throw new FuelError(
|
32361
|
-
ErrorCode.TYPE_NOT_FOUND,
|
32362
|
-
`Type does not exist in the provided abi: ${JSON.stringify({
|
32363
|
-
argument,
|
32364
|
-
abi: this.abi
|
32365
|
-
})}`
|
32366
|
-
);
|
32367
|
-
}
|
32368
|
-
);
|
32369
32384
|
this.name = argument.name;
|
32385
|
+
const type3 = findTypeById(abi, argument.type);
|
32370
32386
|
this.type = type3.type;
|
32371
32387
|
this.originalTypeArguments = argument.typeArguments;
|
32372
32388
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -32418,7 +32434,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32418
32434
|
)
|
32419
32435
|
};
|
32420
32436
|
}
|
32421
|
-
const argType =
|
32437
|
+
const argType = findTypeById(abi, arg.type);
|
32422
32438
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
32423
32439
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
32424
32440
|
return {
|
@@ -32435,7 +32451,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32435
32451
|
}
|
32436
32452
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32437
32453
|
args.forEach((a) => {
|
32438
|
-
const argType =
|
32454
|
+
const argType = findTypeById(abi, a.type);
|
32439
32455
|
if (genericRegEx.test(argType.type)) {
|
32440
32456
|
implicitGenericParameters.push(argType.typeId);
|
32441
32457
|
return;
|
@@ -32544,13 +32560,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32544
32560
|
return new ArrayCoder(arrayElementCoder, length);
|
32545
32561
|
}
|
32546
32562
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32547
|
-
const arg =
|
32548
|
-
if (!arg) {
|
32549
|
-
throw new FuelError(
|
32550
|
-
ErrorCode.INVALID_COMPONENT,
|
32551
|
-
`The provided Vec type is missing the 'type argument'.`
|
32552
|
-
);
|
32553
|
-
}
|
32563
|
+
const arg = findVectorBufferArgument(components);
|
32554
32564
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32555
32565
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32556
32566
|
return new VecCoder(itemCoder);
|
@@ -33019,13 +33029,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33019
33029
|
return new ArrayCoder(arrayElementCoder, length);
|
33020
33030
|
}
|
33021
33031
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
33022
|
-
const arg =
|
33023
|
-
if (!arg) {
|
33024
|
-
throw new FuelError(
|
33025
|
-
ErrorCode.INVALID_COMPONENT,
|
33026
|
-
`The provided Vec type is missing the 'type argument'.`
|
33027
|
-
);
|
33028
|
-
}
|
33032
|
+
const arg = findVectorBufferArgument(components);
|
33029
33033
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
33030
33034
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
33031
33035
|
return new VecCoder2(itemCoder);
|
@@ -33096,7 +33100,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33096
33100
|
jsonAbi;
|
33097
33101
|
constructor(jsonAbi, name) {
|
33098
33102
|
this.jsonAbi = jsonAbi;
|
33099
|
-
this.jsonFn =
|
33103
|
+
this.jsonFn = findFunctionByName(this.jsonAbi, name);
|
33100
33104
|
this.name = name;
|
33101
33105
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33102
33106
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
@@ -33120,13 +33124,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33120
33124
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
33121
33125
|
}
|
33122
33126
|
#isInputDataPointer() {
|
33123
|
-
const inputTypes = this.jsonFn.inputs.map(
|
33124
|
-
(i) => this.jsonAbi.types.find((t) => t.typeId === i.type)
|
33125
|
-
);
|
33127
|
+
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
33126
33128
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
33127
33129
|
}
|
33128
33130
|
#isOutputDataHeap() {
|
33129
|
-
const outputType =
|
33131
|
+
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33130
33132
|
return isHeapType(outputType?.type || "");
|
33131
33133
|
}
|
33132
33134
|
#getOutputEncodedLength() {
|
@@ -33146,9 +33148,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33146
33148
|
encodeArguments(values, offset = 0) {
|
33147
33149
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
33148
33150
|
const shallowCopyValues = values.slice();
|
33149
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33150
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33151
|
-
);
|
33151
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33152
33152
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
33153
33153
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
33154
33154
|
shallowCopyValues.fill(void 0, values.length);
|
@@ -33169,7 +33169,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33169
33169
|
if (args.length === inputs.length) {
|
33170
33170
|
return;
|
33171
33171
|
}
|
33172
|
-
const inputTypes = inputs.map((
|
33172
|
+
const inputTypes = inputs.map((input) => findTypeById(abi, input.type));
|
33173
33173
|
const optionalInputs = inputTypes.filter(
|
33174
33174
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
33175
33175
|
);
|
@@ -33184,9 +33184,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33184
33184
|
}
|
33185
33185
|
decodeArguments(data) {
|
33186
33186
|
const bytes3 = arrayify(data);
|
33187
|
-
const nonEmptyInputs = this.jsonFn.inputs
|
33188
|
-
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33189
|
-
);
|
33187
|
+
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
33190
33188
|
if (nonEmptyInputs.length === 0) {
|
33191
33189
|
if (bytes3.length === 0) {
|
33192
33190
|
return void 0;
|
@@ -33221,10 +33219,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33221
33219
|
return result.decoded;
|
33222
33220
|
}
|
33223
33221
|
decodeOutput(data) {
|
33224
|
-
const outputAbiType =
|
33225
|
-
this.jsonAbi.types,
|
33226
|
-
(t) => t.typeId === this.jsonFn.output.type
|
33227
|
-
);
|
33222
|
+
const outputAbiType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
33228
33223
|
if (outputAbiType.type === "()") {
|
33229
33224
|
return [void 0, 0];
|
33230
33225
|
}
|
@@ -33234,6 +33229,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33234
33229
|
});
|
33235
33230
|
return coder.decode(bytes3, 0);
|
33236
33231
|
}
|
33232
|
+
/**
|
33233
|
+
* Checks if the function is read-only i.e. it only reads from storage, does not write to it.
|
33234
|
+
*
|
33235
|
+
* @returns True if the function is read-only or pure, false otherwise.
|
33236
|
+
*/
|
33237
|
+
isReadOnly() {
|
33238
|
+
const storageAttribute = this.attributes.find((attr) => attr.name === "storage");
|
33239
|
+
return !storageAttribute?.arguments.includes("write");
|
33240
|
+
}
|
33237
33241
|
};
|
33238
33242
|
var Interface = class {
|
33239
33243
|
functions;
|
@@ -33276,38 +33280,33 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33276
33280
|
return fragment.decodeOutput(data);
|
33277
33281
|
}
|
33278
33282
|
decodeLog(data, logId) {
|
33279
|
-
const
|
33280
|
-
|
33283
|
+
const loggedType = this.jsonAbi.loggedTypes.find((type3) => type3.logId === logId);
|
33284
|
+
if (!loggedType) {
|
33285
|
+
throw new FuelError(
|
33286
|
+
ErrorCode.LOG_TYPE_NOT_FOUND,
|
33287
|
+
`Log type with logId '${logId}' doesn't exist in the ABI.`
|
33288
|
+
);
|
33289
|
+
}
|
33290
|
+
return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
|
33281
33291
|
encoding: this.jsonAbi.encoding
|
33282
33292
|
});
|
33283
33293
|
}
|
33284
33294
|
encodeConfigurable(name, value) {
|
33285
|
-
const configurable =
|
33286
|
-
|
33287
|
-
|
33288
|
-
|
33289
|
-
|
33290
|
-
|
33291
|
-
|
33292
|
-
);
|
33293
|
-
}
|
33294
|
-
);
|
33295
|
+
const configurable = this.jsonAbi.configurables.find((c) => c.name === name);
|
33296
|
+
if (!configurable) {
|
33297
|
+
throw new FuelError(
|
33298
|
+
ErrorCode.CONFIGURABLE_NOT_FOUND,
|
33299
|
+
`A configurable with the '${name}' was not found in the ABI.`
|
33300
|
+
);
|
33301
|
+
}
|
33295
33302
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33296
33303
|
isRightPadded: true,
|
33297
|
-
|
33304
|
+
// TODO: Review support for configurables in v1 encoding when it becomes available
|
33305
|
+
encoding: ENCODING_V0
|
33298
33306
|
});
|
33299
33307
|
}
|
33300
33308
|
getTypeById(typeId) {
|
33301
|
-
return
|
33302
|
-
this.jsonAbi.types,
|
33303
|
-
(t) => t.typeId === typeId,
|
33304
|
-
() => {
|
33305
|
-
throw new FuelError(
|
33306
|
-
ErrorCode.TYPE_NOT_FOUND,
|
33307
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
33308
|
-
);
|
33309
|
-
}
|
33310
|
-
);
|
33309
|
+
return findTypeById(this.jsonAbi, typeId);
|
33311
33310
|
}
|
33312
33311
|
};
|
33313
33312
|
|
@@ -39774,8 +39773,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39774
39773
|
assetId,
|
39775
39774
|
txPointer: "0x00000000000000000000000000000000",
|
39776
39775
|
witnessIndex,
|
39777
|
-
predicate: predicate?.bytes
|
39778
|
-
predicateData: predicate?.predicateDataBytes
|
39776
|
+
predicate: predicate?.bytes
|
39779
39777
|
};
|
39780
39778
|
this.pushInput(input);
|
39781
39779
|
this.addChangeOutput(owner, assetId);
|
@@ -39807,8 +39805,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39807
39805
|
recipient: recipient.toB256(),
|
39808
39806
|
amount,
|
39809
39807
|
witnessIndex,
|
39810
|
-
predicate: predicate?.bytes
|
39811
|
-
predicateData: predicate?.predicateDataBytes
|
39808
|
+
predicate: predicate?.bytes
|
39812
39809
|
};
|
39813
39810
|
this.pushInput(input);
|
39814
39811
|
this.addChangeOutput(recipient, assetId);
|
@@ -47800,7 +47797,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47800
47797
|
// src/predicate/predicate.ts
|
47801
47798
|
var Predicate = class extends Account {
|
47802
47799
|
bytes;
|
47803
|
-
predicateDataBytes = Uint8Array.from([]);
|
47804
47800
|
predicateData = [];
|
47805
47801
|
interface;
|
47806
47802
|
/**
|