Skip to content

Commit b06c17d

Browse files
authored
Merge pull request #62 from Concordium/CIS6-track-and-trace-standard
Add CIS6 standard
2 parents 4ad35ae + 78a0bfb commit b06c17d

File tree

4 files changed

+123
-3
lines changed

4 files changed

+123
-3
lines changed

.github/workflows/lint.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
lint:
1212
runs-on: ubuntu-latest
13-
container: sphinxdoc/sphinx
13+
container: sphinxdoc/sphinx:7.0.0
1414
steps:
1515
- name: Checkout 🛎️
1616
uses: actions/checkout@v2.3.1
@@ -22,15 +22,15 @@ jobs:
2222
run: |
2323
apt-get update
2424
apt-get install -y git rsync
25-
pip3 install -r requirements.txt
25+
pip3 install -r requirements.txt
2626
2727
- name: Lint 🔍
2828
shell: bash
2929
run: doc8 source
3030

3131
build:
3232
runs-on: ubuntu-latest
33-
container: sphinxdoc/sphinx
33+
container: sphinxdoc/sphinx:7.0.0
3434
steps:
3535
- name: Checkout 🛎️
3636
uses: actions/checkout@v2.3.1

requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ sphinxcontrib-serializinghtml==1.1.5
3434
stevedore==3.4.0
3535
tornado==6.1
3636
urllib3==1.26.6
37+

source/CIS/cis-6.rst

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
.. _CIS-6:
2+
3+
===============================
4+
CIS-6: Track-and-Trace Standard
5+
===============================
6+
7+
.. list-table::
8+
:stub-columns: 1
9+
10+
* - Created
11+
- Apr 25, 2024
12+
* - Final
13+
- Apr 26, 2024
14+
* - Supported versions
15+
- | Smart contract version 1 or newer
16+
| (Protocol version 4 or newer)
17+
* - Standard identifier
18+
- ``CIS-6``
19+
* - Requires
20+
- :ref:`CIS-0<CIS-0>`
21+
22+
23+
Abstract
24+
========
25+
26+
A standard interface that defines the logged events for tracking items in a smart contract.
27+
The interface defines two events:
28+
29+
- *ItemCreatedEvent* logs the ``item_id``, ``metadata_url``, and the ``initial_status``;
30+
- *ItemStatusChangedEvent* logs the ``item_id``, ``new_status``, and the ``additional_data``;
31+
32+
Specification
33+
=============
34+
35+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in :rfc:`2119`.
36+
37+
38+
General types and serialization
39+
-------------------------------
40+
41+
.. _CIS-6-ItemId:
42+
43+
``ItemId``
44+
^^^^^^^^^^
45+
46+
Each item MUST have a unique ``ItemId``.
47+
An ``ItemId`` is a variable-length ASCII string up to 255 characters.
48+
49+
The identifier is serialized as: 1 byte for the length (``n``) followed by this many bytes for the ASCII encoding of the identifier::
50+
51+
ItemId ::= (n: Byte) (id: Byteⁿ)
52+
53+
.. _CIS-6-MetadataUrl:
54+
55+
``MetadataUrl``
56+
^^^^^^^^^^^^^^^
57+
58+
A URL and optional checksum for metadata stored outside of this contract.
59+
60+
It is serialized as: 2 bytes for the length (``n``) of the metadata URL in little-endian and then this many bytes for the URL to the metadata (``url``) followed by an optional checksum.
61+
The checksum is serialized by 1 byte to indicate whether a hash of the metadata is included.
62+
If its value is 0, then there is no hash; if the value is 1, then 32 bytes for a SHA256 hash (``hash``) follows::
63+
64+
MetadataChecksum ::= (0: Byte)
65+
| (1: Byte) (hash: Byte³²)
66+
67+
MetadataUrl ::= (n: Byte²) (url: Byteⁿ) (checksum: MetadataChecksum)
68+
69+
.. _CIS-6-Status:
70+
71+
``Status``
72+
^^^^^^^^^^
73+
74+
The status defined by this specification is serialized using one byte to discriminate the different statuses that an item can have.
75+
The smart contract can have up to 255 different statuses defined for an item.
76+
77+
It is serialized as: a byte of value (``n``)::
78+
79+
Status ::= (n: Byte)
80+
81+
.. _CIS-6-AdditionalData:
82+
83+
``AdditionalData``
84+
^^^^^^^^^^^^^^^^^^
85+
86+
Additional bytes to include in the event ``ItemStatusChangedEvent``, which can be used to add additional use-case-specific data (e.g. temperature, longitude, latitude, ...) to the event.
87+
88+
It is serialized as: the first 2 bytes encode the length (``n``) of the data, followed by this many bytes for the data (``data``)::
89+
90+
AdditionalData ::= (n: Byte²) (data: Byteⁿ)
91+
92+
Logged events
93+
-------------
94+
95+
The events defined by this specification are serialized using one byte to discriminate the different events.
96+
A custom event SHOULD NOT have a first byte colliding with any of the events defined by this specification.
97+
98+
.. _CIS-6-events-ItemCreatedEvent:
99+
100+
``ItemCreatedEvent``
101+
^^^^^^^^^^^^^^^^^^^^
102+
103+
A ``ItemCreatedEvent`` event MUST be logged when a new item is created in the smart contract.
104+
105+
The ``ItemCreatedEvent`` event is serialized as: first a byte with the value of 237, followed by the :ref:`CIS-6-ItemId` (``id``), the :ref:`CIS-6-MetadataUrl` (``metadata``), and then the :ref:`CIS-6-Status` (``initial_status``)::
106+
107+
ItemCreatedEvent ::= (237: Byte) (item_id: ItemId) (metadata: MetadataUrl) (initial_status: Status)
108+
109+
.. _CIS-6-events-ItemStatusChangedEvent:
110+
111+
``ItemStatusChangedEvent``
112+
^^^^^^^^^^^^^^^^^^^^^^^^^^
113+
114+
A ``ItemStatusChangedEvent`` event MUST be logged when an item status is updated in the smart contract state.
115+
116+
The ``ItemStatusChangedEvent`` event is serialized as: first a byte with the value of 236, followed by the :ref:`CIS-6-ItemId` (``id``), the :ref:`CIS-6-Status` (``new_status``), and then the :ref:`CIS-6-AdditionalData` (``additional_data``)::
117+
118+
ItemStatusChangedEvent ::= (236: Byte) (item_id: ItemId) (new_status: Status) (additional_data: AdditionalData)

source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,5 @@ Concordium Interoperability Specifications
2121
CIS/cis-2
2222
CIS/cis-3
2323
CIS/cis-4
24+
CIS/cis-6
2425
ID/concordium-did.rst

0 commit comments

Comments
 (0)