Skip to content

Commit

Permalink
feat: add an option to send custom gas limit when making transfers (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
helciofranco authored Jul 25, 2024
1 parent 7ac1fed commit a715ad6
Show file tree
Hide file tree
Showing 13 changed files with 347 additions and 198 deletions.
7 changes: 7 additions & 0 deletions .changeset/young-jokes-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@fuel-wallet/connections": minor
"@fuel-wallet/types": minor
"fuels-wallet": minor
---

Add `Gas Limit` input to customize transaction fees when sending a transfer
4 changes: 2 additions & 2 deletions fuel-toolchain.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
channel = "latest-2023-11-30"

[components]
fuel-core = "0.24.3"
forc = "0.56.0"
fuel-core = "0.26.0"
forc = "0.59.0"
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,9 @@
"@adobe/css-tools@<4.3.2": ">=4.3.2",
"@babel/traverse@<7.23.2": ">=7.23.2",
"braces@<3.0.3": ">=3.0.3",
"ws": "8.17.1"
"ws@>=8.0.0 <8.17.1": ">=8.17.1",
"ws@>=7.0.0 <7.5.10": ">=7.5.10",
"ws@>=6.0.0 <6.2.3": ">=6.2.3"
}
}
}
22 changes: 12 additions & 10 deletions packages/app/src/systems/Send/components/SendSelect/SendSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { cssObj } from '@fuel-ui/css';
import { Box, Form, Input, Text } from '@fuel-ui/react';
import { motion } from 'framer-motion';
import { AnimatePresence, motion } from 'framer-motion';
import { type BN, DECIMAL_FUEL, bn } from 'fuels';
import { useEffect, useMemo, useRef, useState } from 'react';
import { AssetSelect } from '~/systems/Asset';
import {
ControlledField,
Layout,
MotionFlex,
MotionStack,
animations,
} from '~/systems/Core';
Expand All @@ -25,7 +26,7 @@ export function SendSelect({
balanceAssets,
balanceAssetSelected,
baseFee = bn(0),
baseGasLimit = bn(0),
minGasLimit = bn(0),
tip,
regularTip,
fastTip,
Expand Down Expand Up @@ -62,16 +63,15 @@ export function SendSelect({
// Adding 2 magical units to match the fake unit that is added on TS SDK (.add(1))
// and then removed on the "transaction" service (.sub(1))
const maxFee = baseFee.add(tip).add(2);
if (maxFee.gt(balanceAssetSelected)) return;

form.setValue('amount', balanceAssetSelected.sub(maxFee), {
shouldValidate: true,
});
form.setValue('amount', balanceAssetSelected.sub(maxFee));
}
}, [watchMax, balanceAssetSelected, baseFee, tip, form.setValue]);

return (
<MotionContent {...animations.slideInTop()}>
<Box.Stack gap="$4">
<Box.Stack gap="$3">
<Box.Flex css={styles.row}>
<Text as="span" css={styles.title}>
Asset
Expand Down Expand Up @@ -146,9 +146,11 @@ export function SendSelect({
}}
/>
{(errorMessage || amountFieldState.error) && (
<Form.ErrorMessage aria-label="Error message">
{errorMessage || amountFieldState.error?.message}
</Form.ErrorMessage>
<MotionFlex {...animations.fadeIn()} key="error">
<Form.ErrorMessage aria-label="Error message">
{errorMessage || amountFieldState.error?.message}
</Form.ErrorMessage>
</MotionFlex>
)}
</Form.Control>
</Box.Stack>
Expand All @@ -164,7 +166,7 @@ export function SendSelect({
</Text>
<TxFeeOptions
baseFee={baseFee}
baseGasLimit={baseGasLimit}
minGasLimit={minGasLimit}
regularTip={regularTip}
fastTip={fastTip}
/>
Expand Down
Loading

0 comments on commit a715ad6

Please sign in to comment.