Skip to content

Commit 82d853c

Browse files
authored
Merge branch 'main' into java-chincode
Signed-off-by: Jakub Dzikowski <jakub.t.dzikowski@gmail.com>
2 parents a090b29 + 78e3a71 commit 82d853c

File tree

4 files changed

+144
-29
lines changed

4 files changed

+144
-29
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
## 2.3.0
22
* Support for running Java chaincode in development mode
33
[#553](https://github.com/hyperledger-labs/fablo/pull/553)
4+
* Hardcode fablo config inside init generator
5+
[#554](https://github.com/hyperledger-labs/fablo/pull/554)
46

57
## 2.2.0
68

Dockerfile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ COPY package.json /fablo/package.json
99
COPY package-lock.json /fablo/package-lock.json
1010

1111
# copy files for init network
12-
COPY samples/fablo-config-hlf2-1org-1chaincode.json /fablo/generators/init/templates/fablo-config.json
1312
COPY samples/chaincodes/chaincode-kv-node /fablo/generators/init/templates/chaincodes/chaincode-kv-node
1413

1514
WORKDIR /fablo

e2e/__snapshots__/fabloCommands.test.ts.snap

Lines changed: 68 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,8 +2475,8 @@ Validation warnings count: 0
24752475
"global": {
24762476
"fabricVersion": "2.5.9",
24772477
"tls": false,
2478-
"engine": "docker",
24792478
"peerDevMode": false,
2479+
"engine": "docker",
24802480
"fabricToolsVersion": "2.5.9",
24812481
"fabricCaVersion": "1.5.5",
24822482
"fabricCcenvVersion": "2.5.9",
@@ -2969,32 +2969,45 @@ exports[`init should init simple fablo config 1`] = `
29692969
"global": {
29702970
"fabricVersion": "2.5.9",
29712971
"tls": false,
2972-
"engine": "docker",
2973-
"peerDevMode": false
2972+
"peerDevMode": false,
2973+
"engine": "docker"
29742974
},
29752975
"orgs": [
29762976
{
29772977
"organization": {
29782978
"name": "Orderer",
2979-
"domain": "orderer.example.com"
2979+
"domain": "orderer.example.com",
2980+
"mspName": "OrdererMSP"
2981+
},
2982+
"ca": {
2983+
"prefix": "ca",
2984+
"db": "sqlite"
29802985
},
29812986
"orderers": [
29822987
{
29832988
"groupName": "group1",
29842989
"type": "solo",
2985-
"instances": 1
2990+
"instances": 1,
2991+
"prefix": "orderer"
29862992
}
29872993
],
29882994
"tools": {}
29892995
},
29902996
{
29912997
"organization": {
29922998
"name": "Org1",
2993-
"domain": "org1.example.com"
2999+
"domain": "org1.example.com",
3000+
"mspName": "Org1MSP"
29943001
},
3002+
"ca": {
3003+
"prefix": "ca",
3004+
"db": "sqlite"
3005+
},
3006+
"orderers": [],
29953007
"peer": {
29963008
"instances": 2,
2997-
"db": "LevelDb"
3009+
"db": "LevelDb",
3010+
"prefix": "peer"
29983011
},
29993012
"tools": {}
30003013
}
@@ -3013,7 +3026,8 @@ exports[`init should init simple fablo config 1`] = `
30133026
]
30143027
}
30153028
],
3016-
"chaincodes": []
3029+
"chaincodes": [],
3030+
"hooks": {}
30173031
}"
30183032
`;
30193033

@@ -3023,32 +3037,45 @@ exports[`init should init simple fablo config with node chaincode 1`] = `
30233037
"global": {
30243038
"fabricVersion": "2.5.9",
30253039
"tls": false,
3026-
"engine": "docker",
3027-
"peerDevMode": false
3040+
"peerDevMode": false,
3041+
"engine": "docker"
30283042
},
30293043
"orgs": [
30303044
{
30313045
"organization": {
30323046
"name": "Orderer",
3033-
"domain": "orderer.example.com"
3047+
"domain": "orderer.example.com",
3048+
"mspName": "OrdererMSP"
3049+
},
3050+
"ca": {
3051+
"prefix": "ca",
3052+
"db": "sqlite"
30343053
},
30353054
"orderers": [
30363055
{
30373056
"groupName": "group1",
30383057
"type": "solo",
3039-
"instances": 1
3058+
"instances": 1,
3059+
"prefix": "orderer"
30403060
}
30413061
],
30423062
"tools": {}
30433063
},
30443064
{
30453065
"organization": {
30463066
"name": "Org1",
3047-
"domain": "org1.example.com"
3067+
"domain": "org1.example.com",
3068+
"mspName": "Org1MSP"
30483069
},
3070+
"ca": {
3071+
"prefix": "ca",
3072+
"db": "sqlite"
3073+
},
3074+
"orderers": [],
30493075
"peer": {
30503076
"instances": 2,
3051-
"db": "LevelDb"
3077+
"db": "LevelDb",
3078+
"prefix": "peer"
30523079
},
30533080
"tools": {}
30543081
}
@@ -3073,9 +3100,11 @@ exports[`init should init simple fablo config with node chaincode 1`] = `
30733100
"version": "0.0.1",
30743101
"lang": "node",
30753102
"channel": "my-channel1",
3076-
"directory": "./chaincodes/chaincode-kv-node"
3103+
"directory": "./chaincodes/chaincode-kv-node",
3104+
"privateData": []
30773105
}
3078-
]
3106+
],
3107+
"hooks": {}
30793108
}"
30803109
`;
30813110

@@ -3085,20 +3114,26 @@ exports[`init should init simple fablo config with node chaincode and rest api 1
30853114
"global": {
30863115
"fabricVersion": "2.5.9",
30873116
"tls": false,
3088-
"engine": "docker",
3089-
"peerDevMode": false
3117+
"peerDevMode": false,
3118+
"engine": "docker"
30903119
},
30913120
"orgs": [
30923121
{
30933122
"organization": {
30943123
"name": "Orderer",
3095-
"domain": "orderer.example.com"
3124+
"domain": "orderer.example.com",
3125+
"mspName": "OrdererMSP"
3126+
},
3127+
"ca": {
3128+
"prefix": "ca",
3129+
"db": "sqlite"
30963130
},
30973131
"orderers": [
30983132
{
30993133
"groupName": "group1",
31003134
"type": "solo",
3101-
"instances": 1
3135+
"instances": 1,
3136+
"prefix": "orderer"
31023137
}
31033138
],
31043139
"tools": {
@@ -3108,11 +3143,18 @@ exports[`init should init simple fablo config with node chaincode and rest api 1
31083143
{
31093144
"organization": {
31103145
"name": "Org1",
3111-
"domain": "org1.example.com"
3146+
"domain": "org1.example.com",
3147+
"mspName": "Org1MSP"
31123148
},
3149+
"ca": {
3150+
"prefix": "ca",
3151+
"db": "sqlite"
3152+
},
3153+
"orderers": [],
31133154
"peer": {
31143155
"instances": 2,
3115-
"db": "LevelDb"
3156+
"db": "LevelDb",
3157+
"prefix": "peer"
31163158
},
31173159
"tools": {
31183160
"fabloRest": true
@@ -3139,8 +3181,10 @@ exports[`init should init simple fablo config with node chaincode and rest api 1
31393181
"version": "0.0.1",
31403182
"lang": "node",
31413183
"channel": "my-channel1",
3142-
"directory": "./chaincodes/chaincode-kv-node"
3184+
"directory": "./chaincodes/chaincode-kv-node",
3185+
"privateData": []
31433186
}
3144-
]
3187+
],
3188+
"hooks": {}
31453189
}"
31463190
`;

src/init/index.ts

Lines changed: 74 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,85 @@
11
import * as Generator from "yeoman-generator";
22
import * as chalk from "chalk";
3-
import parseFabloConfig from "../utils/parseFabloConfig";
4-
import { GlobalJson } from "../types/FabloConfigJson";
3+
import { GlobalJson, FabloConfigJson } from "../types/FabloConfigJson";
4+
5+
function getDefaultFabloConfig(): FabloConfigJson {
6+
return {
7+
$schema: "https://github.com/hyperledger-labs/fablo/releases/download/2.2.0/schema.json",
8+
global: {
9+
fabricVersion: "2.5.9",
10+
tls: false,
11+
peerDevMode: false,
12+
},
13+
orgs: [
14+
{
15+
organization: {
16+
name: "Orderer",
17+
domain: "orderer.example.com",
18+
mspName: "OrdererMSP",
19+
},
20+
ca: {
21+
prefix: "ca",
22+
db: "sqlite",
23+
},
24+
orderers: [
25+
{
26+
groupName: "group1",
27+
type: "solo",
28+
instances: 1,
29+
prefix: "orderer",
30+
},
31+
],
32+
},
33+
{
34+
organization: {
35+
name: "Org1",
36+
domain: "org1.example.com",
37+
mspName: "Org1MSP",
38+
},
39+
ca: {
40+
prefix: "ca",
41+
db: "sqlite",
42+
},
43+
orderers: [],
44+
peer: {
45+
instances: 2,
46+
db: "LevelDb",
47+
prefix: "peer",
48+
},
49+
},
50+
],
51+
channels: [
52+
{
53+
name: "my-channel1",
54+
orgs: [
55+
{
56+
name: "Org1",
57+
peers: ["peer0", "peer1"],
58+
},
59+
],
60+
},
61+
],
62+
chaincodes: [
63+
{
64+
name: "chaincode1",
65+
version: "0.0.1",
66+
lang: "node",
67+
channel: "my-channel1",
68+
directory: "./chaincodes/chaincode-kv-node",
69+
privateData: [],
70+
},
71+
],
72+
hooks: {},
73+
};
74+
}
575

676
export default class InitGenerator extends Generator {
777
constructor(readonly args: string[], opts: Generator.GeneratorOptions) {
878
super(args, opts);
979
}
1080

1181
async copySampleConfig(): Promise<void> {
12-
let fabloConfigJson = parseFabloConfig(this.fs.read(this.templatePath("fablo-config.json")));
82+
let fabloConfigJson = getDefaultFabloConfig();
1383

1484
const shouldInitWithNodeChaincode = this.args.length && this.args.find((v) => v === "node");
1585
if (shouldInitWithNodeChaincode) {
@@ -48,4 +118,4 @@ export default class InitGenerator extends Generator {
48118
console.log("===========================================================");
49119
});
50120
}
51-
}
121+
}

0 commit comments

Comments
 (0)