@massalabs/wallet-provider 1.2.1-dev.20230731160259 → 1.2.1-dev.20230803113644

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.
package/bundle.js CHANGED
@@ -230,6 +230,8 @@ class Connector {
230
230
  constructor() {
231
231
  this.registeredProviders = {};
232
232
  this.pendingRequests = new Map();
233
+ this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery();
234
+ this.initMassaStationListener();
233
235
  this.register();
234
236
  // start listening to messages from content script
235
237
  document
@@ -265,16 +267,18 @@ class Connector {
265
267
  this.registeredProviders[payload.providerName] =
266
268
  providerEventTargetName;
267
269
  });
270
+ }
271
+ initMassaStationListener() {
272
+ this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
273
+ this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
274
+ });
275
+ this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
276
+ delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
277
+ });
278
+ }
279
+ async startMassaStationDiscovery() {
268
280
  try {
269
- // start MassaStation discovery
270
- this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery(1000);
271
- this.massaStationListener.startListening();
272
- this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
273
- this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
274
- });
275
- this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
276
- delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
277
- });
281
+ await this.massaStationListener.startListening();
278
282
  }
279
283
  catch (e) {
280
284
  console.log('MassaStation is not detected');
@@ -355,7 +359,7 @@ class Connector {
355
359
  }
356
360
  exports.connector = new Connector();
357
361
 
358
- },{"..":4,"../massaStation/MassaStationDiscovery":6,"../massaStation/MassaStationProvider":7,"uid":50}],4:[function(require,module,exports){
362
+ },{"..":4,"../massaStation/MassaStationDiscovery":6,"../massaStation/MassaStationProvider":7,"uid":49}],4:[function(require,module,exports){
359
363
  "use strict";
360
364
  Object.defineProperty(exports, "__esModule", { value: true });
361
365
  exports.MassaStationAccount = exports.Provider = exports.EAccountImportResponse = exports.EAccountDeletionResponse = exports.Account = exports.registerProvider = exports.providers = exports.AvailableCommands = void 0;
@@ -395,6 +399,7 @@ async function providers(retry = true, timeout = 3000, pollInterval = 500) {
395
399
  if (timeout <= 0) {
396
400
  return [];
397
401
  }
402
+ await Connector_1.connector.startMassaStationDiscovery();
398
403
  return new Promise((resolve) => {
399
404
  let provider = [];
400
405
  for (const providerName of Object.keys(Connector_1.connector.getWalletProviders())) {
@@ -444,7 +449,7 @@ Object.defineProperty(exports, "Provider", { enumerable: true, get: function ()
444
449
  var MassaStationAccount_1 = require("./massaStation/MassaStationAccount");
445
450
  Object.defineProperty(exports, "MassaStationAccount", { enumerable: true, get: function () { return MassaStationAccount_1.MassaStationAccount; } });
446
451
 
447
- },{"./account":2,"./connector/Connector":3,"./massaStation/MassaStationAccount":5,"./massaStation/MassaStationProvider":7,"./provider":12,"./provider/Provider":11,"buffer":46}],5:[function(require,module,exports){
452
+ },{"./account":2,"./connector/Connector":3,"./massaStation/MassaStationAccount":5,"./massaStation/MassaStationProvider":7,"./provider":12,"./provider/Provider":11,"buffer":45}],5:[function(require,module,exports){
448
453
  "use strict";
449
454
  Object.defineProperty(exports, "__esModule", { value: true });
450
455
  exports.MassaStationAccount = void 0;
@@ -772,7 +777,6 @@ exports.MassaStationAccount = MassaStationAccount;
772
777
  Object.defineProperty(exports, "__esModule", { value: true });
773
778
  exports.MassaStationDiscovery = exports.ON_MASSA_STATION_DISCONNECTED = exports.ON_MASSA_STATION_DISCOVERED = exports.MASSA_STATION_DISCOVERY_URL = void 0;
774
779
  const events_1 = require("events");
775
- const time_1 = require("../utils/time");
776
780
  const RequestHandler_1 = require("./RequestHandler");
777
781
  /**
778
782
  * Url used for the MassaStation discovery and pinging the MassaStation server's index.html
@@ -809,22 +813,17 @@ class MassaStationDiscovery extends events_1.EventEmitter {
809
813
  * @returns An instance of the MassaStation class.
810
814
  *
811
815
  */
812
- constructor(pollIntervalMillis) {
816
+ constructor() {
813
817
  super();
814
- this.pollIntervalMillis = pollIntervalMillis;
815
- this.timeoutId = null;
816
818
  this.isDiscovered = false;
817
- // bind class methods
818
- this.callback = this.callback.bind(this);
819
- this.stopListening = this.stopListening.bind(this);
820
819
  this.startListening = this.startListening.bind(this);
821
820
  }
822
821
  /**
823
- * A callback method that triggers a ping of the MassaStation's server
822
+ * A method to start listening for a connection to MassaStation's server.
824
823
  *
825
824
  * @returns void
826
825
  */
827
- async callback() {
826
+ async startListening() {
828
827
  let resp = null;
829
828
  try {
830
829
  resp = await (0, RequestHandler_1.getRequest)(exports.MASSA_STATION_DISCOVERY_URL);
@@ -837,34 +836,14 @@ class MassaStationDiscovery extends events_1.EventEmitter {
837
836
  this.emit(exports.ON_MASSA_STATION_DISCOVERED);
838
837
  }
839
838
  if ((resp.isError || resp.error) && this.isDiscovered) {
839
+ this.isDiscovered = false;
840
840
  this.emit(exports.ON_MASSA_STATION_DISCONNECTED);
841
841
  }
842
842
  }
843
- /**
844
- * A method to stop listening for a connection to MassaStation's server
845
- *
846
- * @returns void
847
- */
848
- stopListening() {
849
- if (this.timeoutId)
850
- this.timeoutId.clear();
851
- }
852
- /**
853
- * A method to start listening for a connection to MassaStation's server.
854
- *
855
- * @returns void
856
- */
857
- startListening() {
858
- const that = this;
859
- if (this.timeoutId) {
860
- return;
861
- }
862
- this.timeoutId = new time_1.Timeout(this.pollIntervalMillis, () => that.callback());
863
- }
864
843
  }
865
844
  exports.MassaStationDiscovery = MassaStationDiscovery;
866
845
 
867
- },{"../utils/time":14,"./RequestHandler":8,"events":47}],7:[function(require,module,exports){
846
+ },{"./RequestHandler":8,"events":46}],7:[function(require,module,exports){
868
847
  "use strict";
869
848
 
870
849
  Object.defineProperty(exports, "__esModule", {
@@ -1185,7 +1164,7 @@ async function putRequest(url, body) {
1185
1164
  }
1186
1165
  exports.putRequest = putRequest;
1187
1166
 
1188
- },{"axios":15}],9:[function(require,module,exports){
1167
+ },{"axios":14}],9:[function(require,module,exports){
1189
1168
  "use strict";
1190
1169
  Object.defineProperty(exports, "__esModule", { value: true });
1191
1170
  exports.EAccountDeletionResponse = void 0;
@@ -1386,130 +1365,9 @@ function uint8ArrayToBase64(arg) {
1386
1365
  exports.uint8ArrayToBase64 = uint8ArrayToBase64;
1387
1366
 
1388
1367
  }).call(this)}).call(this,require("buffer").Buffer)
1389
- },{"buffer":46}],14:[function(require,module,exports){
1390
- "use strict";
1391
- /**
1392
- * This file defines a TypeScript module with various time-related Typescript methods.
1393
- *
1394
- * @remarks
1395
- * - The classes and their methods implemented here are quite generic and might be useful in other contexts too
1396
- * but have been particularly developed for the purposes of this library
1397
- * - If you want to work on this repo, you will probably be interested in this object
1398
- *
1399
- */
1400
- Object.defineProperty(exports, "__esModule", { value: true });
1401
- exports.withTimeoutRejection = exports.wait = exports.Interval = exports.Timeout = void 0;
1402
- /**
1403
- * This class provides an implementation of a timer calling a callback hook after it ticks.
1404
- * @remarks
1405
- * The timer is being resetted only after the execution of the callback method has finished
1406
- */
1407
- class Timeout {
1408
- /**
1409
- * Timeout constructor
1410
- *
1411
- * @param timeoutMil - The number of milliseconds for the timeout.
1412
- * @param callback - a callback to execute.
1413
- * @returns An instance of the Timeout class.
1414
- */
1415
- constructor(timeoutMil, callback) {
1416
- this.clear = this.clear.bind(this);
1417
- const that = this;
1418
- this.isCleared = false;
1419
- this.isCalled = false;
1420
- this.timeoutHook = setTimeout(() => {
1421
- if (!that.isCleared) {
1422
- this.isCalled = true;
1423
- callback();
1424
- }
1425
- }, timeoutMil);
1426
- }
1427
- /**
1428
- * A method to clear the timeout
1429
- *
1430
- * @returns void
1431
- */
1432
- clear() {
1433
- if (!this.isCleared) {
1434
- clearTimeout(this.timeoutHook);
1435
- this.isCleared = true;
1436
- }
1437
- }
1438
- }
1439
- exports.Timeout = Timeout;
1440
- /**
1441
- * This class provides an implementation of a continuous timer calling a callback hook after every given milliseconds.
1442
- * @remarks
1443
- * The timer is being resetted every given milliseconds
1444
- * irregardless whether the execution of the method is still running or not
1445
- */
1446
- class Interval {
1447
- /**
1448
- * Interval constructor
1449
- *
1450
- * @param timeoutMil - The number of milliseconds for the interval.
1451
- * @param callback - a callback to execute.
1452
- * @returns An instance of the Interval class.
1453
- */
1454
- constructor(timeoutMil, callback) {
1455
- this.clear = this.clear.bind(this);
1456
- const that = this;
1457
- this.isCleared = false;
1458
- this.isCalled = false;
1459
- this.intervalHook = setInterval(() => {
1460
- if (!that.isCleared) {
1461
- this.isCalled = true;
1462
- callback();
1463
- }
1464
- }, timeoutMil);
1465
- }
1466
- /**
1467
- * A method to clear the interval
1468
- *
1469
- * @returns void
1470
- */
1471
- clear() {
1472
- if (!this.isCleared) {
1473
- clearInterval(this.intervalHook);
1474
- this.isCleared = true;
1475
- }
1476
- }
1477
- }
1478
- exports.Interval = Interval;
1479
- /**
1480
- * A function that waits pauses the execution loop for a number of milliseconds
1481
- *
1482
- * @param timeMilli - The number of milliseconds to wait.
1483
- * @returns void
1484
- */
1485
- const wait = async (timeMilli) => {
1486
- return new Promise((resolve, reject) => {
1487
- const timeout = new Timeout(timeMilli, () => {
1488
- timeout.clear();
1489
- return resolve();
1490
- });
1491
- });
1492
- };
1493
- exports.wait = wait;
1494
- /**
1495
- * A function that awaits a promise with a timeout.
1496
- *
1497
- * @param promise - a promise to execute.
1498
- * @param timeoutMs - The number of milliseconds to wait before a timeout.
1499
- * @returns void
1500
- *
1501
- * @remarks
1502
- * The promise is being polled with a timeout. Once the timeout is reached, if not fulfilled, the error is thrown.
1503
- */
1504
- async function withTimeoutRejection(promise, timeoutMs) {
1505
- const sleep = new Promise((resolve, reject) => setTimeout(() => reject(new Error(`Timeout of ${timeoutMs} has passed and promise did not resolve`)), timeoutMs));
1506
- return Promise.race([promise, sleep]);
1507
- }
1508
- exports.withTimeoutRejection = withTimeoutRejection;
1509
-
1510
- },{}],15:[function(require,module,exports){
1368
+ },{"buffer":45}],14:[function(require,module,exports){
1511
1369
  module.exports = require('./lib/axios');
1512
- },{"./lib/axios":17}],16:[function(require,module,exports){
1370
+ },{"./lib/axios":16}],15:[function(require,module,exports){
1513
1371
  'use strict';
1514
1372
 
1515
1373
  var utils = require('./../utils');
@@ -1723,7 +1581,7 @@ module.exports = function xhrAdapter(config) {
1723
1581
  });
1724
1582
  };
1725
1583
 
1726
- },{"../cancel/Cancel":18,"../core/buildFullPath":23,"../core/createError":24,"../defaults/transitional":31,"./../core/settle":28,"./../helpers/buildURL":34,"./../helpers/cookies":36,"./../helpers/isURLSameOrigin":39,"./../helpers/parseHeaders":41,"./../utils":44}],17:[function(require,module,exports){
1584
+ },{"../cancel/Cancel":17,"../core/buildFullPath":22,"../core/createError":23,"../defaults/transitional":30,"./../core/settle":27,"./../helpers/buildURL":33,"./../helpers/cookies":35,"./../helpers/isURLSameOrigin":38,"./../helpers/parseHeaders":40,"./../utils":43}],16:[function(require,module,exports){
1727
1585
  'use strict';
1728
1586
 
1729
1587
  var utils = require('./utils');
@@ -1780,7 +1638,7 @@ module.exports = axios;
1780
1638
  // Allow use of default import syntax in TypeScript
1781
1639
  module.exports.default = axios;
1782
1640
 
1783
- },{"./cancel/Cancel":18,"./cancel/CancelToken":19,"./cancel/isCancel":20,"./core/Axios":21,"./core/mergeConfig":27,"./defaults":30,"./env/data":32,"./helpers/bind":33,"./helpers/isAxiosError":38,"./helpers/spread":42,"./utils":44}],18:[function(require,module,exports){
1641
+ },{"./cancel/Cancel":17,"./cancel/CancelToken":18,"./cancel/isCancel":19,"./core/Axios":20,"./core/mergeConfig":26,"./defaults":29,"./env/data":31,"./helpers/bind":32,"./helpers/isAxiosError":37,"./helpers/spread":41,"./utils":43}],17:[function(require,module,exports){
1784
1642
  'use strict';
1785
1643
 
1786
1644
  /**
@@ -1801,7 +1659,7 @@ Cancel.prototype.__CANCEL__ = true;
1801
1659
 
1802
1660
  module.exports = Cancel;
1803
1661
 
1804
- },{}],19:[function(require,module,exports){
1662
+ },{}],18:[function(require,module,exports){
1805
1663
  'use strict';
1806
1664
 
1807
1665
  var Cancel = require('./Cancel');
@@ -1922,14 +1780,14 @@ CancelToken.source = function source() {
1922
1780
 
1923
1781
  module.exports = CancelToken;
1924
1782
 
1925
- },{"./Cancel":18}],20:[function(require,module,exports){
1783
+ },{"./Cancel":17}],19:[function(require,module,exports){
1926
1784
  'use strict';
1927
1785
 
1928
1786
  module.exports = function isCancel(value) {
1929
1787
  return !!(value && value.__CANCEL__);
1930
1788
  };
1931
1789
 
1932
- },{}],21:[function(require,module,exports){
1790
+ },{}],20:[function(require,module,exports){
1933
1791
  'use strict';
1934
1792
 
1935
1793
  var utils = require('./../utils');
@@ -2079,7 +1937,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2079
1937
 
2080
1938
  module.exports = Axios;
2081
1939
 
2082
- },{"../helpers/buildURL":34,"../helpers/validator":43,"./../utils":44,"./InterceptorManager":22,"./dispatchRequest":25,"./mergeConfig":27}],22:[function(require,module,exports){
1940
+ },{"../helpers/buildURL":33,"../helpers/validator":42,"./../utils":43,"./InterceptorManager":21,"./dispatchRequest":24,"./mergeConfig":26}],21:[function(require,module,exports){
2083
1941
  'use strict';
2084
1942
 
2085
1943
  var utils = require('./../utils');
@@ -2135,7 +1993,7 @@ InterceptorManager.prototype.forEach = function forEach(fn) {
2135
1993
 
2136
1994
  module.exports = InterceptorManager;
2137
1995
 
2138
- },{"./../utils":44}],23:[function(require,module,exports){
1996
+ },{"./../utils":43}],22:[function(require,module,exports){
2139
1997
  'use strict';
2140
1998
 
2141
1999
  var isAbsoluteURL = require('../helpers/isAbsoluteURL');
@@ -2157,7 +2015,7 @@ module.exports = function buildFullPath(baseURL, requestedURL) {
2157
2015
  return requestedURL;
2158
2016
  };
2159
2017
 
2160
- },{"../helpers/combineURLs":35,"../helpers/isAbsoluteURL":37}],24:[function(require,module,exports){
2018
+ },{"../helpers/combineURLs":34,"../helpers/isAbsoluteURL":36}],23:[function(require,module,exports){
2161
2019
  'use strict';
2162
2020
 
2163
2021
  var enhanceError = require('./enhanceError');
@@ -2177,7 +2035,7 @@ module.exports = function createError(message, config, code, request, response)
2177
2035
  return enhanceError(error, config, code, request, response);
2178
2036
  };
2179
2037
 
2180
- },{"./enhanceError":26}],25:[function(require,module,exports){
2038
+ },{"./enhanceError":25}],24:[function(require,module,exports){
2181
2039
  'use strict';
2182
2040
 
2183
2041
  var utils = require('./../utils');
@@ -2266,7 +2124,7 @@ module.exports = function dispatchRequest(config) {
2266
2124
  });
2267
2125
  };
2268
2126
 
2269
- },{"../cancel/Cancel":18,"../cancel/isCancel":20,"../defaults":30,"./../utils":44,"./transformData":29}],26:[function(require,module,exports){
2127
+ },{"../cancel/Cancel":17,"../cancel/isCancel":19,"../defaults":29,"./../utils":43,"./transformData":28}],25:[function(require,module,exports){
2270
2128
  'use strict';
2271
2129
 
2272
2130
  /**
@@ -2311,7 +2169,7 @@ module.exports = function enhanceError(error, config, code, request, response) {
2311
2169
  return error;
2312
2170
  };
2313
2171
 
2314
- },{}],27:[function(require,module,exports){
2172
+ },{}],26:[function(require,module,exports){
2315
2173
  'use strict';
2316
2174
 
2317
2175
  var utils = require('../utils');
@@ -2412,7 +2270,7 @@ module.exports = function mergeConfig(config1, config2) {
2412
2270
  return config;
2413
2271
  };
2414
2272
 
2415
- },{"../utils":44}],28:[function(require,module,exports){
2273
+ },{"../utils":43}],27:[function(require,module,exports){
2416
2274
  'use strict';
2417
2275
 
2418
2276
  var createError = require('./createError');
@@ -2439,7 +2297,7 @@ module.exports = function settle(resolve, reject, response) {
2439
2297
  }
2440
2298
  };
2441
2299
 
2442
- },{"./createError":24}],29:[function(require,module,exports){
2300
+ },{"./createError":23}],28:[function(require,module,exports){
2443
2301
  'use strict';
2444
2302
 
2445
2303
  var utils = require('./../utils');
@@ -2463,7 +2321,7 @@ module.exports = function transformData(data, headers, fns) {
2463
2321
  return data;
2464
2322
  };
2465
2323
 
2466
- },{"../defaults":30,"./../utils":44}],30:[function(require,module,exports){
2324
+ },{"../defaults":29,"./../utils":43}],29:[function(require,module,exports){
2467
2325
  (function (process){(function (){
2468
2326
  'use strict';
2469
2327
 
@@ -2598,7 +2456,7 @@ utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
2598
2456
  module.exports = defaults;
2599
2457
 
2600
2458
  }).call(this)}).call(this,require('_process'))
2601
- },{"../adapters/http":16,"../adapters/xhr":16,"../core/enhanceError":26,"../helpers/normalizeHeaderName":40,"../utils":44,"./transitional":31,"_process":49}],31:[function(require,module,exports){
2459
+ },{"../adapters/http":15,"../adapters/xhr":15,"../core/enhanceError":25,"../helpers/normalizeHeaderName":39,"../utils":43,"./transitional":30,"_process":48}],30:[function(require,module,exports){
2602
2460
  'use strict';
2603
2461
 
2604
2462
  module.exports = {
@@ -2607,11 +2465,11 @@ module.exports = {
2607
2465
  clarifyTimeoutError: false
2608
2466
  };
2609
2467
 
2610
- },{}],32:[function(require,module,exports){
2468
+ },{}],31:[function(require,module,exports){
2611
2469
  module.exports = {
2612
2470
  "version": "0.26.1"
2613
2471
  };
2614
- },{}],33:[function(require,module,exports){
2472
+ },{}],32:[function(require,module,exports){
2615
2473
  'use strict';
2616
2474
 
2617
2475
  module.exports = function bind(fn, thisArg) {
@@ -2624,7 +2482,7 @@ module.exports = function bind(fn, thisArg) {
2624
2482
  };
2625
2483
  };
2626
2484
 
2627
- },{}],34:[function(require,module,exports){
2485
+ },{}],33:[function(require,module,exports){
2628
2486
  'use strict';
2629
2487
 
2630
2488
  var utils = require('./../utils');
@@ -2696,7 +2554,7 @@ module.exports = function buildURL(url, params, paramsSerializer) {
2696
2554
  return url;
2697
2555
  };
2698
2556
 
2699
- },{"./../utils":44}],35:[function(require,module,exports){
2557
+ },{"./../utils":43}],34:[function(require,module,exports){
2700
2558
  'use strict';
2701
2559
 
2702
2560
  /**
@@ -2712,7 +2570,7 @@ module.exports = function combineURLs(baseURL, relativeURL) {
2712
2570
  : baseURL;
2713
2571
  };
2714
2572
 
2715
- },{}],36:[function(require,module,exports){
2573
+ },{}],35:[function(require,module,exports){
2716
2574
  'use strict';
2717
2575
 
2718
2576
  var utils = require('./../utils');
@@ -2767,7 +2625,7 @@ module.exports = (
2767
2625
  })()
2768
2626
  );
2769
2627
 
2770
- },{"./../utils":44}],37:[function(require,module,exports){
2628
+ },{"./../utils":43}],36:[function(require,module,exports){
2771
2629
  'use strict';
2772
2630
 
2773
2631
  /**
@@ -2783,7 +2641,7 @@ module.exports = function isAbsoluteURL(url) {
2783
2641
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2784
2642
  };
2785
2643
 
2786
- },{}],38:[function(require,module,exports){
2644
+ },{}],37:[function(require,module,exports){
2787
2645
  'use strict';
2788
2646
 
2789
2647
  var utils = require('./../utils');
@@ -2798,7 +2656,7 @@ module.exports = function isAxiosError(payload) {
2798
2656
  return utils.isObject(payload) && (payload.isAxiosError === true);
2799
2657
  };
2800
2658
 
2801
- },{"./../utils":44}],39:[function(require,module,exports){
2659
+ },{"./../utils":43}],38:[function(require,module,exports){
2802
2660
  'use strict';
2803
2661
 
2804
2662
  var utils = require('./../utils');
@@ -2868,7 +2726,7 @@ module.exports = (
2868
2726
  })()
2869
2727
  );
2870
2728
 
2871
- },{"./../utils":44}],40:[function(require,module,exports){
2729
+ },{"./../utils":43}],39:[function(require,module,exports){
2872
2730
  'use strict';
2873
2731
 
2874
2732
  var utils = require('../utils');
@@ -2882,7 +2740,7 @@ module.exports = function normalizeHeaderName(headers, normalizedName) {
2882
2740
  });
2883
2741
  };
2884
2742
 
2885
- },{"../utils":44}],41:[function(require,module,exports){
2743
+ },{"../utils":43}],40:[function(require,module,exports){
2886
2744
  'use strict';
2887
2745
 
2888
2746
  var utils = require('./../utils');
@@ -2937,7 +2795,7 @@ module.exports = function parseHeaders(headers) {
2937
2795
  return parsed;
2938
2796
  };
2939
2797
 
2940
- },{"./../utils":44}],42:[function(require,module,exports){
2798
+ },{"./../utils":43}],41:[function(require,module,exports){
2941
2799
  'use strict';
2942
2800
 
2943
2801
  /**
@@ -2966,7 +2824,7 @@ module.exports = function spread(callback) {
2966
2824
  };
2967
2825
  };
2968
2826
 
2969
- },{}],43:[function(require,module,exports){
2827
+ },{}],42:[function(require,module,exports){
2970
2828
  'use strict';
2971
2829
 
2972
2830
  var VERSION = require('../env/data').version;
@@ -3050,7 +2908,7 @@ module.exports = {
3050
2908
  validators: validators
3051
2909
  };
3052
2910
 
3053
- },{"../env/data":32}],44:[function(require,module,exports){
2911
+ },{"../env/data":31}],43:[function(require,module,exports){
3054
2912
  'use strict';
3055
2913
 
3056
2914
  var bind = require('./helpers/bind');
@@ -3401,7 +3259,7 @@ module.exports = {
3401
3259
  stripBOM: stripBOM
3402
3260
  };
3403
3261
 
3404
- },{"./helpers/bind":33}],45:[function(require,module,exports){
3262
+ },{"./helpers/bind":32}],44:[function(require,module,exports){
3405
3263
  'use strict'
3406
3264
 
3407
3265
  exports.byteLength = byteLength
@@ -3553,7 +3411,7 @@ function fromByteArray (uint8) {
3553
3411
  return parts.join('')
3554
3412
  }
3555
3413
 
3556
- },{}],46:[function(require,module,exports){
3414
+ },{}],45:[function(require,module,exports){
3557
3415
  (function (Buffer){(function (){
3558
3416
  /*!
3559
3417
  * The buffer module from node.js, for the browser.
@@ -5334,7 +5192,7 @@ function numberIsNaN (obj) {
5334
5192
  }
5335
5193
 
5336
5194
  }).call(this)}).call(this,require("buffer").Buffer)
5337
- },{"base64-js":45,"buffer":46,"ieee754":48}],47:[function(require,module,exports){
5195
+ },{"base64-js":44,"buffer":45,"ieee754":47}],46:[function(require,module,exports){
5338
5196
  // Copyright Joyent, Inc. and other Node contributors.
5339
5197
  //
5340
5198
  // Permission is hereby granted, free of charge, to any person obtaining a
@@ -5833,7 +5691,7 @@ function eventTargetAgnosticAddListener(emitter, name, listener, flags) {
5833
5691
  }
5834
5692
  }
5835
5693
 
5836
- },{}],48:[function(require,module,exports){
5694
+ },{}],47:[function(require,module,exports){
5837
5695
  /*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
5838
5696
  exports.read = function (buffer, offset, isLE, mLen, nBytes) {
5839
5697
  var e, m
@@ -5920,7 +5778,7 @@ exports.write = function (buffer, value, offset, isLE, mLen, nBytes) {
5920
5778
  buffer[offset + i - d] |= s * 128
5921
5779
  }
5922
5780
 
5923
- },{}],49:[function(require,module,exports){
5781
+ },{}],48:[function(require,module,exports){
5924
5782
  // shim for using process in browser
5925
5783
  var process = module.exports = {};
5926
5784
 
@@ -6106,7 +5964,7 @@ process.chdir = function (dir) {
6106
5964
  };
6107
5965
  process.umask = function() { return 0; };
6108
5966
 
6109
- },{}],50:[function(require,module,exports){
5967
+ },{}],49:[function(require,module,exports){
6110
5968
  "use strict";
6111
5969
 
6112
5970
  Object.defineProperty(exports, "__esModule", {
@@ -3,8 +3,7 @@ import { IAccountSignResponse } from './AccountSign';
3
3
  import { IAccountDetails } from './IAccountDetails';
4
4
  import { ITransactionDetails } from '..';
5
5
  import { IAccount } from './IAccount';
6
- import { Args } from '@massalabs/web3-utils';
7
- import { IContractReadOperationResponse } from '@massalabs/massa-web3';
6
+ import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
8
7
  /**
9
8
  * This module contains the Account class. It is responsible for representing an account in the wallet.
10
9
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Account.d.ts","sourceRoot":"","sources":["../../src/account/Account.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AA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;;;;OAMG;IACU,SAAS,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAiB/B;;;;;;OAMG;IACU,eAAe,CAC1B,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,MAAM,EACxB,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAkB/B;;;;;;;;;;;;;;;;;;;OAmBG;IACU,MAAM,CACjB,eAAe,EAAE,MAAM,EACvB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,UAAU,GAAG,IAAI,EAC5B,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,EACd,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,mBAAmB,GAAG,8BAA8B,CAAC;CA0BjE"}
@@ -44,6 +44,8 @@ declare class Connector {
44
44
  *
45
45
  */
46
46
  private register;
47
+ private initMassaStationListener;
48
+ startMassaStationDiscovery(): Promise<void>;
47
49
  /**
48
50
  * This method sends a message from the webpage script to the content script.
49
51
  *
@@ -1 +1 @@
1
- {"version":3,"file":"Connector.d.ts","sourceRoot":"","sources":["../../src/connector/Connector.ts"],"names":[],"mappings":"AAaA,OAAO,EACL,iBAAiB,EACjB,sBAAsB,EACtB,uBAAuB,EACvB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACrB,MAAM,IAAI,CAAC;AAOZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,wBAAwB,CAAC;AAEzD,KAAK,gBAAgB,GAAG,CACtB,MAAM,EAAE,gBAAgB,EACxB,KAAK,EAAE,KAAK,GAAG,IAAI,KAChB,OAAO,CAAC;AAEb,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,sBAAsB,GACtB,mBAAmB,GACnB,qBAAqB,GACrB,uBAAuB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AC;AAE5B,MAAM,MAAM,gBAAgB,GACxB,MAAM,GACN,uBAAuB,GACvB,oBAAoB,GACpB,sBAAsB,GACtB,wBAAwB,GACxB,QAAQ,EAAE,GACV,MAAM,CAAC;AAEX;;;;;;GAMG;AACH,cAAM,SAAS;IACb,OAAO,CAAC,mBAAmB,CAAiC;IAC5D,OAAO,CAAC,eAAe,CAAgC;IACvD,OAAO,CAAC,oBAAoB,CAAwB;IAEpD;;;;;;;;;;;OAWG;;IAgBH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAqBhB,OAAO,CAAC,wBAAwB;IAWnB,0BAA0B;IAQvC;;;;;;;;;;;;;;;OAeG;IAEI,0BAA0B,CAC/B,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,iBAAiB,EAC1B,MAAM,EAAE,eAAe,EACvB,gBAAgB,EAAE,gBAAgB;IAgCpC;;;;;OAKG;IACI,kBAAkB,IAAI;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE;IAItD;;;;;;;OAOG;IACH,OAAO,CAAC,+BAA+B;CAuBxC;AAED,eAAO,MAAM,SAAS,WAAkB,CAAC"}
@@ -42,6 +42,8 @@ class Connector {
42
42
  constructor() {
43
43
  this.registeredProviders = {};
44
44
  this.pendingRequests = new Map();
45
+ this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery();
46
+ this.initMassaStationListener();
45
47
  this.register();
46
48
  // start listening to messages from content script
47
49
  document
@@ -77,16 +79,18 @@ class Connector {
77
79
  this.registeredProviders[payload.providerName] =
78
80
  providerEventTargetName;
79
81
  });
82
+ }
83
+ initMassaStationListener() {
84
+ this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
85
+ this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
86
+ });
87
+ this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
88
+ delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
89
+ });
90
+ }
91
+ async startMassaStationDiscovery() {
80
92
  try {
81
- // start MassaStation discovery
82
- this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery(1000);
83
- this.massaStationListener.startListening();
84
- this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
85
- this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
86
- });
87
- this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
88
- delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
89
- });
93
+ await this.massaStationListener.startListening();
90
94
  }
91
95
  catch (e) {
92
96
  console.log('MassaStation is not detected');
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,gBAAgB;AAChB,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,EAAE,OAAO,MAAM,CAAC;KACvB;CACF;AAQD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAOjD,oBAAY,iBAAiB;IAC3B,oBAAoB,kBAAkB;IACtC,qBAAqB,mBAAmB;IACxC,qBAAqB,mBAAmB;IACxC,oBAAoB,mBAAmB;IACvC,cAAc,oBAAoB;IAClC,WAAW,iBAAiB;IAC5B,0BAA0B,yBAAyB;IACnD,gBAAgB,uBAAuB;IACvC,eAAe,sBAAsB;IACrC,sBAAsB,6BAA6B;IACnD,aAAa,oBAAoB;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;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ACrC,sBAAsB,6BAA6B;IACnD,aAAa,oBAAoB;CAClC;AAED,MAAM,WAAW,mBAAmB;IAClC,WAAW,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;;GAQG;AACH,wBAAsB,SAAS,CAC7B,KAAK,UAAO,EACZ,OAAO,SAAO,EACd,YAAY,SAAM,GACjB,OAAO,CAAC,SAAS,EAAE,CAAC,CA6BtB;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,SAAsB,GAAG,IAAI,CAQ7E;AAED,OAAO,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEhE,OAAO,EACL,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,mBAAmB,EACnB,oBAAoB,EACpB,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,8BAA8B,EAC9B,qBAAqB,GACtB,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,wBAAwB,EACxB,sBAAsB,EACtB,uBAAuB,EACvB,wBAAwB,EACxB,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,QAAQ,GACT,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
package/dist/index.js CHANGED
@@ -37,6 +37,7 @@ async function providers(retry = true, timeout = 3000, pollInterval = 500) {
37
37
  if (timeout <= 0) {
38
38
  return [];
39
39
  }
40
+ await Connector_1.connector.startMassaStationDiscovery();
40
41
  return new Promise((resolve) => {
41
42
  let provider = [];
42
43
  for (const providerName of Object.keys(Connector_1.connector.getWalletProviders())) {
@@ -1,7 +1,6 @@
1
1
  import { IAccountBalanceResponse, IAccountDetails, IAccountSignResponse, ITransactionDetails } from '..';
2
2
  import { IAccount } from '../account/IAccount';
3
- import { Args } from '@massalabs/web3-utils';
4
- import { IContractReadOperationResponse } from '@massalabs/massa-web3';
3
+ import { Args, IContractReadOperationResponse } from '@massalabs/web3-utils';
5
4
  /**
6
5
  * This module contains the MassaStationAccount class. It is responsible for representing an account in
7
6
  * the MassaStation wallet.
@@ -1 +1 @@
1
- {"version":3,"file":"MassaStationAccount.d.ts","sourceRoot":"","sources":["../../src/massaStation/MassaStationAccount.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,IAAI,CAAC;AACZ,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAM/C,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EACL,8BAA8B,EAE/B,MAAM,uBAAuB,CAAC;AAmC/B;;;;;;;GAOG;AACH,qBAAa,mBAAoB,YAAW,QAAQ;IAClD,OAAO,CAAC,aAAa,CAAS;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,KAAK,CAAS;IAEtB;;;;;;;;;;;;OAYG;gBACgB,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM;IAM3E;;OAEG;IACI,OAAO,IAAI,MAAM;IAIxB;;OAEG;IACI,IAAI,IAAI,MAAM;IAIrB;;OAEG;IACI,YAAY,IAAI,MAAM;IAI7B;;;;OAIG;IACU,OAAO,IAAI,OAAO,CAAC,uBAAuB,CAAC;IAqBxD;;;;;OAKG;IACU,IAAI,CAAC,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAoB3E;;;;;;OAMG;IACU,QAAQ,CACnB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACU,SAAS,CACpB,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,mBAAmB,CAAC;IAoB/B;;;;;;OAMG;IACG,e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  export declare class MassaStationDiscovery extends EventEmitter {
32
- private readonly pollIntervalMillis;
33
- private timeoutId;
34
32
  private isDiscovered;
35
33
  /**
36
34
  * MassaStation constructor
@@ -48,24 +46,12 @@ export declare class MassaStationDiscovery extends EventEmitter {
48
46
  * @returns An instance of the MassaStation class.
49
47
  *
50
48
  */
51
- constructor(pollIntervalMillis: number);
52
- /**
53
- * A callback method that triggers a ping of the MassaStation's server
54
- *
55
- * @returns void
56
- */
57
- private callback;
58
- /**
59
- * A method to stop listening for a connection to MassaStation's server
60
- *
61
- * @returns void
62
- */
63
- stopListening(): void;
49
+ constructor();
64
50
  /**
65
51
  * A method to start listening for a connection to MassaStation's server.
66
52
  *
67
53
  * @returns void
68
54
  */
69
- startListening(): void;
55
+ startListening(): Promise<void>;
70
56
  }
71
57
  //# sourceMappingURL=MassaStationDiscovery.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"MassaStationDiscovery.d.ts","sourceRoot":"","sources":["../../src/massaStation/MassaStationDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC;;GAEG;AACH,eAAO,MAAM,2BAA2B,oCAAoC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;IAoBlC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IAnBtD,OAAO,CAAC,SAAS,CAAwB;IACzC,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;;;;;;;;;;;;OAeG;gBACiC,kBAAkB,EAAE,MAAM;IAS9D;;;;OAIG;YACW,QAAQ;IAkBtB;;;;OAIG;IACI,aAAa,IAAI,IAAI;IAI5B;;;;OAIG;IACI,cAAc,IAAI,IAAI;CAS9B"}
1
+ {"version":3,"file":"MassaStationDiscovery.d.ts","sourceRoot":"","sources":["../../src/massaStation/MassaStationDiscovery.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAGtC;;GAEG;AACH,eAAO,MAAM,2BAA2B,oCAAoC,CAAC;AAE7E;;GAEG;AACH,eAAO,MAAM,2BAA2B,gCAAgC,CAAC;AAEzE;;GAEG;AACH,eAAO,MAAM,6BAA6B,kCAAkC,CAAC;AAE7E;;;;;GAKG;AACH,qBAAa,qBAAsB,SAAQ,YAAY;IACrD,OAAO,CAAC,YAAY,CAAS;IAE7B;;;;;;;;;;;;;;;OAeG;;IAOH;;;;OAIG;IACU,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC;CAkB7C"}
@@ -12,7 +12,6 @@
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.MassaStationDiscovery = exports.ON_MASSA_STATION_DISCONNECTED = exports.ON_MASSA_STATION_DISCOVERED = exports.MASSA_STATION_DISCOVERY_URL = void 0;
14
14
  const events_1 = require("events");
15
- const time_1 = require("../utils/time");
16
15
  const RequestHandler_1 = require("./RequestHandler");
17
16
  /**
18
17
  * Url used for the MassaStation discovery and pinging the MassaStation server's index.html
@@ -49,22 +48,17 @@ class MassaStationDiscovery extends events_1.EventEmitter {
49
48
  * @returns An instance of the MassaStation class.
50
49
  *
51
50
  */
52
- constructor(pollIntervalMillis) {
51
+ constructor() {
53
52
  super();
54
- this.pollIntervalMillis = pollIntervalMillis;
55
- this.timeoutId = null;
56
53
  this.isDiscovered = false;
57
- // bind class methods
58
- this.callback = this.callback.bind(this);
59
- this.stopListening = this.stopListening.bind(this);
60
54
  this.startListening = this.startListening.bind(this);
61
55
  }
62
56
  /**
63
- * A callback method that triggers a ping of the MassaStation's server
57
+ * A method to start listening for a connection to MassaStation's server.
64
58
  *
65
59
  * @returns void
66
60
  */
67
- async callback() {
61
+ async startListening() {
68
62
  let resp = null;
69
63
  try {
70
64
  resp = await (0, RequestHandler_1.getRequest)(exports.MASSA_STATION_DISCOVERY_URL);
@@ -77,29 +71,9 @@ class MassaStationDiscovery extends events_1.EventEmitter {
77
71
  this.emit(exports.ON_MASSA_STATION_DISCOVERED);
78
72
  }
79
73
  if ((resp.isError || resp.error) && this.isDiscovered) {
74
+ this.isDiscovered = false;
80
75
  this.emit(exports.ON_MASSA_STATION_DISCONNECTED);
81
76
  }
82
77
  }
83
- /**
84
- * A method to stop listening for a connection to MassaStation's server
85
- *
86
- * @returns void
87
- */
88
- stopListening() {
89
- if (this.timeoutId)
90
- this.timeoutId.clear();
91
- }
92
- /**
93
- * A method to start listening for a connection to MassaStation's server.
94
- *
95
- * @returns void
96
- */
97
- startListening() {
98
- const that = this;
99
- if (this.timeoutId) {
100
- return;
101
- }
102
- this.timeoutId = new time_1.Timeout(this.pollIntervalMillis, () => that.callback());
103
- }
104
78
  }
105
79
  exports.MassaStationDiscovery = MassaStationDiscovery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massalabs/wallet-provider",
3
- "version": "1.2.1-dev.20230731160259",
3
+ "version": "1.2.1-dev.20230803113644",
4
4
  "description": "massa's wallet provider",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -53,8 +53,7 @@
53
53
  "bundle.min.js"
54
54
  ],
55
55
  "dependencies": {
56
- "@massalabs/massa-web3": "^1.21.0",
57
- "@massalabs/web3-utils": "^1.1.0",
56
+ "@massalabs/web3-utils": "^1.2.0",
58
57
  "axios": "^0.26.1",
59
58
  "bignumber.js": "^9.1.1",
60
59
  "buffer": "^6.0.3",