@aztec/typed-data
Advanced tools
Comparing version
@@ -17,14 +17,11 @@ "use strict"; | ||
*/ | ||
var _require = require('web3-eth-abi'), | ||
AbiCoder = _require.AbiCoder; | ||
var AbiCoder = require('web3-eth-abi'); | ||
var _require2 = require('web3-utils'), | ||
keccak256 = _require2.keccak256, | ||
padLeft = _require2.padLeft; | ||
var _require = require('web3-utils'), | ||
keccak256 = _require.keccak256; | ||
var abiCoder = new AbiCoder(); | ||
var signer = {}; | ||
function padKeccak256(data) { | ||
return padLeft(keccak256(data).slice(2), 64); | ||
function sliceKeccak256(data) { | ||
return keccak256(data).slice(2); | ||
} | ||
@@ -50,15 +47,15 @@ /** | ||
if (types[type]) { | ||
return "".concat(acc).concat(padKeccak256("0x".concat(encodeMessageData(types, type, message[name])))); | ||
return "".concat(acc).concat(sliceKeccak256("0x".concat(encodeMessageData(types, type, message[name])))); | ||
} | ||
if (type === 'string' || type === 'bytes') { | ||
return "".concat(acc).concat(padKeccak256(message[name])); | ||
return "".concat(acc).concat(sliceKeccak256(message[name])); | ||
} | ||
if (type.includes('[')) { | ||
return "".concat(acc).concat(padKeccak256(abiCoder.encodeParameter(type, message[name]))); | ||
return "".concat(acc).concat(sliceKeccak256(AbiCoder.encodeParameter(type, message[name]))); | ||
} | ||
return "".concat(acc).concat(abiCoder.encodeParameters([type], [message[name]]).slice(2)); | ||
}, padKeccak256(signer.encodeStruct(primaryType, types))); | ||
return "".concat(acc).concat(AbiCoder.encodeParameters([type], [message[name]]).slice(2)); | ||
}, sliceKeccak256(signer.encodeStruct(primaryType, types))); | ||
}; | ||
@@ -113,7 +110,7 @@ /** | ||
signer.encodeTypedData = function (typedData) { | ||
var domainHash = padKeccak256("0x".concat(signer.encodeMessageData(typedData.types, 'EIP712Domain', typedData.domain))); | ||
var structHash = padKeccak256("0x".concat(signer.encodeMessageData(typedData.types, typedData.primaryType, typedData.message))); | ||
return "0x".concat(padKeccak256("0x1901".concat(domainHash).concat(structHash))); | ||
var domainHash = sliceKeccak256("0x".concat(signer.encodeMessageData(typedData.types, 'EIP712Domain', typedData.domain))); | ||
var structHash = sliceKeccak256("0x".concat(signer.encodeMessageData(typedData.types, typedData.primaryType, typedData.message))); | ||
return keccak256("0x1901".concat(domainHash).concat(structHash)); | ||
}; | ||
module.exports = signer; |
{ | ||
"name": "@aztec/typed-data", | ||
"description": "JavaScript library for working with typed structured data as defined by EIP-712", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "AZTEC", | ||
@@ -10,4 +10,3 @@ "bugs": { | ||
"dependencies": { | ||
"web3-eth-abi": "1.0.0-beta.55", | ||
"web3-utils": "1.0.0-beta.55" | ||
"web3-utils": "1.2.1" | ||
}, | ||
@@ -22,5 +21,4 @@ "devDependencies": { | ||
"eslint-config-airbnb-base": "^13.1.0", | ||
"eslint-config-prettier": "^4.1.0", | ||
"eslint-config-prettier": "^6.0.0", | ||
"eslint-plugin-import": "^2.16.0", | ||
"fixpack": "^2.3.1", | ||
"mocha": "^6.0.2", | ||
@@ -27,0 +25,0 @@ "shx": "^0.3.2" |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
1
-50%11
-8.33%4
33.33%0
-100%6391
-1.86%90
-3.23%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated