Skip to content

Commit

Permalink
Merge pull request #125 from hyperledger-labs/f-initfpc
Browse files Browse the repository at this point in the history
init FPC token chaincode
  • Loading branch information
adecaro committed Oct 23, 2021
2 parents 33cacbc + 94440e8 commit 4f12dcc
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ require (
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3 // indirect
github.com/google/addlicense v1.0.0 // indirect
github.com/gordonklaus/ineffassign v0.0.0-20210914165742-4cc7213b9bc8 // indirect
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211022125455-3c72131a3c4d
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211023062436-326ec80b626e
github.com/hyperledger/fabric v1.4.0-rc1.0.20210722174351-9815a7a8f0f7
github.com/hyperledger/fabric-chaincode-go v0.0.0-20210718160520-38d29fabecb9
github.com/hyperledger/fabric-protos-go v0.0.0-20210911123859-041d13f0980c
Expand All @@ -33,5 +33,6 @@ require (
github.com/stretchr/testify v1.7.1-0.20210116013205-6990a05d54c2
github.com/tedsuo/ifrit v0.0.0-20191009134036-9a97d0632f00
go.uber.org/atomic v1.7.0
golang.org/x/sys v0.0.0-20211022215931-8e5104632af7 // indirect
gopkg.in/yaml.v2 v2.4.0
)
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -572,8 +572,8 @@ github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpO
github.com/huin/goupnp v1.0.0 h1:wg75sLpL6DZqwHQN6E1Cfk6mtfzS45z8OV+ic+DtHRo=
github.com/huin/goupnp v1.0.0/go.mod h1:n9v9KO1tAxYH82qOn+UTIFQDmx5n1Zxd/ClZDMX7Bnc=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211022125455-3c72131a3c4d h1:bA2WeOpFoZJTHLIpqnEuUuEJ/Hw3G6IpHICCR2WV63U=
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211022125455-3c72131a3c4d/go.mod h1:iGRusTQNJMc3GhHDpI1uaQRMqt61ZVDEOGjWteVJh8c=
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211023062436-326ec80b626e h1:9q5c65Ot9R5e8i/X/T4YLo8FmGFZCHrAKXpXvnMH4J8=
github.com/hyperledger-labs/fabric-smart-client v0.0.0-20211023062436-326ec80b626e/go.mod h1:iGRusTQNJMc3GhHDpI1uaQRMqt61ZVDEOGjWteVJh8c=
github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go v1.2.3-alpha.1 h1:vBvo0PNm82ht7wpBjlYY4ZHxV3YprCfdVd3T4JG9vBw=
github.com/hyperledger-labs/weaver-dlt-interoperability/common/protos-go v1.2.3-alpha.1/go.mod h1:POCGO/RK9YDfgdhuyqjoD9tRNtWfK7Rh5AYYmsb1Chc=
github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-sdk v1.2.3-alpha.1.0.20210812140206-37f430515b8c h1:pKr8VnHlduEgdInwLWykYAw+lpUizjQJaJ8I5fVoRUo=
Expand Down Expand Up @@ -1480,6 +1480,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985 h1:LOlKVhfDyahgmqa97awczplwkjzNaELFg3zRIJ13RYo=
golang.org/x/sys v0.0.0-20211020174200-9d6173849985/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20211022215931-8e5104632af7 h1:e2q1CMOFXDvurT2sa2yhJAkuA2n8Rd9tMDd7Tcfvs6M=
golang.org/x/sys v0.0.0-20211022215931-8e5104632af7/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 h1:v+OssWQX+hTHEmOBgwxdZxK4zHq3yOs8F9J7mk0PY8E=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
29 changes: 23 additions & 6 deletions integration/nwo/token/platform.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"github.com/alecthomas/template"
api2 "github.com/hyperledger-labs/fabric-smart-client/integration/nwo/api"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/flogging"
"github.com/hyperledger-labs/fabric-smart-client/platform/view/services/hash"
"github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
. "github.com/onsi/gomega/gexec"
Expand All @@ -46,6 +47,7 @@ type Builder interface {

type FabricNetwork interface {
DeployChaincode(chaincode *topology.ChannelChaincode)
InvokeChaincode(cc *topology.ChannelChaincode, method string, args ...[]byte) []byte
DefaultIdemixOrgMSPDir() string
Topology() *topology.Topology
PeerChaincodeAddress(peerName string) string
Expand Down Expand Up @@ -161,8 +163,7 @@ func (p *Platform) Members() []grouper.Member {
}

func (p *Platform) PostRun() {
// Install Token Chaincodes
p.DeployTokenChaincodes()
p.SetupTokenChaincodes()
}

func (p *Platform) Cleanup() {
Expand Down Expand Up @@ -218,10 +219,20 @@ func (p *Platform) GenerateCryptoMaterial(node *sfcnode.Node) {
}
}

func (p *Platform) DeployTokenChaincodes() {
// for _, tcc := range p.TCCs {
// p.Fabric(tcc.TMS).DeployChaincode(tcc.Chaincode)
// }
func (p *Platform) SetupTokenChaincodes() {
// For FPCs, we need to initialize the public parameters explicitly
for _, cc := range p.TCCs {
if cc.Chaincode.Private {
pp := p.PublicParameters(cc.TMS)
logger.Infof("Init FPC Token Chaincode [%s:%s:%s][%s]",
cc.TMS.Network, cc.TMS.Channel, cc.TMS.Namespace, hash.Hashable(pp).String())
p.Fabric(cc.TMS).InvokeChaincode(
cc.Chaincode,
"init",
pp,
)
}
}
}

func (p *Platform) TokenGen(command common.Command) (*Session, error) {
Expand Down Expand Up @@ -306,6 +317,12 @@ func (p *Platform) PublicParametersFile(tms *TMS) string {
)
}

func (p *Platform) PublicParameters(tms *TMS) []byte {
raw, err := ioutil.ReadFile(p.PublicParametersFile(tms))
Expect(err).ToNot(HaveOccurred())
return raw
}

func (p *Platform) nextColor() string {
color := p.colorIndex%14 + 31
if color > 37 {
Expand Down

0 comments on commit 4f12dcc

Please sign in to comment.