@fuel-ts/account 0.0.0-rc-1976-20240404171500 → 0.0.0-rc-1976-20240405090158

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;
@@ -31911,6 +31909,9 @@ This unreleased fuel-core build may include features and updates not yet support
31911
31909
  __privateAdd2(this, _getPaddedData);
31912
31910
  }
31913
31911
  encode(value) {
31912
+ if (!Array.isArray(value)) {
31913
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
31914
+ }
31914
31915
  const parts = [];
31915
31916
  const pointer = new BigNumberCoder("u64").encode(BASE_VECTOR_OFFSET);
31916
31917
  const data = __privateMethod2(this, _getPaddedData, getPaddedData_fn).call(this, value);
@@ -31937,7 +31938,7 @@ This unreleased fuel-core build may include features and updates not yet support
31937
31938
  };
31938
31939
  _getPaddedData = /* @__PURE__ */ new WeakSet();
31939
31940
  getPaddedData_fn = function(value) {
31940
- const data = value instanceof Uint8Array ? [value] : [new Uint8Array(value)];
31941
+ const data = [Uint8Array.from(value)];
31941
31942
  const paddingLength = (WORD_SIZE - value.length % WORD_SIZE) % WORD_SIZE;
31942
31943
  if (paddingLength) {
31943
31944
  data.push(new Uint8Array(paddingLength));
@@ -31960,7 +31961,7 @@ This unreleased fuel-core build may include features and updates not yet support
31960
31961
  (max2, coder) => Math.max(max2, coder.encodedLength),
31961
31962
  0
31962
31963
  );
31963
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31964
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
31964
31965
  this.name = name;
31965
31966
  this.coders = coders;
31966
31967
  this.#caseIndexCoder = caseIndexCoder;
@@ -32030,7 +32031,7 @@ This unreleased fuel-core build may include features and updates not yet support
32030
32031
  return { None: [] };
32031
32032
  }
