package
1.0.5
Repository: https://github.com/hyperledger-labs/cckit.git
Documentation: pkg.go.dev

# README

Fabcar CCkit Chaincode

Fabcar CCkit is modification of Hyperledger fabric-samples fabcar chaincode

Fabcar Hyperledger Fabric Chaincode (FHF) short description:

  1. FHF is made without code generating
  2. At FHF you can create cat at once with method 'CreateCar'. Payload example:
{
  "car_number": "CAR1",
  "make": "Toyota",
  "model": "Prius",
  "colour": "blue",
  "owner": "Tomoko"
}
  1. Then you can get car with method 'QueryCar'. Payload example:
{
  "car_number": "CAR1"
}
  1. Or get all cars with method 'QueryAllCars' without payload

  2. Last method is 'ChangeCarOwner' to change car owner. Payload example:

{
  "car_number": "CAR1",
  "new_owner": "Brad"
}

Fabcar CCkit Chaincode (FCk) has four entities: Maker, Car, Owner and Detail. FCk has some difference from FHF:

  1. FCk gateway was generated with proto
  2. You can not create car at once, because before car's maker have to be created and put at BC state. Chaincode state stored as serialized protobuf Use method 'CreateMaker', payload example:
{
  "name": "Toyota",
  "country": "Japan",
  "foundation_year,omitempty": "1937" // it must be more than 1886, because this year was founded the oldest automaker - Mercedes-Benz
}
  1. You can get (method 'GetMaker') or delete (method 'DeleteMaker') maker by its name. For example:
{
  "name": "Toyota"
}
  1. And get all cars with method 'ListMakers' without payload

  2. Now your car can be created with 'CreateCar' method, for example:

{
  "make": "Toyota", // if maker is not created programm will return error
  "model": "Prius",
  "colour": "blue",
  "number": 111111,
  "owners": [
    {
      "first_name": "Tomoko",
      "second_name": "Uemura",
      "vehicle_passport": "bbb222"
    }
  ],
  "details": [
    {
      "type": WHEELS,
      "make": "Michelin"
    },
    {
      "type": BATTERY,
      "make": "BYD"
    }
  ]
}

The response is:

{
  "car": {
    "id": ["Toyota", "Prius", "111111"],
    "make": "",
    "model": "Prius",
    "colour": "blue",
    "number": 111111,
    "owners_quantity": 1
  },
  "owners": {
    "items": [
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "first_name": "Tomoko",
        "second_name": "Uemura",
        "vehicle_passport": "bbb222"
      }
    ]
  },
  "details": {
    "items": [
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "type": WHEELS,
        "make": "Michelin"
      },
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "type": BATTERY,
        "make": "BYD"
      }
    ]
  }
}
  1. Car updating makes with 'UpdateCar', payload:
{
  "id": ["Toyota", "Prius", "111111"],
  "color": "red",
  "owners": [
    {
      "car_id": ["Toyota", "Prius", "111111"],
      "first_name": "Tomoko",
      "second_name": "Uemura",
      "vehicle_passport": "ccc333"
    },
    {
      "car_id": ["Toyota", "Prius", "111111"],
      "first_name": "Michel",
      "second_name": "Uemura",
      "vehicle_passport": "ddd444"
    }
  ],
  "details": [
    {
      "car_id": ["Toyota", "Prius", "111111"],
      "type": BATTERY,
      "make": "Panasonic"
    }
  ]
}

The response is:

{
  "car": {
    "id": ["Toyota", "Prius", "111111"],
    "make": "",
    "model": "Prius",
    "colour": "red", // it was 'blue'
    "number": 111111,
    "owners_quantity": 2 // become more
  },
  "owners": {
    "items": [ // become more
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "first_name": "Tomoko",
        "second_name": "Uemura",
        "vehicle_passport": "ccc333" // it was 'bbb222'
      },
      { // it was added
        "car_id": ["Toyota", "Prius", "111111"],
        "first_name": "Michel",
        "second_name": "Tailor",
        "vehicle_passport": "ddd444"
      }
    ]
  },
  "details": {
    "items": [
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "type": WHEELS,
        "make": "Michelin"
      },
      {
        "car_id": ["Toyota", "Prius", "111111"],
        "type": BATTERY,
        "make": "Panasonic" // it was 'BYD'
      }
    ]
  }
}
  1. Also, you can delete car with 'DeleteCar', the response is like from 'UpdateCar' method (point 5)

  2. If you would like to get car, use 'GetCar' to get it without owners and details or 'GetCarView' with them. Request:

