@fuel-ts/account 0.94.3 → 0.94.5

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.
Files changed (36) hide show
  1. package/dist/account.d.ts.map +1 -1
  2. package/dist/index.global.js +391 -436
  3. package/dist/index.global.js.map +1 -1
  4. package/dist/index.js +345 -195
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +427 -285
  7. package/dist/index.mjs.map +1 -1
  8. package/dist/predicate/predicate.d.ts.map +1 -1
  9. package/dist/providers/__generated__/operations.d.ts +250 -0
  10. package/dist/providers/__generated__/operations.d.ts.map +1 -1
  11. package/dist/providers/fuel-graphql-subscriber.d.ts.map +1 -1
  12. package/dist/providers/message.d.ts +3 -0
  13. package/dist/providers/message.d.ts.map +1 -1
  14. package/dist/providers/provider.d.ts +36 -3
  15. package/dist/providers/provider.d.ts.map +1 -1
  16. package/dist/providers/transaction-request/blob-transaction-request.d.ts.map +1 -1
  17. package/dist/providers/transaction-request/create-transaction-request.d.ts.map +1 -1
  18. package/dist/providers/transaction-request/helpers.d.ts +2 -0
  19. package/dist/providers/transaction-request/helpers.d.ts.map +1 -1
  20. package/dist/providers/transaction-request/script-transaction-request.d.ts.map +1 -1
  21. package/dist/providers/transaction-request/transaction-request.d.ts +4 -2
  22. package/dist/providers/transaction-request/transaction-request.d.ts.map +1 -1
  23. package/dist/providers/transaction-response/transaction-response.d.ts +3 -1
  24. package/dist/providers/transaction-response/transaction-response.d.ts.map +1 -1
  25. package/dist/providers/utils/extract-tx-error.d.ts.map +1 -1
  26. package/dist/providers/utils/handle-gql-error-message.d.ts +6 -0
  27. package/dist/providers/utils/handle-gql-error-message.d.ts.map +1 -0
  28. package/dist/providers/utils/receipts.d.ts.map +1 -1
  29. package/dist/test-utils/launchNode.d.ts.map +1 -1
  30. package/dist/test-utils.global.js +235 -286
  31. package/dist/test-utils.global.js.map +1 -1
  32. package/dist/test-utils.js +300 -162
  33. package/dist/test-utils.js.map +1 -1
  34. package/dist/test-utils.mjs +372 -239
  35. package/dist/test-utils.mjs.map +1 -1
  36. package/package.json +16 -16
@@ -4754,8 +4754,8 @@
4754
4754
  var utils = require_utils();
4755
4755
  var Impl = require_URL_impl();
4756
4756
  var impl = utils.implSymbol;
