Skip to content

Commit

Permalink
Update bearby and remove useless functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Ben-Rey committed Feb 7, 2024
1 parent 121036a commit a97fafd
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 34 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
"dist"
],
"dependencies": {
"@hicaru/bearby.js": "^0.5.5",
"@hicaru/bearby.js": "^0.5.6",
"@massalabs/web3-utils": "^1.4.8",
"axios": "^0.26.1",
"bignumber.js": "^9.1.1",
Expand Down
1 change: 0 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,5 @@ export { connectBearby, disconnectBearby } from './bearbyWallet/BearbyConnect';

export {
isMassaStationAvailable,
isMassaWalletInstalled,
isMassaWalletEnabled,
} from './massaStation/MassaStationDiscovery';
23 changes: 0 additions & 23 deletions src/massaStation/MassaStationDiscovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,6 @@ export async function isMassaStationAvailable(): Promise<boolean> {
return !response.isError;
}

export async function isMassaWalletInstalled(): Promise<boolean> {
const response = await fetchPluginData();
if (response.isError) return false;
return Boolean(findWalletPlugin(response.result));
}

export async function isMassaWalletEnabled(): Promise<boolean> {
const response = await fetchPluginData();

Expand All @@ -36,20 +30,3 @@ export async function isMassaWalletEnabled(): Promise<boolean> {
const walletPlugin = findWalletPlugin(response.result);
return walletPlugin && walletPlugin.status === 'Up';
}

export async function isMassaStationAndWalletPluginInstalled(): Promise<boolean> {
const response = await fetchPluginData();
if (response.isError) {
console.warn('Massa Station plugin data fetch error.');
return false;
}

const walletPlugin = findWalletPlugin(response.result);

if (!walletPlugin) {
console.warn('Massa Wallet plugin is not installed.');
return false;
}

return true;
}
7 changes: 2 additions & 5 deletions src/providersManager/providerList.ts
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
import { web3 } from '@hicaru/bearby.js';
import { BearbyProvider } from '../bearbyWallet/BearbyProvider';
import { isMassaStationAndWalletPluginInstalled } from '../massaStation/MassaStationDiscovery';
import { isMassaWalletEnabled } from '../massaStation/MassaStationDiscovery';
import { MassaStationProvider } from '../massaStation/MassaStationProvider';
import { IProvider } from '../provider/IProvider';

export type ProviderList = {
name: string;
checkInstalled: () => Promise<boolean>;
createInstance: () => IProvider;
isInstalled: boolean;
};

export const providerList: ProviderList[] = [
{
name: 'BEARBY',
checkInstalled: async () => web3.wallet.installed,
createInstance: () => new BearbyProvider(),
isInstalled: false,
},
{
name: 'MASSA_STATION',
checkInstalled: isMassaStationAndWalletPluginInstalled,
checkInstalled: isMassaWalletEnabled,
createInstance: () => new MassaStationProvider(),
isInstalled: false,
},
];

0 comments on commit a97fafd

Please sign in to comment.