Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to comma separated node ids #26

Merged
merged 1 commit into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/commands/reservation/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,22 @@ export default class ReservationCreate extends TransactionCommand {
By default, new reservations begin at the start of the next epoch.`;
static examples = ["<%= config.bin %> <%= command.id %> 0x123abc... 0x456def..."];
static usage = "<%= command.id %> ID IDS... [--spot] [--norenew]";
static strict = false;
static args: Arg[] = [
{ name: "ID", description: "The ID of the project to reserve the nodes.", required: true },
{ name: "IDS", description: "The IDs of the nodes to reserve for the project.", required: true },
{ name: "IDS", description: "The comma separated IDs of the nodes to reserve.", required: true },
];
static flags = {
spot: Flags.boolean({ description: "Reserve in the current epoch (can't release!)" }),
norenew: Flags.boolean({ description: "Don't renew these reservations in next epoch." }),
};

public async run(): Promise<Record<string, unknown>[]> {
const { args, flags, raw } = await this.parse(ReservationCreate);
const { args, flags } = await this.parse(ReservationCreate);
if (!flags.spot && !!flags.norenew) {
this.error("--norenew requires --spot");
}
// Parse vararg IDS
const nodeIds = raw
.filter((arg) => arg.type == "arg")
.map((arg) => arg.input)
.slice(1) // Skip ID
.map((id) => normalizeHash(id));

const nodeIds = args.IDS.split(",").map((id: string) => normalizeHash(id));
const signer = await getSigner(flags.network, flags.rpc, flags.address, flags.signer);
const reservations = await getContract(flags.network, flags.abi, "ArmadaReservations", signer);
const projectId = normalizeHash(args.ID);
Expand Down
13 changes: 3 additions & 10 deletions src/commands/reservation/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,14 @@ export default class ReservationDelete extends TransactionCommand {
The reservations will be deleted starting from the next epoch.`;
static examples = ["<%= config.bin %> <%= command.id %> 0x123abc... 0x456def..."];
static usage = "<%= command.id %> ID IDS...";
static strict = false;
static args: Arg[] = [
{ name: "ID", description: "The ID of the project to release the nodes.", required: true },
{ name: "IDS", description: "The IDs of the nodes to release from the project.", required: true },
{ name: "IDS", description: "The comma separated IDs of the nodes to release.", required: true },
];

public async run(): Promise<Record<string, unknown>[]> {
const { args, flags, raw } = await this.parse(ReservationDelete);
// Parse vararg IDS
const nodeIds = raw
.filter((arg) => arg.type == "arg")
.map((arg) => arg.input)
.slice(1) // Skip ID
.map((id) => normalizeHash(id));

const { args, flags } = await this.parse(ReservationDelete);
const nodeIds = args.IDS.split(",").map((id: string) => normalizeHash(id));
const signer = await getSigner(flags.network, flags.rpc, flags.address, flags.signer);
const reservations = await getContract(flags.network, flags.abi, "ArmadaReservations", signer);
const projectId = normalizeHash(args.ID);
Expand Down