Skip to content

Commit aa4cee1

Browse files
refactor(compliance): ComplianceProof for one proof, ComplianceProofs for the argument
ComplianceProof is one [MerkleProof; 2] value (literal, MerkleProofPair, or a pair of MerkleProofInput). Each SDK package now defines ComplianceProofs as its calls' whole compliance_proofs argument, as veil does: the bridge's is one proof bare or in a one-tuple or None; Shield Swap's is the union of the per-method tuple aliases or None.
1 parent 6d92751 commit aa4cee1

11 files changed

Lines changed: 45 additions & 36 deletions

File tree

‎bridge-sdk/AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ solana-hyperlane / aleo-hyperlane / evm-xreserve / aleo-xreserve) with
7979
``fees`` and ``amount_out`` in human units and ``quote.plan``. Show the
8080
user fees + amount before ``execute``.
8181

82-
### `execute(self, plan, *, on_checkpoint=None, proving: 'str' = 'delegate', mode: 'str | None' = None, record: 'str | None' = None, compliance_proofs: 'ProofBundle | tuple[ProofBundle] | None' = None, merkle_proof: 'str | None' = None, gas_payment_microcredits: 'int | None' = None, secret_nonce: 'str | None' = None, poll_seconds: 'float' = 1.0, timeout_seconds: 'float' = 120.0)`
82+
### `execute(self, plan, *, on_checkpoint=None, proving: 'str' = 'delegate', mode: 'str | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, gas_payment_microcredits: 'int | None' = None, secret_nonce: 'str | None' = None, poll_seconds: 'float' = 1.0, timeout_seconds: 'float' = 120.0)`
8383

8484
Commit funds on the source chain for ``quote.plan``; returns ``Progress``.
8585

@@ -276,7 +276,7 @@ lifecycle layer (plan 4) re-quotes at the last responsible moment by calling thi
276276
Live relayer payment for the route (the exact u64 the hook asserts); quote right before proving.
277277
``asset`` is an asset ref, a ``Route`` or a route id (BAT/USDG need the route: two destinations).
278278

279-
### `xreserve.burn(self, recipient: 'str', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, mode: 'str' = 'private', record: 'str | None' = None, compliance_proofs: 'ProofBundle | tuple[ProofBundle] | None' = None, merkle_proof: 'str | None' = None, route: 'Route | None' = None) -> 'AleoCall[BurnReceipt]'`
279+
### `xreserve.burn(self, recipient: 'str', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, mode: 'str' = 'private', record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, route: 'Route | None' = None) -> 'AleoCall[BurnReceipt]'`
280280

281281
Burn USDCx for USDC on the selected EVM route (Ethereum by default).
282282

@@ -302,7 +302,7 @@ One Circle request for *message_hash*; ``None`` while pending (404).
302302

303303

304304

305-
### `unshield(self, asset: 'Any', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, record: 'str | None' = None, compliance_proofs: 'ProofBundle | tuple[ProofBundle] | None' = None, merkle_proof: 'str | None' = None, recipient: 'str | None' = None) -> 'AleoCall[PrivacyReceipt]'`
305+
### `unshield(self, asset: 'Any', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, recipient: 'str | None' = None) -> 'AleoCall[PrivacyReceipt]'`
306306

307307
Move a private record into the public balance; see ``privacy.unshield``.
308308

‎bridge-sdk/python/aleo_bridge/AGENTS.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ solana-hyperlane / aleo-hyperlane / evm-xreserve / aleo-xreserve) with
7979
``fees`` and ``amount_out`` in human units and ``quote.plan``. Show the
8080
user fees + amount before ``execute``.
8181

82-
### `execute(self, plan, *, on_checkpoint=None, proving: 'str' = 'delegate', mode: 'str | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs | tuple[ComplianceProofs] | None' = None, merkle_proof: 'str | None' = None, gas_payment_microcredits: 'int | None' = None, secret_nonce: 'str | None' = None, poll_seconds: 'float' = 1.0, timeout_seconds: 'float' = 120.0)`
82+
### `execute(self, plan, *, on_checkpoint=None, proving: 'str' = 'delegate', mode: 'str | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, gas_payment_microcredits: 'int | None' = None, secret_nonce: 'str | None' = None, poll_seconds: 'float' = 1.0, timeout_seconds: 'float' = 120.0)`
8383

