@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.

@@ -28952,7 +28952,7 @@ spurious results.`);
28952
28952
  // ../versions/dist/index.mjs
28953
28953
  function getBuiltinVersions() {
28954
28954
  return {
28955
- FORC: "git:xunilrj/encoding-contract-call",
28955
+ FORC: "0.51.1",
28956
28956
  FUEL_CORE: "0.22.1",
28957
28957
  FUELS: "0.77.0"
28958
28958
  };
@@ -31918,6 +31918,9 @@ This unreleased fuel-core build may include features and updates not yet support
31918
31918
  __privateAdd2(this, _getPaddedData);
31919
31919
  }
31920
31920
  encode(value) {
31921
+ if (!Array.isArray(value)) {
31922
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
31923
+ }
31921
31924
  const parts = [];
31922
31925
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31923
31926
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -31944,8 +31947,7 @@ This unreleased fuel-core build may include features and updates not yet support
31944
31947
  };
31945
31948
  _getPaddedData = /* @__PURE__ */ new WeakSet();
31946
31949
  getPaddedData_fn = function(value) {
31947
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
31948
- const data = [Uint8Array.from(bytes3)];
31950
+ const data = [Uint8Array.from(value)];
31949
31951
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31950
31952
  if (paddingLength) {
31951
31953
  data.push(new Uint8Array(paddingLength));
@@ -32038,7 +32040,7 @@ This unreleased fuel-core build may include features and updates not yet support
32038
32040
  return { None: [] };
32039
32041
  }
32040
32042
  decode(data, offset) {
32041
- if (data.length < this.encodedLength) {
32043
+ if (data.length < this.encodedLength - 1) {
32042
32044
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
32043
32045
  }
32044
32046
  const [decoded, newOffset] = super.decode(data, offset);
@@ -32621,8 +32623,11 @@ This unreleased fuel-core build may include features and updates not yet support
32621
32623
  super("struct", "struct Bytes", WORD_SIZE);
32622
32624
  }
32623
32625
  encode(value) {
32624
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
32625
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
32626
+ if (!Array.isArray(value)) {
32627
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32628
+ }
32629
+ const bytes3 = new Uint8Array(value);
32630
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32626
32631
  return new Uint8Array([...lengthBytes, ...bytes3]);
32627
32632
  }
32628
32633
  decode(data, offset) {
@@ -32753,28 +32758,6 @@ This unreleased fuel-core build may include features and updates not yet support
32753
32758
  return [toNumber2(bytes3), offset + this.length];
32754
32759
  }
32755
32760
  };
32756
- var OptionCoder2 = class extends EnumCoder2 {
32757
- encode(value) {
32758
- const result = super.encode(this.toSwayOption(value));
32759
- return result;
32760
- }
32761
- toSwayOption(input) {
32762
- if (input !== void 0) {
32763
- return { Some: input };
32764
- }
32765
- return { None: [] };
32766
- }
32767
- decode(data, offset) {
32768
- const [decoded, newOffset] = super.decode(data, offset);
32769
- return [this.toOption(decoded), newOffset];
32770
- }
32771
- toOption(output3) {
32772
- if (output3 && "Some" in output3) {
32773
- return output3.Some;
32774
- }
32775
- return void 0;
32776
- }
32777
- };
32778
32761
  var RawSliceCoder2 = class extends Coder {
32779
32762
  constructor() {
32780
32763
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -32828,30 +32811,6 @@ This unreleased fuel-core build may include features and updates not yet support
32828
32811
  }
32829
32812
  };
32830
32813
  __publicField4(StdStringCoder2, "memorySize", 1);
32831
- var StrSliceCoder = class extends Coder {
32832
- constructor() {
32833
- super("strSlice", "str", WORD_SIZE);
32834
- }
32835
- encode(value) {
32836
- const bytes3 = toUtf8Bytes(value);
32837
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32838
- return new Uint8Array([...lengthBytes, ...bytes3]);
32839
- }
32840
- decode(data, offset) {
32841
- if (data.length < this.encodedLength) {
32842
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
32843
- }
32844
- const offsetAndLength = offset + WORD_SIZE;
32845
- const lengthBytes = data.slice(offset, offsetAndLength);
32846
- const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32847
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
32848
- if (bytes3.length !== length) {
32849
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
32850
- }
32851
- return [toUtf8String(bytes3), offsetAndLength + length];
32852
- }
32853
- };
32854
- __publicField4(StrSliceCoder, "memorySize", 1);
32855
32814
  var StringCoder2 = class extends Coder {
32856
32815
  constructor(length) {
32857
32816
  super("string", `str[${length}]`, length);
@@ -32890,7 +32849,7 @@ This unreleased fuel-core build may include features and updates not yet support
32890
32849
  Object.keys(this.coders).map((fieldName) => {
32891
32850
  const fieldCoder = this.coders[fieldName];
32892
32851
  const fieldValue = value[fieldName];
32893
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
32852
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
32894
32853
  throw new FuelError(
32895
32854
  ErrorCode.ENCODE_ERROR,
32896
32855
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -32998,8 +32957,6 @@ This unreleased fuel-core build may include features and updates not yet support
32998
32957
  return new ByteCoder2();
32999
32958
  case STD_STRING_CODER_TYPE:
33000
32959
  return new StdStringCoder2();
33001
- case STR_SLICE_CODER_TYPE:
33002
- return new StrSliceCoder();
33003
32960
  default:
33004
32961
  break;
33005
32962
  }
@@ -33044,7 +33001,7 @@ This unreleased fuel-core build may include features and updates not yet support
33044
33001
  const coders = getCoders(components, { getCoder: getCoder2 });
33045
33002
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
33046
33003
  if (isOptionEnum) {
33047
- return new OptionCoder2(enumMatch.name, coders);
33004
+ return new OptionCoder(enumMatch.name, coders);
33048
33005
  }
33049
33006
  return new EnumCoder2(enumMatch.name, coders);
33050
33007
  }
@@ -33055,6 +33012,12 @@ This unreleased fuel-core build may include features and updates not yet support
33055
33012
  );
33056
33013
  return new TupleCoder2(coders);
33057
33014
  }
33015
+ if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
33016
+ throw new FuelError(
33017
+ ErrorCode.INVALID_DATA,
33018
+ "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
33019
+ );
33020
+ }
33058
33021
  throw new FuelError(
33059
33022
  ErrorCode.CODER_NOT_FOUND,
33060
33023
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -33090,8 +33053,6 @@ This unreleased fuel-core build may include features and updates not yet support
33090
33053
  var FunctionFragment = class {
33091
33054
  signature;
33092
33055
  selector;
33093
- selectorBytes;
33094
- encoding;
33095
33056
  name;
33096
33057
  jsonFn;
33097
33058
  attributes;
@@ -33104,8 +33065,6 @@ This unreleased fuel-core build may include features and updates not yet support
33104
33065
  this.name = name;
33105
33066
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33106
33067
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33107
- this.selectorBytes = new StdStringCoder2().encode(name);
33108
- this.encoding = this.jsonAbi.encoding;
33109
33068
  this.isInputDataPointer = this.#isInputDataPointer();
33110
33069
  this.outputMetadata = {
33111
33070
  isHeapType: this.#isOutputDataHeap(),
@@ -33159,14 +33118,11 @@ This unreleased fuel-core build may include features and updates not yet support
33159
33118
  }
33160
33119
  const coders = nonEmptyInputs.map(
33161
33120
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
33162
- isRightPadded: nonEmptyInputs.length > 1,
33163
- encoding: this.encoding
33121
+ isRightPadded: nonEmptyInputs.length > 1
33164
33122
  })
33165
33123
  );
33166
- if (this.encoding === ENCODING_V1) {
33167
- return new TupleCoder2(coders).encode(shallowCopyValues);
33168
- }
33169
- const results = new TupleCoder(coders).encode(shallowCopyValues);
33124
+ const coder = new TupleCoder(coders);
33125
+ const results = coder.encode(shallowCopyValues);
33170
33126
  return unpackDynamicData(results, offset, results.byteLength);
33171
33127
  }
33172
33128
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -33213,7 +33169,7 @@ This unreleased fuel-core build may include features and updates not yet support
33213
33169
  }
33214
33170
  const result = nonEmptyInputs.reduce(
33215
33171
  (obj, input) => {
33216
- const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
33172
+ const coder = AbiCoder.getCoder(this.jsonAbi, input);
33217
33173
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
33218
33174
  return {
33219
33175
  decoded: [...obj.decoded, decodedValue],
@@ -33233,9 +33189,7 @@ This unreleased fuel-core build may include features and updates not yet support
33233
33189
  return [void 0, 0];
33234
33190
  }
33235
33191
  const bytes3 = arrayify(data);
33236
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
33237
- encoding: this.encoding
33238
- });
33192
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
33239
33193
  return coder.decode(bytes3, 0);
33240
33194
  }
33241
33195
  };
@@ -33320,8 +33274,7 @@ This unreleased fuel-core build may include features and updates not yet support
33320
33274
  }
33321
33275
  );
33322
33276
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33323
- isRightPadded: true,
33324
- encoding: this.jsonAbi.encoding
33277
+ isRightPadded: true
33325
33278
  });
33326
33279
  }
33327
33280
  getTypeById(typeId) {