@fuel-ts/account 0.0.0-rc-1895-20240403004459 → 0.0.0-rc-1832-20240403144616

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.

@@ -29088,7 +29088,6 @@ This unreleased fuel-core build may include features and updates not yet support
29088
29088
  })(ErrorCode || {});
29089
29089
  var _FuelError = class extends Error {
29090
29090
  VERSIONS = versions;
29091
- metadata;
29092
29091
  static parse(e) {
29093
29092
  const error = e;
29094
29093
  if (error.code === void 0) {
@@ -29108,15 +29107,14 @@ This unreleased fuel-core build may include features and updates not yet support
29108
29107
  return new _FuelError(error.code, error.message);
29109
29108
  }
29110
29109
  code;
29111
- constructor(code, message, metadata = {}) {
29110
+ constructor(code, message) {
29112
29111
  super(message);
29113
29112
  this.code = code;
29114
29113
  this.name = "FuelError";
29115
- this.metadata = metadata;
29116
29114
  }
29117
29115
  toObject() {
29118
- const { code, name, message, metadata, VERSIONS } = this;
29119
- return { code, name, message, metadata, VERSIONS };
29116
+ const { code, name, message, VERSIONS } = this;
29117
+ return { code, name, message, VERSIONS };
29120
29118
  }
29121
29119
  };
29122
29120
  var FuelError = _FuelError;
@@ -31920,9 +31918,6 @@ This unreleased fuel-core build may include features and updates not yet support
31920
31918
  __privateAdd2(this, _getPaddedData);
31921
31919
  }
31922
31920
  encode(value) {
31923
- if (!Array.isArray(value)) {
31924
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
31925
- }
31926
31921
  const parts = [];
31927
31922
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31928
31923
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -31949,7 +31944,7 @@ This unreleased fuel-core build may include features and updates not yet support
31949
31944
  };
31950
31945
  _getPaddedData = /* @__PURE__ */ new WeakSet();
31951
31946
  getPaddedData_fn = function(value) {
31952
- const data = [Uint8Array.from(value)];
31947
+ const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
31953
31948
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31954
31949
  if (paddingLength) {
31955
31950
  data.push(new Uint8Array(paddingLength));
@@ -31972,7 +31967,7 @@ This unreleased fuel-core build may include features and updates not yet support
31972
31967
  (max2, coder) => Math.max(max2, coder.encodedLength),
31973
31968
  0
31974
31969
  );
31975
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31970
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31976
31971
  this.name = name;
31977
31972
  this.coders = coders;
31978
31973
  this.#caseIndexCoder = caseIndexCoder;
@@ -32042,7 +32037,7 @@ This unreleased fuel-core build may include features and updates not yet support
32042
32037
  return { None: [] };
32043
32038
  }
32044
32039
  decode(data, offset) {
32045
- if (data.length < this.encodedLength - 1) {
32040
+ if (data.length < this.encodedLength) {
32046
32041
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
32047
32042
  }
32048
32043
  const [decoded, newOffset] = super.decode(data, offset);
@@ -32625,11 +32620,8 @@ This unreleased fuel-core build may include features and updates not yet support
32625
32620
  super("struct", "struct Bytes", WORD_SIZE);
32626
32621
  }
32627
32622
  encode(value) {
32628
- if (!Array.isArray(value)) {
32629
- throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32630
- }
32631
- const bytes3 = new Uint8Array(value);
32632
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32623
+ const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
32624
+ const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
32633
32625
  return new Uint8Array([...lengthBytes, ...bytes3]);
32634
32626
  }
32635
32627
  decode(data, offset) {
@@ -32662,7 +32654,7 @@ This unreleased fuel-core build may include features and updates not yet support
32662
32654
  (max2, coder) => Math.max(max2, coder.encodedLength),
32663
32655
  0
32664
32656
  );
32665
- super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32657
+ super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32666
32658
  this.name = name;
32667
32659
  this.coders = coders;
32668
32660
  this.#caseIndexCoder = caseIndexCoder;
@@ -32760,6 +32752,28 @@ This unreleased fuel-core build may include features and updates not yet support
32760
32752
  return [toNumber2(bytes3), offset + this.length];
32761
32753
  }
32762
32754
  };
