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