-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into dev-tools/reenable-coverage-ci
- Loading branch information
Showing
58 changed files
with
852 additions
and
628 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
46 changes: 46 additions & 0 deletions
46
apps/core/src/hooks/stake/useStakingGasBudgetEstimation.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useMemo } from 'react'; | ||
import { useIotaClient } from '@iota/dapp-kit'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { createStakeTransaction } from '../../utils'; | ||
|
||
interface UseStakingGasBudgetEstimationOptions { | ||
senderAddress: string | null; | ||
validatorAddress: string; | ||
amount: bigint; | ||
} | ||
|
||
export function useStakingGasBudgetEstimation({ | ||
senderAddress, | ||
validatorAddress, | ||
amount, | ||
}: UseStakingGasBudgetEstimationOptions) { | ||
const client = useIotaClient(); | ||
|
||
const transaction = useMemo(() => { | ||
return createStakeTransaction(amount, validatorAddress); | ||
}, [amount, validatorAddress]); | ||
|
||
return useQuery({ | ||
// eslint-disable-next-line @tanstack/query/exhaustive-deps | ||
queryKey: [ | ||
'staking-tx-gas-budget-estimate', | ||
senderAddress, | ||
validatorAddress, | ||
transaction.getData(), | ||
], | ||
queryFn: async () => { | ||
if (!senderAddress || !transaction) { | ||
return null; | ||
} | ||
|
||
transaction.setSender(senderAddress); | ||
|
||
await transaction.build({ client }); | ||
|
||
return transaction.getData().gasData.budget; | ||
}, | ||
}); | ||
} |
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
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 was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.