Skip to content

Commit

Permalink
Fix packageID for chaincode approval
Browse files Browse the repository at this point in the history
Signed-off-by: Nicko Guyer <nicko.guyer@kaleido.io>
  • Loading branch information
nguyer committed Mar 17, 2022
1 parent 75895b5 commit 1b173ac
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions internal/blockchain/fabric/fabric_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,11 +447,22 @@ func (p *FabricProvider) DeployContract(filename, contractName string, member ty
if err != nil {
return "", err
}
if len(res.InstalledChaincodes) == 0 {

chaincodeInstalled := false
packageID := ""
for _, installedChaincode := range res.InstalledChaincodes {
if installedChaincode.Label == chaincode {
chaincodeInstalled = true
packageID = installedChaincode.PackageID
break
}
}

if !chaincodeInstalled {
return "", fmt.Errorf("failed to find installed chaincode")
}

if err := p.approveChaincode(channel, chaincode, version, res.InstalledChaincodes[0].PackageID); err != nil {
if err := p.approveChaincode(channel, chaincode, version, packageID); err != nil {
return "", err
}

Expand Down

0 comments on commit 1b173ac

Please sign in to comment.