eip-712-types-generation
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"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)!) |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
153995
629