@@ -8,7 +8,7 @@ import type {
88 TypeName ,
99} from '.' ;
1010import type Condition from '../lib/condition' ;
11- import type Fulfillment from '../lib/fulfillment' ;
11+ import Fulfillment , { FulfillmentAsn1JsonValueMap } from '../lib/fulfillment' ;
1212import type BaseSha256 from './base-sha256' ;
1313
1414export const CONDITION = 'condition' ;
@@ -19,7 +19,7 @@ interface SubConditionBodyMap {
1919 fulfillment : Fulfillment ;
2020}
2121
22- export type SubCondition < T = 'condition' | 'fulfillment' > = {
22+ export type SubCondition < T extends keyof SubConditionBodyMap > = {
2323 type : T ;
2424 body : SubConditionBodyMap [ T ] ;
2525} ;
@@ -32,7 +32,7 @@ export const TYPE_CATEGORY = TypeCategory.ThresholdSha256;
3232
3333export default class ThresholdSha256 extends BaseSha256 {
3434 private threshold : number ;
35- private subconditions : SubCondition [ ] ;
35+ private subconditions : SubCondition < keyof SubConditionBodyMap > [ ] ;
3636
3737 static TYPE_ID : TypeId . ThresholdSha256 ;
3838 static TYPE_NAME : TypeName . ThresholdSha256 ;
@@ -54,9 +54,7 @@ export default class ThresholdSha256 extends BaseSha256 {
5454
5555 private getFingerprintContents ( ) : Buffer ;
5656
57- private calculateCost ( ) : number ;
58-
59- static getSubconditionCost ( cond : SubCondition ) : number ;
57+ static getSubconditionCost < T extends keyof SubConditionBodyMap > ( cond : SubCondition < T > ) : number ;
6058
6159 private static calculateWorstCaseLength (
6260 threshold : number ,
@@ -65,7 +63,7 @@ export default class ThresholdSha256 extends BaseSha256 {
6563
6664 parseJson ( json : ThresholdSha256Json ) : void ;
6765
68- parseAsn1JsonPayload ( json : ThresholdSha256Asn1Json ) : void ;
66+ parseAsn1JsonPayload ( json : FulfillmentAsn1JsonValueMap [ TypeAsn1Fulfillment . ThresholdSha256 ] ) : void ;
6967
7068 getAsn1JsonPayload ( ) : ThresholdSha256Asn1Json ;
7169
0 commit comments