From 77ff2d9ad1e6c43fa6d5763b36e1f33fe7b65466 Mon Sep 17 00:00:00 2001 From: Atatakai Date: Wed, 28 Aug 2024 12:48:46 +0400 Subject: [PATCH 1/2] (launch) fix: allow empty agentIds --- apps/launch/common-util/functions/stakingContract.ts | 2 +- .../components/MyStakingContracts/Create/useFieldRules.tsx | 1 - .../MyStakingContracts/Details/ContractConfiguration.tsx | 3 ++- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/launch/common-util/functions/stakingContract.ts b/apps/launch/common-util/functions/stakingContract.ts index f08edf60..9903d4d7 100644 --- a/apps/launch/common-util/functions/stakingContract.ts +++ b/apps/launch/common-util/functions/stakingContract.ts @@ -55,7 +55,7 @@ export const getStakingContractInitPayload = ({ livenessPeriod, timeForEmissions, numAgentInstances, - agentIds: agentIds.split(/,\s?/).map((agentId) => Number(agentId)), + agentIds: agentIds ? agentIds.split(/,\s?/).map((agentId) => Number(agentId)) : [], threshold, configHash, activityChecker, diff --git a/apps/launch/components/MyStakingContracts/Create/useFieldRules.tsx b/apps/launch/components/MyStakingContracts/Create/useFieldRules.tsx index ecb3cb8b..fea8bfb0 100644 --- a/apps/launch/components/MyStakingContracts/Create/useFieldRules.tsx +++ b/apps/launch/components/MyStakingContracts/Create/useFieldRules.tsx @@ -101,7 +101,6 @@ export const useFieldRules = (): StakingDepositRules => { numAgentInstances: { rules: getGenericFieldRules(FieldConfig.numAgentInstances.name) }, agentIds: { rules: [ - ...getGenericFieldRules(FieldConfig.agentIds.name), { ...FORM_VALIDATION.validateCommaSeparatedList }, ], }, diff --git a/apps/launch/components/MyStakingContracts/Details/ContractConfiguration.tsx b/apps/launch/components/MyStakingContracts/Details/ContractConfiguration.tsx index 0569cdda..5fdacb72 100644 --- a/apps/launch/components/MyStakingContracts/Details/ContractConfiguration.tsx +++ b/apps/launch/components/MyStakingContracts/Details/ContractConfiguration.tsx @@ -129,7 +129,8 @@ const AgentIds: FC<{ address: Address }> = ({ address }) => { return data.map((id) => ( From c8336edbf512d2014950be11cefecd1f49cfb4ec Mon Sep 17 00:00:00 2001 From: Atatakai Date: Wed, 28 Aug 2024 12:56:37 +0400 Subject: [PATCH 2/2] (launch) fix: remove agent ids required test --- .../MyStakingContracts/Create/index.spec.tsx | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/apps/launch/components/MyStakingContracts/Create/index.spec.tsx b/apps/launch/components/MyStakingContracts/Create/index.spec.tsx index cb27a93c..020257bb 100644 --- a/apps/launch/components/MyStakingContracts/Create/index.spec.tsx +++ b/apps/launch/components/MyStakingContracts/Create/index.spec.tsx @@ -203,22 +203,6 @@ describe('', () => { expect(numAgentInstancesInput).toHaveValue('1'); // default value }); - // Agent IDs - it('should display `Agent IDs` field as required and able to fill the field', async () => { - render(); - - const agentIdsInput = screen.getByLabelText('Agent IDs'); - expect(agentIdsInput).toBeRequired(); - - await userEvent.clear(agentIdsInput); - await userEvent.type(agentIdsInput, '1,2, '); - - await clickCreateContractButton(); - expect( - screen.getByText('Please input a valid list of numbers separated by commas.'), - ).toBeInTheDocument(); - }); - // Multisig threshold it('should display `Multisig threshold` field as required and able to fill the field', async () => { render();