@massalabs/wallet-provider 0.0.2-dev.20230719135650 → 0.0.2-dev.20230720090542
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 +22 -12
- package/dist/connector/Connector.d.ts.map +1 -1
- package/dist/connector/Connector.js +14 -9
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -3
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -257,15 +257,20 @@ class Connector {
|
|
|
257
257
|
this.registeredProviders[payload.providerName] =
|
|
258
258
|
providerEventTargetName;
|
|
259
259
|
});
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
this.
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
260
|
+
try {
|
|
261
|
+
// start MassaStation discovery
|
|
262
|
+
this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery(1000);
|
|
263
|
+
this.massaStationListener.startListening();
|
|
264
|
+
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
|
|
265
|
+
this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
|
|
266
|
+
});
|
|
267
|
+
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
|
|
268
|
+
delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
catch (e) {
|
|
272
|
+
console.log('MassaStation is not detected');
|
|
273
|
+
}
|
|
269
274
|
}
|
|
270
275
|
/**
|
|
271
276
|
* This method sends a message from the webpage script to the content script.
|
|
@@ -373,11 +378,12 @@ var AvailableCommands;
|
|
|
373
378
|
* Get the list of providers that are available to interact with.
|
|
374
379
|
*
|
|
375
380
|
* @param retry - If true, will retry to get the list of providers if none are available.
|
|
376
|
-
* @param
|
|
381
|
+
* @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
|
|
382
|
+
* @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
|
|
377
383
|
*
|
|
378
384
|
* @returns An array of providers.
|
|
379
385
|
*/
|
|
380
|
-
async function providers(retry = true, timeout =
|
|
386
|
+
async function providers(retry = true, pollInterval = 500, timeout = 3000) {
|
|
381
387
|
let provider = [];
|
|
382
388
|
while (provider.length === 0) {
|
|
383
389
|
for (const providerName of Object.keys(Connector_1.connector.getWalletProviders())) {
|
|
@@ -392,7 +398,11 @@ async function providers(retry = true, timeout = 500) {
|
|
|
392
398
|
}
|
|
393
399
|
// If no providers are available, wait and try again
|
|
394
400
|
if (retry && provider.length === 0) {
|
|
395
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
401
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
402
|
+
}
|
|
403
|
+
timeout -= pollInterval;
|
|
404
|
+
if (timeout <= 0) {
|
|
405
|
+
break;
|
|
396
406
|
}
|
|
397
407
|
}
|
|
398
408
|
return provider;
|
|
@@ -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,CAAC;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;;IAcH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;
|
|
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,CAAC;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;;IAcH;;;;;;;;;;OAUG;IACH,OAAO,CAAC,QAAQ;IAoChB;;;;;;;;;;;;;;;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"}
|
|
@@ -77,15 +77,20 @@ class Connector {
|
|
|
77
77
|
this.registeredProviders[payload.providerName] =
|
|
78
78
|
providerEventTargetName;
|
|
79
79
|
});
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
this.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
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
|
+
});
|
|
90
|
+
}
|
|
91
|
+
catch (e) {
|
|
92
|
+
console.log('MassaStation is not detected');
|
|
93
|
+
}
|
|
89
94
|
}
|
|
90
95
|
/**
|
|
91
96
|
* This method sends a message from the webpage script to the content script.
|
package/dist/index.d.ts
CHANGED
|
@@ -27,11 +27,12 @@ export interface ITransactionDetails {
|
|
|
27
27
|
* Get the list of providers that are available to interact with.
|
|
28
28
|
*
|
|
29
29
|
* @param retry - If true, will retry to get the list of providers if none are available.
|
|
30
|
-
* @param
|
|
30
|
+
* @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
|
|
31
|
+
* @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
|
|
31
32
|
*
|
|
32
33
|
* @returns An array of providers.
|
|
33
34
|
*/
|
|
34
|
-
export declare function providers(retry?: boolean, timeout?: number): Promise<IProvider[]>;
|
|
35
|
+
export declare function providers(retry?: boolean, pollInterval?: number, timeout?: number): Promise<IProvider[]>;
|
|
35
36
|
/**
|
|
36
37
|
* Manually register a provider to interact with.
|
|
37
38
|
*
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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;CACrB;A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AC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAE1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -28,11 +28,12 @@ var AvailableCommands;
|
|
|
28
28
|
* Get the list of providers that are available to interact with.
|
|
29
29
|
*
|
|
30
30
|
* @param retry - If true, will retry to get the list of providers if none are available.
|
|
31
|
-
* @param
|
|
31
|
+
* @param pollInterval - The timeout in milliseconds to wait between retries. default is 2000ms.
|
|
32
|
+
* @param timeout - The timeout in milliseconds to wait before giving up. default is 3000ms.
|
|
32
33
|
*
|
|
33
34
|
* @returns An array of providers.
|
|
34
35
|
*/
|
|
35
|
-
async function providers(retry = true, timeout =
|
|
36
|
+
async function providers(retry = true, pollInterval = 500, timeout = 3000) {
|
|
36
37
|
let provider = [];
|
|
37
38
|
while (provider.length === 0) {
|
|
38
39
|
for (const providerName of Object.keys(Connector_1.connector.getWalletProviders())) {
|
|
@@ -47,7 +48,11 @@ async function providers(retry = true, timeout = 500) {
|
|
|
47
48
|
}
|
|
48
49
|
// If no providers are available, wait and try again
|
|
49
50
|
if (retry && provider.length === 0) {
|
|
50
|
-
await new Promise((resolve) => setTimeout(resolve,
|
|
51
|
+
await new Promise((resolve) => setTimeout(resolve, pollInterval));
|
|
52
|
+
}
|
|
53
|
+
timeout -= pollInterval;
|
|
54
|
+
if (timeout <= 0) {
|
|
55
|
+
break;
|
|
51
56
|
}
|
|
52
57
|
}
|
|
53
58
|
return provider;
|