Skip to content

Commit

Permalink
Merge pull request #325 from leapsamvel/feature/upgrade-leap-mm-snap-…
Browse files Browse the repository at this point in the history
…provider

Fixed package fetch for cosmos-snap-provider
  • Loading branch information
liujun93 authored Sep 15, 2023
2 parents bb8466f + 8703c55 commit d862ea7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
2 changes: 1 addition & 1 deletion wallets/leap-metamask-cosmos-snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
16 changes: 11 additions & 5 deletions wallets/leap-metamask-cosmos-snap/src/extension/client.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -82,11 +82,11 @@ export class CosmosSnapClient implements WalletClient {
authInfoBytes?: Uint8Array | null;
chainId?: string | null;
accountNumber?: ProviderLong | null;
}) {
}): Promise<DirectSignResponse> {
const signature = (requestSignature(
chainId,
signer,
signDoc // @ts-nocheck
signDoc
) as unknown) as DirectSignResponse;

const accountNumber = signDoc.accountNumber;
Expand All @@ -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)
),
Expand All @@ -121,7 +121,13 @@ export class CosmosSnapClient implements WalletClient {
)) as unknown as StdSignature;
}

async addChain(chainInfo: ChainInfo) {
async addChain(chainRecord: ChainRecord): Promise<void> {
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);
}
}
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3039,10 +3039,10 @@
big-integer "^1.6.48"
utility-types "^3.10.0"

"@leapwallet/[email protected].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/[email protected].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"
Expand Down

0 comments on commit d862ea7

Please sign in to comment.