From ed8465ae98f3b1770028bddb1038a3116507dcfd Mon Sep 17 00:00:00 2001 From: Joe Schnetzler Date: Wed, 4 Oct 2023 13:58:48 -0400 Subject: [PATCH] Fix permission error --- wallets/cosmos-extension-metamask/package.json | 2 +- .../src/extension/client.ts | 16 +++++++--------- .../src/extension/main-wallet.ts | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/wallets/cosmos-extension-metamask/package.json b/wallets/cosmos-extension-metamask/package.json index 4df264e92..1a71461eb 100644 --- a/wallets/cosmos-extension-metamask/package.json +++ b/wallets/cosmos-extension-metamask/package.json @@ -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": [ diff --git a/wallets/cosmos-extension-metamask/src/extension/client.ts b/wallets/cosmos-extension-metamask/src/extension/client.ts index 5b03661a0..668c2e7ab 100644 --- a/wallets/cosmos-extension-metamask/src/extension/client.ts +++ b/wallets/cosmos-extension-metamask/src/extension/client.ts @@ -5,17 +5,14 @@ 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) { @@ -23,7 +20,7 @@ export class CosmosExensionClient implements WalletClient { } async getSimpleAccount(chainId: string) { - const { address } = await this.cosmos.getAccount(chainId); + const { address } = await this.getAccount(chainId); return { namespace: 'cosmos', chainId, @@ -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, @@ -77,4 +75,4 @@ export class CosmosExensionClient implements WalletClient { ) { return await this.cosmos.signDirect(chainId, signer, signDoc); } -} +} \ No newline at end of file diff --git a/wallets/cosmos-extension-metamask/src/extension/main-wallet.ts b/wallets/cosmos-extension-metamask/src/extension/main-wallet.ts index aa1295c8e..2f21dbf33 100644 --- a/wallets/cosmos-extension-metamask/src/extension/main-wallet.ts +++ b/wallets/cosmos-extension-metamask/src/extension/main-wallet.ts @@ -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) { @@ -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); }