Skip to content

Commit da96bcb

Browse files
authored
Merge pull request #96 from smartcontractkit/ggoh/DPA-1321/chain-config-bundle-id-label
[DPA-1321]: fix(chainconfig): attach label to key bundle id
2 parents ccb1bb7 + 8ad69f6 commit da96bcb

File tree

3 files changed

+52
-3
lines changed

3 files changed

+52
-3
lines changed

.changeset/nervous-cups-invite.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@smartcontractkit/operator-ui': minor
3+
---
4+
5+
chainconfig: attach chain type label to key bundle id in UI

src/components/Form/ChainConfigurationForm.test.tsx

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,36 @@ describe('ChainConfigurationForm', () => {
333333
})
334334
})
335335

336+
test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
337+
const handleSubmit = jest.fn()
338+
const initialValues = emptyFormValues()
339+
initialValues.chainType = ChainTypes.EVM
340+
341+
const { container } = renderChainConfigurationForm(
342+
initialValues,
343+
handleSubmit,
344+
[],
345+
{
346+
aptosKeys: {
347+
results: [],
348+
},
349+
solanaKeys: {
350+
results: [],
351+
},
352+
},
353+
)
354+
355+
const ocr2CheckBox = screen.getByText(/ocr2/i)
356+
userEvent.click(ocr2CheckBox)
357+
358+
const keyBundleId2 = container.querySelector('#select-ocr2KeyBundleID')
359+
expect(keyBundleId2).toBeInTheDocument()
360+
// workaround ts lint warning - require check for null
361+
keyBundleId2 && userEvent.click(keyBundleId2)
362+
userEvent.click(getByRole('option', { name: 'ocr2_key_bundle_id (EVM)' }))
363+
await screen.findByRole('button', { name: 'ocr2_key_bundle_id (EVM)' })
364+
})
365+
336366
function emptyFormValues(): FormValues {
337367
return {
338368
chainID: '',
@@ -407,7 +437,15 @@ function renderChainConfigurationForm(
407437
chains={chains}
408438
p2pKeys={[]}
409439
ocrKeys={[]}
410-
ocr2Keys={[]}
440+
ocr2Keys={[
441+
{
442+
id: 'ocr2_key_bundle_id',
443+
chainType: 'EVM',
444+
offChainPublicKey: 'ocr2_public_key',
445+
onChainPublicKey: 'ocr2_on_chain_public_key',
446+
configPublicKey: 'ocr2_config_public_key',
447+
},
448+
]}
411449
showSubmit
412450
/>,
413451
)

src/components/Form/ChainConfigurationForm.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,12 @@ export const ChainConfigurationForm = withStyles(styles)(
228228
ocr2Keys = [],
229229
showSubmit = false,
230230
}: Props) => {
231+
const sortedOcr2Keys = [...ocr2Keys].sort((a, b) => {
232+
if (a.chainType === b.chainType) {
233+
return a.id.localeCompare(b.id)
234+
}
235+
return a.chainType?.localeCompare(b.chainType ?? '') ?? 0
236+
})
231237
return (
232238
<Formik
233239
innerRef={innerRef}
@@ -573,9 +579,9 @@ export const ChainConfigurationForm = withStyles(styles)(
573579
'ocr2KeyBundleID-helper-text',
574580
}}
575581
>
576-
{ocr2Keys.map((key) => (
582+
{sortedOcr2Keys.map((key) => (
577583
<MenuItem key={key.id} value={key.id}>
578-
{key.id}
584+
{key.id} ({key.chainType})
579585
</MenuItem>
580586
))}
581587
</Field>

0 commit comments

Comments
 (0)