Skip to content

Commit

Permalink
Fix: spending limit max amount (#1657)
Browse files Browse the repository at this point in the history
* Fix: spending limit max amount

* Rm "Problem connecting to the RPC provider."
  • Loading branch information
katspaugh authored Feb 9, 2023
1 parent b026a45 commit 8a1e599
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
11 changes: 9 additions & 2 deletions src/components/tx/modals/TokenTransferModal/SendAssetsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,12 @@ const SendAssetsForm = ({
const spendingLimit = useSpendingLimit(selectedToken?.tokenInfo)
const isSpendingLimitType = type === SendTxType.spendingLimit
const spendingLimitAmount = spendingLimit ? BigNumber.from(spendingLimit.amount).sub(spendingLimit.spent) : undefined
const totalAmount = BigNumber.from(selectedToken?.balance || 0)
const maxAmount = spendingLimitAmount
? totalAmount.gt(spendingLimitAmount)
? spendingLimitAmount
: totalAmount
: totalAmount

const balancesItems = useMemo(() => {
return isOnlySpendingLimitBeneficiary
Expand Down Expand Up @@ -235,8 +241,9 @@ const SendAssetsForm = ({
required: true,
validate: (val) => {
const decimals = selectedToken?.tokenInfo.decimals
const max = isSpendingLimitType ? spendingLimitAmount?.toString() : selectedToken?.balance
return validateLimitedAmount(val, decimals, max) || validateDecimalLength(val, decimals)
return (
validateLimitedAmount(val, decimals, maxAmount.toString()) || validateDecimalLength(val, decimals)
)
},
})}
/>
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/coreSDK/useInitSafeCoreSDK.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const useInitSafeCoreSDK = () => {
.catch((e) => {
dispatch(
showNotification({
message: 'Problem connecting to the RPC provider. Please try connecting your wallet again.',
message: 'Please try connecting your wallet again.',
groupKey: 'core-sdk-init-error',
variant: 'error',
detailedMessage: (e as Error).message,
Expand Down

0 comments on commit 8a1e599

Please sign in to comment.