Skip to content

Commit 9db0cda

Browse files
authored
Merge pull request #103 from smartcontractkit/NONEVM-1866-ton-support
feat: add TON operator UI support
2 parents c44b37a + a542661 commit 9db0cda

File tree

7 files changed

+115
-0
lines changed

7 files changed

+115
-0
lines changed

.changeset/heavy-lobsters-walk.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+
feat: add TON operator UI support

src/components/Form/ChainConfigurationForm.test.tsx

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ describe('ChainConfigurationForm', () => {
238238
tronKeys: {
239239
results: [],
240240
},
241+
tonKeys: {
242+
results: [],
243+
},
241244
})
242245

243246
const chainType = getByRole('button', { name: 'EVM' })
@@ -395,6 +398,61 @@ test('should able to create Tron chain config', async () => {
395398
})
396399
})
397400

401+
test('should able to create TON chain config', async () => {
402+
const handleSubmit = jest.fn()
403+
const initialValues = emptyFormValues()
404+
initialValues.chainType = ChainTypes.EVM
405+
initialValues.adminAddr = '0x1234567'
406+
407+
const { container } = renderChainConfigurationForm(
408+
initialValues,
409+
handleSubmit,
410+
)
411+
412+
const chainType = getByRole('button', { name: 'EVM' })
413+
userEvent.click(chainType)
414+
userEvent.click(getByRole('option', { name: 'TON' }))
415+
await screen.findByRole('button', { name: 'TON' })
416+
417+
await selectChainIdOnUI(container, '5555')
418+
419+
const address = container.querySelector('#select-accountAddr')
420+
expect(address).toBeInTheDocument()
421+
address && userEvent.click(address)
422+
userEvent.click(getByRole('option', { name: 'ton_xxxx' }))
423+
await screen.findByRole('button', { name: 'ton_xxxx' })
424+
425+
await userEvent.click(getByRole('button', { name: /submit/i }))
426+
427+
await waitFor(() => {
428+
expect(handleSubmit).toHaveBeenCalledWith({
429+
accountAddr: 'ton_xxxx',
430+
accountAddrPubKey: '',
431+
adminAddr: '0x1234567',
432+
chainID: '5555',
433+
chainType: 'TON',
434+
fluxMonitorEnabled: false,
435+
ocr1Enabled: false,
436+
ocr1IsBootstrap: false,
437+
ocr1KeyBundleID: '',
438+
ocr1Multiaddr: '',
439+
ocr1P2PPeerID: '',
440+
ocr2CommitPluginEnabled: false,
441+
ocr2Enabled: false,
442+
ocr2ExecutePluginEnabled: false,
443+
ocr2ForwarderAddress: '',
444+
ocr2IsBootstrap: false,
445+
ocr2KeyBundleID: '',
446+
ocr2MedianPluginEnabled: false,
447+
ocr2MercuryPluginEnabled: false,
448+
ocr2Multiaddr: '',
449+
ocr2P2PPeerID: '',
450+
ocr2RebalancerPluginEnabled: false,
451+
})
452+
expect(handleSubmit).toHaveBeenCalledTimes(1)
453+
})
454+
})
455+
398456
test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
399457
const handleSubmit = jest.fn()
400458
const initialValues = emptyFormValues()
@@ -417,6 +475,9 @@ test('should be able to select OCR2 Job Type with Key Bundle ID', async () => {
417475
tronKeys: {
418476
results: [],
419477
},
478+
tonKeys: {
479+
results: [],
480+
},
420481
},
421482
)
422483

