From 32be73ea1f1bd700f559666e060dda4a53a1cfa7 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

(cherry picked from commit 59ded148e89ea14da42cce044ae446f16af3f95b)
---
 src/genesis/genesis.ts | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/genesis/genesis.ts b/src/genesis/genesis.ts
index 373c4a9..d3378dd 100644
--- a/src/genesis/genesis.ts
+++ b/src/genesis/genesis.ts
@@ -89,7 +89,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(genesis_path)).toString()).genesis.runtimeAndCode.runtime;
+  const genesisData = JSON.parse(readFileSync(path.resolve(process.cwd(), genesis_path)).toString());
+  // Accomodate for versions of polkadot before and after 1.6.0:
+  const genesis: Genesis = genesisData.genesis.runtimeAndCode?.runtime || genesisData.genesis.runtimeGenesis.patch;
 
   const accounts: Map<Address, Account> = new Map();
   const identities: Map<IdtyIndex, Identity> = new Map();
-- 
GitLab