Skip to content

Commit

Permalink
Merge pull request #343 from mystic-lab/main
Browse files Browse the repository at this point in the history
Fix permission error: URGENT
  • Loading branch information
pyramation authored Oct 4, 2023
2 parents 4a66af6 + ed8465a commit cc8f5c0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
2 changes: 1 addition & 1 deletion wallets/cosmos-extension-metamask/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cosmos-kit/cosmos-extension-metamask",
"version": "0.1.6",
"version": "0.1.7",
"description": "cosmos-kit wallet connector for the official Cosmos Extension for Metamask",
"author": "joe@mysticlabs.xyz",
"contributors": [
Expand Down
16 changes: 7 additions & 9 deletions wallets/cosmos-extension-metamask/src/extension/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,22 @@ import {
SignType,
} from '@cosmos-kit/core';
import { SignOptions, WalletClient } from '@cosmos-kit/core';
import { isSnapInitialized, isSnapInstalled, CosmosSnap, suggestChain, Chain, CosmJSOfflineSigner } from '@cosmsnap/snapper';
import { CosmosSnap, suggestChain, Chain, CosmJSOfflineSigner, installSnap } from '@cosmsnap/snapper';
import { SignDoc } from '@keplr-wallet/types';

export class CosmosExensionClient implements WalletClient {
cosmos: CosmosSnap = new CosmosSnap();
snapInitialized: boolean = false;
snapInstalled: boolean = false;
export class CosmosExtensionClient implements WalletClient {
cosmos: CosmosSnap

constructor() {
isSnapInitialized().then(res => this.snapInitialized = res);
isSnapInstalled().then(res => this.snapInstalled = res);
this.cosmos = new CosmosSnap();
}

async addChain(chainInfo: ChainRecord) {
await suggestChain(chainInfo.chain as unknown as Chain)
}

async getSimpleAccount(chainId: string) {
const { address } = await this.cosmos.getAccount(chainId);
const { address } = await this.getAccount(chainId);
return {
namespace: 'cosmos',
chainId,
Expand All @@ -32,6 +29,7 @@ export class CosmosExensionClient implements WalletClient {
}

async getAccount(chainId: string) {
await installSnap();
const key = await this.cosmos.getAccount(chainId);
return {
address: key.address,
Expand Down Expand Up @@ -77,4 +75,4 @@ export class CosmosExensionClient implements WalletClient {
) {
return await this.cosmos.signDirect(chainId, signer, signDoc);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Wallet } from '@cosmos-kit/core';
import { MainWalletBase } from '@cosmos-kit/core';

import { ChainCosmosExtensionMetamaskSnap } from './chain-wallet';
import { CosmosExensionClient } from './client';
import { CosmosExtensionClient } from './client';

export class CosmosMetamaskExtensionWallet extends MainWalletBase {
constructor(walletInfo: Wallet) {
Expand All @@ -12,7 +12,7 @@ export class CosmosMetamaskExtensionWallet extends MainWalletBase {
async initClient() {
this.initingClient();
try {
this.initClientDone(new CosmosExensionClient());
this.initClientDone(new CosmosExtensionClient());
} catch (error) {
this.initClientError(error);
}
Expand Down

0 comments on commit cc8f5c0

Please sign in to comment.