-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from knarayan/sdkrelay
Sdkrelay
- Loading branch information
Showing
22 changed files
with
1,351 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"network1": { | ||
"connProfilePath": "<PATH-TO-WEAVER>/tests/network-setups/fabric/shared/network1/peerOrganizations/org1.network1.com/connection-org1.yaml", | ||
"relayEndpoint": "localhost:9080", | ||
"mspId": "Org1MSP", | ||
"channelName": "mychannel", | ||
"chaincode": "simpleasset" | ||
}, | ||
"network2": { | ||
"connProfilePath": "<PATH-TO-WEAVER>/tests/network-setups/fabric/shared/network2/peerOrganizations/org1.network2.com/connection-org1.yaml", | ||
"relayEndpoint": "localhost:9083", | ||
"mspId": "Org1MSP", | ||
"channelName": "mychannel", | ||
"chaincode": "simpleasset" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/* | ||
Copyright 2020 IBM All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package configure | ||
|
||
import ( | ||
"errors" | ||
"fmt" | ||
|
||
"github.com/cloudflare/cfssl/log" | ||
"github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-cli/helpers" | ||
"github.com/hyperledger-labs/weaver-dlt-interoperability/sdks/fabric/go-cli/helpers/interopsetup" | ||
) | ||
|
||
// helper functions to log and return errors | ||
func logThenErrorf(format string, args ...interface{}) error { | ||
errorMsg := fmt.Sprintf(format, args...) | ||
log.Error(errorMsg) | ||
return errors.New(errorMsg) | ||
} | ||
|
||
type NetworkConfig struct { | ||
RelayEndPoint string `json:"relayEndPoint"` | ||
ConnProfilePath string `json:"connProfilePath"` | ||
Username string `json:"username"` | ||
MspId string `json:"mspId"` | ||
ChannelName string `json:"channelName"` | ||
Chaincode string `json:"chaincode"` | ||
} | ||
|
||
func ConfigureAll(networkId string) error { | ||
|
||
networkConfig, err := helpers.GetNetworkConfig(networkId) | ||
if err != nil { | ||
return logThenErrorf(err.Error()) | ||
} | ||
connProfilePath := networkConfig.ConnProfilePath | ||
|
||
if connProfilePath != "" { | ||
logThenErrorf("please use a valid network, no valid environment found for %s", networkId) | ||
} | ||
|
||
username := "User1@org1." + networkId + ".com" | ||
log.Infof("generating membership for network: %s", networkId) | ||
|
||
// 1. Generate network configs (membership, access control and verification policy) | ||
|
||
helpers.GenerateMembership("mychannel", "interop", connProfilePath, networkId, "Org1MSP", username) | ||
helpers.GenerateAccessControl("mychannel", "interop", connProfilePath, networkId, "data/interop/accessControlTemplate.json", "Org1MSP", username) | ||
helpers.GenerateVerificationPolicy("mychannel", "interop", connProfilePath, networkId, "data/interop/verificationPolicyTemplate.json", "Org1MSP", username) | ||
|
||
log.Info("generated network maps for networks") | ||
|
||
// 2. Add default data | ||
networkEnv, err := helpers.GetNetworkConfig(networkId) | ||
if err != nil { | ||
return logThenErrorf("failure of helpers.GetNetworkConfig for network %s with error: %s", networkId, err.Error()) | ||
} | ||
connProfilePath = networkEnv.ConnProfilePath | ||
if connProfilePath == "" { | ||
logThenErrorf("please use a valid --local-network, no valid environment found for network %s", networkId) | ||
} | ||
log.Info("populating %s chaincode with data") | ||
|
||
query := helpers.QueryType{ | ||
ContractName: "simplestate", | ||
Channel: "mychannel", | ||
CcFunc: "Create", | ||
Args: []string{}, | ||
} | ||
if networkId == "network1" { | ||
helpers.AddData("stars.json", connProfilePath, networkId, query, "Org1MSP") | ||
} else if networkId == "network2" { | ||
helpers.AddData("starSize.json", connProfilePath, networkId, query, "Org1MSP") | ||
} | ||
|
||
// 3. Load configs from other networks in the credentials folder | ||
log.Infof("loading chaincode for network: %s and connection profile path: %s", networkId, connProfilePath) | ||
|
||
interopsetup.ConfigureNetwork(networkId) | ||
|
||
return nil | ||
} |
11 changes: 11 additions & 0 deletions
11
sdks/fabric/go-cli/data/interop/accessControlTemplate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"securityDomain": "", | ||
"rules": [ | ||
{ | ||
"principal": "<mspid>", | ||
"principalType": "ca", | ||
"resource": "mychannel:simplestate:Read:*", | ||
"read": true | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
sdks/fabric/go-cli/data/interop/verificationPolicyTemplate.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"securityDomain": "<network-id>", | ||
"identifiers": [ | ||
{ | ||
"pattern": "mychannel:simplestate:Read:*", | ||
"policy": { | ||
"type": "Signature", | ||
"criteria": [] | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"Arcturus": "17.671", | ||
"Betelgeuse": "617.1", | ||
"Canopus": "49.395", | ||
"Deneb": "141.23", | ||
"Electra": "4.2159", | ||
"Furud": "2.713", | ||
"Giausar": "27.065", | ||
"Hadar": "5.983", | ||
"IZAR": "18.412", | ||
"Jabbah": "6.033", | ||
"Kuma": "1.386", | ||
"Lesath": "4.244", | ||
"Maia": "4.202", | ||
"Naos": "9.74", | ||
"Omicron1 Eridani": "2.5741", | ||
"Peacock": "3.3602", | ||
"Rotanev": "2.752", | ||
"Sadalsuud": "34.8", | ||
"Talitha": "1.288", | ||
"UNUKALHAI": "8.3484", | ||
"VEGA": "1.6432", | ||
"Wasat": "1.649", | ||
"Xamidimura": "4.774", | ||
"Yildun": "1.948", | ||
"Zosma": "1.4888" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"a": "Arcturus", | ||
"b": "Betelgeuse", | ||
"c": "Canopus", | ||
"d": "Deneb", | ||
"e": "Electra", | ||
"f": "Furud", | ||
"g": "Giausar", | ||
"h": "Hadar", | ||
"i": "IZAR", | ||
"j": "Jabbah", | ||
"k": "Kuma", | ||
"l": "Lesath", | ||
"m": "Maia", | ||
"n": "Naos", | ||
"o": "Omicron1 Eridani", | ||
"p": "Peacock", | ||
"q": "No star with letter q", | ||
"r": "Rotanev", | ||
"s": "Sadalsuud", | ||
"t": "Talitha", | ||
"u": "UNUKALHAI", | ||
"v": "VEGA", | ||
"w": "Wasat", | ||
"x": "Xamidimura", | ||
"y": "Yildun", | ||
"z": "Zosma" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.