@massalabs/wallet-provider 1.4.2-dev.20230920152410 → 1.4.2-dev.20230925081919
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 +26 -16
- package/bundle.min.js +1 -1
- package/dist/cmd/connector/Connector.d.ts +8 -3
- package/dist/cmd/connector/Connector.d.ts.map +1 -1
- package/dist/cmd/connector/Connector.js +11 -2
- package/dist/cmd/connector/Connector.js.map +1 -1
- package/dist/cmd/index.d.ts.map +1 -1
- package/dist/cmd/index.js +1 -1
- package/dist/cmd/index.js.map +1 -1
- package/dist/cmd/massaStation/MassaStationDiscovery.d.ts +1 -1
- package/dist/cmd/massaStation/MassaStationDiscovery.d.ts.map +1 -1
- package/dist/cmd/massaStation/MassaStationDiscovery.js +12 -12
- package/dist/cmd/massaStation/MassaStationDiscovery.js.map +1 -1
- package/dist/cmd/massaStation/MassaStationProvider.d.ts +3 -1
- package/dist/cmd/massaStation/MassaStationProvider.d.ts.map +1 -1
- package/dist/cmd/massaStation/MassaStationProvider.js +2 -1
- package/dist/cmd/massaStation/MassaStationProvider.js.map +1 -1
- package/dist/cmd/massaStation/types.d.ts +9 -0
- package/dist/cmd/massaStation/types.d.ts.map +1 -1
- package/dist/cmd/massaStation/types.js.map +1 -1
- package/dist/connector/Connector.d.ts +8 -3
- package/dist/connector/Connector.d.ts.map +1 -1
- package/dist/connector/Connector.js +11 -2
- package/dist/esm/connector/Connector.d.ts +8 -3
- package/dist/esm/connector/Connector.d.ts.map +1 -1
- package/dist/esm/connector/Connector.js +11 -2
- package/dist/esm/connector/Connector.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/massaStation/MassaStationDiscovery.d.ts +1 -1
- package/dist/esm/massaStation/MassaStationDiscovery.d.ts.map +1 -1
- package/dist/esm/massaStation/MassaStationDiscovery.js +12 -12
- package/dist/esm/massaStation/MassaStationDiscovery.js.map +1 -1
- package/dist/esm/massaStation/MassaStationProvider.d.ts +3 -1
- package/dist/esm/massaStation/MassaStationProvider.d.ts.map +1 -1
- package/dist/esm/massaStation/MassaStationProvider.js +4 -3
- package/dist/esm/massaStation/MassaStationProvider.js.map +1 -1
- package/dist/esm/massaStation/types.d.ts +9 -0
- package/dist/esm/massaStation/types.d.ts.map +1 -1
- package/dist/esm/massaStation/types.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/massaStation/MassaStationDiscovery.d.ts +1 -1
- package/dist/massaStation/MassaStationDiscovery.d.ts.map +1 -1
- package/dist/massaStation/MassaStationDiscovery.js +12 -12
- package/dist/massaStation/MassaStationProvider.d.ts +3 -1
- package/dist/massaStation/MassaStationProvider.d.ts.map +1 -1
- package/dist/massaStation/MassaStationProvider.js +2 -1
- package/dist/massaStation/types.d.ts +9 -0
- package/dist/massaStation/types.d.ts.map +1 -1
- package/package.json +1 -1
package/bundle.js
CHANGED
|
@@ -6486,6 +6486,7 @@ class Connector {
|
|
|
6486
6486
|
*/
|
|
6487
6487
|
constructor() {
|
|
6488
6488
|
this.registeredProviders = {};
|
|
6489
|
+
this.providersInfo = {};
|
|
6489
6490
|
if (typeof document !== 'undefined') {
|
|
6490
6491
|
this.pendingRequests = new Map();
|
|
6491
6492
|
this.massaStationListener = new MassaStationDiscovery_1.MassaStationDiscovery();
|
|
@@ -6531,8 +6532,9 @@ class Connector {
|
|
|
6531
6532
|
}
|
|
6532
6533
|
}
|
|
6533
6534
|
initMassaStationListener() {
|
|
6534
|
-
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, () => {
|
|
6535
|
+
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCOVERED, (walletModule) => {
|
|
6535
6536
|
this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = `${exports.MASSA_WINDOW_OBJECT}_${MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME}`;
|
|
6537
|
+
this.providersInfo[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME] = walletModule;
|
|
6536
6538
|
});
|
|
6537
6539
|
this.massaStationListener.on(MassaStationDiscovery_1.ON_MASSA_STATION_DISCONNECTED, () => {
|
|
6538
6540
|
delete this.registeredProviders[MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME];
|
|
@@ -6543,7 +6545,7 @@ class Connector {
|
|
|
6543
6545
|
await this.massaStationListener.startListening();
|
|
6544
6546
|
}
|
|
6545
6547
|
catch (e) {
|
|
6546
|
-
console.log('MassaStation
|
|
6548
|
+
console.log('get MassaStation provider error: ', e);
|
|
6547
6549
|
}
|
|
6548
6550
|
}
|
|
6549
6551
|
/**
|
|
@@ -6591,6 +6593,13 @@ class Connector {
|
|
|
6591
6593
|
getWalletProviders() {
|
|
6592
6594
|
return this.registeredProviders;
|
|
6593
6595
|
}
|
|
6596
|
+
/**
|
|
6597
|
+
* This method returns the provider wallet info.
|
|
6598
|
+
*
|
|
6599
|
+
*/
|
|
6600
|
+
getProviderInfo(providerName) {
|
|
6601
|
+
return this.providersInfo[providerName];
|
|
6602
|
+
}
|
|
6594
6603
|
/**
|
|
6595
6604
|
* This method handles the response from the content script by
|
|
6596
6605
|
* calling the response callback with the response and error objects.
|
|
@@ -6693,7 +6702,7 @@ function getProviderInstances() {
|
|
|
6693
6702
|
const availableProviders = Object.keys(Connector_1.connector.getWalletProviders());
|
|
6694
6703
|
const providerInstances = availableProviders.map((providerName) => {
|
|
6695
6704
|
if (providerName === MassaStationProvider_1.MASSA_STATION_PROVIDER_NAME) {
|
|
6696
|
-
return new MassaStationProvider_1.MassaStationProvider();
|
|
6705
|
+
return new MassaStationProvider_1.MassaStationProvider(Connector_1.connector.getProviderInfo(providerName));
|
|
6697
6706
|
}
|
|
6698
6707
|
else {
|
|
6699
6708
|
return new Provider_1.Provider(providerName);
|
|
@@ -7087,7 +7096,7 @@ const RequestHandler_1 = __webpack_require__(/*! ./RequestHandler */ "./src/mass
|
|
|
7087
7096
|
/**
|
|
7088
7097
|
* Url used for the MassaStation discovery and pinging the MassaStation server's index.html
|
|
7089
7098
|
*/
|
|
7090
|
-
exports.MASSA_STATION_DISCOVERY_URL = 'https://station.massa/
|
|
7099
|
+
exports.MASSA_STATION_DISCOVERY_URL = 'https://station.massa/plugin-manager';
|
|
7091
7100
|
/**
|
|
7092
7101
|
* A message emitted on successful MassaStation discovery
|
|
7093
7102
|
*/
|
|
@@ -7096,6 +7105,8 @@ exports.ON_MASSA_STATION_DISCOVERED = 'ON_MASSA_STATION_DISCOVERED';
|
|
|
7096
7105
|
* A message emitted on MassaStation disconnect
|
|
7097
7106
|
*/
|
|
7098
7107
|
exports.ON_MASSA_STATION_DISCONNECTED = 'ON_MASSA_STATION_DISCONNECTED';
|
|
7108
|
+
const MS_WALLET_PLUGIN_NAME = 'Massa Wallet';
|
|
7109
|
+
const MS_WALLET_PLUGIN_AUTHOR = 'Massa Labs';
|
|
7099
7110
|
/**
|
|
7100
7111
|
* This file defines a TypeScript class named MassaStation.
|
|
7101
7112
|
* The class is being used to recursively ping MassaStation's server
|
|
@@ -7130,18 +7141,16 @@ class MassaStationDiscovery extends events_1.EventEmitter {
|
|
|
7130
7141
|
* @returns void
|
|
7131
7142
|
*/
|
|
7132
7143
|
async startListening() {
|
|
7133
|
-
|
|
7134
|
-
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7139
|
-
|
|
7140
|
-
|
|
7141
|
-
this.isDiscovered = true;
|
|
7142
|
-
this.emit(exports.ON_MASSA_STATION_DISCOVERED);
|
|
7144
|
+
const resp = await (0, RequestHandler_1.getRequest)(exports.MASSA_STATION_DISCOVERY_URL, 2000);
|
|
7145
|
+
if (!resp.isError) {
|
|
7146
|
+
const walletModule = resp.result.find((module) => module.name === MS_WALLET_PLUGIN_NAME &&
|
|
7147
|
+
module.author === MS_WALLET_PLUGIN_AUTHOR);
|
|
7148
|
+
if (walletModule) {
|
|
7149
|
+
this.isDiscovered = true;
|
|
7150
|
+
this.emit(exports.ON_MASSA_STATION_DISCOVERED, walletModule);
|
|
7151
|
+
}
|
|
7143
7152
|
}
|
|
7144
|
-
if (
|
|
7153
|
+
else if (this.isDiscovered) {
|
|
7145
7154
|
this.isDiscovered = false;
|
|
7146
7155
|
this.emit(exports.ON_MASSA_STATION_DISCONNECTED);
|
|
7147
7156
|
}
|
|
@@ -7194,7 +7203,8 @@ class MassaStationProvider {
|
|
|
7194
7203
|
* @param providerName - The name of the provider.
|
|
7195
7204
|
* @returns An instance of the Provider class.
|
|
7196
7205
|
*/
|
|
7197
|
-
constructor() {
|
|
7206
|
+
constructor(infos) {
|
|
7207
|
+
this.infos = infos;
|
|
7198
7208
|
this.providerName = exports.MASSA_STATION_PROVIDER_NAME;
|
|
7199
7209
|
}
|
|
7200
7210
|
/**
|