@metamask/eth-sig-util
Advanced tools
Comparing version 5.0.2 to 5.0.3
@@ -157,2 +157,11 @@ /// <reference types="node" /> | ||
/** | ||
* Create a EIP-712 Domain Hash. | ||
* This hash is used at the top of the EIP-712 encoding. | ||
* | ||
* @param typedData - The typed message to hash. | ||
* @param version - The EIP-712 version the encoding should comply with. | ||
* @returns The hash of the domain object. | ||
*/ | ||
declare function eip712DomainHash<T extends MessageTypes>(typedData: TypedMessage<T>, version: SignTypedDataVersion.V3 | SignTypedDataVersion.V4): Buffer; | ||
/** | ||
* Hash a typed message according to EIP-712. The returned message starts with the EIP-712 prefix, | ||
@@ -181,2 +190,3 @@ * which is "1901", followed by the hash of the domain separator, then the data (if any). | ||
eip712Hash: typeof eip712Hash; | ||
eip712DomainHash: typeof eip712DomainHash; | ||
}; | ||
@@ -183,0 +193,0 @@ /** |
@@ -198,3 +198,6 @@ "use strict"; | ||
validateVersion(version, [SignTypedDataVersion.V3, SignTypedDataVersion.V4]); | ||
return (0, util_1.arrToBufArr)((0, keccak_1.keccak256)(encodeData(primaryType, data, types, version))); | ||
const encoded = encodeData(primaryType, data, types, version); | ||
const hashed = (0, keccak_1.keccak256)(encoded); | ||
const buf = (0, util_1.arrToBufArr)(hashed); | ||
return buf; | ||
} | ||
@@ -231,2 +234,17 @@ /** | ||
/** | ||
* Create a EIP-712 Domain Hash. | ||
* This hash is used at the top of the EIP-712 encoding. | ||
* | ||
* @param typedData - The typed message to hash. | ||
* @param version - The EIP-712 version the encoding should comply with. | ||
* @returns The hash of the domain object. | ||
*/ | ||
function eip712DomainHash(typedData, version) { | ||
validateVersion(version, [SignTypedDataVersion.V3, SignTypedDataVersion.V4]); | ||
const sanitizedData = sanitizeData(typedData); | ||
const { domain } = sanitizedData; | ||
const domainType = { EIP712Domain: sanitizedData.types.EIP712Domain }; | ||
return hashStruct('EIP712Domain', domain, domainType, version); | ||
} | ||
/** | ||
* Hash a typed message according to EIP-712. The returned message starts with the EIP-712 prefix, | ||
@@ -247,3 +265,3 @@ * which is "1901", followed by the hash of the domain separator, then the data (if any). | ||
const parts = [Buffer.from('1901', 'hex')]; | ||
parts.push(hashStruct('EIP712Domain', sanitizedData.domain, sanitizedData.types, version)); | ||
parts.push(eip712DomainHash(typedData, version)); | ||
if (sanitizedData.primaryType !== 'EIP712Domain') { | ||
@@ -267,2 +285,3 @@ parts.push(hashStruct( | ||
eip712Hash, | ||
eip712DomainHash, | ||
}; | ||
@@ -269,0 +288,0 @@ /** |
{ | ||
"name": "@metamask/eth-sig-util", | ||
"version": "5.0.2", | ||
"version": "5.0.3", | ||
"description": "A few useful functions for signing ethereum data", | ||
@@ -42,5 +42,5 @@ "keywords": [ | ||
"dependencies": { | ||
"@ethereumjs/util": "^8.0.0", | ||
"@ethereumjs/util": "^8.0.6", | ||
"bn.js": "^4.11.8", | ||
"ethereum-cryptography": "^1.1.2", | ||
"ethereum-cryptography": "^2.0.0", | ||
"ethjs-util": "^0.1.6", | ||
@@ -52,3 +52,3 @@ "tweetnacl": "^1.0.3", | ||
"@lavamoat/allow-scripts": "^2.0.3", | ||
"@metamask/auto-changelog": "^2.6.1", | ||
"@metamask/auto-changelog": "^3.1.0", | ||
"@metamask/eslint-config": "^9.0.0", | ||
@@ -55,0 +55,0 @@ "@metamask/eslint-config-jest": "^9.0.0", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
145637
1636
- Removed@noble/hashes@1.2.0(transitive)
- Removed@noble/secp256k1@1.7.1(transitive)
- Removed@scure/bip32@1.1.5(transitive)
- Removed@scure/bip39@1.1.1(transitive)
- Removedethereum-cryptography@1.2.0(transitive)
Updated@ethereumjs/util@^8.0.6
Updatedethereum-cryptography@^2.0.0