diff --git a/auction-dutch/chaincode-go-auditor/smart-contract/auction.go b/auction-dutch/chaincode-go-auditor/smart-contract/auction.go index e0151f8a..c56daedd 100644 --- a/auction-dutch/chaincode-go-auditor/smart-contract/auction.go +++ b/auction-dutch/chaincode-go-auditor/smart-contract/auction.go @@ -148,7 +148,7 @@ func (s *SmartContract) RevealBid(ctx contractapi.TransactionContextInterface, a transientBidJSON, ok := transientMap["bid"] if !ok { - return fmt.Errorf("bid key not found in the transient map") + return errors.New("bid key not found in the transient map") } // get implicit collection name of organization ID diff --git a/auction-dutch/chaincode-go-auditor/smart-contract/auctionQueries.go b/auction-dutch/chaincode-go-auditor/smart-contract/auctionQueries.go index cee05d2c..45b84762 100644 --- a/auction-dutch/chaincode-go-auditor/smart-contract/auctionQueries.go +++ b/auction-dutch/chaincode-go-auditor/smart-contract/auctionQueries.go @@ -6,6 +6,7 @@ package auction import ( "encoding/json" + "errors" "fmt" "github.com/hyperledger/fabric-chaincode-go/v2/shim" @@ -20,7 +21,7 @@ func (s *SmartContract) QueryAuction(ctx contractapi.TransactionContextInterface return nil, fmt.Errorf("failed to get auction object %v: %v", auctionID, err) } if auctionJSON == nil { - return nil, fmt.Errorf("auction does not exist") + return nil, errors.New("auction does not exist") } var auction *Auction diff --git a/auction-dutch/chaincode-go/smart-contract/auction.go b/auction-dutch/chaincode-go/smart-contract/auction.go index e71ae843..3ebf3d65 100644 --- a/auction-dutch/chaincode-go/smart-contract/auction.go +++ b/auction-dutch/chaincode-go/smart-contract/auction.go @@ -8,7 +8,8 @@ import ( "bytes" "crypto/sha256" "encoding/json" - "fmt" + "errors" + "fmt" "sort" "github.com/hyperledger/fabric-contract-api-go/v2/contractapi" @@ -129,7 +130,7 @@ func (s *SmartContract) Bid(ctx contractapi.TransactionContextInterface, auction bidJSON, ok := transientMap["bid"] if !ok { - return "", fmt.Errorf("bid key not found in the transient map") + return "", errors.New("bid key not found in the transient map") } // get the implicit collection name using the bidder's organization ID diff --git a/auction-dutch/chaincode-go/smart-contract/auctionQueries.go b/auction-dutch/chaincode-go/smart-contract/auctionQueries.go index 67d42f61..d5024fb4 100644 --- a/auction-dutch/chaincode-go/smart-contract/auctionQueries.go +++ b/auction-dutch/chaincode-go/smart-contract/auctionQueries.go @@ -6,6 +6,7 @@ package auction import ( "encoding/json" + "errors" "fmt" "github.com/hyperledger/fabric-chaincode-go/v2/shim" @@ -20,7 +21,7 @@ func (s *SmartContract) QueryAuction(ctx contractapi.TransactionContextInterface return nil, fmt.Errorf("failed to get auction object %v: %v", auctionID, err) } if auctionJSON == nil { - return nil, fmt.Errorf("auction does not exist") + return nil, errors.New("auction does not exist") } var auction *Auction diff --git a/token-erc-20/chaincode-go/chaincode/token_contract.go b/token-erc-20/chaincode-go/chaincode/token_contract.go index 388da934..677ee443 100644 --- a/token-erc-20/chaincode-go/chaincode/token_contract.go +++ b/token-erc-20/chaincode-go/chaincode/token_contract.go @@ -43,7 +43,7 @@ func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount return fmt.Errorf("failed to check if contract is already initialized: %v", err) } if !initialized { - return fmt.Errorf("Contract options need to be set before calling any function, call Initialize() to initialize contract") + return errors.New("Contract options need to be set before calling any function, call Initialize() to initialize contract") } // Check minter authorization - this sample assumes Org1 is the central banker with privilege to mint new tokens @@ -52,7 +52,7 @@ func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount return fmt.Errorf("failed to get MSPID: %v", err) } if clientMSPID != "Org1MSP" { - return fmt.Errorf("client is not authorized to mint new tokens") + return errors.New("client is not authorized to mint new tokens") } // Get ID of submitting client identity @@ -62,7 +62,7 @@ func (s *SmartContract) Mint(ctx contractapi.TransactionContextInterface, amount } if amount <= 0 { - return fmt.Errorf("mint amount must be a positive integer") + return errors.New("mint amount must be a positive integer") } currentBalanceBytes, err := ctx.GetStub().GetState(minter) @@ -141,7 +141,7 @@ func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, amount return fmt.Errorf("failed to check if contract is already initialized: %v", err) } if !initialized { - return fmt.Errorf("Contract options need to be set before calling any function, call Initialize() to initialize contract") + return errors.New("Contract options need to be set before calling any function, call Initialize() to initialize contract") } // Check minter authorization - this sample assumes Org1 is the central banker with privilege to burn new tokens clientMSPID, err := ctx.GetClientIdentity().GetMSPID() @@ -149,7 +149,7 @@ func (s *SmartContract) Burn(ctx contractapi.TransactionContextInterface, amount return fmt.Errorf("failed to get MSPID: %v", err) } if clientMSPID != "Org1MSP" { - return fmt.Errorf("client is not authorized to mint new tokens") + return errors.New("client is not authorized to mint new tokens") } // Get ID of submitting client identity @@ -719,7 +719,7 @@ func checkInitialized(ctx contractapi.TransactionContextInterface) (bool, error) // sub two number checking for overflow func sub(b int, q int) (int, error) { - // sub two number checking + // sub two number checking if q <= 0 { return 0, fmt.Errorf("Error: the subtraction number is %d, it should be greater than 0", q) }