aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/schemas/token_schema.ts12
-rw-r--r--src/utils/schema_validator.ts2
2 files changed, 14 insertions, 0 deletions
diff --git a/src/schemas/token_schema.ts b/src/schemas/token_schema.ts
new file mode 100644
index 000000000..01702af68
--- /dev/null
+++ b/src/schemas/token_schema.ts
@@ -0,0 +1,12 @@
+export const tokenSchema = {
+ id: '/token',
+ properties: {
+ name: {type: 'string'},
+ symbol: {type: 'string'},
+ decimals: {type: 'number'},
+ address: {type: 'string'},
+ url: {type: 'string'},
+ },
+ required: ['name', 'symbol', 'decimals', 'address', 'url'],
+ type: 'object',
+};
diff --git a/src/utils/schema_validator.ts b/src/utils/schema_validator.ts
index 61f4c09c8..8132f7414 100644
--- a/src/utils/schema_validator.ts
+++ b/src/utils/schema_validator.ts
@@ -1,5 +1,6 @@
import {Validator, ValidatorResult} from 'jsonschema';
import {ecSignatureSchema, ecSignatureParameter} from '../schemas/ec_signature_schema';
+import {tokenSchema} from '../schemas/token_schema';
export class SchemaValidator {
private validator: Validator;
@@ -7,6 +8,7 @@ export class SchemaValidator {
this.validator = new Validator();
this.validator.addSchema(ecSignatureParameter, ecSignatureParameter.id);
this.validator.addSchema(ecSignatureSchema, ecSignatureSchema.id);
+ this.validator.addSchema(tokenSchema, tokenSchema.id);
}
public validate(instance: object, schema: Schema): ValidatorResult {
return this.validator.validate(instance, schema);