@fuel-ts/account 0.0.0-rc-1895-20240404064636 → 0.0.0-rc-1832-20240404073329

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.

@@ -29083,7 +29083,6 @@ This unreleased fuel-core build may include features and updates not yet support
29083
29083
  })(ErrorCode || {});
29084
29084
  var _FuelError = class extends Error {
29085
29085
  VERSIONS = versions;
29086
- metadata;
29087
29086
  static parse(e) {
29088
29087
  const error = e;
29089
29088
  if (error.code === void 0) {
@@ -29103,15 +29102,14 @@ This unreleased fuel-core build may include features and updates not yet support
29103
29102
  return new _FuelError(error.code, error.message);
29104
29103
  }
29105
29104
  code;
29106
- constructor(code, message, metadata = {}) {
29105
+ constructor(code, message) {
29107
29106
  super(message);
29108
29107
  this.code = code;
29109
29108
  this.name = "FuelError";
29110
- this.metadata = metadata;
29111
29109
  }
29112
29110
  toObject() {
29113
- const { code, name, message, metadata, VERSIONS } = this;
29114
- return { code, name, message, metadata, VERSIONS };
29111
+ const { code, name, message, VERSIONS } = this;
29112
+ return { code, name, message, VERSIONS };
29115
29113
  }
29116
29114
  };
29117
29115
  var FuelError = _FuelError;
@@ -31915,9 +31913,6 @@ This unreleased fuel-core build may include features and updates not yet support
31915
31913
  __privateAdd2(this, _getPaddedData);
31916
31914
  }
31917
31915
  encode(value) {
31918
- if (!Array.isArray(value)) {
31919
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
31920
- }
31921
31916
  const parts = [];
31922
31917
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31923
31918
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -31944,7 +31939,7 @@ This unreleased fuel-core build may include features and updates not yet support
31944
31939
  };
31945
31940
  _getPaddedData = /* @__PURE__ */ new WeakSet();
31946
31941
  getPaddedData_fn = function(value) {
31947
- const data = [Uint8Array.from(value)];
31942
+ const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
31948
31943
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31949
31944
  if (paddingLength) {
31950
31945
  data.push(new Uint8Array(paddingLength));
@@ -31967,7 +31962,7 @@ This unreleased fuel-core build may include features and updates not yet support
31967
31962
  (max2, coder) => Math.max(max2, coder.encodedLength),
31968
31963
  0
31969
31964
  );
31970
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31965
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31971
31966
  this.name = name;
31972
31967
  this.coders = coders;
31973
31968
  this.#caseIndexCoder = caseIndexCoder;
@@ -32037,7 +32032,7 @@ This unreleased fuel-core build may include features and updates not yet support
32037
32032
  return { None: [] };
32038
32033
  }
32039
32034
  decode(data, offset) {
32040
- if (data.length < this.encodedLength - 1) {
32035
+ if (data.length < this.encodedLength) {
32041
32036
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
32042
32037
  }
32043
32038
  const [decoded, newOffset] = super.decode(data, offset);
@@ -32620,11 +32615,8 @@ This unreleased fuel-core build may include features and updates not yet support
32620
32615
  super("struct", "struct Bytes", WORD_SIZE);
32621
32616
  }
32622
32617
  encode(value) {
32623
- if (!Array.isArray(value)) {
32624
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32625
- }
32626
- const bytes3 = new Uint8Array(value);
32627
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32618
+ const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
32619
+ const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
32628
32620
  return new Uint8Array([...lengthBytes, ...bytes3]);
32629
32621
  }
32630
32622
  decode(data, offset) {
@@ -32657,7 +32649,7 @@ This unreleased fuel-core build may include features and updates not yet support
32657
32649
  (max2, coder) => Math.max(max2, coder.encodedLength),
32658
32650
  0
32659
32651
  );
32660
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32652
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32661
32653
  this.name = name;
32662
32654
  this.coders = coders;
32663
32655
  this.#caseIndexCoder = caseIndexCoder;
@@ -32755,6 +32747,28 @@ This unreleased fuel-core build may include features and updates not yet support
32755
32747
  return [toNumber2(bytes3), offset + this.length];
32756
32748
  }
32757
32749
  };