32755
+ var OptionCoder2 = class extends EnumCoder2 {
32756
+ encode(value) {
32757
+ const result = super.encode(this.toSwayOption(value));
32758
+ return result;
32759
+ }
32760
+ toSwayOption(input) {
32761
+ if (input !== void 0) {
32762
+ return { Some: input };
32763
+ }
32764
+ return { None: [] };
32765
+ }
32766
+ decode(data, offset) {
32767
+ const [decoded, newOffset] = super.decode(data, offset);
32768
+ return [this.toOption(decoded), newOffset];
32769
+ }
32770
+ toOption(output3) {
32771
+ if (output3 && "Some" in output3) {
32772
+ return output3.Some;
32773
+ }
32774
+ return void 0;
32775
+ }
32776
+ };
32763
32777
  var RawSliceCoder2 = class extends Coder {
32764
32778
  constructor() {
32765
32779
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -32813,6 +32827,30 @@ This unreleased fuel-core build may include features and updates not yet support
32813
32827
  }
32814
32828
  };
32815
32829
  __publicField4(StdStringCoder2, "memorySize", 1);
32830
+ var StrSliceCoder = class extends Coder {
32831
+ constructor() {
32832
+ super("strSlice", "str", WORD_SIZE);
32833
+ }
32834
+ encode(value) {
32835
+ const bytes3 = toUtf8Bytes(value);
32836
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32837
+ return new Uint8Array([...lengthBytes, ...bytes3]);
32838
+ }
32839
+ decode(data, offset) {
32840
+ if (data.length < this.encodedLength) {
32841
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
32842
+ }
32843
+ const offsetAndLength = offset + WORD_SIZE;
32844
+ const lengthBytes = data.slice(offset, offsetAndLength);
32845
+ const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32846
+ const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
32847
+ if (bytes3.length !== length) {
32848
+ throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
32849
+ }
32850
+ return [toUtf8String(bytes3), offsetAndLength + length];
32851
+ }
32852
+ };
32853
+ __publicField4(StrSliceCoder, "memorySize", 1);
32816
32854
  var StringCoder2 = class extends Coder {
32817
32855
  constructor(length) {
32818
32856
  super("string", `str[${length}]`, length);
@@ -32851,7 +32889,7 @@ This unreleased fuel-core build may include features and updates not yet support
32851
32889
  Object.keys(this.coders).map((fieldName) => {
32852
32890
  const fieldCoder = this.coders[fieldName];
32853
32891
  const fieldValue = value[fieldName];
32854
- if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
32892
+ if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
32855
32893
  throw new FuelError(
32856
32894
  ErrorCode.ENCODE_ERROR,
32857
32895
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -32959,6 +32997,8 @@ This unreleased fuel-core build may include features and updates not yet support
32959
32997
  return new ByteCoder2();
32960
32998
  case STD_STRING_CODER_TYPE:
32961
32999
  return new StdStringCoder2();
33000
+ case STR_SLICE_CODER_TYPE:
33001
+ return new StrSliceCoder();
32962
33002
  default:
32963
33003
  break;
32964
33004
  }
@@ -33003,7 +33043,7 @@ This unreleased fuel-core build may include features and updates not yet support
33003
33043
  const coders = getCoders(components, { getCoder: getCoder2 });
33004
33044
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
33005
33045
  if (isOptionEnum) {
33006
- return new OptionCoder(enumMatch.name, coders);
33046
+ return new OptionCoder2(enumMatch.name, coders);
33007
33047
  }
33008
33048
  return new EnumCoder2(enumMatch.name, coders);
33009
33049
  }
@@ -33014,12 +33054,6 @@ This unreleased fuel-core build may include features and updates not yet support
33014
33054
  );
33015
33055
  return new TupleCoder2(coders);
33016
33056
  }
33017
- if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
33018
- throw new FuelError(
33019
- ErrorCode.INVALID_DATA,
33020
- "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
33021
- );
33022
- }
33023
33057
  throw new FuelError(
33024
33058
  ErrorCode.CODER_NOT_FOUND,
33025
33059
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -33055,6 +33089,8 @@ This unreleased fuel-core build may include features and updates not yet support
33055
33089
  var FunctionFragment = class {
33056
33090
  signature;
33057
33091
  selector;
33092
+ selectorBytes;
33093
+ encoding;
33058
33094
  name;
33059
33095
  jsonFn;
33060
33096
  attributes;
@@ -33067,6 +33103,8 @@ This unreleased fuel-core build may include features and updates not yet support
33067
33103
  this.name = name;
33068
33104
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33069
33105
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33106
+ this.selectorBytes = new StdStringCoder2().encode(name);
33107
+ this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33070
33108
  this.isInputDataPointer = this.#isInputDataPointer();
33071
33109
  this.outputMetadata = {
33072
33110
  isHeapType: this.#isOutputDataHeap(),
@@ -33120,11 +33158,14 @@ This unreleased fuel-core build may include features and updates not yet support
33120
33158
  }
33121
33159
  const coders = nonEmptyInputs.map(
33122
33160
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
33123
- isRightPadded: nonEmptyInputs.length > 1
33161
+ isRightPadded: nonEmptyInputs.length > 1,
33162
+ encoding: this.encoding
33124
33163
  })
33125
33164
  );
