@fuel-ts/account 0.0.0-rc-2045-20240415152456 → 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 +124 -142
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +75 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -62
- 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/provider.d.ts +2 -13
- 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/test-utils.global.js +125 -144
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +71 -93
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +42 -64
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +16 -16
package/dist/index.global.js
CHANGED
@@ -28952,7 +28952,7 @@ spurious results.`);
|
|
28952
28952
|
// ../versions/dist/index.mjs
|
28953
28953
|
function getBuiltinVersions() {
|
28954
28954
|
return {
|
28955
|
-
FORC: "0.
|
28955
|
+
FORC: "0.49.3",
|
28956
28956
|
FUEL_CORE: "0.22.1",
|
28957
28957
|
FUELS: "0.79.0"
|
28958
28958
|
};
|
@@ -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";
|
@@ -31144,7 +31143,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31144
31143
|
toEvmAddress() {
|
31145
31144
|
const b256Address = toB256(this.bech32Address);
|
31146
31145
|
return {
|
31147
|
-
|
31146
|
+
value: clearFirst12BytesFromB256(b256Address)
|
31148
31147
|
};
|
31149
31148
|
}
|
31150
31149
|
/**
|
@@ -31154,7 +31153,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31154
31153
|
*/
|
31155
31154
|
toAssetId() {
|
31156
31155
|
return {
|
31157
|
-
|
31156
|
+
value: this.toB256()
|
31158
31157
|
};
|
31159
31158
|
}
|
31160
31159
|
/**
|
@@ -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;
|
@@ -31605,7 +31604,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31605
31604
|
var ENCODING_V1 = "1";
|
31606
31605
|
var WORD_SIZE = 8;
|
31607
31606
|
var BYTES_32 = 32;
|
31608
|
-
var UTXO_ID_LEN = BYTES_32 + 1;
|
31609
31607
|
var ASSET_ID_LEN = BYTES_32;
|
31610
31608
|
var ADDRESS_LEN = BYTES_32;
|
31611
31609
|
var NONCE_LEN = BYTES_32;
|
@@ -31756,6 +31754,15 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31756
31754
|
}
|
31757
31755
|
};
|
31758
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
|
+
}
|
31759
31766
|
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31760
31767
|
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31761
31768
|
var rightPadToWordSize = (encoded) => {
|
@@ -31765,7 +31772,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31765
31772
|
const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
|
31766
31773
|
return concatBytes2([encoded, padding]);
|
31767
31774
|
};
|
31768
|
-
var isUint8Array = (value) => value instanceof Uint8Array;
|
31769
31775
|
var ArrayCoder = class extends Coder {
|
31770
31776
|
coder;
|
31771
31777
|
length;
|
@@ -32307,11 +32313,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32307
32313
|
this.coder = coder;
|
32308
32314
|
}
|
32309
32315
|
encode(value) {
|
32310
|
-
if (!Array.isArray(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
|
-
);
|
32316
|
+
if (!Array.isArray(value)) {
|
32317
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
32315
32318
|
}
|
32316
32319
|
const parts = [];
|
32317
32320
|
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
@@ -32342,38 +32345,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32342
32345
|
];
|
32343
32346
|
}
|
32344
32347
|
};
|
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
|
-
};
|
32377
32348
|
var ResolvedAbiType = class {
|
32378
32349
|
abi;
|
32379
32350
|
name;
|
@@ -32382,8 +32353,20 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32382
32353
|
components;
|
32383
32354
|
constructor(abi, argument) {
|
32384
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
|
+
);
|
32385
32369
|
this.name = argument.name;
|
32386
|
-
const type3 = findTypeById(abi, argument.type);
|
32387
32370
|
this.type = type3.type;
|
32388
32371
|
this.originalTypeArguments = argument.typeArguments;
|
32389
32372
|
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
@@ -32435,7 +32418,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32435
32418
|
)
|
32436
32419
|
};
|
32437
32420
|
}
|
32438
|
-
const argType =
|
32421
|
+
const argType = findOrThrow(abi.types, (t) => t.typeId === arg.type);
|
32439
32422
|
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
32440
32423
|
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
32441
32424
|
return {
|
@@ -32452,7 +32435,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32452
32435
|
}
|
32453
32436
|
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32454
32437
|
args.forEach((a) => {
|
32455
|
-
const argType =
|
32438
|
+
const argType = findOrThrow(abi.types, (t) => t.typeId === a.type);
|
32456
32439
|
if (genericRegEx.test(argType.type)) {
|
32457
32440
|
implicitGenericParameters.push(argType.typeId);
|
32458
32441
|
return;
|
@@ -32561,7 +32544,13 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32561
32544
|
return new ArrayCoder(arrayElementCoder, length);
|
32562
32545
|
}
|
32563
32546
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32564
|
-
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
|
+
}
|
32565
32554
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32566
32555
|
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32567
32556
|
return new VecCoder(itemCoder);
|
@@ -33030,7 +33019,13 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33030
33019
|
return new ArrayCoder(arrayElementCoder, length);
|
33031
33020
|
}
|
33032
33021
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
33033
|
-
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
|
+
}
|
33034
33029
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
33035
33030
|
const itemCoder = getCoder2(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
33036
33031
|
return new VecCoder2(itemCoder);
|
@@ -33101,7 +33096,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33101
33096
|
jsonAbi;
|
33102
33097
|
constructor(jsonAbi, name) {
|
33103
33098
|
this.jsonAbi = jsonAbi;
|
33104
|
-
this.jsonFn =
|
33099
|
+
this.jsonFn = findOrThrow(this.jsonAbi.functions, (f2) => f2.name === name);
|
33105
33100
|
this.name = name;
|
33106
33101
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
33107
33102
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
@@ -33125,11 +33120,13 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33125
33120
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
33126
33121
|
}
|
33127
33122
|
#isInputDataPointer() {
|
33128
|
-
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
|
+
);
|
33129
33126
|
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
33130
33127
|
}
|
33131
33128
|
#isOutputDataHeap() {
|
33132
|
-
const outputType =
|
33129
|
+
const outputType = findOrThrow(this.jsonAbi.types, (t) => t.typeId === this.jsonFn.output.type);
|
33133
33130
|
return isHeapType(outputType?.type || "");
|
33134
33131
|
}
|
33135
33132
|
#getOutputEncodedLength() {
|
@@ -33149,7 +33146,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33149
33146
|
encodeArguments(values, offset = 0) {
|
33150
33147
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
33151
33148
|
const shallowCopyValues = values.slice();
|
33152
|
-
const nonEmptyInputs =
|
33149
|
+
const nonEmptyInputs = this.jsonFn.inputs.filter(
|
33150
|
+
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33151
|
+
);
|
33153
33152
|
if (Array.isArray(values) && nonEmptyInputs.length !== values.length) {
|
33154
33153
|
shallowCopyValues.length = this.jsonFn.inputs.length;
|
33155
33154
|
shallowCopyValues.fill(void 0, values.length);
|
@@ -33170,7 +33169,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33170
33169
|
if (args.length === inputs.length) {
|
33171
33170
|
return;
|
33172
33171
|
}
|
33173
|
-
const inputTypes = inputs.map((
|
33172
|
+
const inputTypes = inputs.map((i) => findOrThrow(abi.types, (t) => t.typeId === i.type));
|
33174
33173
|
const optionalInputs = inputTypes.filter(
|
33175
33174
|
(x) => x.type === OPTION_CODER_TYPE || x.type === "()"
|
33176
33175
|
);
|
@@ -33185,7 +33184,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33185
33184
|
}
|
33186
33185
|
decodeArguments(data) {
|
33187
33186
|
const bytes3 = arrayify(data);
|
33188
|
-
const nonEmptyInputs =
|
33187
|
+
const nonEmptyInputs = this.jsonFn.inputs.filter(
|
33188
|
+
(x) => findOrThrow(this.jsonAbi.types, (t) => t.typeId === x.type).type !== "()"
|
33189
|
+
);
|
33189
33190
|
if (nonEmptyInputs.length === 0) {
|
33190
33191
|
if (bytes3.length === 0) {
|
33191
33192
|
return void 0;
|
@@ -33220,7 +33221,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33220
33221
|
return result.decoded;
|
33221
33222
|
}
|
33222
33223
|
decodeOutput(data) {
|
33223
|
-
const outputAbiType =
|
33224
|
+
const outputAbiType = findOrThrow(
|
33225
|
+
this.jsonAbi.types,
|
33226
|
+
(t) => t.typeId === this.jsonFn.output.type
|
33227
|
+
);
|
33224
33228
|
if (outputAbiType.type === "()") {
|
33225
33229
|
return [void 0, 0];
|
33226
33230
|
}
|
@@ -33230,15 +33234,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33230
33234
|
});
|
33231
33235
|
return coder.decode(bytes3, 0);
|
33232
33236
|
}
|
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
|
-
}
|
33242
33237
|
};
|
33243
33238
|
var Interface = class {
|
33244
33239
|
functions;
|
@@ -33281,33 +33276,38 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33281
33276
|
return fragment.decodeOutput(data);
|
33282
33277
|
}
|
33283
33278
|
decodeLog(data, logId) {
|
33284
|
-
const loggedType = this.jsonAbi.loggedTypes
|
33285
|
-
|
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, {
|
33279
|
+
const { loggedType } = findOrThrow(this.jsonAbi.loggedTypes, (type3) => type3.logId === logId);
|
33280
|
+
return AbiCoder.decode(this.jsonAbi, loggedType, arrayify(data), 0, {
|
33292
33281
|
encoding: this.jsonAbi.encoding
|
33293
33282
|
});
|
33294
33283
|
}
|
33295
33284
|
encodeConfigurable(name, value) {
|
33296
|
-
const configurable =
|
33297
|
-
|
33298
|
-
|
33299
|
-
|
33300
|
-
|
33301
|
-
|
33302
|
-
|
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
|
+
);
|
33303
33295
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
33304
33296
|
isRightPadded: true,
|
33305
|
-
|
33306
|
-
encoding: ENCODING_V0
|
33297
|
+
encoding: this.jsonAbi.encoding
|
33307
33298
|
});
|
33308
33299
|
}
|
33309
33300
|
getTypeById(typeId) {
|
33310
|
-
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
|
+
);
|
33311
33311
|
}
|
33312
33312
|
};
|
33313
33313
|
|
@@ -38874,8 +38874,8 @@ ${MessageCoinFragmentFragmentDoc}`;
|
|
38874
38874
|
const predicateData = arrayify(value.predicateData ?? "0x");
|
38875
38875
|
return {
|
38876
38876
|
type: InputType.Coin,
|
38877
|
-
txID: hexlify(arrayify(value.id).slice(0,
|
38878
|
-
outputIndex:
|
38877
|
+
txID: hexlify(arrayify(value.id).slice(0, 32)),
|
38878
|
+
outputIndex: arrayify(value.id)[32],
|
38879
38879
|
owner: hexlify(value.owner),
|
38880
38880
|
amount: bn(value.amount),
|
38881
38881
|
assetId: hexlify(value.assetId),
|
@@ -39774,7 +39774,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39774
39774
|
assetId,
|
39775
39775
|
txPointer: "0x00000000000000000000000000000000",
|
39776
39776
|
witnessIndex,
|
39777
|
-
predicate: predicate?.bytes
|
39777
|
+
predicate: predicate?.bytes,
|
39778
|
+
predicateData: predicate?.predicateDataBytes
|
39778
39779
|
};
|
39779
39780
|
this.pushInput(input);
|
39780
39781
|
this.addChangeOutput(owner, assetId);
|
@@ -39806,7 +39807,8 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39806
39807
|
recipient: recipient.toB256(),
|
39807
39808
|
amount,
|
39808
39809
|
witnessIndex,
|
39809
|
-
predicate: predicate?.bytes
|
39810
|
+
predicate: predicate?.bytes,
|
39811
|
+
predicateData: predicate?.predicateDataBytes
|
39810
39812
|
};
|
39811
39813
|
this.pushInput(input);
|
39812
39814
|
this.addChangeOutput(recipient, assetId);
|
@@ -39961,6 +39963,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39961
39963
|
* @param quantities - CoinQuantity Array.
|
39962
39964
|
*/
|
39963
39965
|
fundWithFakeUtxos(quantities, resourcesOwner) {
|
39966
|
+
let idCounter = 0;
|
39967
|
+
const generateId = () => {
|
39968
|
+
const counterString = String(idCounter++);
|
39969
|
+
const id = ZeroBytes32.slice(0, -counterString.length).concat(counterString);
|
39970
|
+
return id;
|
39971
|
+
};
|
39964
39972
|
const findAssetInput = (assetId) => this.inputs.find((input) => {
|
39965
39973
|
if ("assetId" in input) {
|
39966
39974
|
return input.assetId === assetId;
|
@@ -39970,12 +39978,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39970
39978
|
const updateAssetInput = (assetId, quantity) => {
|
39971
39979
|
const assetInput = findAssetInput(assetId);
|
39972
39980
|
if (assetInput && "assetId" in assetInput) {
|
39973
|
-
assetInput.id =
|
39981
|
+
assetInput.id = generateId();
|
39974
39982
|
assetInput.amount = quantity;
|
39975
39983
|
} else {
|
39976
39984
|
this.addResources([
|
39977
39985
|
{
|
39978
|
-
id:
|
39986
|
+
id: generateId(),
|
39979
39987
|
amount: quantity,
|
39980
39988
|
assetId,
|
39981
39989
|
owner: resourcesOwner || Address.fromRandom(),
|
@@ -41801,36 +41809,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41801
41809
|
missingContractIds
|
41802
41810
|
};
|
41803
41811
|
}
|
41804
|
-
/**
|
41805
|
-
* Estimates the transaction gas and fee based on the provided transaction request.
|
41806
|
-
* @param transactionRequest - The transaction request object.
|
41807
|
-
* @returns An object containing the estimated minimum gas, minimum fee, maximum gas, and maximum fee.
|
41808
|
-
*/
|
41809
|
-
estimateTxGasAndFee(params) {
|
41810
|
-
const { transactionRequest } = params;
|
41811
|
-
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41812
|
-
const chainInfo = this.getChain();
|
41813
|
-
const gasPrice = transactionRequest.gasPrice.eq(0) ? minGasPrice : transactionRequest.gasPrice;
|
41814
|
-
transactionRequest.gasPrice = gasPrice;
|
41815
|
-
const minGas = transactionRequest.calculateMinGas(chainInfo);
|
41816
|
-
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41817
|
-
if (transactionRequest.type === TransactionType.Script) {
|
41818
|
-
if (transactionRequest.gasLimit.eq(0)) {
|
41819
|
-
transactionRequest.gasLimit = minGas;
|
41820
|
-
transactionRequest.gasLimit = maxGasPerTx.sub(
|
41821
|
-
transactionRequest.calculateMaxGas(chainInfo, minGas)
|
41822
|
-
);
|
41823
|
-
}
|
41824
|
-
}
|
41825
|
-
const maxGas = transactionRequest.calculateMaxGas(chainInfo, minGas);
|
41826
|
-
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41827
|
-
return {
|
41828
|
-
minGas,
|
41829
|
-
minFee,
|
41830
|
-
maxGas,
|
41831
|
-
maxFee
|
41832
|
-
};
|
41833
|
-
}
|
41834
41812
|
/**
|
41835
41813
|
* Executes a signed transaction without applying the states changes
|
41836
41814
|
* on the chain.
|
@@ -41878,16 +41856,17 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41878
41856
|
signatureCallback
|
41879
41857
|
} = {}) {
|
41880
41858
|
const txRequestClone = clone_default(transactionRequestify(transactionRequestLike));
|
41881
|
-
const
|
41882
|
-
const
|
41859
|
+
const chainInfo = this.getChain();
|
41860
|
+
const { gasPriceFactor, minGasPrice, maxGasPerTx } = this.getGasConfig();
|
41861
|
+
const gasPrice = max(txRequestClone.gasPrice, minGasPrice);
|
41883
41862
|
const isScriptTransaction = txRequestClone.type === TransactionType.Script;
|
41884
41863
|
const coinOutputsQuantities = txRequestClone.getCoinOutputsQuantities();
|
41885
41864
|
const allQuantities = mergeQuantities(coinOutputsQuantities, forwardingQuantities);
|
41886
41865
|
txRequestClone.fundWithFakeUtxos(allQuantities, resourcesOwner?.address);
|
41887
|
-
if (isScriptTransaction) {
|
41888
|
-
txRequestClone.gasLimit = bn(0);
|
41889
|
-
}
|
41890
41866
|
if (estimatePredicates) {
|
41867
|
+
if (isScriptTransaction) {
|
41868
|
+
txRequestClone.gasLimit = bn(0);
|
41869
|
+
}
|
41891
41870
|
if (resourcesOwner && "populateTransactionPredicateData" in resourcesOwner) {
|
41892
41871
|
resourcesOwner.populateTransactionPredicateData(txRequestClone);
|
41893
41872
|
}
|
@@ -41896,34 +41875,36 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
41896
41875
|
if (signatureCallback && isScriptTransaction) {
|
41897
41876
|
await signatureCallback(txRequestClone);
|
41898
41877
|
}
|
41899
|
-
|
41900
|
-
|
41901
|
-
});
|
41878
|
+
const minGas = txRequestClone.calculateMinGas(chainInfo);
|
41879
|
+
const maxGas = txRequestClone.calculateMaxGas(chainInfo, minGas);
|
41902
41880
|
let receipts = [];
|
41903
41881
|
let missingContractIds = [];
|
41904
41882
|
let outputVariables = 0;
|
41905
|
-
let gasUsed = bn(0);
|
41906
41883
|
if (isScriptTransaction && estimateTxDependencies) {
|
41907
41884
|
txRequestClone.gasPrice = bn(0);
|
41885
|
+
txRequestClone.gasLimit = bn(maxGasPerTx.sub(maxGas).toNumber() * 0.9);
|
41908
41886
|
const result = await this.estimateTxDependencies(txRequestClone);
|
41909
41887
|
receipts = result.receipts;
|
41910
41888
|
outputVariables = result.outputVariables;
|
41911
41889
|
missingContractIds = result.missingContractIds;
|
41912
|
-
gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : gasUsed;
|
41913
|
-
txRequestClone.gasLimit = gasUsed;
|
41914
|
-
txRequestClone.gasPrice = setGasPrice;
|
41915
|
-
({ maxFee, maxGas, minFee, minGas } = this.estimateTxGasAndFee({
|
41916
|
-
transactionRequest: txRequestClone
|
41917
|
-
}));
|
41918
41890
|
}
|
41891
|
+
const gasUsed = isScriptTransaction ? getGasUsedFromReceipts(receipts) : minGas;
|
41892
|
+
const usedFee = calculatePriceWithFactor(
|
41893
|
+
gasUsed,
|
41894
|
+
gasPrice,
|
41895
|
+
gasPriceFactor
|
41896
|
+
).normalizeZeroToOne();
|
41897
|
+
const minFee = calculatePriceWithFactor(minGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41898
|
+
const maxFee = calculatePriceWithFactor(maxGas, gasPrice, gasPriceFactor).normalizeZeroToOne();
|
41919
41899
|
return {
|
41920
41900
|
requiredQuantities: allQuantities,
|
41921
41901
|
receipts,
|
41922
41902
|
gasUsed,
|
41923
41903
|
minGasPrice,
|
41924
|
-
gasPrice
|
41904
|
+
gasPrice,
|
41925
41905
|
minGas,
|
41926
41906
|
maxGas,
|
41907
|
+
usedFee,
|
41927
41908
|
minFee,
|
41928
41909
|
maxFee,
|
41929
41910
|
estimatedInputs: txRequestClone.inputs,
|
@@ -44377,12 +44358,12 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44377
44358
|
};
|
44378
44359
|
|
44379
44360
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/rng.js
|
44380
|
-
var
|
44361
|
+
var import_crypto15 = __toESM(__require("crypto"));
|
44381
44362
|
var rnds8Pool = new Uint8Array(256);
|
44382
44363
|
var poolPtr = rnds8Pool.length;
|
44383
44364
|
function rng() {
|
44384
44365
|
if (poolPtr > rnds8Pool.length - 16) {
|
44385
|
-
|
44366
|
+
import_crypto15.default.randomFillSync(rnds8Pool);
|
44386
44367
|
poolPtr = 0;
|
44387
44368
|
}
|
44388
44369
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
@@ -44398,9 +44379,9 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
44398
44379
|
}
|
44399
44380
|
|
44400
44381
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/native.js
|
44401
|
-
var
|
44382
|
+
var import_crypto16 = __toESM(__require("crypto"));
|
44402
44383
|
var native_default = {
|
44403
|
-
randomUUID:
|
44384
|
+
randomUUID: import_crypto16.default.randomUUID
|
44404
44385
|
};
|
44405
44386
|
|
44406
44387
|
// ../../node_modules/.pnpm/uuid@9.0.0/node_modules/uuid/dist/esm-node/v4.js
|
@@ -47819,6 +47800,7 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
47819
47800
|
// src/predicate/predicate.ts
|
47820
47801
|
var Predicate = class extends Account {
|
47821
47802
|
bytes;
|
47803
|
+
predicateDataBytes = Uint8Array.from([]);
|
47822
47804
|
predicateData = [];
|
47823
47805
|
interface;
|
47824
47806
|
/**
|