From f6cef3cd4c629c8aaff0f46ede42836796d7be75 Mon Sep 17 00:00:00 2001 From: DiRaiks Date: Fri, 1 Nov 2024 17:15:13 +0300 Subject: [PATCH] fix: commands and envs --- configs/envs.ts | 3 ++- programs/vault-hub.ts | 36 ++++++++++++++++++------------------ 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/configs/envs.ts b/configs/envs.ts index 00df2fd..90b249b 100644 --- a/configs/envs.ts +++ b/configs/envs.ts @@ -6,7 +6,8 @@ export const envs = parsed; if (envs) { envs.DEPLOYED = envs?.DEPLOYED || (process.env.DEPLOYED as string); envs.RPC_URL_1 = envs?.RPC_URL_1 || (process.env.RPC_URL_1 as string); - envs.RPC_URL_17000 = envs?.RPC_URL_137 || (process.env.RPC_URL_137 as string); + envs.RPC_URL_17000 = + envs?.RPC_URL_17000 || (process.env.RPC_URL_17000 as string); envs.PRIVATE_KEY_1 = envs?.PRIVATE_KEY_1 || (process.env.PRIVATE_KEY_1 as string); diff --git a/programs/vault-hub.ts b/programs/vault-hub.ts index 0ef9763..12bcd16 100644 --- a/programs/vault-hub.ts +++ b/programs/vault-hub.ts @@ -8,7 +8,7 @@ const vaultHub = program.command("vh").description("vault hub contract"); vaultHub .command("constants") .description("get vault hub constants") - .option("--chainId", "chainId") + .option("-c, --chainId ", "chainId") .action(async ({ chainId }) => { const contract = getVaultHubContract(chainId); @@ -26,7 +26,7 @@ vaultHub vaultHub .command("v-count") .description("get vaults count") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .action(async (chainId) => { const contract = getVaultHubContract(chainId); @@ -38,9 +38,9 @@ vaultHub vaultHub .command("v") .description("get vault") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "index") - .action(async (chainId, index) => { + .action(async (index, { chainId }) => { const contract = getVaultHubContract(chainId); const vault = await contract.read.vault(index); @@ -55,9 +55,9 @@ vaultHub vaultHub .command("rr-index") .description("get reserve ratio by index") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "index") - .action(async (chainId, index) => { + .action(async (index, { chainId }) => { const contract = getVaultHubContract(chainId); const vault = await contract.read.vault(index); @@ -69,9 +69,9 @@ vaultHub vaultHub .command("rr-vault") .description("get reserve ratio by vault") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "vault") - .action(async (chainId, vault) => { + .action(async (vault, { chainId }) => { const contract = getVaultHubContract(chainId); const reserveRatio = await contract.read.reserveRatio([vault]); @@ -82,13 +82,13 @@ vaultHub vaultHub .command("v-connect") .description("connect vault") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "vault") .argument("", "cap shares") .argument("", "min reserve ratio bp") .argument("", "treasury fee bp") .action( - async (chainId, vault, capShares, minReserveRatioBP, treasuryFeeBP) => { + async (vault, capShares, minReserveRatioBP, treasuryFeeBP, { chainId }) => { const contract = getVaultHubContract(chainId); const tx = await contract.write.connectVault( @@ -108,10 +108,10 @@ vaultHub .description( "mint StETH tokens backed by vault external balance to the receiver address" ) // Description of the command - .argument("", "chainId") // Argument: chain ID + .option("-c, --chainId ", "chainId") // Argument: chain ID .argument("", "receiver") // Argument: receiver address .argument("", "amount") // Argument: amount to mint - .action(async (chainId, receiver: Address, amount) => { + .action(async (receiver: Address, amount, { chainId }) => { // Get the VaultHub contract instance for the specified chain ID const contract = getVaultHubContract(chainId); @@ -128,9 +128,9 @@ vaultHub vaultHub .command("v-burn-steth") .description("burn steth from the balance of the vault contract") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "amount") - .action(async (chainId, amount) => { + .action(async (amount, { chainId }) => { const contract = getVaultHubContract(chainId); const tx = await contract.write.burnStethBackedByVault([amount], { @@ -144,9 +144,9 @@ vaultHub vaultHub .command("v-force-balance") .description("force rebalance of the vault") - .argument("", "chainId") + .option("-c, --chainId ", "chainId") .argument("", "vault") - .action(async (chainId, vault) => { + .action(async (vault, { chainId }) => { const contract = getVaultHubContract(chainId); const tx = await contract.write.forceRebalance([vault], { @@ -162,8 +162,8 @@ vaultHub .description( "rebalances the vault, by writing off the amount equal to passed ether from the vault's minted stETH counter" ) - .argument("", "chainId") - .action(async (chainId) => { + .option("-c, --chainId ", "chainId") + .action(async ({ chainId }) => { const contract = getVaultHubContract(chainId); const tx = await contract.write.rebalance({