feat(dapp-v2): adds cosmos signature verification (#6)

This commit is contained in:
Ben Kremer 2022-04-04 16:03:28 +02:00
parent 32afbb373c
commit f06ba323ac
3 changed files with 13 additions and 10 deletions

View File

@ -38,7 +38,7 @@
"blockies-ts": "^1.0.0",
"bs58": "^5.0.0",
"caip-api": "^2.0.0-beta.1",
"cosmos-wallet": "^1.1.0",
"cosmos-wallet": "^1.2.0",
"eth-sig-util": "^2.5.3",
"ethereumjs-util": "^7.0.6",
"ethers": "^5.3.0",

View File

@ -3,7 +3,12 @@ import { createContext, ReactNode, useContext, useState } from "react";
import * as encoding from "@walletconnect/encoding";
import { TypedDataField } from "@ethersproject/abstract-signer";
import { Transaction as EthTransaction } from "@ethereumjs/tx";
import { formatDirectSignDoc, stringifySignDocValues } from "cosmos-wallet";
import {
formatDirectSignDoc,
stringifySignDocValues,
verifyAminoSignature,
verifyDirectSignature,
} from "cosmos-wallet";
import bs58 from "bs58";
import { verifyMessageSignature } from "solana-wallet";
import {
@ -367,8 +372,7 @@ export function JsonRpcContextProvider({ children }: { children: ReactNode | Rea
throw new Error(`Missing chain data for chainId: ${chainId}`);
}
// TODO: check if valid
const valid = true;
const valid = await verifyDirectSignature(address, result.signature, signDoc);
// format displayed result
return {
@ -411,8 +415,7 @@ export function JsonRpcContextProvider({ children }: { children: ReactNode | Rea
throw new Error(`Missing chain data for chainId: ${chainId}`);
}
// TODO: check if valid
const valid = true;
const valid = await verifyAminoSignature(address, result.signature, signDoc);
// format displayed result
return {

View File

@ -4685,10 +4685,10 @@ cosmiconfig@^7.0.0:
path-type "^4.0.0"
yaml "^1.10.0"
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==
cosmos-wallet@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/cosmos-wallet/-/cosmos-wallet-1.2.0.tgz#1243066fe933cf5482de1aec0b96169cebe867c6"
integrity sha512-lMEpNhjN6FHU6c8l/lYi1hWU/74bOlTmo3pz0mwVpCHjNSe5u7sZCO7j0dndd3oV0tM8tj/u3eJa4NgZxG9a0Q==
dependencies:
"@cosmjs/amino" "^0.25.4"
"@cosmjs/proto-signing" "^0.25.4"