Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ENG-3471] feat: use estimated fees for stx transactions #720

Merged
merged 8 commits into from
Jan 9, 2024
126 changes: 71 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@ledgerhq/hw-transport-webusb": "^6.27.13",
"@phosphor-icons/react": "^2.0.10",
"@react-spring/web": "^9.6.1",
"@secretkeylabs/xverse-core": "7.0.0",
"@secretkeylabs/xverse-core": "7.2.0-60f9ae5",
"@stacks/connect": "7.4.1",
"@stacks/stacks-blockchain-api-types": "6.1.1",
"@stacks/transactions": "6.9.0",
Expand Down Expand Up @@ -139,10 +139,10 @@
"tsconfig-paths-webpack-plugin": "^4.0.0",
"type-fest": "^2.19.0",
"typescript": "^5.0.0",
"typescript-plugin-styled-components": "^3.0.0",
"vitest": "^0.34.6",
"webpack": "^5.89.0",
"webpack-cli": "^4.0.0",
"webpack-dev-server": "^4.11.0",
"typescript-plugin-styled-components": "^3.0.0"
"webpack-dev-server": "^4.11.0"
}
}
2 changes: 1 addition & 1 deletion src/app/screens/confirmFtTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import TransactionDetailComponent from '@components/transactionDetailComponent';
import useStxWalletData from '@hooks/queries/useStxWalletData';
import useNetworkSelector from '@hooks/useNetwork';
import useWalletSelector from '@hooks/useWalletSelector';
import { broadcastSignedTransaction, StacksTransaction } from '@secretkeylabs/xverse-core';
import { StacksTransaction, broadcastSignedTransaction } from '@secretkeylabs/xverse-core';
import { deserializeTransaction } from '@stacks/transactions';
import { useMutation } from '@tanstack/react-query';
import { isLedgerAccount } from '@utils/helper';
Expand Down
2 changes: 1 addition & 1 deletion src/app/screens/confirmNftTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import useNetworkSelector from '@hooks/useNetwork';
import { useResetUserFlow } from '@hooks/useResetUserFlow';
import useWalletSelector from '@hooks/useWalletSelector';
import NftImage from '@screens/nftDashboard/nftImage';
import { broadcastSignedTransaction, StacksTransaction } from '@secretkeylabs/xverse-core';
import { StacksTransaction, broadcastSignedTransaction } from '@secretkeylabs/xverse-core';
import { deserializeTransaction } from '@stacks/transactions';
import { useMutation } from '@tanstack/react-query';
import { isLedgerAccount } from '@utils/helper';
Expand Down
6 changes: 3 additions & 3 deletions src/app/screens/confirmStxTransaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@ import useNetworkSelector from '@hooks/useNetwork';
import useOnOriginTabClose from '@hooks/useOnTabClosed';
import useWalletSelector from '@hooks/useWalletSelector';
import {
StacksTransaction,
TokenTransferPayload,
addressToString,
broadcastSignedTransaction,
buf2hex,
getStxFiatEquivalent,
isMultiSig,
microstacksToStx,
StacksTransaction,
TokenTransferPayload,
} from '@secretkeylabs/xverse-core';
import { deserializeTransaction, MultiSigSpendingCondition } from '@stacks/transactions';
import { MultiSigSpendingCondition, deserializeTransaction } from '@stacks/transactions';
import { useMutation } from '@tanstack/react-query';
import { isLedgerAccount } from '@utils/helper';
import BigNumber from 'bignumber.js';
Expand Down
16 changes: 6 additions & 10 deletions src/app/screens/sendFt/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import useStxPendingTxData from '@hooks/queries/useStxPendingTxData';
import useNetworkSelector from '@hooks/useNetwork';
import useWalletSelector from '@hooks/useWalletSelector';
import {
buf2hex,
generateUnsignedTransaction,
StacksTransaction,
UnsignedStacksTransation,
applyFeeMultiplier,
buf2hex,
generateUnsignedTransaction,
validateStxAddress,
} from '@secretkeylabs/xverse-core';
import { useMutation } from '@tanstack/react-query';
Expand All @@ -20,7 +21,7 @@ import { useLocation, useNavigate } from 'react-router-dom';
function SendFtScreen() {
const { t } = useTranslation('translation', { keyPrefix: 'SEND' });
const navigate = useNavigate();
const { stxAddress, stxPublicKey, network, feeMultipliers, coinsList } = useWalletSelector();
const { stxAddress, stxPublicKey, network, coinsList, feeMultipliers } = useWalletSelector();
const [amountError, setAmountError] = useState('');
const [addressError, setAddressError] = useState('');
const [memoError, setMemoError] = useState('');
Expand Down Expand Up @@ -71,13 +72,8 @@ function SendFtScreen() {
pendingTxs: stxPendingTxData?.pendingTransactions ?? [],
memo,
};
const unsignedTx: StacksTransaction = await generateUnsignedTransaction(unsginedTx);

const fee: bigint = BigInt(unsignedTx.auth.spendingCondition.fee.toString()) ?? BigInt(0);
if (feeMultipliers?.stxSendTxMultiplier) {
unsignedTx.setFee(fee * BigInt(feeMultipliers.stxSendTxMultiplier));
}

const unsignedTx = await generateUnsignedTransaction(unsginedTx);
applyFeeMultiplier(unsignedTx, feeMultipliers);
return unsignedTx;
},
});
Expand Down
Loading
Loading