From e6e23fef5faad250a7688f9d1fcf1e7599588f2d Mon Sep 17 00:00:00 2001 From: sky1045 Date: Mon, 2 Dec 2024 17:58:08 +0900 Subject: [PATCH 1/2] Add workflow for validating planets.json --- .github/workflows/planets.yaml | 17 +++++ planets/index.json | 129 +++++++++++++++++++++++++++++++++ planets/schema.json | 97 +++++++++++++++++++++++++ 3 files changed, 243 insertions(+) create mode 100644 .github/workflows/planets.yaml create mode 100644 planets/index.json create mode 100644 planets/schema.json diff --git a/.github/workflows/planets.yaml b/.github/workflows/planets.yaml new file mode 100644 index 00000000..1f5eae43 --- /dev/null +++ b/.github/workflows/planets.yaml @@ -0,0 +1,17 @@ +name: Validate planets config +on: + pull_request: + paths: + - 'planets/**.json' + +jobs: + validate-planets-config: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: docker://orrosenblatt/validate-json-action:latest + name: Validate Planets JSON + env: + INPUT_SCHEMA: planets/schema.json + INPUT_JSONS: planets/index.json + diff --git a/planets/index.json b/planets/index.json new file mode 100644 index 00000000..9f82fb83 --- /dev/null +++ b/planets/index.json @@ -0,0 +1,129 @@ +[ + { + "id": "0x000000000000", + "name": "odin", + "genesisHash": "4582250d0da33b06779a8475d283d5dd210c683b9b999d74d03fac4f58fa6bce", + "genesisUri": "https://release.nine-chronicles.com/genesis-block-9c-main", + "9cscanUrl": "https://9cscan.com", + "rpcEndpoints": { + "dp.gql": ["http://odin-dp.9c.gg/graphql"], + "9cscan.rest": ["https://api.9cscan.com"], + "headless.gql": [ + "https://odin-rpc-2.nine-chronicles.com/graphql", + "http://ash-nc-1.ninodes.com/graphql", + "http://phx-nc-1.ninodes.com/graphql", + "http://nld-nc-1.ninodes.com/graphql" + ], + "headless.grpc": [ + "http://odin-rpc-2.nine-chronicles.com:31238", + "http://ash-nc-1.ninodes.com:31238", + "http://phx-nc-1.ninodes.com:31238", + "http://nld-nc-1.ninodes.com:31238" + ], + "market.rest": [ + "https://odin-market.9c.gg" + ], + "world-boss.rest": [ + "https://odin-world-boss.9c.gg" + ], + "patrol-reward.gql": [ + "https://odin-patrol.9c.gg/graphql" + ], + "arena.gql": [ + "http://odin-arena.9c.gg/graphql" + ] + }, + "bridges": { + "0x000000000001": { + "agent": "0x1c2ae97380CFB4F732049e454F6D9A25D4967c6f", + "avatar": "0x41aEFE4cdDFb57C9dFfd490e17e571705c593dDc" + }, + "0x000000000003": { + "agent": "0x3e498a6A5cDbE027769F9502026c37Cb8613186e", + "avatar": "0x41E9Dc57F04cC561B68378490528e22a386ba9e1" + } + } + }, + { + "id": "0x000000000001", + "name": "heimdall", + "genesisHash": "729fa26958648a35b53e8e3905d11ec53b1b4929bf5f499884aed7df616f5913", + "genesisUri": "https://planets.nine-chronicles.com/planets/0x000000000001/genesis", + "9cscanUrl": "https://heimdall.9cscan.com", + "rpcEndpoints": { + "dp.gql": [ + "http://heimdall-dp.9c.gg/graphql" + ], + "9cscan.rest": [ + "https://api-heimdall.9cscan.com" + ], + "headless.gql": [ + "https://heimdall-rpc-1.nine-chronicles.com/graphql", + "https://heimdall-rpc-2.nine-chronicles.com/graphql", + "https://heimdall-rpc-3.nine-chronicles.com/graphql" + ], + "headless.grpc": [ + "http://heimdall-rpc-1.nine-chronicles.com:31238", + "http://heimdall-rpc-2.nine-chronicles.com:31238", + "http://heimdall-rpc-3.nine-chronicles.com:31238" + ], + "market.rest": [ + "http://heimdall-market.9c.gg" + ], + "world-boss.rest": [ + "http://heimdall-world-boss.9c.gg" + ], + "patrol-reward.gql": [ + "https://heimdall-patrol.9c.gg/graphql" + ], + "arena.gql": [ + "http://heimdall-arena.9c.gg/graphql" + ] + }, + "bridges": { + "0x000000000000": { + "agent": "0x1c2ae97380CFB4F732049e454F6D9A25D4967c6f", + "avatar": "0x41aEFE4cdDFb57C9dFfd490e17e571705c593dDc" + } + } + }, + { + "id": "0x000000000003", + "name": "thor", + "genesisUri": "https://planets.nine-chronicles.com/planets/0x000000000003/genesis", + "genesisHash": "bde462fd59de5ccba8495ebb163b124bf77ddc82cfc8b2f9fb57c00fc6e133b7", + "9cscanUrl": "https://thor.9cscan.com", + "rpcEndpoints": { + "dp.gql": [ + "http://thor-dp.9c.gg/graphql" + ], + "9cscan.rest": [ + "https://api-thor.9cscan.com" + ], + "headless.gql": [ + "https://thor-rpc-1.nine-chronicles.com/graphql" + ], + "headless.grpc": [ + "http://thor-rpc-1.nine-chronicles.com:31238" + ], + "market.rest": [ + "http://thor-market.9c.gg" + ], + "world-boss.rest": [ + "http://thor-world-boss.9c.gg" + ], + "patrol-reward.gql": [ + "http://thor-patrol.9c.gg/graphql" + ], + "arena.gql": [ + "http://thor-arena.9c.gg/graphql" + ] + }, + "bridges": { + "0x000000000000": { + "agent": "0x3e498a6A5cDbE027769F9502026c37Cb8613186e", + "avatar": "0x41E9Dc57F04cC561B68378490528e22a386ba9e1" + } + } + } +] \ No newline at end of file diff --git a/planets/schema.json b/planets/schema.json new file mode 100644 index 00000000..1f254742 --- /dev/null +++ b/planets/schema.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "type": "array", + "items": { + "type": "object", + "properties": { + "id": { + "type": "string", + "pattern": "^0x[0-9a-fA-F]{12}$" + }, + "name": { + "type": "string" + }, + "genesisHash": { + "type": "string", + "pattern": "^[0-9a-fA-F]{40,64}$" + }, + "genesisUri": { + "type": "string", + "format": "uri" + }, + "9cscanUrl": { + "type": "string", + "format": "uri" + }, + "rpcEndpoints": { + "type": "object", + "properties": { + "dp.gql": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "9cscan.rest": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "headless.gql": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "headless.grpc": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "market.rest": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "world-boss.rest": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "patrol-reward.gql": { + "type": "array", + "items": { "type": "string", "format": "uri" } + }, + "arena.gql": { + "type": "array", + "items": { "type": "string", "format": "uri" } + } + }, + "additionalProperties": false + }, + "bridges": { + "type": "object", + "patternProperties": { + "^0x[0-9a-fA-F]{12}$": { + "type": "object", + "properties": { + "agent": { + "type": "string", + "pattern": "^0x[0-9a-fA-F]+$" + }, + "avatar": { + "type": "string", + "pattern": "^0x[0-9a-fA-F]+$" + } + }, + "required": ["agent", "avatar"], + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "required": [ + "id", + "name", + "genesisHash", + "genesisUri", + "9cscanUrl", + "rpcEndpoints", + "bridges" + ], + "additionalProperties": false + } +} From bae6600e7f918c335f8293758c3b09ffe34df0e5 Mon Sep 17 00:00:00 2001 From: eseiker Date: Tue, 3 Dec 2024 17:17:14 +0900 Subject: [PATCH 2/2] update planets validation/update actions update planets/index.json use main planet registry --- .github/scripts/validate-planets.js | 25 +++++++ .github/workflows/planets.yaml | 17 ----- .github/workflows/update-planets.yaml | 28 +++++++ .github/workflows/validate-planets.yaml | 17 +++++ planets/index.json | 8 +- planets/schema.json | 97 ------------------------- 6 files changed, 77 insertions(+), 115 deletions(-) create mode 100644 .github/scripts/validate-planets.js delete mode 100644 .github/workflows/planets.yaml create mode 100644 .github/workflows/update-planets.yaml create mode 100644 .github/workflows/validate-planets.yaml delete mode 100644 planets/schema.json diff --git a/.github/scripts/validate-planets.js b/.github/scripts/validate-planets.js new file mode 100644 index 00000000..1a870cb2 --- /dev/null +++ b/.github/scripts/validate-planets.js @@ -0,0 +1,25 @@ +import * as path from "jsr:@std/path"; + +import Ajv2019 from "npm:ajv/dist/2019.js"; +import addFormats from "npm:ajv-formats"; + +const baseUrl = + "https://planetarium.github.io/json-schema/NineChronicles/2024-12/"; +const fetchJsonSchema = async (name) => + await (await fetch(path.join(baseUrl, `/${name}.schema.json`))).json(); + +const ajv = new Ajv2019({ allErrors: true }); +addFormats(ajv); + +ajv.addSchema(await fetchJsonSchema("PlanetSpec"), "PlanetSpec.schema.json"); + +const validate = ajv.compile(await fetchJsonSchema("PlanetRegistry")); + +for (const filename of Deno.args) { + console.log(`validating ${filename}`); + const valid = validate(JSON.parse(await Deno.readTextFile(filename))); + if (!valid) { + console.error(`Error validating ${filename}:`, validate.errors); + Deno.exit(1); + } +} diff --git a/.github/workflows/planets.yaml b/.github/workflows/planets.yaml deleted file mode 100644 index 1f5eae43..00000000 --- a/.github/workflows/planets.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Validate planets config -on: - pull_request: - paths: - - 'planets/**.json' - -jobs: - validate-planets-config: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: docker://orrosenblatt/validate-json-action:latest - name: Validate Planets JSON - env: - INPUT_SCHEMA: planets/schema.json - INPUT_JSONS: planets/index.json - diff --git a/.github/workflows/update-planets.yaml b/.github/workflows/update-planets.yaml new file mode 100644 index 00000000..cbce1610 --- /dev/null +++ b/.github/workflows/update-planets.yaml @@ -0,0 +1,28 @@ +name: Update planets config + +on: + pull_request: + paths: + - planets/index.json + branches: + - main + types: + - closed + +jobs: + validate-planets-config: + if: github.event.pull_request.merged == true + uses: ./.github/workflows/validate-planets.yaml + update-planets-config: + needs: [validate-planets-config] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: us-east-2 + - run: | + aws s3 cp planets/index.json s3://planets.nine-chronicles.com/planets/index.json + aws cloudfront create-invalidation --distribution-id EP1JH2OWQMIKM --paths "/*" diff --git a/.github/workflows/validate-planets.yaml b/.github/workflows/validate-planets.yaml new file mode 100644 index 00000000..57f245ad --- /dev/null +++ b/.github/workflows/validate-planets.yaml @@ -0,0 +1,17 @@ +name: Validate planets config + +on: + workflow_call: + pull_request: + paths: + - planets/index.json + +jobs: + validate-planets-config: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: denoland/setup-deno@v2 + with: + deno-version: v2.x + - run: deno -A .github/scripts/validate-planets.js planets/index.json diff --git a/planets/index.json b/planets/index.json index 9f82fb83..8f52a1de 100644 --- a/planets/index.json +++ b/planets/index.json @@ -9,13 +9,19 @@ "dp.gql": ["http://odin-dp.9c.gg/graphql"], "9cscan.rest": ["https://api.9cscan.com"], "headless.gql": [ + "https://odin-rpc-1.nine-chronicles.com/graphql", "https://odin-rpc-2.nine-chronicles.com/graphql", + "http://sgp-nc-1.ninodes.com/graphql", + "http://sgp-nc-2.ninodes.com/graphql", "http://ash-nc-1.ninodes.com/graphql", "http://phx-nc-1.ninodes.com/graphql", "http://nld-nc-1.ninodes.com/graphql" ], "headless.grpc": [ + "http://odin-rpc-1.nine-chronicles.com:31238", "http://odin-rpc-2.nine-chronicles.com:31238", + "http://sgp-nc-1.ninodes.com:31238", + "http://sgp-nc-2.ninodes.com:31238", "http://ash-nc-1.ninodes.com:31238", "http://phx-nc-1.ninodes.com:31238", "http://nld-nc-1.ninodes.com:31238" @@ -126,4 +132,4 @@ } } } -] \ No newline at end of file +] diff --git a/planets/schema.json b/planets/schema.json deleted file mode 100644 index 1f254742..00000000 --- a/planets/schema.json +++ /dev/null @@ -1,97 +0,0 @@ -{ - "$schema": "http://json-schema.org/draft-07/schema#", - "type": "array", - "items": { - "type": "object", - "properties": { - "id": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]{12}$" - }, - "name": { - "type": "string" - }, - "genesisHash": { - "type": "string", - "pattern": "^[0-9a-fA-F]{40,64}$" - }, - "genesisUri": { - "type": "string", - "format": "uri" - }, - "9cscanUrl": { - "type": "string", - "format": "uri" - }, - "rpcEndpoints": { - "type": "object", - "properties": { - "dp.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "9cscan.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "headless.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "headless.grpc": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "market.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "world-boss.rest": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "patrol-reward.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - }, - "arena.gql": { - "type": "array", - "items": { "type": "string", "format": "uri" } - } - }, - "additionalProperties": false - }, - "bridges": { - "type": "object", - "patternProperties": { - "^0x[0-9a-fA-F]{12}$": { - "type": "object", - "properties": { - "agent": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]+$" - }, - "avatar": { - "type": "string", - "pattern": "^0x[0-9a-fA-F]+$" - } - }, - "required": ["agent", "avatar"], - "additionalProperties": false - } - }, - "additionalProperties": false - } - }, - "required": [ - "id", - "name", - "genesisHash", - "genesisUri", - "9cscanUrl", - "rpcEndpoints", - "bridges" - ], - "additionalProperties": false - } -}