33126
- const coder = new TupleCoder(coders);
33127
- const results = coder.encode(shallowCopyValues);
33165
+ if (this.encoding === ENCODING_V1) {
33166
+ return new TupleCoder2(coders).encode(shallowCopyValues);
33167
+ }
33168
+ const results = new TupleCoder(coders).encode(shallowCopyValues);
33128
33169
  return unpackDynamicData(results, offset, results.byteLength);
33129
33170
  }
33130
33171
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -33171,7 +33212,7 @@ This unreleased fuel-core build may include features and updates not yet support
33171
33212
  }
33172
33213
  const result = nonEmptyInputs.reduce(
33173
33214
  (obj, input) => {
33174
- const coder = AbiCoder.getCoder(this.jsonAbi, input);
33215
+ const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
33175
33216
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
33176
33217
  return {
33177
33218
  decoded: [...obj.decoded, decodedValue],
@@ -33191,7 +33232,9 @@ This unreleased fuel-core build may include features and updates not yet support
33191
33232
  return [void 0, 0];
33192
33233
  }
33193
33234
  const bytes3 = arrayify(data);
33194
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
33235
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
33236
+ encoding: this.encoding
33237
+ });
33195
33238
  return coder.decode(bytes3, 0);
33196
33239
  }
33197
33240
  };
@@ -33259,7 +33302,8 @@ This unreleased fuel-core build may include features and updates not yet support
33259
33302
  }
33260
33303
  );
33261
33304
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33262
- isRightPadded: true
33305
+ isRightPadded: true,
33306
+ encoding: this.jsonAbi.encoding
33263
33307
  });
33264
33308
  }
33265
33309
  getTypeById(typeId) {
@@ -38964,60 +39008,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38964
39008
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
38965
39009
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
38966
39010
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
38967
- var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
38968
39011
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
38969
- var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
38970
- var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
38971
- var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
38972
- var PANIC_REASONS = [
38973
- "UnknownPanicReason",
38974
- "Revert",
38975
- "OutOfGas",
38976
- "TransactionValidity",
38977
- "MemoryOverflow",
38978
- "ArithmeticOverflow",
38979
- "ContractNotFound",
38980
- "MemoryOwnership",
38981
- "NotEnoughBalance",
38982
- "ExpectedInternalContext",
38983
- "AssetIdNotFound",
38984
- "InputNotFound",
38985
- "OutputNotFound",
38986
- "WitnessNotFound",
38987
- "TransactionMaturity",
38988
- "InvalidMetadataIdentifier",
38989
- "MalformedCallStructure",
38990
- "ReservedRegisterNotWritable",
38991
- "InvalidFlags",
38992
- "InvalidImmediateValue",
38993
- "ExpectedCoinInput",
38994
- "EcalError",
38995
- "MemoryWriteOverlap",
38996
- "ContractNotInInputs",
38997
- "InternalBalanceOverflow",
38998
- "ContractMaxSize",
38999
- "ExpectedUnallocatedStack",
39000
- "MaxStaticContractsReached",
39001
- "TransferAmountCannotBeZero",
39002
- "ExpectedOutputVariable",
39003
- "ExpectedParentInternalContext",
39004
- "PredicateReturnedNonOne",
39005
- "ContractIdAlreadyDeployed",
39006
- "ContractMismatch",
39007
- "MessageDataTooLong",
39008
- "ArithmeticError",
39009
- "ContractInstructionNotAllowed",
39010
- "TransferZeroCoins",
39011
- "InvalidInstruction",
39012
- "MemoryNotExecutable",
39013
- "PolicyIsNotSet",
39014
- "PolicyNotFound",
39015
- "TooManyReceipts",
39016
- "BalanceOverflow",
39017
- "InvalidBlockHeight",
39018
- "TooManySlots"
39019
- ];
39020
- var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
39021
39012
 
39022
39013
  // src/providers/utils/receipts.ts
39023
39014
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -39391,74 +39382,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39391
39382
  });
