Private CLI workflow for reviewed depowit operations
This commit is contained in:
Executable
+30
@@ -0,0 +1,30 @@
|
||||
export const CUSTODY_DB_ACTION_ARGUMENT_COUNTS = {
|
||||
migrate: 0,
|
||||
'grant-runtime': 1,
|
||||
'grant-monero-credit-runtime': 1,
|
||||
'import-sqlite': 1,
|
||||
audit: 0,
|
||||
'resolve-integrity': 1,
|
||||
'deposit-prepare-credit': 2,
|
||||
'deposit-stage-credit': 1,
|
||||
'deposit-prepare-release': 1,
|
||||
'deposit-release': 1,
|
||||
'deposit-reconcile-holds': 1,
|
||||
'deposit-prepare-resolve-hold': 2,
|
||||
'deposit-resolve-hold': 1,
|
||||
} as const;
|
||||
|
||||
export type CustodyDbAction = keyof typeof CUSTODY_DB_ACTION_ARGUMENT_COUNTS;
|
||||
export type CustodyDbArguments = { action: CustodyDbAction; argument?: string; extraArgument?: string };
|
||||
|
||||
export function parseCustodyDbArguments(args: readonly string[]): CustodyDbArguments {
|
||||
const [action, ...values] = args;
|
||||
if (!action || !Object.hasOwn(CUSTODY_DB_ACTION_ARGUMENT_COUNTS, action)) {
|
||||
throw new Error(`Expected one of: ${Object.keys(CUSTODY_DB_ACTION_ARGUMENT_COUNTS).join(', ')}`);
|
||||
}
|
||||
const count = CUSTODY_DB_ACTION_ARGUMENT_COUNTS[action as CustodyDbAction];
|
||||
if (values.length !== count || values.some(value => value.length === 0)) {
|
||||
throw new Error(`Invalid argument count for custody operation: ${action}`);
|
||||
}
|
||||
return { action: action as CustodyDbAction, argument: values[0], extraArgument: values[1] };
|
||||
}
|
||||
Reference in New Issue
Block a user