@fuel-ts/account 0.0.0-pr-1699-20240210143234 → 0.0.0-pr-1699-20240214162234

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.

Files changed (34) hide show
  1. package/dist/account.d.ts +1 -0
  2. package/dist/account.d.ts.map +1 -1
  3. package/dist/connectors/fuel.d.ts +9 -4
  4. package/dist/connectors/fuel.d.ts.map +1 -1
  5. package/dist/connectors/index.d.ts +0 -4
  6. package/dist/connectors/index.d.ts.map +1 -1
  7. package/dist/connectors/types/index.d.ts +1 -1
  8. package/dist/connectors/types/index.d.ts.map +1 -1
  9. package/dist/connectors/types/local-storage.d.ts +11 -0
  10. package/dist/connectors/types/local-storage.d.ts.map +1 -0
  11. package/dist/index.global.js +73 -1271
  12. package/dist/index.global.js.map +1 -1
  13. package/dist/index.js +74 -302
  14. package/dist/index.js.map +1 -1
  15. package/dist/index.mjs +73 -298
  16. package/dist/index.mjs.map +1 -1
  17. package/dist/providers/provider.d.ts.map +1 -1
  18. package/dist/test-utils.global.js +44 -25
  19. package/dist/test-utils.global.js.map +1 -1
  20. package/dist/test-utils.js +43 -24
  21. package/dist/test-utils.js.map +1 -1
  22. package/dist/test-utils.mjs +43 -24
  23. package/dist/test-utils.mjs.map +1 -1
  24. package/package.json +16 -16
  25. package/dist/connectors/default-connector.d.ts +0 -7
  26. package/dist/connectors/default-connector.d.ts.map +0 -1
  27. package/dist/connectors/fuel-wallet-connector.d.ts +0 -54
  28. package/dist/connectors/fuel-wallet-connector.d.ts.map +0 -1
  29. package/dist/connectors/fuel-wallet-development-connector.d.ts +0 -7
  30. package/dist/connectors/fuel-wallet-development-connector.d.ts.map +0 -1
  31. package/dist/connectors/fuelet-wallet-connector.d.ts +0 -8
  32. package/dist/connectors/fuelet-wallet-connector.d.ts.map +0 -1
  33. package/dist/connectors/types/fuel-storage.d.ts +0 -11
  34. package/dist/connectors/types/fuel-storage.d.ts.map +0 -1