4757
- function URL2(url) {
4758
- if (!this || this[impl] || !(this instanceof URL2)) {
4757
+ function URL3(url) {
4758
+ if (!this || this[impl] || !(this instanceof URL3)) {
4759
4759
  throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
4760
4760
  }
4761
4761
  if (arguments.length < 1) {
@@ -4771,7 +4771,7 @@
4771
4771
  }
4772
4772
  module.exports.setup(this, args);
4773
4773
  }
4774
- URL2.prototype.toJSON = function toJSON() {
4774
+ URL3.prototype.toJSON = function toJSON() {
4775
4775
  if (!this || !module.exports.is(this)) {
4776
4776
  throw new TypeError("Illegal invocation");
4777
4777
  }
@@ -4781,7 +4781,7 @@
4781
4781
  }
4782
4782
  return this[impl].toJSON.apply(this[impl], args);
4783
4783
  };
4784
- Object.defineProperty(URL2.prototype, "href", {
4784
+ Object.defineProperty(URL3.prototype, "href", {
4785
4785
  get() {
4786
4786
  return this[impl].href;
4787
4787
  },
@@ -4792,20 +4792,20 @@
4792
4792
  enumerable: true,
4793
4793
  configurable: true
4794
4794
  });
4795
- URL2.prototype.toString = function() {
4795
+ URL3.prototype.toString = function() {
4796
4796
  if (!this || !module.exports.is(this)) {
4797
4797
  throw new TypeError("Illegal invocation");
4798
4798
  }
4799
4799
  return this.href;
4800
4800
  };
4801
- Object.defineProperty(URL2.prototype, "origin", {
4801
+ Object.defineProperty(URL3.prototype, "origin", {
4802
4802
  get() {
4803
4803
  return this[impl].origin;
4804
4804
  },
4805
4805
  enumerable: true,
4806
4806
  configurable: true
4807
4807
  });
4808
- Object.defineProperty(URL2.prototype, "protocol", {
4808
+ Object.defineProperty(URL3.prototype, "protocol", {
4809
4809
  get() {
4810
4810
  return this[impl].protocol;
4811
4811
  },
@@ -4816,7 +4816,7 @@
4816
4816
  enumerable: true,
4817
4817
  configurable: true
4818
4818
  });
4819
- Object.defineProperty(URL2.prototype, "username", {
4819
+ Object.defineProperty(URL3.prototype, "username", {
4820
4820
  get() {
4821
4821
  return this[impl].username;
4822
4822
  },
@@ -4827,7 +4827,7 @@
4827
4827
  enumerable: true,
4828
4828
  configurable: true
4829
4829
  });
4830
- Object.defineProperty(URL2.prototype, "password", {
4830
+ Object.defineProperty(URL3.prototype, "password", {
4831
4831
  get() {
4832
4832
  return this[impl].password;
4833
4833
  },
@@ -4838,7 +4838,7 @@
4838
4838
  enumerable: true,
4839
4839
  configurable: true
4840
4840
  });
4841
- Object.defineProperty(URL2.prototype, "host", {
4841
+ Object.defineProperty(URL3.prototype, "host", {
4842
4842
  get() {
4843
4843
  return this[impl].host;
4844
4844
  },
@@ -4849,7 +4849,7 @@
4849
4849
  enumerable: true,
4850
4850
  configurable: true
4851
4851
  });
4852
- Object.defineProperty(URL2.prototype, "hostname", {
4852
+ Object.defineProperty(URL3.prototype, "hostname", {
4853
4853
  get() {
4854
4854
  return this[impl].hostname;
4855
4855
  },
@@ -4860,7 +4860,7 @@
4860
4860
  enumerable: true,
4861
4861
  configurable: true
4862
4862
  });
4863
- Object.defineProperty(URL2.prototype, "port", {
4863
+ Object.defineProperty(URL3.prototype, "port", {
4864
4864
  get() {
4865
4865
  return this[impl].port;
4866
4866
  },
@@ -4871,7 +4871,7 @@
4871
4871
  enumerable: true,
4872
4872
  configurable: true
4873
4873
  });
4874
- Object.defineProperty(URL2.prototype, "pathname", {
4874
+ Object.defineProperty(URL3.prototype, "pathname", {
4875
4875
  get() {
4876
4876
  return this[impl].pathname;
4877
4877
  },
@@ -4882,7 +4882,7 @@
4882
4882
  enumerable: true,
4883
4883
  configurable: true
4884
4884
  });
4885
- Object.defineProperty(URL2.prototype, "search", {
4885
+ Object.defineProperty(URL3.prototype, "search", {
4886
4886
  get() {
4887
4887
  return this[impl].search;
4888
4888
  },
@@ -4893,7 +4893,7 @@
4893
4893
  enumerable: true,
4894
4894
  configurable: true
4895
4895
  });
4896
- Object.defineProperty(URL2.prototype, "hash", {
4896
+ Object.defineProperty(URL3.prototype, "hash", {
4897
4897
  get() {
4898
4898
  return this[impl].hash;
4899
4899
  },
@@ -4909,7 +4909,7 @@
4909
4909
  return !!obj && obj[impl] instanceof Impl.implementation;
4910
4910
  },
4911
4911
  create(constructorArgs, privateData) {
4912
- let obj = Object.create(URL2.prototype);
4912
+ let obj = Object.create(URL3.prototype);
4913
4913
  this.setup(obj, constructorArgs, privateData);
4914
4914
  return obj;
4915
4915
  },
@@ -4920,10 +4920,10 @@
4920
4920
  obj[impl] = new Impl.implementation(constructorArgs, privateData);
4921
4921
  obj[impl][utils.wrapperSymbol] = obj;
4922
4922
  },
4923
- interface: URL2,
4923
+ interface: URL3,
4924
4924
  expose: {
4925
- Window: { URL: URL2 },
4926
- Worker: { URL: URL2 }
4925
+ Window: { URL: URL3 },
4926
+ Worker: { URL: URL3 }
4927
4927
  }
4928
4928
  };
4929
4929
  }
@@ -5257,7 +5257,7 @@
5257
5257
  }
5258
5258
  function parseURL(urlStr) {
5259
5259
  if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
5260
- urlStr = new URL(urlStr).toString();
5260
+ urlStr = new URL2(urlStr).toString();
5261
5261
  }
5262
5262
  return parse_url(urlStr);
5263
5263
  }
@@ -5551,7 +5551,7 @@
5551
5551
  stream.end();
5552
5552
  }
5553
5553
  }
5554
- var import_stream, import_http, import_url, import_whatwg_url, import_https, import_zlib, Readable, BUFFER, TYPE, Blob2, convert, INTERNALS, PassThrough, invalidTokenRegex, invalidHeaderCharRegex, MAP, Headers2, INTERNAL, HeadersIteratorPrototype, INTERNALS$1, STATUS_CODES, Response2, INTERNALS$2, URL, parse_url, format_url, streamDestructionSupported, Request, URL$1, PassThrough$1, isDomainOrSubdomain, isSameProtocol, lib_default;
5554
+ var import_stream, import_http, import_url, import_whatwg_url, import_https, import_zlib, Readable, BUFFER, TYPE, Blob2, convert, INTERNALS, PassThrough, invalidTokenRegex, invalidHeaderCharRegex, MAP, Headers2, INTERNAL, HeadersIteratorPrototype, INTERNALS$1, STATUS_CODES, Response2, INTERNALS$2, URL2, parse_url, format_url, streamDestructionSupported, Request, URL$1, PassThrough$1, isDomainOrSubdomain, isSameProtocol, lib_default;
5555
5555
  var init_lib = __esm({
5556
5556
  "../../node_modules/.pnpm/node-fetch@2.7.0/node_modules/node-fetch/lib/index.mjs"() {
5557
5557
  import_stream = __toESM(__require("stream"), 1);
@@ -6074,7 +6074,7 @@
6074
6074
  configurable: true
6075
6075
  });
6076
6076
  INTERNALS$2 = Symbol("Request internals");
6077
- URL = import_url.default.URL || import_whatwg_url.default.URL;
6077
+ URL2 = import_url.default.URL || import_whatwg_url.default.URL;
6078
6078
  parse_url = import_url.default.parse;
6079
6079
  format_url = import_url.default.format;
6080
6080
  streamDestructionSupported = "destroy" in import_stream.default.Readable.prototype;
@@ -28799,9 +28799,9 @@ spurious results.`);
28799
28799
  // ../versions/dist/index.mjs
28800
28800
  function getBuiltinVersions() {
28801
28801
  return {
28802
- FORC: "0.63.3",
28803
- FUEL_CORE: "0.34.0",
28804
- FUELS: "0.94.3"
28802
+ FORC: "0.63.5",
28803
+ FUEL_CORE: "0.35.0",
28804
+ FUELS: "0.94.5"
28805
28805
  };
28806
28806
  }
28807
28807
  function parseVersion(version) {
@@ -28964,7 +28964,7 @@ This unreleased fuel-core build may include features and updates not yet support
28964
28964
  return new _FuelError(error.code, error.message);
28965
28965
  }
28966
28966
  code;
28967
- constructor(code, message, metadata = {}, rawError = {}) {
28967
+ constructor(code, message, metadata = {}, rawError = null) {
28968
28968
  super(message);
28969
28969
  this.code = code;
28970
28970
  this.name = "FuelError";
@@ -30422,44 +30422,16 @@ If you are attempting to transform a hex value, please make sure it is being pas
30422
30422
  return derivedKey;
30423
30423
  };
30424
30424
  var keccak256 = (data) => keccak_256(data);
30425
- var locked = false;
30426
- var helper2 = (data) => ripemd160(data);
30427
- var ripemd = helper2;
30428
30425
  function ripemd1602(_data) {
30429
30426
  const data = arrayify(_data, "data");
30430
- return ripemd(data);
30427
+ return ripemd160(data);
30431
30428
  }
30432
- ripemd1602._ = helper2;
30433
- ripemd1602.lock = () => {
30434
- locked = true;
30435
- };
30436
- ripemd1602.register = (func) => {
30437
- if (locked) {
30438
- throw new FuelError(ErrorCode.HASHER_LOCKED, "ripemd160 is locked");
30439
- }
30440
- ripemd = func;
30441
- };
30442
- Object.freeze(ripemd1602);
30443
30429
  var bufferFromString = (string, encoding = "base64") => Uint8Array.from(Buffer.from(string, encoding));
30444
- var locked2 = false;
30445
- var PBKDF2 = (password, salt, iterations, keylen, algo) => (0, import_crypto2.pbkdf2Sync)(password, salt, iterations, keylen, algo);
30446
- var pBkdf2 = PBKDF2;
30447
30430
  function pbkdf22(_password, _salt, iterations, keylen, algo) {
30448
30431
  const password = arrayify(_password, "password");
30449
30432
  const salt = arrayify(_salt, "salt");
30450
- return hexlify(pBkdf2(password, salt, iterations, keylen, algo));
30433
+ return hexlify((0, import_crypto2.pbkdf2Sync)(password, salt, iterations, keylen, algo));
30451
30434
  }
30452
- pbkdf22._ = PBKDF2;
30453
- pbkdf22.lock = () => {
30454
- locked2 = true;
30455
- };
30456
- pbkdf22.register = (func) => {
30457
- if (locked2) {
30458
- throw new FuelError(ErrorCode.HASHER_LOCKED, "pbkdf2 is locked");
30459
- }
30460
- pBkdf2 = func;
30461
- };
30462
- Object.freeze(pbkdf22);
30463
30435
  var randomBytes = (length) => {
30464
30436
  const randomValues = Uint8Array.from(import_crypto3.default.randomBytes(length));
30465
30437
  return randomValues;
@@ -30510,25 +30482,11 @@ If you are attempting to transform a hex value, please make sure it is being pas
30510
30482
  const decrypted = await Buffer.concat([decipher.update(data), decipher.final()]);
30511
30483
  return new Uint8Array(decrypted);
30512
30484
  }
30513
- var locked3 = false;
30514
- var COMPUTEHMAC = (algorithm, key, data) => (0, import_crypto5.createHmac)(algorithm, key).update(data).digest();
30515
- var computeHMAC = COMPUTEHMAC;
30516
30485
  function computeHmac(algorithm, _key, _data) {
30517
30486
  const key = arrayify(_key, "key");
30518
30487
  const data = arrayify(_data, "data");
30519
- return hexlify(computeHMAC(algorithm, key, data));
30488
+ return hexlify((0, import_crypto5.createHmac)(algorithm, key).update(data).digest());
30520
30489
  }
30521
- computeHmac._ = COMPUTEHMAC;
30522
- computeHmac.lock = () => {
30523
- locked3 = true;
30524
- };
30525
- computeHmac.register = (func) => {
30526
- if (locked3) {
30527
- throw new FuelError(ErrorCode.HASHER_LOCKED, "computeHmac is locked");
30528
- }
30529
- computeHMAC = func;
30530
- };
30531
- Object.freeze(computeHmac);
30532
30490
  var randomUUID = () => (0, import_crypto6.randomUUID)();
30533
30491
  var api = {
30534
30492
  bufferFromString,
@@ -32105,169 +32063,6 @@ If you are attempting to transform a hex value, please make sure it is being pas
32105
32063
  }
32106
32064
  };
32107
32065
 
32108
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isPlaceholder.js
32109
- function _isPlaceholder(a) {
32110
- return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
32111
- }
32112
-
32113
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry1.js
32114
- function _curry1(fn) {
32115
- return function f1(a) {
32116
- if (arguments.length === 0 || _isPlaceholder(a)) {
32117
- return f1;
32118
- } else {
32119
- return fn.apply(this, arguments);
32120
- }
32121
- };
32122
- }
32123
-
32124
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/type.js
32125
- var type = /* @__PURE__ */ _curry1(function type2(val) {
32126
- return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
32127
- });
32128
- var type_default = type;
32129
-
32130
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_cloneRegExp.js
32131
- function _cloneRegExp(pattern) {
32132
- return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
32133
- }
32134
-
32135
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_clone.js
32136
- function _clone(value, deep, map) {
32137
- map || (map = new _ObjectMap());
32138
- if (_isPrimitive(value)) {
32139
- return value;
32140
- }
32141
- var copy = function copy2(copiedValue) {
32142
- var cachedCopy = map.get(value);
32143
- if (cachedCopy) {
32144
- return cachedCopy;
32145
- }
32146
- map.set(value, copiedValue);
32147
- for (var key in value) {
32148
- if (Object.prototype.hasOwnProperty.call(value, key)) {
32149
- copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
32150
- }
32151
- }
32152
- return copiedValue;
32153
- };
32154
- switch (type_default(value)) {
32155
- case "Object":
32156
- return copy(Object.create(Object.getPrototypeOf(value)));
32157
- case "Array":
32158
- return copy(Array(value.length));
32159
- case "Date":
32160
- return new Date(value.valueOf());
32161
- case "RegExp":
32162
- return _cloneRegExp(value);
32163
- case "Int8Array":
32164
- case "Uint8Array":
32165
- case "Uint8ClampedArray":
32166
- case "Int16Array":
32167
- case "Uint16Array":
32168
- case "Int32Array":
32169
- case "Uint32Array":
32170
- case "Float32Array":
32171
- case "Float64Array":
32172
- case "BigInt64Array":
32173
- case "BigUint64Array":
32174
- return value.slice();
32175
- default:
32176
- return value;
32177
- }
32178
- }
32179
- function _isPrimitive(param) {
32180
- var type3 = typeof param;
32181
- return param == null || type3 != "object" && type3 != "function";
32182
- }
32183
- var _ObjectMap = /* @__PURE__ */ function() {
32184
- function _ObjectMap2() {
32185
- this.map = {};
32186
- this.length = 0;
32187
- }
32188
- _ObjectMap2.prototype.set = function(key, value) {
32189
- var hashedKey = this.hash(key);
32190
- var bucket = this.map[hashedKey];
32191
- if (!bucket) {
32192
- this.map[hashedKey] = bucket = [];
32193
- }
32194
- bucket.push([key, value]);
32195
- this.length += 1;
32196
- };
32197
- _ObjectMap2.prototype.hash = function(key) {
32198
- var hashedKey = [];
32199
- for (var value in key) {
32200
- hashedKey.push(Object.prototype.toString.call(key[value]));
32201
- }
32202
- return hashedKey.join();
32203
- };
32204
- _ObjectMap2.prototype.get = function(key) {
32205
- if (this.length <= 180) {
32206
- for (var p in this.map) {
32207
- var bucket = this.map[p];
32208
- for (var i = 0; i < bucket.length; i += 1) {
32209
- var element = bucket[i];
32210
- if (element[0] === key) {
32211
- return element[1];
32212
- }
32213
- }
32214
- }
32215
- return;
32216
- }
32217
- var hashedKey = this.hash(key);
32218
- var bucket = this.map[hashedKey];
32219
- if (!bucket) {
32220
- return;
32221
- }
32222
- for (var i = 0; i < bucket.length; i += 1) {
32223
- var element = bucket[i];
32224
- if (element[0] === key) {
32225
- return element[1];
32226
- }
32227
- }
32228
- };
32229
- return _ObjectMap2;
32230
- }();
32231
-
32232
- // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/clone.js
32233
- var clone = /* @__PURE__ */ _curry1(function clone2(value) {
32234
- return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
32235
- });
32236
- var clone_default = clone;
32237
-
32238
- // src/providers/coin-quantity.ts
32239
- var coinQuantityfy = (coinQuantityLike) => {
32240
- let assetId;
32241
- let amount;
32242
- let max;
32243
- if (Array.isArray(coinQuantityLike)) {
32244
- amount = coinQuantityLike[0];
32245
- assetId = coinQuantityLike[1];
32246
- max = coinQuantityLike[2] ?? void 0;
32247
- } else {
32248
- amount = coinQuantityLike.amount;
32249
- assetId = coinQuantityLike.assetId;
32250
- max = coinQuantityLike.max ?? void 0;
32251
- }
32252
- const bnAmount = bn(amount);
32253
- return {
32254
- assetId: hexlify(assetId),
32255
- amount: bnAmount.lt(1) ? bn(1) : bnAmount,
32256
- max: max ? bn(max) : void 0
32257
- };
32258
- };
32259
- var addAmountToCoinQuantities = (params) => {
32260
- const { amount, assetId } = params;
32261
- const coinQuantities = [...params.coinQuantities];
32262
- const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
32263
- if (assetIdx !== -1) {
32264
- coinQuantities[assetIdx].amount = coinQuantities[assetIdx].amount.add(amount);
32265
- } else {
32266
- coinQuantities.push({ assetId, amount });
32267
- }
32268
- return coinQuantities;
32269
- };
32270
-
32271
32066
  // ../transactions/dist/index.mjs
32272
32067
  var ByteArrayCoder = class extends Coder {
32273
32068
  length;
@@ -32915,150 +32710,11 @@ If you are attempting to transform a hex value, please make sure it is being pas
32915
32710
  ReceiptType2[ReceiptType2["Burn"] = 12] = "Burn";
32916
32711
  return ReceiptType2;
32917
32712
  })(ReceiptType || {});
32918
- var ReceiptMessageOutCoder = class extends Coder {
32919
- constructor() {
32920
- super("ReceiptMessageOut", "struct ReceiptMessageOut", 0);
32921
- }
32922
- static getMessageId(value) {
32923
- const parts = [];
32924
- parts.push(new ByteArrayCoder(32).encode(value.sender));
32925
- parts.push(new ByteArrayCoder(32).encode(value.recipient));
32926
- parts.push(new ByteArrayCoder(32).encode(value.nonce));
32927
- parts.push(new BigNumberCoder("u64").encode(value.amount));
32928
- parts.push(arrayify(value.data || "0x"));
32929
- return sha2562(concat(parts));
32930
- }
32931
- encode(value) {
32932
- const parts = [];
32933
- parts.push(new B256Coder().encode(value.sender));
32934
- parts.push(new B256Coder().encode(value.recipient));
32935
- parts.push(new BigNumberCoder("u64").encode(value.amount));
32936
- parts.push(new B256Coder().encode(value.nonce));
32937
- parts.push(new NumberCoder("u16", { padToWordSize: true }).encode(value.data.length));
32938
- parts.push(new B256Coder().encode(value.digest));
32939
- parts.push(new ByteArrayCoder(value.data.length).encode(value.data));
32940
- return concat(parts);
32941
- }
32942
- decode(data, offset) {
32943
- let decoded;
32944
- let o = offset;
32945
- [decoded, o] = new B256Coder().decode(data, o);
32946
- const sender = decoded;
32947
- [decoded, o] = new B256Coder().decode(data, o);
32948
- const recipient = decoded;
32949
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
32950
- const amount = decoded;
32951
- [decoded, o] = new B256Coder().decode(data, o);
32952
- const nonce = decoded;
32953
- [decoded, o] = new NumberCoder("u16", { padToWordSize: true }).decode(data, o);
32954
- const len = decoded;
32955
- [decoded, o] = new B256Coder().decode(data, o);
32956
- const digest = decoded;
32957
- [decoded, o] = new ByteArrayCoder(len).decode(data, o);
32958
- const messageData = arrayify(decoded);
32959
- const receiptMessageOut = {
32960
- type: 10,
32961
- messageId: "",
32962
- sender,
32963
- recipient,
32964
- amount,
32965
- nonce,
32966
- digest,
32967
- data: messageData
32968
- };
32969
- receiptMessageOut.messageId = ReceiptMessageOutCoder.getMessageId(receiptMessageOut);
32970
- return [receiptMessageOut, o];
32971
- }
32972
- };
32973
32713
  var getMintedAssetId = (contractId, subId) => {
32974
32714
  const contractIdBytes = arrayify(contractId);
32975
32715
  const subIdBytes = arrayify(subId);
32976
32716
  return sha2562(concat([contractIdBytes, subIdBytes]));
32977
32717
  };
32978
- var ReceiptMintCoder = class extends Coder {
32979
- constructor() {
32980
- super("ReceiptMint", "struct ReceiptMint", 0);
32981
- }
32982
- static getAssetId(contractId, subId) {
32983
- return getMintedAssetId(contractId, subId);
32984
- }
32985
- encode(value) {
32986
- const parts = [];
32987
- parts.push(new B256Coder().encode(value.subId));
32988
- parts.push(new B256Coder().encode(value.contractId));
32989
- parts.push(new BigNumberCoder("u64").encode(value.val));
32990
- parts.push(new BigNumberCoder("u64").encode(value.pc));
32991
- parts.push(new BigNumberCoder("u64").encode(value.is));
32992
- return concat(parts);
32993
- }
32994
- decode(data, offset) {
32995
- let decoded;
32996
- let o = offset;
32997
- [decoded, o] = new B256Coder().decode(data, o);
32998
- const subId = decoded;
32999
- [decoded, o] = new B256Coder().decode(data, o);
33000
- const contractId = decoded;
33001
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33002
- const val = decoded;
33003
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33004
- const pc = decoded;
33005
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33006
- const is = decoded;
33007
- const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
33008
- const receiptMint = {
33009
- type: 11,
33010
- subId,
33011
- contractId,
33012
- val,
33013
- pc,
33014
- is,
33015
- assetId
33016
- };
33017
- return [receiptMint, o];
33018
- }
33019
- };
33020
- var ReceiptBurnCoder = class extends Coder {
33021
- constructor() {
33022
- super("ReceiptBurn", "struct ReceiptBurn", 0);
33023
- }
33024
- static getAssetId(contractId, subId) {
33025
- return getMintedAssetId(contractId, subId);
33026
- }
33027
- encode(value) {
33028
- const parts = [];
33029
- parts.push(new B256Coder().encode(value.subId));
33030
- parts.push(new B256Coder().encode(value.contractId));
33031
- parts.push(new BigNumberCoder("u64").encode(value.val));
33032
- parts.push(new BigNumberCoder("u64").encode(value.pc));
33033
- parts.push(new BigNumberCoder("u64").encode(value.is));
33034
- return concat(parts);
33035
- }
33036
- decode(data, offset) {
33037
- let decoded;
33038
- let o = offset;
33039
- [decoded, o] = new B256Coder().decode(data, o);
33040
- const subId = decoded;
33041
- [decoded, o] = new B256Coder().decode(data, o);
33042
- const contractId = decoded;
33043
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33044
- const val = decoded;
33045
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33046
- const pc = decoded;
33047
- [decoded, o] = new BigNumberCoder("u64").decode(data, o);
33048
- const is = decoded;
33049
- const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
33050
- const receiptBurn = {
33051
- type: 12,
33052
- subId,
33053
- contractId,
33054
- val,
33055
- pc,
33056
- is,
33057
- assetId
33058
- };
33059
- return [receiptBurn, o];
33060
- }
33061
- };
33062
32718
  var StorageSlotCoder = class extends StructCoder {
33063
32719
  constructor() {
33064
32720
  super("StorageSlot", {
@@ -33634,6 +33290,169 @@ If you are attempting to transform a hex value, please make sure it is being pas
33634
33290
  }
33635
33291
  };
33636
33292
 
33293
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_isPlaceholder.js
33294
+ function _isPlaceholder(a) {
33295
+ return a != null && typeof a === "object" && a["@@functional/placeholder"] === true;
33296
+ }
33297
+
33298
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_curry1.js
33299
+ function _curry1(fn) {
33300
+ return function f1(a) {
33301
+ if (arguments.length === 0 || _isPlaceholder(a)) {
33302
+ return f1;
33303
+ } else {
33304
+ return fn.apply(this, arguments);
33305
+ }
33306
+ };
33307
+ }
33308
+
33309
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/type.js
33310
+ var type = /* @__PURE__ */ _curry1(function type2(val) {
33311
+ return val === null ? "Null" : val === void 0 ? "Undefined" : Object.prototype.toString.call(val).slice(8, -1);
33312
+ });
33313
+ var type_default = type;
33314
+
33315
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_cloneRegExp.js
33316
+ function _cloneRegExp(pattern) {
33317
+ return new RegExp(pattern.source, pattern.flags ? pattern.flags : (pattern.global ? "g" : "") + (pattern.ignoreCase ? "i" : "") + (pattern.multiline ? "m" : "") + (pattern.sticky ? "y" : "") + (pattern.unicode ? "u" : "") + (pattern.dotAll ? "s" : ""));
33318
+ }
33319
+
33320
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/internal/_clone.js
33321
+ function _clone(value, deep, map) {
33322
+ map || (map = new _ObjectMap());
33323
+ if (_isPrimitive(value)) {
33324
+ return value;
33325
+ }
33326
+ var copy = function copy2(copiedValue) {
33327
+ var cachedCopy = map.get(value);
33328
+ if (cachedCopy) {
33329
+ return cachedCopy;
33330
+ }
33331
+ map.set(value, copiedValue);
33332
+ for (var key in value) {
33333
+ if (Object.prototype.hasOwnProperty.call(value, key)) {
33334
+ copiedValue[key] = deep ? _clone(value[key], true, map) : value[key];
33335
+ }
33336
+ }
33337
+ return copiedValue;
33338
+ };
33339
+ switch (type_default(value)) {
33340
+ case "Object":
33341
+ return copy(Object.create(Object.getPrototypeOf(value)));
33342
+ case "Array":
33343
+ return copy(Array(value.length));
33344
+ case "Date":
33345
+ return new Date(value.valueOf());
33346
+ case "RegExp":
33347
+ return _cloneRegExp(value);
33348
+ case "Int8Array":
33349
+ case "Uint8Array":
33350
+ case "Uint8ClampedArray":
33351
+ case "Int16Array":
33352
+ case "Uint16Array":
33353
+ case "Int32Array":
33354
+ case "Uint32Array":
33355
+ case "Float32Array":
33356
+ case "Float64Array":
33357
+ case "BigInt64Array":
33358
+ case "BigUint64Array":
33359
+ return value.slice();
33360
+ default:
33361
+ return value;
33362
+ }
33363
+ }
33364
+ function _isPrimitive(param) {
33365
+ var type3 = typeof param;
33366
+ return param == null || type3 != "object" && type3 != "function";
33367
+ }
33368
+ var _ObjectMap = /* @__PURE__ */ function() {
33369
+ function _ObjectMap2() {
33370
+ this.map = {};
33371
+ this.length = 0;
33372
+ }
33373
+ _ObjectMap2.prototype.set = function(key, value) {
33374
+ var hashedKey = this.hash(key);
33375
+ var bucket = this.map[hashedKey];
33376
+ if (!bucket) {
33377
+ this.map[hashedKey] = bucket = [];
33378
+ }
33379
+ bucket.push([key, value]);
33380
+ this.length += 1;
33381
+ };
33382
+ _ObjectMap2.prototype.hash = function(key) {
33383
+ var hashedKey = [];
33384
+ for (var value in key) {
33385
+ hashedKey.push(Object.prototype.toString.call(key[value]));
33386
+ }
33387
+ return hashedKey.join();
33388
+ };
33389
+ _ObjectMap2.prototype.get = function(key) {
33390
+ if (this.length <= 180) {
33391
+ for (var p in this.map) {
33392
+ var bucket = this.map[p];
33393
+ for (var i = 0; i < bucket.length; i += 1) {
33394
+ var element = bucket[i];
33395
+ if (element[0] === key) {
33396
+ return element[1];
33397
+ }
33398
+ }
33399
+ }
33400
+ return;
33401
+ }
33402
+ var hashedKey = this.hash(key);
33403
+ var bucket = this.map[hashedKey];
33404
+ if (!bucket) {
33405
+ return;
33406
+ }
33407
+ for (var i = 0; i < bucket.length; i += 1) {
33408
+ var element = bucket[i];
33409
+ if (element[0] === key) {
33410
+ return element[1];
33411
+ }
33412
+ }
33413
+ };
33414
+ return _ObjectMap2;
33415
+ }();
33416
+
33417
+ // ../../node_modules/.pnpm/ramda@0.30.1/node_modules/ramda/es/clone.js
33418
+ var clone = /* @__PURE__ */ _curry1(function clone2(value) {
33419
+ return value != null && typeof value.clone === "function" ? value.clone() : _clone(value, true);
33420
+ });
33421
+ var clone_default = clone;
33422
+
33423
+ // src/providers/coin-quantity.ts
33424
+ var coinQuantityfy = (coinQuantityLike) => {
33425
+ let assetId;
33426
+ let amount;
33427
+ let max;
33428
+ if (Array.isArray(coinQuantityLike)) {
33429
+ amount = coinQuantityLike[0];
33430
+ assetId = coinQuantityLike[1];
33431
+ max = coinQuantityLike[2] ?? void 0;
33432
+ } else {
33433
+ amount = coinQuantityLike.amount;
33434
+ assetId = coinQuantityLike.assetId;
33435
+ max = coinQuantityLike.max ?? void 0;
33436
+ }
33437
+ const bnAmount = bn(amount);
33438
+ return {
33439
+ assetId: hexlify(assetId),
33440
+ amount: bnAmount.lt(1) ? bn(1) : bnAmount,
33441
+ max: max ? bn(max) : void 0
33442
+ };
33443
+ };
33444
+ var addAmountToCoinQuantities = (params) => {
33445
+ const { amount, assetId } = params;
33446
+ const coinQuantities = [...params.coinQuantities];
33447
+ const assetIdx = coinQuantities.findIndex((coinQuantity) => coinQuantity.assetId === assetId);
33448
+ if (assetIdx !== -1) {
33449
+ coinQuantities[assetIdx].amount = coinQuantities[assetIdx].amount.add(amount);
33450
+ } else {
33451
+ coinQuantities.push({ assetId, amount });
33452
+ }
33453
+ return coinQuantities;
33454
+ };
33455
+
33637
33456
  // ../../node_modules/.pnpm/@noble+curves@1.4.2/node_modules/@noble/curves/esm/abstract/utils.js
33638
33457
  var utils_exports = {};
33639
33458
  __export(utils_exports, {
@@ -37369,6 +37188,14 @@ ${ReceiptFragmentDoc}`;
37369
37188
  height
37370
37189
  header {
37371
37190
  time
37191
+ daHeight
37192
+ stateTransitionBytecodeVersion
37193
+ transactionsCount
37194
+ transactionsRoot
37195
+ messageOutboxRoot
37196
+ eventInboxRoot
37197
+ prevRoot
37198
+ applicationHash
37372
37199
  }
37373
37200
  transactions {
37374
37201
  id
@@ -37974,6 +37801,13 @@ ${MessageFragmentDoc}`;
37974
37801
  submitAndAwait(tx: $encodedTransaction) {
37975
37802
  ...transactionStatusSubscriptionFragment
37976
37803
  }
37804
+ }
37805
+ ${TransactionStatusSubscriptionFragmentDoc}`;
37806
+ var SubmitAndAwaitStatusDocument = lib_default2`
37807
+ subscription submitAndAwaitStatus($encodedTransaction: HexString!) {
37808
+ submitAndAwaitStatus(tx: $encodedTransaction) {
37809
+ ...transactionStatusSubscriptionFragment
37810
+ }
37977
37811
  }
37978
37812
  ${TransactionStatusSubscriptionFragmentDoc}`;
37979
37813
  var StatusChangeDocument = lib_default2`
@@ -38072,6 +37906,9 @@ ${MessageFragmentDoc}`;
38072
37906
  submitAndAwait(variables, options) {
38073
37907
  return requester(SubmitAndAwaitDocument, variables, options);
38074
37908
  },
37909
+ submitAndAwaitStatus(variables, options) {
37910
+ return requester(SubmitAndAwaitStatusDocument, variables, options);
37911
+ },
38075
37912
  statusChange(variables, options) {
38076
37913
  return requester(StatusChangeDocument, variables, options);
38077
37914
  }
@@ -38096,7 +37933,9 @@ ${MessageFragmentDoc}`;
38096
37933
  Accept: "text/event-stream"
38097
37934
  }
38098
37935
  });
38099
- return new _FuelGraphqlSubscriber(response.body.getReader());
37936
+ const [errorReader, resultReader] = response.body.tee().map((stream) => stream.getReader());
37937
+ await new _FuelGraphqlSubscriber(errorReader).next();
37938
+ return new _FuelGraphqlSubscriber(resultReader);
38100
37939
  }
38101
37940
  events = [];
38102
37941
  parsingLeftover = "";
@@ -38139,10 +37978,8 @@ ${MessageFragmentDoc}`;
38139
37978
  /**
38140
37979
  * Gets called when `break` is called in a `for-await-of` loop.
38141
37980
  */
38142
- async return() {
38143
- await this.stream.cancel();
38144
- this.stream.releaseLock();
38145
- return { done: true, value: void 0 };
37981
+ return() {
37982
+ return Promise.resolve({ done: true, value: void 0 });
38146
37983
  }
38147
37984
  [Symbol.asyncIterator]() {
38148
37985
  return this;
@@ -38335,6 +38172,9 @@ ${MessageFragmentDoc}`;
38335
38172
  }
38336
38173
  };
38337
38174
 
38175
+ // src/providers/message.ts
38176
+ var isMessageCoin = (message) => !("data" in message);
38177
+
38338
38178
  // src/providers/resource.ts
38339
38179
  var isRawCoin = (resource) => "utxoId" in resource;
38340
38180
  var isRawMessage = (resource) => "recipient" in resource;
@@ -38559,12 +38399,12 @@ ${MessageFragmentDoc}`;
38559
38399
  const amount = bn(receipt.amount);
38560
38400
  const data = receipt.data ? arrayify(receipt.data) : Uint8Array.from([]);
38561
38401
  const digest = hexOrZero(receipt.digest);
38562
- const messageId = ReceiptMessageOutCoder.getMessageId({
38402
+ const messageId = InputMessageCoder.getMessageId({
38563
38403
  sender,
38564
38404
  recipient,
38565
38405
  nonce,
38566
38406
  amount,
38567
- data
38407
+ data: hexlify(data)
38568
38408
  });
38569
38409
  const receiptMessageOut = {
38570
38410
  type: ReceiptType.MessageOut,
@@ -38581,7 +38421,7 @@ ${MessageFragmentDoc}`;
38581
38421
  case "MINT" /* Mint */: {
38582
38422
  const contractId = hexOrZero(receipt.id || receipt.contractId);
38583
38423
  const subId = hexOrZero(receipt.subId);
38584
- const assetId = ReceiptMintCoder.getAssetId(contractId, subId);
38424
+ const assetId = getMintedAssetId(contractId, subId);
38585
38425
  const mintReceipt = {
38586
38426
  type: ReceiptType.Mint,
38587
38427
  subId,
@@ -38596,7 +38436,7 @@ ${MessageFragmentDoc}`;
38596
38436
  case "BURN" /* Burn */: {
38597
38437
  const contractId = hexOrZero(receipt.id || receipt.contractId);
38598
38438
  const subId = hexOrZero(receipt.subId);
38599
- const assetId = ReceiptBurnCoder.getAssetId(contractId, subId);
38439
+ const assetId = getMintedAssetId(contractId, subId);
38600
38440
  const burnReceipt = {
38601
38441
  type: ReceiptType.Burn,
38602
38442
  subId,
@@ -38827,20 +38667,22 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
38827
38667
  let reason = "";
38828
38668
  if (revertReceipt) {
38829
38669
  const reasonHex = bn(revertReceipt.val).toHex();
38670
+ const lastLog = logs[logs.length - 1];
38671
+ const lastButOneLog = logs[logs.length - 2];
38830
38672
  switch (reasonHex) {
38831
38673
  case FAILED_REQUIRE_SIGNAL: {
38832
38674
  reason = "require";
38833
- errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(logs[0]) : "an error."}.`;
38675
+ errorMessage = `The transaction reverted because a "require" statement has thrown ${logs.length ? stringify(lastLog) : "an error."}.`;
38834
38676
  break;
38835
38677
  }
38836
38678
  case FAILED_ASSERT_EQ_SIGNAL: {
38837
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
38679
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastLog)} and ${stringify(lastButOneLog)}.` : ".";
38838
38680
  reason = "assert_eq";
38839
38681
  errorMessage = `The transaction reverted because of an "assert_eq" statement${sufix}`;
38840
38682
  break;
38841
38683
  }
38842
38684
  case FAILED_ASSERT_NE_SIGNAL: {
38843
- const sufix = logs.length >= 2 ? ` comparing ${stringify(logs[1])} and ${stringify(logs[0])}.` : ".";
38685
+ const sufix = logs.length >= 2 ? ` comparing ${stringify(lastButOneLog)} and ${stringify(lastLog)}.` : ".";
38844
38686
  reason = "assert_ne";
38845
38687
  errorMessage = `The transaction reverted because of an "assert_ne" statement${sufix}`;
38846
38688
  break;
@@ -38911,7 +38753,9 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
38911
38753
  // src/providers/transaction-request/helpers.ts
38912
38754
  var isRequestInputCoin = (input) => input.type === InputType.Coin;
38913
38755
  var isRequestInputMessage = (input) => input.type === InputType.Message;
38914
- var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
38756
+ var isRequestInputMessageWithoutData = (input) => input.type === InputType.Message && bn(input.data).isZero();
38757
+ var isRequestInputCoinOrMessage = (input) => isRequestInputCoin(input) || isRequestInputMessage(input);
38758
+ var isRequestInputResource = (input) => isRequestInputCoin(input) || isRequestInputMessageWithoutData(input);
38915
38759
  var getRequestInputResourceOwner = (input) => isRequestInputCoin(input) ? input.owner : input.recipient;
38916
38760
  var isRequestInputResourceFromOwner = (input, owner) => getRequestInputResourceOwner(input) === owner.toB256();
38917
38761
  var getAssetAmountInRequestInputs = (inputs, assetId, baseAsset) => inputs.filter(isRequestInputResource).reduce((acc, input) => {
@@ -39220,7 +39064,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39220
39064
  * @param message - Message resource.
39221
39065
  */
39222
39066
  addMessageInput(message) {
39223
- const { recipient, sender, amount, predicate, nonce, assetId, predicateData } = message;
39067
+ const { recipient, sender, amount, predicate, nonce, predicateData } = message;
39224
39068
  let witnessIndex;
39225
39069
  if (message.predicate) {
39226
39070
  witnessIndex = 0;
@@ -39235,13 +39079,16 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39235
39079
  type: InputType.Message,
39236
39080
  sender: sender.toB256(),
39237
39081
  recipient: recipient.toB256(),
39082
+ data: isMessageCoin(message) ? "0x" : message.data,
39238
39083
  amount,
39239
39084
  witnessIndex,
39240
39085
  predicate,
39241
39086
  predicateData
39242
39087
  };
39243
39088
  this.pushInput(input);
39244
- this.addChangeOutput(recipient, assetId);
39089
+ if (isMessageCoin(message)) {
39090
+ this.addChangeOutput(recipient, message.assetId);
39091
+ }
39245
39092
  }
39246
39093
  /**
39247
39094
  * Adds a single resource to the transaction by adding a coin/message input and a
@@ -39373,6 +39220,8 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39373
39220
  *
39374
39221
  * @param quantities - CoinQuantity Array.
39375
39222
  * @param baseAssetId - The base asset to fund the transaction.
39223
+ * @deprecated - This method is deprecated and will be removed in future versions.
39224
+ * Please use `Account.generateFakeResources` along with `this.addResources` instead.
39376
39225
  */
39377
39226
  fundWithFakeUtxos(quantities, baseAssetId, resourcesOwner) {
39378
39227
  const findAssetInput = (assetId) => this.inputs.find((input) => {
@@ -39441,7 +39290,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39441
39290
  });
39442
39291
  }
39443
39292
  updatePredicateGasUsed(inputs) {
39444
- const inputsToExtractGasUsed = inputs.filter(isRequestInputResource);
39293
+ const inputsToExtractGasUsed = inputs.filter(isRequestInputCoinOrMessage);
39445
39294
  this.inputs.filter(isRequestInputResource).forEach((i) => {
39446
39295
  const owner = getRequestInputResourceOwner(i);
39447
39296
  const correspondingInput = inputsToExtractGasUsed.find(
@@ -39525,10 +39374,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39525
39374
  // src/providers/transaction-request/blob-transaction-request.ts
39526
39375
  var BlobTransactionRequest = class extends BaseTransactionRequest {
39527
39376
  static from(obj) {
39528
- if (obj instanceof this) {
39529
- return obj;
39530
- }
39531
- return new this(obj);
39377
+ return new this(clone_default(obj));
39532
39378
  }
39533
39379
  /** Type of the transaction */
39534
39380
  type = TransactionType.Blob;
@@ -39611,10 +39457,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39611
39457
  // src/providers/transaction-request/create-transaction-request.ts
39612
39458
  var CreateTransactionRequest = class extends BaseTransactionRequest {
39613
39459
  static from(obj) {
39614
- if (obj instanceof this) {
39615
- return obj;
39616
- }
39617
- return new this(obj);
39460
+ return new this(clone_default(obj));
39618
39461
  }
39619
39462
  /** Type of the transaction */
39620
39463
  type = TransactionType.Create;
@@ -39724,10 +39567,7 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
39724
39567
  // src/providers/transaction-request/script-transaction-request.ts
39725
39568
  var ScriptTransactionRequest = class extends BaseTransactionRequest {
39726
39569
  static from(obj) {
39727
- if (obj instanceof this) {
39728
- return obj;
39729
- }
39730
- return new this(obj);
39570
+ return new this(clone_default(obj));
39731
39571
  }
39732
39572
  /** Type of the transaction */
39733
39573
  type = TransactionType.Script;
@@ -40782,29 +40622,30 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
40782
40622
  });
40783
40623
  }
40784
40624
  var TransactionResponse = class {
40785
- /** Transaction ID */
40786
- id;
40787
- /** Current provider */
40788
- provider;
40789
- /** Gas used on the transaction */
40790
- gasUsed = bn(0);
40791
- /** The graphql Transaction with receipts object. */
40792
- gqlTransaction;
40793
- request;
40794
- status;
40795
- abis;
40796
40625
  /**
40797
40626
  * Constructor for `TransactionResponse`.
40798
40627
  *
40799
40628
  * @param tx - The transaction ID or TransactionRequest.
40800
40629
  * @param provider - The provider.
40801
40630
  */
40802
- constructor(tx, provider, abis) {
40631
+ constructor(tx, provider, abis, submitTxSubscription) {
40632
+ this.submitTxSubscription = submitTxSubscription;
40803
40633
  this.id = typeof tx === "string" ? tx : tx.getTransactionId(provider.getChainId());
40804
40634
  this.provider = provider;
40805
40635
  this.abis = abis;
40806
40636
  this.request = typeof tx === "string" ? void 0 : tx;
40807
40637
  }
40638
+ /** Transaction ID */
40639
+ id;
40640
+ /** Current provider */
40641
+ provider;
40642
+ /** Gas used on the transaction */
40643
+ gasUsed = bn(0);
40644
+ /** The graphql Transaction with receipts object. */
40645
+ gqlTransaction;
40646
+ request;
40647
+ status;
40648
+ abis;
40808
40649
  /**
40809
40650
  * Async constructor for `TransactionResponse`. This method can be used to create
40810
40651
  * an instance of `TransactionResponse` and wait for the transaction to be fetched
@@ -40937,10 +40778,11 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
40937
40778
  if (status && status !== "SubmittedStatus") {
40938
40779
  return;
40939
40780
  }
40940
- const subscription = await this.provider.operations.statusChange({
40781
+ const subscription = this.submitTxSubscription ?? await this.provider.operations.statusChange({
40941
40782
  transactionId: this.id
40942
40783
  });
40943
- for await (const { statusChange } of subscription) {
40784
+ for await (const sub of subscription) {
40785
+ const statusChange = "statusChange" in sub ? sub.statusChange : sub.submitAndAwaitStatus;
40944
40786
  this.status = statusChange;
40945
40787
  if (statusChange.type === "SqueezedOutStatus") {
40946
40788
  this.unsetResourceCache();
@@ -41051,6 +40893,21 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41051
40893
  };
41052
40894
  }
41053
40895
 
40896
+ // src/providers/utils/handle-gql-error-message.ts
40897
+ var handleGqlErrorMessage = (errorMessage, rawError) => {
40898
+ switch (errorMessage) {
40899
+ case "not enough coins to fit the target" /* NOT_ENOUGH_COINS */:
40900
+ throw new FuelError(
40901
+ ErrorCode.NOT_ENOUGH_FUNDS,
40902
+ `The account(s) sending the transaction don't have enough funds to cover the transaction.`,
40903
+ {},
40904
+ rawError
40905
+ );
40906
+ default:
40907
+ throw new FuelError(ErrorCode.INVALID_REQUEST, errorMessage);
40908
+ }
40909
+ };
40910
+
41054
40911
  // src/providers/provider.ts
41055
40912
  var MAX_RETRIES = 10;
41056
40913
  var RESOURCES_PAGE_SIZE_LIMIT = 512;
@@ -41177,6 +41034,17 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41177
41034
  return options.fetch ? options.fetch(url, fullRequest, options) : fetch(url, fullRequest);
41178
41035
  }, retryOptions);
41179
41036
  }
41037
+ static extractBasicAuth(url) {
41038
+ const parsedUrl = new URL(url);
41039
+ const username = parsedUrl.username;
41040
+ const password = parsedUrl.password;
41041
+ const urlNoBasicAuth = `${parsedUrl.origin}${parsedUrl.pathname}`;
41042
+ if (!(username && password)) {
41043
+ return { url, auth: void 0 };
41044
+ }
41045
+ const auth = `Basic ${btoa(`${username}:${password}`)}`;
41046
+ return { url: urlNoBasicAuth, auth };
41047
+ }
41180
41048
  /**
41181
41049
  * Creates a new instance of the Provider class. This is the recommended way to initialize a Provider.
41182
41050
  *
@@ -41186,7 +41054,17 @@ ${PANIC_DOC_URL}#variant.${statusReason}`;
41186
41054
  * @returns A promise that resolves to a Provider instance.
41187
41055
  */
41188
41056
  static async create(url, options = {}) {
41189
- const provider = new _Provider(url, options);
41057
+ const { url: urlToUse, auth } = this.extractBasicAuth(url);
41058
+ const provider = new _Provider(urlToUse, {
41059
+ ...options,
41060
+ requestMiddleware: async (request) => {
41061
+ if (auth && request) {
41062
+ request.headers ??= {};
41063
+ request.headers.Authorization = auth;
41064
+ }
41065
+ return options.requestMiddleware?.(request) ?? request;
41066
+ }
41067
+ });
41190
41068
  await provider.fetchChainAndNodeInfo();
41191
41069
  return provider;
41192
41070
  }
@@ -41292,10 +41170,9 @@ Supported fuel-core version: ${supportedVersion}.`
41292
41170
  if ("response" in response) {
41293
41171
  const graphQlResponse = response.response;
41294
41172
  if (Array.isArray(graphQlResponse?.errors)) {
41295
- throw new FuelError(
41296
- FuelError.CODES.INVALID_REQUEST,
41297
- graphQlResponse.errors.map((err) => err.message).join("\n\n")
41298
- );
41173
+ for (const error of graphQlResponse.errors) {
41174
+ handleGqlErrorMessage(error.message, error);
41175
+ }
41299
41176
  }
41300
41177
  }
41301
41178
  }
@@ -41313,7 +41190,26 @@ Supported fuel-core version: ${supportedVersion}.`
41313
41190
  }
41314
41191
  return gqlClient.request(query, vars);
41315
41192
  };
41316
- return getSdk(executeQuery);
41193
+ const customOperations = (requester) => ({
41194
+ getBlobs(variables) {
41195
+ const queryParams = variables.blobIds.map((_, i) => `$blobId${i}: BlobId!`).join(", ");
41196
+ const blobParams = variables.blobIds.map((_, i) => `blob${i}: blob(id: $blobId${i}) { id }`).join("\n");
41197
+ const updatedVariables = variables.blobIds.reduce(
41198
+ (acc, blobId, i) => {
41199
+ acc[`blobId${i}`] = blobId;
41200
+ return acc;
41201
+ },
41202
+ {}
41203
+ );
41204
+ const document2 = lib_default2`
41205
+ query getBlobs(${queryParams}) {
41206
+ ${blobParams}
41207
+ }
41208
+ `;
41209
+ return requester(document2, updatedVariables);
41210
+ }
41211
+ });
41212
+ return { ...getSdk(executeQuery), ...customOperations(executeQuery) };
41317
41213
  }
41318
41214
  /**
41319
41215
  * Returns the version of the connected node.
@@ -41422,11 +41318,9 @@ Supported fuel-core version: ${supportedVersion}.`
41422
41318
  if (isTransactionTypeScript(transactionRequest)) {
41423
41319
  abis = transactionRequest.abis;
41424
41320
  }
41425
- const {
41426
- submit: { id: transactionId }
41427
- } = await this.operations.submit({ encodedTransaction });
41428
- __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionId);
41429
- return new TransactionResponse(transactionRequest, this, abis);
41321
+ const subscription = await this.operations.submitAndAwaitStatus({ encodedTransaction });
41322
+ __privateMethod(this, _cacheInputs, cacheInputs_fn).call(this, transactionRequest.inputs, transactionRequest.getTransactionId(this.getChainId()));
41323
+ return new TransactionResponse(transactionRequest, this, abis, subscription);
41430
41324
  }
41431
41325
  /**
41432
41326
  * Executes a transaction without actually submitting it to the chain.
@@ -41860,6 +41754,21 @@ Supported fuel-core version: ${supportedVersion}.`
41860
41754
  }).filter((v) => !!v);
41861
41755
  return coins;
41862
41756
  }
41757
+ /**
41758
+ * Returns an array of blobIds that exist on chain, for a given array of blobIds.
41759
+ *
41760
+ * @param blobIds - blobIds to check.
41761
+ * @returns - A promise that resolves to an array of blobIds that exist on chain.
41762
+ */
41763
+ async getBlobs(blobIds) {
41764
+ const res = await this.operations.getBlobs({ blobIds });
41765
+ const blobs = [];
41766
+ Object.keys(res).forEach((key) => {
41767
+ const val = res[key];
41768
+ blobs.push(val?.id ?? null);
41769
+ });
41770
+ return blobs.filter((v) => v);
41771
+ }
41863
41772
  /**
41864
41773
  * Returns block matching the given ID or height.
41865
41774
  *
@@ -41881,11 +41790,22 @@ Supported fuel-core version: ${supportedVersion}.`
41881
41790
  if (!block2) {
41882
41791
  return null;
41883
41792
  }
41793
+ const { header, height, id, transactions } = block2;
41884
41794
  return {
41885
- id: block2.id,
41886
- height: bn(block2.height),
41887
- time: block2.header.time,
41888
- transactionIds: block2.transactions.map((tx) => tx.id)
41795
+ id,
41796
+ height: bn(height),
41797
+ time: header.time,
41798
+ header: {
41799
+ applicationHash: header.applicationHash,
41800
+ daHeight: bn(header.daHeight),
41801
+ eventInboxRoot: header.eventInboxRoot,
41802
+ messageOutboxRoot: header.messageOutboxRoot,
41803
+ prevRoot: header.prevRoot,
41804
+ stateTransitionBytecodeVersion: header.stateTransitionBytecodeVersion,
41805
+ transactionsCount: header.transactionsCount,
41806
+ transactionsRoot: header.transactionsRoot
41807
+ },
41808
+ transactionIds: transactions.map((tx) => tx.id)
41889
41809
  };
41890
41810
  }
41891
41811
  /**
@@ -41907,6 +41827,16 @@ Supported fuel-core version: ${supportedVersion}.`
41907
41827
  id: block2.id,
41908
41828
  height: bn(block2.height),
41909
41829
  time: block2.header.time,
41830
+ header: {
41831
+ applicationHash: block2.header.applicationHash,
41832
+ daHeight: bn(block2.header.daHeight),
41833
+ eventInboxRoot: block2.header.eventInboxRoot,
41834
+ messageOutboxRoot: block2.header.messageOutboxRoot,
41835
+ prevRoot: block2.header.prevRoot,
41836
+ stateTransitionBytecodeVersion: block2.header.stateTransitionBytecodeVersion,
41837
+ transactionsCount: block2.header.transactionsCount,
41838
+ transactionsRoot: block2.header.transactionsRoot
41839
+ },
41910
41840
  transactionIds: block2.transactions.map((tx) => tx.id)
41911
41841
  }));
41912
41842
  return { blocks, pageInfo };
@@ -41934,6 +41864,16 @@ Supported fuel-core version: ${supportedVersion}.`
41934
41864
  id: block2.id,
41935
41865
  height: bn(block2.height, 10),
41936
41866
  time: block2.header.time,
41867
+ header: {
41868
+ applicationHash: block2.header.applicationHash,
41869
+ daHeight: bn(block2.header.daHeight),
41870
+ eventInboxRoot: block2.header.eventInboxRoot,
41871
+ messageOutboxRoot: block2.header.messageOutboxRoot,
41872
+ prevRoot: block2.header.prevRoot,
41873
+ stateTransitionBytecodeVersion: block2.header.stateTransitionBytecodeVersion,
41874
+ transactionsCount: block2.header.transactionsCount,
41875
+ transactionsRoot: block2.header.transactionsRoot
41876
+ },
41937
41877
  transactionIds: block2.transactions.map((tx) => tx.id),
41938
41878
  transactions: block2.transactions.map(
41939
41879
  (tx) => new TransactionCoder().decode(arrayify(tx.rawPayload), 0)?.[0]
@@ -42245,10 +42185,25 @@ Supported fuel-core version: ${supportedVersion}.`
42245
42185
  * @returns A promise that resolves to the Message object or null.
42246
42186
  */
42247
42187
  async getMessageByNonce(nonce) {
42248
- const { message } = await this.operations.getMessageByNonce({ nonce });
42249
- if (!message) {
42188
+ const { message: rawMessage } = await this.operations.getMessageByNonce({ nonce });
42189
+ if (!rawMessage) {
42250
42190
  return null;
42251
42191
  }
42192
+ const message = {
42193
+ messageId: InputMessageCoder.getMessageId({
42194
+ sender: rawMessage.sender,
42195
+ recipient: rawMessage.recipient,
42196
+ nonce: rawMessage.nonce,
42197
+ amount: bn(rawMessage.amount),
42198
+ data: rawMessage.data
42199
+ }),
42200
+ sender: Address.fromAddressOrString(rawMessage.sender),
42201
+ recipient: Address.fromAddressOrString(rawMessage.recipient),
42202
+ nonce: rawMessage.nonce,
42203
+ amount: bn(rawMessage.amount),
42204
+ data: InputMessageCoder.decodeData(rawMessage.data),
42205
+ daHeight: bn(rawMessage.daHeight)
42206
+ };
42252
42207
  return message;
42253
42208
  }
42254
42209
  /**
@@ -42809,7 +42764,7 @@ Supported fuel-core version: ${supportedVersion}.`
42809
42764
  gasPrice
42810
42765
  });
42811
42766
  const totalBaseAssetOnInputs = getAssetAmountInRequestInputs(
42812
- request.inputs,
42767
+ request.inputs.filter(isRequestInputResource),
42813
42768
  baseAssetId,
42814
42769
  baseAssetId
42815
42770
  );
@@ -43015,10 +42970,10 @@ Supported fuel-core version: ${supportedVersion}.`
43015
42970
  const requiredQuantities = mergeQuantities(coinOutputsQuantities, quantities);
43016
42971
  const transactionFeeForDryRun = [{ assetId: baseAssetId, amount: bn("100000000000000000") }];
43017
42972
  const findAssetInput = (assetId) => txRequestClone.inputs.find((input) => {
43018
- if ("assetId" in input) {
42973
+ if (input.type === InputType.Coin) {
43019
42974
  return input.assetId === assetId;
43020
42975
  }
43021
- if ("recipient" in input) {
42976
+ if (isRequestInputMessageWithoutData(input)) {
43022
42977
  return baseAssetId === assetId;
43023
42978
  }
43024
42979
  return false;
@@ -48377,7 +48332,7 @@ Supported fuel-core version: ${supportedVersion}.`
48377
48332
  if (placeholderIndex !== -1) {
48378
48333
  request.removeWitness(placeholderIndex);
48379
48334
  }
48380
- request.inputs.filter(isRequestInputResource).forEach((input) => {
48335
+ request.inputs.filter(isRequestInputCoinOrMessage).forEach((input) => {
48381
48336
  if (isRequestInputResourceFromOwner(input, this.address)) {
48382
48337
  input.predicate = hexlify(this.bytes);
48383
48338
  input.predicateData = hexlify(this.getPredicateData());