32032
32033
  decode(data, offset) {
32033
- if (data.length < this.encodedLength) {
32034
+ if (data.length < this.encodedLength - 1) {
32034
32035
  throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid option data size.`);
32035
32036
  }
32036
32037
  const [decoded, newOffset] = super.decode(data, offset);
@@ -32613,8 +32614,11 @@ This unreleased fuel-core build may include features and updates not yet support
32613
32614
  super("struct", "struct Bytes", WORD_SIZE);
32614
32615
  }
32615
32616
  encode(value) {
32616
- const bytes3 = value instanceof Uint8Array ? value : new Uint8Array(value);
32617
- const lengthBytes = new BigNumberCoder("u64").encode(bytes3.length);
32617
+ if (!Array.isArray(value)) {
32618
+ throw new FuelError(ErrorCode.ENCODE_ERROR, `Expected array value.`);
32619
+ }
32620
+ const bytes3 = new Uint8Array(value);
32621
+ const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32618
32622
  return new Uint8Array([...lengthBytes, ...bytes3]);
32619
32623
  }
32620
32624
  decode(data, offset) {
@@ -32647,7 +32651,7 @@ This unreleased fuel-core build may include features and updates not yet support
32647
32651
  (max2, coder) => Math.max(max2, coder.encodedLength),
32648
32652
  0
32649
32653
  );
32650
- super(`enum ${name}`, `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32654
+ super("enum", `enum ${name}`, caseIndexCoder.encodedLength + encodedValueSize);
32651
32655
  this.name = name;
32652
32656
  this.coders = coders;
32653
32657
  this.#caseIndexCoder = caseIndexCoder;
@@ -32745,28 +32749,6 @@ This unreleased fuel-core build may include features and updates not yet support
32745
32749
  return [toNumber2(bytes3), offset + this.length];
32746
32750
  }
32747
32751
  };
32748
- var OptionCoder2 = class extends EnumCoder2 {
32749
- encode(value) {
32750
- const result = super.encode(this.toSwayOption(value));
32751
- return result;
32752
- }
32753
- toSwayOption(input) {
32754
- if (input !== void 0) {
32755
- return { Some: input };
32756
- }
32757
- return { None: [] };
32758
- }
32759
- decode(data, offset) {
32760
- const [decoded, newOffset] = super.decode(data, offset);
32761
- return [this.toOption(decoded), newOffset];
32762
- }
32763
- toOption(output3) {
32764
- if (output3 && "Some" in output3) {
32765
- return output3.Some;
32766
- }
32767
- return void 0;
32768
- }
32769
- };
32770
32752
  var RawSliceCoder2 = class extends Coder {
32771
32753
  constructor() {
32772
32754
  super("raw untyped slice", "raw untyped slice", WORD_SIZE);
@@ -32820,30 +32802,6 @@ This unreleased fuel-core build may include features and updates not yet support
32820
32802
  }
32821
32803
  };
32822
32804
  __publicField4(StdStringCoder2, "memorySize", 1);
32823
- var StrSliceCoder = class extends Coder {
32824
- constructor() {
32825
- super("strSlice", "str", WORD_SIZE);
32826
- }
32827
- encode(value) {
32828
- const bytes3 = toUtf8Bytes(value);
32829
- const lengthBytes = new BigNumberCoder("u64").encode(value.length);
32830
- return new Uint8Array([...lengthBytes, ...bytes3]);
32831
- }
32832
- decode(data, offset) {
32833
- if (data.length < this.encodedLength) {
32834
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice data size.`);
32835
- }
32836
- const offsetAndLength = offset + WORD_SIZE;
32837
- const lengthBytes = data.slice(offset, offsetAndLength);
32838
- const length = bn(new BigNumberCoder("u64").decode(lengthBytes, 0)[0]).toNumber();
32839
- const bytes3 = data.slice(offsetAndLength, offsetAndLength + length);
32840
- if (bytes3.length !== length) {
32841
- throw new FuelError(ErrorCode.DECODE_ERROR, `Invalid string slice byte data size.`);
32842
- }
32843
- return [toUtf8String(bytes3), offsetAndLength + length];
32844
- }
32845
- };
32846
- __publicField4(StrSliceCoder, "memorySize", 1);
32847
32805
  var StringCoder2 = class extends Coder {
32848
32806
  constructor(length) {
32849
32807
  super("string", `str[${length}]`, length);
@@ -32882,7 +32840,7 @@ This unreleased fuel-core build may include features and updates not yet support
32882
32840
  Object.keys(this.coders).map((fieldName) => {
32883
32841
  const fieldCoder = this.coders[fieldName];
32884
32842
  const fieldValue = value[fieldName];
32885
- if (!(fieldCoder instanceof OptionCoder2) && fieldValue == null) {
32843
+ if (!(fieldCoder instanceof OptionCoder) && fieldValue == null) {
32886
32844
  throw new FuelError(
32887
32845
  ErrorCode.ENCODE_ERROR,
32888
32846
  `Invalid ${this.type}. Field "${fieldName}" not present.`
@@ -32990,8 +32948,6 @@ This unreleased fuel-core build may include features and updates not yet support
32990
32948
  return new ByteCoder2();
32991
32949
  case STD_STRING_CODER_TYPE:
32992
32950
  return new StdStringCoder2();
32993
- case STR_SLICE_CODER_TYPE:
32994
- return new StrSliceCoder();
32995
32951
  default:
32996
32952
  break;
32997
32953
  }
@@ -33036,7 +32992,7 @@ This unreleased fuel-core build may include features and updates not yet support
33036
32992
  const coders = getCoders(components, { getCoder: getCoder2 });
33037
32993
  const isOptionEnum = resolvedAbiType.type === OPTION_CODER_TYPE;
33038
32994
  if (isOptionEnum) {
33039
- return new OptionCoder2(enumMatch.name, coders);
32995
+ return new OptionCoder(enumMatch.name, coders);
33040
32996
  }
33041
32997
  return new EnumCoder2(enumMatch.name, coders);
33042
32998
  }
@@ -33047,6 +33003,12 @@ This unreleased fuel-core build may include features and updates not yet support
33047
33003
  );
33048
33004
  return new TupleCoder2(coders);
33049
33005
  }
33006
+ if (resolvedAbiType.type === STR_SLICE_CODER_TYPE) {
33007
+ throw new FuelError(
33008
+ ErrorCode.INVALID_DATA,
33009
+ "String slices can not be decoded from logs. Convert the slice to `str[N]` with `__to_str_array`"
33010
+ );
33011
+ }
33050
33012
  throw new FuelError(
33051
33013
  ErrorCode.CODER_NOT_FOUND,
33052
33014
  `Coder not found: ${JSON.stringify(resolvedAbiType)}.`
@@ -33082,8 +33044,6 @@ This unreleased fuel-core build may include features and updates not yet support
33082
33044
  var FunctionFragment = class {
33083
33045
  signature;
33084
33046
  selector;
33085
- selectorBytes;
33086
- encoding;
33087
33047
  name;
33088
33048
  jsonFn;
33089
33049
  attributes;
@@ -33096,8 +33056,6 @@ This unreleased fuel-core build may include features and updates not yet support
33096
33056
  this.name = name;
33097
33057
  this.signature = FunctionFragment.getSignature(this.jsonAbi, this.jsonFn);
33098
33058
  this.selector = FunctionFragment.getFunctionSelector(this.signature);
33099
- this.selectorBytes = new StdStringCoder2().encode(name);
33100
- this.encoding = this.jsonAbi.encoding ?? ENCODING_V0;
33101
33059
  this.isInputDataPointer = this.#isInputDataPointer();
33102
33060
  this.outputMetadata = {
33103
33061
  isHeapType: this.#isOutputDataHeap(),
@@ -33151,14 +33109,11 @@ This unreleased fuel-core build may include features and updates not yet support
33151
33109
  }
33152
33110
  const coders = nonEmptyInputs.map(
33153
33111
  (t) => AbiCoder.getCoder(this.jsonAbi, t, {
33154
- isRightPadded: nonEmptyInputs.length > 1,
33155
- encoding: this.encoding
33112
+ isRightPadded: nonEmptyInputs.length > 1
33156
33113
  })
33157
33114
  );
33158
- if (this.encoding === ENCODING_V1) {
33159
- return new TupleCoder2(coders).encode(shallowCopyValues);
33160
- }
33161
- const results = new TupleCoder(coders).encode(shallowCopyValues);
33115
+ const coder = new TupleCoder(coders);
33116
+ const results = coder.encode(shallowCopyValues);
33162
33117
  return unpackDynamicData(results, offset, results.byteLength);
33163
33118
  }
33164
33119
  static verifyArgsAndInputsAlign(args, inputs, abi) {
@@ -33205,7 +33160,7 @@ This unreleased fuel-core build may include features and updates not yet support
33205
33160
  }
33206
33161
  const result = nonEmptyInputs.reduce(
33207
33162
  (obj, input) => {
33208
- const coder = AbiCoder.getCoder(this.jsonAbi, input, { encoding: this.encoding });
33163
+ const coder = AbiCoder.getCoder(this.jsonAbi, input);
33209
33164
  const [decodedValue, decodedValueByteSize] = coder.decode(bytes3, obj.offset);
33210
33165
  return {
33211
33166
  decoded: [...obj.decoded, decodedValue],
@@ -33225,9 +33180,7 @@ This unreleased fuel-core build may include features and updates not yet support
33225
33180
  return [void 0, 0];
33226
33181
  }
33227
33182
  const bytes3 = arrayify(data);
33228
- const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output, {
33229
- encoding: this.encoding
33230
- });
33183
+ const coder = AbiCoder.getCoder(this.jsonAbi, this.jsonFn.output);
33231
33184
  return coder.decode(bytes3, 0);
33232
33185
  }
33233
33186
  };
@@ -33289,8 +33242,7 @@ This unreleased fuel-core build may include features and updates not yet support
33289
33242
  }
33290
33243
  );
33291
33244
  return AbiCoder.encode(this.jsonAbi, configurable.configurableType, value, {
33292
- isRightPadded: true,
33293
- encoding: this.jsonAbi.encoding
33245
+ isRightPadded: true
33294
33246
  });
33295
33247
  }
33296
33248
  getTypeById(typeId) {
@@ -38998,60 +38950,7 @@ ${MessageCoinFragmentFragmentDoc}`;
38998
38950
  var MAX_SCRIPT_DATA_LENGTH = 1024 * 1024 * 1024;
38999
38951
  var MAX_PREDICATE_LENGTH = 1024 * 1024;
39000
38952
  var MAX_PREDICATE_DATA_LENGTH = 1024 * 1024;
39001
- var FAILED_REQUIRE_SIGNAL = "0xffffffffffff0000";
39002
38953
  var FAILED_TRANSFER_TO_ADDRESS_SIGNAL = "0xffffffffffff0001";
39003
- var FAILED_ASSERT_EQ_SIGNAL = "0xffffffffffff0003";
39004
- var FAILED_ASSERT_SIGNAL = "0xffffffffffff0004";
39005
- var FAILED_ASSERT_NE_SIGNAL = "0xffffffffffff0005";
39006
- var PANIC_REASONS = [
39007
- "UnknownPanicReason",
39008
- "Revert",
39009
- "OutOfGas",
39010
- "TransactionValidity",
39011
- "MemoryOverflow",
39012
- "ArithmeticOverflow",
39013
- "ContractNotFound",
39014
- "MemoryOwnership",
39015
- "NotEnoughBalance",
39016
- "ExpectedInternalContext",
39017
- "AssetIdNotFound",
39018
- "InputNotFound",
39019
- "OutputNotFound",
39020
- "WitnessNotFound",
39021
- "TransactionMaturity",
39022
- "InvalidMetadataIdentifier",
39023
- "MalformedCallStructure",
39024
- "ReservedRegisterNotWritable",
39025
- "InvalidFlags",
39026
- "InvalidImmediateValue",
39027
- "ExpectedCoinInput",
39028
- "EcalError",
39029
- "MemoryWriteOverlap",
39030
- "ContractNotInInputs",
39031
- "InternalBalanceOverflow",
39032
- "ContractMaxSize",
39033
- "ExpectedUnallocatedStack",
39034
- "MaxStaticContractsReached",
39035
- "TransferAmountCannotBeZero",
39036
- "ExpectedOutputVariable",
39037
- "ExpectedParentInternalContext",
39038
- "PredicateReturnedNonOne",
39039
- "ContractIdAlreadyDeployed",
39040
- "ContractMismatch",
39041
- "MessageDataTooLong",
39042
- "ArithmeticError",
39043
- "ContractInstructionNotAllowed",
39044
- "TransferZeroCoins",
39045
- "InvalidInstruction",
39046
- "MemoryNotExecutable",
39047
- "PolicyIsNotSet",
39048
- "PolicyNotFound",
39049
- "TooManyReceipts",
39050
- "BalanceOverflow",
39051
- "InvalidBlockHeight",
39052
- "TooManySlots"
39053
- ];
39054
- var PANIC_DOC_URL = "https://docs.rs/fuel-asm/latest/fuel_asm/enum.PanicReason.html";
39055
38954
 
39056
38955
  // src/providers/utils/receipts.ts
39057
38956
  var doesReceiptHaveMissingOutputVariables = (receipt) => receipt.type === ReceiptType.Revert && receipt.val.toString("hex") === FAILED_TRANSFER_TO_ADDRESS_SIGNAL;
@@ -39425,74 +39324,6 @@ ${MessageCoinFragmentFragmentDoc}`;
39425
39324
  });
39426
39325
  }
39427
39326
 
39428
- // src/providers/utils/extract-tx-error.ts
39429
- var assemblePanicError = (status) => {
39430
- let errorMessage = `The transaction reverted with reason: "${status.reason}".`;
39431
- const reason = status.reason;
39432
- if (PANIC_REASONS.includes(status.reason)) {
39433
- errorMessage = `${errorMessage}
39434
-
39435
- You can read more about this error at:
39436
-
39437
- ${PANIC_DOC_URL}#variant.${status.reason}`;
39438
- }
39439
- return { errorMessage, reason };
39440
- };
39441
- var stringify2 = (obj) => JSON.stringify(obj, null, 2);
39442
- var assembleRevertError = (receipts, logs) => {
39443
- let errorMessage = "The transaction reverted with an unknown reason.";
39444
- const revertReceipt = receipts.find(({ type: type3 }) => type3 === ReceiptType.Revert);
39445
- let reason = "";
39446
- if (revertReceipt) {
39447
- const reasonHex = bn(revertReceipt.val).toHex();
39448
- switch (reasonHex) {
39449
- case FAILED_REQUIRE_SIGNAL: {
39450
- reason = "require";
39451
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify2(logs[0]) : "an error."}.`;
39452
- break;
39453
- }
39454
- case FAILED_ASSERT_EQ_SIGNAL: {
39455
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39456
- reason = "assert_eq";
39457
- errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
39458
- break;
39459
- }
39460
- case FAILED_ASSERT_NE_SIGNAL: {
39461
- const sufix = logs.length >= 2 ? ` comparing ${stringify2(logs[1])} and ${stringify2(logs[0])}.` : ".";
39462
- reason = "assert_ne";
39463
- errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
39464
- break;
39465
- }
39466
- case FAILED_ASSERT_SIGNAL:
39467
- reason = "assert";
39468
- errorMessage = `The transaction reverted because an "assert" statement failed to evaluate to true.`;
39469
- break;
39470
- case FAILED_TRANSFER_TO_ADDRESS_SIGNAL:
39471
- reason = "MissingOutputChange";
39472
- errorMessage = `The transaction reverted because it's missing an "OutputChange".`;
39473
- break;
39474
- default:
39475
- reason = "unknown";
39476
- errorMessage = `The transaction reverted with an unknown reason: ${revertReceipt.val}`;
39477
- }
39478
- }
39479
- return { errorMessage, reason };
39480
- };
39481
- var extractTxError = (params) => {
39482
- const { receipts, status, logs } = params;
39483
- const isPanic = receipts.some(({ type: type3 }) => type3 === ReceiptType.Panic);
39484
- const isRevert = receipts.some(({ type: type3 }) => type3 === ReceiptType.Revert);
39485
- const { errorMessage, reason } = status?.type === "FailureStatus" && isPanic ? assemblePanicError(status) : assembleRevertError(receipts, logs);
39486
- const metadata = {
39487
- logs,
39488
- receipts,
39489
- panic: isPanic,
39490
- revert: isRevert,
39491
- reason
39492
- };
39493
- return new FuelError(ErrorCode.SCRIPT_REVERTED, errorMessage, metadata);
39494
- };
39495
-
39496
39327
  // src/providers/transaction-request/errors.ts
39497
39328
  var ChangeOutputCollisionError = class extends Error {
39498
39329
  name = "ChangeOutputCollisionError";
@@ -41311,26 +41142,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41311
41142
  gqlTransaction: this.gqlTransaction,
41312
41143
  ...transactionSummary
41313
41144
  };
41314
- let logs = [];
41315
41145
  if (this.abis) {
41316
- logs = getDecodedLogs(
41146
+ const logs = getDecodedLogs(
41317
41147
  transactionSummary.receipts,
41318
41148
  this.abis.main,
41319
41149
  this.abis.otherContractsAbis
41320
41150
  );
41321
41151
  transactionResult.logs = logs;
41322
41152
  }
41323
- if (transactionResult.isStatusFailure) {
41324
- const {
41325
- receipts,
41326
- gqlTransaction: { status }
41327
- } = transactionResult;
41328
- throw extractTxError({
41329
- receipts,
41330
- status,
41331
- logs
41332
- });
41333
- }
41334
41153
  return transactionResult;
41335
41154
  }
41336
41155
  /**
@@ -41339,7 +41158,14 @@ ${PANIC_DOC_URL}#variant.${status.reason}`;
41339
41158
  * @param contractsAbiMap - The contracts ABI map.
41340
41159
  */
41341
41160
  async wait(contractsAbiMap) {
41342
- return this.waitForResult(contractsAbiMap);
41161
+ const result = await this.waitForResult(contractsAbiMap);
41162
+ if (result.isStatusFailure) {
41163
+ throw new FuelError(
41164
+ ErrorCode.TRANSACTION_FAILED,
41165
+ `Transaction failed: ${result.gqlTransaction.status.reason}`
41166
+ );
41167
+ }
41168
+ return result;
41343
41169
  }
41344
41170
  };
41345
41171