@@ -29189,983 +29189,6 @@ spurious results.`);
29189
29189
  }
29190
29190
  });
29191
29191
 
29192
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/models.js
29193
- var require_models = __commonJS({
29194
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/models.js"(exports) {
29195
- "use strict";
29196
- var __extends = exports && exports.__extends || function() {
29197
- var extendStatics = function(d, b) {
29198
- extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
29199
- d2.__proto__ = b2;
29200
- } || function(d2, b2) {
29201
- for (var p in b2)
29202
- if (Object.prototype.hasOwnProperty.call(b2, p))
29203
- d2[p] = b2[p];
29204
- };
29205
- return extendStatics(d, b);
29206
- };
29207
- return function(d, b) {
29208
- if (typeof b !== "function" && b !== null)
29209
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
29210
- extendStatics(d, b);
29211
- function __() {
29212
- this.constructor = d;
29213
- }
29214
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
29215
- };
29216
- }();
29217
- Object.defineProperty(exports, "__esModule", { value: true });
29218
- exports.createJSONRPCNotification = exports.createJSONRPCRequest = exports.createJSONRPCSuccessResponse = exports.createJSONRPCErrorResponse = exports.JSONRPCErrorCode = exports.JSONRPCErrorException = exports.isJSONRPCResponses = exports.isJSONRPCResponse = exports.isJSONRPCRequests = exports.isJSONRPCRequest = exports.isJSONRPCID = exports.JSONRPC = void 0;
29219
- exports.JSONRPC = "2.0";
29220
- var isJSONRPCID = function(id) {
29221
- return typeof id === "string" || typeof id === "number" || id === null;
29222
- };
29223
- exports.isJSONRPCID = isJSONRPCID;
29224
- var isJSONRPCRequest = function(payload) {
29225
- return payload.jsonrpc === exports.JSONRPC && payload.method !== void 0 && payload.result === void 0 && payload.error === void 0;
29226
- };
29227
- exports.isJSONRPCRequest = isJSONRPCRequest;
29228
- var isJSONRPCRequests = function(payload) {
29229
- return Array.isArray(payload) && payload.every(exports.isJSONRPCRequest);
29230
- };
29231
- exports.isJSONRPCRequests = isJSONRPCRequests;
29232
- var isJSONRPCResponse = function(payload) {
29233
- return payload.jsonrpc === exports.JSONRPC && payload.id !== void 0 && (payload.result !== void 0 || payload.error !== void 0);
29234
- };
29235
- exports.isJSONRPCResponse = isJSONRPCResponse;
29236
- var isJSONRPCResponses = function(payload) {
29237
- return Array.isArray(payload) && payload.every(exports.isJSONRPCResponse);
29238
- };
29239
- exports.isJSONRPCResponses = isJSONRPCResponses;
29240
- var createJSONRPCError = function(code, message, data) {
29241
- var error = { code, message };
29242
- if (data != null) {
29243
- error.data = data;
29244
- }
29245
- return error;
29246
- };
29247
- var JSONRPCErrorException = (
29248
- /** @class */
29249
- function(_super) {
29250
- __extends(JSONRPCErrorException2, _super);
29251
- function JSONRPCErrorException2(message, code, data) {
29252
- var _this = _super.call(this, message) || this;
29253
- Object.setPrototypeOf(_this, JSONRPCErrorException2.prototype);
29254
- _this.code = code;
29255
- _this.data = data;
29256
- return _this;
29257
- }
29258
- JSONRPCErrorException2.prototype.toObject = function() {
29259
- return createJSONRPCError(this.code, this.message, this.data);
29260
- };
29261
- return JSONRPCErrorException2;
29262
- }(Error)
29263
- );
29264
- exports.JSONRPCErrorException = JSONRPCErrorException;
29265
- var JSONRPCErrorCode;
29266
- (function(JSONRPCErrorCode2) {
29267
- JSONRPCErrorCode2[JSONRPCErrorCode2["ParseError"] = -32700] = "ParseError";
29268
- JSONRPCErrorCode2[JSONRPCErrorCode2["InvalidRequest"] = -32600] = "InvalidRequest";
29269
- JSONRPCErrorCode2[JSONRPCErrorCode2["MethodNotFound"] = -32601] = "MethodNotFound";
29270
- JSONRPCErrorCode2[JSONRPCErrorCode2["InvalidParams"] = -32602] = "InvalidParams";
29271
- JSONRPCErrorCode2[JSONRPCErrorCode2["InternalError"] = -32603] = "InternalError";
29272
- })(JSONRPCErrorCode = exports.JSONRPCErrorCode || (exports.JSONRPCErrorCode = {}));
29273
- var createJSONRPCErrorResponse = function(id, code, message, data) {
29274
- return {
29275
- jsonrpc: exports.JSONRPC,
29276
- id,
29277
- error: createJSONRPCError(code, message, data)
29278
- };
29279
- };
29280
- exports.createJSONRPCErrorResponse = createJSONRPCErrorResponse;
29281
- var createJSONRPCSuccessResponse = function(id, result) {
29282
- return {
29283
- jsonrpc: exports.JSONRPC,
29284
- id,
29285
- result: result !== null && result !== void 0 ? result : null
29286
- };
29287
- };
29288
- exports.createJSONRPCSuccessResponse = createJSONRPCSuccessResponse;
29289
- var createJSONRPCRequest = function(id, method, params) {
29290
- return {
29291
- jsonrpc: exports.JSONRPC,
29292
- id,
29293
- method,
29294
- params
29295
- };
29296
- };
29297
- exports.createJSONRPCRequest = createJSONRPCRequest;
29298
- var createJSONRPCNotification = function(method, params) {
29299
- return {
29300
- jsonrpc: exports.JSONRPC,
29301
- method,
29302
- params
29303
- };
29304
- };
29305
- exports.createJSONRPCNotification = createJSONRPCNotification;
29306
- }
29307
- });
29308
-
29309
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/internal.js
29310
- var require_internal = __commonJS({
29311
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/internal.js"(exports) {
29312
- "use strict";
29313
- Object.defineProperty(exports, "__esModule", { value: true });
29314
- exports.DefaultErrorCode = void 0;
29315
- exports.DefaultErrorCode = 0;
29316
- }
29317
- });
29318
-
29319
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/client.js
29320
- var require_client = __commonJS({
29321
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/client.js"(exports) {
29322
- "use strict";
29323
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
29324
- function adopt(value) {
29325
- return value instanceof P ? value : new P(function(resolve) {
29326
- resolve(value);
29327
- });
29328
- }
29329
- return new (P || (P = Promise))(function(resolve, reject) {
29330
- function fulfilled(value) {
29331
- try {
29332
- step(generator.next(value));
29333
- } catch (e) {
29334
- reject(e);
29335
- }
29336
- }
29337
- function rejected(value) {
29338
- try {
29339
- step(generator["throw"](value));
29340
- } catch (e) {
29341
- reject(e);
29342
- }
29343
- }
29344
- function step(result) {
29345
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29346
- }
29347
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29348
- });
29349
- };
29350
- var __generator = exports && exports.__generator || function(thisArg, body) {
29351
- var _ = { label: 0, sent: function() {
29352
- if (t[0] & 1)
29353
- throw t[1];
29354
- return t[1];
29355
- }, trys: [], ops: [] }, f2, y, t, g;
29356
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
29357
- return this;
29358
- }), g;
29359
- function verb(n) {
29360
- return function(v) {
29361
- return step([n, v]);
29362
- };
29363
- }
29364
- function step(op) {
29365
- if (f2)
29366
- throw new TypeError("Generator is already executing.");
29367
- while (g && (g = 0, op[0] && (_ = 0)), _)
29368
- try {
29369
- if (f2 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
29370
- return t;
29371
- if (y = 0, t)
29372
- op = [op[0] & 2, t.value];
29373
- switch (op[0]) {
29374
- case 0:
29375
- case 1:
29376
- t = op;
29377
- break;
29378
- case 4:
29379
- _.label++;
29380
- return { value: op[1], done: false };
29381
- case 5:
29382
- _.label++;
29383
- y = op[1];
29384
- op = [0];
29385
- continue;
29386
- case 7:
29387
- op = _.ops.pop();
29388
- _.trys.pop();
29389
- continue;
29390
- default:
29391
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
29392
- _ = 0;
29393
- continue;
29394
- }
29395
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
29396
- _.label = op[1];
29397
- break;
29398
- }
29399
- if (op[0] === 6 && _.label < t[1]) {
29400
- _.label = t[1];
29401
- t = op;
29402
- break;
29403
- }
29404
- if (t && _.label < t[2]) {
29405
- _.label = t[2];
29406
- _.ops.push(op);
29407
- break;
29408
- }
29409
- if (t[2])
29410
- _.ops.pop();
29411
- _.trys.pop();
29412
- continue;
29413
- }
29414
- op = body.call(thisArg, _);
29415
- } catch (e) {
29416
- op = [6, e];
29417
- y = 0;
29418
- } finally {
29419
- f2 = t = 0;
29420
- }
29421
- if (op[0] & 5)
29422
- throw op[1];
29423
- return { value: op[0] ? op[1] : void 0, done: true };
29424
- }
29425
- };
29426
- Object.defineProperty(exports, "__esModule", { value: true });
29427
- exports.JSONRPCClient = void 0;
29428
- var models_1 = require_models();
29429
- var internal_1 = require_internal();
29430
- var JSONRPCClient2 = (
29431
- /** @class */
29432
- function() {
29433
- function JSONRPCClient3(_send, createID) {
29434
- this._send = _send;
29435
- this.createID = createID;
29436
- this.idToResolveMap = /* @__PURE__ */ new Map();
29437
- this.id = 0;
29438
- }
29439
- JSONRPCClient3.prototype._createID = function() {
29440
- if (this.createID) {
29441
- return this.createID();
29442
- } else {
29443
- return ++this.id;
29444
- }
29445
- };
29446
- JSONRPCClient3.prototype.timeout = function(delay, overrideCreateJSONRPCErrorResponse) {
29447
- var _this = this;
29448
- if (overrideCreateJSONRPCErrorResponse === void 0) {
29449
- overrideCreateJSONRPCErrorResponse = function(id) {
29450
- return (0, models_1.createJSONRPCErrorResponse)(id, internal_1.DefaultErrorCode, "Request timeout");
29451
- };
29452
- }
29453
- var timeoutRequest = function(ids, request) {
29454
- var timeoutID = setTimeout(function() {
29455
- ids.forEach(function(id) {
29456
- var resolve = _this.idToResolveMap.get(id);
29457
- if (resolve) {
29458
- _this.idToResolveMap.delete(id);
29459
- resolve(overrideCreateJSONRPCErrorResponse(id));
29460
- }
29461
- });
29462
- }, delay);
29463
- return request().then(function(result) {
29464
- clearTimeout(timeoutID);
29465
- return result;
29466
- }, function(error) {
29467
- clearTimeout(timeoutID);
29468
- return Promise.reject(error);
29469
- });
29470
- };
29471
- var requestAdvanced = function(request, clientParams) {
29472
- var ids = (!Array.isArray(request) ? [request] : request).map(function(request2) {
29473
- return request2.id;
29474
- }).filter(isDefinedAndNonNull);
29475
- return timeoutRequest(ids, function() {
29476
- return _this.requestAdvanced(request, clientParams);
29477
- });
29478
- };
29479
- return {
29480
- request: function(method, params, clientParams) {
29481
- var id = _this._createID();
29482
- return timeoutRequest([id], function() {
29483
- return _this.requestWithID(method, params, clientParams, id);
29484
- });
29485
- },
29486
- requestAdvanced: function(request, clientParams) {
29487
- return requestAdvanced(request, clientParams);
29488
- }
29489
- };
29490
- };
29491
- JSONRPCClient3.prototype.request = function(method, params, clientParams) {
29492
- return this.requestWithID(method, params, clientParams, this._createID());
29493
- };
29494
- JSONRPCClient3.prototype.requestWithID = function(method, params, clientParams, id) {
29495
- return __awaiter(this, void 0, void 0, function() {
29496
- var request, response;
29497
- return __generator(this, function(_a) {
29498
- switch (_a.label) {
29499
- case 0:
29500
- request = (0, models_1.createJSONRPCRequest)(id, method, params);
29501
- return [4, this.requestAdvanced(request, clientParams)];
29502
- case 1:
29503
- response = _a.sent();
29504
- if (response.result !== void 0 && !response.error) {
29505
- return [2, response.result];
29506
- } else if (response.result === void 0 && response.error) {
29507
- return [2, Promise.reject(new models_1.JSONRPCErrorException(response.error.message, response.error.code, response.error.data))];
29508
- } else {
29509
- return [2, Promise.reject(new Error("An unexpected error occurred"))];
29510
- }
29511
- return [
29512
- 2
29513
- /*return*/
29514
- ];
29515
- }
29516
- });
29517
- });
29518
- };
29519
- JSONRPCClient3.prototype.requestAdvanced = function(requests, clientParams) {
29520
- var _this = this;
29521
- var areRequestsOriginallyArray = Array.isArray(requests);
29522
- if (!Array.isArray(requests)) {
29523
- requests = [requests];
29524
- }
29525
- var requestsWithID = requests.filter(function(request) {
29526
- return isDefinedAndNonNull(request.id);
29527
- });
29528
- var promises = requestsWithID.map(function(request) {
29529
- return new Promise(function(resolve) {
29530
- return _this.idToResolveMap.set(request.id, resolve);
29531
- });
29532
- });
29533
- var promise = Promise.all(promises).then(function(responses) {
29534
- if (areRequestsOriginallyArray || !responses.length) {
29535
- return responses;
29536
- } else {
29537
- return responses[0];
29538
- }
29539
- });
29540
- return this.send(areRequestsOriginallyArray ? requests : requests[0], clientParams).then(function() {
29541
- return promise;
29542
- }, function(error) {
29543
- requestsWithID.forEach(function(request) {
29544
- _this.receive((0, models_1.createJSONRPCErrorResponse)(request.id, internal_1.DefaultErrorCode, error && error.message || "Failed to send a request"));
29545
- });
29546
- return promise;
29547
- });
29548
- };
29549
- JSONRPCClient3.prototype.notify = function(method, params, clientParams) {
29550
- var request = (0, models_1.createJSONRPCNotification)(method, params);
29551
- this.send(request, clientParams).then(void 0, function() {
29552
- return void 0;
29553
- });
29554
- };
29555
- JSONRPCClient3.prototype.send = function(payload, clientParams) {
29556
- return __awaiter(this, void 0, void 0, function() {
29557
- return __generator(this, function(_a) {
29558
- return [2, this._send(payload, clientParams)];
29559
- });
29560
- });
29561
- };
29562
- JSONRPCClient3.prototype.rejectAllPendingRequests = function(message) {
29563
- this.idToResolveMap.forEach(function(resolve, id) {
29564
- return resolve((0, models_1.createJSONRPCErrorResponse)(id, internal_1.DefaultErrorCode, message));
29565
- });
29566
- this.idToResolveMap.clear();
29567
- };
29568
- JSONRPCClient3.prototype.receive = function(responses) {
29569
- var _this = this;
29570
- if (!Array.isArray(responses)) {
29571
- responses = [responses];
29572
- }
29573
- responses.forEach(function(response) {
29574
- var resolve = _this.idToResolveMap.get(response.id);
29575
- if (resolve) {
29576
- _this.idToResolveMap.delete(response.id);
29577
- resolve(response);
29578
- }
29579
- });
29580
- };
29581
- return JSONRPCClient3;
29582
- }()
29583
- );
29584
- exports.JSONRPCClient = JSONRPCClient2;
29585
- var isDefinedAndNonNull = function(value) {
29586
- return value !== void 0 && value !== null;
29587
- };
29588
- }
29589
- });
29590
-
29591
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/interfaces.js
29592
- var require_interfaces = __commonJS({
29593
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/interfaces.js"(exports) {
29594
- "use strict";
29595
- Object.defineProperty(exports, "__esModule", { value: true });
29596
- }
29597
- });
29598
-
29599
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/server.js
29600
- var require_server = __commonJS({
29601
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/server.js"(exports) {
29602
- "use strict";
29603
- var __assign2 = exports && exports.__assign || function() {
29604
- __assign2 = Object.assign || function(t) {
29605
- for (var s, i = 1, n = arguments.length; i < n; i++) {
29606
- s = arguments[i];
29607
- for (var p in s)
29608
- if (Object.prototype.hasOwnProperty.call(s, p))
29609
- t[p] = s[p];
29610
- }
29611
- return t;
29612
- };
29613
- return __assign2.apply(this, arguments);
29614
- };
29615
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
29616
- function adopt(value) {
29617
- return value instanceof P ? value : new P(function(resolve) {
29618
- resolve(value);
29619
- });
29620
- }
29621
- return new (P || (P = Promise))(function(resolve, reject) {
29622
- function fulfilled(value) {
29623
- try {
29624
- step(generator.next(value));
29625
- } catch (e) {
29626
- reject(e);
29627
- }
29628
- }
29629
- function rejected(value) {
29630
- try {
29631
- step(generator["throw"](value));
29632
- } catch (e) {
29633
- reject(e);
29634
- }
29635
- }
29636
- function step(result) {
29637
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29638
- }
29639
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29640
- });
29641
- };
29642
- var __generator = exports && exports.__generator || function(thisArg, body) {
29643
- var _ = { label: 0, sent: function() {
29644
- if (t[0] & 1)
29645
- throw t[1];
29646
- return t[1];
29647
- }, trys: [], ops: [] }, f2, y, t, g;
29648
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
29649
- return this;
29650
- }), g;
29651
- function verb(n) {
29652
- return function(v) {
29653
- return step([n, v]);
29654
- };
29655
- }
29656
- function step(op) {
29657
- if (f2)
29658
- throw new TypeError("Generator is already executing.");
29659
- while (g && (g = 0, op[0] && (_ = 0)), _)
29660
- try {
29661
- if (f2 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
29662
- return t;
29663
- if (y = 0, t)
29664
- op = [op[0] & 2, t.value];
29665
- switch (op[0]) {
29666
- case 0:
29667
- case 1:
29668
- t = op;
29669
- break;
29670
- case 4:
29671
- _.label++;
29672
- return { value: op[1], done: false };
29673
- case 5:
29674
- _.label++;
29675
- y = op[1];
29676
- op = [0];
29677
- continue;
29678
- case 7:
29679
- op = _.ops.pop();
29680
- _.trys.pop();
29681
- continue;
29682
- default:
29683
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
29684
- _ = 0;
29685
- continue;
29686
- }
29687
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
29688
- _.label = op[1];
29689
- break;
29690
- }
29691
- if (op[0] === 6 && _.label < t[1]) {
29692
- _.label = t[1];
29693
- t = op;
29694
- break;
29695
- }
29696
- if (t && _.label < t[2]) {
29697
- _.label = t[2];
29698
- _.ops.push(op);
29699
- break;
29700
- }
29701
- if (t[2])
29702
- _.ops.pop();
29703
- _.trys.pop();
29704
- continue;
29705
- }
29706
- op = body.call(thisArg, _);
29707
- } catch (e) {
29708
- op = [6, e];
29709
- y = 0;
29710
- } finally {
29711
- f2 = t = 0;
29712
- }
29713
- if (op[0] & 5)
29714
- throw op[1];
29715
- return { value: op[0] ? op[1] : void 0, done: true };
29716
- }
29717
- };
29718
- var __spreadArray = exports && exports.__spreadArray || function(to, from, pack) {
29719
- if (pack || arguments.length === 2)
29720
- for (var i = 0, l = from.length, ar; i < l; i++) {
29721
- if (ar || !(i in from)) {
29722
- if (!ar)
29723
- ar = Array.prototype.slice.call(from, 0, i);
29724
- ar[i] = from[i];
29725
- }
29726
- }
29727
- return to.concat(ar || Array.prototype.slice.call(from));
29728
- };
29729
- Object.defineProperty(exports, "__esModule", { value: true });
29730
- exports.JSONRPCServer = void 0;
29731
- var models_1 = require_models();
29732
- var internal_1 = require_internal();
29733
- var createParseErrorResponse = function() {
29734
- return (0, models_1.createJSONRPCErrorResponse)(null, models_1.JSONRPCErrorCode.ParseError, "Parse error");
29735
- };
29736
- var createInvalidRequestResponse = function(request) {
29737
- return (0, models_1.createJSONRPCErrorResponse)((0, models_1.isJSONRPCID)(request.id) ? request.id : null, models_1.JSONRPCErrorCode.InvalidRequest, "Invalid Request");
29738
- };
29739
- var createMethodNotFoundResponse = function(id) {
29740
- return (0, models_1.createJSONRPCErrorResponse)(id, models_1.JSONRPCErrorCode.MethodNotFound, "Method not found");
29741
- };
29742
- var JSONRPCServer = (
29743
- /** @class */
29744
- function() {
29745
- function JSONRPCServer2(options) {
29746
- if (options === void 0) {
29747
- options = {};
29748
- }
29749
- var _a;
29750
- this.mapErrorToJSONRPCErrorResponse = defaultMapErrorToJSONRPCErrorResponse;
29751
- this.nameToMethodDictionary = {};
29752
- this.middleware = null;
29753
- this.errorListener = (_a = options.errorListener) !== null && _a !== void 0 ? _a : console.warn;
29754
- }
29755
- JSONRPCServer2.prototype.hasMethod = function(name) {
29756
- return !!this.nameToMethodDictionary[name];
29757
- };
29758
- JSONRPCServer2.prototype.addMethod = function(name, method) {
29759
- this.addMethodAdvanced(name, this.toJSONRPCMethod(method));
29760
- };
29761
- JSONRPCServer2.prototype.removeMethod = function(name) {
29762
- delete this.nameToMethodDictionary[name];
29763
- };
29764
- JSONRPCServer2.prototype.toJSONRPCMethod = function(method) {
29765
- return function(request, serverParams) {
29766
- var response = method(request.params, serverParams);
29767
- return Promise.resolve(response).then(function(result) {
29768
- return mapResultToJSONRPCResponse(request.id, result);
29769
- });
29770
- };
29771
- };
29772
- JSONRPCServer2.prototype.addMethodAdvanced = function(name, method) {
29773
- var _a;
29774
- this.nameToMethodDictionary = __assign2(__assign2({}, this.nameToMethodDictionary), (_a = {}, _a[name] = method, _a));
29775
- };
29776
- JSONRPCServer2.prototype.receiveJSON = function(json, serverParams) {
29777
- var request = this.tryParseRequestJSON(json);
29778
- if (request) {
29779
- return this.receive(request, serverParams);
29780
- } else {
29781
- return Promise.resolve(createParseErrorResponse());
29782
- }
29783
- };
29784
- JSONRPCServer2.prototype.tryParseRequestJSON = function(json) {
29785
- try {
29786
- return JSON.parse(json);
29787
- } catch (_a) {
29788
- return null;
29789
- }
29790
- };
29791
- JSONRPCServer2.prototype.receive = function(request, serverParams) {
29792
- if (Array.isArray(request)) {
29793
- return this.receiveMultiple(request, serverParams);
29794
- } else {
29795
- return this.receiveSingle(request, serverParams);
29796
- }
29797
- };
29798
- JSONRPCServer2.prototype.receiveMultiple = function(requests, serverParams) {
29799
- return __awaiter(this, void 0, void 0, function() {
29800
- var responses;
29801
- var _this = this;
29802
- return __generator(this, function(_a) {
29803
- switch (_a.label) {
29804
- case 0:
29805
- return [4, Promise.all(requests.map(function(request) {
29806
- return _this.receiveSingle(request, serverParams);
29807
- }))];
29808
- case 1:
29809
- responses = _a.sent().filter(isNonNull);
29810
- if (responses.length === 1) {
29811
- return [2, responses[0]];
29812
- } else if (responses.length) {
29813
- return [2, responses];
29814
- } else {
29815
- return [2, null];
29816
- }
29817
- return [
29818
- 2
29819
- /*return*/
29820
- ];
29821
- }
29822
- });
29823
- });
29824
- };
29825
- JSONRPCServer2.prototype.receiveSingle = function(request, serverParams) {
29826
- return __awaiter(this, void 0, void 0, function() {
29827
- var method, response;
29828
- return __generator(this, function(_a) {
29829
- switch (_a.label) {
29830
- case 0:
29831
- method = this.nameToMethodDictionary[request.method];
29832
- if (!!(0, models_1.isJSONRPCRequest)(request))
29833
- return [3, 1];
29834
- return [2, createInvalidRequestResponse(request)];
29835
- case 1:
29836
- return [4, this.callMethod(method, request, serverParams)];
29837
- case 2:
29838
- response = _a.sent();
29839
- return [2, mapResponse(request, response)];
29840
- }
29841
- });
29842
- });
29843
- };
29844
- JSONRPCServer2.prototype.applyMiddleware = function() {
29845
- var middlewares = [];
29846
- for (var _i = 0; _i < arguments.length; _i++) {
29847
- middlewares[_i] = arguments[_i];
29848
- }
29849
- if (this.middleware) {
29850
- this.middleware = this.combineMiddlewares(__spreadArray([
29851
- this.middleware
29852
- ], middlewares, true));
29853
- } else {
29854
- this.middleware = this.combineMiddlewares(middlewares);
29855
- }
29856
- };
29857
- JSONRPCServer2.prototype.combineMiddlewares = function(middlewares) {
29858
- if (!middlewares.length) {
29859
- return null;
29860
- } else {
29861
- return middlewares.reduce(this.middlewareReducer);
29862
- }
29863
- };
29864
- JSONRPCServer2.prototype.middlewareReducer = function(prevMiddleware, nextMiddleware) {
29865
- return function(next, request, serverParams) {
29866
- return prevMiddleware(function(request2, serverParams2) {
29867
- return nextMiddleware(next, request2, serverParams2);
29868
- }, request, serverParams);
29869
- };
29870
- };
29871
- JSONRPCServer2.prototype.callMethod = function(method, request, serverParams) {
29872
- var _this = this;
29873
- var callMethod = function(request2, serverParams2) {
29874
- if (method) {
29875
- return method(request2, serverParams2);
29876
- } else if (request2.id !== void 0) {
29877
- return Promise.resolve(createMethodNotFoundResponse(request2.id));
29878
- } else {
29879
- return Promise.resolve(null);
29880
- }
29881
- };
29882
- var onError = function(error) {
29883
- _this.errorListener('An unexpected error occurred while executing "'.concat(request.method, '" JSON-RPC method:'), error);
29884
- return Promise.resolve(_this.mapErrorToJSONRPCErrorResponseIfNecessary(request.id, error));
29885
- };
29886
- try {
29887
- return (this.middleware || noopMiddleware)(callMethod, request, serverParams).then(void 0, onError);
29888
- } catch (error) {
29889
- return onError(error);
29890
- }
29891
- };
29892
- JSONRPCServer2.prototype.mapErrorToJSONRPCErrorResponseIfNecessary = function(id, error) {
29893
- if (id !== void 0) {
29894
- return this.mapErrorToJSONRPCErrorResponse(id, error);
29895
- } else {
29896
- return null;
29897
- }
29898
- };
29899
- return JSONRPCServer2;
29900
- }()
29901
- );
29902
- exports.JSONRPCServer = JSONRPCServer;
29903
- var isNonNull = function(value) {
29904
- return value !== null;
29905
- };
29906
- var noopMiddleware = function(next, request, serverParams) {
29907
- return next(request, serverParams);
29908
- };
29909
- var mapResultToJSONRPCResponse = function(id, result) {
29910
- if (id !== void 0) {
29911
- return (0, models_1.createJSONRPCSuccessResponse)(id, result);
29912
- } else {
29913
- return null;
29914
- }
29915
- };
29916
- var defaultMapErrorToJSONRPCErrorResponse = function(id, error) {
29917
- var _a;
29918
- var message = (_a = error === null || error === void 0 ? void 0 : error.message) !== null && _a !== void 0 ? _a : "An unexpected error occurred";
29919
- var code = internal_1.DefaultErrorCode;
29920
- var data;
29921
- if (error instanceof models_1.JSONRPCErrorException) {
29922
- code = error.code;
29923
- data = error.data;
29924
- }
29925
- return (0, models_1.createJSONRPCErrorResponse)(id, code, message, data);
29926
- };
29927
- var mapResponse = function(request, response) {
29928
- if (response) {
29929
- return response;
29930
- } else if (request.id !== void 0) {
29931
- return (0, models_1.createJSONRPCErrorResponse)(request.id, models_1.JSONRPCErrorCode.InternalError, "Internal error");
29932
- } else {
29933
- return null;
29934
- }
29935
- };
29936
- }
29937
- });
29938
-
29939
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/server-and-client.js
29940
- var require_server_and_client = __commonJS({
29941
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/server-and-client.js"(exports) {
29942
- "use strict";
29943
- var __awaiter = exports && exports.__awaiter || function(thisArg, _arguments, P, generator) {
29944
- function adopt(value) {
29945
- return value instanceof P ? value : new P(function(resolve) {
29946
- resolve(value);
29947
- });
29948
- }
29949
- return new (P || (P = Promise))(function(resolve, reject) {
29950
- function fulfilled(value) {
29951
- try {
29952
- step(generator.next(value));
29953
- } catch (e) {
29954
- reject(e);
29955
- }
29956
- }
29957
- function rejected(value) {
29958
- try {
29959
- step(generator["throw"](value));
29960
- } catch (e) {
29961
- reject(e);
29962
- }
29963
- }
29964
- function step(result) {
29965
- result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
29966
- }
29967
- step((generator = generator.apply(thisArg, _arguments || [])).next());
29968
- });
29969
- };
29970
- var __generator = exports && exports.__generator || function(thisArg, body) {
29971
- var _ = { label: 0, sent: function() {
29972
- if (t[0] & 1)
29973
- throw t[1];
29974
- return t[1];
29975
- }, trys: [], ops: [] }, f2, y, t, g;
29976
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
29977
- return this;
29978
- }), g;
29979
- function verb(n) {
29980
- return function(v) {
29981
- return step([n, v]);
29982
- };
29983
- }
29984
- function step(op) {
29985
- if (f2)
29986
- throw new TypeError("Generator is already executing.");
29987
- while (g && (g = 0, op[0] && (_ = 0)), _)
29988
- try {
29989
- if (f2 = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
29990
- return t;
29991
- if (y = 0, t)
29992
- op = [op[0] & 2, t.value];
29993
- switch (op[0]) {
29994
- case 0:
29995
- case 1:
29996
- t = op;
29997
- break;
29998
- case 4:
29999
- _.label++;
30000
- return { value: op[1], done: false };
30001
- case 5:
30002
- _.label++;
30003
- y = op[1];
30004
- op = [0];
30005
- continue;
30006
- case 7:
30007
- op = _.ops.pop();
30008
- _.trys.pop();
30009
- continue;
30010
- default:
30011
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
30012
- _ = 0;
30013
- continue;
30014
- }
30015
- if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
30016
- _.label = op[1];
30017
- break;
30018
- }
30019
- if (op[0] === 6 && _.label < t[1]) {
30020
- _.label = t[1];
30021
- t = op;
30022
- break;
30023
- }
30024
- if (t && _.label < t[2]) {
30025
- _.label = t[2];
30026
- _.ops.push(op);
30027
- break;
30028
- }
30029
- if (t[2])
30030
- _.ops.pop();
30031
- _.trys.pop();
30032
- continue;
30033
- }
30034
- op = body.call(thisArg, _);
30035
- } catch (e) {
30036
- op = [6, e];
30037
- y = 0;
30038
- } finally {
30039
- f2 = t = 0;
30040
- }
30041
- if (op[0] & 5)
30042
- throw op[1];
30043
- return { value: op[0] ? op[1] : void 0, done: true };
30044
- }
30045
- };
30046
- Object.defineProperty(exports, "__esModule", { value: true });
30047
- exports.JSONRPCServerAndClient = void 0;
30048
- var models_1 = require_models();
30049
- var JSONRPCServerAndClient = (
30050
- /** @class */
30051
- function() {
30052
- function JSONRPCServerAndClient2(server, client, options) {
30053
- if (options === void 0) {
30054
- options = {};
30055
- }
30056
- var _a;
30057
- this.server = server;
30058
- this.client = client;
30059
- this.errorListener = (_a = options.errorListener) !== null && _a !== void 0 ? _a : console.warn;
30060
- }
30061
- JSONRPCServerAndClient2.prototype.applyServerMiddleware = function() {
30062
- var _a;
30063
- var middlewares = [];
30064
- for (var _i = 0; _i < arguments.length; _i++) {
30065
- middlewares[_i] = arguments[_i];
30066
- }
30067
- (_a = this.server).applyMiddleware.apply(_a, middlewares);
30068
- };
30069
- JSONRPCServerAndClient2.prototype.hasMethod = function(name) {
30070
- return this.server.hasMethod(name);
30071
- };
30072
- JSONRPCServerAndClient2.prototype.addMethod = function(name, method) {
30073
- this.server.addMethod(name, method);
30074
- };
30075
- JSONRPCServerAndClient2.prototype.addMethodAdvanced = function(name, method) {
30076
- this.server.addMethodAdvanced(name, method);
30077
- };
30078
- JSONRPCServerAndClient2.prototype.removeMethod = function(name) {
30079
- this.server.removeMethod(name);
30080
- };
30081
- JSONRPCServerAndClient2.prototype.timeout = function(delay) {
30082
- return this.client.timeout(delay);
30083
- };
30084
- JSONRPCServerAndClient2.prototype.request = function(method, params, clientParams) {
30085
- return this.client.request(method, params, clientParams);
30086
- };
30087
- JSONRPCServerAndClient2.prototype.requestAdvanced = function(jsonRPCRequest, clientParams) {
30088
- return this.client.requestAdvanced(jsonRPCRequest, clientParams);
30089
- };
30090
- JSONRPCServerAndClient2.prototype.notify = function(method, params, clientParams) {
30091
- this.client.notify(method, params, clientParams);
30092
- };
30093
- JSONRPCServerAndClient2.prototype.rejectAllPendingRequests = function(message) {
30094
- this.client.rejectAllPendingRequests(message);
30095
- };
30096
- JSONRPCServerAndClient2.prototype.receiveAndSend = function(payload, serverParams, clientParams) {
30097
- return __awaiter(this, void 0, void 0, function() {
30098
- var response, message;
30099
- return __generator(this, function(_a) {
30100
- switch (_a.label) {
30101
- case 0:
30102
- if (!((0, models_1.isJSONRPCResponse)(payload) || (0, models_1.isJSONRPCResponses)(payload)))
30103
- return [3, 1];
30104
- this.client.receive(payload);
30105
- return [3, 4];
30106
- case 1:
30107
- if (!((0, models_1.isJSONRPCRequest)(payload) || (0, models_1.isJSONRPCRequests)(payload)))
30108
- return [3, 3];
30109
- return [4, this.server.receive(payload, serverParams)];
30110
- case 2:
30111
- response = _a.sent();
30112
- if (response) {
30113
- return [2, this.client.send(response, clientParams)];
30114
- }
30115
- return [3, 4];
30116
- case 3:
30117
- message = "Received an invalid JSON-RPC message";
30118
- this.errorListener(message, payload);
30119
- return [2, Promise.reject(new Error(message))];
30120
- case 4:
30121
- return [
30122
- 2
30123
- /*return*/
30124
- ];
30125
- }
30126
- });
30127
- });
30128
- };
30129
- return JSONRPCServerAndClient2;
30130
- }()
30131
- );
30132
- exports.JSONRPCServerAndClient = JSONRPCServerAndClient;
30133
- }
30134
- });
30135
-
30136
- // ../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/index.js
30137
- var require_dist3 = __commonJS({
30138
- "../../node_modules/.pnpm/json-rpc-2.0@1.7.0/node_modules/json-rpc-2.0/dist/index.js"(exports) {
30139
- "use strict";
30140
- var __createBinding = exports && exports.__createBinding || (Object.create ? function(o, m, k, k2) {
30141
- if (k2 === void 0)
30142
- k2 = k;
30143
- var desc = Object.getOwnPropertyDescriptor(m, k);
30144
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
30145
- desc = { enumerable: true, get: function() {
30146
- return m[k];
30147
- } };
30148
- }
30149
- Object.defineProperty(o, k2, desc);
30150
- } : function(o, m, k, k2) {
30151
- if (k2 === void 0)
30152
- k2 = k;
30153
- o[k2] = m[k];
30154
- });
30155
- var __exportStar = exports && exports.__exportStar || function(m, exports2) {
30156
- for (var p in m)
30157
- if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports2, p))
30158
- __createBinding(exports2, m, p);
30159
- };
30160
- Object.defineProperty(exports, "__esModule", { value: true });
30161
- __exportStar(require_client(), exports);
30162
- __exportStar(require_interfaces(), exports);
30163
- __exportStar(require_models(), exports);
30164
- __exportStar(require_server(), exports);
30165
- __exportStar(require_server_and_client(), exports);
30166
- }
30167
- });
30168
-
30169
29192
  // ../../node_modules/.pnpm/@noble+hashes@1.3.1/node_modules/@noble/hashes/esm/_assert.js
30170
29193
  function number(n) {
30171
29194
  if (!Number.isSafeInteger(n) || n < 0)
@@ -31079,7 +30102,7 @@ spurious results.`);
31079
30102
  // ../versions/dist/index.mjs
