Skip to content

Commit e6908ff

Browse files
committed
resolved errors from git pull
Signed-off-by: Claudia Emmanuel <emmanuel.claudia@gmail.com>
2 parents ba09668 + ec39b85 commit e6908ff

File tree

5 files changed

+101
-1
lines changed

5 files changed

+101
-1
lines changed

extension.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,12 @@ function activate(context) {
257257
treeItem.label
258258
);
259259

260+
if (descItem) {
261+
treeViewProviderDesc.setActiveNetwork(descItem);
262+
}
263+
if (fabricItem) {
264+
treeViewProviderFabric.setActiveNetwork(fabricItem);
265+
}
260266
if (descItem) {
261267
treeViewProviderDesc.setActiveNetwork(descItem);
262268
}

package-lock.json

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,13 @@
255255
]
256256
},
257257
"dependencies": {
258+
258259
"@hyperledger/fabric-protos": "^0.2.2",
259260
"@vscode/debugadapter": "^1.68.0",
260261
"dotenv": "^16.4.5",
262+
263+
"@hyperledger/fabric-gateway": "^1.7.0",
264+
261265
"fabric-ca-client": "^2.2.20",
262266
"fabric-network": "^2.2.20",
263267
"fabric-protos": "^2.2.20",
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "fabric-network",
3+
"version": "1.0.0",
4+
"client": {
5+
"organization": "Org1",
6+
"connection": {
7+
"timeout": {
8+
"peer": "300"
9+
}
10+
}
11+
},
12+
"channels": {
13+
"mychannel": {
14+
"orderers": [
15+
{
16+
"url": "grpcs://localhost:7050"
17+
}
18+
],
19+
"peers": {
20+
"peer0.org1.example.com": {
21+
"url": "grpcs://localhost:7051"
22+
}
23+
}
24+
}
25+
},
26+
"organizations": {
27+
"Org1": {
28+
"mspid": "Org1MSP",
29+
"peerNames": ["peer0.org1.example.com"],
30+
"certificateAuthorities": ["ca.org1.example.com"]
31+
}
32+
},
33+
"orderers": [
34+
{
35+
"url": "grpcs://localhost:7050"
36+
}
37+
],
38+
"peers": {
39+
"peer0.org1.example.com": {
40+
"url": "grpcs://localhost:7051"
41+
}
42+
}
43+
}

src/invokechaincode/invoke.js

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
const { Gateway, Wallets } = require('fabric-network');
2+
const FabricCAServices = require('fabric-ca-client');
3+
const path = require('path');
4+
const fs = require('fs');
5+
const { log } = require('console');
6+
7+
async function invokeChaincode(functionName, args, context) {
8+
try {
9+
10+
const ccpPath = path.resolve(__dirname, 'connection-profile.json');
11+
const ccp = JSON.parse(fs.readFileSync(ccpPath, 'utf8'));
12+
const wallet = await Wallets.newFileSystemWallet(path.join(process.cwd(), 'wallet'));
13+
const gateway = new Gateway();
14+
await gateway.connect(ccp, {
15+
wallet,
16+
identity: 'admin',
17+
discovery: { enabled: true, asLocalhost: true }
18+
});
19+
20+
21+
const network = await gateway.getNetwork('mychannel');
22+
const contract = network.getContract('mychaincode');
23+
24+
const result = await contract.submitTransaction('CreateAsset', 'asset1', '100');
25+
console.log(`Chaincode invoked successfully. Result: ${result.toString()}`);
26+
27+
28+
await gateway.disconnect();
29+
30+
return result.toString();
31+
} catch (error) {
32+
console.error(`Failed to invoke chaincode: ${error.message}`);
33+
throw new Error(`Failed to invoke chaincode: ${error.message}`);
34+
}
35+
}
36+
37+
38+
invokeChaincode();

0 commit comments

Comments
 (0)