Skip to content

Commit

Permalink
Merge pull request #81 from secretkeylabs/update-btc-providers-array-…
Browse files Browse the repository at this point in the history
…name

replace webbtcProviders with btc_providers
  • Loading branch information
m-aboelenein authored Mar 15, 2024
2 parents 9f12d07 + ade6c77 commit 5d3fa14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions src/provider/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { type BitcoinProvider, type WebbtcProvider } from './types';
import { type BitcoinProvider, type Provider } from './types';

export async function getProviderOrThrow(
getProvider?: () => Promise<BitcoinProvider | undefined>
Expand All @@ -13,17 +13,17 @@ export async function getProviderOrThrow(
return provider;
}

export function getProviders(): WebbtcProvider[] {
if (!window.webbtc_providers) window.webbtc_providers = [];
return window.webbtc_providers;
export function getProviders(): Provider[] {
if (!window.btc_providers) window.btc_providers = [];
return window.btc_providers;
}

export function getProviderById(providerId: string) {
if (Array.isArray(window.webbtc_providers)) {
const provider = window.webbtc_providers.find((provider) => provider.id === providerId);
if (Array.isArray(window.btc_providers)) {
const provider = window.btc_providers.find((provider) => provider.id === providerId);
return provider?.id?.split('.').reduce((acc: any, part) => acc?.[part], window);
} else {
console.log('window.webbtc_providers is not defined or not an array');
console.log('window.btc_providers is not defined or not an array');
return undefined;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/provider/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export interface BitcoinProvider extends BaseBitcoinProvider {
getCapabilities?: (request: string) => Promise<GetCapabilitiesResponse>;
}

export interface WebbtcProvider {
export interface Provider {
id: string;
name: string;
icon: string;
Expand All @@ -50,6 +50,6 @@ declare global {
interface Window {
BitcoinProvider?: BitcoinProvider;
XverseProviders?: XverseProviders;
webbtc_providers?: WebbtcProvider[];
btc_providers?: Provider[];
}
}

0 comments on commit 5d3fa14

Please sign in to comment.