diff --git a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/go.mod b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/go.mod index 83fba2d1..1e3470bc 100644 --- a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/go.mod +++ b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/go.mod @@ -5,16 +5,20 @@ go 1.23.0 require ( github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0 github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0 + github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 + github.com/stretchr/testify v1.10.0 + google.golang.org/protobuf v1.36.1 ) require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/go-openapi/jsonpointer v0.21.0 // indirect github.com/go-openapi/jsonreference v0.21.0 // indirect github.com/go-openapi/spec v0.21.0 // indirect github.com/go-openapi/swag v0.23.0 // indirect - github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/mailru/easyjson v0.7.7 // indirect + github.com/pmezard/go-difflib v1.0.0 // indirect github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect github.com/xeipuuv/gojsonschema v1.2.0 // indirect @@ -23,6 +27,5 @@ require ( golang.org/x/text v0.17.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect google.golang.org/grpc v1.67.0 // indirect - google.golang.org/protobuf v1.36.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset.go b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset.go index b777b32f..d27f2ad2 100644 --- a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset.go +++ b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset.go @@ -1,18 +1,10 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - */ - package main -// OwnerIdentifier represents the owner of an asset with their organisation MSP ID and user identifier. -// Fields are lowercase to match the TypeScript serialisation format. type OwnerIdentifier struct { Org string `json:"org"` User string `json:"user"` } -// Asset describes the details of an asset stored in the world state. -// Fields are defined in alphabetical order to produce deterministic JSON serialisation. type Asset struct { AppraisedValue int `json:"AppraisedValue"` Color string `json:"Color"` diff --git a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset_transfer.go b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset_transfer.go index 41582693..823715ca 100644 --- a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset_transfer.go +++ b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset_transfer.go @@ -25,7 +25,7 @@ func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface, return err } if exists { - return fmt.Errorf("the asset %s already exists", id) + return fmt.Errorf("The asset %s already exists", id) } ownerID, err := clientIdentifier(ctx, owner) @@ -96,7 +96,7 @@ func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface, return err } if !ok { - return fmt.Errorf("only owner can update assets") + return fmt.Errorf("Only owner can update assets") } // Owner is intentionally preserved; use TransferAsset to change owner. @@ -141,7 +141,7 @@ func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface, return err } if !ok { - return fmt.Errorf("only owner can delete assets") + return fmt.Errorf("Only owner can delete assets") } if err := ctx.GetStub().DelState(id); err != nil { @@ -180,7 +180,7 @@ func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterfac return err } if !ok { - return fmt.Errorf("only owner can transfer assets") + return fmt.Errorf("Only owner can transfer assets") } newOwnerID := OwnerIdentifier{Org: newOwnerOrg, User: newOwner} @@ -241,7 +241,7 @@ func readAsset(ctx contractapi.TransactionContextInterface, id string) ([]byte, return nil, fmt.Errorf("failed to read from world state: %v", err) } if assetBytes == nil { - return nil, fmt.Errorf("sorry, asset %s has not been created", id) + return nil, fmt.Errorf("Sorry, asset %s has not been created", id) } return assetBytes, nil diff --git a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/main.go b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/main.go index 529e27e3..44f3416a 100644 --- a/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/main.go +++ b/full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/main.go @@ -1,7 +1,3 @@ -/* - * SPDX-License-Identifier: Apache-2.0 - */ - package main import (