31080
30103
  function getBuiltinVersions() {
31081
30104
  return {
31082
- FORC: "0.49.2",
30105
+ FORC: "0.50.0",
31083
30106
  FUEL_CORE: "0.22.0",
31084
30107
  FUELS: "0.73.0"
31085
30108
  };
@@ -43179,23 +42202,6 @@ ${MessageCoinFragmentFragmentDoc}`;
43179
42202
  if (estimateTxDependencies) {
43180
42203
  await this.estimateTxDependencies(transactionRequest);
43181
42204
  }
43182
- const { gasUsed, minGasPrice } = await this.getTransactionCost(transactionRequest, [], {
43183
- estimateTxDependencies: false,
43184
- estimatePredicates: false
43185
- });
43186
- if (bn(minGasPrice).gt(bn(transactionRequest.gasPrice))) {
43187
- throw new FuelError(
43188
- ErrorCode.GAS_PRICE_TOO_LOW,
43189
- `Gas price '${transactionRequest.gasPrice}' is lower than the required: '${minGasPrice}'.`
43190
- );
43191
- }
43192
- const isScriptTransaction = transactionRequest.type === TransactionType.Script;
43193
- if (isScriptTransaction && bn(gasUsed).gt(bn(transactionRequest.gasLimit))) {
43194
- throw new FuelError(
43195
- ErrorCode.GAS_LIMIT_TOO_LOW,
43196
- `Gas limit '${transactionRequest.gasLimit}' is lower than the required: '${gasUsed}'.`
43197
- );
43198
- }
43199
42205
  const encodedTransaction = hexlify(transactionRequest.toTransactionBytes());
43200
42206
  if (awaitExecution) {
43201
42207
  const subscription = this.operations.submitAndAwait({ encodedTransaction });
@@ -44148,10 +43154,14 @@ ${MessageCoinFragmentFragmentDoc}`;
44148
43154
  const request = new ScriptTransactionRequest(params);
44149
43155
  request.addCoinOutput(Address.fromAddressOrString(destination), amount, assetId);
44150
43156
  const { maxFee, requiredQuantities, gasUsed } = await this.provider.getTransactionCost(request);
44151
- const gasPriceToUse = bn(txParams.gasPrice ?? minGasPrice);
44152
- const gasLimitToUse = bn(txParams.gasLimit ?? gasUsed);
44153
- request.gasPrice = gasPriceToUse;
44154
- request.gasLimit = gasLimitToUse;
43157
+ request.gasPrice = bn(txParams.gasPrice ?? minGasPrice);
43158
+ request.gasLimit = bn(txParams.gasLimit ?? gasUsed);
43159
+ this.validateGas({
43160
+ gasUsed,
43161
+ gasPrice: request.gasPrice,
43162
+ gasLimit: request.gasLimit,
43163
+ minGasPrice
43164
+ });
44155
43165
  await this.fund(request, requiredQuantities, maxFee);
44156
43166
  return request;
44157
43167
  }
