diff --git a/packages-ts/starknet-gauntlet-cli/src/index.ts b/packages-ts/starknet-gauntlet-cli/src/index.ts index b9fcd8f50..f5644d116 100644 --- a/packages-ts/starknet-gauntlet-cli/src/index.ts +++ b/packages-ts/starknet-gauntlet-cli/src/index.ts @@ -8,7 +8,6 @@ import { } from '@chainlink/starknet-gauntlet-example' import { Commands as OZCommands } from '@chainlink/starknet-gauntlet-oz' import { - L1Commands as L1StarkgateCommands, L2Commands as L2StarkgateCommands, InspectionCommands as StarkgateInspectionCommands, } from '@chainlink/starknet-gauntlet-starkgate' @@ -120,7 +119,7 @@ const registerInspectionCommand = ( return registerCommand(deps) } -const L1ExecuteCommands = [...L1StarkgateCommands, ...L1EmergencyProtocolCommands] +const L1ExecuteCommands = [...L1EmergencyProtocolCommands] const L2ExecuteCommands = [ ...OCR2ExecuteCommands, ...ExampleExecuteCommands, diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deploy.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deploy.ts deleted file mode 100644 index 32b5649e5..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deploy.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = {} -type ContractInput = any[] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return {} -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [] -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'deploy', - ux: { - description: 'Deploys an L1 token bridge', - examples: [`${CATEGORIES.L1_BRIDGE}:deploy --network=`], - }, - makeUserInput, - makeContractInput, - validations: [], - loadContract: l1BridgeContractLoader, -} - -// todo: fix type annotation required by compiler -export default makeEVMExecuteCommand(commandConfig) as any diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deposit.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deposit.ts deleted file mode 100644 index 21e1b065a..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/deposit.ts +++ /dev/null @@ -1,62 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { isValidAddress } from '@chainlink/starknet-gauntlet' -import { BigNumber, utils } from 'ethers' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - amount: string - recipient: string -} - -type ContractInput = [amount: BigNumber, recipient: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - amount: flags.amount, - recipient: flags.recipient, - } -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [utils.parseEther(input.amount), input.recipient] -} - -const validateInput = async (input: UserInput): Promise => { - if (isNaN(Number(input.amount))) { - throw new Error(`Invalid amount: ${input.amount}`) - } - - if (!isValidAddress(input.recipient)) { - throw new Error(`Invalid address of L2 recipient: ${input.recipient}`) - } - - return true -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'deposit', - ux: { - description: 'Deposits funds to L1 bridge for L2 recipient', - examples: [ - `${CATEGORIES.L1_BRIDGE}:deposit --network= --recipient=[L2_RECIPIENT_ADDRESS] --amount=[AMOUNT_IN_LINK] [L1_BRIDGE_PROXY_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/index.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/index.ts deleted file mode 100644 index 782a11a68..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/index.ts +++ /dev/null @@ -1,17 +0,0 @@ -import Deploy from './deploy' -import Deposit from './deposit' -import Withdraw from './withdraw' -import SetL2Bridge from './setL2Bridge' -import SetMaxTotalBalance from './setMaxTotalBalance' -import SetMaxDeposit from './setMaxDeposit' -import ProxyDeploy from './proxy/deploy' - -export default [ - Deploy, - SetL2Bridge, - SetMaxTotalBalance, - SetMaxDeposit, - Deposit, - Withdraw, - ProxyDeploy, -] diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/proxy/deploy.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/proxy/deploy.ts deleted file mode 100644 index 497232fbf..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/proxy/deploy.ts +++ /dev/null @@ -1,77 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { utils, constants } from 'ethers' -import { isValidAddress } from '@chainlink/evm-gauntlet' -import { CATEGORIES } from '../../../lib/categories' -import { - l1BridgeContractLoader, - l1BridgeProxyContractLoader, - CONTRACT_LIST, -} from '../../../lib/contracts' - -type UserInput = { - l1BridgeAddress: string - tokenAddress: string - starknetMessagingAddress: string // starknet core contract implements the interface -} -type ContractInput = [l1BridgeAddress: string, encodedInput: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - l1BridgeAddress: flags.bridge, - tokenAddress: flags.token, - starknetMessagingAddress: flags.core, - } -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - const l1BridgeArtifact = await l1BridgeContractLoader() - const l1BridgeInterface = l1BridgeArtifact.interface - const data = utils.hexConcat([ - utils.hexZeroPad(constants.AddressZero, 32), - utils.hexZeroPad(input.tokenAddress, 32), - utils.hexZeroPad(input.starknetMessagingAddress, 32), - ]) - const encodedInput = l1BridgeInterface.encodeFunctionData('initialize(bytes data)', [data]) - return [input.l1BridgeAddress, encodedInput] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.l1BridgeAddress)) { - throw new Error(`Invalid address of L1 bridge: ${input.l1BridgeAddress}`) - } - if (!isValidAddress(input.tokenAddress)) { - throw new Error(`Invalid address of L1 token: ${input.tokenAddress}`) - } - if (!isValidAddress(input.starknetMessagingAddress)) { - throw new Error(`Invalid address of Starknet core: ${input.starknetMessagingAddress}`) - } - return true -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE_PROXY, - category: CATEGORIES.L1_BRIDGE, - action: 'deploy', - suffixes: ['proxy'], - ux: { - description: 'Deploys an L1 token bridge proxy and initialises the bridge', - examples: [ - `${CATEGORIES.L1_BRIDGE}:deploy:proxy --network= --bridge= --token= --core=`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeProxyContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setL2Bridge.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setL2Bridge.ts deleted file mode 100644 index 071a389cd..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setL2Bridge.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { isValidAddress } from '@chainlink/starknet-gauntlet' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - address: string -} - -type ContractInput = [address: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - address: flags.address, - } -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [input.address] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.address)) { - throw new Error(`Invalid address of L2 bridge: ${input.address}`) - } - return true -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'set_l2_bridge', - internalFunction: 'setL2TokenBridge', - ux: { - description: 'Sets L2 bridge', - examples: [ - `${CATEGORIES.L1_BRIDGE}:set_l2_bridge --network= --address=[L2_BRIDGE_ADDRESS] [L1_BRIDGE_PROXY_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxDeposit.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxDeposit.ts deleted file mode 100644 index 73f4a7de9..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxDeposit.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { BigNumber, utils } from 'ethers' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - amount: string -} - -type ContractInput = [amount: BigNumber] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - amount: flags.amount, - } -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [utils.parseEther(input.amount)] -} - -const validateInput = async (input: UserInput): Promise => { - if (isNaN(Number(input.amount))) { - throw new Error(`Invalid amount: ${input.amount}`) - } - - return true -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'set_max_deposit', - internalFunction: 'setMaxDeposit', - ux: { - description: 'Sets Max Deposit amount for the L1 Bridge', - examples: [ - `${CATEGORIES.L1_BRIDGE}:set_max_deposit --network= --amount=[AMOUNT_IN_LINK] [L1_BRIDGE_PROXY_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxTotalBalance.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxTotalBalance.ts deleted file mode 100644 index 8d4ce25ef..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/setMaxTotalBalance.ts +++ /dev/null @@ -1,56 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { BigNumber, utils } from 'ethers' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - amount: string -} - -type ContractInput = [amount: BigNumber] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - amount: flags.amount, - } -} - -const validateInput = async (input: UserInput): Promise => { - if (isNaN(Number(input.amount))) { - throw new Error(`Invalid amount: ${input.amount}`) - } - - return true -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [utils.parseEther(input.amount)] -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'set_max_total_balance', - internalFunction: 'setMaxTotalBalance', - ux: { - description: 'Sets Max Total Balance for the L1 Bridge', - examples: [ - `${CATEGORIES.L1_BRIDGE}:set_max_total_balance --network= --amount=[AMOUNT_IN_LINK] [L1_BRIDGE_PROXY_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/withdraw.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/withdraw.ts deleted file mode 100644 index d6ea82e01..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L1-bridge/withdraw.ts +++ /dev/null @@ -1,63 +0,0 @@ -import { - EVMExecuteCommandConfig, - EVMExecutionContext, - makeEVMExecuteCommand, -} from '@chainlink/evm-gauntlet' -import { isValidAddress } from '@chainlink/evm-gauntlet' -import { BigNumber, utils } from 'ethers' -import { CATEGORIES } from '../../lib/categories' -import { l1BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - amount: string - recipient: string -} - -type ContractInput = [amount: BigNumber, recipient: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - amount: flags.amount, - recipient: flags.recipient, - } -} - -const makeContractInput = async ( - input: UserInput, - context: EVMExecutionContext, -): Promise => { - return [utils.parseEther(input.amount), input.recipient] -} - -const validateInput = async (input: UserInput): Promise => { - if (isNaN(Number(input.amount))) { - throw new Error(`Invalid amount: ${input.amount}`) - } - - if (!isValidAddress(input.recipient)) { - throw new Error(`Invalid address of L1 recipient: ${input.recipient}`) - } - - return true -} - -const commandConfig: EVMExecuteCommandConfig = { - contractId: CONTRACT_LIST.L1_BRIDGE, - category: CATEGORIES.L1_BRIDGE, - action: 'withdraw', - internalFunction: 'withdraw(uint256,address)', - ux: { - description: 'Withdraws funds from L1 bridge to L1 recipient', - examples: [ - `${CATEGORIES.L1_BRIDGE}:withdraw --network= --recipient=[L1_RECIPIENT_ADDRESS] --amount=[AMOUNT_IN_LINK] [L1_BRIDGE_PROXY_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l1BridgeContractLoader, -} - -export default makeEVMExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/deploy.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/deploy.ts deleted file mode 100644 index 5ba87f6bd..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/deploy.ts +++ /dev/null @@ -1,71 +0,0 @@ -import { - BeforeExecute, - ExecuteCommandConfig, - ExecutionContext, - makeExecuteCommand, -} from '@chainlink/starknet-gauntlet' -import { isValidAddress } from '@chainlink/starknet-gauntlet' -import { CATEGORIES } from '../../lib/categories' -import { l2BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - governor?: string -} - -type ContractInput = [governor: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - governor: flags.governor, - } -} - -const makeContractInput = async ( - input: UserInput, - context: ExecutionContext, -): Promise => { - const defaultWallet = context.wallet.getAccountAddress() - return [input.governor || defaultWallet] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.governor)) { - throw new Error(`Invalid governor: ${input.governor}`) - } - - return true -} - -const beforeExecute: BeforeExecute = ( - context, - input, - deps, -) => async () => { - deps.logger.info(`About to deploy an L2 Bridge Contract with the following details: - ${input.contract} - `) -} - -const commandConfig: ExecuteCommandConfig = { - contractId: CONTRACT_LIST.L2_BRIDGE, - category: CATEGORIES.L2_BRIDGE, - action: 'deploy', - ux: { - description: 'Deploys an L2 token bridge', - examples: [ - `${CATEGORIES.L2_BRIDGE}:deploy --network= --governor=[OWNER_ADDRESS]`, - `${CATEGORIES.L2_BRIDGE}:deploy --network=`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l2BridgeContractLoader, - hooks: { - beforeExecute, - }, -} - -export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/index.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/index.ts deleted file mode 100644 index 7989653c3..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -import Deploy from './deploy' -import SetL1Bridge from './setL1Bridge' -import SetL2Token from './setL2Token' -import InitiateWithdraw from './initiateWithdraw' - -export default [Deploy, SetL1Bridge, SetL2Token, InitiateWithdraw] diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/initiateWithdraw.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/initiateWithdraw.ts deleted file mode 100644 index 5229316b3..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/initiateWithdraw.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { - BeforeExecute, - ExecuteCommandConfig, - ExecutionContext, - makeExecuteCommand, -} from '@chainlink/starknet-gauntlet' -import { isValidAddress } from '@chainlink/evm-gauntlet' -import { uint256 } from 'starknet' -import { utils } from 'ethers' -import { CATEGORIES } from '../../lib/categories' -import { l2BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - recipient: string - amount: string -} - -type ContractInput = [recipient: string, amount: any] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - recipient: flags.recipient, - amount: flags.amount, - } -} - -const makeContractInput = async ( - input: UserInput, - context: ExecutionContext, -): Promise => { - const amount = utils.parseEther(input.amount).toString() - return [input.recipient, uint256.bnToUint256(amount)] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.recipient)) { - throw new Error(`Invalid L1 recipient: ${input.recipient}`) - } - - if (isNaN(Number(input.amount))) { - throw new Error(`Invalid amount: ${input.amount}`) - } - - return true -} - -const beforeExecute: BeforeExecute = ( - context, - input, - deps, -) => async () => { - deps.logger.info(`About to initiate withdraw to L1 with the following details: - ${input.contract} - `) -} - -const commandConfig: ExecuteCommandConfig = { - contractId: CONTRACT_LIST.L2_BRIDGE, - category: CATEGORIES.L2_BRIDGE, - action: 'initiate_withdraw', - ux: { - description: 'Initiates withdraw to L1', - examples: [ - `${CATEGORIES.L2_BRIDGE}:initiate_withdraw --network= --recipient=[L1_RECIPIENT_ADDRESS] --amount=[AMOUNT_IN_LINK] [L2_BRIDGE_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l2BridgeContractLoader, - hooks: { - beforeExecute, - }, -} - -export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL1Bridge.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL1Bridge.ts deleted file mode 100644 index d29fc2e11..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL1Bridge.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { - BeforeExecute, - ExecuteCommandConfig, - ExecutionContext, - makeExecuteCommand, -} from '@chainlink/starknet-gauntlet' -import { isValidAddress } from '@chainlink/evm-gauntlet' -import { CATEGORIES } from '../../lib/categories' -import { l2BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - address: string -} - -type ContractInput = [address: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - address: flags.address, - } -} - -const makeContractInput = async ( - input: UserInput, - context: ExecutionContext, -): Promise => { - return [input.address] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.address)) { - throw new Error(`Invalid L1 address: ${input.address}`) - } - - return true -} - -const beforeExecute: BeforeExecute = ( - context, - input, - deps, -) => async () => { - deps.logger.info(`About to set L1 Bridge of an L2 Bridge Contract with the following details: - ${input.contract} - `) -} - -const commandConfig: ExecuteCommandConfig = { - contractId: CONTRACT_LIST.L2_BRIDGE, - category: CATEGORIES.L2_BRIDGE, - action: 'set_l1_bridge', - ux: { - description: 'Sets L1 bridge on an L2 token bridge', - examples: [ - `${CATEGORIES.L2_BRIDGE}:set_l1_bridge --network= --address=[L1_BRIDGE_ADDRESS] [L2_BRIDGE_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l2BridgeContractLoader, - hooks: { - beforeExecute, - }, -} - -export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL2Token.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL2Token.ts deleted file mode 100644 index fe8945df5..000000000 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/L2-bridge/setL2Token.ts +++ /dev/null @@ -1,69 +0,0 @@ -import { - BeforeExecute, - ExecuteCommandConfig, - ExecutionContext, - makeExecuteCommand, -} from '@chainlink/starknet-gauntlet' -import { isValidAddress } from '@chainlink/starknet-gauntlet' -import { CATEGORIES } from '../../lib/categories' -import { l2BridgeContractLoader, CONTRACT_LIST } from '../../lib/contracts' - -type UserInput = { - address: string -} - -type ContractInput = [address: string] - -const makeUserInput = async (flags, args): Promise => { - if (flags.input) return flags.input as UserInput - - return { - address: flags.address, - } -} - -const makeContractInput = async ( - input: UserInput, - context: ExecutionContext, -): Promise => { - return [input.address] -} - -const validateInput = async (input: UserInput): Promise => { - if (!isValidAddress(input.address)) { - throw new Error(`Invalid L2 token address: ${input.address}`) - } - - return true -} - -const beforeExecute: BeforeExecute = ( - context, - input, - deps, -) => async () => { - deps.logger.info(`About to set L2 Token of an L2 Bridge Contract with the following details: - ${input.contract} - `) -} - -const commandConfig: ExecuteCommandConfig = { - contractId: CONTRACT_LIST.L2_BRIDGE, - category: CATEGORIES.L2_BRIDGE, - action: 'set_l2_token', - ux: { - description: 'Sets L1 token on an L2 token bridge', - examples: [ - `${CATEGORIES.L2_BRIDGE}:set_l2_token --network= --address=[L2_TOKEN_ADDRESS] [L2_BRIDGE_ADDRESS]`, - ], - }, - makeUserInput, - makeContractInput, - validations: [validateInput], - loadContract: l2BridgeContractLoader, - hooks: { - beforeExecute, - }, -} - -export default makeExecuteCommand(commandConfig) diff --git a/packages-ts/starknet-gauntlet-starkgate/src/commands/index.ts b/packages-ts/starknet-gauntlet-starkgate/src/commands/index.ts index 3bad33a4c..a42b7c65a 100644 --- a/packages-ts/starknet-gauntlet-starkgate/src/commands/index.ts +++ b/packages-ts/starknet-gauntlet-starkgate/src/commands/index.ts @@ -1,8 +1,5 @@ import Token from './token' -import L1Bridge from './L1-bridge' -import L2Bridge from './L2-bridge' import Inspection from './inspection' -export const L1Commands = [...L1Bridge] -export const L2Commands = [...Token, ...L2Bridge] +export const L2Commands = [...Token] export const InspectionCommands = [...Inspection] diff --git a/packages-ts/starknet-gauntlet-starkgate/src/index.ts b/packages-ts/starknet-gauntlet-starkgate/src/index.ts index b793ffb4a..680f5a6d1 100644 --- a/packages-ts/starknet-gauntlet-starkgate/src/index.ts +++ b/packages-ts/starknet-gauntlet-starkgate/src/index.ts @@ -1,3 +1,3 @@ -import { L1Commands, L2Commands, InspectionCommands } from './commands' +import { L2Commands, InspectionCommands } from './commands' -export { L1Commands, L2Commands, InspectionCommands } +export { L2Commands, InspectionCommands }