Skip to content

Commit

Permalink
fix ibc and add optional deposit gas fee (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
ben2x4 authored Feb 5, 2022
1 parent cdd7fcb commit f13da21
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
7 changes: 2 additions & 5 deletions features/assets/components/TransferDialog/AmountInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,18 @@ import {
useTriggerInputFocus,
} from 'components/BasicNumberInput'
import { formatTokenBalance } from 'util/conversion'
import { useIBCTokenBalance } from 'hooks/useIBCTokenBalance'

type AmountInputProps = {
tokenSymbol: string
amount: number
maxApplicableAmount: number
onAmountChange: (amount: number) => void
}

export const AmountInput = ({
tokenSymbol,
amount,
maxApplicableAmount,
onAmountChange,
}: AmountInputProps) => {
const { balance: maxApplicableAmount } = useIBCTokenBalance(tokenSymbol)

const { isFocused, bind } = useTriggerInputFocus()

return (
Expand Down
9 changes: 8 additions & 1 deletion features/assets/components/TransferDialog/TransferDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ export const TransferDialog = ({
onTokenSelect,
}: TransferDialogProps) => {
const tokenInfo = useIBCAssetInfo(tokenSymbol)
const deposit_gas_fee = tokenInfo.deposit_gas_fee
? tokenInfo.deposit_gas_fee
: 0.01

const { balance: externalIbcAssetBalance } = useIBCTokenBalance(tokenSymbol)
const { balance: nativeAssetBalance } = useTokenBalance(tokenSymbol)
Expand Down Expand Up @@ -128,7 +131,11 @@ export const TransferDialog = ({
Amount
</Text>
<AmountInput
tokenSymbol={tokenSymbol}
maxApplicableAmount={
transactionKind === 'deposit'
? Math.max(externalIbcAssetBalance - deposit_gas_fee, 0)
: nativeAssetBalance
}
amount={tokenAmount}
onAmountChange={setTokenAmount}
/>
Expand Down
1 change: 1 addition & 0 deletions hooks/useIbcAssetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export type IBCAssetInfo = {
juno_channel: string
channel: string
logoURI: string
deposit_gas_fee?: number
}

export type IBCAssetList = {
Expand Down

0 comments on commit f13da21

Please sign in to comment.