diff --git a/.changeset/brown-horses-give.md b/.changeset/brown-horses-give.md new file mode 100644 index 00000000..e1433e65 --- /dev/null +++ b/.changeset/brown-horses-give.md @@ -0,0 +1,5 @@ +--- +'@smartcontractkit/operator-ui': minor +--- + +feat: create tron chain config diff --git a/src/components/Form/ChainConfigurationForm.test.tsx b/src/components/Form/ChainConfigurationForm.test.tsx index d42751da..7ae067c8 100644 --- a/src/components/Form/ChainConfigurationForm.test.tsx +++ b/src/components/Form/ChainConfigurationForm.test.tsx @@ -232,6 +232,9 @@ describe('ChainConfigurationForm', () => { solanaKeys: { results: [], }, + tronKeys: { + results: [], + }, }) const chainType = getByRole('button', { name: 'EVM' }) @@ -334,6 +337,61 @@ describe('ChainConfigurationForm', () => { }) }) +test('should able to create Tron chain config', async () => { + const handleSubmit = jest.fn() + const initialValues = emptyFormValues() + initialValues.chainType = ChainTypes.EVM + initialValues.adminAddr = '0x1234567' + + const { container } = renderChainConfigurationForm( + initialValues, + handleSubmit, + ) + + const chainType = getByRole('button', { name: 'EVM' }) + userEvent.click(chainType) + userEvent.click(getByRole('option', { name: 'TRON' })) + await screen.findByRole('button', { name: 'TRON' }) + + await selectChainIdOnUI(container, '4444') + + const address = container.querySelector('#select-accountAddr') + expect(address).toBeInTheDocument() + address && userEvent.click(address) + userEvent.click(getByRole('option', { name: 'tron_xxxx' })) + await screen.findByRole('button', { name: 'tron_xxxx' }) + + await userEvent.click(getByRole('button', { name: /submit/i })) + + await waitFor(() => { + expect(handleSubmit).toHaveBeenCalledWith({ + accountAddr: 'tron_xxxx', + accountAddrPubKey: '', + adminAddr: '0x1234567', + chainID: '4444', + chainType: 'TRON', + fluxMonitorEnabled: false, + ocr1Enabled: false, + ocr1IsBootstrap: false, + ocr1KeyBundleID: '', + ocr1Multiaddr: '', + ocr1P2PPeerID: '', + ocr2CommitPluginEnabled: false, + ocr2Enabled: false, + ocr2ExecutePluginEnabled: false, + ocr2ForwarderAddress: '', + ocr2IsBootstrap: false, + ocr2KeyBundleID: '', + ocr2MedianPluginEnabled: false, + ocr2MercuryPluginEnabled: false, + ocr2Multiaddr: '', + ocr2P2PPeerID: '', + ocr2RebalancerPluginEnabled: false, + }) + expect(handleSubmit).toHaveBeenCalledTimes(1) + }) +}) + test('should be able to select OCR2 Job Type with Key Bundle ID', async () => { const handleSubmit = jest.fn() const initialValues = emptyFormValues() @@ -350,6 +408,9 @@ test('should be able to select OCR2 Job Type with Key Bundle ID', async () => { solanaKeys: { results: [], }, + tronKeys: { + results: [], + }, }, ) @@ -410,6 +471,11 @@ function renderChainConfigurationForm( enabled: true, network: 'solana', }, + { + id: '4444', + enabled: true, + network: 'tron', + }, ], accountsNonEvm: FetchNonEvmKeys | undefined = { aptosKeys: { @@ -418,6 +484,9 @@ function renderChainConfigurationForm( solanaKeys: { results: [{ id: 'solana_xxxx' }], }, + tronKeys: { + results: [{ id: 'tron_xxxx' }], + }, }, ) { return render( diff --git a/src/components/Form/ChainConfigurationForm.tsx b/src/components/Form/ChainConfigurationForm.tsx index 1fb71c19..4065cb10 100644 --- a/src/components/Form/ChainConfigurationForm.tsx +++ b/src/components/Form/ChainConfigurationForm.tsx @@ -260,6 +260,10 @@ export const ChainConfigurationForm = withStyles(styles)( chainAccountAddresses = accountsNonEvm?.solanaKeys.results.map((acc) => acc.id) ?? [] break + case ChainTypes.TRON: + chainAccountAddresses = + accountsNonEvm?.tronKeys.results.map((acc) => acc.id) ?? [] + break default: chainAccountAddresses = [] } @@ -295,6 +299,9 @@ export const ChainConfigurationForm = withStyles(styles)( + diff --git a/src/components/Form/ChainTypes.ts b/src/components/Form/ChainTypes.ts index 387bc7b8..f1244c4e 100644 --- a/src/components/Form/ChainTypes.ts +++ b/src/components/Form/ChainTypes.ts @@ -4,4 +4,5 @@ export const ChainTypes = { SOLANA: 'SOLANA', STARKNET: 'STARKNET', COSMOS: 'COSMOS', + TRON: 'TRON', } diff --git a/src/hooks/queries/useNonEvmAccountsQuery.test.tsx b/src/hooks/queries/useNonEvmAccountsQuery.test.tsx index 1fb5a8f7..9eba91ed 100644 --- a/src/hooks/queries/useNonEvmAccountsQuery.test.tsx +++ b/src/hooks/queries/useNonEvmAccountsQuery.test.tsx @@ -19,6 +19,10 @@ const mockData = { __typename: 'SolanaKeys', results: [{ __typename: 'SolanaKey', id: '3' }], }, + tronKeys: { + __typename: 'TronKeys', + results: [{ __typename: 'TronKey', id: '4' }], + }, }, } @@ -51,6 +55,12 @@ const TestComponent: React.FC = () => {
Solana ID: {key.id}
))} + + {data?.tronKeys.results.map((key, i) => ( +Tron ID: {key.id}
+