@@ -44196,7 +43206,13 @@ ${MessageCoinFragmentFragmentDoc}`;
44196
43206
  request,
44197
43207
  [{ amount: bn(amount), assetId: String(assetId) }]
44198
43208
  );
44199
- request.gasLimit = bn(params.gasLimit || gasUsed);
43209
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
43210
+ this.validateGas({
43211
+ gasUsed,
43212
+ gasPrice: request.gasPrice,
43213
+ gasLimit: request.gasLimit,
43214
+ minGasPrice
43215
+ });
44200
43216
  await this.fund(request, requiredQuantities, maxFee);
44201
43217
  return this.sendTransaction(request);
44202
43218
  }
@@ -44209,6 +43225,7 @@ ${MessageCoinFragmentFragmentDoc}`;
44209
43225
  * @returns A promise that resolves to the transaction response.
44210
43226
  */
44211
43227
  async withdrawToBaseLayer(recipient, amount, txParams = {}) {
43228
+ const { minGasPrice } = this.provider.getGasConfig();
44212
43229
  const recipientAddress = Address.fromAddressOrString(recipient);
44213
43230
  const recipientDataArray = getBytesCopy(
44214
43231
  "0x".concat(recipientAddress.toHexString().substring(2).padStart(64, "0"))
@@ -44221,14 +43238,20 @@ ${MessageCoinFragmentFragmentDoc}`;
44221
43238
  ...recipientDataArray,
44222
43239
  ...amountDataArray
44223
43240
  ]);
44224
- const params = { script, ...txParams };
43241
+ const params = { script, gasPrice: minGasPrice, ...txParams };
44225
43242
  const request = new ScriptTransactionRequest(params);
44226
43243
  const forwardingQuantities = [{ amount: bn(amount), assetId: BaseAssetId }];
44227
43244
  const { requiredQuantities, maxFee, gasUsed } = await this.provider.getTransactionCost(
44228
43245
  request,
44229
43246
  forwardingQuantities
44230
43247
  );
44231
- request.gasLimit = params.gasLimit ? bn(params.gasLimit) : gasUsed;
43248
+ request.gasLimit = bn(params.gasLimit ?? gasUsed);
43249
+ this.validateGas({
43250
+ gasUsed,
43251
+ gasPrice: request.gasPrice,
43252
+ gasLimit: request.gasLimit,
43253
+ minGasPrice
43254
+ });
44232
43255
  await this.fund(request, requiredQuantities, maxFee);
44233
43256
  return this.sendTransaction(request);
44234
43257
  }
@@ -44257,6 +43280,25 @@ ${MessageCoinFragmentFragmentDoc}`;
44257
43280
  await this.provider.estimateTxDependencies(transactionRequest);
44258
43281
  return this.provider.simulate(transactionRequest, { estimateTxDependencies: false });
44259
43282
  }
43283
+ validateGas({
43284
+ gasUsed,
43285
+ gasPrice,
43286
+ gasLimit,
43287
+ minGasPrice
43288
+ }) {
43289
+ if (minGasPrice.gt(gasPrice)) {
43290
+ throw new FuelError(
43291
+ ErrorCode.GAS_PRICE_TOO_LOW,
43292
+ `Gas price '${gasPrice}' is lower than the required: '${minGasPrice}'.`
43293
+ );
43294
+ }
43295
+ if (gasUsed.gt(gasLimit)) {
43296
+ throw new FuelError(
43297
+ ErrorCode.GAS_LIMIT_TOO_LOW,
43298
+ `Gas limit '${gasLimit}' is lower than the required: '${gasUsed}'.`
43299
+ );
43300
+ }
43301
+ }
44260
43302
  };
