Skip to content

Commit

Permalink
add skip option when propose
Browse files Browse the repository at this point in the history
  • Loading branch information
hujw77 committed Nov 7, 2024
1 parent ca6d58b commit 0c9b369
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 35 deletions.
2 changes: 1 addition & 1 deletion packages/plugins/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hujw77/plugins",
"version": "0.1.28",
"version": "0.1.29",
"description": "Sphinx plugins",
"main": "dist/index",
"types": "dist/index",
Expand Down
66 changes: 34 additions & 32 deletions packages/plugins/src/cli/propose/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export interface ProposeArgs {
networks: Array<string>
isDryRun: boolean
silent: boolean
skip: boolean
scriptPath: string
sphinxContext: SphinxContext
targetContract?: string
Expand Down Expand Up @@ -243,7 +244,7 @@ export const propose = async (
networkConfigArray?: Array<NetworkConfig>
merkleTree?: SphinxMerkleTree
}> => {
const { confirm, networks, isDryRun, silent, sphinxContext, targetContract } =
const { confirm, networks, isDryRun, silent, sphinxContext, targetContract, skip } =
args
const sig = args.sig === undefined ? ['run()'] : args.sig

Expand Down Expand Up @@ -382,7 +383,6 @@ export const propose = async (
const merkleTree = makeSphinxMerkleTree(deploymentData)

spinner.succeed(`Built proposal.`)
spinner.start(`Running simulation...`)

const deploymentConfig = makeDeploymentConfig(
networkConfigArray,
Expand All @@ -391,18 +391,21 @@ export const propose = async (
merkleTree
)

const gasEstimatesPromises = networkConfigArrayWithRpcUrls
.filter(({ networkConfig }) => networkConfig.actionInputs.length > 0)
.map(({ networkConfig, rpcUrl }) =>
sphinxContext.getNetworkGasEstimate(
deploymentConfig,
networkConfig.chainId,
rpcUrl
if (!skip) {
spinner.start(`Running simulation...`)
const gasEstimatesPromises = networkConfigArrayWithRpcUrls
.filter(({ networkConfig }) => networkConfig.actionInputs.length > 0)
.map(({ networkConfig, rpcUrl }) =>
sphinxContext.getNetworkGasEstimate(
deploymentConfig,
networkConfig.chainId,
rpcUrl
)
)
)
const gasEstimates = await Promise.all(gasEstimatesPromises)
const gasEstimates = await Promise.all(gasEstimatesPromises)
}

spinner.succeed(`Simulation succeeded.`)
// spinner.succeed(`Simulation succeeded.`)
const preview = getPreview(networkConfigArray, merkleTree.root)
if (confirm || isDryRun) {
if (!silent) {
Expand Down Expand Up @@ -466,25 +469,25 @@ export const propose = async (
chainIds.push(Number(networkConfig.chainId))
}

const proposalRequest: ProposalRequest = {
apiKey,
orgId: newConfig.orgId,
isTestnet,
chainIds,
projectName: newConfig.projectName,
safeAddress,
moduleAddress,
projectDeployments,
gasEstimates,
diff: preview,
compilerConfigId: undefined,
deploymentConfigId: undefined,
sphinxPluginVersion: SPHINX_PLUGINS_VERSION,
tree: {
root: merkleTree.root,
chainStatus,
},
}
// const proposalRequest: ProposalRequest = {
// apiKey,
// orgId: newConfig.orgId,
// isTestnet,
// chainIds,
// projectName: newConfig.projectName,
// safeAddress,
// moduleAddress,
// projectDeployments,
// gasEstimates,
// diff: preview,
// compilerConfigId: undefined,
// deploymentConfigId: undefined,
// sphinxPluginVersion: SPHINX_PLUGINS_VERSION,
// tree: {
// root: merkleTree.root,
// chainStatus,
// },
// }

const deploymentConfigData = JSON.stringify(deploymentConfig, null, 2)

Expand Down Expand Up @@ -519,7 +522,6 @@ export const propose = async (
// )
}
return {
proposalRequest,
deploymentConfigData,
configArtifacts,
networkConfigArray,
Expand Down
8 changes: 7 additions & 1 deletion packages/plugins/src/cli/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ export const makeCLI = (
boolean: true,
default: false,
})
.option('skip', {
describe: 'Skip the executeion simulation.',
boolean: true,
default: false,
})
.check((argv) => {
const { networks } = argv

Expand Down Expand Up @@ -339,7 +344,7 @@ const proposeCommandHandler = async (
argv: ProposeCommandArgs,
sphinxContext: SphinxContext
): Promise<void> => {
const { networks, scriptPath, targetContract, silent, dryRun, confirm, sig } =
const { networks, scriptPath, targetContract, silent, dryRun, confirm, sig, skip } =
argv

if (dryRun && confirm) {
Expand Down Expand Up @@ -367,6 +372,7 @@ const proposeCommandHandler = async (
sphinxContext,
targetContract,
sig,
skip,
})
}

Expand Down
1 change: 1 addition & 0 deletions packages/plugins/src/cli/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface ProposeCommandArgs {
confirm: boolean
dryRun: boolean
silent: boolean
skip: boolean
targetContract?: string
sig?: Array<string>
}
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/cli/version.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const SPHINX_PLUGINS_VERSION = 'v0.1.28'
export const SPHINX_PLUGINS_VERSION = 'v0.1.29'

0 comments on commit 0c9b369

Please sign in to comment.