Skip to content

Commit

Permalink
feat: update amp worker set query to not use keyID (#42)
Browse files Browse the repository at this point in the history
* feat: update amp worker set query to not use keyID

* update ecdsa field key

* update worker set query to adjust to prover API changes

* remove unused option

* Revert "remove unused option"

This reverts commit 3cce2bc.
  • Loading branch information
eguajardo authored Sep 20, 2023
1 parent b6d46f0 commit 2afa6c3
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions evm/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ const getEVMAddresses = async (config, chain, options = {}) => {
const keyID = options.keyID || '';

const evmAddresses = options.amplifier
? await getAmplifierKeyAddresses(config, chain, keyID)
? await getAmplifierKeyAddresses(config, chain)
: await httpGet(`${config.axelar.lcd}/axelar/evm/v1beta1/key_address/${chain}?key_id=${keyID}`);

const sortedAddresses = evmAddresses.addresses.sort((a, b) => a.address.toLowerCase().localeCompare(b.address.toLowerCase()));
Expand All @@ -419,19 +419,16 @@ const getEVMAddresses = async (config, chain, options = {}) => {
return { addresses, weights, threshold };
};

const getAmplifierKeyAddresses = async (config, chain, keyID = '') => {
const getAmplifierKeyAddresses = async (config, chain) => {
const client = await CosmWasmClient.connect(config.axelar.rpc);
const key = await client.queryContractSmart(config.axelar.contracts.Multisig.address, {
get_key: { key_id: { owner: config.axelar.contracts.MultisigProver[chain].address, subkey: keyID } },
});
const pubkeys = new Map(Object.entries(key.pub_keys));
const workerSet = await client.queryContractSmart(config.axelar.contracts.MultisigProver[chain].address, 'get_worker_set');

const weightedAddresses = Object.values(key.snapshot.participants).map((participant) => ({
address: computeAddress(`0x${pubkeys.get(participant.address)}`),
weight: participant.weight,
const weightedAddresses = workerSet.signers.map((signer) => ({
address: computeAddress(`0x${signer.pub_key.ecdsa}`),
weight: signer.weight,
}));

return { addresses: weightedAddresses, threshold: key.snapshot.quorum };
return { addresses: weightedAddresses, threshold: workerSet.threshold };
};

function sleep(ms) {
Expand Down

0 comments on commit 2afa6c3

Please sign in to comment.