8484
Commit funds on the source chain for ``quote.plan``; returns ``Progress``.
8585

@@ -276,7 +276,7 @@ lifecycle layer (plan 4) re-quotes at the last responsible moment by calling thi
276276
Live relayer payment for the route (the exact u64 the hook asserts); quote right before proving.
277277
``asset`` is an asset ref, a ``Route`` or a route id (BAT/USDG need the route: two destinations).
278278

279-
### `xreserve.burn(self, recipient: 'str', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, mode: 'str' = 'private', record: 'str | None' = None, compliance_proofs: 'ComplianceProofs | tuple[ComplianceProofs] | None' = None, merkle_proof: 'str | None' = None, route: 'Route | None' = None) -> 'AleoCall[BurnReceipt]'`
279+
### `xreserve.burn(self, recipient: 'str', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, mode: 'str' = 'private', record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, route: 'Route | None' = None) -> 'AleoCall[BurnReceipt]'`
280280

281281
Burn USDCx for USDC on the selected EVM route (Ethereum by default).
282282

@@ -302,7 +302,7 @@ One Circle request for *message_hash*; ``None`` while pending (404).
302302

303303

304304

305-
### `unshield(self, asset: 'Any', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs | tuple[ComplianceProofs] | None' = None, merkle_proof: 'str | None' = None, recipient: 'str | None' = None) -> 'AleoCall[PrivacyReceipt]'`
305+
### `unshield(self, asset: 'Any', *, amount: 'Any' = None, amount_atomic: 'int | None' = None, record: 'str | None' = None, compliance_proofs: 'ComplianceProofs' = None, merkle_proof: 'str | None' = None, recipient: 'str | None' = None) -> 'AleoCall[PrivacyReceipt]'`
306306

307307
Move a private record into the public balance; see ``privacy.unshield``.
308308

‎bridge-sdk/python/aleo_bridge/__init__.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from .circle import CircleClient # noqa: E402
3030
from .client import Bridge # noqa: E402
3131
from .eth import Ethereum, EthModule # noqa: E402
32-
from .freezelist import EMPTY_MERKLE_PROOF_PAIR, FreezeList, MerkleProofInput, MerkleProofPair, ComplianceProofs # noqa: E402
32+
from .freezelist import EMPTY_MERKLE_PROOF_PAIR, ComplianceProof, ComplianceProofs, FreezeList, MerkleProofInput, MerkleProofPair # noqa: E402
3333
from .hyperlane import HyperlaneModule # noqa: E402
3434
from . import lifecycle # noqa: E402
3535
from .lifecycle import prepare # noqa: E402
@@ -51,7 +51,7 @@
5151
"Fee", "GasQuote", "MintReceipt", "Plan", "PreparedTx", "PrivacyReceipt", "Progress", "Quote", "Receipt",
5252
"SolanaHyperlaneQuote", "Status", "Step", "to_progress",
5353
"AleoCall", "Bridge", "CircleClient", "DEFAULT_ENDPOINT", "EMPTY_MERKLE_PROOF_PAIR", "FreezeList",
54-
"MerkleProofInput", "MerkleProofPair", "ComplianceProofs",
54+
"ComplianceProof", "ComplianceProofs", "MerkleProofInput", "MerkleProofPair",
5555
"HyperlaneModule", "PrivacyModule", "Profile", "XReserveModule",
5656
"Checkpoint", "CheckpointLoadResult", "CheckpointProblem", "CheckpointStore", "FileCheckpointStore", "create_checkpoint",
5757
"EthModule", "Ethereum", "EvmCall",

