-
Notifications
You must be signed in to change notification settings - Fork 306
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: bugfix for gas setting dialog with payment token (#10642)
- Loading branch information
1 parent
9ff4f61
commit 2e3c014
Showing
6 changed files
with
61 additions
and
34 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useContainer } from 'unstated-next' | ||
import { PopupContext } from './usePopupContext.js' | ||
import { useAsync } from 'react-use' | ||
import { DepositPaymaster } from '@masknet/web3-providers' | ||
import { isNativeTokenAddress } from '@masknet/web3-shared-evm' | ||
|
||
export function useGasRatio(paymentToken?: string) { | ||
const { smartPayChainId } = useContainer(PopupContext) | ||
|
||
const { value: smartPayRatio } = useAsync(async () => { | ||
if (!smartPayChainId) return | ||
const depositPaymaster = new DepositPaymaster(smartPayChainId) | ||
const ratio = await depositPaymaster.getRatio() | ||
|
||
return ratio | ||
}, [smartPayChainId]) | ||
|
||
return paymentToken && !isNativeTokenAddress(paymentToken) ? smartPayRatio : undefined | ||
} |
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