Skip to content

Commit

Permalink
Merge pull request #96 from smartcontractkit/ggoh/DPA-1321/chain-conf…
Browse files Browse the repository at this point in the history
…ig-bundle-id-label

[DPA-1321]: fix(chainconfig): attach label to key bundle id
  • Loading branch information
archseer authored Nov 20, 2024
2 parents ccb1bb7 + 8ad69f6 commit da96bcb
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/nervous-cups-invite.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@smartcontractkit/operator-ui': minor
---

chainconfig: attach chain type label to key bundle id in UI
40 changes: 39 additions & 1 deletion src/components/Form/ChainConfigurationForm.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,36 @@ describe('ChainConfigurationForm', () => {
})
})

test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
const handleSubmit = jest.fn()
const initialValues = emptyFormValues()
initialValues.chainType = ChainTypes.EVM

const { container } = renderChainConfigurationForm(
initialValues,
handleSubmit,
[],
{
aptosKeys: {
results: [],
},
solanaKeys: {
results: [],
},
},
)

const ocr2CheckBox = screen.getByText(/ocr2/i)
userEvent.click(ocr2CheckBox)

const keyBundleId2 = container.querySelector('#select-ocr2KeyBundleID')
expect(keyBundleId2).toBeInTheDocument()
// workaround ts lint warning - require check for null
keyBundleId2 && userEvent.click(keyBundleId2)
userEvent.click(getByRole('option', { name: 'ocr2_key_bundle_id (EVM)' }))
await screen.findByRole('button', { name: 'ocr2_key_bundle_id (EVM)' })
})

function emptyFormValues(): FormValues {
return {
chainID: '',
Expand Down Expand Up @@ -407,7 +437,15 @@ function renderChainConfigurationForm(
chains={chains}
p2pKeys={[]}
ocrKeys={[]}
ocr2Keys={[]}
ocr2Keys={[
{
id: 'ocr2_key_bundle_id',
chainType: 'EVM',
offChainPublicKey: 'ocr2_public_key',
onChainPublicKey: 'ocr2_on_chain_public_key',
configPublicKey: 'ocr2_config_public_key',
},
]}
showSubmit
/>,
)
Expand Down
10 changes: 8 additions & 2 deletions src/components/Form/ChainConfigurationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,12 @@ export const ChainConfigurationForm = withStyles(styles)(
ocr2Keys = [],
showSubmit = false,
}: Props) => {
const sortedOcr2Keys = [...ocr2Keys].sort((a, b) => {
if (a.chainType === b.chainType) {
return a.id.localeCompare(b.id)
}
return a.chainType?.localeCompare(b.chainType ?? '') ?? 0
})
return (
<Formik
innerRef={innerRef}
Expand Down Expand Up @@ -573,9 +579,9 @@ export const ChainConfigurationForm = withStyles(styles)(
'ocr2KeyBundleID-helper-text',
}}
>
{ocr2Keys.map((key) => (
{sortedOcr2Keys.map((key) => (
<MenuItem key={key.id} value={key.id}>
{key.id}
{key.id} ({key.chainType})
</MenuItem>
))}
</Field>
Expand Down

0 comments on commit da96bcb

Please sign in to comment.