From 90633392009e67b359c9b488bf04f2629394cf79 Mon Sep 17 00:00:00 2001 From: Arya Lanjewar <102943033+AryaLanjewar3005@users.noreply.github.com> Date: Thu, 6 Feb 2025 12:22:20 +0530 Subject: [PATCH] fixed staking script parsing pub_key error --- src/setup/devnet/index.js | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/setup/devnet/index.js b/src/setup/devnet/index.js index 73f0617d..2de61e24 100644 --- a/src/setup/devnet/index.js +++ b/src/setup/devnet/index.js @@ -1372,14 +1372,23 @@ export class Devnet { // return { ...account, pub_key: s.pub_key }; // }) this.config.accounts = this.signerDumpData - .slice(0, this.config.numOfBorValidators) - .map((s) => { - const account = getAccountFromPrivateKey(s.priv_key) - const sanitizedPubKey = s.pub_key.startsWith('0x04') - ? '0x' + s.pub_key.slice(4) - : s.pub_key // Remove "04" prefix if present - return { ...account, pub_key: sanitizedPubKey } - }) + .slice(0, this.config.numOfBorValidators) + .map((s) => { + const account = getAccountFromPrivateKey(s.priv_key) + + // Extract key from the format 'PubKeySecp256k1{04...}' + const match = s.pub_key.match(/{(.*)}/) + let sanitizedPubKey = s.pub_key + + if (match) { + const keyWithPrefix = match[1] // Extract the key inside braces + sanitizedPubKey = keyWithPrefix.startsWith('04') + ? '0x' + keyWithPrefix.slice(2) // Remove '04' and add '0x' + : '0x' + keyWithPrefix + } + + return { ...account, pub_key: sanitizedPubKey } + }) if (this.config.numOfErigonValidators > 0) { const erigonAccounts = this.signerDumpData