@@ -482,6 +543,11 @@ function renderChainConfigurationForm(
482543
enabled: true,
483544
network: 'tron',
484545
},
546+
{
547+
id: '5555',
548+
enabled: true,
549+
network: 'ton',
550+
},
485551
],
486552
accountsNonEvm: FetchNonEvmKeys | undefined = {
487553
aptosKeys: {
@@ -496,6 +562,9 @@ function renderChainConfigurationForm(
496562
tronKeys: {
497563
results: [{ id: 'tron_xxxx' }],
498564
},
565+
tonKeys: {
566+
results: [{ addressBase64: '123', rawAddress: '0:456', id: 'ton_xxxx' }],
567+
},
499568
},
500569
) {
501570
return render(

src/components/Form/ChainConfigurationForm.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,10 @@ export const ChainConfigurationForm = withStyles(styles)(
264264
chainAccountAddresses =
265265
accountsNonEvm?.tronKeys.results.map((acc) => acc.id) ?? []
266266
break
267+
case ChainTypes.TON:
268+
chainAccountAddresses =
269+
accountsNonEvm?.tonKeys.results.map((acc) => acc.id) ?? []
270+
break
267271
default:
268272
chainAccountAddresses = []
269273
}
@@ -302,6 +306,9 @@ export const ChainConfigurationForm = withStyles(styles)(
302306
<MenuItem key={ChainTypes.TRON} value={ChainTypes.TRON}>
303307
TRON
304308
</MenuItem>
309+
<MenuItem key={ChainTypes.TON} value={ChainTypes.TON}>
310+
TON
311+
</MenuItem>
305312
</Field>
306313
</Grid>
307314

src/components/Form/ChainTypes.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,5 @@ export const ChainTypes = {
55
STARKNET: 'STARKNET',
66
COSMOS: 'COSMOS',
77
TRON: 'TRON',
8+
TON: 'TON',
89
}

src/hooks/queries/useNonEvmAccountsQuery.test.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ const mockData = {
2323
__typename: 'TronKeys',
2424
results: [{ __typename: 'TronKey', id: '4' }],
2525
},
26+
tonKeys: {
27+
__typename: 'TONKeys',
28+
results: [{ __typename: 'TONKey', id: '5' }],
29+
},
2630
},
2731
}
2832

@@ -61,6 +65,12 @@ const TestComponent: React.FC = () => {
6165
<p>Tron ID: {key.id}</p>
6266
</div>
6367
))}
68+
69+
{data?.tonKeys.results.map((key, i) => (
70+
<div key={i}>
71+
<p>TON ID: {key.id}</p>
72+
</div>
73+
))}
6474
</div>
6575
)
6676
}
@@ -81,6 +91,7 @@ describe('useNonEvmAccountsQuery', () => {
8191

8292
expect(screen.getByText('Solana ID: 3')).toBeInTheDocument()
8393
expect(screen.getByText('Tron ID: 4')).toBeInTheDocument()
94+
expect(screen.getByText('TON ID: 5')).toBeInTheDocument()
8495
})
8596
})
8697
})

src/hooks/queries/useNonEvmAccountsQuery.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,20 @@ export const TRON_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
2525
}
2626
`
2727

28+
export const TON_KEYS_PAYLOAD__RESULTS_FIELDS = gql`
29+
fragment TONKeysPayload_ResultsFields on TONKey {
30+
addressBase64
31+
rawAddress
32+
id
33+
}
34+
`
35+
2836
export const NON_EVM_KEYS_QUERY = gql`
2937
${APTOS_KEYS_PAYLOAD__RESULTS_FIELDS}
3038
${SOLANA_KEYS_PAYLOAD__RESULTS_FIELDS}
3139
${STARKNET_KEYS_PAYLOAD__RESULTS_FIELDS}
3240
${TRON_KEYS_PAYLOAD__RESULTS_FIELDS}
41+
${TON_KEYS_PAYLOAD__RESULTS_FIELDS}
3342
query FetchNonEvmKeys {
3443
aptosKeys {
3544
results {
@@ -51,6 +60,11 @@ export const NON_EVM_KEYS_QUERY = gql`
5160
...TronKeysPayload_ResultsFields
5261
}
5362
}
63+
tonKeys {
64+
results {
65+
...TONKeysPayload_ResultsFields
66+
}
67+
}
5468
}
5569
`
5670

src/screens/KeyManagement/NonEVMKeys.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,14 @@ const SCHEMAS = {
2626
title: 'TRON',
2727
fields: [{ label: 'Public Key', key: 'id', copy: true }],
2828
},
29+
tonKeys: {
30+
title: 'TON',
31+
fields: [
32+
{ label: 'Public Key', key: 'id', copy: true },
33+
{ label: 'Base64 Address', key: 'addressBase64', copy: true },
34+
{ label: 'Raw Address', key: 'rawAddress', copy: true },
35+
],
36+
},
2937
}
3038

3139
export const NonEVMKeys = () => {

0 commit comments

Comments
 (0)