From 06b3c135d3d57ca3ce985c637a64f962d570c1d1 Mon Sep 17 00:00:00 2001 From: SamvelRaja Sakthivel Date: Fri, 15 Sep 2023 08:04:20 +0530 Subject: [PATCH 1/3] Fixed package fetch for cosmos-snap-provider --- yarn.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/yarn.lock b/yarn.lock index 3c64b8c67..f0110e55d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3039,10 +3039,10 @@ big-integer "^1.6.48" utility-types "^3.10.0" -"@leapwallet/cosmos-snap-provider@0.1.20": - version "0.1.20" - resolved "https://registry.yarnpkg.com/@leapwallet/cosmos-snap-provider/-/cosmos-snap-provider-0.1.20.tgz#b0c36f3b0e2cfa441769c6ed93bd4238f62a66d4" - integrity sha512-VUoxun5prJdLTjkCRU3EBLwx2CNnvYnP9deSiffwCx4lQQzcN38gSIHs3rfXpdyLdPv1jIi6nVVsqIVKFzvB1w== +"@leapwallet/cosmos-snap-provider@0.1.21": + version "0.1.21" + resolved "https://registry.yarnpkg.com/@leapwallet/cosmos-snap-provider/-/cosmos-snap-provider-0.1.21.tgz#b50205858d818a8583558f725b1b1909d35e995f" + integrity sha512-2B6bmjx+cU/bNKdNzswsWohX2vw1nmSbctzLEe022AdtKfh9nCzpDq1/a73oXXqZOdUOSDE0KggjTP/zxRo8AA== dependencies: "@cosmjs/amino" "^0.31.0" "@cosmjs/proto-signing" "^0.31.0" From eff80df7a7dc985a27581b06d0f104dad7c68458 Mon Sep 17 00:00:00 2001 From: SamvelRaja Sakthivel Date: Fri, 15 Sep 2023 10:50:01 +0530 Subject: [PATCH 2/3] Fixed types in leap metamask snap client --- wallets/leap-metamask-cosmos-snap/package.json | 2 +- .../src/extension/client.ts | 14 ++++++++++---- yarn.lock | 8 ++++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/wallets/leap-metamask-cosmos-snap/package.json b/wallets/leap-metamask-cosmos-snap/package.json index 31e414fe5..c61bc5b29 100644 --- a/wallets/leap-metamask-cosmos-snap/package.json +++ b/wallets/leap-metamask-cosmos-snap/package.json @@ -61,7 +61,7 @@ "dependencies": { "@chain-registry/keplr": "1.8.0", "@cosmos-kit/core": "^2.6.2", - "@leapwallet/cosmos-snap-provider": "0.1.21", + "@leapwallet/cosmos-snap-provider": "0.1.22", "@metamask/providers": "^11.1.1" }, "peerDependencies": { diff --git a/wallets/leap-metamask-cosmos-snap/src/extension/client.ts b/wallets/leap-metamask-cosmos-snap/src/extension/client.ts index 71ec9c2c6..10150a93e 100644 --- a/wallets/leap-metamask-cosmos-snap/src/extension/client.ts +++ b/wallets/leap-metamask-cosmos-snap/src/extension/client.ts @@ -1,6 +1,6 @@ import { AminoSignResponse, OfflineAminoSigner, StdSignature, StdSignDoc } from '@cosmjs/amino'; import { Algo, DirectSignResponse } from '@cosmjs/proto-signing'; -import { SignType } from '@cosmos-kit/core'; +import { ChainRecord, SignType } from '@cosmos-kit/core'; import { SignOptions, WalletClient } from '@cosmos-kit/core'; import { ChainInfo, CosmjsOfflineSigner, experimentalSuggestChain, signArbitrary } from '@leapwallet/cosmos-snap-provider'; @@ -82,7 +82,7 @@ export class CosmosSnapClient implements WalletClient { authInfoBytes?: Uint8Array | null; chainId?: string | null; accountNumber?: ProviderLong | null; - }) { + }): Promise { const signature = (requestSignature( chainId, signer, @@ -100,7 +100,7 @@ export class CosmosSnapClient implements WalletClient { signature: signature.signature, signed: { ...signature.signed, - accountNumber: `${modifiedAccountNumber.toString()}`, + accountNumber: modifiedAccountNumber, authInfoBytes: new Uint8Array( Object.values(signature.signed.authInfoBytes) ), @@ -121,7 +121,13 @@ export class CosmosSnapClient implements WalletClient { )) as unknown as StdSignature; } - async addChain(chainInfo: ChainInfo) { + async addChain(chainRecord: ChainRecord): Promise { + const chainInfo: ChainInfo = { + chainId: chainRecord?.chain?.chain_id, + chainName: chainRecord?.chain?.chain_name, + bip44: { coinType: chainRecord?.chain?.slip44 }, + bech32Config: { bech32PrefixAccAddr: chainRecord?.chain?.bech32_prefix }, + } await experimentalSuggestChain(chainInfo); } } diff --git a/yarn.lock b/yarn.lock index f0110e55d..44a5d83c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3039,10 +3039,10 @@ big-integer "^1.6.48" utility-types "^3.10.0" -"@leapwallet/cosmos-snap-provider@0.1.21": - version "0.1.21" - resolved "https://registry.yarnpkg.com/@leapwallet/cosmos-snap-provider/-/cosmos-snap-provider-0.1.21.tgz#b50205858d818a8583558f725b1b1909d35e995f" - integrity sha512-2B6bmjx+cU/bNKdNzswsWohX2vw1nmSbctzLEe022AdtKfh9nCzpDq1/a73oXXqZOdUOSDE0KggjTP/zxRo8AA== +"@leapwallet/cosmos-snap-provider@0.1.22": + version "0.1.22" + resolved "https://registry.yarnpkg.com/@leapwallet/cosmos-snap-provider/-/cosmos-snap-provider-0.1.22.tgz#684bf04c23721268803ae9fea7a88c6d3bbbea27" + integrity sha512-4shW8JU6bRMwY1HGey7dQeFnL7yL1bU9V8wJ1Y6LcFv2XDxQx3pNpaXsmUNAcf3G/EViZkdrFm++KmmDmLAyIA== dependencies: "@cosmjs/amino" "^0.31.0" "@cosmjs/proto-signing" "^0.31.0" From 8703c5523ea782fea032fee3ed94cbbf4264b503 Mon Sep 17 00:00:00 2001 From: SamvelRaja Sakthivel Date: Fri, 15 Sep 2023 10:52:30 +0530 Subject: [PATCH 3/3] Removed ts nocheck comment --- wallets/leap-metamask-cosmos-snap/src/extension/client.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wallets/leap-metamask-cosmos-snap/src/extension/client.ts b/wallets/leap-metamask-cosmos-snap/src/extension/client.ts index 10150a93e..4b08d3d04 100644 --- a/wallets/leap-metamask-cosmos-snap/src/extension/client.ts +++ b/wallets/leap-metamask-cosmos-snap/src/extension/client.ts @@ -86,7 +86,7 @@ export class CosmosSnapClient implements WalletClient { const signature = (requestSignature( chainId, signer, - signDoc // @ts-nocheck + signDoc ) as unknown) as DirectSignResponse; const accountNumber = signDoc.accountNumber;