From 55e37bdcea73360fef4229a0521ff1d882634da3 Mon Sep 17 00:00:00 2001 From: imsk17 Date: Tue, 6 Aug 2024 15:33:09 +0530 Subject: [PATCH] fix(tezos): addSelfAsValidator: check for signatures using publickey --- src/deps.ts | 1 + src/handler/tezos/utils/addSelfAsValidator.ts | 12 ++++++------ src/handler/tezos/utils/selfIsValidator.ts | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/deps.ts b/src/deps.ts index 98420ffb..a1550c4e 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -144,6 +144,7 @@ export async function configTezosHandler( }); const provider = new TezosToolkit(conf.rpcURL); const signer = new InMemorySigner(tezosWallet.secretKey); + provider.setSignerProvider(signer); return tezosHandler({ provider, signer, diff --git a/src/handler/tezos/utils/addSelfAsValidator.ts b/src/handler/tezos/utils/addSelfAsValidator.ts index fa143765..eefd4ade 100644 --- a/src/handler/tezos/utils/addSelfAsValidator.ts +++ b/src/handler/tezos/utils/addSelfAsValidator.ts @@ -20,7 +20,7 @@ export default async function addSelfAsValidator( try { let validatorsCount = (await bc.storage()).validators_count.toNumber(); let signatureCount = Number( - await storage.getStakingSignaturesCount(await signer.publicKeyHash()), + await storage.getStakingSignaturesCount(await signer.publicKey()), ); while (signatureCount < confirmationCountNeeded(validatorsCount)) { @@ -45,10 +45,9 @@ export default async function addSelfAsValidator( }; }); - await bc.methods - .add_validator( - tas.address(await signer.publicKeyHash()), - stakingSignatures.map((e) => { + await bc.methodsObject + .add_validator({ + sigs: stakingSignatures.map((e) => { const addr = tas.address( b58cencode( hash( @@ -67,7 +66,8 @@ export default async function addSelfAsValidator( signer: tas.key(e.signerAddress), }; }), - ) + validator: tas.address(await signer.publicKeyHash()), + }) .send(); return "success"; } catch (e) { diff --git a/src/handler/tezos/utils/selfIsValidator.ts b/src/handler/tezos/utils/selfIsValidator.ts index 53a2c002..3559915c 100644 --- a/src/handler/tezos/utils/selfIsValidator.ts +++ b/src/handler/tezos/utils/selfIsValidator.ts @@ -6,7 +6,7 @@ export default async function selfIsValidator( bc: BridgeContractType, signer: Signer, ) { - const mutez = (await bc.storage()).validators.get( + const mutez = await (await bc.storage()).validators.get( tas.address(await signer.publicKeyHash()), ); return mutez !== undefined;