Skip to content

Commit

Permalink
Merge pull request #549 from subquery/feat/data-node
Browse files Browse the repository at this point in the history
feat: data node rule
  • Loading branch information
HuberTRoy authored Nov 14, 2024
2 parents 639f2a0 + 43ebec7 commit d9e9197
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 d9e9197

Please sign in to comment.