Skip to content

Commit

Permalink
don't call experiementalSuggestChain() if it's natively supported alr…
Browse files Browse the repository at this point in the history
…eady. No need to register.
  • Loading branch information
pyramation committed Jun 18, 2024
1 parent d5f38a3 commit 90b3184
Show file tree
Hide file tree
Showing 5 changed files with 99 additions and 14 deletions.
27 changes: 14 additions & 13 deletions packages/core/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ export interface Metadata {

export interface AppUrl {
native?:
| string
| {
android?: string;
ios?: string;
macos?: string;
windows?: string;
};
| string
| {
android?: string;
ios?: string;
macos?: string;
windows?: string;
};
universal?: string;
}

Expand All @@ -82,14 +82,15 @@ export interface Wallet {
mobileDisabled: boolean | (() => boolean);
description?: string;
rejectMessage?:
| {
source: string; // message from wallet app
target?: string; // message stored in walletManager, default 'Request Rejected!'
}
| string; // message from wallet app
| {
source: string; // message from wallet app
target?: string; // message stored in walletManager, default 'Request Rejected!'
}
| string; // message from wallet app
rejectCode?: number; // code from wallet app
connectEventNamesOnWindow?: string[];
connectEventNamesOnClient?: string[];
supportedChains?: string[]; // array of supported chains
downloads?: DownloadInfo[];
logo?: string | { major: string; minor: string };
walletconnect?: {
Expand Down Expand Up @@ -244,7 +245,7 @@ export interface WalletClient {
export type WalletAdapter = ChainWalletBase | MainWalletBase;

export interface IChainWallet {
new (walletInfo: Wallet, chainInfo: ChainRecord): ChainWalletBase;
new(walletInfo: Wallet, chainInfo: ChainRecord): ChainWalletBase;
}

export type NameServiceName = string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import {
} from '@cosmos-kit/core';
import Long from 'long';

import { Mock } from './types';
import { DirectSignDoc, WalletClient } from '../../../src/types';
import { Mock } from './types';

export class MockClient implements WalletClient {
readonly client: Mock;
Expand Down
16 changes: 16 additions & 0 deletions wallets/keplr-extension/src/extension/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ import {
import { BroadcastMode, Keplr } from '@keplr-wallet/types';
import Long from 'long';

import { keplrExtensionInfo } from './registry';

export class KeplrClient implements WalletClient {
readonly client: Keplr;
private _defaultSignOptions: SignOptions = {
Expand Down Expand Up @@ -121,6 +123,20 @@ export class KeplrClient implements WalletClient {
}

async addChain(chainInfo: ChainRecord) {
// TODO later allow walletInfo getter to be available here
// make this more generic
if (
keplrExtensionInfo.supportedChains &&
keplrExtensionInfo.supportedChains.length
) {
if (keplrExtensionInfo.supportedChains.includes(chainInfo.name)) {
console.warn(
`${chainInfo.name} is already added. No need to call experimentalSuggestChain()`
);
return;
}
}

const suggestChain = chainRegistryChainToKeplr(
chainInfo.chain,
chainInfo.assetList ? [chainInfo.assetList] : []
Expand Down
28 changes: 28 additions & 0 deletions wallets/keplr-extension/src/extension/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,34 @@ export const keplrExtensionInfo: Wallet = {
source: 'Request rejected',
},
connectEventNamesOnWindow: ['keplr_keystorechange'],
supportedChains: [
'cosmoshub',
'osmosis',
'secretnetwork',
'regen',
'akash',
'sifchain',
'stargaze',
'sentinel',
'persistence',
'kava',
'cryptoorgchain',
'irisnet',
'agoric',
'axelar',
'certik',
'ixo',
'emoney',
'juno',
'sommelier',
'umee',
'evmos',
'bostrom',
'starname',
'gravitybridge',
'stride',
'tgrade',
],
downloads: [
{
device: 'desktop',
Expand Down
40 changes: 40 additions & 0 deletions wallets/keplr-mobile/src/wallet-connect/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,46 @@ export const keplrMobileInfo: Wallet = {
},
],
connectEventNamesOnWindow: ['keplr_keystorechange'],
supportedChains: [
'agoric',
'akash',
'axelar',
'bitcanna',
'bitsong',
'bostrom',
'certik',
'cheqd',
'chihuahua',
'comdex',
'cosmoshub',
'cryptoorgchain',
'desmos',
'dig',
'emoney',
'evmos',
'gravitybridge',
'injective',
'irisnet',
'ixo',
'juno',
'ki',
'likecoin',
'lumnetwork',
'osmosis',
'panacea',
'persistence',
'regen',
'secretnetwork',
'sentinel',
'sifchain',
'sommelier',
'stargaze',
'starname',
'terra',
'tick',
'umee',
'vidulum',
],
walletconnect: {
name: 'Keplr',
projectId:
Expand Down

0 comments on commit 90b3184

Please sign in to comment.