chia-changelist-generator
Advanced tools
Comparing version 1.0.4 to 1.0.5
29
index.js
@@ -23,5 +23,8 @@ const Datalayer = require("chia-datalayer"); | ||
const isValidHexadecimal = (value) => { | ||
const isValidHexadecimal = (value) => { | ||
if (value?.startsWith("0x")) { | ||
value = value.slice(2); | ||
} | ||
const hexRegex = /^[0-9a-fA-F]+$/; | ||
return hexRegex.test(value); | ||
return hexRegex.test(value?.trim()); | ||
}; | ||
@@ -34,5 +37,5 @@ | ||
if (!isValidHexadecimal(value)) { | ||
if (action == 'insert' && !isValidHexadecimal(value)) { | ||
throw new Error( | ||
`Value for ${decodeHex(key)} is not a valid hexadecimal string` | ||
`Value for ${key} is not a valid hexadecimal string` | ||
); | ||
@@ -55,3 +58,6 @@ } | ||
if (existingKeys.includes(`0x${key}`)) { | ||
const hexKey = key.startsWith("0x") ? key : "0x" + key; | ||
if (existingKeys.includes(hexKey)) { | ||
console.log(`UPDATE: Key ${decodeHex(key)}`); | ||
change.push({ | ||
@@ -61,2 +67,4 @@ action: "delete", | ||
}); | ||
} else { | ||
console.log(`INSERT: Key ${decodeHex(key)}`); | ||
} | ||
@@ -76,3 +84,8 @@ | ||
if (existingKeys.includes(`0x${key}`)) { | ||
const hexKey = key.startsWith("0x") ? key : "0x" + key; | ||
if (existingKeys.includes(hexKey)) { | ||
console.log( | ||
`DELETE: Key ${decodeHex(key)} exists in store adding to change list` | ||
); | ||
change.push({ | ||
@@ -82,2 +95,6 @@ action: "delete", | ||
}); | ||
} else { | ||
console.warn( | ||
`Key ${decodeHex(key)} does not exist in store not adding to change list` | ||
); | ||
} | ||
@@ -84,0 +101,0 @@ |
{ | ||
"name": "chia-changelist-generator", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Easily Generate a ChangeList for Chia DataLayer", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
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
8412
4
110