44261
43303
 
44262
43304
  // ../../node_modules/.pnpm/@noble+hashes@1.3.3/node_modules/@noble/hashes/esm/_assert.js
@@ -49888,9 +48930,6 @@ ${MessageCoinFragmentFragmentDoc}`;
49888
48930
  }
49889
48931
  };
49890
48932
 
49891
- // src/connectors/fuel-wallet-connector.ts
49892
- var import_json_rpc_2 = __toESM(require_dist3());
49893
-
49894
48933
  // src/connectors/fuel-connector.ts
49895
48934
  var import_events2 = __require("events");
49896
48935
 
@@ -49950,6 +48989,26 @@ ${MessageCoinFragmentFragmentDoc}`;
49950
48989
  return MessageTypes2;
49951
48990
  })(MessageTypes || {});
49952
48991
 
48992
+ // src/connectors/types/local-storage.ts
48993
+ var LocalStorage = class {
48994
+ storage;
48995
+ constructor(localStorage) {
48996
+ this.storage = localStorage;
48997
+ }
48998
+ async setItem(key, value) {
48999
+ this.storage.setItem(key, value);
49000
+ }
49001
+ async getItem(key) {
49002
+ return this.storage.getItem(key);
49003
+ }
49004
+ async removeItem(key) {
49005
+ this.storage.removeItem(key);
49006
+ }
49007
+ async clear() {
49008
+ this.storage.clear();
49009
+ }
49010
+ };
49011
+
49953
49012
  // src/connectors/fuel-connector.ts