32750
+ var OptionCoder2 = class extends EnumCoder2 {
32751
+ encode(value) {
32752
+ const result = super.encode(this.toSwayOption(value));
32753
+ return result;
32754
+ }
32755
+ toSwayOption(input) {
32756
+ if (input !== void 0) {
32757
+ return { Some: input };
32758
+ }
32759
+ return { None: [] };
32760
+ }
32761
+ decode(data, offset) {
32762
+ const [decoded, newOffset] = super.decode(data, offset);
32763
+ return [this.toOption(decoded), newOffset];
32764
+ }
32765
+ toOption(output3) {
32766
+ if (output3 && "Some" in output3) {
32767
+ return output3.Some;
32768
+ }
32769
+ return void 0;
32770
+ }
32771
+ };
32758
32772
  var RawSliceCoder2 = class extends Coder {
32759
32773
  constructor() {
32760
32774
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -32808,6 +32822,30 @@ This unreleased fuel-core build may include features and updates not yet support
32808
32822
  }
32809
32823
  };
32810
32824
  __publicField4(StdStringCoder2, "memorySize", 1);
32825
+ var StrSliceCoder = class extends Coder {
32826
+ constructor() {
32827
+ super("strSlice", "str", WORD_SIZE);
32828
+ }
32829
+ encode(value) {
32830
+ const bytes3 = toUtf8Bytes(value);
32831
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32832
+ return new Uint8Array([...lengthBytes, ...bytes3]);
32833
+ }
32834
+ decode(data, offset) {
32835
+ if (data.length < this.encodedLength) {
32836
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
32837
+ }
32838
+ const offsetAndLength = offset + WORD_SIZE;
32839
+ const lengthBytes = data.slice(offset, offsetAndLength);
32840
+ const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32841
+ const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
32842
+ if (bytes3.length !== length) {
32843
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
32844
+ }
32845
+ return [toUtf8String(bytes3), offsetAndLength + length];
32846
+ }
32847
+ };
32848
+ __publicField4(StrSliceCoder, "memorySize", 1);
32811
32849
  var StringCoder2 = class extends Coder {
32812
32850
  constructor(length) {
32813
32851
  super("string", `str[${length}]`, length);
@@ -32846,7 +32884,7 @@ This unreleased fuel-core build may include features and updates not yet support
32846
32884
  Object.keys(this.coders).map((fieldName) => {
32847
32885
  const fieldCoder = this.coders[fieldName];
32848
32886
  const fieldValue = value[fieldName];
32849
- if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
32887
+ if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
32850
32888
  throw new FuelError(
32851
32889
  ErrorCode.ENCODE_ERROR,
32852
32890
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -32954,6 +32992,8 @@ This unreleased fuel-core build may include features and updates not yet support
32954
32992
  return new ByteCoder2();
32955
32993
  case STD_STRING_CODER_TYPE:
32956
32994
  return new StdStringCoder2();
32995
+ case STR_SLICE_CODER_TYPE:
32996
+ return new StrSliceCoder();
32957
32997
  default:
32958
32998
  break;
32959
32999
  }
@@ -32998,7 +33038,7 @@ This unreleased fuel-core build may include features and updates not yet support
32998
33038
  const coders = getCoders(components, { getCoder: getCoder2 });
32999
33039
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
33000
33040
  if (isOptionEnum) {
33001
- return new OptionCoder(enumMatch.name, coders);
33041
+ return new OptionCoder2(enumMatch.name, coders);
33002
33042
  }
33003
33043
  return new EnumCoder2(enumMatch.name, coders);
33004
33044
  }
@@ -33009,12 +33049,6 @@ This unreleased fuel-core build may include features and updates not yet support
33009
33049
  );
33010
33050
  return new TupleCoder2(coders);
33011
33051
  }
33012
- if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
33013
- throw new FuelError(
33014
- ErrorCode.INVALID_DATA,
33015
- "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
33016
- );
33017
- }
33018
33052
  throw new FuelError(
33019
33053
  ErrorCode.CODER_NOT_FOUND,
33020
33054
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -33050,6 +33084,8 @@ This unreleased fuel-core build may include features and updates not yet support
33050
33084
  var FunctionFragment = class {
33051
33085
  signature;
33052
33086
  selector;
33087
+ selectorBytes;
33088
+ encoding;
33053
33089
  name;
33054
33090
  jsonFn;
33055
33091
  attributes;
@@ -33062,6 +33098,8 @@ This unreleased fuel-core build may include features and updates not yet support
33062
33098
  this.name = name;
33063
33099
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33064
33100
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33101
+ this.selectorBytes = new StdStringCoder2().encode(name);
33102
+ this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33065
33103
  this.isInputDataPointer = this.#isInputDataPointer();
33066
33104
  this.outputMetadata = {
33067
33105
  isHeapType: this.#isOutputDataHeap(),
@@ -33115,11 +33153,14 @@ This unreleased fuel-core build may include features and updates not yet support
33115
33153
  }
33116
33154
  const coders = nonEmptyInputs.map(
33117
33155
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
33118
- isRightPadded: nonEmptyInputs.length > 1
33156
+ isRightPadded: nonEmptyInputs.length > 1,
33157
+ encoding: this.encoding
33119
33158
  })
33120
33159
  );
