@fuel-ts/account 0.0.0-rc-1832-20240322144804 → 0.0.0-rc-1928-20240322151851

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.

@@ -31914,7 +31914,7 @@ spurious results.`);
31914
31914
  // ../versions/dist/index.mjs
31915
31915
  function getBuiltinVersions() {
31916
31916
  return {
31917
- FORC: "git:xunilrj/encoding-contract-call",
31917
+ FORC: "0.51.1",
31918
31918
  FUEL_CORE: "0.22.1",
31919
31919
  FUELS: "0.77.0"
31920
31920
  };
@@ -35383,6 +35383,9 @@ This unreleased fuel-core build may include features and updates not yet support
35383
35383
  __privateAdd2(this, _getPaddedData);
35384
35384
  }
35385
35385
  encode(value) {
35386
+ if (!Array.isArray(value)) {
35387
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
35388
+ }
35386
35389
  const parts = [];
35387
35390
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
35388
35391
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -35409,8 +35412,7 @@ This unreleased fuel-core build may include features and updates not yet support
35409
35412
  };
35410
35413
  _getPaddedData = /* @__PURE__ */ new WeakSet();
35411
35414
  getPaddedData_fn = function(value) {
35412
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
35413
- const data = [Uint8Array.from(bytes3)];
35415
+ const data = [Uint8Array.from(value)];
35414
35416
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
35415
35417
  if (paddingLength) {
35416
35418
  data.push(new Uint8Array(paddingLength));
@@ -35503,7 +35505,7 @@ This unreleased fuel-core build may include features and updates not yet support
35503
35505
  return { None: [] };
35504
35506
  }
35505
35507
  decode(data, offset) {
35506
- if (data.length < this.encodedLength) {
35508
+ if (data.length < this.encodedLength - 1) {
35507
35509
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
35508
35510
  }
35509
35511
  const [decoded, newOffset] = super.decode(data, offset);
@@ -36086,8 +36088,11 @@ This unreleased fuel-core build may include features and updates not yet support
36086
36088
  super("struct", "struct Bytes", WORD_SIZE);
36087
36089
  }
36088
36090
  encode(value) {
36089
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
36090
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
36091
+ if (!Array.isArray(value)) {
36092
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
36093
+ }
36094
+ const bytes3 = new Uint8Array(value);
36095
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36091
36096
  return new Uint8Array([...lengthBytes, ...bytes3]);
36092
36097
  }
36093
36098
  decode(data, offset) {
@@ -36218,28 +36223,6 @@ This unreleased fuel-core build may include features and updates not yet support
36218
36223
  return [toNumber2(bytes3), offset + this.length];
36219
36224
  }
36220
36225
  };
36221
- var OptionCoder2 = class extends EnumCoder2 {
36222
- encode(value) {
36223
- const result = super.encode(this.toSwayOption(value));
36224
- return result;
36225
- }
36226
- toSwayOption(input) {
36227
- if (input !== void 0) {
36228
- return { Some: input };
36229
- }
36230
- return { None: [] };
36231
- }
36232
- decode(data, offset) {
36233
- const [decoded, newOffset] = super.decode(data, offset);
36234
- return [this.toOption(decoded), newOffset];
36235
- }
36236
- toOption(output3) {
36237
- if (output3 && "Some" in output3) {
36238
- return output3.Some;
36239
- }
36240
- return void 0;
36241
- }
36242
- };
36243
36226
  var RawSliceCoder2 = class extends Coder {
36244
36227
  constructor() {
36245
36228
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -36293,30 +36276,6 @@ This unreleased fuel-core build may include features and updates not yet support
36293
36276
  }
36294
36277
  };
36295
36278
  __publicField4(StdStringCoder2, "memorySize", 1);
36296
- var StrSliceCoder = class extends Coder {
36297
- constructor() {
36298
- super("strSlice", "str", WORD_SIZE);
36299
- }
36300
- encode(value) {
36301
- const bytes3 = toUtf8Bytes(value);
36302
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
36303
- return new Uint8Array([...lengthBytes, ...bytes3]);
36304
- }
36305
- decode(data, offset) {
36306
- if (data.length < this.encodedLength) {
36307
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
36308
- }
36309
- const offsetAndLength = offset + WORD_SIZE;
36310
- const lengthBytes = data.slice(offset, offsetAndLength);
36311
- const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
36312
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
36313
- if (bytes3.length !== length) {
36314
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
36315
- }
36316
- return [toUtf8String(bytes3), offsetAndLength + length];
36317
- }
36318
- };
36319
- __publicField4(StrSliceCoder, "memorySize", 1);
36320
36279
  var StringCoder2 = class extends Coder {
36321
36280
  constructor(length) {
36322
36281
  super("string", `str[${length}]`, length);
@@ -36355,7 +36314,7 @@ This unreleased fuel-core build may include features and updates not yet support
36355
36314
  Object.keys(this.coders).map((fieldName) => {
36356
36315
  const fieldCoder = this.coders[fieldName];
36357
36316
  const fieldValue = value[fieldName];
36358
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
36317
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
36359
36318
  throw new FuelError(
36360
36319
  ErrorCode.ENCODE_ERROR,
36361
36320
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -36463,8 +36422,6 @@ This unreleased fuel-core build may include features and updates not yet support
36463
36422
  return new ByteCoder2();
36464
36423
  case STD_STRING_CODER_TYPE:
36465
36424
  return new StdStringCoder2();
36466
- case STR_SLICE_CODER_TYPE:
36467
- return new StrSliceCoder();
36468
36425
  default:
36469
36426
  break;
36470
36427
  }
@@ -36509,7 +36466,7 @@ This unreleased fuel-core build may include features and updates not yet support
36509
36466
  const coders = getCoders(components, { getCoder: getCoder2 });
36510
36467
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
36511
36468
  if (isOptionEnum) {
36512
- return new OptionCoder2(enumMatch.name, coders);
36469
+ return new OptionCoder(enumMatch.name, coders);
36513
36470
  }
36514
36471
  return new EnumCoder2(enumMatch.name, coders);
36515
36472
  }
@@ -36520,6 +36477,12 @@ This unreleased fuel-core build may include features and updates not yet support
36520
36477
  );
36521
36478
  return new TupleCoder2(coders);
36522
36479
  }
36480
+ if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
36481
+ throw new FuelError(
36482
+ ErrorCode.INVALID_DATA,
36483
+ "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
36484
+ );
36485
+ }
36523
36486
  throw new FuelError(
36524
36487
  ErrorCode.CODER_NOT_FOUND,
36525
36488
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -36555,8 +36518,6 @@ This unreleased fuel-core build may include features and updates not yet support
36555
36518
  var FunctionFragment = class {
36556
36519
  signature;
36557
36520
  selector;
36558
- selectorBytes;
36559
- encoding;
36560
36521
  name;
36561
36522
  jsonFn;
36562
36523
  attributes;
@@ -36569,8 +36530,6 @@ This unreleased fuel-core build may include features and updates not yet support
36569
36530
  this.name = name;
36570
36531
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
36571
36532
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
36572
- this.selectorBytes = new StdStringCoder2().encode(name);
36573
- this.encoding = this.jsonAbi.encoding;
36574
36533
  this.isInputDataPointer = this.#isInputDataPointer();
36575
36534
  this.outputMetadata = {
36576
36535
  isHeapType: this.#isOutputDataHeap(),
@@ -36624,14 +36583,11 @@ This unreleased fuel-core build may include features and updates not yet support
36624
36583
  }
36625
36584
  const coders = nonEmptyInputs.map(
36626
36585
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
36627
- isRightPadded: nonEmptyInputs.length > 1,
36628
- encoding: this.encoding
36586
+ isRightPadded: nonEmptyInputs.length > 1
36629
36587
  })
36630
36588
  );
36631
- if (this.encoding === ENCODING_V1) {
36632
- return new TupleCoder2(coders).encode(shallowCopyValues);
36633
- }
36634
- const results = new TupleCoder(coders).encode(shallowCopyValues);
36589
+ const coder = new TupleCoder(coders);
36590
+ const results = coder.encode(shallowCopyValues);
36635
36591
  return unpackDynamicData(results, offset, results.byteLength);
36636
36592
  }
36637
36593
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -36678,7 +36634,7 @@ This unreleased fuel-core build may include features and updates not yet support
36678
36634
  }
36679
36635
  const result = nonEmptyInputs.reduce(
36680
36636
  (obj, input) => {
36681
- const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
36637
+ const coder = AbiCoder.getCoder(this.jsonAbi, input);
36682
36638
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
36683
36639
  return {
36684
36640
  decoded: [...obj.decoded, decodedValue],
@@ -36698,9 +36654,7 @@ This unreleased fuel-core build may include features and updates not yet support
36698
36654
  return [void 0, 0];
36699
36655
  }
36700
36656
  const bytes3 = arrayify(data);
36701
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
36702
- encoding: this.encoding
36703
- });
36657
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
36704
36658
  return coder.decode(bytes3, 0);
36705
36659
  }
36706
36660
  };
@@ -36785,8 +36739,7 @@ This unreleased fuel-core build may include features and updates not yet support
36785
36739
  }
36786
36740
  );
36787
36741
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
36788
- isRightPadded: true,
36789
- encoding: this.jsonAbi.encoding
36742
+ isRightPadded: true
36790
36743
  });
36791
36744
  }
36792
36745
  getTypeById(typeId) {