Skip to content

Commit

Permalink
add getUndelegations to cosmos
Browse files Browse the repository at this point in the history
  • Loading branch information
Elemberg committed Sep 30, 2024
1 parent 69bc252 commit 8dde41a
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion cosmos.js
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,22 @@ async function getDelegations(address) {
})
}

return {result: delegatorArray};
} catch (error) {
throw new Error(error);
}
}

/** getUndelegations - list of undelegations
* @param {string} address - Account blockchain address (staker)
* @returns {Promise<object>} Promise object with undelegations
*/
async function getUndelegations(address) {
try {
const unbindingResponse = await axios.get(`${API_URL}/cosmos/staking/v1beta1/delegators/${address}/unbonding_delegations`);
const unbonding = unbindingResponse.data.unbonding_responses;

return {result: {delegations: delegatorArray, unbonding: unbonding}};
return {result: unbonding};
} catch (error) {
throw new Error(error);
}
Expand All @@ -217,4 +229,5 @@ module.exports = {
undelegate,
withdrawRewards,
getDelegations,
getUndelegations,
};

0 comments on commit 8dde41a

Please sign in to comment.