Skip to content

Commit

Permalink
Merge pull request #580 from secretkeylabs/mahmoud/eng-5128-stxcity-t…
Browse files Browse the repository at this point in the history
…oken-fails-on-estimate-fees-need-a-fallback-for

[ENG-5128][ENG-5129][ENG-5077] Use Updated Estimate util & remove nonce manipulation
  • Loading branch information
m-aboelenein authored Sep 17, 2024
2 parents a5ec2cd + 9e8ffc8 commit c0f18e6
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 22 deletions.
15 changes: 8 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@react-spring/web": "^9.6.1",
"@sats-connect/core": "0.2.1",
"@scure/btc-signer": "1.2.1",
"@secretkeylabs/xverse-core": "19.1.0",
"@secretkeylabs/xverse-core": "19.3.0",
"@stacks/connect": "7.4.1",
"@stacks/stacks-blockchain-api-types": "6.1.1",
"@stacks/transactions": "6.16.1",
Expand Down
10 changes: 4 additions & 6 deletions src/app/components/confirmStxTransactionComponent/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Transport from '@ledgerhq/hw-transport-webusb';
import { FadersHorizontal } from '@phosphor-icons/react';
import type { StacksTransaction } from '@secretkeylabs/xverse-core';
import {
estimateStacksTransactionWithFallback,
getNonce,
getStxFiatEquivalent,
microstacksToStx,
Expand All @@ -24,7 +25,7 @@ import {
signTransaction,
stxToMicrostacks,
} from '@secretkeylabs/xverse-core';
import { estimateTransaction, PostConditionMode } from '@stacks/transactions';
import { PostConditionMode } from '@stacks/transactions';
import SelectFeeRate from '@ui-components/selectFeeRate';
import Button from '@ui-library/button';
import Callout from '@ui-library/callout';
Expand Down Expand Up @@ -128,9 +129,8 @@ function ConfirmStxTransactionComponent({
const fetchStxFees = async () => {
try {
setFeesLoading(true);
const [low, medium, high] = await estimateTransaction(
initialStxTransactions[0].payload,
undefined,
const [low, medium, high] = await estimateStacksTransactionWithFallback(
initialStxTransactions[0],
selectedNetwork,
);

Expand Down Expand Up @@ -224,8 +224,6 @@ function ConfirmStxTransactionComponent({

if (initialStxTransactions.length === 1) {
const transaction = initialStxTransactions[0];
const nonce = await nextBestNonce(selectedAccount.stxAddress, network);
transaction.setNonce(nonce);
const signedContractCall = await signTransaction(
transaction,
seed,
Expand Down
8 changes: 4 additions & 4 deletions src/app/hooks/useRbfTransactionData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import useStxWalletData from '@hooks/queries/useStxWalletData';
import {
estimateStacksTransactionWithFallback,
mempoolApi,
microstacksToStx,
rbf,
Expand All @@ -9,7 +10,7 @@ import {
type StacksTransaction,
type StxTransactionData,
} from '@secretkeylabs/xverse-core';
import { deserializeTransaction, estimateTransaction } from '@stacks/transactions';
import { deserializeTransaction } from '@stacks/transactions';
import { isLedgerAccount } from '@utils/helper';
import axios from 'axios';
import BigNumber from 'bignumber.js';
Expand Down Expand Up @@ -137,9 +138,8 @@ const useRbfTransactionData = (transaction?: BtcTransactionData | StxTransaction
const txRaw: string = await getRawTransaction(transaction.txid, network);
const unsignedTx: StacksTransaction = deserializeTransaction(txRaw);

const [slow, medium, high] = await estimateTransaction(
unsignedTx.payload,
undefined,
const [slow, medium, high] = await estimateStacksTransactionWithFallback(
unsignedTx,
selectedNetwork,
);

Expand Down
8 changes: 4 additions & 4 deletions src/app/screens/sendStx/steps/Step2SelectAmount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import useSelectedAccount from '@hooks/useSelectedAccount';
import useWalletSelector from '@hooks/useWalletSelector';
import {
buf2hex,
estimateStacksTransactionWithFallback,
generateUnsignedStxTokenTransferTransaction,
generateUnsignedTransaction,
getStxFiatEquivalent,
Expand All @@ -14,7 +15,7 @@ import {
type FungibleToken,
type StacksTransaction,
} from '@secretkeylabs/xverse-core';
import { deserializeTransaction, estimateTransaction } from '@stacks/transactions';
import { deserializeTransaction } from '@stacks/transactions';
import SelectFeeRate, { type FeeRates } from '@ui-components/selectFeeRate';
import Button from '@ui-library/button';
import Callout from '@ui-library/callout';
Expand Down Expand Up @@ -205,9 +206,8 @@ function Step2SelectAmount({
const fetchStxFees = async () => {
try {
const unsignedTx: StacksTransaction = deserializeTransaction(unsignedSendStxTx);
const [low, medium, high] = await estimateTransaction(
unsignedTx.payload,
undefined,
const [low, medium, high] = await estimateStacksTransactionWithFallback(
unsignedTx,
selectedNetwork,
);

Expand Down

0 comments on commit c0f18e6

Please sign in to comment.