Skip to content

Commit

Permalink
Merge pull request hyperledger#58 from lightclient/editorconfig
Browse files Browse the repository at this point in the history
Add editorconfig
  • Loading branch information
lightclient authored Aug 23, 2021
2 parents af88228 + fd95e16 commit 95801f0
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 37 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true

[*.js]
indent_style = space

[*.json]
indent_style = tab
indent_size = 4
52 changes: 26 additions & 26 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,43 +6,43 @@ let methods = [];
let methodsBase = "src/methods/";
let methodFiles = fs.readdirSync(methodsBase);
methodFiles.forEach(file => {
console.log(file);
console.log(file);
let raw = fs.readFileSync(methodsBase + file);
let parsed = JSON.parse(raw);
methods = [
...methods,
...parsed,
];
let parsed = JSON.parse(raw);
methods = [
...methods,
...parsed,
];
});

let schemas = {};
let schemasBase = "src/schemas/"
let schemaFiles = fs.readdirSync(schemasBase);
schemaFiles.forEach(file => {
console.log(file);
console.log(file);
let raw = fs.readFileSync(schemasBase + file);
let parsed = JSON.parse(raw);
schemas = {
...schemas,
...parsed,
};
let parsed = JSON.parse(raw);
schemas = {
...schemas,
...parsed,
};
});

const spec = {
openrpc: "1.2.4",
info: {
title: "Ethereum JSON-RPC Specification",
description: "A specification of the standard interface for Ethereum clients.",
license: {
name: "CC0-1.0",
url: "https://creativecommons.org/publicdomain/zero/1.0/legalcode"
},
version: "0.0.0"
},
methods: methods,
components: {
schemas: schemas
}
openrpc: "1.2.4",
info: {
title: "Ethereum JSON-RPC Specification",
description: "A specification of the standard interface for Ethereum clients.",
license: {
name: "CC0-1.0",
url: "https://creativecommons.org/publicdomain/zero/1.0/legalcode"
},
version: "0.0.0"
},
methods: methods,
components: {
schemas: schemas
}
}

let data = JSON.stringify(spec, null, '\t');
Expand Down
22 changes: 11 additions & 11 deletions scripts/validate.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import fs from "fs";
import {
parseOpenRPCDocument,
validateOpenRPCDocument
parseOpenRPCDocument,
validateOpenRPCDocument
} from "@open-rpc/schema-utils-js";

let rawdata = fs.readFileSync("openrpc.json");
let openrpc = JSON.parse(rawdata);

const error = validateOpenRPCDocument(openrpc);
if (error != true) {
console.log(error.name);
console.log(error.message);
process.exit(1);
console.log(error.name);
console.log(error.message);
process.exit(1);
}

try {
await Promise.resolve(parseOpenRPCDocument(openrpc));
await Promise.resolve(parseOpenRPCDocument(openrpc));
} catch(e) {
console.log(e.name);
let end = e.message.indexOf("schema in question");
let msg = e.message.substring(0, end);
console.log(msg);
process.exit(1);
console.log(e.name);
let end = e.message.indexOf("schema in question");
let msg = e.message.substring(0, end);
console.log(msg);
process.exit(1);
}

console.log("OpenRPC spec validated successfully.");

0 comments on commit 95801f0

Please sign in to comment.