classic-ui/services/schema/index.js
FreezyEx b32527e057 Revert "minor fixes"
This reverts commit 7f8f7c2aa15c8b8c6a7449d177f46f8a417e2f67.
2022-10-13 16:03:54 +02:00

43 lines
816 B
JavaScript

import { toBN } from 'web3-utils'
import relayerSchemas from './relayer'
const Ajv = require('ajv')
const ajv = new Ajv({ allErrors: true, schemas: relayerSchemas })
ajv.addKeyword('BN', {
validate: (schema, data) => {
try {
toBN(data)
return true
} catch (e) {
return false
}
},
errors: true
})
function getRelayerValidateFunction(netId) {
switch (netId) {
case 56:
return ajv.getSchema('bscRelayer')
case 100:
return ajv.getSchema('xdaiRelayer')
case 137:
return ajv.getSchema('polygonRelayer')
case 43114:
return ajv.getSchema('avalancheRelayer')
case 10:
case 42161:
return ajv.getSchema('l2Relayer')
default:
return ajv.getSchema('defaultRelayer')
}
}
export default {
getRelayerValidateFunction
}