Skip to content

Commit

Permalink
CIP Domain Validation: Allow arrays in token metadata
Browse files Browse the repository at this point in the history
To allow (sub)domains longer than 64 bytes, allow the array of strings
workaround known from other metadata standards.
  • Loading branch information
HeptaSean committed Sep 25, 2022
1 parent 248f449 commit 3638814
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
13 changes: 10 additions & 3 deletions CIP--HeptaSean-DomainValidation/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
18 changes: 14 additions & 4 deletions CIP--HeptaSean-DomainValidation/cardano-domain-validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)


Expand Down

0 comments on commit 3638814

Please sign in to comment.