@injectivelabs/wallet-cosmostation 1.16.24 → 1.16.25-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +0,0 @@
1
- import type { ChainId, CosmosChainId, TestnetCosmosChainId } from '@injectivelabs/ts-types';
2
- export declare class CosmostationWallet {
3
- private chainId;
4
- constructor(chainId: CosmosChainId | TestnetCosmosChainId | ChainId);
5
- static isChainIdSupported(chainId: CosmosChainId): Promise<boolean>;
6
- checkChainIdSupport(): Promise<boolean>;
7
- getCosmostationWallet(): Promise<typeof import("@cosmostation/extension-client/cosmos.js")>;
8
- }
@@ -1,40 +0,0 @@
1
- import { cosmos, InstallError } from '@cosmostation/extension-client';
2
- import { ErrorType, UnspecifiedErrorCode, CosmosWalletException, } from '@injectivelabs/exceptions';
3
- export class CosmostationWallet {
4
- chainId;
5
- constructor(chainId) {
6
- this.chainId = chainId;
7
- }
8
- static async isChainIdSupported(chainId) {
9
- return new CosmostationWallet(chainId).checkChainIdSupport();
10
- }
11
- async checkChainIdSupport() {
12
- const { chainId: actualChainId } = this;
13
- const provider = await this.getCosmostationWallet();
14
- const chainName = actualChainId.split('-');
15
- try {
16
- const supportedChainIds = await provider.getSupportedChainIds();
17
- return !!supportedChainIds.official.find((chainId) => chainId === actualChainId);
18
- }
19
- catch {
20
- throw new CosmosWalletException(new Error(`Cosmostation doesn't support ${chainName[0] || actualChainId} network. Please use another Cosmos wallet`));
21
- }
22
- }
23
- async getCosmostationWallet() {
24
- try {
25
- const provider = await cosmos();
26
- return provider;
27
- }
28
- catch (e) {
29
- if (e instanceof InstallError) {
30
- throw new CosmosWalletException(new Error('Please install the Cosmostation extension'), {
31
- code: UnspecifiedErrorCode,
32
- type: ErrorType.WalletNotInstalledError,
33
- });
34
- }
35
- throw new CosmosWalletException(new Error(e.message), {
36
- code: UnspecifiedErrorCode,
37
- });
38
- }
39
- }
40
- }