Skip to content

Commit 60894c9

Browse files
committed
corrected some logs based on the typescript implementation
1 parent 992baff commit 60894c9

File tree

4 files changed

+10
-19
lines changed

4 files changed

+10
-19
lines changed

full-stack-asset-transfer-guide/contracts/asset-transfer-go/go.mod

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@ go 1.23.0
55
require (
66
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0
77
github.com/hyperledger/fabric-contract-api-go/v2 v2.2.0
8+
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4
9+
github.com/stretchr/testify v1.10.0
10+
google.golang.org/protobuf v1.36.1
811
)
912

1013
require (
14+
github.com/davecgh/go-spew v1.1.1 // indirect
1115
github.com/go-openapi/jsonpointer v0.21.0 // indirect
1216
github.com/go-openapi/jsonreference v0.21.0 // indirect
1317
github.com/go-openapi/spec v0.21.0 // indirect
1418
github.com/go-openapi/swag v0.23.0 // indirect
15-
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.4 // indirect
1619
github.com/josharian/intern v1.0.0 // indirect
1720
github.com/mailru/easyjson v0.7.7 // indirect
21+
github.com/pmezard/go-difflib v1.0.0 // indirect
1822
github.com/xeipuuv/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
1923
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
2024
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
@@ -23,6 +27,5 @@ require (
2327
golang.org/x/text v0.17.0 // indirect
2428
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
2529
google.golang.org/grpc v1.67.0 // indirect
26-
google.golang.org/protobuf v1.36.1 // indirect
2730
gopkg.in/yaml.v3 v3.0.1 // indirect
2831
)

full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,10 @@
1-
/*
2-
* SPDX-License-Identifier: Apache-2.0
3-
*/
4-
51
package main
62

7-
// OwnerIdentifier represents the owner of an asset with their organisation MSP ID and user identifier.
8-
// Fields are lowercase to match the TypeScript serialisation format.
93
type OwnerIdentifier struct {
104
Org string `json:"org"`
115
User string `json:"user"`
126
}
137

14-
// Asset describes the details of an asset stored in the world state.
15-
// Fields are defined in alphabetical order to produce deterministic JSON serialisation.
168
type Asset struct {
179
AppraisedValue int `json:"AppraisedValue"`
1810
Color string `json:"Color"`

full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/asset_transfer.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface,
2525
return err
2626
}
2727
if exists {
28-
return fmt.Errorf("the asset %s already exists", id)
28+
return fmt.Errorf("The asset %s already exists", id)
2929
}
3030

3131
ownerID, err := clientIdentifier(ctx, owner)
@@ -96,7 +96,7 @@ func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface,
9696
return err
9797
}
9898
if !ok {
99-
return fmt.Errorf("only owner can update assets")
99+
return fmt.Errorf("Only owner can update assets")
100100
}
101101

102102
// Owner is intentionally preserved; use TransferAsset to change owner.
@@ -141,7 +141,7 @@ func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface,
141141
return err
142142
}
143143
if !ok {
144-
return fmt.Errorf("only owner can delete assets")
144+
return fmt.Errorf("Only owner can delete assets")
145145
}
146146

147147
if err := ctx.GetStub().DelState(id); err != nil {
@@ -180,7 +180,7 @@ func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterfac
180180
return err
181181
}
182182
if !ok {
183-
return fmt.Errorf("only owner can transfer assets")
183+
return fmt.Errorf("Only owner can transfer assets")
184184
}
185185

186186
newOwnerID := OwnerIdentifier{Org: newOwnerOrg, User: newOwner}
@@ -241,7 +241,7 @@ func readAsset(ctx contractapi.TransactionContextInterface, id string) ([]byte,
241241
return nil, fmt.Errorf("failed to read from world state: %v", err)
242242
}
243243
if assetBytes == nil {
244-
return nil, fmt.Errorf("sorry, asset %s has not been created", id)
244+
return nil, fmt.Errorf("Sorry, asset %s has not been created", id)
245245
}
246246

247247
return assetBytes, nil

full-stack-asset-transfer-guide/contracts/asset-transfer-go/src/main.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,3 @@
1-
/*
2-
* SPDX-License-Identifier: Apache-2.0
3-
*/
4-
51
package main
62

73
import (

0 commit comments

Comments
 (0)