Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eip-712-types-generation

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eip-712-types-generation - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

2

package.json
{
"name": "eip-712-types-generation",
"version": "0.1.2",
"version": "0.1.3",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

@@ -7,3 +7,3 @@ # eip-712-types-generation

Import `getEthTypesFromSchema` into your project and pass in the `message` that you intend to sign using EIP-712, including the `proof` object. This will return an object that can be used as the `types` object passed into `eth_signTypedDatav4`
Import `getEthTypesFromInputDoc` into your project and pass in the `message` that you intend to sign using EIP-712, including the `proof` object. This will return an object that can be used as the `types` object passed into `eth_signTypedDatav4`

@@ -10,0 +10,0 @@ ## Developing

@@ -13,7 +13,2 @@ import { canonicalize } from "json-canonicalize";

}
res.set("EIP712Domain", [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
]);
let obj = Object.fromEntries(res);

@@ -26,3 +21,4 @@ obj = {

],
...obj};
...obj
};
return obj;

@@ -34,4 +30,2 @@ }

function getEthTypesFromInputDocHelper(input: object, primaryType: string): Map<string, TypedDataField[]> {
const output = new Map<string, TypedDataField[]>();

@@ -43,9 +37,7 @@ const types = new Array<TypedDataField>();

for (const property in canonicalizedInput) {
// console.log("property: ", property);
const val = canonicalizedInput[property];
const type = typeof val;
// console.log("typeof canonicalizedInput[property]: ", type);
if (type === "boolean") {
types.push({ name: property, type: "bool" })
} else if (type === "number") {
} else if (type === "number" || type === "bigint") {
types.push({ name: property, type: "uint256" })

@@ -56,3 +48,2 @@ } else if (type === "string") {

if (Array.isArray(val)) {
console.log("is Array.");
if (val.length === 0) {

@@ -80,3 +71,2 @@ throw new Error("Array with length 0 found")

} else {
console.log("is Not Array.");
const recursiveOutput = getEthTypesFromInputDocHelper(val, primaryType);

@@ -88,3 +78,2 @@ const recursiveTypes = recursiveOutput.get(primaryType);

for (const key in recursiveOutput) {
console.log("recursiveOutput key: ", key);
if (key !== primaryType) {

@@ -91,0 +80,0 @@ output.set(key, recursiveOutput.get(key)!)

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc