Init
This commit is contained in:
commit
e5a7886b9c
7 files changed
+316
No files matched your search
+76
@@ -0,0 +1,76 @@
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
!.vscode/tasks.json
|
||||
!.vscode/launch.json
|
||||
!.vscode/extensions.json
|
||||
!.vscode/*.code-snippets
|
||||
.history/
|
||||
*.vsix
|
||||
cmake-build-*/
|
||||
*.iws
|
||||
out/
|
||||
atlassian-ide-plugin.xml
|
||||
com_crashlytics_export_strings.xml
|
||||
crashlytics.properties
|
||||
crashlytics-build.properties
|
||||
fabric.properties
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
.pnpm-debug.log*
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
lib-cov
|
||||
coverage
|
||||
*.lcov
|
||||
.nyc_output
|
||||
.grunt
|
||||
bower_components
|
||||
.lock-wscript
|
||||
build/Release
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
web_modules/
|
||||
*.tsbuildinfo
|
||||
.npm
|
||||
.eslintcache
|
||||
.stylelintcache
|
||||
.rpt2_cache/
|
||||
.rts2_cache_cjs/
|
||||
.rts2_cache_es/
|
||||
.rts2_cache_umd/
|
||||
.node_repl_history
|
||||
*.tgz
|
||||
.yarn-integrity
|
||||
.env
|
||||
.env.development.local
|
||||
.env.test.local
|
||||
.env.production.local
|
||||
.env.local
|
||||
.cache
|
||||
.parcel-cache
|
||||
.next
|
||||
out
|
||||
.nuxt
|
||||
dist
|
||||
.cache/
|
||||
.vuepress/dist
|
||||
.temp
|
||||
.docusaurus
|
||||
.serverless/
|
||||
.fusebox/
|
||||
.dynamodb/
|
||||
.tern-port
|
||||
.vscode-test
|
||||
.yarn/cache
|
||||
.yarn/unplugged
|
||||
.yarn/build-state.yml
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
.idea
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"name": "ExampleToken",
|
||||
"ticker": "EXT",
|
||||
"title": "Example Token Network",
|
||||
"iconFileName": "0x1234567890abcdef1234567890abcdef12345678.png",
|
||||
"infoURL": "https://example.com/info",
|
||||
"contractAddress": "0x1234567890abcdef1234567890abcdef12345678",
|
||||
"type": "fungible",
|
||||
"decimals": 18,
|
||||
"description": "This is an example token used for demonstrating the JSON schema validation.",
|
||||
"website": "https://example.com",
|
||||
"whitepaper": "https://example.com/whitepaper",
|
||||
"initialSupply": 1000000,
|
||||
"totalSupply": 5000000,
|
||||
"maxSupply": 10000000
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 23 KiB |
Generated
+71
@@ -0,0 +1,71 @@
|
||||
{
|
||||
"name": "token-list",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "token-list",
|
||||
"version": "1.0.0",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1",
|
||||
"ajv-formats": "^3.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv": {
|
||||
"version": "8.17.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv/-/ajv-8.17.1.tgz",
|
||||
"integrity": "sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==",
|
||||
"dependencies": {
|
||||
"fast-deep-equal": "^3.1.3",
|
||||
"fast-uri": "^3.0.1",
|
||||
"json-schema-traverse": "^1.0.0",
|
||||
"require-from-string": "^2.0.2"
|
||||
},
|
||||
"funding": {
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/epoberezkin"
|
||||
}
|
||||
},
|
||||
"node_modules/ajv-formats": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/ajv-formats/-/ajv-formats-3.0.1.tgz",
|
||||
"integrity": "sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==",
|
||||
"dependencies": {
|
||||
"ajv": "^8.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"ajv": "^8.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"ajv": {
|
||||
"optional": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/fast-deep-equal": {
|
||||
"version": "3.1.3",
|
||||
"resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz",
|
||||
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q=="
|
||||
},
|
||||
"node_modules/fast-uri": {
|
||||
"version": "3.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.0.1.tgz",
|
||||
"integrity": "sha512-MWipKbbYiYI0UC7cl8m/i/IWTqfC8YXsqjzybjddLsFjStroQzsHXkc73JutMvBiXmOvapk+axIl79ig5t55Bw=="
|
||||
},
|
||||
"node_modules/json-schema-traverse": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz",
|
||||
"integrity": "sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug=="
|
||||
},
|
||||
"node_modules/require-from-string": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/require-from-string/-/require-from-string-2.0.2.tgz",
|
||||
"integrity": "sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==",
|
||||
"engines": {
|
||||
"node": ">=0.10.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"name": "token-list",
|
||||
"version": "1.0.0",
|
||||
"description": "Vara Network token list",
|
||||
"main": "scripts/verifier.js",
|
||||
"scripts": {
|
||||
"start": "node scripts/verifier.js"
|
||||
},
|
||||
"keywords": [
|
||||
"vara network",
|
||||
"varan wallet",
|
||||
"token list"
|
||||
],
|
||||
"author": "uxname",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ajv": "^8.17.1",
|
||||
"ajv-formats": "^3.0.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
{
|
||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||
"title": "Token Schema",
|
||||
"description": "Schema for validating token information in a blockchain context.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"name": {
|
||||
"type": "string",
|
||||
"description": "The name of the token."
|
||||
},
|
||||
"ticker": {
|
||||
"type": "string",
|
||||
"description": "The short name of the token."
|
||||
},
|
||||
"title": {
|
||||
"type": "string",
|
||||
"description": "The full name of the network or token."
|
||||
},
|
||||
"iconFileName": {
|
||||
"type": "string",
|
||||
"description": "The icon file name for the token."
|
||||
},
|
||||
"infoURL": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "URL for additional information about the token."
|
||||
},
|
||||
"contractAddress": {
|
||||
"type": "string",
|
||||
"description": "The smart contract address of the token."
|
||||
},
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"fungible",
|
||||
"nft"
|
||||
],
|
||||
"description": "The type of token (fungible or NFT)."
|
||||
},
|
||||
"decimals": {
|
||||
"type": "integer",
|
||||
"description": "The number of decimal places."
|
||||
},
|
||||
"description": {
|
||||
"type": "string",
|
||||
"description": "A description of the token.",
|
||||
"default": ""
|
||||
},
|
||||
"website": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "Link to the project's website.",
|
||||
"default": ""
|
||||
},
|
||||
"whitepaper": {
|
||||
"type": "string",
|
||||
"format": "uri",
|
||||
"description": "Link to the project's whitepaper.",
|
||||
"default": ""
|
||||
},
|
||||
"initialSupply": {
|
||||
"type": "number",
|
||||
"description": "The initial supply of tokens.",
|
||||
"default": 0
|
||||
},
|
||||
"totalSupply": {
|
||||
"type": "number",
|
||||
"description": "The total supply of tokens.",
|
||||
"default": 0
|
||||
},
|
||||
"maxSupply": {
|
||||
"type": "number",
|
||||
"description": "The maximum supply of tokens.",
|
||||
"default": 0
|
||||
}
|
||||
},
|
||||
"required": [
|
||||
"name",
|
||||
"ticker",
|
||||
"title",
|
||||
"iconFileName",
|
||||
"infoURL",
|
||||
"contractAddress",
|
||||
"type",
|
||||
"decimals"
|
||||
],
|
||||
"additionalProperties": false
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
const Ajv = require('ajv');
|
||||
const addFormats = require('ajv-formats');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
|
||||
const schema = require('./token-schema.json');
|
||||
|
||||
function validateJsonFile(filePath) {
|
||||
try {
|
||||
const data = JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
||||
const valid = validate(data);
|
||||
if (valid) {
|
||||
console.log(`File ${path.basename(filePath)} is valid.`);
|
||||
} else {
|
||||
console.log(`File ${path.basename(filePath)} is invalid:`, validate.errors);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error(`Error reading or parsing the file ${path.basename(filePath)}:`, error);
|
||||
}
|
||||
}
|
||||
|
||||
function validateAllJsonFilesInDirectory(directoryPath) {
|
||||
fs.readdir(directoryPath, (err, files) => {
|
||||
if (err) {
|
||||
console.error('Error reading directory:', err);
|
||||
return;
|
||||
}
|
||||
|
||||
files.forEach(file => {
|
||||
const filePath = path.join(directoryPath, file);
|
||||
if (path.extname(file) === '.json') {
|
||||
validateJsonFile(filePath);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
const ajv = new Ajv();
|
||||
addFormats(ajv);
|
||||
|
||||
const validate = ajv.compile(schema);
|
||||
|
||||
const dataDirectoryPath = path.resolve(process.cwd(), 'data');
|
||||
|
||||
validateAllJsonFilesInDirectory(dataDirectoryPath);
|
||||
Reference in new issue
Block a user