39392
39383
  }
39393
39384
 
39394
- // src/providers/utils/extract-tx-error.ts
39395
- var assemblePanicError = (status) => {
39396
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
39397
- const reason = status.reason;
39398
- if (PANIC_REASONS.includes(status.reason)) {
39399
- errorMessage = `${errorMessage}
39400
-
39401
- You can read more about this error at:
39402
-
39403
- ${PANIC_DOC_URL}#variant.${status.reason}`;
39404
- }
39405
- return { errorMessage, reason };
39406
- };
39407
- var stringify2 = (obj) => JSON.stringify(obj, null, 2);
39408
- var assembleRevertError = (receipts, logs) => {
39409
- let errorMessage = "The transaction reverted with an unknown reason.";
39410
- const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
39411
- let reason = "";
39412
- if (revertReceipt) {
39413
- const reasonHex = bn(revertReceipt.val).toHex();
39414
- switch (reasonHex) {
39415
- case FAILED_REQUIRE_SIGNAL: {
39416
- reason = "require";
39417
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
39418
- break;
39419
- }
39420
- case FAILED_ASSERT_EQ_SIGNAL: {
39421
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39422
- reason = "assert_eq";
39423
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
39424
- break;
39425
- }
39426
- case FAILED_ASSERT_NE_SIGNAL: {
39427
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39428
- reason = "assert_ne";
39429
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
39430
- break;
39431
- }
39432
- case FAILED_ASSERT_SIGNAL:
39433
- reason = "assert";
39434
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
39435
- break;
39436
- case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
39437
- reason = "MissingOutputChange";
39438
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
39439
- break;
39440
- default:
39441
- reason = "unknown";
39442
- errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
39443
- }
39444
- }
39445
- return { errorMessage, reason };
39446
- };
39447
- var extractTxError = (params) => {
39448
- const { receipts, status, logs } = params;
39449
- const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
39450
- const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
39451
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
39452
- const metadata = {
39453
- logs,
39454
- receipts,
39455
- panic: isPanic,
39456
- revert: isRevert,
39457
- reason
39458
- };
39459
- return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
39460
- };
39461
-
39462
39385
  // src/providers/transaction-request/errors.ts
39463
39386
  var ChangeOutputCollisionError = class extends Error {
39464
39387
  name = "ChangeOutputCollisionError";
@@ -41275,26 +41198,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41275
41198
  gqlTransaction: this.gqlTransaction,
41276
41199
  ...transactionSummary
41277
41200
  };
41278
- let logs = [];
41279
41201
  if (this.abis) {
41280
- logs = getDecodedLogs(
41202
+ const logs = getDecodedLogs(
41281
41203
  transactionSummary.receipts,
41282
41204
  this.abis.main,
41283
41205
  this.abis.otherContractsAbis
41284
41206
  );
41285
41207
  transactionResult.logs = logs;
41286
41208
  }
41287
- if (transactionResult.isStatusFailure) {
41288
- const {
41289
- receipts,
41290
- gqlTransaction: { status }
41291
- } = transactionResult;
41292
- throw extractTxError({
41293
- receipts,
41294
- status,
41295
- logs
41296
- });
41297
- }
41298
41209
  return transactionResult;
41299
41210
  }
41300
41211
  /**
@@ -41303,7 +41214,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41303
41214
  * @param contractsAbiMap - The contracts ABI map.
41304
41215
  */
41305
41216
  async wait(contractsAbiMap) {
41306
- return this.waitForResult(contractsAbiMap);
41217
+ const result = await this.waitForResult(contractsAbiMap);
41218
+ if (result.isStatusFailure) {
41219
+ throw new FuelError(
41220
+ ErrorCode.TRANSACTION_FAILED,
41221
+ `Transaction failed: ${result.gqlTransaction.status.reason}`
41222
+ );
41223
+ }
41224
+ return result;
41307
41225
  }
41308
41226
  };
41309
41227