From 36388148d97487eda4a9095e1807a7fbd12b63c8 Mon Sep 17 00:00:00 2001 From: Benjamin Braatz Date: Sun, 25 Sep 2022 16:33:34 +0200 Subject: [PATCH] CIP Domain Validation: Allow arrays in token metadata To allow (sub)domains longer than 64 bytes, allow the array of strings workaround known from other metadata standards. --- CIP--HeptaSean-DomainValidation/README.md | 13 ++++++++++--- .../cardano-domain-validation.py | 18 ++++++++++++++---- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CIP--HeptaSean-DomainValidation/README.md b/CIP--HeptaSean-DomainValidation/README.md index 8c6834f0c..206ae73f2 100644 --- a/CIP--HeptaSean-DomainValidation/README.md +++ b/CIP--HeptaSean-DomainValidation/README.md @@ -86,14 +86,21 @@ number of DNS): | --------------------------- | ------------ | | 53 | DNS Domain | -The metadatum at this label is a single UTF-8 string – the domain that is -represented by this token, in JSON representation: +The metadatum at this label is the domain that is represented by this +token – either as a single UTF-8 string or as an array of strings, in JSON +representation: ```json { "53": "example.org" } ``` +or +```json +{ "53": [ "very.long.subdomain.for.", + "example.org" ] } +``` Since strings in the metadata of Cardano transactions are restricted to 64 -bytes, this domain is also restricted to 64 bytes. +bytes, the domain has to be split into such an array of strings if it is +longer than 64 bytes. The domain must be a DNS domain name as specified in [RFC 1034](https://datatracker.ietf.org/doc/html/rfc1034) and following. diff --git a/CIP--HeptaSean-DomainValidation/cardano-domain-validation.py b/CIP--HeptaSean-DomainValidation/cardano-domain-validation.py index 3318d34b8..ab4579db3 100644 --- a/CIP--HeptaSean-DomainValidation/cardano-domain-validation.py +++ b/CIP--HeptaSean-DomainValidation/cardano-domain-validation.py @@ -154,10 +154,20 @@ def query_address(address: str) -> List[str]: asset_info = json.loads(json_body) for asset_object in asset_info: for metadatum in asset_object['minting_tx_metadata']: - if (metadatum['key'] == '53' and - isinstance(metadatum['json'], str) and - is_domain(metadatum['json'])): - result.add(metadatum['json']) + if metadatum['key'] == '53': + if (isinstance(metadatum['json'], str) and + is_domain(metadatum['json'])): + result.add(metadatum['json']) + elif isinstance(metadatum['json'], list): + domain = '' + for part in metadatum['json']: + if isinstance(part, str): + domain += part + else: + domain = '' + break + if domain and is_domain(domain): + result.add(domain) return sorted(result)