Added verifyTypedData utility (reported on Farcaster).
This commit is contained in:
parent
e11d4c1c20
commit
f06a445247
@ -51,7 +51,8 @@ export {
|
||||
ensNormalize, isValidName, namehash, dnsEncode,
|
||||
hashMessage, verifyMessage,
|
||||
solidityPacked, solidityPackedKeccak256, solidityPackedSha256,
|
||||
TypedDataEncoder
|
||||
TypedDataEncoder,
|
||||
verifyTypedData
|
||||
} from "./hash/index.js";
|
||||
|
||||
export {
|
||||
@ -149,7 +150,8 @@ export type {
|
||||
ConstantContractMethod, ContractEvent, ContractEventArgs, ContractEventName,
|
||||
ContractInterface, ContractMethod, ContractMethodArgs, ContractTransaction,
|
||||
DeferredTopicFilter, Overrides,
|
||||
BaseContractMethod, ContractDeployTransaction, PostfixOverrides
|
||||
BaseContractMethod, ContractDeployTransaction, PostfixOverrides,
|
||||
WrappedFallback
|
||||
} from "./contract/index.js";
|
||||
|
||||
export type { ProgressCallback, SignatureLike } from "./crypto/index.js";
|
||||
|
@ -10,6 +10,6 @@ export { hashMessage, verifyMessage } from "./message.js";
|
||||
export {
|
||||
solidityPacked, solidityPackedKeccak256, solidityPackedSha256
|
||||
} from "./solidity.js";
|
||||
export { TypedDataEncoder } from "./typed-data.js";
|
||||
export { TypedDataEncoder, verifyTypedData } from "./typed-data.js";
|
||||
|
||||
export type { TypedDataDomain, TypedDataField } from "./typed-data.js";
|
||||
|
@ -1,6 +1,7 @@
|
||||
//import { TypedDataDomain, TypedDataField } from "@ethersproject/providerabstract-signer";
|
||||
import { getAddress } from "../address/index.js";
|
||||
import { keccak256 } from "../crypto/index.js";
|
||||
import { recoverAddress } from "../transaction/index.js";
|
||||
import {
|
||||
concat, defineProperties, getBigInt, getBytes, hexlify, isHexString, mask, toBeHex, toTwos, zeroPadValue,
|
||||
assertArgument
|
||||
@ -8,6 +9,7 @@ import {
|
||||
|
||||
import { id } from "./id.js";
|
||||
|
||||
import type { SignatureLike } from "../crypto/index.js";
|
||||
import type { BigNumberish, BytesLike } from "../utils/index.js";
|
||||
|
||||
|
||||
@ -487,3 +489,9 @@ export class TypedDataEncoder {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Compute the address used to sign the typed data for the %%signature%%.
|
||||
*/
|
||||
export function verifyTypedData(domain: TypedDataDomain, types: Record<string, Array<TypedDataField>>, value: Record<string, any>, signature: SignatureLike): string {
|
||||
return recoverAddress(TypedDataEncoder.hash(domain, types, value), signature);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user