Skip to content

Commit

Permalink
feat: data node rule
Browse files Browse the repository at this point in the history
  • Loading branch information
HuberTRoy committed Nov 11, 2024
1 parent f390bc1 commit 43ebec7
Showing 1 changed file with 37 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -171,49 +171,56 @@ const RpcSetting: FC<IProps> = (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]);

Expand Down

0 comments on commit 43ebec7

Please sign in to comment.