Skip to content

Commit aed68be

Browse files
Merge pull request #1647 from input-output-hk/feat/tx-summary-inspector-return-resolved-inputs
feat(core): return resolved inputs from summary inspector - [LW-12769]
2 parents 561c90b + 23b4f26 commit aed68be

File tree

2 files changed

+80
-1
lines changed

2 files changed

+80
-1
lines changed

packages/core/src/util/transactionSummaryInspector.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export type TransactionSummaryInspection = {
5151
inputs: Cardano.TxIn[];
5252
value: Cardano.Value;
5353
};
54+
resolvedInputs: ResolutionResult['resolvedInputs'];
5455
};
5556

5657
export type TransactionSummaryInspector = (
@@ -232,6 +233,7 @@ export const transactionSummaryInspector: TransactionSummaryInspector =
232233
collateral,
233234
deposit: implicit.deposit || 0n,
234235
fee,
236+
resolvedInputs: resolvedInputs.resolvedInputs,
235237
returnedDeposit: implicit.reclaimDeposit || 0n,
236238
unresolved: {
237239
inputs: resolvedInputs.unresolvedInputs,

packages/core/test/util/transactionSummaryInspector.test.ts

Lines changed: 78 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
AssetInfoWithAmount,
77
AssetProvider,
88
Milliseconds,
9+
TransactionSummaryInspection,
910
createTxInspector,
1011
transactionSummaryInspector
1112
} from '../../src';
@@ -339,7 +340,7 @@ describe('Transaction Summary Inspector', () => {
339340
const { summary } = await inspectTx(tx);
340341

341342
// Assert
342-
expect(summary).toEqual({
343+
expect(summary).toEqual<TransactionSummaryInspection>({
343344
assets: buildAssetInfoWithAmount([
344345
[assetInfos[AssetInfoIdx.A], 1n],
345346
[assetInfos[AssetInfoIdx.C], -1n],
@@ -352,6 +353,20 @@ describe('Transaction Summary Inspector', () => {
352353
collateral: 0n,
353354
deposit: 0n,
354355
fee,
356+
resolvedInputs: [
357+
{
358+
...tx.body.inputs[0],
359+
value: histTx[0].body.outputs[0].value
360+
},
361+
{
362+
...tx.body.inputs[1],
363+
value: histTx[0].body.outputs[1].value
364+
},
365+
{
366+
...tx.body.inputs[2],
367+
value: histTx[0].body.outputs[2].value
368+
}
369+
],
355370
returnedDeposit: 0n,
356371
unresolved: {
357372
inputs: [],
@@ -444,6 +459,12 @@ describe('Transaction Summary Inspector', () => {
444459
collateral: 10_000_000n,
445460
deposit: 0n,
446461
fee,
462+
resolvedInputs: [
463+
{
464+
...tx.body.inputs[0],
465+
value: histTx[0].body.outputs[0].value
466+
}
467+
],
447468
returnedDeposit: 0n,
448469
unresolved: {
449470
inputs: [],
@@ -538,6 +559,12 @@ describe('Transaction Summary Inspector', () => {
538559
collateral: 25_000_000n,
539560
deposit: 0n,
540561
fee,
562+
resolvedInputs: [
563+
{
564+
...tx.body.inputs[0],
565+
value: histTx[0].body.outputs[0].value
566+
}
567+
],
541568
returnedDeposit: 0n,
542569
unresolved: {
543570
inputs: [],
@@ -624,6 +651,12 @@ describe('Transaction Summary Inspector', () => {
624651
collateral: 5_000_000n,
625652
deposit: 0n,
626653
fee,
654+
resolvedInputs: [
655+
{
656+
...tx.body.inputs[0],
657+
value: histTx[0].body.outputs[0].value
658+
}
659+
],
627660
returnedDeposit: 0n,
628661
unresolved: {
629662
inputs: [],
@@ -693,6 +726,12 @@ describe('Transaction Summary Inspector', () => {
693726
collateral: 0n,
694727
deposit: 2_000_000n,
695728
fee,
729+
resolvedInputs: [
730+
{
731+
...tx.body.inputs[0],
732+
value: histTx[0].body.outputs[0].value
733+
}
734+
],
696735
returnedDeposit: 0n,
697736
unresolved: {
698737
inputs: [],
@@ -762,6 +801,12 @@ describe('Transaction Summary Inspector', () => {
762801
collateral: 0n,
763802
deposit: 0n,
764803
fee,
804+
resolvedInputs: [
805+
{
806+
...tx.body.inputs[0],
807+
value: histTx[0].body.outputs[0].value
808+
}
809+
],
765810
returnedDeposit: 2_000_000n,
766811
unresolved: {
767812
inputs: [],
@@ -840,6 +885,12 @@ describe('Transaction Summary Inspector', () => {
840885
collateral: 0n,
841886
deposit: 15_000_000n,
842887
fee,
888+
resolvedInputs: [
889+
{
890+
...tx.body.inputs[0],
891+
value: histTx[0].body.outputs[0].value
892+
}
893+
],
843894
returnedDeposit: 0n,
844895
unresolved: {
845896
inputs: [],
@@ -918,6 +969,12 @@ describe('Transaction Summary Inspector', () => {
918969
collateral: 0n,
919970
deposit: 0n,
920971
fee,
972+
resolvedInputs: [
973+
{
974+
...tx.body.inputs[0],
975+
value: histTx[0].body.outputs[0].value
976+
}
977+
],
921978
returnedDeposit: 15_000_000n,
922979
unresolved: {
923980
inputs: [],
@@ -1011,6 +1068,12 @@ describe('Transaction Summary Inspector', () => {
10111068
collateral: 0n,
10121069
deposit: 0n,
10131070
fee,
1071+
resolvedInputs: [
1072+
{
1073+
...tx.body.inputs[0],
1074+
value: histTx[0].body.outputs[0].value
1075+
}
1076+
],
10141077
returnedDeposit: 0n,
10151078
unresolved: {
10161079
inputs: [
@@ -1100,6 +1163,7 @@ describe('Transaction Summary Inspector', () => {
11001163
collateral: 0n,
11011164
deposit: 0n,
11021165
fee,
1166+
resolvedInputs: [],
11031167
returnedDeposit: 0n,
11041168
unresolved: {
11051169
inputs: [
@@ -1199,6 +1263,19 @@ describe('Transaction Summary Inspector', () => {
11991263
"collateral": 0n,
12001264
"deposit": 0n,
12011265
"fee": 170000n,
1266+
"resolvedInputs": Array [
1267+
Object {
1268+
"address": "addr1z8phkx6acpnf78fuvxn0mkew3l0fd058hzquvz7w36x4gten0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgs9yc0hh",
1269+
"index": 0,
1270+
"txId": "bb217abaca60fc0ca68c1555eca6a96d2478547818ae76ce6836133f3cc546e0",
1271+
"value": Object {
1272+
"assets": Map {
1273+
"659f2917fb63f12b33667463ee575eeac1845bbc736b9c0bbc40ba8254534c41" => 5n,
1274+
},
1275+
"coins": 3000000n,
1276+
},
1277+
},
1278+
],
12021279
"returnedDeposit": 0n,
12031280
"unresolved": Object {
12041281
"inputs": Array [],

0 commit comments

Comments
 (0)