Skip to content

Commit

Permalink
chore(suite): types and receive priorityFee object
Browse files Browse the repository at this point in the history
  • Loading branch information
enjojoy committed Jan 15, 2025
1 parent 892a2d8 commit db85ed5
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions packages/connect/src/api/blockchainEstimateFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export default class BlockchainEstimateFee extends AbstractMethod<'blockchainEst
maxFee: coinInfo.maxFee,
dustLimit: coinInfo.type === 'bitcoin' ? coinInfo.dustLimit : undefined,
levels: [],
priorityFees: undefined,
};
if (request && request.feeLevels) {
const fees = new FeeLevels(coinInfo);
Expand All @@ -82,6 +83,10 @@ export default class BlockchainEstimateFee extends AbstractMethod<'blockchainEst
} else {
const backend = await initBlockchain(coinInfo, this.postMessage, identity);
feeInfo.levels = await backend.estimateFee(request || {});
// priority fees are not supported on Ethereum classic
if (coinInfo.type === 'ethereum' && coinInfo.chainId !== 61) {
feeInfo.priorityFees = feeInfo.levels[0].eip1559;
}
}

return feeInfo;
Expand Down
2 changes: 2 additions & 0 deletions packages/connect/src/types/api/blockchainEstimateFee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ interface EstimatedFee extends Omit<FeeInfo, 'dustLimit'> {

export interface BlockchainEstimatedFee extends EstimatedFee {
levels: BlockchainLinkResponse<'estimateFee'>;
priorityFees?: FeeLevel['eip1559'];
}

export interface BlockchainEstimatedFeeLevel extends EstimatedFee {
levels: FeeLevel[];
priorityFees?: FeeLevel['eip1559'];
}

export declare function blockchainEstimateFee(
Expand Down
3 changes: 2 additions & 1 deletion packages/connect/src/types/fees.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export const FeeInfo = Type.Object({
dustLimit: Type.Number(),
});

const PriorityFeeEstimationDetails = Type.Object({
export type PriorityFeeEstimationDetails = Static<typeof PriorityFeeEstimationDetails>;
export const PriorityFeeEstimationDetails = Type.Object({
maxFeePerGas: Type.String(),
maxPriorityFeePerGas: Type.String(),
maxWaitTimeEstimate: Type.Number(),
Expand Down
1 change: 1 addition & 0 deletions suite-common/wallet-types/src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export interface FeeInfo {
dustLimit?: number; // coin dust limit
feeLimit?: number; // eth gas limit
levels: FeeLevel[]; // fee levels are predefined in @trezor/connect > trezor-firmware/common
priorityFees?: FeeLevel['eip1559'];
}

export type NetworksFees = Record<NetworkSymbol, FeeInfo>;
Expand Down

0 comments on commit db85ed5

Please sign in to comment.