Skip to content

Classes

ymeister edited this page Feb 3, 2019 · 34 revisions
Data types:
- address - address in blockchain
- address (private) - address that is not accessible via API
- string - text data
- uint - unsigned integer (positive integers)
- uint (time) - number of seconds from 01.01.1970 (standard way of keeping track of time)
- enum ContractType
  - NON_AUTHORIZED
  - ITEM
  - USER
  - MANUFACTURER
  - VENDOR
  - SERVICE_CENTER
- enum Status
  - NORMAL
  - ON_SERVICE
  - DEFECTED
  - RETURNED
- enum Action
  - CREATION
  - TRANSFER
  - CHANGED_OWNER
  - SERVICE
  - RETURN
contract Main {
- userList [[ownerID, userID]]
- manufacturerList [[ownerID, manufacturerID]]
- vendorList [[ownerID, vendorID]]
- serviceCenterList [[ownerID, serviceCenterID]]

- constructor (address userDeployer, address manufacturerDeployer, address vendorDeployer, address serviceCenterDeployer)

- ownerToID (address owner) -> address ID
- getManufacturerList () -> [[pubkey, manufacturerID]]
- getVendorList () -> [[pubkey, vendorID]]
- getServiceCenterList () -> [[pubkey, serviceCenterID]]

- registerUser (address owner) -> address user
  - Creates User contract, sets it's ownerID

- registerManufacturer (address ownerID, string name, string physicalAddress, string registrationNumber) -> address manufacturer
  - Creates Manufacturer contract, sets it's ownerID
  - Fills name, physicalAddress and registrationNumber of the contract

- registerVendor (address ownerID, string name, string physicalAddress, string registrationNumber) -> address vendor
  - Creates Vendor contract, sets it's ownerID
  - Fills name, physicalAddress and registrationNumber of the contract

- registerServiceCenter (address ownerID, string name, string physicalAddress, string registrationNumber) -> address serviceCenter
  - Creates ServiceCenter contract, sets it's ownerID
  - Fills name, physicalAddress and registrationNumber of the contract
}
contract Item {
- id              (address)           - address of this contract
- ownerID         (address (private)) - private address of the owner of the item
- serial          (string)            - serial number of the item
- info            (string)            - information about the item (model, characteristics, etc.)
- manufacturerID  (address)           - address of the manufacturer's contract
- vendorID        (address)           - address of the vendor's contract
- created         (uint (time))       - time of creation of the item
- warrantyPeriod  (uint (time))       - warranty duration
- warrantyTerms   (string)            - terms (conditions) of the warranty for the item
- activated       (uint (time))       - time of activation of the warranty
- status          (Status)            - status of the item
- history         ([Action])          - history of the item

- constructor (address main, string serial, string info, uint warrantyPeriod, string warrantyTerms)
  - Constructs the contract with given main registry, serial number, information about the item, warranty period and warranty terms of the item
  - Sets the address of the creator as manufacturerID upon creation

- getInfo () -> (serial, info, manufacturerID, vendorID, created, warrantyPeriod, warrantyTerms, activated, status, history)
  - returns item's info

- setVendor (address vendor)
  - Sets vendorID as vendor
  - Can only be applied once by the manufacturer

- setOwner (address user)
  - Sets ownerID as user
  - Can only be applied once by the vendor

- changeOwner (address user)
  - Changes ownerID to user
  - Can only be applied by the owner

- activateWarranty ()
  - Sets "activated" of the item as current time
    - Can only be applied once by the manufacturer or vendor

- statusNormal ()
  - Sets status to NORMAL
  - Can only be applied by service center

- statusOnService ()
  - Sets status to ON_SERVICE
  - Can only be applied by service center

- statusDefected ()
  - Sets status to DEFECTED
  - Can only be applied by service center

- statusReturned ()
  - Sets status to RETURNED
  - Can only be applied by manufacturer or vendor
}
contract User {
- id              (address)           - address of this contract
- ownerID         (address (private)) - private address of the owner of the account
- items           ([address])         - list of items owned by the user

- getItems () -> [address]

- requestTransfer (address user, address[] items)
- acceptTransfer (address user, address[] items)
- declineTransfer (address user, address[] items)
- revertTransfer (address user, address[] items)
}
contract Manufacturer {
- id                      (address)             - address of the contract
- ownerID                 (address (private))   - private address of the manufacturer
- name                    (string)              - Name of the manufacturer
- physicalAddress         (string)              - Physical address of the manufacturer
- registrationNumber      (string)              - Registration number of the manufacturer
- vendors                 ([address])           - vendors that are in partnership
- serviceCenters          ([address])           - service centers that are in partnership
- pendingItems            ([address])           - items that are not yet sold

- constructor (address main, address owner, string name, string physicalAddress, string registrationNumber)
  - Constructs the contract with given main registry, owner, name, physical address and registration number of the manufacturer
  - Sets the address of the creator as ownerID upon creation

- getInfo () -> (name, physicalAddress, registrationNumber)
- getVendors () -> [address]
- getServiceCenters() -> [address]
- getPendingItems () -> [address]

- createItem (string serial, string info, uint warrantyPeriod, string warrantyTerms) -> address item
  - Can be applied only by the owner
  - Creates item contract with given serial, info, warranty period and warranty terms
  - Appends address of the created item to pendingItems[]
  - Returns item's address

- requestPartnership (address partner)
- acceptPartnership (address partner)
- declinePartnership (address partner)
- revertPartnership (address partner)
- cancelPartnership (address partner)

- requestTransfer (address vendor, address[] items)
- acceptTransfer (address vendor, address[] items)
- declineTransfer (address vendor, address[] items)
- revertTransfer (address vendor, address[] items)

- setVendorToItem (address vendor, address item)
  - Sets vendorID of the item to vendor
  - Can only be applied once

- activateWarranty (address item)
  - Sets "activated" of the item as current time
    - Can only be applied once by the manufacturer or vendor
}
contract Vendor {
- id                      (address)             - address of the contract
- ownerID                 (address (private))   - private address of the vendor
- name                    (string)              - Name of the vendor
- physicalAddress         (string)              - Physical address of the vendor
- registrationNumber      (string)              - Registration number of the vendor
- manufacturers           ([address])           - manufacturers that are in partnership
- pendingItems            ([address])           - items that are not yet sold

- constructor (address main, address owner, string name, string physicalAddress, string registrationNumber)
  - Constructs the contract with given main registry, owner, name, physical address and registration number of the vendor
  - Sets the address of the creator as ownerID upon creation

- getInfo () -> (name, physicalAddress, registrationNumber)
- getManufacturers () -> [address]
- getPendingItems () -> [address]

- requestPartnership (address partner)
- acceptPartnership (address partner)
- declinePartnership (address partner)
- revertPartnership (address partner)
- cancelPartnership (address partner)

- requestTransfer (address vendor or user, address[] items)
- acceptTransfer (address vendor or user, address[] items)
- declineTransfer (address vendor or user, address[] items)
- revertTransfer (address vendor or user, address[] items)

- setOwnerToItem (address user, address item)
  - Sets ownerID of the item as user
  - Can only be applied once

- activateWarranty (address item)
  - Sets "activated" of the item as current time
    - Can only be applied once by the manufacturer or vendor
}
contract ServiceCenter {
- id                      (address)             - address of the contract
- ownerID                 (address (private))   - private address of the service center
- name                    (string)              - Name of the service center
- physicalAddress         (string)              - Physical address of the service center
- registrationNumber      (string)              - Registration number of the service center
- manufacturers           ([address])           - manufacturers that are in partnership
- pendingItems            ([address])           - items that are not yet processed

- constructor (address main, address owner, string name, string physicalAddress, string registrationNumber)
  - Constructs the contract with given main registry, owner, name, physical address and registration number of the service center
  - Sets the address of the creator as ownerID upon creation

- getInfo () -> (name, physicalAddress, registrationNumber)
- getManufacturers () -> [address]
- getPendingItems () -> [address]

- requestPartnership (address partner)
- acceptPartnership (address partner)
- declinePartnership (address partner)
- revertPartnership (address partner)
- cancelPartnership (address partner)

- requestTransfer (address user, address[] items)
- acceptTransfer (address user, address[] items)
- declineTransfer (address user, address[] items)
- revertTransfer (address user, address[] items)
}
Clone this wiki locally