Skip to content

Commit

Permalink
Merge pull request #62 from nabla-studio/DavideSegullo/feat-add_wallets
Browse files Browse the repository at this point in the history
Feat: add wallets
  • Loading branch information
DavideSegullo authored Feb 2, 2024
2 parents 688baac + efbc9d9 commit fd31860
Show file tree
Hide file tree
Showing 22 changed files with 140 additions and 21 deletions.
31 changes: 21 additions & 10 deletions examples/vue3/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,30 @@ import { quirksPlugin } from '@quirks/vue';

const app = createApp(App);

import {
bitsong,
bitsongAssetList,
osmosis,
osmosisAssetList,
} from '@nabla-studio/chain-registry';
import { osmosis, osmosisAssetList } from '@nabla-studio/chain-registry';
import type { Config } from '@quirks/store';
import { keplrExtension, keplrMobile, leapExtension } from '@quirks/wallets';
import {
cosmostationMobile,
keplrExtension,
keplrMobile,
leapExtension,
okxExtension,
stationExtension,
xdefiExtension,
} from '@quirks/wallets';

const config: Config = {
wallets: [keplrExtension, leapExtension, keplrMobile],
chains: [osmosis, bitsong],
assetsLists: [osmosisAssetList, bitsongAssetList],
wallets: [
keplrExtension,
leapExtension,
keplrMobile,
xdefiExtension,
stationExtension,
okxExtension,
cosmostationMobile,
],
chains: [osmosis],
assetsLists: [osmosisAssetList],
walletConnectOptions: {
providerOpts: {
logger: 'info',
Expand Down
6 changes: 1 addition & 5 deletions examples/vue3/src/views/HomeView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,6 @@ const { connect, disconnect, connected, status, walletName } = useConnect();
const { pairingURI } = useWalletConnect();
const open = async (chainName: string) => {
const suggestChains = (await import('@quirks/store')).suggestChains;
await suggestChains(chainName, [
{ chain: bitsong, assetList: bitsongAssetList, name: 'bitsong' },
]);
await connect(chainName);
};
Expand Down Expand Up @@ -68,7 +64,7 @@ const send = async () => {
<div v-for="wallet in wallets" :key="wallet.options.wallet_name">
<button @click="open(wallet.options.wallet_name)">
<img
:src="wallet.logoLight"
:src="wallet.logoLight ?? wallet.logoDark"
:alt="wallet.options.pretty_name"
height="48px"
width="48px"
Expand Down
1 change: 1 addition & 0 deletions packages/wallet-registry/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface CosmosWallet {
website?: string;
git_repo?: string;
supported_chains: string[];
connection_type?: 'browser_extension' | 'wallet_connect';
features?: ('suggest_chain' | 'get_supported_chains' | 'icns')[];
platforms: {
device: 'mobile' | 'tablet' | 'desktop' | 'other';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const cosmostationextension: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'cosmostationextention',
pretty_name: 'Cosmostation',
connection_type: 'browser_extension',
website: 'https://www.cosmostation.io/',
git_repo: 'https://github.com/cosmostation/cosmostation-chrome-extension',
supported_chains: [
Expand Down
13 changes: 12 additions & 1 deletion packages/wallet-registry/src/wallets/cosmostationmobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { CosmosWallet } from '../types';
export const cosmostationmobile: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'cosmostation',
pretty_name: 'Cosmostation',
pretty_name: 'Cosmostation Mobile',
connection_type: 'wallet_connect',
website: 'https://www.cosmostation.io/',
git_repo: 'https://github.com/cosmostation/cosmostation-android',
supported_chains: [
Expand Down Expand Up @@ -89,12 +90,22 @@ export const cosmostationmobile: CosmosWallet = {
layout: 'logomark',
},
],
wallet_connect: {
deeplink: {
path: {
android: 'wc',
ios: 'wc',
},
},
},
mobile: {
ios: {
bundle_identifier: 'io.wannabit.cosmostation',
schema: 'cosmostation',
},
android: {
package_name: 'wannabit.io.cosmostaion',
schema: 'cosmostation',
},
},
};
1 change: 1 addition & 0 deletions packages/wallet-registry/src/wallets/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './xdefiextension';
export * from './trustwalletmobile';
export * from './okxextension';
export * from './leapmobile';
export * from './leapextension';
export * from './keplrmobile';
Expand Down
1 change: 1 addition & 0 deletions packages/wallet-registry/src/wallets/keplrextension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const keplrextension: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'keplrextension',
pretty_name: 'Keplr',
connection_type: 'browser_extension',
website: 'https://www.keplr.app/',
git_repo: 'https://github.com/chainapsis/keplr-wallet',
supported_chains: [
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet-registry/src/wallets/keplrmobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { CosmosWallet } from '../types';
export const keplrmobile: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'keplrmobile',
pretty_name: 'Keplr',
pretty_name: 'Keplr Mobile',
connection_type: 'wallet_connect',
website: 'https://www.keplr.app/',
git_repo: 'https://github.com/chainapsis/keplr-wallet',
supported_chains: [
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet-registry/src/wallets/leapextension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { CosmosWallet } from '../types';
export const leapextension: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'leapextension',
pretty_name: 'Leap Cosmos Wallet',
pretty_name: 'Leap',
connection_type: 'browser_extension',
website: 'https://www.leapwallet.io/',
git_repo: '',
supported_chains: [
Expand Down
3 changes: 2 additions & 1 deletion packages/wallet-registry/src/wallets/leapmobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ import type { CosmosWallet } from '../types';
export const leapmobile: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'leapmobile',
pretty_name: 'Leap cosmos',
pretty_name: 'Leap Mobile',
connection_type: 'wallet_connect',
website: 'https://leapwallet.io',
git_repo: '',
supported_chains: [
Expand Down
39 changes: 39 additions & 0 deletions packages/wallet-registry/src/wallets/okxextension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import type { CosmosWallet } from '../types';

export const okxextension: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'okxextension',
pretty_name: 'OKX',
connection_type: 'browser_extension',
website: 'https://www.okx.com/',
git_repo: 'https://github.com/okx',
supported_chains: ['cosmoshub', 'osmosis'],
features: [],
platforms: [
{
device: 'desktop',
type: 'extension',
platform: 'chrome',
install_link:
'https://chrome.google.com/webstore/detail/okx-wallet/mcohilncbfahbmgdjkbpemcciiolgcge',
},
{
device: 'desktop',
type: 'extension',
platform: 'firefox',
install_link:
'https://addons.mozilla.org/zh-CN/firefox/addon/okexwallet/',
},
],
images: [
{
png: 'https://raw.githubusercontent.com/cosmos/wallet-registry/main/wallets/okxextension/images/logo.png',
theme: {
primary_color_hex: '#000000',
circle: false,
dark_mode: true,
},
layout: 'logomark',
},
],
};
1 change: 1 addition & 0 deletions packages/wallet-registry/src/wallets/trustwalletmobile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const trustwalletmobile: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'trustwalletmobile',
pretty_name: 'Trust Wallet',
connection_type: 'wallet_connect',
website: 'https://www.trustwallet.com',
git_repo: 'https://github.com/trustwallet',
supported_chains: [
Expand Down
1 change: 1 addition & 0 deletions packages/wallet-registry/src/wallets/xdefiextension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const xdefiextension: CosmosWallet = {
$schema: '../../wallet.schema.json',
wallet_name: 'xdefiextension',
pretty_name: 'xDefi',
connection_type: 'browser_extension',
website: 'https://www.xdefi.io/',
git_repo: '',
supported_chains: [
Expand Down
6 changes: 6 additions & 0 deletions packages/wallets/src/cosmostation-mobile/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { WCWallet } from '@quirks/core';
import { cosmostationWalletMobileConnectOptions } from './registry';

const cosmostationMobile = new WCWallet(cosmostationWalletMobileConnectOptions);

export { cosmostationMobile };
10 changes: 10 additions & 0 deletions packages/wallets/src/cosmostation-mobile/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { WalletConnectionTypes, type WalletOptions } from '@quirks/core';
import { cosmostationmobile } from '@nabla-studio/wallet-registry';

export const cosmostationWalletMobileConnectOptions: WalletOptions = {
...cosmostationmobile,
connectionType: WalletConnectionTypes.WALLET_CONNECT,
events: {
keystorechange: 'accountsChanged',
},
};
2 changes: 2 additions & 0 deletions packages/wallets/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ export * from './leap';
export * from './cosmostation';
export * from './xdefi';
export * from './station';
export * from './okx';
export * from './wallet-connect';
export * from './keplr-mobile';
export * from './leap-mobile';
export * from './cosmostation-mobile';
export * from './utils';
export * from './types';
4 changes: 3 additions & 1 deletion packages/wallets/src/keplr/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ import type { Keplr } from '@keplr-wallet/types';
import Long from 'long';
import { getChainInfo } from '../utils';

export class KeplrWalletExtension extends ExtensionWallet<Keplr> {
export class KeplrWalletExtension<
T extends Keplr = Keplr,
> extends ExtensionWallet<T> {
constructor(options: WalletOptions) {
super(options);
}
Expand Down
11 changes: 11 additions & 0 deletions packages/wallets/src/okx/extension.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { assertIsDefined } from '@quirks/core';
import { KeplrWalletExtension } from '../keplr/extension';
import { OKX } from './types';

export class OKXWalletExtension extends KeplrWalletExtension<OKX> {
override async disable(): Promise<void> {
assertIsDefined(this.client);

return this.client.disconnect();
}
}
6 changes: 6 additions & 0 deletions packages/wallets/src/okx/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { OKXWalletExtension } from './extension';
import { okxExtensionOptions } from './registry';

const okxExtension = new OKXWalletExtension(okxExtensionOptions);

export { okxExtension };
11 changes: 11 additions & 0 deletions packages/wallets/src/okx/registry.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { WalletConnectionTypes, type WalletOptions } from '@quirks/core';
import { okxextension } from '@nabla-studio/wallet-registry';

export const okxExtensionOptions: WalletOptions = {
...okxextension,
connectionType: WalletConnectionTypes.EXTENSION,
windowKey: 'okxwallet.keplr',
events: {
keystorechange: 'okxwallet_keystorechange',
},
};
5 changes: 5 additions & 0 deletions packages/wallets/src/okx/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import type { Keplr } from '@keplr-wallet/types';

export interface OKX extends Keplr {
disconnect: () => Promise<void>;
}

0 comments on commit fd31860

Please # to comment.