Skip to content

Commit d16a14f

Browse files
authored
feat(fabric-connector): replace deprecated fabric-tools with new cli (#3955)
Signed-off-by: Carlos Amaro <[email protected]>
1 parent c7d9376 commit d16a14f

File tree

81 files changed

+8563
-2815
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+8563
-2815
lines changed

.cspell.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
"jsrsasign",
119119
"keccak",
120120
"Keychain",
121-
"Keycloak",
121+
"kubaya",
122122
"KEYUTIL",
123123
"KJUR",
124124
"Knetic",
@@ -134,6 +134,7 @@
134134
"miekg",
135135
"mitchellh",
136136
"msal",
137+
"MSPCONFIG",
137138
"MSPCONFIGPATH",
138139
"MSPID",
139140
"Mspids",

examples/cactus-example-carbon-accounting-backend/src/main/resources/core.yaml

Lines changed: 758 additions & 0 deletions
Large diffs are not rendered by default.

examples/cactus-example-carbon-accounting-backend/src/main/typescript/carbon-accounting-app.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,6 @@ export class CarbonAccountingApp {
101101

102102
const xdaiAccount = await this.ledgers.xdai.createEthTestAccount();
103103

104-
const sshConfig = await this.ledgers.fabric.getSshConfig();
105104
const connectionProfile =
106105
await this.ledgers.fabric.getConnectionProfileOrg1();
107106
const enrollAdminOut = await this.ledgers.fabric.enrollAdmin();
@@ -142,12 +141,7 @@ export class CarbonAccountingApp {
142141

143142
const fabricPlugin = new PluginLedgerConnectorFabric({
144143
instanceId: uuidv4(),
145-
dockerBinary: "/usr/local/bin/docker",
146-
peerBinary: "/fabric-samples/bin/peer",
147-
goBinary: "/usr/local/go/bin/go",
148144
pluginRegistry: pluginRegistry,
149-
cliContainerEnv: this.ledgers.org1Env,
150-
sshConfig,
151145
connectionProfile,
152146
logLevel: this.options.logLevel || "INFO",
153147
discoveryOptions: {
@@ -158,6 +152,7 @@ export class CarbonAccountingApp {
158152
strategy: DefaultEventHandlerStrategy.NetworkScopeAllfortx,
159153
commitTimeout: 300,
160154
},
155+
dockerNetworkName: this.ledgers.fabric.getNetworkName(),
161156
});
162157

163158
const xdaiPlugin = new PluginLedgerConnectorXdai({

examples/cactus-example-carbon-accounting-backend/src/main/typescript/infrastructure/carbon-accounting-app-dummy-infrastructure.ts

Lines changed: 33 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import TimelockContract from "../../json/generated/src/main/solidity/net-emissio
2424
import NetEmissionsTokenNetworkContract from "../../json/generated/src/main/solidity/net-emissions-token-network/NetEmissionsTokenNetwork.sol/NetEmissionsTokenNetwork.json";
2525
import {
2626
ChainCodeProgrammingLanguage,
27-
DeploymentTargetOrgFabric2x,
2827
FileBase64,
2928
PluginLedgerConnectorFabric,
3029
} from "@hyperledger/cactus-plugin-ledger-connector-fabric";
@@ -72,43 +71,6 @@ export class CarbonAccountingAppDummyInfrastructure {
7271
return CarbonAccountingAppDummyInfrastructure.FABRIC_2_AIO_CLI_CFG_DIR;
7372
}
7473

75-
public get org1Env(): NodeJS.ProcessEnv & DeploymentTargetOrgFabric2x {
76-
return {
77-
CORE_LOGGING_LEVEL: "debug",
78-
FABRIC_LOGGING_SPEC: "debug",
79-
CORE_PEER_LOCALMSPID: "Org1MSP",
80-
81-
ORDERER_CA: `${this.orgCfgDir}ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem`,
82-
83-
FABRIC_CFG_PATH: "/etc/hyperledger/fabric",
84-
CORE_PEER_TLS_ENABLED: "true",
85-
CORE_PEER_TLS_ROOTCERT_FILE: `${this.orgCfgDir}peerOrganizations/org1.example.com/peers/peer0.org1.example.com/tls/ca.crt`,
86-
CORE_PEER_MSPCONFIGPATH: `${this.orgCfgDir}peerOrganizations/org1.example.com/users/[email protected]/msp`,
87-
CORE_PEER_ADDRESS: "peer0.org1.example.com:7051",
88-
ORDERER_TLS_ROOTCERT_FILE: `${this.orgCfgDir}ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem`,
89-
};
90-
}
91-
92-
public get org2Env(): NodeJS.ProcessEnv & DeploymentTargetOrgFabric2x {
93-
const orgCfgDir =
94-
CarbonAccountingAppDummyInfrastructure.FABRIC_2_AIO_CLI_CFG_DIR;
95-
96-
return {
97-
CORE_LOGGING_LEVEL: "debug",
98-
FABRIC_LOGGING_SPEC: "debug",
99-
CORE_PEER_LOCALMSPID: "Org2MSP",
100-
101-
FABRIC_CFG_PATH: "/etc/hyperledger/fabric",
102-
CORE_PEER_TLS_ENABLED: "true",
103-
ORDERER_CA: `${orgCfgDir}ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem`,
104-
105-
CORE_PEER_ADDRESS: "peer0.org2.example.com:9051",
106-
CORE_PEER_MSPCONFIGPATH: `${orgCfgDir}peerOrganizations/org2.example.com/users/[email protected]/msp`,
107-
CORE_PEER_TLS_ROOTCERT_FILE: `${orgCfgDir}peerOrganizations/org2.example.com/peers/peer0.org2.example.com/tls/ca.crt`,
108-
ORDERER_TLS_ROOTCERT_FILE: `${orgCfgDir}ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem`,
109-
};
110-
}
111-
11274
constructor(
11375
public readonly options: ICarbonAccountingAppDummyInfrastructureOptions,
11476
) {
@@ -333,19 +295,51 @@ export class CarbonAccountingAppDummyInfrastructure {
333295
});
334296
}
335297

298+
const peer0Org1Certs = await this.fabric.getPeerOrgCertsAndConfig(
299+
"org1",
300+
"peer0",
301+
);
302+
const peer0Org2Certs = await this.fabric.getPeerOrgCertsAndConfig(
303+
"org2",
304+
"peer0",
305+
);
306+
307+
const filePath = path.join(__dirname, "../../yaml/resources/core.yaml");
308+
const buffer = await fs.readFile(filePath);
309+
const coreFile = {
310+
body: buffer.toString("base64"),
311+
filename: "core.yaml",
312+
};
313+
336314
const res = await fabricPlugin.deployContract({
337315
channelId,
338316
ccVersion,
339317
sourceFiles,
340318
ccName,
341-
targetOrganizations: [this.org1Env, this.org2Env],
319+
targetOrganizations: [
320+
{
321+
CORE_PEER_LOCALMSPID: "Org1MSP",
322+
CORE_PEER_ADDRESS: "peer0.org1.example.com:7051",
323+
CORE_PEER_MSPCONFIG: peer0Org1Certs.mspConfig,
324+
CORE_PEER_TLS_ROOTCERT: peer0Org1Certs.peerTlsCert,
325+
ORDERER_TLS_ROOTCERT: peer0Org1Certs.ordererTlsRootCert,
326+
},
327+
{
328+
CORE_PEER_LOCALMSPID: "Org2MSP",
329+
CORE_PEER_ADDRESS: "peer0.org2.example.com:9051",
330+
CORE_PEER_MSPCONFIG: peer0Org2Certs.mspConfig,
331+
CORE_PEER_TLS_ROOTCERT: peer0Org2Certs.peerTlsCert,
332+
ORDERER_TLS_ROOTCERT: peer0Org2Certs.ordererTlsRootCert,
333+
},
334+
],
342335
caFile: `${this.orgCfgDir}ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem`,
343336
ccLabel,
344337
ccLang: ChainCodeProgrammingLanguage.Typescript,
345338
ccSequence: 1,
346339
orderer: "orderer.example.com:7050",
347340
ordererTLSHostnameOverride: "orderer.example.com",
348341
connTimeout: 60,
342+
coreYamlFile: coreFile,
349343
});
350344

351345
const { packageIds, success } = res;

examples/cactus-example-cbdc-bridging-backend/src/main/typescript/infrastructure/cbdc-bridging-app-dummy-infrastructure.ts

Lines changed: 88 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ export class CbdcBridgingAppDummyInfrastructure {
154154
organization: "org2",
155155
});
156156

157-
const sshConfig = await this.fabric.getSshConfig();
158-
159157
const keychainEntryKey1 = "userA";
160158
const keychainEntryValue1 = JSON.stringify(userIdentity1);
161159

@@ -181,12 +179,7 @@ export class CbdcBridgingAppDummyInfrastructure {
181179
this.log.info(`Creating Fabric Connector...`);
182180
return new PluginLedgerConnectorFabric({
183181
instanceId: uuidv4(),
184-
dockerBinary: "/usr/local/bin/docker",
185-
peerBinary: "/fabric-samples/bin/peer",
186-
goBinary: "/usr/local/go/bin/go",
187182
pluginRegistry,
188-
cliContainerEnv: this.org1Env,
189-
sshConfig,
190183
connectionProfile: connectionProfileOrg1,
191184
logLevel: this.options.logLevel || "INFO",
192185
discoveryOptions: {
@@ -197,6 +190,7 @@ export class CbdcBridgingAppDummyInfrastructure {
197190
strategy: DefaultEventHandlerStrategy.NetworkScopeAllfortx,
198191
commitTimeout: 300,
199192
},
193+
dockerNetworkName: this.fabric.getNetworkName(),
200194
});
201195
}
202196

@@ -375,30 +369,59 @@ export class CbdcBridgingAppDummyInfrastructure {
375369
});
376370
}
377371

372+
const peer0Org1Certs = await this.fabric.getPeerOrgCertsAndConfig(
373+
"org1",
374+
"peer0",
375+
);
376+
const peer0Org2Certs = await this.fabric.getPeerOrgCertsAndConfig(
377+
"org2",
378+
"peer0",
379+
);
380+
381+
const filePath = path.join(__dirname, "../../yaml/resources/core.yaml");
382+
const buffer = await fs.readFile(filePath);
383+
const coreFile = {
384+
body: buffer.toString("base64"),
385+
filename: "core.yaml",
386+
};
387+
378388
let retries = 0;
379389
while (retries <= 5) {
380390
await fabricApiClient
381-
.deployContractV1(
382-
{
383-
channelId,
384-
ccVersion: "1.0.0",
385-
sourceFiles,
386-
ccName: contractName,
387-
targetOrganizations: [this.org1Env, this.org2Env],
388-
caFile:
389-
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.ORDERER_TLS_ROOTCERT_FILE,
390-
ccLabel: "asset-reference-contract",
391-
ccLang: ChainCodeProgrammingLanguage.Typescript,
392-
ccSequence: 1,
393-
orderer: "orderer.example.com:7050",
394-
ordererTLSHostnameOverride: "orderer.example.com",
395-
connTimeout: 120,
396-
},
397-
{
398-
maxContentLength: Infinity,
399-
maxBodyLength: Infinity,
400-
},
401-
)
391+
.deployContractV1({
392+
channelId,
393+
ccVersion: "1.0.0",
394+
sourceFiles,
395+
ccName: contractName,
396+
targetOrganizations: [
397+
{
398+
CORE_PEER_LOCALMSPID:
399+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_LOCALMSPID,
400+
CORE_PEER_ADDRESS:
401+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_ADDRESS,
402+
CORE_PEER_MSPCONFIG: peer0Org1Certs.mspConfig,
403+
CORE_PEER_TLS_ROOTCERT: peer0Org1Certs.peerTlsCert,
404+
ORDERER_TLS_ROOTCERT: peer0Org1Certs.ordererTlsRootCert,
405+
},
406+
{
407+
CORE_PEER_LOCALMSPID:
408+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2.CORE_PEER_LOCALMSPID,
409+
CORE_PEER_ADDRESS:
410+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2.CORE_PEER_ADDRESS,
411+
CORE_PEER_MSPCONFIG: peer0Org2Certs.mspConfig,
412+
CORE_PEER_TLS_ROOTCERT: peer0Org2Certs.peerTlsCert,
413+
ORDERER_TLS_ROOTCERT: peer0Org2Certs.ordererTlsRootCert,
414+
},
415+
],
416+
caFile: peer0Org1Certs.ordererTlsRootCert,
417+
ccLabel: "basic-asset-transfer-2",
418+
ccLang: ChainCodeProgrammingLanguage.Typescript,
419+
ccSequence: 1,
420+
orderer: "orderer.example.com:7050",
421+
ordererTLSHostnameOverride: "orderer.example.com",
422+
connTimeout: 60,
423+
coreYamlFile: coreFile,
424+
})
402425
.then(async (res: { data: { packageIds: any; lifecycle: any } }) => {
403426
retries = 6;
404427

@@ -503,6 +526,22 @@ export class CbdcBridgingAppDummyInfrastructure {
503526
});
504527
}
505528

529+
const peer0Org1Certs = await this.fabric.getPeerOrgCertsAndConfig(
530+
"org1",
531+
"peer0",
532+
);
533+
const peer0Org2Certs = await this.fabric.getPeerOrgCertsAndConfig(
534+
"org2",
535+
"peer0",
536+
);
537+
538+
const filePath = path.join(__dirname, "../../yaml/resources/core.yaml");
539+
const buffer = await fs.readFile(filePath);
540+
const coreFile = {
541+
body: buffer.toString("base64"),
542+
filename: "core.yaml",
543+
};
544+
506545
let retries = 0;
507546
while (retries <= 5) {
508547
await fabricApiClient
@@ -512,7 +551,26 @@ export class CbdcBridgingAppDummyInfrastructure {
512551
ccVersion: "1.0.0",
513552
sourceFiles,
514553
ccName: contractName,
515-
targetOrganizations: [this.org1Env, this.org2Env],
554+
targetOrganizations: [
555+
{
556+
CORE_PEER_LOCALMSPID:
557+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_LOCALMSPID,
558+
CORE_PEER_ADDRESS:
559+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.CORE_PEER_ADDRESS,
560+
CORE_PEER_MSPCONFIG: peer0Org1Certs.mspConfig,
561+
CORE_PEER_TLS_ROOTCERT: peer0Org1Certs.peerTlsCert,
562+
ORDERER_TLS_ROOTCERT: peer0Org1Certs.ordererTlsRootCert,
563+
},
564+
{
565+
CORE_PEER_LOCALMSPID:
566+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2.CORE_PEER_LOCALMSPID,
567+
CORE_PEER_ADDRESS:
568+
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_2.CORE_PEER_ADDRESS,
569+
CORE_PEER_MSPCONFIG: peer0Org2Certs.mspConfig,
570+
CORE_PEER_TLS_ROOTCERT: peer0Org2Certs.peerTlsCert,
571+
ORDERER_TLS_ROOTCERT: peer0Org2Certs.ordererTlsRootCert,
572+
},
573+
],
516574
caFile:
517575
FABRIC_25_LTS_FABRIC_SAMPLES_ENV_INFO_ORG_1.ORDERER_TLS_ROOTCERT_FILE,
518576
ccLabel: "cbdc",
@@ -521,6 +579,7 @@ export class CbdcBridgingAppDummyInfrastructure {
521579
orderer: "orderer.example.com:7050",
522580
ordererTLSHostnameOverride: "orderer.example.com",
523581
connTimeout: 120,
582+
coreYamlFile: coreFile,
524583
},
525584
{
526585
maxContentLength: Infinity,

0 commit comments

Comments
 (0)