49954
49013
  var FuelConnector = class extends import_events2.EventEmitter {
49955
49014
  name = "";
@@ -50168,261 +49227,6 @@ ${MessageCoinFragmentFragmentDoc}`;
50168
49227
  }
50169
49228
  };
50170
49229
 
50171
- // src/connectors/fuel-wallet-connector.ts
50172
- var FuelWalletConnector = class extends FuelConnector {
50173
- name = "";
50174
- connected = false;
50175
- installed = false;
50176
- events = FuelConnectorEventTypes;
50177
- metadata = {
50178
- image: "/connectors/fuel-wallet.svg",
50179
- install: {
50180
- action: "Install",
50181
- description: "To connect your Fuel Wallet, install the browser extension.",
50182
- link: "https://chrome.google.com/webstore/detail/fuel-wallet/dldjpboieedgcmpkchcjcbijingjcgok"
50183
- }
50184
- };
50185
- client;
50186
- constructor(name = "Fuel Wallet") {
50187
- super();
50188
- this.name = name;
50189
- this.setMaxListeners(100);
50190
- this.client = new import_json_rpc_2.JSONRPCClient(this.sendRequest.bind(this), this.createRequestId);
50191
- this.setupListener();
50192
- this.setupConnector();
50193
- }
50194
- /**
50195
- * ============================================================
50196
- * Application communication methods
50197
- * ============================================================
50198
- */
50199
- setupConnector() {
50200
- if (typeof window !== "undefined") {
50201
- this.ping().then(() => {
50202
- window.dispatchEvent(new CustomEvent("FuelConnector", { detail: this }));
50203
- }).catch(() => {
50204
- });
50205
- }
50206
- }
50207
- acceptMessage(message) {
50208
- const { data: event } = message;
50209
- return message.origin === window.origin && event.type !== "request" /* request */ && event.connectorName === this.name && event.target === CONNECTOR_SCRIPT;
50210
- }
50211
- setupListener() {
50212
- if (typeof window === "undefined") {
50213
- return;
50214
- }
50215
- window.addEventListener(EVENT_MESSAGE, this.onMessage.bind(this));
50216
- }
50217
- createRequestId() {
50218
- return v4_default();
50219
- }
50220
- postMessage(message, origin) {
50221
- window.postMessage(message, origin || window.origin);
50222
- }
50223
- // eslint-disable-next-line @typescript-eslint/require-await
50224
- async sendRequest(request) {
50225
- if (!request) {
50226
- return;
50227
- }
50228
- this.postMessage({
50229
- type: "request" /* request */,
50230
- target: CONTENT_SCRIPT_NAME,
50231
- connectorName: this.name,
50232
- request
50233
- });
50234
- }
50235
- onResponse(message) {
50236
- this.client.receive(message.response);
50237
- }
50238
- onEvent(message) {
50239
- message.events.forEach((eventData) => {
50240
- if (eventData.event === "start") {
50241
- this.setupConnector();
50242
- } else {
50243
- this.emit(eventData.event, ...eventData.params);
50244
- }
50245
- });
50246
- }
50247
- onMessage = (message) => {
50248
- const messageFroze = Object.freeze(message);
50249
- if (!this.acceptMessage(messageFroze)) {
50250
- return;
50251
- }
50252
- const { data: event } = messageFroze;
50253
- this.onCommunicationMessage(event);
50254
- };
50255
- onCommunicationMessage = (message) => {
50256
- switch (message.type) {
50257
- case "response" /* response */:
50258
- this.onResponse(message);
50259
- break;
50260
- case "event" /* event */:
50261
- this.onEvent(message);
50262
- break;
50263
- default:
50264
- }
50265
- };
50266
- /**
50267
- * ============================================================
50268
- * Connector methods
50269
- * ============================================================
50270
- */
50271
- async ping() {
50272
- return this.client.timeout(800).request("ping", {});
50273
- }
50274
- async isConnected() {
50275
- try {
50276
- return await this.client.request("isConnected", {});
50277
- } catch {
50278
- return false;
50279
- }
50280
- }
50281
- async connect() {
50282
- return this.client.request("connect", {});
50283
- }
50284
- async disconnect() {
50285
- return this.client.request("disconnect", {});
50286
- }
50287
- async accounts() {
50288
- return this.client.request("accounts", {});
50289
- }
50290
- async currentAccount() {
50291
- return this.client.request("currentAccount", {});
50292
- }
50293
- async signMessage(address, message) {
50294
- if (!message.trim()) {
50295
- throw new Error("Message is required");
50296
- }
50297
- return this.client.request("signMessage", {
50298
- address,
50299
- message
50300
- });
50301
- }
50302
- async sendTransaction(address, transaction) {
50303
- if (!transaction) {
50304
- throw new Error("Transaction is required");
50305
- }
50306
- const txRequest = transactionRequestify(transaction);
50307
- const network = await this.currentNetwork();
50308
- const provider = {
50309
- url: network.url
50310
- };
50311
- return this.client.request("sendTransaction", {
50312
- address,
50313
- transaction: JSON.stringify(txRequest),
50314
- provider
50315
- });
50316
- }
50317
- async assets() {
50318
- return this.client.request("assets", {});
50319
- }
50320
- async addAsset(asset) {
50321
- return this.addAssets([asset]);
50322
- }
50323
- async addAssets(assets) {
50324
- const assetsData = assets.map((asset) => {
50325
- const fuelNetworkAsset = asset.networks.find((n) => n.type === "fuel");
50326
- if (!fuelNetworkAsset) {
50327
- throw new Error("Asset for Fuel Network not found!");
50328
- }
50329
- return {
50330
- ...asset,
50331
- imageUrl: asset.icon,
50332
- decimals: fuelNetworkAsset.decimals,
50333
- assetId: fuelNetworkAsset.assetId
50334
- };
50335
- });
50336
- return this.client.request("addAssets", {
50337
- assets: assetsData
50338
- });
50339
- }
50340
- async addABI(contractId, abi) {
50341
- return this.client.request("addAbi", {
50342
- abiMap: {
50343
- [contractId]: abi
50344
- }
50345
- });
50346
- }
50347
- async getABI(contractId) {
50348
- return this.client.request("getAbi", {
50349
- contractId
50350
- });
50351
- }
50352
- async hasABI(contractId) {
50353
- const abi = await this.getABI(contractId);
50354
- return !!abi;
50355
- }
50356
- async currentNetwork() {
50357
- return this.client.request("network", {});
50358
- }
50359
- // eslint-disable-next-line @typescript-eslint/require-await
50360
- async selectNetwork(_network) {
50361
- throw new Error("Method not implemented.");
50362
- }
50363
- async networks() {
50364
- return this.client.request("networks", {});
50365
- }
50366
- async addNetwork(networkUrl) {
50367
- const provider = await Provider.create(networkUrl);
50368
- return this.client.request("addNetwork", {
50369
- network: {
50370
- url: provider.url,
50371
- name: provider.getChain().name
50372
- }
50373
- });
50374
- }
50375
- async version() {
50376
- return this.client.request("version", {
50377
- app: "0.0.0",
50378
- network: "0.0.0"
50379
- });
50380
- }
50381
- };
50382
-
50383
- // src/connectors/fuel-wallet-development-connector.ts
50384
- var FuelWalletDevelopmentConnector = class extends FuelWalletConnector {
50385
- metadata = {
50386
- image: "/connectors/fuel-wallet-dev.svg",
50387
- install: {
50388
- action: "Install",
50389
- description: "To connect your Fuel Wallet, you need to install the browser extension first.",
50390
- link: "https://chrome.google.com/webstore/detail/fuel-wallet-development/hcgmehahnlbhpilepakbdinkhhaackmc"
50391
- }
50392
- };
50393
- constructor() {
50394
- super("Fuel Wallet Development");
50395
- }
50396
- };
50397
-
50398
- // src/connectors/fuelet-wallet-connector.ts
50399
- var FueletWalletConnector = class extends FuelWalletConnector {
50400
- name = "Fuelet Wallet";
50401
- metadata = {
50402
- image: {
50403
- light: "/connectors/fuelet-light.svg",
50404
- dark: "/connectors/fuelet-dark.svg"
50405
- },
50406
- install: {
50407
- action: "Install",
50408
- description: "Install Fuelet Wallet in order to connect it.",
50409
- link: "https://fuelet.app/download/"
50410
- }
50411
- };
50412
- constructor() {
50413
- super("Fuelet Wallet");
50414
- }
50415
- };
50416
-
50417
- // src/connectors/default-connector.ts
50418
- function defaultConnectors({ devMode } = {}) {
50419
- const connectors = [new FuelWalletConnector(), new FueletWalletConnector()];
50420
- if (devMode) {
50421
- connectors.push(new FuelWalletDevelopmentConnector());
50422
- }
50423
- return connectors;
50424
- }
50425
-
50426
49230
  // src/connectors/fuel-wallet-locked.ts
50427
49231
  var FuelWalletLocked = class extends WalletLocked {
50428
49232
  connector;
@@ -50535,9 +49339,7 @@ ${MessageCoinFragmentFragmentDoc}`;
50535
49339
  constructor(config = _Fuel.defaultConfig) {
50536
49340
  super();
50537
49341
  this.setMaxListeners(1e3);
50538
- this._connectors = config.connectors ?? defaultConnectors({
50539
- devMode: config.devMode
50540
- });
49342
+ this._connectors = config.connectors ?? [];
50541
49343
  this._targetObject = this.getTargetObject(config.targetObject);
50542
49344
  this._storage = config.storage === void 0 ? this.getStorage() : config.storage;
50543
49345
  this.setupMethods();
@@ -50564,15 +49366,15 @@ ${MessageCoinFragmentFragmentDoc}`;
50564
49366
  */
50565
49367
  getStorage() {
50566
49368
  if (typeof window !== "undefined") {
50567
- return window.localStorage;
49369
+ return new LocalStorage(window.localStorage);
50568
49370
  }
50569
49371
  return void 0;
50570
49372
  }
50571
49373
  /**
50572
49374
  * Setup the default connector from the storage.
50573
49375
  */
50574
- setDefaultConnector() {
50575
- const connectorName = this._storage?.getItem(_Fuel.STORAGE_KEY) || this._connectors[0]?.name;
49376
+ async setDefaultConnector() {
49377
+ const connectorName = await this._storage?.getItem(_Fuel.STORAGE_KEY) || this._connectors[0]?.name;
50576
49378
  if (connectorName) {
50577
49379
  return this.selectConnector(connectorName, {
50578
49380
  emitEvents: false
@@ -50760,7 +49562,7 @@ ${MessageCoinFragmentFragmentDoc}`;
50760
49562
  this._currentConnector = connector;
50761
49563
  this.emit(this.events.currentConnector, connector);
50762
49564
  this.setupConnectorEvents(Object.values(FuelConnectorEventTypes));
50763
- this._storage?.setItem(_Fuel.STORAGE_KEY, connector.name);
49565
+ await this._storage?.setItem(_Fuel.STORAGE_KEY, connector.name);
50764
49566
  if (options.emitEvents) {
50765
49567
  this.triggerConnectorEvents();
50766
49568
  }
@@ -50842,15 +49644,15 @@ ${MessageCoinFragmentFragmentDoc}`;
50842
49644
  /**
50843
49645
  * Clean all the data from the storage.
50844
49646
  */
50845
- clean() {
50846
- this._storage?.removeItem(_Fuel.STORAGE_KEY);
49647
+ async clean() {
49648
+ await this._storage?.removeItem(_Fuel.STORAGE_KEY);
50847
49649
  }
50848
49650
  /**
50849
49651
  * Removes all listeners and cleans the storage.
50850
49652
  */
50851
- destroy() {
49653
+ async destroy() {
50852
49654
  this.unsubscribe();
50853
- this.clean();
49655
+ await this.clean();
50854
49656
  }
50855
49657
  };
50856
49658
  var Fuel = _Fuel;