1- import { common } from '@hyperledger/fabric-protos' ;
1+ import { common , msp } from '@hyperledger/fabric-protos' ;
22import SignaturePolicy = common . SignaturePolicy
3+ import SignaturePolicyEnvelope = common . SignaturePolicyEnvelope
34import NOutOf = SignaturePolicy . NOutOf ;
45import { IndexDigit , isIndex } from "../types.js" ;
56import assert from 'assert'
6-
7- const { SignaturePolicyEnvelope} = common
7+ import MSPPrincipal = msp . MSPPrincipal
88
99
1010/**
@@ -14,12 +14,11 @@ export const SignaturePolicyType = "Signature"
1414export const TypeCase = [ 'TYPE_NOT_SET' , 'SIGNED_BY' , 'N_OUT_OF' ]
1515
1616/**
17- *
1817 * @param {NOutOf } [n_out_of] exclusive with signed_by
19- * @param { IndexDigit } [signed_by] exclusive with n_out_of
18+ * @param [signed_by] exclusive with n_out_of
2019 * @return {SignaturePolicy }
2120 */
22- export function build ( { n_out_of, signed_by} : { n_out_of ?: NOutOf ; signed_by ?: IndexDigit } ) {
21+ export function build ( { n_out_of, signed_by} : { n_out_of ?: NOutOf ; signed_by ?: IndexDigit } ) : SignaturePolicy {
2322 const signaturePolicy = new SignaturePolicy ( ) ;
2423 if ( n_out_of ) {
2524 signaturePolicy . setNOutOf ( n_out_of )
@@ -29,21 +28,18 @@ export function build({n_out_of, signed_by}: { n_out_of?: NOutOf; signed_by?: In
2928 return signaturePolicy ;
3029}
3130
32- /**
33- *
34- * @param {IndexDigit } n
35- * @param {SignaturePolicy[] } rules
36- * @return {NOutOf }
37- */
38- export function buildNOutOf ( { n, rules} : { n : IndexDigit , rules : SignaturePolicy [ ] } ) {
31+ export function buildNOutOf ( { n, rules} : { n : IndexDigit , rules : SignaturePolicy [ ] } ) : NOutOf {
3932 const nOutOf = new SignaturePolicy . NOutOf ( )
4033 assert . ok ( isIndex ( n ) )
4134 nOutOf . setN ( n )
4235 nOutOf . setRulesList ( rules )
4336 return nOutOf
4437}
4538
46- export function buildEnvelope ( { identities, rule} ) {
39+ export function buildEnvelope ( { identities, rule} : {
40+ identities : MSPPrincipal [ ] ,
41+ rule : SignaturePolicy
42+ } ) : SignaturePolicyEnvelope {
4743 const envelope = new SignaturePolicyEnvelope ( ) ;
4844 envelope . setVersion ( 0 ) ;
4945 envelope . setRule ( rule ) ;
0 commit comments