mirror of
https://github.com/bitbaum/solon.git
synced 2026-12-04 05:57:03 +01:00
* chore: pnpm — the fleet has one package manager Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn * fix: declare espree — pnpm's strict layout exposes the phantom dep eslint.config.mjs imports espree directly; npm's flat hoisting provided it by accident, pnpm does not. CI caught it (ERR_MODULE_NOT_FOUND). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WqKqMnHQHSmkGFfc5t7Rxn --------- Co-authored-by: Mao Nakamoto <41178744+maonakamoto@users.noreply.github.com> Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
66 lines
1.9 KiB
TypeScript
66 lines
1.9 KiB
TypeScript
/**
|
|
* Operator bootstrap: register a watch-only Bitcoin address as a treasury source.
|
|
*
|
|
* Solon never holds keys. This script only writes the address the public
|
|
* dashboard will look up on mempool.space. Do not invent an address. Do not
|
|
* use a voting member's key as the treasury. Run on the box with DATABASE_URL.
|
|
*
|
|
* Usage:
|
|
* pnpm exec tsx scripts/add-treasury-source.ts --org orangecat \
|
|
* --label "OrangeCat platform" --address <btc-address>
|
|
*/
|
|
import { parseArgs } from "node:util";
|
|
import { and, eq } from "drizzle-orm";
|
|
import { db } from "../src/lib/db/client";
|
|
import { organizations, treasurySources } from "../src/lib/db/schema";
|
|
|
|
const { values } = parseArgs({
|
|
options: {
|
|
org: { type: "string" },
|
|
label: { type: "string" },
|
|
address: { type: "string" },
|
|
},
|
|
});
|
|
|
|
async function main() {
|
|
const { org, label, address } = values;
|
|
if (!org || !label || !address) {
|
|
console.error("required: --org --label --address");
|
|
process.exit(1);
|
|
}
|
|
|
|
const organization = await db.query.organizations.findFirst({
|
|
where: eq(organizations.slug, org),
|
|
});
|
|
if (!organization) {
|
|
console.error(`organization "${org}" not found`);
|
|
process.exit(1);
|
|
}
|
|
|
|
const existing = await db.query.treasurySources.findFirst({
|
|
where: and(
|
|
eq(treasurySources.organizationId, organization.id),
|
|
eq(treasurySources.address, address),
|
|
),
|
|
});
|
|
if (existing) {
|
|
console.log(
|
|
`treasury source already registered: ${existing.id} (${existing.label} ${existing.address})`,
|
|
);
|
|
process.exit(0);
|
|
}
|
|
|
|
const [source] = await db
|
|
.insert(treasurySources)
|
|
.values({ organizationId: organization.id, label, address })
|
|
.returning();
|
|
console.log(`treasury source created: ${source.id} (${source.label} ${source.address})`);
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => db.$client.end());
|