From ba8e67dbf2fffce461aa4b049324d7b701b5b1ff Mon Sep 17 00:00:00 2001 From: sumanjeet0012 Date: Sun, 5 Jul 2026 18:39:40 +0530 Subject: [PATCH] fix(code): add missing tag categories in _get_tag --- multicodec/code.py | 24 ++++++++++++++++++++++++ tests/test_code.py | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/multicodec/code.py b/multicodec/code.py index ce55f5e..1f04744 100644 --- a/multicodec/code.py +++ b/multicodec/code.py @@ -342,6 +342,14 @@ def _get_tag(code: int) -> str: if name in ("multicodec", "multihash", "multiaddr", "multibase", "varsig"): return "multiformat" + # Multikey + if name == "chacha20-poly1305": + return "multikey" + + # Multisig + if "-msig" in name or ("lamport-" in name and "-sig" in name): + return "multisig" + # Multihash if any( h in name @@ -387,6 +395,10 @@ def _get_tag(code: int) -> str: ): return "namespace" + # Nonce + if name == "nonce": + return "nonce" + # Serialization if name in ( "protobuf", @@ -402,6 +414,14 @@ def _get_tag(code: int) -> str: ): return "serialization" + # Shelter + if name.startswith("shelter-"): + return "shelter" + + # Softhash + if name == "iscc": + return "softhash" + # Transport if name in ( "transport-bitswap", @@ -425,6 +445,10 @@ def _get_tag(code: int) -> str: ): return "varsig" + # Vlad + if name == "vlad": + return "vlad" + # Zeroxcert if name in ("zeroxcert-imprint-256",): return "zeroxcert" diff --git a/tests/test_code.py b/tests/test_code.py index 451bb53..00d80d5 100644 --- a/tests/test_code.py +++ b/tests/test_code.py @@ -117,6 +117,32 @@ def test_code_tag(self): code = Code(0x55) # raw assert code.tag() == "ipld" + # Multikey + code = Code(0xA000) # chacha20-poly1305 + assert code.tag() == "multikey" + + # Multisig + code = Code(0xD01300) # es256k-msig + assert code.tag() == "multisig" + code = Code(0x1A44) # lamport-sha3-512-sig + assert code.tag() == "multisig" + + # Nonce + code = Code(0x123B) # nonce + assert code.tag() == "nonce" + + # Shelter + code = Code(0x511E00) # shelter-contract-manifest + assert code.tag() == "shelter" + + # Softhash + code = Code(0xCC01) # iscc + assert code.tag() == "softhash" + + # Vlad + code = Code(0x1207) # vlad + assert code.tag() == "vlad" + class ReservedRangeTestCase: """Tests for reserved range constants and functions."""