{
  "id": ["Toyota", "Prius", "111111"]
}
  1. To get all cars use 'ListCars' without payload

  2. Also, car owner can be updated without car changing ('UpdateCarOwners' method):

{
  "car_id": ["Toyota", "Prius", "111111"],
  "owners": [
    {
      "first_name": "Tomoko",
      "second_name": "Uemura",
      "vehicle_passport": "eee555"
    },
    {
      "first_name": "Adriana",
      "second_name": "Grande",
      "vehicle_passport": "fff666"
    }
  ]
}

The response:

{
  "items": [
    {
      "car_id": ["Toyota", "Prius", "111111"],
      "first_name": "Tomoko",
      "second_name": "Uemura",
      "vehicle_passport": "eee555" // it was 'ccc333'
    },
    { // without changes
      "car_id": ["Toyota", "Prius", "111111"],
      "first_name": "Michel",
      "second_name": "Uemura",
      "vehicle_passport": "ddd444"
    },
    { // was added
      "car_id": ["Toyota", "Prius", "111111"],
      "first_name": "Adriana",
      "second_name": "Grande",
      "vehicle_passport": "fff666"
    }
  ]
}
  1. To delete ('DeleteCarOwner') or get ('GetCarOwner') car owner use the same payload:
{
  "car_id": ["Toyota", "Prius", "111111"],
  "first_name": "Tomoko",
  "second_name": "Uemura"
}
  1. Also, you can update car detail ('UpdateCarDetails') without car changes, for example:
{
  "car_id": ["Toyota", "Prius", "111111"],
  "details": [
     {
        "type": WHEELS, 
        "make": "Michelin"
     },
     {
        "type": BATTERY,
        "make": "Contemporary Amperex Technology"
     }
  ]
}

The response:

{
   "items": [
      { // without changes
         "car_id": ["Toyota", "Prius", "111111"],
         "type": WHEELS,
         "make": "Michelin"
      },
      {
         "car_id": ["Toyota", "Prius", "111111"],
         "type": BATTERY,
         "make": "Contemporary Amperex Technology" // it was 'Panasonic'
      }
   ]
}
  1. To delete ('DeleteCarDetail') or get ('GetCarDetail') car owner use the same payload:
{
  "car_id": ["Toyota", "Prius", "111111"],
  "type": BATTERY
}
  1. And, of course, you can get list of car owners (method 'ListCarOwners') or list of car details (method 'ListCarDetails') by car id. Use payload:
{
   "id": ["Toyota", "Prius", "111111"] 
}

# Packages

No description provided by the author

# Functions

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewFabCarServiceGateway creates gateway to access chaincode method via chaincode service.
No description provided by the author
RegisterFabCarServiceChaincode registers service methods as chaincode router handlers.
RegisterFabCarServiceHandler registers the http handlers for service FabCarService to "mux".
RegisterFabCarServiceHandlerClient registers the http handlers for service FabCarService to "mux".
RegisterFabCarServiceHandlerFromEndpoint is same as RegisterFabCarServiceHandler but automatically dials to "endpoint" and closes the connection when "ctx" gets done.
RegisterFabCarServiceHandlerServer registers the http handlers for service FabCarService to "mux".
No description provided by the author
No description provided by the author

# Constants

No description provided by the author
No description provided by the author
No description provided by the author
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincode method names.
FabCarServiceChaincodeMethodPrefix allows to use multiple services with same method names in one chaincode.

# Variables

Enum value maps for DetailType.
Enum value maps for DetailType.
No description provided by the author
go:embed fabcar.swagger.json.
No description provided by the author
No description provided by the author

# Structs

No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Entities.
No description provided by the author
FabCarServiceChaincodeResolver interface for service resolver.
FabCarServiceChaincodeResolver interface for service resolver.
No description provided by the author
gateway implementation gateway can be used as kind of SDK, GRPC or REST server ( via grpc-gateway or clay ).
No description provided by the author
Events.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
UnimplementedFabCarServiceServer can be embedded to have forward compatible implementations.
No description provided by the author
No description provided by the author
No description provided by the author

# Interfaces

FabCarServiceChaincode chaincode methods interface.
FabCarServiceChaincodeResolver interface for service resolver.
FabCarServiceClient is the client API for FabCarService service.
FabCarServiceServer is the server API for FabCarService service.

# Type aliases

Dictionaries.