Skip to content

Commit ce982cd

Browse files
committed
[WIP] migrating discovery.ts
@hyperledger-twgc/fabric-formatter: 0.0.0-dev.11 fix path.js Signed-off-by: david <[email protected]>
1 parent a90d604 commit ce982cd

File tree

7 files changed

+35
-20
lines changed

7 files changed

+35
-20
lines changed

ts/formatter/lib/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
export * as chaincode from './chaincode.js';
22
export * from './constants.js';
3+
export * from './ca/constants.js'
34
export * as discovery from './discovery.js';
45
export * as gatePolicy from './gate-policy.js';
56
export * from './helper.js';
7+
export * from './fs/path.js'
68
export * as mspPrincipal from './msp-principal.js';
79
export * from './names.js';
810
export * from './pretty-parser.js';
911
export * as collection from './side-db.js';
1012
export * from './types.js';
11-
export * from './user.js';
13+
export * from './user.js';
14+
export * as proto from './proto/index.js'

ts/formatter/lib/proto/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export * from './channel-builder.js'
2+
export * from './common-builder.js'
3+
export * from './common-parser.js'
4+
export * from './proposal-builder.js'
5+
export * as signaturePolicy from './signature-policy.js'

ts/formatter/lib/proto/signature-policy.ts

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import {common} from '@hyperledger/fabric-protos';
1+
import {common, msp} from '@hyperledger/fabric-protos';
22
import SignaturePolicy = common.SignaturePolicy
3+
import SignaturePolicyEnvelope = common.SignaturePolicyEnvelope
34
import NOutOf = SignaturePolicy.NOutOf;
45
import {IndexDigit, isIndex} from "../types.js";
56
import assert from 'assert'
6-
7-
const {SignaturePolicyEnvelope} = common
7+
import MSPPrincipal = msp.MSPPrincipal
88

99

1010
/**
@@ -14,12 +14,11 @@ export const SignaturePolicyType = "Signature"
1414
export 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);

ts/formatter/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "@hyperledger-twgc/fabric-formatter",
3-
"version": "0.0.0-dev.9",
3+
"version": "0.0.0-dev.11",
44
"description": "Hyperledger Fabric formatter",
55
"repository": {
66
"type": "git",
77
"url": "https://github.com/Hyperledger/fabric-admin-sdk"
88
},
99
"main": "dist/index.js",
10+
"module": "dist/index.js",
1011
"author": {
1112
"name": "hyperledger-twgc",
1213
"url": "https://github.com/Hyperledger-TWGC/Hyperledger-TWGC"
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
11
import "@hyperledger/fabric-protos"
22
import "@hyperledger-twgc/fabric-formatter/dist/index.js"
3-
import "@hyperledger-twgc/fabric-formatter"
3+
import "@hyperledger-twgc/fabric-formatter"
4+
5+
it('ok', function () {
6+
7+
})
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
{
22
"scripts": {
3-
"test": "node index.js"
3+
"test": "mocha index.js"
44
},
55
"dependencies": {
6-
"@hyperledger-twgc/fabric-formatter": "unstable",
6+
"@hyperledger-twgc/fabric-formatter": "^0.0.0-dev.11",
77
"@hyperledger/fabric-protos": "latest"
88
},
9+
"devDependencies": {
10+
"mocha": "latest"
11+
},
912
"private": true,
1013
"type": "module"
1114
}

ts/formatter/test/syntax.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ import "../dist/msp-principal.js"
1010
import "../dist/policy.js"
1111
import "../dist/pretty-parser.js"
1212
import "../dist/side-db.js"
13-
it('OK', ()=>{
13+
import "../dist/proto/index.js"
14+
import "../dist/index.js"
15+
16+
it('OK', () => {
1417

1518
})

0 commit comments

Comments
 (0)