‎bridge-sdk/python/aleo_bridge/client.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
from .cctp import CctpModule
2121
from .errors import BridgeError, ConfigurationError, UnsupportedRouteError
2222
from .eth import Ethereum, EthModule
23-
from .freezelist import FreezeList, ComplianceProofs
23+
from .freezelist import ComplianceProofs, FreezeList
2424
from .hyperlane import HyperlaneModule
2525
from .privacy import PrivacyModule
2626
from .profile import DEFAULT_ENDPOINT, Profile
@@ -268,7 +268,7 @@ def shield(self, asset: Any, *, amount: Any = None, amount_atomic: int | None =
268268
return self.privacy.shield(asset, amount=amount, amount_atomic=amount_atomic, recipient=recipient)
269269

270270
def unshield(self, asset: Any, *, amount: Any = None, amount_atomic: int | None = None, record: str | None = None,
271-
compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None = None, merkle_proof: str | None = None,
271+
compliance_proofs: ComplianceProofs = None, merkle_proof: str | None = None,
272272
recipient: str | None = None) -> AleoCall[PrivacyReceipt]:
273273
"""Move a private record into the public balance; see ``privacy.unshield``.
274274
@@ -377,7 +377,7 @@ def quote(self, *, source_chain: str | None = None, source_asset: str | None = N
377377
mint_mode=mint_mode, secret_nonce=secret_nonce, **({"cctp": cctp} if cctp is not None else {}))
378378

379379
def execute(self, plan, *, on_checkpoint=None, proving: str = "delegate", mode: str | None = None,
380-
record: str | None = None, compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None = None,
380+
record: str | None = None, compliance_proofs: ComplianceProofs = None,
381381
merkle_proof: str | None = None,
382382
gas_payment_microcredits: int | None = None, secret_nonce: str | None = None,
383383
poll_seconds: float = 1.0, timeout_seconds: float = 120.0):

‎bridge-sdk/python/aleo_bridge/freezelist.py‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
FrozenAddressError,
2626
MerkleProofInput,
2727
MerkleProofPair,
28-
ComplianceProofs,
28+
ComplianceProof,
2929
address_to_field_int,
3030
build_tree,
3131
format_merkle_proof,
@@ -41,11 +41,15 @@
4141
if TYPE_CHECKING: # pragma: no cover
4242
from .client import Bridge
4343

44+
#: The ``compliance_proofs`` argument of a bridge call, which takes exactly one proof: a
45+
#: :data:`ComplianceProof` bare or in a one-tuple, or ``None`` to have the SDK build it.
46+
ComplianceProofs = ComplianceProof | tuple[ComplianceProof] | None
47+
4448
#: Token program -> its freeze-list program, for when ``Bridge.program(token).imports`` is unavailable.
4549
FREEZE_LIST_PROGRAMS = {program: freezelist for program, freezelist in KNOWN_TOKEN_FREEZELISTS.items() if freezelist}
4650

4751

48-
def literal_compliance_proof(compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None, merkle_proof: str | None) -> str | None:
52+
def literal_compliance_proof(compliance_proofs: ComplianceProofs, merkle_proof: str | None) -> str | None:
4953
"""The single ``[MerkleProof; 2]`` literal a bridge call was given, or ``None`` to compute one.
5054
5155
Raises:
@@ -150,6 +154,6 @@ def exclusion_proof(self, address: str, program: str) -> str:
150154
__all__ = ["CURRENT_ROOT_KEY", "DEFAULT_DEPTH", "EMPTY_MERKLE_PROOF_PAIR", "EMPTY_TREE_ROOT",
151155
"FREEZE_LIST_INDEX_MAPPING", "FREEZE_LIST_LAST_INDEX_MAPPING", "FREEZE_LIST_MAPPING",
152156
"FREEZE_LIST_PROGRAMS", "FREEZE_LIST_ROOT_MAPPING", "PROOF_SIBLINGS", "ZERO_ADDRESS", "FreezeList",
153-
"FreezeListError", "FrozenAddressError", "MerkleProofInput", "MerkleProofPair", "ComplianceProofs",
157+
"FreezeListError", "FrozenAddressError", "MerkleProofInput", "MerkleProofPair", "ComplianceProof", "ComplianceProofs",
154158
"address_to_field_int", "build_tree", "format_merkle_proof", "generate_leaves", "hash_two",
155159
"leaf_indices", "literal_compliance_proof", "sibling_path"]

‎bridge-sdk/python/aleo_bridge/privacy.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import re
66
from typing import TYPE_CHECKING, Any
77

8-
from aleo.compliance import ComplianceProofs
8+
from .freezelist import ComplianceProofs
99

1010
from ._calls import AleoCall
1111
from .errors import ConfigurationError, InsufficientBalanceError, InvalidAmountError, InvalidRecipientError, UnsupportedRouteError
@@ -107,7 +107,7 @@ def build(tx_id: str, _outputs: list[str]) -> PrivacyReceipt:
107107
return self._bridge._call(privacy.program, function, inputs, build)
108108

109109
def unshield(self, asset: Any, *, amount: Any = None, amount_atomic: int | None = None, record: str | None = None,
110-
compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None = None, merkle_proof: str | None = None,
110+
compliance_proofs: ComplianceProofs = None, merkle_proof: str | None = None,
111111
recipient: str | None = None) -> AleoCall[PrivacyReceipt]:
112112
"""Move a private record into the public balance.
113113

‎bridge-sdk/python/aleo_bridge/xreserve.py‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@
66
from typing import TYPE_CHECKING, Any
77

88
import requests
9-
from aleo.compliance import ComplianceProofs
109

1110
from . import encoding as enc
1211
from ._calls import AleoCall
1312
from ._keccak import keccak256
1413
from .circle import CircleClient
15-
from .freezelist import literal_compliance_proof
14+
from .freezelist import ComplianceProofs, literal_compliance_proof
1615
from .errors import (AttestationError, ConfigurationError, InvalidAmountError, InvalidRecipientError,
1716
RouteNotFoundError, RouteUnavailableError, UnsupportedRouteError)
1817
from .registry import Route
@@ -138,7 +137,7 @@ def build_burn_inputs(self, route: Route, *, mode: str, amount_atomic: int, reci
138137
return route.meta_str("bridgeProgram"), function, [amount_lit, domain_lit, recipient_lit]
139138

140139
def burn(self, recipient: str, *, amount: Any = None, amount_atomic: int | None = None, mode: str = "private",
141-
record: str | None = None, compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None = None,
140+
record: str | None = None, compliance_proofs: ComplianceProofs = None,
142141
merkle_proof: str | None = None, route: Route | None = None) -> AleoCall[BurnReceipt]:
143142
"""Burn USDCx for USDC on the selected EVM route (Ethereum by default).
144143
@@ -157,7 +156,7 @@ def burn(self, recipient: str, *, amount: Any = None, amount_atomic: int | None
157156

158157
def _burn(self, recipient: str, *, amount: Any = None, amount_atomic: int | None = None,
159158
mode: str = "private", record: str | None = None,
160-
compliance_proofs: ComplianceProofs | tuple[ComplianceProofs] | None = None, merkle_proof: str | None = None,
159+
compliance_proofs: ComplianceProofs = None, merkle_proof: str | None = None,
161160
route: Route | None = None, withdrawal_fee_atomic: int | None = None) -> AleoCall[BurnReceipt]:
162161
"""Build a burn with the lifecycle's validated execution-time estimate, if supplied."""
163162
if mode not in BURN_MODES:

‎sdk/python/aleo/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
FrozenAddressError as FrozenAddressError,
3838
MerkleProofInput as MerkleProofInput,
3939
MerkleProofPair as MerkleProofPair,
40-
ComplianceProofs as ComplianceProofs,
40+
ComplianceProof as ComplianceProof,
4141
ComplianceProofContext as ComplianceProofContext,
4242
)
4343
from .facade.errors import (

‎sdk/python/aleo/compliance.py‎

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -264,9 +264,11 @@ def from_string(cls, text: str) -> "MerkleProofPair":
264264
return cls(MerkleProofInput.from_string(parts[0]), MerkleProofInput.from_string(parts[1]))
265265

266266

267-
#: One compliance proof argument as a caller may supply it: the ``[MerkleProof; 2]``
267+
#: One compliance proof as a caller may supply it: the ``[MerkleProof; 2]``
268268
#: literal, a :class:`MerkleProofPair`, or the two :class:`MerkleProofInput` paths.
269-
ComplianceProofs = str | MerkleProofPair | tuple[MerkleProofInput, MerkleProofInput]
269+
#: A call's ``compliance_proofs`` argument holds one or more of these (see the
270+
#: ``ComplianceProofs`` alias of each SDK package).
271+
ComplianceProof = str | MerkleProofPair | tuple[MerkleProofInput, MerkleProofInput]
270272

271273

272274
def format_merkle_proof_pair(pair: MerkleProofPair | tuple[MerkleProofInput, MerkleProofInput]) -> str:
@@ -278,7 +280,7 @@ def format_merkle_proof_pair(pair: MerkleProofPair | tuple[MerkleProofInput, Mer
278280
raise FreezeListError("A proof pair is a MerkleProofPair or a (MerkleProofInput, MerkleProofInput) tuple")
279281

280282

281-
def _bundle_literal(bundle: ComplianceProofs) -> str:
283+
def _bundle_literal(bundle: ComplianceProof) -> str:
282284
"""The ``[MerkleProof; 2]`` literal for one caller-supplied bundle, validated."""
283285
if isinstance(bundle, str):
284286
text = bundle.strip()
@@ -295,7 +297,7 @@ def literal_compliance_proof(compliance_proofs: Any, legacy: Any = None, *, lega
295297
"""The one ``[MerkleProof; 2]`` literal a call was given, or ``None`` when the SDK should build it.
296298
297299
Normalises the proof arguments of a call that takes exactly one bundle:
298-
a :data:`ComplianceProofs` or a one-element tuple of one under
300+
a :data:`ComplianceProof` or a one-element tuple of one under
299301
``compliance_proofs``, and the literal string the call accepted before
300302
under its old keyword. Reads nothing from the chain.
301303
@@ -315,11 +317,11 @@ def literal_compliance_proof(compliance_proofs: Any, legacy: Any = None, *, lega
315317
if isinstance(compliance_proofs, tuple):
316318
items = cast(tuple[Any, ...], compliance_proofs)
317319
if _is_path_tuple(items):
318-
return _bundle_literal(cast(ComplianceProofs, items))
320+
return _bundle_literal(cast(ComplianceProof, items))
319321
if len(items) != 1:
320322
raise FreezeListError(f"This operation requires exactly one compliance proof bundle; received {len(items)}")
321-
return _bundle_literal(cast(ComplianceProofs, items[0]))
322-
return _bundle_literal(cast(ComplianceProofs, compliance_proofs))
323+
return _bundle_literal(cast(ComplianceProof, items[0]))
324+
return _bundle_literal(cast(ComplianceProof, compliance_proofs))
323325

324326

325327
def _is_path_tuple(value: Any) -> bool:
@@ -713,7 +715,7 @@ def _network_module(network: str) -> Any:
713715
"FREEZE_LIST_INDEX_MAPPING", "FREEZE_LIST_LAST_INDEX_MAPPING", "FREEZE_LIST_MAPPING", "FREEZE_LIST_ROOT_MAPPING",
714716
"KNOWN_TOKEN_FREEZELISTS", "PROOF_SIBLINGS", "ZERO_ADDRESS",
715717
"AsyncFreezeListProofs", "FreezeListError", "FreezeListProofs", "FrozenAddressError",
716-
"ComplianceProofContext", "MerkleProofInput", "MerkleProofPair", "ComplianceProofs",
718+
"ComplianceProofContext", "MerkleProofInput", "MerkleProofPair", "ComplianceProof",
717719
"address_to_field_int", "async_freezelist_program", "build_tree", "format_merkle_proof",
718720
"format_merkle_proof_pair", "freezelist_from_imports", "freezelist_program", "generate_freezelist_proof",
719721
"generate_leaves", "hash_two", "leaf_indices", "literal_compliance_proof", "sibling_path",

‎shield-swap-sdk/python/aleo_shield_swap/__init__.py‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,12 @@
2525
from .compliance import (
2626
ClaimProofs as ClaimProofs,
2727
CollectProofs as CollectProofs,
28+
ComplianceProof as ComplianceProof,
29+
ComplianceProofs as ComplianceProofs,
2830
IncreaseProofs as IncreaseProofs,
2931
MerkleProofInput as MerkleProofInput,
3032
MerkleProofPair as MerkleProofPair,
3133
MintProofs as MintProofs,
32-
ComplianceProofs as ComplianceProofs,
3334
RebalanceProofs as RebalanceProofs,
3435
SHIELD_SWAP_FREEZELIST as SHIELD_SWAP_FREEZELIST,
3536
SwapProofs as SwapProofs,

0 commit comments

Comments
 (0)