Skip to content

Commit

Permalink
Add create default config
Browse files Browse the repository at this point in the history
  • Loading branch information
aryzing committed Mar 27, 2024
1 parent 31ca133 commit 3b626fe
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"dependencies": {
"bitcoin-address-validation": "2.2.3",
"jsontokens": "4.0.1",
"lodash.omit": "4.5.0"
"lodash.omit": "4.5.0",
"@sats-connect/ui": "*"
},
"devDependencies": {
"@types/jest": "^29.2.6",
Expand Down
5 changes: 3 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
export * from './addresses';
export * from './request';
export * from './adapters';
export * from './addresses';
export * from './capabilities';
export * from './inscriptions';
export * from './messages';
export * from './provider';
export * from './request';
export * from './transactions';
export * from './types';
export * from './ui';
44 changes: 44 additions & 0 deletions src/ui/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { Config } from '@sats-connect/ui';
import { SupportedWallet } from 'src/provider';

export const xverseIcon =
'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgdmlld0JveD0iMCAwIDEwMiAxMDIiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGlkPSJJY29uX0FydCAoRWRpdCBNZSkiPgo8cmVjdCB3aWR0aD0iMTAyIiBoZWlnaHQ9IjEwMiIgZmlsbD0iIzE4MTgxOCIvPgo8ZyBpZD0iTG9nby9FbWJsZW0iIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMF8xMjIzKSI+CjxwYXRoIGlkPSJWZWN0b3IiIGQ9Ik03NC42NTQyIDczLjg4ODNWNjUuMjMxMkM3NC42NTQyIDY0Ljg4OCA3NC41MTc3IDY0LjU2MDYgNzQuMjc0NSA2NC4zMTc0TDM3LjQzOTcgMjcuNDgyNUM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IDQ3LjYzNTUgNjQuNzE1MSA0Ny4xNDIyTDc0LjY1NDEgMzcuMTg3M0M3NC43OTk0IDM3LjA0MTggNzQuODgxNiAzNi44NDQgNzQuODgxNiAzNi42MzcxVjI3LjkxODlDNzQuODgxNiAyNy40ODkyIDc0LjUzMzQgMjcuMTM5MSA3NC4xMDE3IDI3LjEzOTFMNjUuMjUzOCAyNy4xMjc3QzY1LjA0NyAyNy4xMjc3IDY0Ljg0OTIgMjcuMjA5NiA2NC43MDE0IDI3LjM1NTFMNTQuODA1NiAzNy4yMzVDNTQuMzE0NSAzNy43MjYgNTQuNjYyMyAzOC41NjcyIDU1LjM1NTcgMzguNTY3Mkg1NS4zNThaIiBmaWxsPSIjRUU3QTMwIi8+CjwvZz4KPC9nPgo8ZGVmcz4KPGNsaXBQYXRoIGlkPSJjbGlwMF8yMF8xMjIzIj4KPHJlY3Qgd2lkdGg9IjQ3LjgxMjUiIGhlaWdodD0iNDcuODEyNSIgZmlsbD0id2hpdGUiIHRyYW5zZm9ybT0idHJhbnNsYXRlKDI3LjA5MzggMjcuMDkzOCkiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K';

export function createDefaultConfig(providers: SupportedWallet[]): Config {
const config: Config = { providers: [] };
// Xverse
const xverseProvider = providers.find(
(provider) => provider.id === 'XverseProviders.BitcoinProvider'
);
config.providers.push(
xverseProvider
? xverseProvider
: {
id: 'XverseProviders.BitcoinProvider',
name: 'Xverse',
icon: xverseIcon,
isInstalled: false,
chromeWebStoreUrl:
'https://chromewebstore.google.com/detail/xverse-wallet/idnnbdplmphpflfnlkomgpfbpcgelopg',
googlePlayStoreUrl:
'https://play.google.com/store/apps/details?id=com.secretkeylabs.xverse',
iOSAppStoreUrl: 'https://apps.apple.com/app/xverse-bitcoin-web3-wallet/id1552272513',
webUrl: 'https://www.xverse.app/',
}
);

// Unisat
const unisatProvider = providers.find((provider) => provider.id === 'unisat');
if (unisatProvider && unisatProvider.isInstalled) {
config.providers.push(unisatProvider);
}

// Rest
config.providers.concat(
providers.filter((provider) => {
return provider.id !== 'xverseProviders.bitcoinProvider' && provider.id !== 'unisat';
})
);

return config;
}

0 comments on commit 3b626fe

Please sign in to comment.