@aztec/typed-data
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -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" |
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
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
11
4
0
6391
90
+ Addedelliptic@6.6.1(transitive)
+ Addedeth-lib@0.2.7(transitive)
+ Addedhash.js@1.1.7(transitive)
+ Addedrandomhex@0.1.5(transitive)
+ Addedunderscore@1.9.1(transitive)
+ Addedutf8@3.0.0(transitive)
+ Addedweb3-utils@1.2.1(transitive)
- Removedweb3-eth-abi@1.0.0-beta.55
- Removed@babel/runtime@7.26.0(transitive)
- Removed@types/bn.js@4.11.6(transitive)
- Removed@types/node@10.17.60(transitive)
- Removedaes-js@3.0.0(transitive)
- Removedelliptic@6.5.4(transitive)
- Removedeth-lib@0.2.8(transitive)
- Removedethers@4.0.49(transitive)
- Removedhash.js@1.1.3(transitive)
- Removedjs-sha3@0.5.7(transitive)
- Removedlodash@4.17.21(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedregenerator-runtime@0.14.1(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedscrypt-js@2.0.4(transitive)
- Removedsetimmediate@1.0.4(transitive)
- Removedutf8@2.1.1(transitive)
- Removeduuid@2.0.1(transitive)
- Removedweb3-eth-abi@1.0.0-beta.55(transitive)
- Removedweb3-utils@1.0.0-beta.55(transitive)
- Removedxmlhttprequest@1.8.0(transitive)
Updatedweb3-utils@1.2.1