Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import * as t from 'io-ts';
import { httpRoute, httpRequest, optional } from '@api-ts/io-ts-http';
import { TransactionRequest as TxRequestResponse } from '@bitgo/public-types';
import type { PrebuildTransactionFeeInfo } from '@bitgo/sdk-core';
import { BitgoExpressError } from '../../schemas/error';
import {
FullySignedTransactionResponse,
Expand Down Expand Up @@ -217,14 +218,15 @@ export const AddressVerificationData = t.partial({
});

/**
* Fee information
* Fee information — codec for {@link PrebuildTransactionFeeInfo} from sdk-core.
*/
export const FeeInfo = t.partial({
/** Fee amount */
fee: t.number,
/** Fee as string */
feeString: t.string,
});
export type FeeInfo = PrebuildTransactionFeeInfo;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the standard t.TypeOf construction would be more appropriate - from here I have no way to tell if they are in fact equal and will stay equal


/**
* Consolidation details for sweep/consolidation transactions
Expand Down
12 changes: 3 additions & 9 deletions modules/sdk-core/src/bitgo/utils/tss/baseTypes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Key, SerializedKeyPair } from 'openpgp';
import { EncryptionVersion, IEncryptionSession, IRequestTracer } from '../../../api';
import { type ITransactionRecipient, KeychainsTriplet, ParsedTransaction, TransactionParams } from '../../baseCoin';
import { ApiKeyShare, Keychain, WebauthnKeyEncryptionInfo } from '../../keychain';
import { ApiVersion, Memo, WalletType } from '../../wallet';
import { ApiVersion, Memo, WalletType, type PrebuildTransactionFeeInfo } from '../../wallet';
import { EDDSA, GShare, Signature, SignShare } from '../../../account-lib/mpc/tss';
import { Signature as EcdsaSignature } from '../../../account-lib/mpc/tss/ecdsa/types';
import { KeyShare } from './ecdsa';
Expand Down Expand Up @@ -531,10 +531,7 @@ export type UnsignedTransactionTss = SignableTransaction & {
// derivation path of the signer
derivationPath: string;
// transaction fees
feeInfo?: {
fee: number;
feeString: string;
};
feeInfo?: Required<PrebuildTransactionFeeInfo>;
coinSpecific?: Record<string, unknown>;
parsedTx?: unknown;
eip1559?: EIP1559FeeOptions;
Expand Down Expand Up @@ -769,10 +766,7 @@ export interface MPCTx {
signableHex?: string;
derivationPath?: string;
parsedTx?: ParsedTransaction;
feeInfo?: {
fee: number;
feeString: string;
};
feeInfo?: Required<PrebuildTransactionFeeInfo>;
coinSpecific?: {
firstValid?: number;
maxDuration?: number;
Expand Down
15 changes: 9 additions & 6 deletions modules/sdk-core/src/bitgo/wallet/iWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,13 @@ export interface PrebuildAndSignTransactionOptions extends PrebuildTransactionOp
verification?: VerificationOptions;
}

export interface PrebuildTransactionResult extends TransactionPrebuild {
/** Fee fields returned on {@link PrebuildTransactionResult} (withdraw / send previews). */
export type PrebuildTransactionFeeInfo = {
fee?: number;
feeString?: string;
};

export type PrebuildTransactionResult = TransactionPrebuild & {
walletId: string;
// Consolidate ID is used for consolidate account transactions and indicates if this is
// a consolidation and what consolidate group it should be referenced by.
Expand All @@ -332,16 +338,13 @@ export interface PrebuildTransactionResult extends TransactionPrebuild {
consolidationDetails?: {
senderAddressIndex: number;
};
feeInfo?: {
fee?: number;
feeString?: string;
};
feeInfo?: PrebuildTransactionFeeInfo;
pendingApprovalId?: string;
reqId?: IRequestTracer;
payload?: string;
stakingParams?: unknown;
recipients?: ITransactionRecipient[];
}
};

export interface CustomSigningFunction {
(params: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import assert from 'assert';

import type { PrebuildTransactionFeeInfo, PrebuildTransactionResult } from '../../../../src/bitgo/wallet/iWallet';

describe('PrebuildTransactionFeeInfo', () => {
it('assigns feeInfo on PrebuildTransactionResult', () => {
const feeInfo: PrebuildTransactionFeeInfo = {
fee: 1000,
feeString: '1000',
};

const prebuild: Pick<PrebuildTransactionResult, 'walletId' | 'feeInfo'> = {
walletId: 'wallet-id',
feeInfo,
};

assert.strictEqual(prebuild.feeInfo?.feeString, '1000');
});
});
Loading