33121
- const coder = new TupleCoder(coders);
33122
- const results = coder.encode(shallowCopyValues);
33160
+ if (this.encoding === ENCODING_V1) {
33161
+ return new TupleCoder2(coders).encode(shallowCopyValues);
33162
+ }
33163
+ const results = new TupleCoder(coders).encode(shallowCopyValues);
33123
33164
  return unpackDynamicData(results, offset, results.byteLength);
33124
33165
  }
33125
33166
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -33166,7 +33207,7 @@ This unreleased fuel-core build may include features and updates not yet support
33166
33207
  }
33167
33208
  const result = nonEmptyInputs.reduce(
33168
33209
  (obj, input) => {
33169
- const coder = AbiCoder.getCoder(this.jsonAbi, input);
33210
+ const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
33170
33211
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
33171
33212
  return {
33172
33213
  decoded: [...obj.decoded, decodedValue],
@@ -33186,7 +33227,9 @@ This unreleased fuel-core build may include features and updates not yet support
33186
33227
  return [void 0, 0];
33187
33228
  }
33188
33229
  const bytes3 = arrayify(data);
33189
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
33230
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
33231
+ encoding: this.encoding
33232
+ });
33190
33233
  return coder.decode(bytes3, 0);
33191
33234
  }
33192
33235
  };
@@ -33248,7 +33291,8 @@ This unreleased fuel-core build may include features and updates not yet support
33248
33291
  }
33249
33292
  );
33250
33293
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33251
- isRightPadded: true
33294
+ isRightPadded: true,
33295
+ encoding: this.jsonAbi.encoding
33252
33296
  });
33253
33297
  }
33254
33298
  getTypeById(typeId) {
@@ -38953,60 +38997,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38953
38997
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
38954
38998
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
38955
38999
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
38956
- var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
38957
39000
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
38958
- var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
38959
- var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
38960
- var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
38961
- var PANIC_REASONS = [
38962
- "UnknownPanicReason",
38963
- "Revert",
38964
- "OutOfGas",
38965
- "TransactionValidity",
38966
- "MemoryOverflow",
38967
- "ArithmeticOverflow",
38968
- "ContractNotFound",
38969
- "MemoryOwnership",
38970
- "NotEnoughBalance",
38971
- "ExpectedInternalContext",
38972
- "AssetIdNotFound",
38973
- "InputNotFound",
38974
- "OutputNotFound",
38975
- "WitnessNotFound",
38976
- "TransactionMaturity",
38977
- "InvalidMetadataIdentifier",
38978
- "MalformedCallStructure",
38979
- "ReservedRegisterNotWritable",
38980
- "InvalidFlags",
38981
- "InvalidImmediateValue",
38982
- "ExpectedCoinInput",
38983
- "EcalError",
38984
- "MemoryWriteOverlap",
38985
- "ContractNotInInputs",
38986
- "InternalBalanceOverflow",
38987
- "ContractMaxSize",
38988
- "ExpectedUnallocatedStack",
38989
- "MaxStaticContractsReached",
38990
- "TransferAmountCannotBeZero",
38991
- "ExpectedOutputVariable",
38992
- "ExpectedParentInternalContext",
38993
- "PredicateReturnedNonOne",
38994
- "ContractIdAlreadyDeployed",
38995
- "ContractMismatch",
38996
- "MessageDataTooLong",
38997
- "ArithmeticError",
38998
- "ContractInstructionNotAllowed",
38999
- "TransferZeroCoins",
39000
- "InvalidInstruction",
39001
- "MemoryNotExecutable",
39002
- "PolicyIsNotSet",
39003
- "PolicyNotFound",
39004
- "TooManyReceipts",
39005
- "BalanceOverflow",
39006
- "InvalidBlockHeight",
39007
- "TooManySlots"
39008
- ];
39009
- var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
39010
39001
 
39011
39002
  // src/providers/utils/receipts.ts
39012
39003
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -39380,74 +39371,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39380
39371
  });
