-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7501af3
commit 27906ea
Showing
27 changed files
with
96 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useBTCTipHeight.ts → src/app/hooks/client/api/useBTCTipHeight.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useNetworkFees.ts → src/app/hooks/client/api/useNetworkFees.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useNetworkInfo.ts → src/app/hooks/client/api/useNetworkInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useOrdinals.ts → src/app/hooks/client/api/useOrdinals.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useSystemStats.ts → src/app/hooks/client/api/useSystemStats.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useUTXOs.ts → src/app/hooks/client/api/useUTXOs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/app/hooks/api/useVersions.ts → src/app/hooks/client/api/useVersions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { incentivequery } from "@babylonlabs-io/babylon-proto-ts"; | ||
import { QueryClient, createProtobufRpcClient } from "@cosmjs/stargate"; | ||
import { useCallback } from "react"; | ||
|
||
import { useCosmosWallet } from "@/app/context/wallet/CosmosWalletProvider"; | ||
|
||
const REWARD_GAUGE_KEY_BTC_DELEGATION = "btc_delegation"; | ||
|
||
/** | ||
* Query service for Babylon which contains all the queries for | ||
* interacting with Babylon RPC nodes | ||
*/ | ||
export const useBbnQuery = () => { | ||
const { queryClient, bech32Address } = useCosmosWallet(); | ||
|
||
const getRewards = useCallback(async (): Promise<number> => { | ||
if (!queryClient || !bech32Address) { | ||
return 0; | ||
} | ||
const { incentive } = setupIncentiveExtension(queryClient); | ||
|
||
const req: incentivequery.QueryRewardGaugesRequest = | ||
incentivequery.QueryRewardGaugesRequest.fromPartial({ | ||
address: bech32Address, | ||
}); | ||
|
||
const { rewardGauges } = await incentive.RewardGauges(req); | ||
const btcDelegationRewards = | ||
rewardGauges[REWARD_GAUGE_KEY_BTC_DELEGATION]?.coins; | ||
if (!btcDelegationRewards) { | ||
return 0; | ||
} | ||
|
||
return btcDelegationRewards.reduce( | ||
(acc, coin) => acc + Number(coin.amount), | ||
0, | ||
); | ||
}, [queryClient, bech32Address]); | ||
|
||
return { | ||
getRewards, | ||
}; | ||
}; | ||
|
||
// Extend the QueryClient with the Incentive module | ||
const setupIncentiveExtension = ( | ||
base: QueryClient, | ||
): { | ||
incentive: incentivequery.QueryClientImpl; | ||
} => { | ||
const rpc = createProtobufRpcClient(base); | ||
const incentiveQueryClient = new incentivequery.QueryClientImpl(rpc); | ||
return { incentive: incentiveQueryClient }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters