mirror of
https://github.com/hyperledger/fabric-samples.git
synced 2026-06-22 01:25:10 +00:00
corrected some logs based on the typescript implementation
Signed-off-by: nXtCyberNet <rohantech2005@gmail.com>
This commit is contained in:
parent
ada8de3677
commit
d62b51853d
4 changed files with 10 additions and 19 deletions
|
|
@ -5,16 +5,20 @@ go 1.23.0
|
||||||
require (
|
require (
|
||||||
github.com/hyperledger/fabric-chaincode-go/v2 v2.0.0
|
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-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 (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
github.com/go-openapi/jsonpointer v0.21.0 // indirect
|
||||||
github.com/go-openapi/jsonreference 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/spec v0.21.0 // indirect
|
||||||
github.com/go-openapi/swag v0.23.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/josharian/intern v1.0.0 // indirect
|
||||||
github.com/mailru/easyjson v0.7.7 // 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/gojsonpointer v0.0.0-20190905194746-02993c407bfb // indirect
|
||||||
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
github.com/xeipuuv/gojsonreference v0.0.0-20180127040603-bd5ef7bd5415 // indirect
|
||||||
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
github.com/xeipuuv/gojsonschema v1.2.0 // indirect
|
||||||
|
|
@ -23,6 +27,5 @@ require (
|
||||||
golang.org/x/text v0.17.0 // indirect
|
golang.org/x/text v0.17.0 // indirect
|
||||||
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
google.golang.org/genproto/googleapis/rpc v0.0.0-20240814211410-ddb44dafa142 // indirect
|
||||||
google.golang.org/grpc v1.67.0 // 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
|
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,10 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
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 {
|
type OwnerIdentifier struct {
|
||||||
Org string `json:"org"`
|
Org string `json:"org"`
|
||||||
User string `json:"user"`
|
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 {
|
type Asset struct {
|
||||||
AppraisedValue int `json:"AppraisedValue"`
|
AppraisedValue int `json:"AppraisedValue"`
|
||||||
Color string `json:"Color"`
|
Color string `json:"Color"`
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ func (s *SmartContract) CreateAsset(ctx contractapi.TransactionContextInterface,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if exists {
|
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)
|
ownerID, err := clientIdentifier(ctx, owner)
|
||||||
|
|
@ -96,7 +96,7 @@ func (s *SmartContract) UpdateAsset(ctx contractapi.TransactionContextInterface,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !ok {
|
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.
|
// Owner is intentionally preserved; use TransferAsset to change owner.
|
||||||
|
|
@ -141,7 +141,7 @@ func (s *SmartContract) DeleteAsset(ctx contractapi.TransactionContextInterface,
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !ok {
|
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 {
|
if err := ctx.GetStub().DelState(id); err != nil {
|
||||||
|
|
@ -180,7 +180,7 @@ func (s *SmartContract) TransferAsset(ctx contractapi.TransactionContextInterfac
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if !ok {
|
if !ok {
|
||||||
return fmt.Errorf("only owner can transfer assets")
|
return fmt.Errorf("Only owner can transfer assets")
|
||||||
}
|
}
|
||||||
|
|
||||||
newOwnerID := OwnerIdentifier{Org: newOwnerOrg, User: newOwner}
|
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)
|
return nil, fmt.Errorf("failed to read from world state: %v", err)
|
||||||
}
|
}
|
||||||
if assetBytes == nil {
|
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
|
return assetBytes, nil
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,3 @@
|
||||||
/*
|
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
|
||||||
*/
|
|
||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue