mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-17 07:25:10 +00:00
Rename IssueAsset to CreateAsset
- Move go chaincode to chaincode-go subdirectory - Add public description argument to CreateAsset() Signed-off-by: Tiffany Harris <tiffany.harris@ibm.com>
This commit is contained in:
parent
82eaaad954
commit
f1775d7fdc
9 changed files with 6 additions and 7 deletions
|
|
@ -118,7 +118,7 @@ Now that we can operate as both organizations, we need install the private asset
|
|||
|
||||
Open the Org1 terminal. Run the following command to package the private asset transfer chaincode:
|
||||
```
|
||||
peer lifecycle chaincode package assets_transfer.tar.gz --path ../asset-transfer-secured-agreement --lang golang --label assets_transfer_1
|
||||
peer lifecycle chaincode package assets_transfer.tar.gz --path ../asset-transfer-secured-agreement/chaincode-go --lang golang --label assets_transfer_1
|
||||
```
|
||||
|
||||
The command creates a chaincode package named `assets_transfer.tar.gz`. We can now install this package on the Org1 peer:
|
||||
|
|
@ -180,7 +180,7 @@ export asset_PROPERTIES=$(echo -n "{\"object_type\":\"asset_properties\",\"asset
|
|||
```
|
||||
We can now use the following command to create a asset that belongs to Org1:
|
||||
```
|
||||
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n assets_transfer -c '{"function":"IssueAsset","Args":["asset1"]}' --transient "{\"asset_properties\":\"$asset_PROPERTIES\"}"
|
||||
peer chaincode invoke -o localhost:7050 --ordererTLSHostnameOverride orderer.example.com --tls --cafile ${PWD}/organizations/ordererOrganizations/example.com/orderers/orderer.example.com/msp/tlscacerts/tlsca.example.com-cert.pem -C mychannel -n assets_transfer -c '{"function":"CreateAsset","Args":["asset1", "A new asset for Org1MSP"]}' --transient "{\"asset_properties\":\"$asset_PROPERTIES\"}"
|
||||
```
|
||||
|
||||
We can can query the Org1 implicit data collection to see the asset that was created:
|
||||
|
|
@ -55,8 +55,8 @@ type receipt struct {
|
|||
timestamp time.Time
|
||||
}
|
||||
|
||||
// IssueAsset creates a asset and sets it as owned by the client's org
|
||||
func (s *SmartContract) IssueAsset(ctx contractapi.TransactionContextInterface, assetID string) error {
|
||||
// CreateAsset creates a asset and sets it as owned by the client's org
|
||||
func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, assetID, publicDescription string) error {
|
||||
|
||||
transMap, err := ctx.GetStub().GetTransient()
|
||||
if err != nil {
|
||||
|
|
@ -76,13 +76,12 @@ func (s *SmartContract) IssueAsset(ctx contractapi.TransactionContextInterface,
|
|||
return fmt.Errorf("failed to get verified OrgID: %s", err.Error())
|
||||
}
|
||||
|
||||
// Create and persit asset
|
||||
|
||||
// Create and persist asset
|
||||
asset := Asset{
|
||||
ObjectType: "asset",
|
||||
ID: assetID,
|
||||
OwnerOrg: clientOrgID,
|
||||
PublicDescription: "A new asset for " + clientOrgID,
|
||||
PublicDescription: publicDescription,
|
||||
}
|
||||
|
||||
assetJSON, err := json.Marshal(asset)
|
||||
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 198 KiB |
|
Before Width: | Height: | Size: 238 KiB After Width: | Height: | Size: 238 KiB |
|
Before Width: | Height: | Size: 239 KiB After Width: | Height: | Size: 239 KiB |
Loading…
Reference in a new issue