Skip to content

Commit 9cb09c9

Browse files
OttoAllmendingerllm-git
andcommitted
feat(sdk-core): improve ParsedTransaction interface type
Document the main purpose of ParsedTransaction and make the key field implicitExternalSpendAmount explicit in the interface. Remove unnecessary type assertions in pendingApproval.ts that are now handled by the improved type definition. Issue: BTC-2732 Co-authored-by: llm-git <[email protected]>
1 parent 50d0d27 commit 9cb09c9

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

modules/sdk-core/src/bitgo/baseCoin/iBaseCoin.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,8 +277,14 @@ export interface ParseTransactionOptions {
277277
[index: string]: unknown;
278278
}
279279

280-
// TODO (SDKT-9): reverse engineer and add options
280+
/**
281+
* This is only used for determining the PayGo fee of a transaction which is only relevant for UTXO coins.
282+
* Some coins return various other fields here, but they are only used internally by the respective coins.
283+
*/
281284
export interface ParsedTransaction {
285+
// the callsite assumes that this is the PayGo amount
286+
implicitExternalSpendAmount?: number | bigint;
287+
// coins may add internal fields
282288
[index: string]: unknown;
283289
}
284290

modules/sdk-core/src/bitgo/pendingApproval/pendingApproval.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -304,16 +304,16 @@ export class PendingApproval implements IPendingApproval {
304304
prebuildParams = _.extend({}, prebuildParams, { reqId: reqId });
305305
const signedTransaction = await this.wallet.prebuildAndSignTransaction(prebuildParams);
306306
// compare PAYGo fees
307-
const originalParsedTransaction = (await this.baseCoin.parseTransaction({
307+
const originalParsedTransaction = await this.baseCoin.parseTransaction({
308308
txParams: prebuildParams,
309309
wallet: this.wallet,
310310
txPrebuild: originalPrebuild,
311-
})) as any;
312-
const recreatedParsedTransaction = (await this.baseCoin.parseTransaction({
311+
});
312+
const recreatedParsedTransaction = await this.baseCoin.parseTransaction({
313313
txParams: prebuildParams,
314314
wallet: this.wallet,
315315
txPrebuild: signedTransaction,
316-
})) as any;
316+
});
317317

318318
if (_.isUndefined(recreatedParsedTransaction.implicitExternalSpendAmount)) {
319319
return signedTransaction;

0 commit comments

Comments
 (0)