Skip to content

Commit

Permalink
Improve fees calculation in transaction views (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibautBremand authored Nov 9, 2023
1 parent 434bd4f commit 24522f4
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 103 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,19 +45,7 @@ export const AcceptNFTOffer: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'NFTokenAcceptOffer',
Account: '',
...(params.transaction?.NFTokenSellOffer && {
NFTokenSellOffer: params.transaction.NFTokenSellOffer
}),
...(params.transaction?.NFTokenBuyOffer && {
NFTokenBuyOffer: params.transaction.NFTokenBuyOffer
}),
...(params.transaction?.NFTokenBrokerFee && {
NFTokenBrokerFee: params.transaction.NFTokenBrokerFee
})
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,7 @@ export const AddNewTrustline: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'TrustSet',
Account: '',
LimitAmount: params.transaction?.LimitAmount || {
currency: '',
issuer: '',
value: '0'
},
...(params.transaction?.Memos && { Memos: params.transaction?.Memos }),
...(params.transaction?.Flags && { Flags: params.transaction.Flags })
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
7 changes: 1 addition & 6 deletions packages/extension/src/components/pages/BurnNFT/BurnNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,7 @@ export const BurnNFT: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'NFTokenBurn',
Account: '',
NFTokenID: params.transaction?.NFTokenID ?? '',
...(params.transaction?.Owner && { Owner: params.transaction.Owner })
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,7 @@ export const CancelNFTOffer: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'NFTokenCancelOffer',
Account: '',
NFTokenOffers: params.transaction?.NFTokenOffers ?? []
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@ export const CancelOffer: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'OfferCancel',
Account: '',
OfferSequence: params.transaction?.OfferSequence ?? 0
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,16 +45,7 @@ export const CreateNFTOffer: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'NFTokenCreateOffer',
Account: '',
NFTokenID: params.transaction?.NFTokenID ?? '',
Amount: params.transaction?.Amount ?? '',
...(params.transaction?.Owner && { Owner: params.transaction.Owner }),
...(params.transaction?.Expiration && { Expiration: params.transaction.Expiration }),
...(params.transaction?.Destination && { Destination: params.transaction?.Destination }),
...(params.transaction?.Flags && { Flags: params.transaction.Flags })
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ export const CreateOffer: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'OfferCreate',
Account: '',
...(params.transaction?.Flags && { Flags: params.transaction.Flags }),
...(params.transaction?.Expiration && { Expiration: params.transaction.Expiration }),
...(params.transaction?.OfferSequence && { OfferSequence: params.transaction.OfferSequence }),
TakerGets: params.transaction?.TakerGets ?? '',
TakerPays: params.transaction?.TakerPays ?? ''
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const DeleteAccountConfirm: FC<DeleteAccountConfirmProps> = ({
const { errorFees, difference } = useFees(
{
TransactionType: 'AccountDelete',
Account: '',
Account: wallet?.publicAddress ?? '',
Destination: destinationAddress
},
null
Expand Down
10 changes: 1 addition & 9 deletions packages/extension/src/components/pages/MintNFT/MintNFT.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,7 @@ export const MintNFT: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'NFTokenMint',
Account: '',
NFTokenTaxon: params.transaction?.NFTokenTaxon ?? 0,
...(params.transaction?.URI && { URI: params.transaction.URI }),
...(params.transaction?.Flags && { Flags: params.transaction.Flags }),
...(params.transaction?.TransferFee && { TransferFee: params.transaction.TransferFee }),
...(params.transaction?.Issuer && { Issuer: params.transaction.Issuer })
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,7 @@ export const SetAccount: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'AccountSet',
Account: '',
...(params.transaction?.Flags ? { Flags: params.transaction.Flags } : {}),
...(params.transaction?.ClearFlag ? { ClearFlag: params.transaction.ClearFlag } : {}),
...(params.transaction?.Domain ? { Domain: params.transaction.Domain } : {}),
...(params.transaction?.EmailHash ? { EmailHash: params.transaction.EmailHash } : {}),
...(params.transaction?.MessageKey ? { MessageKey: params.transaction.MessageKey } : {}),
...(params.transaction?.NFTokenMinter
? { NFTokenMinter: params.transaction.NFTokenMinter }
: {}),
...(params.transaction?.SetFlag ? { SetFlag: params.transaction.SetFlag } : {}),
...(params.transaction?.TransferRate
? { TransferRate: params.transaction.TransferRate }
: {}),
...(params.transaction?.TickSize ? { TickSize: params.transaction.TickSize } : {})
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,8 @@ export const SignTransaction: FC = () => {
const { isConnectionFailed, networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
params.txParam ?? {
TransactionType: 'Payment',
Account: '',
Destination: '',
Amount: ''
},
params.txParam?.Fee ?? null
params.txParam ?? [],
params.txParam?.Fee
);

const urlParams = new URLSearchParams(window.location.search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const SubmitTransaction: FC = () => {
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
params.txParam ?? [],
params.txParam?.Fee ?? null
params.txParam?.Fee
);

const urlParams = new URLSearchParams(window.location.search);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,7 @@ export const Transaction: FC = () => {
const { networkName } = useNetwork();
const { setTransactionProgress } = useTransactionProgress();
const { estimatedFees, errorFees, difference } = useFees(
{
TransactionType: 'Payment',
Account: '',
Amount: params.transaction?.Amount ?? '',
Destination: params.transaction?.Destination ?? '',
Memos: params.transaction?.Memos ?? undefined,
DestinationTag: params.transaction?.DestinationTag ?? undefined,
Flags: params.transaction?.Flags ?? undefined
},
params.transaction ?? [],
params.transaction?.Fee
);

Expand Down

0 comments on commit 24522f4

Please sign in to comment.