argus-mint 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- argus_mint/__init__.py +20 -0
- argus_mint/__main__.py +5 -0
- argus_mint/_codec.py +63 -0
- argus_mint/_version.py +24 -0
- argus_mint/abi/Card.json +1342 -0
- argus_mint/abi/Deed.json +874 -0
- argus_mint/abi/Ledger.json +539 -0
- argus_mint/abi/__init__.py +19 -0
- argus_mint/chain.py +101 -0
- argus_mint/cli.py +472 -0
- argus_mint/darkroom.py +213 -0
- argus_mint/indexer.py +152 -0
- argus_mint/keys.py +95 -0
- argus_mint/ledger.py +76 -0
- argus_mint/merkle.py +126 -0
- argus_mint/metadata.py +121 -0
- argus_mint/networks.py +72 -0
- argus_mint/pin.py +84 -0
- argus_mint/py.typed +0 -0
- argus_mint/render.py +151 -0
- argus_mint/siwe.py +284 -0
- argus_mint/templates.py +264 -0
- argus_mint/vouchers.py +140 -0
- argus_mint-0.1.0.dist-info/METADATA +190 -0
- argus_mint-0.1.0.dist-info/RECORD +28 -0
- argus_mint-0.1.0.dist-info/WHEEL +4 -0
- argus_mint-0.1.0.dist-info/entry_points.txt +2 -0
- argus_mint-0.1.0.dist-info/licenses/LICENSE +21 -0
argus_mint/__init__.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"""argus-mint — provenance tokens for game assets.
|
|
2
|
+
|
|
3
|
+
Render from reviewed templates, pin to IPFS, mint ERC-721 cards and soulbound deeds,
|
|
4
|
+
and anchor commitments and Merkle roots on-chain. No game logic lives here.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
try:
|
|
10
|
+
# Written by hatch-vcs at build time (see pyproject [tool.hatch.build.hooks.vcs]).
|
|
11
|
+
from argus_mint._version import __version__
|
|
12
|
+
except ImportError: # running from a source checkout that hasn't been built
|
|
13
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
14
|
+
|
|
15
|
+
try:
|
|
16
|
+
__version__ = version("argus-mint")
|
|
17
|
+
except PackageNotFoundError:
|
|
18
|
+
__version__ = "0.0.0+unknown"
|
|
19
|
+
|
|
20
|
+
__all__ = ["__version__"]
|
argus_mint/__main__.py
ADDED
argus_mint/_codec.py
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"""Shared encoding helpers: keccak256, canonical JSON, and Pydantic field types for
|
|
2
|
+
32-byte values and addresses. Pure; no I/O."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import json
|
|
7
|
+
from typing import Annotated, Any
|
|
8
|
+
|
|
9
|
+
from Crypto.Hash import keccak as _keccak
|
|
10
|
+
from eth_utils import is_address, to_checksum_address
|
|
11
|
+
from pydantic import BeforeValidator, PlainSerializer
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def keccak256(data: bytes) -> bytes:
|
|
15
|
+
"""Ethereum's keccak256 (not NIST SHA3-256)."""
|
|
16
|
+
return _keccak.new(digest_bits=256, data=data).digest()
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
def canonical(doc: Any) -> bytes:
|
|
20
|
+
"""Canonical JSON: sorted keys, compact separators, UTF-8, no NaN/Infinity.
|
|
21
|
+
|
|
22
|
+
The same document always gives the same bytes, so its hash is stable.
|
|
23
|
+
"""
|
|
24
|
+
return json.dumps(doc, sort_keys=True, separators=(",", ":"), ensure_ascii=False, allow_nan=False).encode("utf-8")
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def to_bytes32(value: Any) -> bytes:
|
|
28
|
+
"""Accept 32 raw bytes or a 0x-prefixed 64-hex-digit string."""
|
|
29
|
+
if isinstance(value, bytes | bytearray):
|
|
30
|
+
b = bytes(value)
|
|
31
|
+
elif isinstance(value, str):
|
|
32
|
+
if not value.startswith("0x") or len(value) != 66:
|
|
33
|
+
raise ValueError("expected 0x followed by 64 hex digits")
|
|
34
|
+
try:
|
|
35
|
+
b = bytes.fromhex(value[2:])
|
|
36
|
+
except ValueError as e:
|
|
37
|
+
raise ValueError("expected 0x followed by 64 hex digits") from e
|
|
38
|
+
else:
|
|
39
|
+
raise ValueError("expected 32 bytes or a 0x hex string")
|
|
40
|
+
if len(b) != 32:
|
|
41
|
+
raise ValueError(f"expected 32 bytes, got {len(b)}")
|
|
42
|
+
return b
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def hex0x(b: bytes) -> str:
|
|
46
|
+
return "0x" + b.hex()
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def to_address(value: Any) -> str:
|
|
50
|
+
"""Validate an address and return its EIP-55 checksum form.
|
|
51
|
+
|
|
52
|
+
A mixed-case address with a wrong checksum is rejected (it's probably a typo).
|
|
53
|
+
"""
|
|
54
|
+
if not isinstance(value, str) or not is_address(value):
|
|
55
|
+
raise ValueError(f"not a valid address: {value!r}")
|
|
56
|
+
return to_checksum_address(value)
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
Bytes32 = Annotated[bytes, BeforeValidator(to_bytes32), PlainSerializer(hex0x, return_type=str, when_used="json")]
|
|
60
|
+
Address = Annotated[str, BeforeValidator(to_address)]
|
|
61
|
+
|
|
62
|
+
UINT64_MAX = 2**64 - 1
|
|
63
|
+
UINT256_MAX = 2**256 - 1
|
argus_mint/_version.py
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# file generated by vcs-versioning
|
|
2
|
+
# don't change, don't track in version control
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
"__version__",
|
|
7
|
+
"__version_tuple__",
|
|
8
|
+
"version",
|
|
9
|
+
"version_tuple",
|
|
10
|
+
"__commit_id__",
|
|
11
|
+
"commit_id",
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
version: str
|
|
15
|
+
__version__: str
|
|
16
|
+
__version_tuple__: tuple[int | str, ...]
|
|
17
|
+
version_tuple: tuple[int | str, ...]
|
|
18
|
+
commit_id: str | None
|
|
19
|
+
__commit_id__: str | None
|
|
20
|
+
|
|
21
|
+
__version__ = version = '0.1.0'
|
|
22
|
+
__version_tuple__ = version_tuple = (0, 1, 0)
|
|
23
|
+
|
|
24
|
+
__commit_id__ = commit_id = None
|