@fuel-ts/account 0.80.0 → 0.82.0

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.

@@ -28954,7 +28954,7 @@ spurious results.`);
28954
28954
  return {
28955
28955
  FORC: "0.49.3",
28956
28956
  FUEL_CORE: "0.22.1",
28957
- FUELS: "0.80.0"
28957
+ FUELS: "0.82.0"
28958
28958
  };
28959
28959
  }
28960
28960
  function parseVersion(version2) {
@@ -32342,6 +32342,20 @@ This unreleased fuel-core build may include features and updates not yet support
32342
32342
  ];
32343
32343
  }
32344
32344
  };
32345
+ var getEncodingVersion = (encoding) => {
32346
+ switch (encoding) {
32347
+ case void 0:
32348
+ case ENCODING_V0:
32349
+ return ENCODING_V0;
32350
+ case ENCODING_V1:
32351
+ return ENCODING_V1;
32352
+ default:
32353
+ throw new FuelError(
32354
+ ErrorCode.UNSUPPORTED_ENCODING_VERSION,
32355
+ `Encoding version '${encoding}' is unsupported.`
32356
+ );
32357
+ }
32358
+ };
32345
32359
  var findFunctionByName = (abi, name) => {
32346
32360
  const fn = abi.functions.find((f2) => f2.name === name);
32347
32361
  if (!fn) {
@@ -33106,7 +33120,7 @@ This unreleased fuel-core build may include features and updates not yet support
33106
33120
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33107
33121
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33108
33122
  this.selectorBytes = new StdStringCoder2().encode(name);
33109
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33123
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33110
33124
  this.isInputDataPointer = this.#isInputDataPointer();
33111
33125
  this.outputMetadata = {
33112
33126
  isHeapType: this.#isOutputDataHeap(),
@@ -33244,8 +33258,10 @@ This unreleased fuel-core build may include features and updates not yet support
33244
33258
  functions;
33245
33259
  configurables;
33246
33260
  jsonAbi;
33261
+ encoding;
33247
33262
  constructor(jsonAbi) {
33248
33263
  this.jsonAbi = jsonAbi;
33264
+ this.encoding = getEncodingVersion(jsonAbi.encoding);
33249
33265
  this.functions = Object.fromEntries(
33250
33266
  this.jsonAbi.functions.map((x) => [x.name, new FunctionFragment(this.jsonAbi, x.name)])
33251
33267
  );
@@ -33289,7 +33305,7 @@ This unreleased fuel-core build may include features and updates not yet support
33289
33305
  );
33290
33306
  }
33291
33307
  return AbiCoder.decode(this.jsonAbi, loggedType.loggedType, arrayify(data), 0, {
33292
- encoding: this.jsonAbi.encoding
33308
+ encoding: this.encoding
33293
33309
  });
33294
33310
  }
33295
33311
  encodeConfigurable(name, value) {
@@ -38761,36 +38777,45 @@ ${MessageCoinFragmentFragmentDoc}`;
38761
38777
  });
38762
38778
  this.stream = response.body.getReader();
38763
38779
  }
38780
+ events = [];
38781
+ parsingLeftover = "";
38764
38782
  async next() {
38765
38783
  if (!this.stream) {
38766
38784
  await this.setStream();
38767
38785
  }
38768
38786
  while (true) {
38787
+ if (this.events.length > 0) {
38788
+ const { data, errors } = this.events.shift();
38789
+ if (Array.isArray(errors)) {
38790
+ throw new FuelError(
38791
+ FuelError.CODES.INVALID_REQUEST,
38792
+ errors.map((err) => err.message).join("\n\n")
38793
+ );
38794
+ }
38795
+ return { value: data, done: false };
38796
+ }
38769
38797
  const { value, done } = await this.stream.read();
38770
38798
  if (done) {
38771
38799
  return { value, done };
38772
38800
  }
38773
- const text = _FuelGraphqlSubscriber.textDecoder.decode(value);
38774
- if (!text.startsWith("data:")) {
38801
+ const decoded = _FuelGraphqlSubscriber.textDecoder.decode(value).replace(":keep-alive-text\n\n", "");
38802
+ if (decoded === "") {
38775
38803
  continue;
38776
38804
  }
38777
- let data;
38778
- let errors;
38779
- try {
38780
- ({ data, errors } = JSON.parse(text.replace(/^data:/, "")));
38781
- } catch (e) {
38782
- throw new FuelError(
38783
- ErrorCode.STREAM_PARSING_ERROR,
38784
- `Error while parsing stream data response: ${text}`
38785
- );
38786
- }
38787
- if (Array.isArray(errors)) {
38788
- throw new FuelError(
38789
- FuelError.CODES.INVALID_REQUEST,
38790
- errors.map((err) => err.message).join("\n\n")
38791
- );
38792
- }
38793
- return { value: data, done: false };
38805
+ const text = `${this.parsingLeftover}${decoded}`;
38806
+ const regex = /data:.*\n\n/g;
38807
+ const matches = [...text.matchAll(regex)].flatMap((match) => match);
38808
+ matches.forEach((match) => {
38809
+ try {
38810
+ this.events.push(JSON.parse(match.replace(/^data:/, "")));
38811
+ } catch (e) {
38812
+ throw new FuelError(
38813
+ ErrorCode.STREAM_PARSING_ERROR,
38814
+ `Error while parsing stream data response: ${text}`
38815
+ );
38816
+ }
38817
+ });
38818
+ this.parsingLeftover = text.replace(matches.join(), "");
38794
38819
  }
38795
38820
  }
38796
38821
  /**