-
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.
fix(tooling-wallet): Fix staking with ledger (#4296)
* feat(wallet): Fix speculos default port * feat(wallet): Update outdated comment * feat(wallet): Replace one useDryRunTransaction with new hook to estimate gas budget in StakeForm. Make useDryRunTransaction in StakeForm not trigger a ledger wallet interaction * feat(wallet): Revert speculos default port change
- Loading branch information
Showing
4 changed files
with
67 additions
and
15 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
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