Replace manualTest.ts with templates

This commit is contained in:
Andrew Morris
2023-05-22 22:29:15 +10:00
parent c1c0ea4b7e
commit d0997e29f5
3 changed files with 40 additions and 46 deletions

View File

@@ -1,46 +0,0 @@
import SeedSplitter from "./mod.ts";
// const secret =
// "expire gun route tornado female reflect holiday grief spring clown deliver army";
// const curve = await SeedSplitter.fit([
// {
// name: "secret",
// mnemonic: secret.split(" "),
// },
// await SeedSplitter.randomPoint(),
// await SeedSplitter.randomPoint(),
// ]);
const recoveryData = `
charlotte: valley when dial juice vapor ill payment lunch brass zone alpha topic
daniel: long neutral reject ahead cart proud shoulder auction april same solar match
emily: come foam country senior awkward task possible auction spice hidden sphere giraffe
`;
const curve = await SeedSplitter.fit(
recoveryData.split("\n").map((line) => {
if (line.trim() === "") {
return [];
}
const [name, mnemonic] = line.split(": ");
return { name, mnemonic: mnemonic.split(" ") };
}).flat(),
);
const names = [
"secret",
"ava",
"benjamin",
"charlotte",
"daniel",
"emily",
"finn",
"grace",
];
for (const name of names) {
console.log(`${name}:`, (await curve.calculate(name)).join(" "));
}

17
templates/generate.ts Normal file
View File

@@ -0,0 +1,17 @@
import SeedSplitter from "../mod.ts";
const secret =
"vault soap student engine hub blanket tortoise fit device critic stage clay";
const ss = await SeedSplitter.fit([
{ name: "secret", mnemonic: secret.split(" ") },
await SeedSplitter.randomPoint(),
await SeedSplitter.randomPoint(),
]);
for (const name of ["benjamin", "charlotte", "drawer", "car", "backyard"]) {
console.log(
`${(name + ":").padEnd(10, " ")}`,
(await ss.calculate(name)).join(" "),
);
}

23
templates/recover.ts Normal file
View File

@@ -0,0 +1,23 @@
import SeedSplitter from "../mod.ts";
const recoveryData = `
charlotte: evidence foil nut riot draft bronze shine town meat strategy fit broom
car: credit spoil coin drip camera risk ginger just delay spider correct soap
backyard: silent merit way main shop when toward spirit wolf catch level face
`;
const ss = await SeedSplitter.fit(
recoveryData.split("\n").map((line) => {
if (line.trim() === "") {
return [];
}
const [name, mnemonic] = line
.split(": ")
.map((part) => part.trim());
return { name, mnemonic: mnemonic.split(" ") };
}).flat(),
);
console.log((await ss.calculate("secret")).join(" "));