From 43ebec70a156687e886b6a560152e98eb8aaa6db Mon Sep 17 00:00:00 2001 From: cyrbuzz Date: Mon, 11 Nov 2024 14:57:33 +0800 Subject: [PATCH] feat: data node rule --- .../project-details/components/rpcSetting.tsx | 67 ++++++++++--------- 1 file changed, 37 insertions(+), 30 deletions(-) diff --git a/apps/indexer-admin/src/pages/project-details/components/rpcSetting.tsx b/apps/indexer-admin/src/pages/project-details/components/rpcSetting.tsx index b7087585..0582deb0 100644 --- a/apps/indexer-admin/src/pages/project-details/components/rpcSetting.tsx +++ b/apps/indexer-admin/src/pages/project-details/components/rpcSetting.tsx @@ -171,49 +171,56 @@ const RpcSetting: FC = (props) => { }; }; - return { - evm: (endpointType: 'http' | 'ws' | 'metrics', value: string, ruleField: string) => { - if (endpointType === 'metrics') { - const metricsVal = form.getFieldValue(ruleField); - - if (metricsVal) { - return checkIfWsAndHttpSame(); - } + const evmAndDataNodeRule = ( + endpointType: 'http' | 'ws' | 'metrics', + value: string, + ruleField: string + ) => { + if (endpointType === 'metrics') { + const metricsVal = form.getFieldValue(ruleField); - return { - result: true, - }; + if (metricsVal) { + return checkIfWsAndHttpSame(); } - if (endpointType === 'ws') { - const wsVal = form.getFieldValue(ruleField.replace('Http', 'Ws')); - if (wsVal && wsVal?.startsWith('ws')) { - return checkIfWsAndHttpSame(); - } + return { + result: true, + }; + } - if (wsVal && !wsVal?.startsWith('ws')) { - return { - result: false, - message: 'Please input a valid endpoint', - }; - } + if (endpointType === 'ws') { + const wsVal = form.getFieldValue(ruleField.replace('Http', 'Ws')); + if (wsVal && wsVal?.startsWith('ws')) { + return checkIfWsAndHttpSame(); + } + if (wsVal && !wsVal?.startsWith('ws')) { return { - result: true, + result: false, + message: 'Please input a valid endpoint', }; } - if (value?.startsWith('http')) - return { - result: true, - }; return { - result: false, - message: 'Please input a valid endpoint', + result: true, + }; + } + if (value?.startsWith('http')) + return { + result: true, }; - }, + + return { + result: false, + message: 'Please input a valid endpoint', + }; + }; + + return { + evm: evmAndDataNodeRule, polkadot: polkadotAndSubstrateRule, substrate: polkadotAndSubstrateRule, + subql_dict: evmAndDataNodeRule, }; }, [form, keys.data?.getRpcEndpointKeys]);