From 59ded148e89ea14da42cce044ae446f16af3f95b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carles=20Barrobe=CC=81s?= <carles@barrobes.com>
Date: Fri, 16 Feb 2024 16:53:08 +0100
Subject: [PATCH] Make genesis format compatible with different polkadot
 versions

---
 src/genesis.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/genesis.ts b/src/genesis.ts
index e87b8b6..1e29d35 100644
--- a/src/genesis.ts
+++ b/src/genesis.ts
@@ -11,7 +11,9 @@ export async function saveGenesis(ctx: Ctx, block: Block) {
   ctx.log.info("Loading genesis");
 
   // Read genesis json
-  const genesis: Genesis = JSON.parse(readFileSync(path.resolve(process.cwd(), genesis_path)).toString()).genesis.runtimeAndCode.runtime;
+  const genesisData = JSON.parse(readFileSync(path.resolve(process.cwd(), genesis_path)).toString()).genesis;
+  // Accomodate for versions of polkadot before and after 1.6.0:
+  const genesis: Genesis = genesisData.runtimeAndCode?.runtime || genesisData.runtimeGenesis.patch;
 
   const accounts: Map<Address, Account> = new Map();
   const identities: Map<IdtyIndex, Identity> = new Map();
-- 
GitLab