hyperledger / fabric-admin-sdk

Hyperledger Fabric admin SDK
Apache License 2.0
31 stars 19 forks source link

How to set SignaturePolicy for Collections #106

Closed 1gezhanghao closed 1 year ago

1gezhanghao commented 1 year ago

// Definition of a chaincode in https://github.com/hyperledger/fabric-admin-sdk/blob/main/pkg/chaincode/lifecycle.go

type Definition struct {
    ChannelName         string
    PackageID           string
    Name                string
    Version             string
    EndorsementPlugin   string
    ValidationPlugin    string
    Sequence            int64
    ValidationParameter []byte
    InitRequired        bool
    Collections         *peer.CollectionConfigPackage
}

it sames SignaturePolicy is in Collections Field, can give a demo for this?

SamYuan1990 commented 1 year ago

you can follow up with our CI https://github.com/hyperledger/fabric-admin-sdk/actions/runs/4211821804/jobs/7310418287 as https://github.com/hyperledger/fabric-admin-sdk/blob/main/test/e2e_test.go#L236 here for demo

1gezhanghao commented 1 year ago

https://github.com/hyperledger/fabric-admin-sdk/blob/main/test/e2e_test.go#L236 in this demo Collections is set to nil, nothing more.How to set a SignaturePolicy in Collections is my question

eg:the SignaturePolicy expression is "AND('Org2MSP.peer','Org1MSP.peer')" , how to set this?

SamYuan1990 commented 1 year ago

ok, could you give me an example with peer cli then I am going to trace with the code.

1gezhanghao commented 1 year ago

you can find the example in https://hyperledger-fabric.readthedocs.io/en/latest/commands/peerlifecycle.html in chapter : peer lifecycle chaincode approveformyorg example

use the cmd like this

peer lifecycle chaincode approveformyorg  -o orderer.example.com:7050 --tls --cafile $ORDERER_CA --channelID mychannel --name mycc --version 1.0 --init-required --package-id myccv1:a7ca45a7cc85f1d89c905b775920361ed089a364e12a9b6d55ba75c965ddd6a9 --sequence 1 --signature-policy "AND ('Org1MSP.peer','Org2MSP.peer')"
SamYuan1990 commented 1 year ago

I made a sample as https://github.com/hyperledger/fabric-admin-sdk/pull/108

SamYuan1990 commented 1 year ago

@1gezhanghao we just have a PR to fix this issue, would you like to have a try?