Revert "Cosmos signature verification (#6)"
This reverts commit 3c47a595b8
.
This commit is contained in:
parent
3c47a595b8
commit
dad29d7611
@ -1,11 +1,6 @@
|
||||
import React, { useState } from "react";
|
||||
import { version } from "@walletconnect/client/package.json";
|
||||
import {
|
||||
formatDirectSignDoc,
|
||||
stringifySignDocValues,
|
||||
verifyAminoSignature,
|
||||
verifyDirectSignature,
|
||||
} from "cosmos-wallet";
|
||||
import { formatDirectSignDoc, stringifySignDocValues } from "cosmos-wallet";
|
||||
|
||||
import Banner from "./components/Banner";
|
||||
import Blockchain from "./components/Blockchain";
|
||||
@ -134,12 +129,10 @@ export default function App() {
|
||||
params,
|
||||
});
|
||||
|
||||
const valid = await verifyDirectSignature(address, result.signature, signDoc);
|
||||
|
||||
return {
|
||||
method: "cosmos_signDirect",
|
||||
address,
|
||||
valid,
|
||||
valid: true,
|
||||
result: result.signature,
|
||||
};
|
||||
};
|
||||
@ -169,12 +162,10 @@ export default function App() {
|
||||
params,
|
||||
});
|
||||
|
||||
const valid = await verifyAminoSignature(address, result.signature, signDoc);
|
||||
|
||||
return {
|
||||
method: "cosmos_signAmino",
|
||||
address,
|
||||
valid,
|
||||
valid: true,
|
||||
result: result.signature,
|
||||
};
|
||||
};
|
||||
|
@ -2605,7 +2605,7 @@
|
||||
"@walletconnect/utils" "^2.0.0-beta.23"
|
||||
ws "^8.3.0"
|
||||
|
||||
"@walletconnect/cosmos-provider@2.0.0-beta.23":
|
||||
"@walletconnect/cosmos-provider@^2.0.0-beta.23":
|
||||
version "2.0.0-beta.23"
|
||||
resolved "https://registry.yarnpkg.com/@walletconnect/cosmos-provider/-/cosmos-provider-2.0.0-beta.23.tgz#54c3c26835c6bc286b14eb63a7c24f6961df95e6"
|
||||
integrity sha512-RDTSHWtFVNJxK00tQtZyueaFoPEh9Nsc1Hae5NOphQsp+FQhwvVX76+J48ELW+ylS5RNU1Ji1Q/xXX32QNtRLw==
|
||||
|
@ -1,3 +0,0 @@
|
||||
NEXT_PUBLIC_PROJECT_ID=...
|
||||
NEXT_PUBLIC_RELAY_URL=wss://relay.walletconnect.com
|
||||
|
@ -13,23 +13,9 @@ This example aims to demonstrate basic and advanced use cases enabled by WalletC
|
||||
Eexample is built atop of [NextJS](https://nextjs.org/) in order to abstract complexity of setting up bundlers, routing etc. So there are few steps you need to follow in order to set everything up
|
||||
|
||||
1. Go to [WalletConnect Cloud](https://cloud.walletconnect.com/sign-in) and obtain a project id
|
||||
|
||||
2. Add your project details in [WalletConnectUtil.ts](https://github.com/WalletConnect/web-examples/blob/main/wallets/react-wallet-v2/src/utils/WalletConnectUtil.ts) file
|
||||
|
||||
3. Install dependencies `yarn install` or `npm install`
|
||||
|
||||
4. Setup your environment variables
|
||||
|
||||
```bash
|
||||
cp .env.local.example .env.local
|
||||
```
|
||||
|
||||
Your `.env.local` now contains the following environment variables:
|
||||
|
||||
- `NEXT_PUBLIC_PROJECT_ID` (placeholder) - You can generate your own ProjectId at https://cloud.walletconnect.com
|
||||
- `NEXT_PUBLIC_RELAY_URL` (already set)
|
||||
|
||||
5. Run `yarn dev` or `npm run dev` to start local development
|
||||
4. Run `yarn dev` or `npm run dev` to start local development
|
||||
|
||||
## Navigating through example
|
||||
|
||||
|
@ -2,34 +2,33 @@
|
||||
"name": "react-wallet-v2",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "next dev -p 3001",
|
||||
"dev": "next dev",
|
||||
"build": "next build",
|
||||
"start": "next start",
|
||||
"lint": "next lint"
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/amino": "0.27.1",
|
||||
"@cosmjs/encoding": "0.27.1",
|
||||
"@cosmjs/proto-signing": "0.27.1",
|
||||
"@json-rpc-tools/utils": "1.7.6",
|
||||
"@nextui-org/react": "1.0.2-beta.4",
|
||||
"@walletconnect/client": "experimental",
|
||||
"@walletconnect/utils": "experimental",
|
||||
"cosmos-wallet": "^1.1.0",
|
||||
"ethers": "5.5.4",
|
||||
"framer-motion": "6.2.8",
|
||||
"@json-rpc-tools/utils": "1.7.6",
|
||||
"@nextui-org/react": "1.0.2-beta.4",
|
||||
"mnemonic-keyring": "1.4.0",
|
||||
"next": "12.1.0",
|
||||
"react": "17.0.2",
|
||||
"react-code-blocks": "0.0.9-0",
|
||||
"react-dom": "17.0.2",
|
||||
"react-qr-reader-es6": "2.2.1-2",
|
||||
"valtio": "1.3.1"
|
||||
"framer-motion": "6.2.8",
|
||||
"ethers": "5.5.4",
|
||||
"valtio": "1.3.1",
|
||||
"react-code-blocks": "0.0.9-0",
|
||||
"@cosmjs/proto-signing": "0.27.1",
|
||||
"@cosmjs/encoding": "0.27.1",
|
||||
"@cosmjs/amino": "0.27.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@walletconnect/types": "experimental",
|
||||
"@types/node": "17.0.21",
|
||||
"@types/react": "17.0.39",
|
||||
"@walletconnect/types": "experimental",
|
||||
"eslint": "8.10.0",
|
||||
"eslint-config-next": "12.1.0",
|
||||
"eslint-config-prettier": "8.5.0",
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { Secp256k1Wallet, StdSignDoc } from '@cosmjs/amino'
|
||||
import { fromHex } from '@cosmjs/encoding'
|
||||
import { DirectSecp256k1Wallet } from '@cosmjs/proto-signing'
|
||||
import { DirectSecp256k1Wallet, makeSignBytes } from '@cosmjs/proto-signing'
|
||||
// @ts-expect-error
|
||||
import { SignDoc } from '@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx'
|
||||
import MnemonicKeyring from 'mnemonic-keyring'
|
||||
@ -58,7 +58,10 @@ export class Cosmos {
|
||||
}
|
||||
|
||||
public async signDirect(address: string, signDoc: SignDoc) {
|
||||
return await this.directSigner.signDirect(address, signDoc)
|
||||
console.log(signDoc)
|
||||
const signDocBytes = makeSignBytes(signDoc)
|
||||
// @ts-expect-error
|
||||
return await this.directSigner.signDirect(address, signDocBytes)
|
||||
}
|
||||
|
||||
public async signAmino(address: string, signDoc: StdSignDoc) {
|
||||
|
@ -4,7 +4,6 @@ import { getWalletAddressFromParams } from '@/utils/HelperUtil'
|
||||
import { formatJsonRpcError, formatJsonRpcResult } from '@json-rpc-tools/utils'
|
||||
import { RequestEvent } from '@walletconnect/types'
|
||||
import { ERROR } from '@walletconnect/utils'
|
||||
import { parseSignDocValues } from 'cosmos-wallet'
|
||||
|
||||
export async function approveCosmosRequest(requestEvent: RequestEvent) {
|
||||
const { method, params, id } = requestEvent.request
|
||||
@ -12,10 +11,7 @@ export async function approveCosmosRequest(requestEvent: RequestEvent) {
|
||||
|
||||
switch (method) {
|
||||
case COSMOS_SIGNING_METHODS.COSMOS_SIGN_DIRECT:
|
||||
const signedDirect = await wallet.signDirect(
|
||||
params.signerAddress,
|
||||
parseSignDocValues(params.signDoc)
|
||||
)
|
||||
const signedDirect = await wallet.signDirect(params.signerAddress, params.signDoc)
|
||||
return formatJsonRpcResult(id, signedDirect.signature)
|
||||
|
||||
case COSMOS_SIGNING_METHODS.COSMOS_SIGN_AMINO:
|
||||
|
@ -153,16 +153,6 @@
|
||||
"@cosmjs/math" "0.27.1"
|
||||
"@cosmjs/utils" "0.27.1"
|
||||
|
||||
"@cosmjs/amino@^0.25.4", "@cosmjs/amino@^0.25.6":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/amino/-/amino-0.25.6.tgz#cdf9632253bfab7b1d2ef967124953d7bf16351f"
|
||||
integrity sha512-9dXN2W7LHjDtJUGNsQ9ok0DfxeN3ca/TXnxCR3Ikh/5YqBqxI8Gel1J9PQO9L6EheYyh045Wff4bsMaLjyEeqQ==
|
||||
dependencies:
|
||||
"@cosmjs/crypto" "^0.25.6"
|
||||
"@cosmjs/encoding" "^0.25.6"
|
||||
"@cosmjs/math" "^0.25.6"
|
||||
"@cosmjs/utils" "^0.25.6"
|
||||
|
||||
"@cosmjs/crypto@0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.27.1.tgz#271c853089a3baf3acd6cf0b2122fd49f8815743"
|
||||
@ -179,22 +169,6 @@
|
||||
ripemd160 "^2.0.2"
|
||||
sha.js "^2.4.11"
|
||||
|
||||
"@cosmjs/crypto@^0.25.6":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/crypto/-/crypto-0.25.6.tgz#695d2d0d2195bdbdd5825d415385646244900bbb"
|
||||
integrity sha512-ec+YcQLrg2ibcxtNrh4FqQnG9kG9IE/Aik2NH6+OXQdFU/qFuBTxSFcKDgzzBOChwlkXwydllM9Jjbp+dgIzRw==
|
||||
dependencies:
|
||||
"@cosmjs/encoding" "^0.25.6"
|
||||
"@cosmjs/math" "^0.25.6"
|
||||
"@cosmjs/utils" "^0.25.6"
|
||||
bip39 "^3.0.2"
|
||||
bn.js "^4.11.8"
|
||||
elliptic "^6.5.3"
|
||||
js-sha3 "^0.8.0"
|
||||
libsodium-wrappers "^0.7.6"
|
||||
ripemd160 "^2.0.2"
|
||||
sha.js "^2.4.11"
|
||||
|
||||
"@cosmjs/encoding@0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.27.1.tgz#3cd5bc0af743485eb2578cdb08cfa84c86d610e1"
|
||||
@ -204,15 +178,6 @@
|
||||
bech32 "^1.1.4"
|
||||
readonly-date "^1.0.0"
|
||||
|
||||
"@cosmjs/encoding@^0.25.6":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/encoding/-/encoding-0.25.6.tgz#da741a33eaf063a6d3611d7d68db5ca3938e0ef5"
|
||||
integrity sha512-0imUOB8XkUstI216uznPaX1hqgvLQ2Xso3zJj5IV5oJuNlsfDj9nt/iQxXWbJuettc6gvrFfpf+Vw2vBZSZ75g==
|
||||
dependencies:
|
||||
base64-js "^1.3.0"
|
||||
bech32 "^1.1.4"
|
||||
readonly-date "^1.0.0"
|
||||
|
||||
"@cosmjs/math@0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.27.1.tgz#be78857b008ffc6b1ed6fecaa1c4cd5bc38c07d7"
|
||||
@ -220,13 +185,6 @@
|
||||
dependencies:
|
||||
bn.js "^5.2.0"
|
||||
|
||||
"@cosmjs/math@^0.25.6":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/math/-/math-0.25.6.tgz#25c7b106aaded889a5b80784693caa9e654b0c28"
|
||||
integrity sha512-Fmyc9FJ8KMU34n7rdapMJrT/8rx5WhMw2F7WLBu7AVLcBh0yWsXIcMSJCoPHTOnMIiABjXsnrrwEaLrOOBfu6A==
|
||||
dependencies:
|
||||
bn.js "^4.11.8"
|
||||
|
||||
"@cosmjs/proto-signing@0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.27.1.tgz#1f8f662550aab012d957d02f43c77d914c2ae0db"
|
||||
@ -239,25 +197,11 @@
|
||||
long "^4.0.0"
|
||||
protobufjs "~6.10.2"
|
||||
|
||||
"@cosmjs/proto-signing@^0.25.4":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/proto-signing/-/proto-signing-0.25.6.tgz#d9fc57b8e0a46cda97e192bd0435157b24949ff8"
|
||||
integrity sha512-JpQ+Vnv9s6i3x8f3Jo0lJZ3VMnj3R5sMgX+8ti1LtB7qEYRR85qbDrEG9hDGIKqJJabvrAuCHnO6hYi0vJEJHA==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.25.6"
|
||||
long "^4.0.0"
|
||||
protobufjs "~6.10.2"
|
||||
|
||||
"@cosmjs/utils@0.27.1":
|
||||
version "0.27.1"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.27.1.tgz#1c8efde17256346ef142a3bd15158ee4055470e2"
|
||||
integrity sha512-VG7QPDiMUzVPxRdJahDV8PXxVdnuAHiIuG56hldV4yPnOz/si/DLNd7VAUUA5923b6jS1Hhev0Hr6AhEkcxBMg==
|
||||
|
||||
"@cosmjs/utils@^0.25.6":
|
||||
version "0.25.6"
|
||||
resolved "https://registry.yarnpkg.com/@cosmjs/utils/-/utils-0.25.6.tgz#934d9a967180baa66163847616a74358732227ca"
|
||||
integrity sha512-ofOYiuxVKNo238vCPPlaDzqPXy2AQ/5/nashBo5rvPZJkxt9LciGfUEQWPCOb1BIJDNx2Dzu0z4XCf/dwzl0Dg==
|
||||
|
||||
"@emotion/is-prop-valid@^0.8.2", "@emotion/is-prop-valid@^0.8.8":
|
||||
version "0.8.8"
|
||||
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a"
|
||||
@ -1663,14 +1607,6 @@ cosmjs-types@^0.4.0:
|
||||
long "^4.0.0"
|
||||
protobufjs "~6.11.2"
|
||||
|
||||
cosmos-wallet@^1.1.0:
|
||||
version "1.1.0"
|
||||
resolved "https://registry.yarnpkg.com/cosmos-wallet/-/cosmos-wallet-1.1.0.tgz#ca554d19fda1a1a7a8ee21fef4e0ef8f7fa9ef7b"
|
||||
integrity sha512-jm5MFRYzvOCA/mhULObpaoE2Na0shBn3lrkv2GDedmRZfuoDvOa63WID4qMoIycteefjRKdxXf+26vDrgd79aQ==
|
||||
dependencies:
|
||||
"@cosmjs/amino" "^0.25.4"
|
||||
"@cosmjs/proto-signing" "^0.25.4"
|
||||
|
||||
create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196"
|
||||
|
Loading…
Reference in New Issue
Block a user