Skip to content
This repository has been archived by the owner on Oct 9, 2024. It is now read-only.

Commit

Permalink
feat: allow custom fork labels (#11)
Browse files Browse the repository at this point in the history
* feat: allow custom fork labels

* feat: alter code
  • Loading branch information
sakulstra authored Jan 22, 2023
1 parent 23eb52a commit 1d8dcdb
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type CommonOptions = {
blockNumber?: string;
forkNetworkId: string;
forkId?: string;
forkLabel?: string;
//
enterProposalId: boolean;
proposalId?: number;
Expand Down Expand Up @@ -220,6 +221,13 @@ const questions: { [key: string]: InquirerQuestion | YargsQuestion } = {
describe: "Address to fund with 1000 of native currency",
type: "string",
},
forkLabel: {
message:
"Enter label to be used on tenderly (keep empty for autogenerated)",
describe: "Label will be used in tenderly to differentiate between forks",
type: "string",
when: (args) => args.forkType === "new",
},
keepAlive: {
message: "Should the fork be kept alive after terminal is closed?",
describe: "Keep the fork alive after this session",
Expand Down Expand Up @@ -286,12 +294,15 @@ function getOptions(options: {
}

function getName(options: Options) {
if (options.proposalId) {
return `proposalId-${options.proposalId}`;
const unix = Math.floor(new Date().getTime() / 1000);
if (options.forkLabel) {
return `${unix}-${options.forkLabel}`;
} else if (options.proposalId) {
return `${unix}-proposalId-${options.proposalId}`;
} else if (options.payloadAddress) {
return `payloadAddress-${options.payloadAddress}`;
return `${unix}-payloadAddress-${options.payloadAddress}`;
} else if (options.artifactPath) {
return `artifact-${options.artifactPath}`;
return `${unix}-artifact-${options.artifactPath.replace(/^.*[\\\/]/, "")}`;
}
return "vanilla-fork";
}
Expand Down

0 comments on commit 1d8dcdb

Please sign in to comment.