@fuel-ts/account 0.0.0-rc-2143-20240513161105 → 0.0.0-rc-2238-20240513185415
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/account.d.ts.map +1 -1
- package/dist/index.global.js +412 -1146
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +116 -146
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +108 -144
- package/dist/index.mjs.map +1 -1
- package/dist/predicate/predicate.d.ts.map +1 -1
- package/dist/providers/coin.d.ts +0 -1
- package/dist/providers/coin.d.ts.map +1 -1
- package/dist/providers/message.d.ts +0 -1
- package/dist/providers/message.d.ts.map +1 -1
- package/dist/providers/transaction-request/input.d.ts +0 -2
- package/dist/providers/transaction-request/input.d.ts.map +1 -1
- package/dist/providers/transaction-request/transaction-request.d.ts +0 -1
- package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
- package/dist/providers/transaction-summary/call.d.ts +1 -1
- package/dist/providers/transaction-summary/call.d.ts.map +1 -1
- package/dist/test-utils/launchNode.d.ts +2 -4
- package/dist/test-utils/launchNode.d.ts.map +1 -1
- package/dist/test-utils.global.js +3643 -6596
- package/dist/test-utils.global.js.map +1 -1
- package/dist/test-utils.js +111 -134
- package/dist/test-utils.js.map +1 -1
- package/dist/test-utils.mjs +102 -125
- package/dist/test-utils.mjs.map +1 -1
- package/package.json +15 -15
package/dist/index.global.js
CHANGED
@@ -29470,7 +29470,7 @@ spurious results.`);
|
|
29470
29470
|
// ../versions/dist/index.mjs
|
29471
29471
|
function getBuiltinVersions() {
|
29472
29472
|
return {
|
29473
|
-
FORC: "0.
|
29473
|
+
FORC: "0.57.0",
|
29474
29474
|
FUEL_CORE: "0.26.0",
|
29475
29475
|
FUELS: "0.85.0"
|
29476
29476
|
};
|
@@ -31092,19 +31092,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31092
31092
|
__defNormalProp4(obj, typeof key !== "symbol" ? key + "" : key, value);
|
31093
31093
|
return value;
|
31094
31094
|
};
|
31095
|
-
var __accessCheck2 = (obj, member, msg) => {
|
31096
|
-
if (!member.has(obj))
|
31097
|
-
throw TypeError("Cannot " + msg);
|
31098
|
-
};
|
31099
|
-
var __privateAdd2 = (obj, member, value) => {
|
31100
|
-
if (member.has(obj))
|
31101
|
-
throw TypeError("Cannot add the same private member more than once");
|
31102
|
-
member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
31103
|
-
};
|
31104
|
-
var __privateMethod2 = (obj, member, method) => {
|
31105
|
-
__accessCheck2(obj, member, "access private method");
|
31106
|
-
return method;
|
31107
|
-
};
|
31108
31095
|
var Coder = class {
|
31109
31096
|
name;
|
31110
31097
|
type;
|
@@ -31136,7 +31123,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31136
31123
|
var enumRegEx = /^enum (?<name>\w+)$/;
|
31137
31124
|
var tupleRegEx = /^\((?<items>.*)\)$/;
|
31138
31125
|
var genericRegEx = /^generic (?<name>\w+)$/;
|
31139
|
-
var ENCODING_V0 = "0";
|
31140
31126
|
var ENCODING_V1 = "1";
|
31141
31127
|
var WORD_SIZE = 8;
|
31142
31128
|
var BYTES_32 = 32;
|
@@ -31147,10 +31133,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31147
31133
|
var TX_LEN = WORD_SIZE * 4;
|
31148
31134
|
var TX_POINTER_LEN = WORD_SIZE * 2;
|
31149
31135
|
var MAX_BYTES = 2 ** 32 - 1;
|
31150
|
-
var calculateVmTxMemory = ({ maxInputs }) => BYTES_32 + // Tx ID
|
31151
|
-
ASSET_ID_LEN + // Base asset ID
|
31152
|
-
// Asset ID/Balance coin input pairs
|
31153
|
-
maxInputs * (ASSET_ID_LEN + WORD_SIZE) + WORD_SIZE;
|
31154
31136
|
var SCRIPT_FIXED_SIZE = WORD_SIZE + // Identifier
|
31155
31137
|
WORD_SIZE + // Gas limit
|
31156
31138
|
WORD_SIZE + // Script size
|
@@ -31181,125 +31163,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31181
31163
|
WORD_SIZE + // Predicate size
|
31182
31164
|
WORD_SIZE + // Predicate data size
|
31183
31165
|
WORD_SIZE;
|
31184
|
-
var encodedLengths = {
|
31185
|
-
u64: WORD_SIZE,
|
31186
|
-
u256: WORD_SIZE * 4
|
31187
|
-
};
|
31188
|
-
var BigNumberCoder = class extends Coder {
|
31189
|
-
constructor(baseType) {
|
31190
|
-
super("bigNumber", baseType, encodedLengths[baseType]);
|
31191
|
-
}
|
31192
|
-
encode(value) {
|
31193
|
-
let bytes2;
|
31194
|
-
try {
|
31195
|
-
bytes2 = toBytes2(value, this.encodedLength);
|
31196
|
-
} catch (error) {
|
31197
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
|
31198
|
-
}
|
31199
|
-
return bytes2;
|
31200
|
-
}
|
31201
|
-
decode(data, offset) {
|
31202
|
-
if (data.length < this.encodedLength) {
|
31203
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);
|
31204
|
-
}
|
31205
|
-
let bytes2 = data.slice(offset, offset + this.encodedLength);
|
31206
|
-
bytes2 = bytes2.slice(0, this.encodedLength);
|
31207
|
-
if (bytes2.length !== this.encodedLength) {
|
31208
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);
|
31209
|
-
}
|
31210
|
-
return [bn(bytes2), offset + this.encodedLength];
|
31211
|
-
}
|
31212
|
-
};
|
31213
|
-
var VEC_PROPERTY_SPACE = 3;
|
31214
|
-
var BASE_VECTOR_OFFSET = VEC_PROPERTY_SPACE * WORD_SIZE;
|
31215
|
-
var RAW_SLICE_PROPERTY_SPACE = 2;
|
31216
|
-
var BASE_RAW_SLICE_OFFSET = RAW_SLICE_PROPERTY_SPACE * WORD_SIZE;
|
31217
|
-
function concatWithDynamicData(items) {
|
31218
|
-
const topLevelData = {};
|
31219
|
-
let totalIndex = 0;
|
31220
|
-
const objects = items.map((item) => {
|
31221
|
-
const dynamicData = item.dynamicData;
|
31222
|
-
if (dynamicData) {
|
31223
|
-
Object.entries(dynamicData).forEach(([pointerIndex, vData]) => {
|
31224
|
-
topLevelData[parseInt(pointerIndex, 10) + totalIndex] = vData;
|
31225
|
-
});
|
31226
|
-
}
|
31227
|
-
const byteArray = arrayify(item);
|
31228
|
-
totalIndex += byteArray.byteLength / WORD_SIZE;
|
31229
|
-
return byteArray;
|
31230
|
-
});
|
31231
|
-
const length = objects.reduce((accum, item) => accum + item.length, 0);
|
31232
|
-
const result = new Uint8Array(length);
|
31233
|
-
objects.reduce((offset, object) => {
|
31234
|
-
result.set(object, offset);
|
31235
|
-
return offset + object.length;
|
31236
|
-
}, 0);
|
31237
|
-
if (Object.keys(topLevelData).length) {
|
31238
|
-
result.dynamicData = topLevelData;
|
31239
|
-
}
|
31240
|
-
return result;
|
31241
|
-
}
|
31242
|
-
function unpackDynamicData(results, baseOffset, dataOffset) {
|
31243
|
-
if (!results.dynamicData) {
|
31244
|
-
return concat([results]);
|
31245
|
-
}
|
31246
|
-
let cumulativeDynamicByteLength = 0;
|
31247
|
-
let updatedResults = results;
|
31248
|
-
Object.entries(results.dynamicData).forEach(([pointerIndex, vData]) => {
|
31249
|
-
const pointerOffset = parseInt(pointerIndex, 10) * WORD_SIZE;
|
31250
|
-
const adjustedValue = new BigNumberCoder("u64").encode(
|
31251
|
-
dataOffset + baseOffset + cumulativeDynamicByteLength
|
31252
|
-
);
|
31253
|
-
updatedResults.set(adjustedValue, pointerOffset);
|
31254
|
-
const dataToAppend = vData.dynamicData ? (
|
31255
|
-
// unpack child dynamic data
|
31256
|
-
unpackDynamicData(
|
31257
|
-
vData,
|
31258
|
-
baseOffset,
|
31259
|
-
dataOffset + vData.byteLength + cumulativeDynamicByteLength
|
31260
|
-
)
|
31261
|
-
) : vData;
|
31262
|
-
updatedResults = concat([updatedResults, dataToAppend]);
|
31263
|
-
cumulativeDynamicByteLength += dataToAppend.byteLength;
|
31264
|
-
});
|
31265
|
-
return updatedResults;
|
31266
|
-
}
|
31267
|
-
var chunkByLength = (data, length = WORD_SIZE) => {
|
31268
|
-
const chunks = [];
|
31269
|
-
let offset = 0;
|
31270
|
-
let chunk = data.slice(offset, offset + length);
|
31271
|
-
while (chunk.length) {
|
31272
|
-
chunks.push(chunk);
|
31273
|
-
offset += length;
|
31274
|
-
chunk = data.slice(offset, offset + length);
|
31275
|
-
}
|
31276
|
-
return chunks;
|
31277
|
-
};
|
31278
|
-
var isPointerType = (type3) => {
|
31279
|
-
switch (type3) {
|
31280
|
-
case "u8":
|
31281
|
-
case "u16":
|
31282
|
-
case "u32":
|
31283
|
-
case "u64":
|
31284
|
-
case "bool": {
|
31285
|
-
return false;
|
31286
|
-
}
|
31287
|
-
default: {
|
31288
|
-
return true;
|
31289
|
-
}
|
31290
|
-
}
|
31291
|
-
};
|
31292
|
-
var isHeapType = (type3) => type3 === VEC_CODER_TYPE || type3 === BYTES_CODER_TYPE || type3 === STD_STRING_CODER_TYPE;
|
31293
|
-
var isMultipleOfWordSize = (length) => length % WORD_SIZE === 0;
|
31294
|
-
var getWordSizePadding = (length) => WORD_SIZE - length % WORD_SIZE;
|
31295
|
-
var rightPadToWordSize = (encoded) => {
|
31296
|
-
if (isMultipleOfWordSize(encoded.length)) {
|
31297
|
-
return encoded;
|
31298
|
-
}
|
31299
|
-
const padding = new Uint8Array(WORD_SIZE - encoded.length % WORD_SIZE);
|
31300
|
-
return concatBytes2([encoded, padding]);
|
31301
|
-
};
|
31302
|
-
var isUint8Array = (value) => value instanceof Uint8Array;
|
31303
31166
|
var ArrayCoder = class extends Coder {
|
31304
31167
|
coder;
|
31305
31168
|
length;
|
@@ -31315,7 +31178,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31315
31178
|
if (this.length !== value.length) {
|
31316
31179
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`);
|
31317
31180
|
}
|
31318
|
-
return
|
31181
|
+
return concat(Array.from(value).map((v) => this.coder.encode(v)));
|
31319
31182
|
}
|
31320
31183
|
decode(data, offset) {
|
31321
31184
|
if (data.length < this.encodedLength || data.length > MAX_BYTES) {
|
@@ -31392,16 +31255,42 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31392
31255
|
return [toHex(bytes2, this.encodedLength), offset + this.encodedLength];
|
31393
31256
|
}
|
31394
31257
|
};
|
31258
|
+
var encodedLengths = {
|
31259
|
+
u64: WORD_SIZE,
|
31260
|
+
u256: WORD_SIZE * 4
|
31261
|
+
};
|
31262
|
+
var BigNumberCoder = class extends Coder {
|
31263
|
+
constructor(baseType) {
|
31264
|
+
super("bigNumber", baseType, encodedLengths[baseType]);
|
31265
|
+
}
|
31266
|
+
encode(value) {
|
31267
|
+
let bytes2;
|
31268
|
+
try {
|
31269
|
+
bytes2 = toBytes2(value, this.encodedLength);
|
31270
|
+
} catch (error) {
|
31271
|
+
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.type}.`);
|
31272
|
+
}
|
31273
|
+
return bytes2;
|
31274
|
+
}
|
31275
|
+
decode(data, offset) {
|
31276
|
+
if (data.length < this.encodedLength) {
|
31277
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} data size.`);
|
31278
|
+
}
|
31279
|
+
let bytes2 = data.slice(offset, offset + this.encodedLength);
|
31280
|
+
bytes2 = bytes2.slice(0, this.encodedLength);
|
31281
|
+
if (bytes2.length !== this.encodedLength) {
|
31282
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid ${this.type} byte data size.`);
|
31283
|
+
}
|
31284
|
+
return [bn(bytes2), offset + this.encodedLength];
|
31285
|
+
}
|
31286
|
+
};
|
31395
31287
|
var BooleanCoder = class extends Coder {
|
31396
|
-
paddingLength;
|
31397
31288
|
options;
|
31398
31289
|
constructor(options = {
|
31399
|
-
|
31400
|
-
isRightPadded: false
|
31290
|
+
padToWordSize: false
|
31401
31291
|
}) {
|
31402
|
-
const
|
31403
|
-
super("boolean", "boolean",
|
31404
|
-
this.paddingLength = paddingLength;
|
31292
|
+
const encodedLength = options.padToWordSize ? WORD_SIZE : 1;
|
31293
|
+
super("boolean", "boolean", encodedLength);
|
31405
31294
|
this.options = options;
|
31406
31295
|
}
|
31407
31296
|
encode(value) {
|
@@ -31409,73 +31298,45 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31409
31298
|
if (!isTrueBool) {
|
31410
31299
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);
|
31411
31300
|
}
|
31412
|
-
|
31413
|
-
if (this.options.isRightPadded) {
|
31414
|
-
return output2.reverse();
|
31415
|
-
}
|
31416
|
-
return output2;
|
31301
|
+
return toBytes2(value ? 1 : 0, this.encodedLength);
|
31417
31302
|
}
|
31418
31303
|
decode(data, offset) {
|
31419
|
-
if (data.length < this.
|
31304
|
+
if (data.length < this.encodedLength) {
|
31420
31305
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);
|
31421
31306
|
}
|
31422
|
-
|
31423
|
-
if (
|
31424
|
-
|
31425
|
-
} else {
|
31426
|
-
bytes2 = data.slice(offset, offset + this.paddingLength);
|
31427
|
-
}
|
31428
|
-
const decodedValue = bn(bytes2);
|
31429
|
-
if (decodedValue.isZero()) {
|
31430
|
-
return [false, offset + this.paddingLength];
|
31307
|
+
const bytes2 = bn(data.slice(offset, offset + this.encodedLength));
|
31308
|
+
if (bytes2.isZero()) {
|
31309
|
+
return [false, offset + this.encodedLength];
|
31431
31310
|
}
|
31432
|
-
if (!
|
31311
|
+
if (!bytes2.eq(bn(1))) {
|
31433
31312
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`);
|
31434
31313
|
}
|
31435
|
-
return [true, offset + this.
|
31314
|
+
return [true, offset + this.encodedLength];
|
31436
31315
|
}
|
31437
31316
|
};
|
31438
|
-
var _getPaddedData;
|
31439
|
-
var getPaddedData_fn;
|
31440
31317
|
var ByteCoder = class extends Coder {
|
31441
31318
|
constructor() {
|
31442
|
-
super("struct", "struct Bytes",
|
31443
|
-
__privateAdd2(this, _getPaddedData);
|
31319
|
+
super("struct", "struct Bytes", WORD_SIZE);
|
31444
31320
|
}
|
31445
31321
|
encode(value) {
|
31446
|
-
const
|
31447
|
-
const
|
31448
|
-
|
31449
|
-
pointer.dynamicData = {
|
31450
|
-
0: concatWithDynamicData([data])
|
31451
|
-
};
|
31452
|
-
parts.push(pointer);
|
31453
|
-
parts.push(new BigNumberCoder("u64").encode(data.byteLength));
|
31454
|
-
parts.push(new BigNumberCoder("u64").encode(value.length));
|
31455
|
-
return concatWithDynamicData(parts);
|
31322
|
+
const bytes2 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
31323
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
|
31324
|
+
return new Uint8Array([...lengthBytes, ...bytes2]);
|
31456
31325
|
}
|
31457
31326
|
decode(data, offset) {
|
31458
|
-
if (data.length <
|
31327
|
+
if (data.length < WORD_SIZE) {
|
31459
31328
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`);
|
31460
31329
|
}
|
31461
|
-
const
|
31462
|
-
const
|
31463
|
-
const
|
31464
|
-
|
31330
|
+
const offsetAndLength = offset + WORD_SIZE;
|
31331
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
31332
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
31333
|
+
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
31334
|
+
if (dataBytes.length !== length) {
|
31465
31335
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`);
|
31466
31336
|
}
|
31467
|
-
return [
|
31337
|
+
return [dataBytes, offsetAndLength + length];
|
31468
31338
|
}
|
31469
31339
|
};
|
31470
|
-
_getPaddedData = /* @__PURE__ */ new WeakSet();
|
31471
|
-
getPaddedData_fn = function(value) {
|
31472
|
-
const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
|
31473
|
-
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31474
|
-
if (paddingLength) {
|
31475
|
-
data.push(new Uint8Array(paddingLength));
|
31476
|
-
}
|
31477
|
-
return concat(data);
|
31478
|
-
};
|
31479
31340
|
__publicField4(ByteCoder, "memorySize", 1);
|
31480
31341
|
var isFullyNativeEnum = (enumCoders) => Object.values(enumCoders).every(
|
31481
31342
|
// @ts-expect-error complicated types
|
@@ -31519,8 +31380,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31519
31380
|
const valueCoder = this.coders[caseKey];
|
31520
31381
|
const caseIndex = Object.keys(this.coders).indexOf(caseKey);
|
31521
31382
|
const encodedValue = valueCoder.encode(value[caseKey]);
|
31522
|
-
|
31523
|
-
return concatWithDynamicData([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]);
|
31383
|
+
return new Uint8Array([...this.#caseIndexCoder.encode(caseIndex), ...encodedValue]);
|
31524
31384
|
}
|
31525
31385
|
#decodeNativeEnum(caseKey, newOffset) {
|
31526
31386
|
return [caseKey, newOffset];
|
@@ -31529,10 +31389,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31529
31389
|
if (data.length < this.#encodedValueSize) {
|
31530
31390
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);
|
31531
31391
|
}
|
31532
|
-
|
31533
|
-
|
31534
|
-
[decoded, newOffset] = new BigNumberCoder("u64").decode(data, newOffset);
|
31535
|
-
const caseIndex = toNumber(decoded);
|
31392
|
+
const caseBytes = new BigNumberCoder("u64").decode(data, offset)[0];
|
31393
|
+
const caseIndex = toNumber(caseBytes);
|
31536
31394
|
const caseKey = Object.keys(this.coders)[caseIndex];
|
31537
31395
|
if (!caseKey) {
|
31538
31396
|
throw new FuelError(
|
@@ -31541,67 +31399,35 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31541
31399
|
);
|
31542
31400
|
}
|
31543
31401
|
const valueCoder = this.coders[caseKey];
|
31544
|
-
const
|
31545
|
-
newOffset
|
31546
|
-
[decoded, newOffset] = valueCoder.decode(data, newOffset);
|
31402
|
+
const offsetAndCase = offset + WORD_SIZE;
|
31403
|
+
const [decoded, newOffset] = valueCoder.decode(data, offsetAndCase);
|
31547
31404
|
if (isFullyNativeEnum(this.coders)) {
|
31548
31405
|
return this.#decodeNativeEnum(caseKey, newOffset);
|
31549
31406
|
}
|
31550
31407
|
return [{ [caseKey]: decoded }, newOffset];
|
31551
31408
|
}
|
31552
31409
|
};
|
31553
|
-
var
|
31554
|
-
|
31555
|
-
|
31556
|
-
|
31557
|
-
|
31558
|
-
|
31559
|
-
|
31560
|
-
return
|
31561
|
-
|
31562
|
-
|
31563
|
-
}
|
31564
|
-
decode(data, offset) {
|
31565
|
-
if (data.length < this.encodedLength) {
|
31566
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
|
31567
|
-
}
|
31568
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
31569
|
-
return [this.toOption(decoded), newOffset];
|
31570
|
-
}
|
31571
|
-
toOption(output2) {
|
31572
|
-
if (output2 && "Some" in output2) {
|
31573
|
-
return output2.Some;
|
31574
|
-
}
|
31575
|
-
return void 0;
|
31410
|
+
var getLength = (baseType) => {
|
31411
|
+
switch (baseType) {
|
31412
|
+
case "u8":
|
31413
|
+
return 1;
|
31414
|
+
case "u16":
|
31415
|
+
return 2;
|
31416
|
+
case "u32":
|
31417
|
+
return 4;
|
31418
|
+
default:
|
31419
|
+
throw new FuelError(ErrorCode.TYPE_NOT_SUPPORTED, `Invalid number type: ${baseType}`);
|
31576
31420
|
}
|
31577
31421
|
};
|
31578
31422
|
var NumberCoder = class extends Coder {
|
31579
|
-
// This is to align the bits to the total bytes
|
31580
|
-
// See https://github.com/FuelLabs/fuel-specs/blob/master/specs/protocol/abi.md#unsigned-integers
|
31581
|
-
length;
|
31582
|
-
paddingLength;
|
31583
31423
|
baseType;
|
31584
31424
|
options;
|
31585
31425
|
constructor(baseType, options = {
|
31586
|
-
|
31587
|
-
isRightPadded: false
|
31426
|
+
padToWordSize: false
|
31588
31427
|
}) {
|
31589
|
-
const
|
31590
|
-
super("number", baseType,
|
31428
|
+
const length = options.padToWordSize ? WORD_SIZE : getLength(baseType);
|
31429
|
+
super("number", baseType, length);
|
31591
31430
|
this.baseType = baseType;
|
31592
|
-
switch (baseType) {
|
31593
|
-
case "u8":
|
31594
|
-
this.length = 1;
|
31595
|
-
break;
|
31596
|
-
case "u16":
|
31597
|
-
this.length = 2;
|
31598
|
-
break;
|
31599
|
-
case "u32":
|
31600
|
-
default:
|
31601
|
-
this.length = 4;
|
31602
|
-
break;
|
31603
|
-
}
|
31604
|
-
this.paddingLength = paddingLength;
|
31605
31431
|
this.options = options;
|
31606
31432
|
}
|
31607
31433
|
encode(value) {
|
@@ -31611,778 +31437,97 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
31611
31437
|
} catch (error) {
|
31612
31438
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
|
31613
31439
|
}
|
31614
|
-
if (bytes2.length > this.
|
31440
|
+
if (bytes2.length > this.encodedLength) {
|
31615
31441
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
|
31616
31442
|
}
|
31617
|
-
|
31618
|
-
if (this.baseType !== "u8") {
|
31619
|
-
return output2;
|
31620
|
-
}
|
31621
|
-
return this.options.isRightPadded ? output2.reverse() : output2;
|
31622
|
-
}
|
31623
|
-
decodeU8(data, offset) {
|
31624
|
-
let bytes2;
|
31625
|
-
if (this.options.isRightPadded) {
|
31626
|
-
bytes2 = data.slice(offset, offset + 1);
|
31627
|
-
} else {
|
31628
|
-
bytes2 = data.slice(offset, offset + this.paddingLength);
|
31629
|
-
bytes2 = bytes2.slice(this.paddingLength - this.length, this.paddingLength);
|
31630
|
-
}
|
31631
|
-
return [toNumber(bytes2), offset + this.paddingLength];
|
31443
|
+
return toBytes2(bytes2, this.encodedLength);
|
31632
31444
|
}
|
31633
31445
|
decode(data, offset) {
|
31634
|
-
if (data.length < this.
|
31446
|
+
if (data.length < this.encodedLength) {
|
31635
31447
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`);
|
31636
31448
|
}
|
31637
|
-
|
31638
|
-
|
31639
|
-
}
|
31640
|
-
let bytes2 = data.slice(offset, offset + this.paddingLength);
|
31641
|
-
bytes2 = bytes2.slice(8 - this.length, 8);
|
31642
|
-
if (bytes2.length !== this.paddingLength - (this.paddingLength - this.length)) {
|
31449
|
+
const bytes2 = data.slice(offset, offset + this.encodedLength);
|
31450
|
+
if (bytes2.length !== this.encodedLength) {
|
31643
31451
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
|
31644
31452
|
}
|
31645
|
-
return [toNumber(bytes2), offset +
|
31453
|
+
return [toNumber(bytes2), offset + this.encodedLength];
|
31454
|
+
}
|
31455
|
+
};
|
31456
|
+
var OptionCoder = class extends EnumCoder {
|
31457
|
+
encode(value) {
|
31458
|
+
const result = super.encode(this.toSwayOption(value));
|
31459
|
+
return result;
|
31460
|
+
}
|
31461
|
+
toSwayOption(input) {
|
31462
|
+
if (input !== void 0) {
|
31463
|
+
return { Some: input };
|
31464
|
+
}
|
31465
|
+
return { None: [] };
|
31466
|
+
}
|
31467
|
+
decode(data, offset) {
|
31468
|
+
const [decoded, newOffset] = super.decode(data, offset);
|
31469
|
+
return [this.toOption(decoded), newOffset];
|
31470
|
+
}
|
31471
|
+
toOption(output2) {
|
31472
|
+
if (output2 && "Some" in output2) {
|
31473
|
+
return output2.Some;
|
31474
|
+
}
|
31475
|
+
return void 0;
|
31646
31476
|
}
|
31647
31477
|
};
|
31648
31478
|
var RawSliceCoder = class extends Coder {
|
31649
31479
|
constructor() {
|
31650
|
-
super("raw untyped slice", "raw untyped slice",
|
31480
|
+
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
31651
31481
|
}
|
31652
31482
|
encode(value) {
|
31653
31483
|
if (!Array.isArray(value)) {
|
31654
31484
|
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
31655
31485
|
}
|
31656
|
-
const
|
31657
|
-
const
|
31658
|
-
const
|
31659
|
-
|
31660
|
-
);
|
31661
|
-
pointer.dynamicData = {
|
31662
|
-
0: concatWithDynamicData(value.map((v) => coder.encode(v)))
|
31663
|
-
};
|
31664
|
-
parts.push(pointer);
|
31665
|
-
parts.push(new BigNumberCoder("u64").encode(value.length));
|
31666
|
-
return concatWithDynamicData(parts);
|
31486
|
+
const internalCoder = new ArrayCoder(new NumberCoder("u8"), value.length);
|
31487
|
+
const bytes2 = internalCoder.encode(value);
|
31488
|
+
const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
|
31489
|
+
return new Uint8Array([...lengthBytes, ...bytes2]);
|
31667
31490
|
}
|
31668
31491
|
decode(data, offset) {
|
31669
|
-
|
31670
|
-
|
31671
|
-
|
31672
|
-
|
31673
|
-
);
|
31492
|
+
if (data.length < this.encodedLength) {
|
31493
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid raw slice data size.`);
|
31494
|
+
}
|
31495
|
+
const offsetAndLength = offset + WORD_SIZE;
|
31496
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
31497
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
31498
|
+
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
31499
|
+
if (dataBytes.length !== length) {
|
31500
|
+
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid raw slice byte data size.`);
|
31501
|
+
}
|
31502
|
+
const internalCoder = new ArrayCoder(new NumberCoder("u8"), length);
|
31674
31503
|
const [decodedValue] = internalCoder.decode(dataBytes, 0);
|
31675
|
-
return [decodedValue,
|
31504
|
+
return [decodedValue, offsetAndLength + length];
|
31676
31505
|
}
|
31677
31506
|
};
|
31678
|
-
var _getPaddedData2;
|
31679
|
-
var getPaddedData_fn2;
|
31680
31507
|
var StdStringCoder = class extends Coder {
|
31681
31508
|
constructor() {
|
31682
|
-
super("struct", "struct String",
|
31683
|
-
__privateAdd2(this, _getPaddedData2);
|
31509
|
+
super("struct", "struct String", WORD_SIZE);
|
31684
31510
|
}
|
31685
31511
|
encode(value) {
|
31686
|
-
const
|
31687
|
-
const
|
31688
|
-
|
31689
|
-
pointer.dynamicData = {
|
31690
|
-
0: concatWithDynamicData([data])
|
31691
|
-
};
|
31692
|
-
parts.push(pointer);
|
31693
|
-
parts.push(new BigNumberCoder("u64").encode(data.byteLength));
|
31694
|
-
parts.push(new BigNumberCoder("u64").encode(value.length));
|
31695
|
-
return concatWithDynamicData(parts);
|
31512
|
+
const bytes2 = toUtf8Bytes(value);
|
31513
|
+
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
31514
|
+
return new Uint8Array([...lengthBytes, ...bytes2]);
|
31696
31515
|
}
|
31697
31516
|
decode(data, offset) {
|
31698
31517
|
if (data.length < this.encodedLength) {
|
31699
31518
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`);
|
31700
31519
|
}
|
31701
|
-
const
|
31702
|
-
const
|
31703
|
-
const
|
31704
|
-
|
31520
|
+
const offsetAndLength = offset + WORD_SIZE;
|
31521
|
+
const lengthBytes = data.slice(offset, offsetAndLength);
|
31522
|
+
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
31523
|
+
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
31524
|
+
if (dataBytes.length !== length) {
|
31705
31525
|
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`);
|
31706
31526
|
}
|
31707
|
-
|
31708
|
-
return [value, offset + BASE_VECTOR_OFFSET];
|
31527
|
+
return [toUtf8String(dataBytes), offsetAndLength + length];
|
31709
31528
|
}
|
31710
31529
|
};
|
31711
|
-
_getPaddedData2 = /* @__PURE__ */ new WeakSet();
|
31712
|
-
getPaddedData_fn2 = function(value) {
|
31713
|
-
const data = [toUtf8Bytes(value)];
|
31714
|
-
const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
|
31715
|
-
if (paddingLength) {
|
31716
|
-
data.push(new Uint8Array(paddingLength));
|
31717
|
-
}
|
31718
|
-
return concat(data);
|
31719
|
-
};
|
31720
31530
|
__publicField4(StdStringCoder, "memorySize", 1);
|
31721
|
-
var StringCoder = class extends Coder {
|
31722
|
-
length;
|
31723
|
-
#paddingLength;
|
31724
|
-
constructor(length) {
|
31725
|
-
let paddingLength = (8 - length) % 8;
|
31726
|
-
paddingLength = paddingLength < 0 ? paddingLength + 8 : paddingLength;
|
31727
|
-
super("string", `str[${length}]`, length + paddingLength);
|
31728
|
-
this.length = length;
|
31729
|
-
this.#paddingLength = paddingLength;
|
31730
|
-
}
|
31731
|
-
encode(value) {
|
31732
|
-
if (this.length !== value.length) {
|
31733
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Value length mismatch during encode.`);
|
31734
|
-
}
|
31735
|
-
const encoded = toUtf8Bytes(value);
|
31736
|
-
const padding = new Uint8Array(this.#paddingLength);
|
31737
|
-
return concat([encoded, padding]);
|
31738
|
-
}
|
31739
|
-
decode(data, offset) {
|
31740
|
-
if (data.length < this.encodedLength) {
|
31741
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string data size.`);
|
31742
|
-
}
|
31743
|
-
const bytes2 = data.slice(offset, offset + this.length);
|
31744
|
-
if (bytes2.length !== this.length) {
|
31745
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string byte data size.`);
|
31746
|
-
}
|
31747
|
-
const value = toUtf8String(bytes2);
|
31748
|
-
const padding = this.#paddingLength;
|
31749
|
-
return [value, offset + this.length + padding];
|
31750
|
-
}
|
31751
|
-
};
|
31752
|
-
var StructCoder = class extends Coder {
|
31753
|
-
name;
|
31754
|
-
coders;
|
31755
|
-
constructor(name, coders) {
|
31756
|
-
const encodedLength = Object.values(coders).reduce(
|
31757
|
-
(acc, coder) => acc + coder.encodedLength,
|
31758
|
-
0
|
31759
|
-
);
|
31760
|
-
super("struct", `struct ${name}`, encodedLength);
|
31761
|
-
this.name = name;
|
31762
|
-
this.coders = coders;
|
31763
|
-
}
|
31764
|
-
encode(value) {
|
31765
|
-
const encodedFields = Object.keys(this.coders).map((fieldName) => {
|
31766
|
-
const fieldCoder = this.coders[fieldName];
|
31767
|
-
const fieldValue = value[fieldName];
|
31768
|
-
if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
|
31769
|
-
throw new FuelError(
|
31770
|
-
ErrorCode.ENCODE_ERROR,
|
31771
|
-
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
31772
|
-
);
|
31773
|
-
}
|
31774
|
-
const encoded = fieldCoder.encode(fieldValue);
|
31775
|
-
if (!isMultipleOfWordSize(encoded.length)) {
|
31776
|
-
return rightPadToWordSize(encoded);
|
31777
|
-
}
|
31778
|
-
return encoded;
|
31779
|
-
});
|
31780
|
-
return concatWithDynamicData([concatWithDynamicData(encodedFields)]);
|
31781
|
-
}
|
31782
|
-
decode(data, offset) {
|
31783
|
-
if (data.length < this.encodedLength) {
|
31784
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid struct data size.`);
|
31785
|
-
}
|
31786
|
-
let newOffset = offset;
|
31787
|
-
const decodedValue = Object.keys(this.coders).reduce((obj, fieldName) => {
|
31788
|
-
const fieldCoder = this.coders[fieldName];
|
31789
|
-
let decoded;
|
31790
|
-
[decoded, newOffset] = fieldCoder.decode(data, newOffset);
|
31791
|
-
if (!isMultipleOfWordSize(newOffset)) {
|
31792
|
-
newOffset += getWordSizePadding(newOffset);
|
31793
|
-
}
|
31794
|
-
obj[fieldName] = decoded;
|
31795
|
-
return obj;
|
31796
|
-
}, {});
|
31797
|
-
return [decodedValue, newOffset];
|
31798
|
-
}
|
31799
|
-
};
|
31800
|
-
var TupleCoder = class extends Coder {
|
31801
|
-
coders;
|
31802
|
-
constructor(coders) {
|
31803
|
-
const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0);
|
31804
|
-
super("tuple", `(${coders.map((coder) => coder.type).join(", ")})`, encodedLength);
|
31805
|
-
this.coders = coders;
|
31806
|
-
}
|
31807
|
-
encode(value) {
|
31808
|
-
if (this.coders.length !== value.length) {
|
31809
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Types/values length mismatch.`);
|
31810
|
-
}
|
31811
|
-
return concatWithDynamicData(
|
31812
|
-
this.coders.map((coder, i) => {
|
31813
|
-
const encoded = coder.encode(value[i]);
|
31814
|
-
if (!isMultipleOfWordSize(encoded.length)) {
|
31815
|
-
return rightPadToWordSize(encoded);
|
31816
|
-
}
|
31817
|
-
return encoded;
|
31818
|
-
})
|
31819
|
-
);
|
31820
|
-
}
|
31821
|
-
decode(data, offset) {
|
31822
|
-
if (data.length < this.encodedLength) {
|
31823
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid tuple data size.`);
|
31824
|
-
}
|
31825
|
-
let newOffset = offset;
|
31826
|
-
const decodedValue = this.coders.map((coder) => {
|
31827
|
-
let decoded;
|
31828
|
-
[decoded, newOffset] = coder.decode(data, newOffset);
|
31829
|
-
if (!isMultipleOfWordSize(newOffset)) {
|
31830
|
-
newOffset += getWordSizePadding(newOffset);
|
31831
|
-
}
|
31832
|
-
return decoded;
|
31833
|
-
});
|
31834
|
-
return [decodedValue, newOffset];
|
31835
|
-
}
|
31836
|
-
};
|
31837
|
-
var VecCoder = class extends Coder {
|
31838
|
-
coder;
|
31839
|
-
constructor(coder) {
|
31840
|
-
super("struct", `struct Vec`, coder.encodedLength + BASE_VECTOR_OFFSET);
|
31841
|
-
this.coder = coder;
|
31842
|
-
}
|
31843
|
-
encode(value) {
|
31844
|
-
if (!Array.isArray(value) && !isUint8Array(value)) {
|
31845
|
-
throw new FuelError(
|
31846
|
-
ErrorCode.ENCODE_ERROR,
|
31847
|
-
`Expected array value, or a Uint8Array. You can use arrayify to convert a value to a Uint8Array.`
|
31848
|
-
);
|
31849
|
-
}
|
31850
|
-
const parts = [];
|
31851
|
-
const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
|
31852
|
-
pointer.dynamicData = {
|
31853
|
-
0: concatWithDynamicData(Array.from(value).map((v) => this.coder.encode(v)))
|
31854
|
-
};
|
31855
|
-
parts.push(pointer);
|
31856
|
-
parts.push(new BigNumberCoder("u64").encode(value.length));
|
31857
|
-
parts.push(new BigNumberCoder("u64").encode(value.length));
|
31858
|
-
return concatWithDynamicData(parts);
|
31859
|
-
}
|
31860
|
-
decode(data, offset) {
|
31861
|
-
if (data.length < BASE_VECTOR_OFFSET || data.length > MAX_BYTES) {
|
31862
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec data size.`);
|
31863
|
-
}
|
31864
|
-
const len = data.slice(16, 24);
|
31865
|
-
const encodedLength = bn(new BigNumberCoder("u64").decode(len, 0)[0]).toNumber();
|
31866
|
-
const vectorRawDataLength = encodedLength * this.coder.encodedLength;
|
31867
|
-
const vectorRawData = data.slice(BASE_VECTOR_OFFSET, BASE_VECTOR_OFFSET + vectorRawDataLength);
|
31868
|
-
if (vectorRawData.length !== vectorRawDataLength) {
|
31869
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid vec byte data size.`);
|
31870
|
-
}
|
31871
|
-
return [
|
31872
|
-
chunkByLength(vectorRawData, this.coder.encodedLength).map(
|
31873
|
-
(chunk) => this.coder.decode(chunk, 0)[0]
|
31874
|
-
),
|
31875
|
-
offset + BASE_VECTOR_OFFSET
|
31876
|
-
];
|
31877
|
-
}
|
31878
|
-
};
|
31879
|
-
var getEncodingVersion = (encoding) => {
|
31880
|
-
switch (encoding) {
|
31881
|
-
case void 0:
|
31882
|
-
case ENCODING_V0:
|
31883
|
-
return ENCODING_V0;
|
31884
|
-
case ENCODING_V1:
|
31885
|
-
return ENCODING_V1;
|
31886
|
-
default:
|
31887
|
-
throw new FuelError(
|
31888
|
-
ErrorCode.UNSUPPORTED_ENCODING_VERSION,
|
31889
|
-
`Encoding version '${encoding}' is unsupported.`
|
31890
|
-
);
|
31891
|
-
}
|
31892
|
-
};
|
31893
|
-
var findFunctionByName = (abi, name) => {
|
31894
|
-
const fn = abi.functions.find((f2) => f2.name === name);
|
31895
|
-
if (!fn) {
|
31896
|
-
throw new FuelError(
|
31897
|
-
ErrorCode.FUNCTION_NOT_FOUND,
|
31898
|
-
`Function with name '${name}' doesn't exist in the ABI`
|
31899
|
-
);
|
31900
|
-
}
|
31901
|
-
return fn;
|
31902
|
-
};
|
31903
|
-
var findTypeById = (abi, typeId) => {
|
31904
|
-
const type3 = abi.types.find((t) => t.typeId === typeId);
|
31905
|
-
if (!type3) {
|
31906
|
-
throw new FuelError(
|
31907
|
-
ErrorCode.TYPE_NOT_FOUND,
|
31908
|
-
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
31909
|
-
);
|
31910
|
-
}
|
31911
|
-
return type3;
|
31912
|
-
};
|
31913
|
-
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
31914
|
-
var findVectorBufferArgument = (components) => {
|
31915
|
-
const bufferComponent = components.find((c) => c.name === "buf");
|
31916
|
-
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
31917
|
-
if (!bufferComponent || !bufferTypeArgument) {
|
31918
|
-
throw new FuelError(
|
31919
|
-
ErrorCode.INVALID_COMPONENT,
|
31920
|
-
`The Vec type provided is missing or has a malformed 'buf' component.`
|
31921
|
-
);
|
31922
|
-
}
|
31923
|
-
return bufferTypeArgument;
|
31924
|
-
};
|
31925
|
-
var ResolvedAbiType = class {
|
31926
|
-
abi;
|
31927
|
-
name;
|
31928
|
-
type;
|
31929
|
-
originalTypeArguments;
|
31930
|
-
components;
|
31931
|
-
constructor(abi, argument) {
|
31932
|
-
this.abi = abi;
|
31933
|
-
this.name = argument.name;
|
31934
|
-
const type3 = findTypeById(abi, argument.type);
|
31935
|
-
this.type = type3.type;
|
31936
|
-
this.originalTypeArguments = argument.typeArguments;
|
31937
|
-
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
31938
|
-
abi,
|
31939
|
-
argument,
|
31940
|
-
type3.components,
|
31941
|
-
type3.typeParameters ?? ResolvedAbiType.getImplicitGenericTypeParameters(abi, type3.components)
|
31942
|
-
);
|
31943
|
-
}
|
31944
|
-
static getResolvedGenericComponents(abi, arg, components, typeParameters) {
|
31945
|
-
if (components === null) {
|
31946
|
-
return null;
|
31947
|
-
}
|
31948
|
-
if (typeParameters === null || typeParameters.length === 0) {
|
31949
|
-
return components.map((c) => new ResolvedAbiType(abi, c));
|
31950
|
-
}
|
31951
|
-
const typeParametersAndArgsMap = typeParameters.reduce(
|
31952
|
-
(obj, typeParameter, typeParameterIndex) => {
|
31953
|
-
const o = { ...obj };
|
31954
|
-
o[typeParameter] = structuredClone(
|
31955
|
-
arg.typeArguments?.[typeParameterIndex]
|
31956
|
-
);
|
31957
|
-
return o;
|
31958
|
-
},
|
31959
|
-
{}
|
31960
|
-
);
|
31961
|
-
const resolvedComponents = this.resolveGenericArgTypes(
|
31962
|
-
abi,
|
31963
|
-
components,
|
31964
|
-
typeParametersAndArgsMap
|
31965
|
-
);
|
31966
|
-
return resolvedComponents.map((c) => new ResolvedAbiType(abi, c));
|
31967
|
-
}
|
31968
|
-
static resolveGenericArgTypes(abi, args, typeParametersAndArgsMap) {
|
31969
|
-
return args.map((arg) => {
|
31970
|
-
if (typeParametersAndArgsMap[arg.type] !== void 0) {
|
31971
|
-
return {
|
31972
|
-
...typeParametersAndArgsMap[arg.type],
|
31973
|
-
name: arg.name
|
31974
|
-
};
|
31975
|
-
}
|
31976
|
-
if (arg.typeArguments) {
|
31977
|
-
return {
|
31978
|
-
...structuredClone(arg),
|
31979
|
-
typeArguments: this.resolveGenericArgTypes(
|
31980
|
-
abi,
|
31981
|
-
arg.typeArguments,
|
31982
|
-
typeParametersAndArgsMap
|
31983
|
-
)
|
31984
|
-
};
|
31985
|
-
}
|
31986
|
-
const argType = findTypeById(abi, arg.type);
|
31987
|
-
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
31988
|
-
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
31989
|
-
return {
|
31990
|
-
...structuredClone(arg),
|
31991
|
-
typeArguments: implicitTypeParameters.map((itp) => typeParametersAndArgsMap[itp])
|
31992
|
-
};
|
31993
|
-
}
|
31994
|
-
return arg;
|
31995
|
-
});
|
31996
|
-
}
|
31997
|
-
static getImplicitGenericTypeParameters(abi, args, implicitGenericParametersParam) {
|
31998
|
-
if (!Array.isArray(args)) {
|
31999
|
-
return null;
|
32000
|
-
}
|
32001
|
-
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
32002
|
-
args.forEach((a) => {
|
32003
|
-
const argType = findTypeById(abi, a.type);
|
32004
|
-
if (genericRegEx.test(argType.type)) {
|
32005
|
-
implicitGenericParameters.push(argType.typeId);
|
32006
|
-
return;
|
32007
|
-
}
|
32008
|
-
if (!Array.isArray(a.typeArguments)) {
|
32009
|
-
return;
|
32010
|
-
}
|
32011
|
-
this.getImplicitGenericTypeParameters(abi, a.typeArguments, implicitGenericParameters);
|
32012
|
-
});
|
32013
|
-
return implicitGenericParameters.length > 0 ? implicitGenericParameters : null;
|
32014
|
-
}
|
32015
|
-
getSignature() {
|
32016
|
-
const prefix = this.getArgSignaturePrefix();
|
32017
|
-
const content = this.getArgSignatureContent();
|
32018
|
-
return `${prefix}${content}`;
|
32019
|
-
}
|
32020
|
-
getArgSignaturePrefix() {
|
32021
|
-
const structMatch = structRegEx.test(this.type);
|
32022
|
-
if (structMatch) {
|
32023
|
-
return "s";
|
32024
|
-
}
|
32025
|
-
const arrayMatch = arrayRegEx.test(this.type);
|
32026
|
-
if (arrayMatch) {
|
32027
|
-
return "a";
|
32028
|
-
}
|
32029
|
-
const enumMatch = enumRegEx.test(this.type);
|
32030
|
-
if (enumMatch) {
|
32031
|
-
return "e";
|
32032
|
-
}
|
32033
|
-
return "";
|
32034
|
-
}
|
32035
|
-
getArgSignatureContent() {
|
32036
|
-
if (this.type === "raw untyped ptr") {
|
32037
|
-
return "rawptr";
|
32038
|
-
}
|
32039
|
-
if (this.type === "raw untyped slice") {
|
32040
|
-
return "rawslice";
|
32041
|
-
}
|
32042
|
-
const strMatch = stringRegEx.exec(this.type)?.groups;
|
32043
|
-
if (strMatch) {
|
32044
|
-
return `str[${strMatch.length}]`;
|
32045
|
-
}
|
32046
|
-
if (this.components === null) {
|
32047
|
-
return this.type;
|
32048
|
-
}
|
32049
|
-
const arrayMatch = arrayRegEx.exec(this.type)?.groups;
|
32050
|
-
if (arrayMatch) {
|
32051
|
-
return `[${this.components[0].getSignature()};${arrayMatch.length}]`;
|
32052
|
-
}
|
32053
|
-
const typeArgumentsSignature = this.originalTypeArguments !== null ? `<${this.originalTypeArguments.map((a) => new ResolvedAbiType(this.abi, a).getSignature()).join(",")}>` : "";
|
32054
|
-
const componentsSignature = `(${this.components.map((c) => c.getSignature()).join(",")})`;
|
32055
|
-
return `${typeArgumentsSignature}${componentsSignature}`;
|
32056
|
-
}
|
32057
|
-
};
|
32058
|
-
function getCoders(components, options) {
|
32059
|
-
const { getCoder: getCoder3 } = options;
|
32060
|
-
return components.reduce((obj, component) => {
|
32061
|
-
const o = obj;
|
32062
|
-
o[component.name] = getCoder3(component, options);
|
32063
|
-
return o;
|
32064
|
-
}, {});
|
32065
|
-
}
|
32066
|
-
var getCoder = (resolvedAbiType, options) => {
|
32067
|
-
switch (resolvedAbiType.type) {
|
32068
|
-
case U8_CODER_TYPE:
|
32069
|
-
case U16_CODER_TYPE:
|
32070
|
-
case U32_CODER_TYPE:
|
32071
|
-
return new NumberCoder(resolvedAbiType.type, options);
|
32072
|
-
case U64_CODER_TYPE:
|
32073
|
-
case RAW_PTR_CODER_TYPE:
|
32074
|
-
return new BigNumberCoder("u64");
|
32075
|
-
case U256_CODER_TYPE:
|
32076
|
-
return new BigNumberCoder("u256");
|
32077
|
-
case RAW_SLICE_CODER_TYPE:
|
32078
|
-
return new RawSliceCoder();
|
32079
|
-
case BOOL_CODER_TYPE:
|
32080
|
-
return new BooleanCoder(options);
|
32081
|
-
case B256_CODER_TYPE:
|
32082
|
-
return new B256Coder();
|
32083
|
-
case B512_CODER_TYPE:
|
32084
|
-
return new B512Coder();
|
32085
|
-
case BYTES_CODER_TYPE:
|
32086
|
-
return new ByteCoder();
|
32087
|
-
case STD_STRING_CODER_TYPE:
|
32088
|
-
return new StdStringCoder();
|
32089
|
-
default:
|
32090
|
-
break;
|
32091
|
-
}
|
32092
|
-
const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups;
|
32093
|
-
if (stringMatch) {
|
32094
|
-
const length = parseInt(stringMatch.length, 10);
|
32095
|
-
return new StringCoder(length);
|
32096
|
-
}
|
32097
|
-
const components = resolvedAbiType.components;
|
32098
|
-
const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups;
|
32099
|
-
if (arrayMatch) {
|
32100
|
-
const length = parseInt(arrayMatch.length, 10);
|
32101
|
-
const arg = components[0];
|
32102
|
-
if (!arg) {
|
32103
|
-
throw new FuelError(
|
32104
|
-
ErrorCode.INVALID_COMPONENT,
|
32105
|
-
`The provided Array type is missing an item of 'component'.`
|
32106
|
-
);
|
32107
|
-
}
|
32108
|
-
const arrayElementCoder = getCoder(arg, { isSmallBytes: true });
|
32109
|
-
return new ArrayCoder(arrayElementCoder, length);
|
32110
|
-
}
|
32111
|
-
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32112
|
-
const arg = findVectorBufferArgument(components);
|
32113
|
-
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32114
|
-
const itemCoder = getCoder(argType, { isSmallBytes: true, encoding: ENCODING_V0 });
|
32115
|
-
return new VecCoder(itemCoder);
|
32116
|
-
}
|
32117
|
-
const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups;
|
32118
|
-
if (structMatch) {
|
32119
|
-
const coders = getCoders(components, { isRightPadded: true, getCoder });
|
32120
|
-
return new StructCoder(structMatch.name, coders);
|
32121
|
-
}
|
32122
|
-
const enumMatch = enumRegEx.exec(resolvedAbiType.type)?.groups;
|
32123
|
-
if (enumMatch) {
|
32124
|
-
const coders = getCoders(components, { getCoder });
|
32125
|
-
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
32126
|
-
if (isOptionEnum) {
|
32127
|
-
return new OptionCoder(enumMatch.name, coders);
|
32128
|
-
}
|
32129
|
-
return new EnumCoder(enumMatch.name, coders);
|
32130
|
-
}
|
32131
|
-
const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups;
|
32132
|
-
if (tupleMatch) {
|
32133
|
-
const coders = components.map(
|
32134
|
-
(component) => getCoder(component, { isRightPadded: true, encoding: ENCODING_V0 })
|
32135
|
-
);
|
32136
|
-
return new TupleCoder(coders);
|
32137
|
-
}
|
32138
|
-
if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
|
32139
|
-
throw new FuelError(
|
32140
|
-
ErrorCode.INVALID_DATA,
|
32141
|
-
"String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
|
32142
|
-
);
|
32143
|
-
}
|
32144
|
-
throw new FuelError(
|
32145
|
-
ErrorCode.CODER_NOT_FOUND,
|
32146
|
-
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
32147
|
-
);
|
32148
|
-
};
|
32149
|
-
var BooleanCoder2 = class extends Coder {
|
32150
|
-
constructor() {
|
32151
|
-
super("boolean", "boolean", 1);
|
32152
|
-
}
|
32153
|
-
encode(value) {
|
32154
|
-
const isTrueBool = value === true || value === false;
|
32155
|
-
if (!isTrueBool) {
|
32156
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid boolean value.`);
|
32157
|
-
}
|
32158
|
-
return toBytes2(value ? 1 : 0, this.encodedLength);
|
32159
|
-
}
|
32160
|
-
decode(data, offset) {
|
32161
|
-
if (data.length < this.encodedLength) {
|
32162
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean data size.`);
|
32163
|
-
}
|
32164
|
-
const bytes2 = bn(data.slice(offset, offset + this.encodedLength));
|
32165
|
-
if (bytes2.isZero()) {
|
32166
|
-
return [false, offset + this.encodedLength];
|
32167
|
-
}
|
32168
|
-
if (!bytes2.eq(bn(1))) {
|
32169
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid boolean value.`);
|
32170
|
-
}
|
32171
|
-
return [true, offset + this.encodedLength];
|
32172
|
-
}
|
32173
|
-
};
|
32174
|
-
var ByteCoder2 = class extends Coder {
|
32175
|
-
constructor() {
|
32176
|
-
super("struct", "struct Bytes", WORD_SIZE);
|
32177
|
-
}
|
32178
|
-
encode(value) {
|
32179
|
-
const bytes2 = value instanceof Uint8Array ? value : new Uint8Array(value);
|
32180
|
-
const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
|
32181
|
-
return new Uint8Array([...lengthBytes, ...bytes2]);
|
32182
|
-
}
|
32183
|
-
decode(data, offset) {
|
32184
|
-
if (data.length < WORD_SIZE) {
|
32185
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid byte data size.`);
|
32186
|
-
}
|
32187
|
-
const offsetAndLength = offset + WORD_SIZE;
|
32188
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
32189
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32190
|
-
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
32191
|
-
if (dataBytes.length !== length) {
|
32192
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid bytes byte data size.`);
|
32193
|
-
}
|
32194
|
-
return [dataBytes, offsetAndLength + length];
|
32195
|
-
}
|
32196
|
-
};
|
32197
|
-
__publicField4(ByteCoder2, "memorySize", 1);
|
32198
|
-
var isFullyNativeEnum2 = (enumCoders) => Object.values(enumCoders).every(
|
32199
|
-
// @ts-expect-error complicated types
|
32200
|
-
({ type: type3, coders }) => type3 === "()" && JSON.stringify(coders) === JSON.stringify([])
|
32201
|
-
);
|
32202
|
-
var EnumCoder2 = class extends Coder {
|
32203
|
-
name;
|
32204
|
-
coders;
|
32205
|
-
#caseIndexCoder;
|
32206
|
-
#encodedValueSize;
|
32207
|
-
constructor(name, coders) {
|
32208
|
-
const caseIndexCoder = new BigNumberCoder("u64");
|
32209
|
-
const encodedValueSize = Object.values(coders).reduce(
|
32210
|
-
(max, coder) => Math.max(max, coder.encodedLength),
|
32211
|
-
0
|
32212
|
-
);
|
32213
|
-
super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
|
32214
|
-
this.name = name;
|
32215
|
-
this.coders = coders;
|
32216
|
-
this.#caseIndexCoder = caseIndexCoder;
|
32217
|
-
this.#encodedValueSize = encodedValueSize;
|
32218
|
-
}
|
32219
|
-
#encodeNativeEnum(value) {
|
32220
|
-
const valueCoder = this.coders[value];
|
32221
|
-
const encodedValue = valueCoder.encode([]);
|
32222
|
-
const caseIndex = Object.keys(this.coders).indexOf(value);
|
32223
|
-
const padding = new Uint8Array(this.#encodedValueSize - valueCoder.encodedLength);
|
32224
|
-
return concat([this.#caseIndexCoder.encode(caseIndex), padding, encodedValue]);
|
32225
|
-
}
|
32226
|
-
encode(value) {
|
32227
|
-
if (typeof value === "string" && this.coders[value]) {
|
32228
|
-
return this.#encodeNativeEnum(value);
|
32229
|
-
}
|
32230
|
-
const [caseKey, ...empty] = Object.keys(value);
|
32231
|
-
if (!caseKey) {
|
32232
|
-
throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, "A field for the case must be provided.");
|
32233
|
-
}
|
32234
|
-
if (empty.length !== 0) {
|
32235
|
-
throw new FuelError(ErrorCode.INVALID_DECODE_VALUE, "Only one field must be provided.");
|
32236
|
-
}
|
32237
|
-
const valueCoder = this.coders[caseKey];
|
32238
|
-
const caseIndex = Object.keys(this.coders).indexOf(caseKey);
|
32239
|
-
const encodedValue = valueCoder.encode(value[caseKey]);
|
32240
|
-
return new Uint8Array([...this.#caseIndexCoder.encode(caseIndex), ...encodedValue]);
|
32241
|
-
}
|
32242
|
-
#decodeNativeEnum(caseKey, newOffset) {
|
32243
|
-
return [caseKey, newOffset];
|
32244
|
-
}
|
32245
|
-
decode(data, offset) {
|
32246
|
-
if (data.length < this.#encodedValueSize) {
|
32247
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid enum data size.`);
|
32248
|
-
}
|
32249
|
-
const caseBytes = new BigNumberCoder("u64").decode(data, offset)[0];
|
32250
|
-
const caseIndex = toNumber(caseBytes);
|
32251
|
-
const caseKey = Object.keys(this.coders)[caseIndex];
|
32252
|
-
if (!caseKey) {
|
32253
|
-
throw new FuelError(
|
32254
|
-
ErrorCode.INVALID_DECODE_VALUE,
|
32255
|
-
`Invalid caseIndex "${caseIndex}". Valid cases: ${Object.keys(this.coders)}.`
|
32256
|
-
);
|
32257
|
-
}
|
32258
|
-
const valueCoder = this.coders[caseKey];
|
32259
|
-
const offsetAndCase = offset + WORD_SIZE;
|
32260
|
-
const [decoded, newOffset] = valueCoder.decode(data, offsetAndCase);
|
32261
|
-
if (isFullyNativeEnum2(this.coders)) {
|
32262
|
-
return this.#decodeNativeEnum(caseKey, newOffset);
|
32263
|
-
}
|
32264
|
-
return [{ [caseKey]: decoded }, newOffset];
|
32265
|
-
}
|
32266
|
-
};
|
32267
|
-
var getLength = (baseType) => {
|
32268
|
-
switch (baseType) {
|
32269
|
-
case "u8":
|
32270
|
-
return 1;
|
32271
|
-
case "u16":
|
32272
|
-
return 2;
|
32273
|
-
case "u32":
|
32274
|
-
return 4;
|
32275
|
-
default:
|
32276
|
-
throw new FuelError(ErrorCode.TYPE_NOT_SUPPORTED, `Invalid number type: ${baseType}`);
|
32277
|
-
}
|
32278
|
-
};
|
32279
|
-
var NumberCoder2 = class extends Coder {
|
32280
|
-
length;
|
32281
|
-
baseType;
|
32282
|
-
constructor(baseType) {
|
32283
|
-
const length = getLength(baseType);
|
32284
|
-
super("number", baseType, length);
|
32285
|
-
this.baseType = baseType;
|
32286
|
-
this.length = length;
|
32287
|
-
}
|
32288
|
-
encode(value) {
|
32289
|
-
let bytes2;
|
32290
|
-
try {
|
32291
|
-
bytes2 = toBytes2(value);
|
32292
|
-
} catch (error) {
|
32293
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}.`);
|
32294
|
-
}
|
32295
|
-
if (bytes2.length > this.length) {
|
32296
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Invalid ${this.baseType}, too many bytes.`);
|
32297
|
-
}
|
32298
|
-
return toBytes2(bytes2, this.length);
|
32299
|
-
}
|
32300
|
-
decode(data, offset) {
|
32301
|
-
if (data.length < this.encodedLength) {
|
32302
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number data size.`);
|
32303
|
-
}
|
32304
|
-
const bytes2 = data.slice(offset, offset + this.length);
|
32305
|
-
if (bytes2.length !== this.encodedLength) {
|
32306
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid number byte data size.`);
|
32307
|
-
}
|
32308
|
-
return [toNumber(bytes2), offset + this.length];
|
32309
|
-
}
|
32310
|
-
};
|
32311
|
-
var OptionCoder2 = class extends EnumCoder2 {
|
32312
|
-
encode(value) {
|
32313
|
-
const result = super.encode(this.toSwayOption(value));
|
32314
|
-
return result;
|
32315
|
-
}
|
32316
|
-
toSwayOption(input) {
|
32317
|
-
if (input !== void 0) {
|
32318
|
-
return { Some: input };
|
32319
|
-
}
|
32320
|
-
return { None: [] };
|
32321
|
-
}
|
32322
|
-
decode(data, offset) {
|
32323
|
-
const [decoded, newOffset] = super.decode(data, offset);
|
32324
|
-
return [this.toOption(decoded), newOffset];
|
32325
|
-
}
|
32326
|
-
toOption(output2) {
|
32327
|
-
if (output2 && "Some" in output2) {
|
32328
|
-
return output2.Some;
|
32329
|
-
}
|
32330
|
-
return void 0;
|
32331
|
-
}
|
32332
|
-
};
|
32333
|
-
var RawSliceCoder2 = class extends Coder {
|
32334
|
-
constructor() {
|
32335
|
-
super("raw untyped slice", "raw untyped slice", WORD_SIZE);
|
32336
|
-
}
|
32337
|
-
encode(value) {
|
32338
|
-
if (!Array.isArray(value)) {
|
32339
|
-
throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
|
32340
|
-
}
|
32341
|
-
const internalCoder = new ArrayCoder(new NumberCoder2("u8"), value.length);
|
32342
|
-
const bytes2 = internalCoder.encode(value);
|
32343
|
-
const lengthBytes = new BigNumberCoder("u64").encode(bytes2.length);
|
32344
|
-
return new Uint8Array([...lengthBytes, ...bytes2]);
|
32345
|
-
}
|
32346
|
-
decode(data, offset) {
|
32347
|
-
if (data.length < this.encodedLength) {
|
32348
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid raw slice data size.`);
|
32349
|
-
}
|
32350
|
-
const offsetAndLength = offset + WORD_SIZE;
|
32351
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
32352
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32353
|
-
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
32354
|
-
if (dataBytes.length !== length) {
|
32355
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid raw slice byte data size.`);
|
32356
|
-
}
|
32357
|
-
const internalCoder = new ArrayCoder(new NumberCoder2("u8"), length);
|
32358
|
-
const [decodedValue] = internalCoder.decode(dataBytes, 0);
|
32359
|
-
return [decodedValue, offsetAndLength + length];
|
32360
|
-
}
|
32361
|
-
};
|
32362
|
-
var StdStringCoder2 = class extends Coder {
|
32363
|
-
constructor() {
|
32364
|
-
super("struct", "struct String", WORD_SIZE);
|
32365
|
-
}
|
32366
|
-
encode(value) {
|
32367
|
-
const bytes2 = toUtf8Bytes(value);
|
32368
|
-
const lengthBytes = new BigNumberCoder("u64").encode(value.length);
|
32369
|
-
return new Uint8Array([...lengthBytes, ...bytes2]);
|
32370
|
-
}
|
32371
|
-
decode(data, offset) {
|
32372
|
-
if (data.length < this.encodedLength) {
|
32373
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string data size.`);
|
32374
|
-
}
|
32375
|
-
const offsetAndLength = offset + WORD_SIZE;
|
32376
|
-
const lengthBytes = data.slice(offset, offsetAndLength);
|
32377
|
-
const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
|
32378
|
-
const dataBytes = data.slice(offsetAndLength, offsetAndLength + length);
|
32379
|
-
if (dataBytes.length !== length) {
|
32380
|
-
throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid std string byte data size.`);
|
32381
|
-
}
|
32382
|
-
return [toUtf8String(dataBytes), offsetAndLength + length];
|
32383
|
-
}
|
32384
|
-
};
|
32385
|
-
__publicField4(StdStringCoder2, "memorySize", 1);
|
32386
31531
|
var StrSliceCoder = class extends Coder {
|
32387
31532
|
constructor() {
|
32388
31533
|
super("strSlice", "str", WORD_SIZE);
|
@@ -32407,7 +31552,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32407
31552
|
}
|
32408
31553
|
};
|
32409
31554
|
__publicField4(StrSliceCoder, "memorySize", 1);
|
32410
|
-
var
|
31555
|
+
var StringCoder = class extends Coder {
|
32411
31556
|
constructor(length) {
|
32412
31557
|
super("string", `str[${length}]`, length);
|
32413
31558
|
}
|
@@ -32428,7 +31573,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32428
31573
|
return [toUtf8String(bytes2), offset + this.encodedLength];
|
32429
31574
|
}
|
32430
31575
|
};
|
32431
|
-
var
|
31576
|
+
var StructCoder = class extends Coder {
|
32432
31577
|
name;
|
32433
31578
|
coders;
|
32434
31579
|
constructor(name, coders) {
|
@@ -32445,7 +31590,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32445
31590
|
Object.keys(this.coders).map((fieldName) => {
|
32446
31591
|
const fieldCoder = this.coders[fieldName];
|
32447
31592
|
const fieldValue = value[fieldName];
|
32448
|
-
if (!(fieldCoder instanceof
|
31593
|
+
if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
|
32449
31594
|
throw new FuelError(
|
32450
31595
|
ErrorCode.ENCODE_ERROR,
|
32451
31596
|
`Invalid ${this.type}. Field "${fieldName}" not present.`
|
@@ -32470,7 +31615,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32470
31615
|
return [decodedValue, newOffset];
|
32471
31616
|
}
|
32472
31617
|
};
|
32473
|
-
var
|
31618
|
+
var TupleCoder = class extends Coder {
|
32474
31619
|
coders;
|
32475
31620
|
constructor(coders) {
|
32476
31621
|
const encodedLength = coders.reduce((acc, coder) => acc + coder.encodedLength, 0);
|
@@ -32496,13 +31641,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32496
31641
|
return [decodedValue, newOffset];
|
32497
31642
|
}
|
32498
31643
|
};
|
32499
|
-
var
|
31644
|
+
var isUint8Array = (value) => value instanceof Uint8Array;
|
31645
|
+
var VecCoder = class extends Coder {
|
32500
31646
|
coder;
|
32501
31647
|
#isOptionVec;
|
32502
31648
|
constructor(coder) {
|
32503
31649
|
super("struct", `struct Vec`, coder.encodedLength + WORD_SIZE);
|
32504
31650
|
this.coder = coder;
|
32505
|
-
this.#isOptionVec = this.coder instanceof
|
31651
|
+
this.#isOptionVec = this.coder instanceof OptionCoder;
|
32506
31652
|
}
|
32507
31653
|
encode(value) {
|
32508
31654
|
if (!Array.isArray(value) && !isUint8Array(value)) {
|
@@ -32541,29 +31687,214 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32541
31687
|
return [chunks, newOffset];
|
32542
31688
|
}
|
32543
31689
|
};
|
32544
|
-
var
|
31690
|
+
var getEncodingVersion = (encoding) => {
|
31691
|
+
switch (encoding) {
|
31692
|
+
case void 0:
|
31693
|
+
case ENCODING_V1:
|
31694
|
+
return ENCODING_V1;
|
31695
|
+
default:
|
31696
|
+
throw new FuelError(
|
31697
|
+
ErrorCode.UNSUPPORTED_ENCODING_VERSION,
|
31698
|
+
`Encoding version '${encoding}' is unsupported.`
|
31699
|
+
);
|
31700
|
+
}
|
31701
|
+
};
|
31702
|
+
var findFunctionByName = (abi, name) => {
|
31703
|
+
const fn = abi.functions.find((f2) => f2.name === name);
|
31704
|
+
if (!fn) {
|
31705
|
+
throw new FuelError(
|
31706
|
+
ErrorCode.FUNCTION_NOT_FOUND,
|
31707
|
+
`Function with name '${name}' doesn't exist in the ABI`
|
31708
|
+
);
|
31709
|
+
}
|
31710
|
+
return fn;
|
31711
|
+
};
|
31712
|
+
var findTypeById = (abi, typeId) => {
|
31713
|
+
const type3 = abi.types.find((t) => t.typeId === typeId);
|
31714
|
+
if (!type3) {
|
31715
|
+
throw new FuelError(
|
31716
|
+
ErrorCode.TYPE_NOT_FOUND,
|
31717
|
+
`Type with typeId '${typeId}' doesn't exist in the ABI.`
|
31718
|
+
);
|
31719
|
+
}
|
31720
|
+
return type3;
|
31721
|
+
};
|
31722
|
+
var findNonEmptyInputs = (abi, inputs) => inputs.filter((input) => findTypeById(abi, input.type).type !== "()");
|
31723
|
+
var findVectorBufferArgument = (components) => {
|
31724
|
+
const bufferComponent = components.find((c) => c.name === "buf");
|
31725
|
+
const bufferTypeArgument = bufferComponent?.originalTypeArguments?.[0];
|
31726
|
+
if (!bufferComponent || !bufferTypeArgument) {
|
31727
|
+
throw new FuelError(
|
31728
|
+
ErrorCode.INVALID_COMPONENT,
|
31729
|
+
`The Vec type provided is missing or has a malformed 'buf' component.`
|
31730
|
+
);
|
31731
|
+
}
|
31732
|
+
return bufferTypeArgument;
|
31733
|
+
};
|
31734
|
+
var ResolvedAbiType = class {
|
31735
|
+
abi;
|
31736
|
+
name;
|
31737
|
+
type;
|
31738
|
+
originalTypeArguments;
|
31739
|
+
components;
|
31740
|
+
constructor(abi, argument) {
|
31741
|
+
this.abi = abi;
|
31742
|
+
this.name = argument.name;
|
31743
|
+
const type3 = findTypeById(abi, argument.type);
|
31744
|
+
this.type = type3.type;
|
31745
|
+
this.originalTypeArguments = argument.typeArguments;
|
31746
|
+
this.components = ResolvedAbiType.getResolvedGenericComponents(
|
31747
|
+
abi,
|
31748
|
+
argument,
|
31749
|
+
type3.components,
|
31750
|
+
type3.typeParameters ?? ResolvedAbiType.getImplicitGenericTypeParameters(abi, type3.components)
|
31751
|
+
);
|
31752
|
+
}
|
31753
|
+
static getResolvedGenericComponents(abi, arg, components, typeParameters) {
|
31754
|
+
if (components === null) {
|
31755
|
+
return null;
|
31756
|
+
}
|
31757
|
+
if (typeParameters === null || typeParameters.length === 0) {
|
31758
|
+
return components.map((c) => new ResolvedAbiType(abi, c));
|
31759
|
+
}
|
31760
|
+
const typeParametersAndArgsMap = typeParameters.reduce(
|
31761
|
+
(obj, typeParameter, typeParameterIndex) => {
|
31762
|
+
const o = { ...obj };
|
31763
|
+
o[typeParameter] = structuredClone(
|
31764
|
+
arg.typeArguments?.[typeParameterIndex]
|
31765
|
+
);
|
31766
|
+
return o;
|
31767
|
+
},
|
31768
|
+
{}
|
31769
|
+
);
|
31770
|
+
const resolvedComponents = this.resolveGenericArgTypes(
|
31771
|
+
abi,
|
31772
|
+
components,
|
31773
|
+
typeParametersAndArgsMap
|
31774
|
+
);
|
31775
|
+
return resolvedComponents.map((c) => new ResolvedAbiType(abi, c));
|
31776
|
+
}
|
31777
|
+
static resolveGenericArgTypes(abi, args, typeParametersAndArgsMap) {
|
31778
|
+
return args.map((arg) => {
|
31779
|
+
if (typeParametersAndArgsMap[arg.type] !== void 0) {
|
31780
|
+
return {
|
31781
|
+
...typeParametersAndArgsMap[arg.type],
|
31782
|
+
name: arg.name
|
31783
|
+
};
|
31784
|
+
}
|
31785
|
+
if (arg.typeArguments) {
|
31786
|
+
return {
|
31787
|
+
...structuredClone(arg),
|
31788
|
+
typeArguments: this.resolveGenericArgTypes(
|
31789
|
+
abi,
|
31790
|
+
arg.typeArguments,
|
31791
|
+
typeParametersAndArgsMap
|
31792
|
+
)
|
31793
|
+
};
|
31794
|
+
}
|
31795
|
+
const argType = findTypeById(abi, arg.type);
|
31796
|
+
const implicitTypeParameters = this.getImplicitGenericTypeParameters(abi, argType.components);
|
31797
|
+
if (implicitTypeParameters && implicitTypeParameters.length > 0) {
|
31798
|
+
return {
|
31799
|
+
...structuredClone(arg),
|
31800
|
+
typeArguments: implicitTypeParameters.map((itp) => typeParametersAndArgsMap[itp])
|
31801
|
+
};
|
31802
|
+
}
|
31803
|
+
return arg;
|
31804
|
+
});
|
31805
|
+
}
|
31806
|
+
static getImplicitGenericTypeParameters(abi, args, implicitGenericParametersParam) {
|
31807
|
+
if (!Array.isArray(args)) {
|
31808
|
+
return null;
|
31809
|
+
}
|
31810
|
+
const implicitGenericParameters = implicitGenericParametersParam ?? [];
|
31811
|
+
args.forEach((a) => {
|
31812
|
+
const argType = findTypeById(abi, a.type);
|
31813
|
+
if (genericRegEx.test(argType.type)) {
|
31814
|
+
implicitGenericParameters.push(argType.typeId);
|
31815
|
+
return;
|
31816
|
+
}
|
31817
|
+
if (!Array.isArray(a.typeArguments)) {
|
31818
|
+
return;
|
31819
|
+
}
|
31820
|
+
this.getImplicitGenericTypeParameters(abi, a.typeArguments, implicitGenericParameters);
|
31821
|
+
});
|
31822
|
+
return implicitGenericParameters.length > 0 ? implicitGenericParameters : null;
|
31823
|
+
}
|
31824
|
+
getSignature() {
|
31825
|
+
const prefix = this.getArgSignaturePrefix();
|
31826
|
+
const content = this.getArgSignatureContent();
|
31827
|
+
return `${prefix}${content}`;
|
31828
|
+
}
|
31829
|
+
getArgSignaturePrefix() {
|
31830
|
+
const structMatch = structRegEx.test(this.type);
|
31831
|
+
if (structMatch) {
|
31832
|
+
return "s";
|
31833
|
+
}
|
31834
|
+
const arrayMatch = arrayRegEx.test(this.type);
|
31835
|
+
if (arrayMatch) {
|
31836
|
+
return "a";
|
31837
|
+
}
|
31838
|
+
const enumMatch = enumRegEx.test(this.type);
|
31839
|
+
if (enumMatch) {
|
31840
|
+
return "e";
|
31841
|
+
}
|
31842
|
+
return "";
|
31843
|
+
}
|
31844
|
+
getArgSignatureContent() {
|
31845
|
+
if (this.type === "raw untyped ptr") {
|
31846
|
+
return "rawptr";
|
31847
|
+
}
|
31848
|
+
if (this.type === "raw untyped slice") {
|
31849
|
+
return "rawslice";
|
31850
|
+
}
|
31851
|
+
const strMatch = stringRegEx.exec(this.type)?.groups;
|
31852
|
+
if (strMatch) {
|
31853
|
+
return `str[${strMatch.length}]`;
|
31854
|
+
}
|
31855
|
+
if (this.components === null) {
|
31856
|
+
return this.type;
|
31857
|
+
}
|
31858
|
+
const arrayMatch = arrayRegEx.exec(this.type)?.groups;
|
31859
|
+
if (arrayMatch) {
|
31860
|
+
return `[${this.components[0].getSignature()};${arrayMatch.length}]`;
|
31861
|
+
}
|
31862
|
+
const typeArgumentsSignature = this.originalTypeArguments !== null ? `<${this.originalTypeArguments.map((a) => new ResolvedAbiType(this.abi, a).getSignature()).join(",")}>` : "";
|
31863
|
+
const componentsSignature = `(${this.components.map((c) => c.getSignature()).join(",")})`;
|
31864
|
+
return `${typeArgumentsSignature}${componentsSignature}`;
|
31865
|
+
}
|
31866
|
+
};
|
31867
|
+
function getCoders(components, options) {
|
31868
|
+
const { getCoder: getCoder2 } = options;
|
31869
|
+
return components.reduce((obj, component) => {
|
31870
|
+
const o = obj;
|
31871
|
+
o[component.name] = getCoder2(component, options);
|
31872
|
+
return o;
|
31873
|
+
}, {});
|
31874
|
+
}
|
31875
|
+
var getCoder = (resolvedAbiType, _options) => {
|
32545
31876
|
switch (resolvedAbiType.type) {
|
32546
31877
|
case U8_CODER_TYPE:
|
32547
31878
|
case U16_CODER_TYPE:
|
32548
31879
|
case U32_CODER_TYPE:
|
32549
|
-
return new
|
31880
|
+
return new NumberCoder(resolvedAbiType.type);
|
32550
31881
|
case U64_CODER_TYPE:
|
32551
31882
|
case RAW_PTR_CODER_TYPE:
|
32552
31883
|
return new BigNumberCoder("u64");
|
32553
31884
|
case U256_CODER_TYPE:
|
32554
31885
|
return new BigNumberCoder("u256");
|
32555
31886
|
case RAW_SLICE_CODER_TYPE:
|
32556
|
-
return new
|
31887
|
+
return new RawSliceCoder();
|
32557
31888
|
case BOOL_CODER_TYPE:
|
32558
|
-
return new
|
31889
|
+
return new BooleanCoder();
|
32559
31890
|
case B256_CODER_TYPE:
|
32560
31891
|
return new B256Coder();
|
32561
31892
|
case B512_CODER_TYPE:
|
32562
31893
|
return new B512Coder();
|
32563
31894
|
case BYTES_CODER_TYPE:
|
32564
|
-
return new
|
31895
|
+
return new ByteCoder();
|
32565
31896
|
case STD_STRING_CODER_TYPE:
|
32566
|
-
return new
|
31897
|
+
return new StdStringCoder();
|
32567
31898
|
case STR_SLICE_CODER_TYPE:
|
32568
31899
|
return new StrSliceCoder();
|
32569
31900
|
default:
|
@@ -32572,7 +31903,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32572
31903
|
const stringMatch = stringRegEx.exec(resolvedAbiType.type)?.groups;
|
32573
31904
|
if (stringMatch) {
|
32574
31905
|
const length = parseInt(stringMatch.length, 10);
|
32575
|
-
return new
|
31906
|
+
return new StringCoder(length);
|
32576
31907
|
}
|
32577
31908
|
const components = resolvedAbiType.components;
|
32578
31909
|
const arrayMatch = arrayRegEx.exec(resolvedAbiType.type)?.groups;
|
@@ -32585,46 +31916,42 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32585
31916
|
`The provided Array type is missing an item of 'component'.`
|
32586
31917
|
);
|
32587
31918
|
}
|
32588
|
-
const arrayElementCoder =
|
31919
|
+
const arrayElementCoder = getCoder(arg);
|
32589
31920
|
return new ArrayCoder(arrayElementCoder, length);
|
32590
31921
|
}
|
32591
31922
|
if (resolvedAbiType.type === VEC_CODER_TYPE) {
|
32592
31923
|
const arg = findVectorBufferArgument(components);
|
32593
31924
|
const argType = new ResolvedAbiType(resolvedAbiType.abi, arg);
|
32594
|
-
const itemCoder =
|
32595
|
-
return new
|
31925
|
+
const itemCoder = getCoder(argType, { encoding: ENCODING_V1 });
|
31926
|
+
return new VecCoder(itemCoder);
|
32596
31927
|
}
|
32597
31928
|
const structMatch = structRegEx.exec(resolvedAbiType.type)?.groups;
|
32598
31929
|
if (structMatch) {
|
32599
|
-
const coders = getCoders(components, {
|
32600
|
-
return new
|
31930
|
+
const coders = getCoders(components, { getCoder });
|
31931
|
+
return new StructCoder(structMatch.name, coders);
|
32601
31932
|
}
|
32602
31933
|
const enumMatch = enumRegEx.exec(resolvedAbiType.type)?.groups;
|
32603
31934
|
if (enumMatch) {
|
32604
|
-
const coders = getCoders(components, { getCoder
|
31935
|
+
const coders = getCoders(components, { getCoder });
|
32605
31936
|
const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
|
32606
31937
|
if (isOptionEnum) {
|
32607
|
-
return new
|
31938
|
+
return new OptionCoder(enumMatch.name, coders);
|
32608
31939
|
}
|
32609
|
-
return new
|
31940
|
+
return new EnumCoder(enumMatch.name, coders);
|
32610
31941
|
}
|
32611
31942
|
const tupleMatch = tupleRegEx.exec(resolvedAbiType.type)?.groups;
|
32612
31943
|
if (tupleMatch) {
|
32613
|
-
const coders = components.map(
|
32614
|
-
|
32615
|
-
);
|
32616
|
-
return new TupleCoder2(coders);
|
31944
|
+
const coders = components.map((component) => getCoder(component, { encoding: ENCODING_V1 }));
|
31945
|
+
return new TupleCoder(coders);
|
32617
31946
|
}
|
32618
31947
|
throw new FuelError(
|
32619
31948
|
ErrorCode.CODER_NOT_FOUND,
|
32620
31949
|
`Coder not found: ${JSON.stringify(resolvedAbiType)}.`
|
32621
31950
|
);
|
32622
31951
|
};
|
32623
|
-
function getCoderForEncoding(encoding =
|
31952
|
+
function getCoderForEncoding(encoding = ENCODING_V1) {
|
32624
31953
|
switch (encoding) {
|
32625
31954
|
case ENCODING_V1:
|
32626
|
-
return getCoder2;
|
32627
|
-
case ENCODING_V0:
|
32628
31955
|
return getCoder;
|
32629
31956
|
default:
|
32630
31957
|
throw new FuelError(
|
@@ -32635,7 +31962,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32635
31962
|
}
|
32636
31963
|
var AbiCoder = class {
|
32637
31964
|
static getCoder(abi, argument, options = {
|
32638
|
-
|
31965
|
+
padToWordSize: false
|
32639
31966
|
}) {
|
32640
31967
|
const resolvedAbiType = new ResolvedAbiType(abi, argument);
|
32641
31968
|
return getCoderForEncoding(options.encoding)(resolvedAbiType, options);
|
@@ -32655,8 +31982,6 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32655
31982
|
name;
|
32656
31983
|
jsonFn;
|
32657
31984
|
attributes;
|
32658
|
-
isInputDataPointer;
|
32659
|
-
outputMetadata;
|
32660
31985
|
jsonAbi;
|
32661
31986
|
constructor(jsonAbi, name) {
|
32662
31987
|
this.jsonAbi = jsonAbi;
|
@@ -32664,13 +31989,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32664
31989
|
this.name = name;
|
32665
31990
|
this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
|
32666
31991
|
this.selector = FunctionFragment.getFunctionSelector(this.signature);
|
32667
|
-
this.selectorBytes = new
|
31992
|
+
this.selectorBytes = new StdStringCoder().encode(name);
|
32668
31993
|
this.encoding = getEncodingVersion(jsonAbi.encoding);
|
32669
|
-
this.isInputDataPointer = this.#isInputDataPointer();
|
32670
|
-
this.outputMetadata = {
|
32671
|
-
isHeapType: this.#isOutputDataHeap(),
|
32672
|
-
encodedLength: this.#getOutputEncodedLength()
|
32673
|
-
};
|
32674
31994
|
this.attributes = this.jsonFn.attributes ?? [];
|
32675
31995
|
}
|
32676
31996
|
static getSignature(abi, fn) {
|
@@ -32683,29 +32003,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32683
32003
|
const hashedFunctionSignature = sha2562(bufferFromString2(functionSignature, "utf-8"));
|
32684
32004
|
return bn(hashedFunctionSignature.slice(0, 10)).toHex(8);
|
32685
32005
|
}
|
32686
|
-
|
32687
|
-
const inputTypes = this.jsonFn.inputs.map((i) => findTypeById(this.jsonAbi, i.type));
|
32688
|
-
return this.jsonFn.inputs.length > 1 || isPointerType(inputTypes[0]?.type || "");
|
32689
|
-
}
|
32690
|
-
#isOutputDataHeap() {
|
32691
|
-
const outputType = findTypeById(this.jsonAbi, this.jsonFn.output.type);
|
32692
|
-
return isHeapType(outputType?.type || "");
|
32693
|
-
}
|
32694
|
-
#getOutputEncodedLength() {
|
32695
|
-
try {
|
32696
|
-
const heapCoder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
|
32697
|
-
if (heapCoder instanceof VecCoder) {
|
32698
|
-
return heapCoder.coder.encodedLength;
|
32699
|
-
}
|
32700
|
-
if (heapCoder instanceof ByteCoder) {
|
32701
|
-
return ByteCoder.memorySize;
|
32702
|
-
}
|
32703
|
-
return heapCoder.encodedLength;
|
32704
|
-
} catch (e) {
|
32705
|
-
return 0;
|
32706
|
-
}
|
32707
|
-
}
|
32708
|
-
encodeArguments(values, offset = 0) {
|
32006
|
+
encodeArguments(values) {
|
32709
32007
|
FunctionFragment.verifyArgsAndInputsAlign(values, this.jsonFn.inputs, this.jsonAbi);
|
32710
32008
|
const shallowCopyValues = values.slice();
|
32711
32009
|
const nonEmptyInputs = findNonEmptyInputs(this.jsonAbi, this.jsonFn.inputs);
|
@@ -32715,15 +32013,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32715
32013
|
}
|
32716
32014
|
const coders = nonEmptyInputs.map(
|
32717
32015
|
(t) => AbiCoder.getCoder(this.jsonAbi, t, {
|
32718
|
-
isRightPadded: nonEmptyInputs.length > 1,
|
32719
32016
|
encoding: this.encoding
|
32720
32017
|
})
|
32721
32018
|
);
|
32722
|
-
|
32723
|
-
return new TupleCoder2(coders).encode(shallowCopyValues);
|
32724
|
-
}
|
32725
|
-
const results = new TupleCoder(coders).encode(shallowCopyValues);
|
32726
|
-
return unpackDynamicData(results, offset, results.byteLength);
|
32019
|
+
return new TupleCoder(coders).encode(shallowCopyValues);
|
32727
32020
|
}
|
32728
32021
|
static verifyArgsAndInputsAlign(args, inputs, abi) {
|
32729
32022
|
if (args.length === inputs.length) {
|
@@ -32832,9 +32125,9 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32832
32125
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
32833
32126
|
return fragment.decodeArguments(data);
|
32834
32127
|
}
|
32835
|
-
encodeFunctionData(functionFragment, values
|
32128
|
+
encodeFunctionData(functionFragment, values) {
|
32836
32129
|
const fragment = typeof functionFragment === "string" ? this.getFunction(functionFragment) : functionFragment;
|
32837
|
-
return fragment.encodeArguments(values
|
32130
|
+
return fragment.encodeArguments(values);
|
32838
32131
|
}
|
32839
32132
|
// Decode the result of a function call
|
32840
32133
|
decodeFunctionResult(functionFragment, data) {
|
@@ -32862,9 +32155,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32862
32155
|
);
|
32863
32156
|
}
|
32864
32157
|
return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
|
32865
|
-
|
32866
|
-
// TODO: Review support for configurables in v1 encoding when it becomes available
|
32867
|
-
encoding: ENCODING_V0
|
32158
|
+
encoding: this.encoding
|
32868
32159
|
});
|
32869
32160
|
}
|
32870
32161
|
getTypeById(typeId) {
|
@@ -32914,8 +32205,8 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32914
32205
|
var TxPointerCoder = class extends StructCoder {
|
32915
32206
|
constructor() {
|
32916
32207
|
super("TxPointer", {
|
32917
|
-
blockHeight: new NumberCoder("u32"),
|
32918
|
-
txIndex: new NumberCoder("u16")
|
32208
|
+
blockHeight: new NumberCoder("u32", { padToWordSize: true }),
|
32209
|
+
txIndex: new NumberCoder("u16", { padToWordSize: true })
|
32919
32210
|
});
|
32920
32211
|
}
|
32921
32212
|
};
|
@@ -32932,12 +32223,12 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32932
32223
|
encode(value) {
|
32933
32224
|
const parts = [];
|
32934
32225
|
parts.push(new B256Coder().encode(value.txID));
|
32935
|
-
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
32226
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputIndex));
|
32936
32227
|
parts.push(new B256Coder().encode(value.owner));
|
32937
32228
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
32938
32229
|
parts.push(new B256Coder().encode(value.assetId));
|
32939
32230
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
32940
|
-
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
32231
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessIndex));
|
32941
32232
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
32942
32233
|
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
32943
32234
|
parts.push(new BigNumberCoder("u64").encode(value.predicateDataLength));
|
@@ -32952,7 +32243,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32952
32243
|
let o = offset;
|
32953
32244
|
[decoded, o] = new B256Coder().decode(data, o);
|
32954
32245
|
const txID = decoded;
|
32955
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32246
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
32956
32247
|
const outputIndex = decoded;
|
32957
32248
|
[decoded, o] = new B256Coder().decode(data, o);
|
32958
32249
|
const owner = decoded;
|
@@ -32962,7 +32253,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
32962
32253
|
const assetId = decoded;
|
32963
32254
|
[decoded, o] = new TxPointerCoder().decode(data, o);
|
32964
32255
|
const txPointer = decoded;
|
32965
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32256
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
32966
32257
|
const witnessIndex = Number(decoded);
|
32967
32258
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
32968
32259
|
const predicateGasUsed = decoded;
|
@@ -33001,7 +32292,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33001
32292
|
encode(value) {
|
33002
32293
|
const parts = [];
|
33003
32294
|
parts.push(new B256Coder().encode(value.txID));
|
33004
|
-
parts.push(new NumberCoder("u16").encode(value.outputIndex));
|
32295
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputIndex));
|
33005
32296
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33006
32297
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33007
32298
|
parts.push(new TxPointerCoder().encode(value.txPointer));
|
@@ -33013,7 +32304,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33013
32304
|
let o = offset;
|
33014
32305
|
[decoded, o] = new B256Coder().decode(data, o);
|
33015
32306
|
const txID = decoded;
|
33016
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32307
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33017
32308
|
const outputIndex = decoded;
|
33018
32309
|
[decoded, o] = new B256Coder().decode(data, o);
|
33019
32310
|
const balanceRoot = decoded;
|
@@ -33062,7 +32353,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33062
32353
|
parts.push(new ByteArrayCoder(32).encode(value.recipient));
|
33063
32354
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33064
32355
|
parts.push(new ByteArrayCoder(32).encode(value.nonce));
|
33065
|
-
parts.push(new NumberCoder("u16").encode(value.witnessIndex));
|
32356
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessIndex));
|
33066
32357
|
parts.push(new BigNumberCoder("u64").encode(value.predicateGasUsed));
|
33067
32358
|
parts.push(new BigNumberCoder("u64").encode(data.length));
|
33068
32359
|
parts.push(new BigNumberCoder("u64").encode(value.predicateLength));
|
@@ -33091,11 +32382,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33091
32382
|
const amount = decoded;
|
33092
32383
|
[decoded, o] = new B256Coder().decode(data, o);
|
33093
32384
|
const nonce = decoded;
|
33094
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32385
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33095
32386
|
const witnessIndex = Number(decoded);
|
33096
32387
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33097
32388
|
const predicateGasUsed = decoded;
|
33098
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
32389
|
+
[decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
|
33099
32390
|
const dataLength2 = decoded;
|
33100
32391
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33101
32392
|
const predicateLength = decoded;
|
@@ -33133,7 +32424,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33133
32424
|
}
|
33134
32425
|
encode(value) {
|
33135
32426
|
const parts = [];
|
33136
|
-
parts.push(new NumberCoder("u8").encode(value.type));
|
32427
|
+
parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
|
33137
32428
|
const { type: type3 } = value;
|
33138
32429
|
switch (type3) {
|
33139
32430
|
case 0: {
|
@@ -33160,7 +32451,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33160
32451
|
decode(data, offset) {
|
33161
32452
|
let decoded;
|
33162
32453
|
let o = offset;
|
33163
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
32454
|
+
[decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
|
33164
32455
|
const type3 = decoded;
|
33165
32456
|
switch (type3) {
|
33166
32457
|
case 0: {
|
@@ -33229,7 +32520,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33229
32520
|
}
|
33230
32521
|
encode(value) {
|
33231
32522
|
const parts = [];
|
33232
|
-
parts.push(new NumberCoder("u8").encode(value.inputIndex));
|
32523
|
+
parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.inputIndex));
|
33233
32524
|
parts.push(new B256Coder().encode(value.balanceRoot));
|
33234
32525
|
parts.push(new B256Coder().encode(value.stateRoot));
|
33235
32526
|
return concat(parts);
|
@@ -33237,7 +32528,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33237
32528
|
decode(data, offset) {
|
33238
32529
|
let decoded;
|
33239
32530
|
let o = offset;
|
33240
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
32531
|
+
[decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
|
33241
32532
|
const inputIndex = decoded;
|
33242
32533
|
[decoded, o] = new B256Coder().decode(data, o);
|
33243
32534
|
const balanceRoot = decoded;
|
@@ -33349,7 +32640,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33349
32640
|
}
|
33350
32641
|
encode(value) {
|
33351
32642
|
const parts = [];
|
33352
|
-
parts.push(new NumberCoder("u8").encode(value.type));
|
32643
|
+
parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
|
33353
32644
|
const { type: type3 } = value;
|
33354
32645
|
switch (type3) {
|
33355
32646
|
case 0: {
|
@@ -33384,7 +32675,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33384
32675
|
decode(data, offset) {
|
33385
32676
|
let decoded;
|
33386
32677
|
let o = offset;
|
33387
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
32678
|
+
[decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
|
33388
32679
|
const type3 = decoded;
|
33389
32680
|
switch (type3) {
|
33390
32681
|
case 0: {
|
@@ -33452,7 +32743,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33452
32743
|
parts.push(new BigNumberCoder("u64").encode(data));
|
33453
32744
|
break;
|
33454
32745
|
case 4:
|
33455
|
-
parts.push(new NumberCoder("u32").encode(data));
|
32746
|
+
parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(data));
|
33456
32747
|
break;
|
33457
32748
|
default: {
|
33458
32749
|
throw new FuelError(ErrorCode.INVALID_POLICY_TYPE, `Invalid policy type: ${type3}`);
|
@@ -33475,7 +32766,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33475
32766
|
policies.push({ type: 2, data: witnessLimit });
|
33476
32767
|
}
|
33477
32768
|
if (policyTypes & 4) {
|
33478
|
-
const [maturity, nextOffset] = new NumberCoder("u32").decode(
|
32769
|
+
const [maturity, nextOffset] = new NumberCoder("u32", { padToWordSize: true }).decode(
|
32770
|
+
data,
|
32771
|
+
o
|
32772
|
+
);
|
33479
32773
|
o = nextOffset;
|
33480
32774
|
policies.push({ type: 4, data: maturity });
|
33481
32775
|
}
|
@@ -33522,7 +32816,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33522
32816
|
parts.push(new B256Coder().encode(value.recipient));
|
33523
32817
|
parts.push(new BigNumberCoder("u64").encode(value.amount));
|
33524
32818
|
parts.push(new B256Coder().encode(value.nonce));
|
33525
|
-
parts.push(new NumberCoder("u16").encode(value.data.length));
|
32819
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.data.length));
|
33526
32820
|
parts.push(new B256Coder().encode(value.digest));
|
33527
32821
|
parts.push(new ByteArrayCoder(value.data.length).encode(value.data));
|
33528
32822
|
return concat(parts);
|
@@ -33538,7 +32832,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33538
32832
|
const amount = decoded;
|
33539
32833
|
[decoded, o] = new B256Coder().decode(data, o);
|
33540
32834
|
const nonce = decoded;
|
33541
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32835
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33542
32836
|
const len = decoded;
|
33543
32837
|
[decoded, o] = new B256Coder().decode(data, o);
|
33544
32838
|
const digest = decoded;
|
@@ -33662,11 +32956,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33662
32956
|
encode(upgradePurposeType) {
|
33663
32957
|
const parts = [];
|
33664
32958
|
const { type: type3 } = upgradePurposeType;
|
33665
|
-
parts.push(new NumberCoder("u8").encode(type3));
|
32959
|
+
parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(type3));
|
33666
32960
|
switch (type3) {
|
33667
32961
|
case 0: {
|
33668
32962
|
const data = upgradePurposeType.data;
|
33669
|
-
parts.push(new NumberCoder("u16").encode(data.witnessIndex));
|
32963
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(data.witnessIndex));
|
33670
32964
|
parts.push(new B256Coder().encode(data.checksum));
|
33671
32965
|
break;
|
33672
32966
|
}
|
@@ -33687,11 +32981,11 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33687
32981
|
decode(data, offset) {
|
33688
32982
|
let o = offset;
|
33689
32983
|
let decoded;
|
33690
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
32984
|
+
[decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
|
33691
32985
|
const type3 = decoded;
|
33692
32986
|
switch (type3) {
|
33693
32987
|
case 0: {
|
33694
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
32988
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33695
32989
|
const witnessIndex = decoded;
|
33696
32990
|
[decoded, o] = new B256Coder().decode(data, o);
|
33697
32991
|
const checksum = decoded;
|
@@ -33722,14 +33016,14 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33722
33016
|
}
|
33723
33017
|
encode(value) {
|
33724
33018
|
const parts = [];
|
33725
|
-
parts.push(new NumberCoder("u32").encode(value.dataLength));
|
33019
|
+
parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.dataLength));
|
33726
33020
|
parts.push(new ByteArrayCoder(value.dataLength).encode(value.data));
|
33727
33021
|
return concat(parts);
|
33728
33022
|
}
|
33729
33023
|
decode(data, offset) {
|
33730
33024
|
let decoded;
|
33731
33025
|
let o = offset;
|
33732
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33026
|
+
[decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
|
33733
33027
|
const dataLength2 = decoded;
|
33734
33028
|
[decoded, o] = new ByteArrayCoder(dataLength2).decode(data, o);
|
33735
33029
|
const witnessData = decoded;
|
@@ -33760,10 +33054,10 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33760
33054
|
parts.push(new B256Coder().encode(value.receiptsRoot));
|
33761
33055
|
parts.push(new BigNumberCoder("u64").encode(value.scriptLength));
|
33762
33056
|
parts.push(new BigNumberCoder("u64").encode(value.scriptDataLength));
|
33763
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
33764
|
-
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
33765
|
-
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
33766
|
-
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
33057
|
+
parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.policyTypes));
|
33058
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.inputsCount));
|
33059
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputsCount));
|
33060
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessesCount));
|
33767
33061
|
parts.push(new ByteArrayCoder(value.scriptLength.toNumber()).encode(value.script));
|
33768
33062
|
parts.push(new ByteArrayCoder(value.scriptDataLength.toNumber()).encode(value.scriptData));
|
33769
33063
|
parts.push(new PoliciesCoder().encode(value.policies));
|
@@ -33783,13 +33077,13 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33783
33077
|
const scriptLength = decoded;
|
33784
33078
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33785
33079
|
const scriptDataLength = decoded;
|
33786
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33080
|
+
[decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
|
33787
33081
|
const policyTypes = decoded;
|
33788
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33082
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33789
33083
|
const inputsCount = decoded;
|
33790
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33084
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33791
33085
|
const outputsCount = decoded;
|
33792
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33086
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33793
33087
|
const witnessesCount = decoded;
|
33794
33088
|
[decoded, o] = new ByteArrayCoder(scriptLength.toNumber()).decode(data, o);
|
33795
33089
|
const script = decoded;
|
@@ -33831,13 +33125,13 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33831
33125
|
}
|
33832
33126
|
encode(value) {
|
33833
33127
|
const parts = [];
|
33834
|
-
parts.push(new NumberCoder("u16").encode(value.bytecodeWitnessIndex));
|
33128
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.bytecodeWitnessIndex));
|
33835
33129
|
parts.push(new B256Coder().encode(value.salt));
|
33836
33130
|
parts.push(new BigNumberCoder("u64").encode(value.storageSlotsCount));
|
33837
|
-
parts.push(new NumberCoder("u32").encode(value.policyTypes));
|
33838
|
-
parts.push(new NumberCoder("u16").encode(value.inputsCount));
|
33839
|
-
parts.push(new NumberCoder("u16").encode(value.outputsCount));
|
33840
|
-
parts.push(new NumberCoder("u16").encode(value.witnessesCount));
|
33131
|
+
parts.push(new NumberCoder("u32", { padToWordSize: true }).encode(value.policyTypes));
|
33132
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.inputsCount));
|
33133
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.outputsCount));
|
33134
|
+
parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.witnessesCount));
|
33841
33135
|
parts.push(
|
33842
33136
|
new ArrayCoder(new StorageSlotCoder(), value.storageSlotsCount.toNumber()).encode(
|
33843
33137
|
value.storageSlots
|
@@ -33852,19 +33146,19 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
33852
33146
|
decode(data, offset) {
|
33853
33147
|
let decoded;
|
33854
33148
|
let o = offset;
|
33855
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33149
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33856
33150
|
const bytecodeWitnessIndex = decoded;
|
33857
33151
|
[decoded, o] = new B256Coder().decode(data, o);
|
33858
33152
|
const salt = decoded;
|
33859
33153
|
[decoded, o] = new BigNumberCoder("u64").decode(data, o);
|
33860
33154
|
const storageSlotsCount = decoded;
|
33861
|
-
[decoded, o] = new NumberCoder("u32").decode(data, o);
|
33155
|
+
[decoded, o] = new NumberCoder("u32", { padToWordSize: true }).decode(data, o);
|
33862
33156
|
const policyTypes = decoded;
|
33863
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33157
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33864
33158
|
const inputsCount = decoded;
|
33865
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33159
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33866
33160
|
const outputsCount = decoded;
|
33867
|
-
[decoded, o] = new NumberCoder("u16").decode(data, o);
|
33161
|
+
[decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
|
33868
33162
|
const witnessesCount = decoded;
|
33869
33163
|
[decoded, o] = new ArrayCoder(new StorageSlotCoder(), storageSlotsCount.toNumber()).decode(
|
33870
33164
|
data,
|
@@ -34078,7 +33372,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34078
33372
|
}
|
34079
33373
|
encode(value) {
|
34080
33374
|
const parts = [];
|
34081
|
-
parts.push(new NumberCoder("u8").encode(value.type));
|
33375
|
+
parts.push(new NumberCoder("u8", { padToWordSize: true }).encode(value.type));
|
34082
33376
|
const { type: type3 } = value;
|
34083
33377
|
switch (value.type) {
|
34084
33378
|
case 0: {
|
@@ -34121,7 +33415,7 @@ This unreleased fuel-core build may include features and updates not yet support
|
|
34121
33415
|
decode(data, offset) {
|
34122
33416
|
let decoded;
|
34123
33417
|
let o = offset;
|
34124
|
-
[decoded, o] = new NumberCoder("u8").decode(data, o);
|
33418
|
+
[decoded, o] = new NumberCoder("u8", { padToWordSize: true }).decode(data, o);
|
34125
33419
|
const type3 = decoded;
|
34126
33420
|
switch (type3) {
|
34127
33421
|
case 0: {
|
@@ -39848,15 +39142,6 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
39848
39142
|
}
|
39849
39143
|
});
|
39850
39144
|
}
|
39851
|
-
shiftPredicateData() {
|
39852
|
-
this.inputs.forEach((input) => {
|
39853
|
-
if ("predicateData" in input && "padPredicateData" in input && typeof input.padPredicateData === "function") {
|
39854
|
-
input.predicateData = input.padPredicateData(
|
39855
|
-
BaseTransactionRequest.getPolicyMeta(this).policies.length
|
39856
|
-
);
|
39857
|
-
}
|
39858
|
-
});
|
39859
|
-
}
|
39860
39145
|
};
|
39861
39146
|
|
39862
39147
|
// src/providers/transaction-request/hash-transaction.ts
|
@@ -40321,37 +39606,27 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
|
|
40321
39606
|
};
|
40322
39607
|
|
40323
39608
|
// src/providers/transaction-summary/call.ts
|
40324
|
-
var getFunctionCall = ({ abi, receipt
|
39609
|
+
var getFunctionCall = ({ abi, receipt }) => {
|
40325
39610
|
const abiInterface = new Interface(abi);
|
40326
39611
|
const callFunctionSelector = receipt.param1.toHex(8);
|
40327
39612
|
const functionFragment = abiInterface.getFunction(callFunctionSelector);
|
40328
39613
|
const inputs = functionFragment.jsonFn.inputs;
|
40329
|
-
|
40330
|
-
if (functionFragment.isInputDataPointer) {
|
40331
|
-
if (rawPayload) {
|
40332
|
-
const argsOffset = bn(receipt.param2).sub(calculateVmTxMemory({ maxInputs: maxInputs.toNumber() })).toNumber();
|
40333
|
-
encodedArgs = `0x${rawPayload.slice(2).slice(argsOffset * 2)}`;
|
40334
|
-
}
|
40335
|
-
} else {
|
40336
|
-
encodedArgs = receipt.param2.toHex();
|
40337
|
-
}
|
39614
|
+
const encodedArgs = receipt.param2.toHex();
|
40338
39615
|
let argumentsProvided;
|
40339
|
-
|
40340
|
-
|
40341
|
-
|
40342
|
-
|
40343
|
-
|
40344
|
-
|
40345
|
-
|
40346
|
-
|
40347
|
-
|
40348
|
-
|
40349
|
-
|
40350
|
-
|
40351
|
-
|
40352
|
-
|
40353
|
-
}, {});
|
40354
|
-
}
|
39616
|
+
const data = functionFragment.decodeArguments(encodedArgs);
|
39617
|
+
if (data) {
|
39618
|
+
argumentsProvided = inputs.reduce((prev, input, index) => {
|
39619
|
+
const value = data[index];
|
39620
|
+
const name = input.name;
|
39621
|
+
if (name) {
|
39622
|
+
return {
|
39623
|
+
...prev,
|
39624
|
+
// reparse to remove bn
|
39625
|
+
[name]: JSON.parse(JSON.stringify(value))
|
39626
|
+
};
|
39627
|
+
}
|
39628
|
+
return prev;
|
39629
|
+
}, {});
|
40355
39630
|
}
|
40356
39631
|
const call = {
|
40357
39632
|
functionSignature: functionFragment.signature,
|
@@ -42848,7 +42123,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42848
42123
|
cacheRequestInputsResourcesFromOwner(request.inputs, this.address)
|
42849
42124
|
);
|
42850
42125
|
request.addResources(resources);
|
42851
|
-
request.shiftPredicateData();
|
42852
42126
|
request.updatePredicateGasUsed(estimatedPredicates);
|
42853
42127
|
const requestToReestimate2 = clone_default(request);
|
42854
42128
|
if (addedSignatures) {
|
@@ -42880,7 +42154,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
42880
42154
|
}
|
42881
42155
|
fundingAttempts += 1;
|
42882
42156
|
}
|
42883
|
-
request.shiftPredicateData();
|
42884
42157
|
request.updatePredicateGasUsed(estimatedPredicates);
|
42885
42158
|
const requestToReestimate = clone_default(request);
|
42886
42159
|
if (addedSignatures) {
|
@@ -47954,7 +47227,6 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
47954
47227
|
*/
|
47955
47228
|
populateTransactionPredicateData(transactionRequestLike) {
|
47956
47229
|
const request = transactionRequestify(transactionRequestLike);
|
47957
|
-
const { policies } = BaseTransactionRequest.getPolicyMeta(request);
|
47958
47230
|
const placeholderIndex = this.getIndexFromPlaceholderWitness(request);
|
47959
47231
|
if (placeholderIndex !== -1) {
|
47960
47232
|
request.removeWitness(placeholderIndex);
|
@@ -47962,7 +47234,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
47962
47234
|
request.inputs.filter(isRequestInputResource).forEach((input) => {
|
47963
47235
|
if (isRequestInputResourceFromOwner(input, this.address)) {
|
47964
47236
|
input.predicate = hexlify(this.bytes);
|
47965
|
-
input.predicateData = hexlify(this.getPredicateData(
|
47237
|
+
input.predicateData = hexlify(this.getPredicateData());
|
47966
47238
|
input.witnessIndex = 0;
|
47967
47239
|
}
|
47968
47240
|
});
|
@@ -47988,17 +47260,12 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
47988
47260
|
const transactionRequest = transactionRequestify(transactionRequestLike);
|
47989
47261
|
return super.simulateTransaction(transactionRequest, { estimateTxDependencies: false });
|
47990
47262
|
}
|
47991
|
-
getPredicateData(
|
47263
|
+
getPredicateData() {
|
47992
47264
|
if (!this.predicateData.length) {
|
47993
47265
|
return new Uint8Array();
|
47994
47266
|
}
|
47995
47267
|
const mainFn = this.interface?.functions.main;
|
47996
|
-
|
47997
|
-
const VM_TX_MEMORY = calculateVmTxMemory({
|
47998
|
-
maxInputs: this.provider.getChain().consensusParameters.txParameters.maxInputs.toNumber()
|
47999
|
-
});
|
48000
|
-
const OFFSET = VM_TX_MEMORY + SCRIPT_FIXED_SIZE + INPUT_COIN_FIXED_SIZE + WORD_SIZE + paddedCode.byteLength + policiesLength * WORD_SIZE;
|
48001
|
-
return mainFn?.encodeArguments(this.predicateData, OFFSET) || new Uint8Array();
|
47268
|
+
return mainFn?.encodeArguments(this.predicateData) || new Uint8Array();
|
48002
47269
|
}
|
48003
47270
|
/**
|
48004
47271
|
* Processes the predicate data and returns the altered bytecode and interface.
|
@@ -48047,8 +47314,7 @@ Supported fuel-core version: ${supportedVersion}.`
|
|
48047
47314
|
);
|
48048
47315
|
return resources.map((resource) => ({
|
48049
47316
|
...resource,
|
48050
|
-
predicate: hexlify(this.bytes)
|
48051
|
-
padPredicateData: (policiesLength) => hexlify(this.getPredicateData(policiesLength))
|
47317
|
+
predicate: hexlify(this.bytes)
|
48052
47318
|
}));
|
48053
47319
|
}
|
48054
47320
|
/**
|