Skip to content

Commit

Permalink
fix(tezos): addSelfAsValidator: check for signatures using publickey
Browse files Browse the repository at this point in the history
  • Loading branch information
imsk17 committed Aug 6, 2024
1 parent d008197 commit 55e37bd
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
1 change: 1 addition & 0 deletions src/deps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
12 changes: 6 additions & 6 deletions src/handler/tezos/utils/addSelfAsValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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(
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion src/handler/tezos/utils/selfIsValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 55e37bd

Please sign in to comment.