39381
39372
  }
39382
39373
 
39383
- // src/providers/utils/extract-tx-error.ts
39384
- var assemblePanicError = (status) => {
39385
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
39386
- const reason = status.reason;
39387
- if (PANIC_REASONS.includes(status.reason)) {
39388
- errorMessage = `${errorMessage}
39389
-
39390
- You can read more about this error at:
39391
-
39392
- ${PANIC_DOC_URL}#variant.${status.reason}`;
39393
- }
39394
- return { errorMessage, reason };
39395
- };
39396
- var stringify2 = (obj) => JSON.stringify(obj, null, 2);
39397
- var assembleRevertError = (receipts, logs) => {
39398
- let errorMessage = "The transaction reverted with an unknown reason.";
39399
- const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
39400
- let reason = "";
39401
- if (revertReceipt) {
39402
- const reasonHex = bn(revertReceipt.val).toHex();
39403
- switch (reasonHex) {
39404
- case FAILED_REQUIRE_SIGNAL: {
39405
- reason = "require";
39406
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
39407
- break;
39408
- }
39409
- case FAILED_ASSERT_EQ_SIGNAL: {
39410
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39411
- reason = "assert_eq";
39412
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
39413
- break;
39414
- }
39415
- case FAILED_ASSERT_NE_SIGNAL: {
39416
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39417
- reason = "assert_ne";
39418
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
39419
- break;
39420
- }
39421
- case FAILED_ASSERT_SIGNAL:
39422
- reason = "assert";
39423
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
39424
- break;
39425
- case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
39426
- reason = "MissingOutputChange";
39427
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
39428
- break;
39429
- default:
39430
- reason = "unknown";
39431
- errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
39432
- }
39433
- }
39434
- return { errorMessage, reason };
39435
- };
39436
- var extractTxError = (params) => {
39437
- const { receipts, status, logs } = params;
39438
- const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
39439
- const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
39440
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
39441
- const metadata = {
39442
- logs,
39443
- receipts,
39444
- panic: isPanic,
39445
- revert: isRevert,
39446
- reason
39447
- };
39448
- return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
39449
- };
39450
-
39451
39374
  // src/providers/transaction-request/errors.ts
39452
39375
  var ChangeOutputCollisionError = class extends Error {
39453
39376
  name = "ChangeOutputCollisionError";
@@ -41264,26 +41187,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41264
41187
  gqlTransaction: this.gqlTransaction,
41265
41188
  ...transactionSummary
41266
41189
  };
41267
- let logs = [];
41268
41190
  if (this.abis) {
41269
- logs = getDecodedLogs(
41191
+ const logs = getDecodedLogs(
41270
41192
  transactionSummary.receipts,
41271
41193
  this.abis.main,
41272
41194
  this.abis.otherContractsAbis
41273
41195
  );
41274
41196
  transactionResult.logs = logs;
41275
41197
  }
41276
- if (transactionResult.isStatusFailure) {
41277
- const {
41278
- receipts,
41279
- gqlTransaction: { status }
41280
- } = transactionResult;
41281
- throw extractTxError({
41282
- receipts,
41283
- status,
41284
- logs
41285
- });
41286
- }
41287
41198
  return transactionResult;
41288
41199
  }
41289
41200
  /**
@@ -41292,7 +41203,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41292
41203
  * @param contractsAbiMap - The contracts ABI map.
41293
41204
  */
41294
41205
  async wait(contractsAbiMap) {
41295
- return this.waitForResult(contractsAbiMap);
41206
+ const result = await this.waitForResult(contractsAbiMap);
41207
+ if (result.isStatusFailure) {
41208
+ throw new FuelError(
41209
+ ErrorCode.TRANSACTION_FAILED,
41210
+ `Transaction failed: ${result.gqlTransaction.status.reason}`
41211
+ );
41212
+ }
41213
+ return result;
41296
41214
  }
41297
41215
  };
41298
41216