armachain 0.3.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.
armachain/__init__.py ADDED
@@ -0,0 +1,173 @@
1
+ """
2
+ ArmaChain Python SDK
3
+ Official Python SDK for ArmaChain -- independent L1 blockchain with integrated CEX-grade DEX.
4
+
5
+ v0.2.0 additions (the feature signed-order path):
6
+ - ``signing.py``: ML-DSA-65 and ECDSA signing primitives
7
+ - ``OrderCanonicalFields``: Borsh-serializable order canonical (88 bytes)
8
+ - ``AmendSigningPayload``: Borsh-serializable amend signing scope (126 bytes)
9
+ - ``sign_order_mldsa65``, ``sign_amend_mldsa65``: signing helpers
10
+ - ``derive_pq_address``, ``keypair_from_seed``: key management
11
+ - ``compute_stable_id``: size-excluded order identity helper
12
+ - ``DexModule.get_expected_nonce``: nonce fetcher
13
+ - ``DexModule.submit_signed_batch_orders``: The feature batch submission
14
+ - ``DexModule.amend_order_signed``: The feature in-place size-DOWN amend (PUT)
15
+ - ``HttpClient.put``: HTTP PUT support
16
+
17
+ Additions (cancel by stable id):
18
+ - ``CancelSigningPayload``: Borsh-serializable cancel signing scope (118 bytes)
19
+ - ``sign_cancel_mldsa65``, ``verify_cancel_mldsa65``: cancel signing helpers
20
+ - ``DexModule.cancel_order_by_stable_id``: version-2 cancel by the order's
21
+ ``stable_id`` (the order-create response returns it), which reaches a
22
+ partially filled perp order; ``DexModule.cancel_order_signed`` for either version
23
+ - ``HttpClient.delete(path, json)``: DELETE with a JSON body
24
+ """
25
+
26
+ from .account import AccountLike, account_bytes, account_hex
27
+ from .bridge import BridgeModule
28
+ from .client import ArmaChainClient
29
+ from .dex import DexModule
30
+ from .explorer import ExplorerModule
31
+ from .http import ArmaChainError, HttpClient
32
+ from .oracle import OracleModule
33
+ from .rpc import RpcModule
34
+ from .signing import (
35
+ CANCEL_VERSION_BY_ORDER_ID,
36
+ CANCEL_VERSION_BY_STABLE_ID,
37
+ AmendSigningPayload,
38
+ CancelSigningPayload,
39
+ OrderCanonicalFields,
40
+ build_signed_order_dict,
41
+ compute_stable_id,
42
+ derive_pq_address,
43
+ generate_keypair,
44
+ keypair_from_seed,
45
+ sign_amend_mldsa65,
46
+ sign_cancel_mldsa65,
47
+ sign_order_mldsa65,
48
+ verify_amend_mldsa65,
49
+ verify_cancel_mldsa65,
50
+ verify_order_mldsa65,
51
+ )
52
+ from .network_binding import ( # noqa: E402
53
+ NetworkBindingError,
54
+ eip191_action_message_v2,
55
+ fetch_network_id,
56
+ json_message_with_network,
57
+ native_tx_hash_v2,
58
+ parse_network_id,
59
+ pq_domain_hash_v2,
60
+ reward_payout_text_v2,
61
+ )
62
+ from .spot import SpotModule
63
+ from .staking import StakingModule
64
+ from .tokenomics import TokenomicsModule
65
+
66
+ __version__ = "0.3.0"
67
+
68
+ __all__ = [
69
+ "AccountLike", "account_bytes", "account_hex",
70
+ # Client
71
+ "ArmaChainClient",
72
+ "ArmaChainError",
73
+ "HttpClient",
74
+ # Modules
75
+ "RpcModule",
76
+ "DexModule",
77
+ "SpotModule",
78
+ "OracleModule",
79
+ "BridgeModule",
80
+ "StakingModule",
81
+ "TokenomicsModule",
82
+ "ExplorerModule",
83
+ # Signing primitives (v0.2.0)
84
+ "OrderCanonicalFields",
85
+ "AmendSigningPayload",
86
+ "sign_order_mldsa65",
87
+ "sign_amend_mldsa65",
88
+ "verify_order_mldsa65",
89
+ "verify_amend_mldsa65",
90
+ "derive_pq_address",
91
+ "keypair_from_seed",
92
+ "generate_keypair",
93
+ "pq_domain_hash_v2",
94
+ "NetworkBindingError", "eip191_action_message_v2", "fetch_network_id", "json_message_with_network",
95
+ "native_tx_hash_v2", "parse_network_id", "reward_payout_text_v2",
96
+ "compute_stable_id",
97
+ "build_signed_order_dict",
98
+ # signed cancel, including the version-2 cancel by stable id
99
+ "CancelSigningPayload",
100
+ "CANCEL_VERSION_BY_ORDER_ID",
101
+ "CANCEL_VERSION_BY_STABLE_ID",
102
+ "sign_cancel_mldsa65",
103
+ "verify_cancel_mldsa65",
104
+ ]
105
+
106
+ from .money import (build_signed_money, deposit_v3_payload, withdraw_v3_payload, bridge_v3_payload,
107
+ funded_faucet_v3_payload, funded_faucet_entry)
108
+ __all__ += ["build_signed_money", "deposit_v3_payload", "withdraw_v3_payload", "bridge_v3_payload", "funded_faucet_v3_payload", "funded_faucet_entry"]
109
+
110
+
111
+ from . import timestamped_signing # noqa: E402
112
+ from .timestamped_signing import ( # noqa: E402
113
+ ChainClock,
114
+ ChainClockError,
115
+ TimestampedSigningDetectError,
116
+ build_signed_withdrawal_v3,
117
+ classify_timestamped_signing_refusal,
118
+ fetch_timestamped_signing_active,
119
+ is_timestamped_signing_active,
120
+ plan_place_order_signing,
121
+ sign_order_v3_mldsa65,
122
+ )
123
+
124
+ __all__ += [
125
+ "the feature", "ChainClock", "ChainClockError", "TimestampedSigningDetectError", "build_signed_withdrawal_v3",
126
+ "classify_timestamped_signing_refusal", "fetch_timestamped_signing_active", "is_timestamped_signing_active", "plan_place_order_signing",
127
+ "sign_order_v3_mldsa65",
128
+ ]
129
+
130
+ from .nonce_guard import NonceGapOpenError, NonceGateUnconfirmedError, NonceGuard # noqa: E402
131
+
132
+ __all__ += ["NonceGapOpenError", "NonceGateUnconfirmedError", "NonceGuard"]
133
+
134
+ from .order_outcome import ( # noqa: E402
135
+ CANCELLED_IN_BATCH,
136
+ ORDER_OUTCOME_CODES,
137
+ is_cancelled_in_batch,
138
+ is_known_outcome_code,
139
+ is_order_outcome_terminal,
140
+ parse_order_queue,
141
+ parse_queued_at_ms,
142
+ )
143
+
144
+ __all__ += [
145
+ "CANCELLED_IN_BATCH", "ORDER_OUTCOME_CODES", "is_cancelled_in_batch", "is_known_outcome_code",
146
+ "is_order_outcome_terminal", "parse_order_queue", "parse_queued_at_ms",
147
+ ]
148
+
149
+ from .account_actions import (create_sub_payload, dex_transfer_payload, derive_sub_address,
150
+ typed_data as account_action_typed_data, action_digest, action_body, action_entry, action_tx_hash, build_signed_action)
151
+ __all__ += ["create_sub_payload","dex_transfer_payload","derive_sub_address","account_action_typed_data",
152
+ "action_digest","action_body","action_entry","action_tx_hash","build_signed_action"]
153
+
154
+ from .transfer_receipts import TransferExpectation, ReceiptEffects, parse_transfer, parse_history
155
+ __all__ += ["TransferExpectation","ReceiptEffects","parse_transfer","parse_history"]
156
+
157
+ from .master_trade import (MasterTrade, build_master_trade, canonical_master_inner, encode_master_trade, decode_master_trade, sign_master_trade, submit_master_trade)
158
+ __all__ += ["MasterTrade","build_master_trade","canonical_master_inner","encode_master_trade","decode_master_trade","sign_master_trade","submit_master_trade"]
159
+
160
+ from .signed_read import selected_account_read_query
161
+ __all__ += ["selected_account_read_query"]
162
+
163
+ from .master_trade import unsigned_master_trade_action
164
+ __all__ += ["unsigned_master_trade_action"]
165
+
166
+ from .order_outcome import parse_outcome_account_context
167
+ __all__ += ["parse_outcome_account_context"]
168
+
169
+ from .order_outcome import (ORDER_OUTCOME_KINDS, NONTRADE_BUDGET_CODES, is_order_outcome_kind, stored_outcome_kind, outcome_kind_for_wire, parse_nontrade_budget_outcome)
170
+ __all__ += ["ORDER_OUTCOME_KINDS","NONTRADE_BUDGET_CODES","is_order_outcome_kind","stored_outcome_kind","outcome_kind_for_wire","parse_nontrade_budget_outcome"]
171
+
172
+ from .purchase34 import ReserveRequestWeightV3,encode_purchase34,decode_purchase34,sign_purchase34
173
+ __all__ += ["ReserveRequestWeightV3","encode_purchase34","decode_purchase34","sign_purchase34"]
armachain/account.py ADDED
@@ -0,0 +1,40 @@
1
+ """Full 20-byte account ABI; no registry or numeric identity conversion."""
2
+ import re
3
+ from typing import Union
4
+
5
+ AccountLike = Union[str, bytes]
6
+
7
+
8
+ def account_bytes(value: AccountLike, *, user: bool = True) -> bytes:
9
+ if isinstance(value, str):
10
+ if not re.fullmatch(r"0x[0-9a-fA-F]{40}", value):
11
+ raise ValueError("account must be 0x followed by 40 hexadecimal digits")
12
+ raw = bytes.fromhex(value[2:])
13
+ elif isinstance(value, bytes):
14
+ raw = value
15
+ else:
16
+ raise ValueError("account must be a hexadecimal string or 20 raw bytes")
17
+ if len(raw) != 20:
18
+ raise ValueError("account must be exactly 20 bytes")
19
+ if user and (raw == bytes(20) or raw[:18] == b"\xa7" + bytes(17)):
20
+ raise ValueError("zero and system accounts cannot be user accounts")
21
+ return raw
22
+
23
+
24
+ def account_hex(value: AccountLike, *, user: bool = True) -> str:
25
+ return "0x" + account_bytes(value, user=user).hex()
26
+
27
+
28
+ def parse_account_fields(value):
29
+ """Validate AccountKey JSON response fields, retaining internal system identities.
30
+
31
+ Reader decoding is deliberately distinct from user admission. Numbers and byte
32
+ lists are never an AccountKey JSON representation, even in error envelopes.
33
+ """
34
+ if isinstance(value, dict):
35
+ return {key: (account_hex(item, user=False) if key in ("trader_id", "traderId")
36
+ and item is not None else parse_account_fields(item))
37
+ for key, item in value.items()}
38
+ if isinstance(value, list):
39
+ return [parse_account_fields(item) for item in value]
40
+ return value
@@ -0,0 +1,186 @@
1
+ """Actions35/36: exact full-address codecs and offline two-scheme signing.
2
+
3
+ Identity authenticity is distinct from current-prefix money/Sub authorization.
4
+ The network id N is required everywhere: it derives Sub
5
+ addresses, it is bound into the ML-DSA domain hash (v2), and it IS the EIP-712
6
+ domain salt. It is never guessed from chain ID. No quota equation here.
7
+ """
8
+ import re
9
+ from typing import Callable, Optional
10
+ import blake3
11
+ from Crypto.Hash import keccak
12
+
13
+ from .account import account_bytes, account_hex
14
+ from .money import _fixed, _uint, canonical_amount
15
+ from .withdrawal_signing import exact_uint
16
+ from .signing import (PQ_PUBKEY_SIZE, PQ_SIGNATURE_SIZE, PQ_SECRET_KEY_SIZE,
17
+ derive_pq_address, _dilithium3_sign)
18
+ from .network_binding import pq_domain_hash_v2, require_network_id
19
+
20
+ CREATE_DOMAIN = b"ARMA_DEX_CREATE_SUB_ACCOUNT_V3:"
21
+ TRANSFER_DOMAIN = b"ARMA_DEX_TRANSFER_V3:"
22
+ CREATE_TYPE = "CreateSubAccountV3(uint8 version,uint64 chainId,uint64 nonce,address submitter,uint32 index,uint32 feeAsset,uint128 maxOpenFee,uint64 timestampMs,uint64 expiresAtMs)"
23
+ TRANSFER_TYPE = "DexTransferV3(uint8 version,uint64 chainId,uint64 nonce,address submitter,bool vaultPresent,address vaultAddress,address beneficiary,uint32 asset,uint128 amount,uint128 maxOpenFee,uint64 timestampMs,uint64 expiresAtMs,bytes32 sourceRef)"
24
+ DOMAIN_TYPE = "EIP712Domain(string name,string version,uint256 chainId,bytes32 salt)"
25
+ CREATE_FIELDS = {"version","chain_id","nonce","submitter","index","fee_asset","max_open_fee","timestamp_ms","expires_at_ms"}
26
+ TRANSFER_FIELDS = {"version","chain_id","nonce","submitter","vault_address","beneficiary","asset","amount","max_open_fee","timestamp_ms","expires_at_ms","source_ref"}
27
+
28
+
29
+ def _keccak(raw: bytes) -> bytes:
30
+ return keccak.new(digest_bits=256,data=raw).digest()
31
+
32
+
33
+ def _amount(value) -> int:
34
+ if isinstance(value,str):
35
+ if not re.fullmatch(r"0|[1-9][0-9]{0,38}",value):
36
+ raise ValueError("invalid canonical atomic amount")
37
+ value=int(value)
38
+ return exact_uint(value,128,"amount")
39
+
40
+
41
+ def _asset(value: int) -> bytes:
42
+ # Existing DexAssetId::COUNT; no new assets or fee conversion.
43
+ exact_uint(value,32,"asset")
44
+ if value >= 4:
45
+ raise ValueError("unsupported asset")
46
+ return _uint(value,32)
47
+
48
+
49
+ def _prefix(fields: dict, expected: set) -> bytes:
50
+ if set(fields) != expected or type(fields["version"]) is not int or fields["version"] != 3:
51
+ raise ValueError("only exact version-3 address action fields are accepted")
52
+ if type(fields["chain_id"]) is not int or fields["chain_id"] != 2028:
53
+ raise ValueError("chain id must be 2028")
54
+ return b"\x03"+_uint(fields["chain_id"],64)+_uint(fields["nonce"],64)+account_bytes(fields["submitter"])
55
+
56
+
57
+ def create_sub_payload(**fields) -> bytes:
58
+ prefix=_prefix(fields,CREATE_FIELDS)
59
+ return (prefix+_uint(fields["index"],32)+_asset(fields["fee_asset"])
60
+ +_uint(_amount(fields["max_open_fee"]),128)+_uint(fields["timestamp_ms"],64)
61
+ +_uint(fields["expires_at_ms"],64))
62
+
63
+
64
+ def dex_transfer_payload(**fields) -> bytes:
65
+ prefix=_prefix(fields,TRANSFER_FIELDS)
66
+ vault=fields["vault_address"]
67
+ if vault is not None and account_bytes(vault)==account_bytes(fields["submitter"]):
68
+ raise ValueError("vault must differ from signer")
69
+ amount=canonical_amount(fields["amount"])
70
+ if amount+_amount(fields["max_open_fee"]) >= 1 << 128:
71
+ raise ValueError("transfer total overflows")
72
+ return (prefix+(b"\x00" if vault is None else b"\x01"+account_bytes(vault))
73
+ +account_bytes(fields["beneficiary"])+_asset(fields["asset"])+_uint(amount,128)
74
+ +_uint(_amount(fields["max_open_fee"]),128)+_uint(fields["timestamp_ms"],64)
75
+ +_uint(fields["expires_at_ms"],64)+_fixed(fields["source_ref"],32))
76
+
77
+
78
+ def derive_sub_address(trusted_network: bytes, master, index: int) -> str:
79
+ """N must come from an independently trusted local network identity."""
80
+ digest=_keccak(b"ArmaChain dex-subaccount v1"+_fixed(trusted_network,32)
81
+ +account_bytes(master)+exact_uint(index,32,"index").to_bytes(4,"big"))
82
+ return account_hex(digest[12:])
83
+
84
+
85
+ def domain_separator(network_id: bytes, chain_id: int=2028) -> bytes:
86
+ """EIP-712 domain; the salt is the network id N (the feature ON)."""
87
+ if type(chain_id) is not int or chain_id != 2028:
88
+ raise ValueError("chain id must be 2028")
89
+ return _keccak(_keccak(DOMAIN_TYPE.encode())+_keccak(b"ArmaChain")+_keccak(b"1")
90
+ +chain_id.to_bytes(32,"big")+require_network_id(network_id))
91
+
92
+
93
+ def _action(kind: str):
94
+ if kind=="create_sub_account":
95
+ return create_sub_payload,CREATE_DOMAIN,CREATE_TYPE,35
96
+ if kind=="dex_transfer":
97
+ return dex_transfer_payload,TRANSFER_DOMAIN,TRANSFER_TYPE,36
98
+ raise ValueError("unknown account action")
99
+
100
+
101
+ def typed_data(kind: str, network_id: bytes, **fields) -> dict:
102
+ encoder,_,typ,_=_action(kind)
103
+ encoder(**fields)
104
+ message={"version":3,"chainId":2028,"nonce":fields["nonce"],
105
+ "submitter":account_hex(fields["submitter"]),"maxOpenFee":str(_amount(fields["max_open_fee"])),
106
+ "timestampMs":fields["timestamp_ms"],"expiresAtMs":fields["expires_at_ms"]}
107
+ if kind=="create_sub_account":
108
+ message.update(index=fields["index"],feeAsset=fields["fee_asset"])
109
+ else:
110
+ vault=fields["vault_address"]
111
+ message.update(vaultPresent=vault is not None,
112
+ vaultAddress="0x"+bytes(20).hex() if vault is None else account_hex(vault),
113
+ beneficiary=account_hex(fields["beneficiary"]),asset=fields["asset"],
114
+ amount=str(canonical_amount(fields["amount"])),sourceRef="0x"+fields["source_ref"].hex())
115
+ primary=typ.split("(")[0]
116
+ members=[dict(type=a.split()[0],name=a.split()[1]) for a in typ.split("(")[1][:-1].split(",")]
117
+ return dict(types={"EIP712Domain":[dict(name=n,type=t) for n,t in
118
+ [("name","string"),("version","string"),("chainId","uint256"),("salt","bytes32")]],primary:members},
119
+ primaryType=primary,domain=dict(name="ArmaChain",version="1",chainId=2028,salt="0x"+_fixed(network_id,32).hex()),message=message)
120
+
121
+
122
+ def struct_hash(kind: str, **fields) -> bytes:
123
+ data=typed_data(kind,bytes(32),**fields)
124
+ _,_,typ,_=_action(kind)
125
+ words=[_keccak(typ.encode())]
126
+ for member in data["types"][data["primaryType"]]:
127
+ value=data["message"][member["name"]];t=member["type"]
128
+ if t=="address":words.append(bytes(12)+bytes.fromhex(value[2:]))
129
+ elif t=="bytes32":words.append(bytes.fromhex(value[2:]))
130
+ else:words.append(int(value).to_bytes(32,"big"))
131
+ return _keccak(b"".join(words))
132
+
133
+
134
+ def action_digest(kind: str, scheme: int, *, network_id: Optional[bytes]=None, **fields) -> bytes:
135
+ encoder,domain,_,_=_action(kind);payload=encoder(**fields)
136
+ if type(scheme) is not int or scheme not in (0,2):
137
+ raise ValueError("unsupported signature scheme")
138
+ network_id=require_network_id(network_id)
139
+ if scheme==0:return pq_domain_hash_v2(domain,fields["chain_id"],network_id,payload)
140
+ return _keccak(b"\x19\x01"+domain_separator(network_id)+struct_hash(kind,**fields))
141
+
142
+
143
+ def action_body(kind: str, *, signature_scheme: int, signature: bytes, pubkey: bytes, **fields) -> bytes:
144
+ encoder,_,_,_=_action(kind);payload=encoder(**fields)
145
+ if type(signature_scheme) is not int or signature_scheme not in (0,2):
146
+ raise ValueError("unsupported signature scheme")
147
+ _fixed(signature,3309 if signature_scheme==0 else 65)
148
+ _fixed(pubkey,1952 if signature_scheme==0 else 0)
149
+ return payload+bytes([signature_scheme])+_uint(len(signature),32)+signature+_uint(len(pubkey),32)+pubkey
150
+
151
+
152
+ def action_tx_hash(kind: str, scheme: int, **fields) -> str:
153
+ encoder,domain,_,_=_action(kind);payload=encoder(**fields)
154
+ if type(scheme) is not int or scheme not in (0,2):raise ValueError("unsupported signature scheme")
155
+ return "0x"+blake3.blake3(domain+payload+bytes([scheme])).hexdigest()
156
+
157
+
158
+ def build_signed_action(kind: str, *, signature_scheme: int, public_key: bytes=b"",
159
+ secret_key: Optional[bytes]=None, signer: Optional[Callable[[bytes],bytes]]=None,
160
+ network_id: Optional[bytes]=None, **fields) -> dict:
161
+ digest=action_digest(kind,signature_scheme,network_id=network_id,**fields)
162
+ if (secret_key is None)==(signer is None):raise ValueError("provide exactly one signer")
163
+ if signature_scheme==0:
164
+ _fixed(public_key,PQ_PUBKEY_SIZE)
165
+ if derive_pq_address(public_key)!=account_bytes(fields["submitter"]):raise ValueError("public key does not derive submitter")
166
+ signature=(_dilithium3_sign(digest,_fixed(secret_key,PQ_SECRET_KEY_SIZE)) if secret_key is not None else signer(digest))
167
+ else:
168
+ from eth_keys import keys
169
+ from .timestamped_signing import normalize_ecdsa_signature
170
+ _fixed(public_key,0)
171
+ signature=(keys.PrivateKey(_fixed(secret_key,32)).sign_msg_hash(digest).to_bytes() if secret_key is not None else signer(digest))
172
+ signature=normalize_ecdsa_signature(signature)
173
+ recovered=keys.Signature(signature_bytes=signature[:64]+bytes([signature[64]-27])).recover_public_key_from_msg_hash(digest).to_canonical_address()
174
+ if recovered!=account_bytes(fields["submitter"]):raise ValueError("signature does not derive submitter")
175
+ action_body(kind,signature_scheme=signature_scheme,signature=signature,pubkey=public_key,**fields)
176
+ body=dict(fields,submitter=account_hex(fields["submitter"]),max_open_fee=str(_amount(fields["max_open_fee"])),
177
+ signature_scheme=signature_scheme,signature=signature.hex(),pubkey=public_key.hex())
178
+ if kind=="dex_transfer":
179
+ body.update(vault_address=None if fields["vault_address"] is None else account_hex(fields["vault_address"]),
180
+ beneficiary=account_hex(fields["beneficiary"]),amount=str(canonical_amount(fields["amount"])),source_ref="0x"+fields["source_ref"].hex())
181
+ return body
182
+
183
+
184
+ def action_entry(kind: str, **fields) -> bytes:
185
+ """Final outer DEX tag35/36 and bounded two-scheme body."""
186
+ return bytes([_action(kind)[3]])+action_body(kind,**fields)
armachain/bridge.py ADDED
@@ -0,0 +1,36 @@
1
+ """
2
+ ArmaChain SDK -- Bridge Module
3
+ Cross-chain transfer status, initiation, tracking.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Any, Dict
9
+
10
+ from .http import HttpClient
11
+ from .network_binding import fetch_network_id
12
+
13
+
14
+ class BridgeModule:
15
+ """Bridge methods -- cross-chain transfers, status."""
16
+
17
+ def __init__(self, http: HttpClient) -> None:
18
+ self._http = http
19
+
20
+ async def network_id(self, pin: Any = None) -> bytes:
21
+ """The 32-byte network id every the feature v2 signature binds: ``/health`` ``dex_bridge_network_id``.
22
+ Raises ``NetworkBindingError`` when absent, malformed, all-zero or different from ``pin``."""
23
+ return await fetch_network_id(self._http.get, pin)
24
+
25
+ async def get_status(self) -> Dict[str, Any]:
26
+ """Get bridge status -- pause state, pending transfers, totals."""
27
+ return await self._http.get("/api/bridge/status")
28
+
29
+ async def get_transfer(self, tx_hash: str) -> Dict[str, Any]:
30
+ """
31
+ Get transfer details by transaction hash.
32
+
33
+ Args:
34
+ tx_hash: Bridge transfer hash
35
+ """
36
+ return await self._http.get(f"/api/bridge/transfers/{tx_hash}")
armachain/client.py ADDED
@@ -0,0 +1,96 @@
1
+ """
2
+ ArmaChain SDK -- Main Client
3
+ Wraps all API modules under a single entry point.
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ from typing import Optional
9
+
10
+ from .bridge import BridgeModule
11
+ from .dex import DexModule
12
+ from .explorer import ExplorerModule
13
+ from .http import HttpClient
14
+ from .oracle import OracleModule
15
+ from .rpc import RpcModule
16
+ from .spot import SpotModule
17
+ from .staking import StakingModule
18
+ from .tokenomics import TokenomicsModule
19
+
20
+ DEFAULT_API_URL = "https://api.armascan.io"
21
+ DEFAULT_RPC_URL = "https://rpc.armascan.io"
22
+ DEFAULT_TIMEOUT = 10.0
23
+
24
+
25
+ class ArmaChainClient:
26
+ """
27
+ Main ArmaChain SDK client.
28
+
29
+ Wraps all API modules under a single entry point with typed sub-clients.
30
+
31
+ Example::
32
+
33
+ from armachain import ArmaChainClient
34
+
35
+ client = ArmaChainClient()
36
+
37
+ # RPC methods
38
+ height = await client.rpc.get_block_number()
39
+ balance = await client.rpc.get_balance("0x...")
40
+
41
+ # DEX trading
42
+ orderbook = await client.dex.get_orderbook(0)
43
+ positions = await client.dex.get_positions("0x...")
44
+
45
+ # Spot trading
46
+ markets = await client.spot.get_markets()
47
+
48
+ # Oracle prices
49
+ prices = await client.oracle.get_prices()
50
+
51
+ # Bridge status
52
+ bridge = await client.bridge.get_status()
53
+
54
+ # Tokenomics
55
+ fees = await client.tokenomics.get_fee_schedule()
56
+ burns = await client.tokenomics.get_burn_stats()
57
+
58
+ # Staking
59
+ validators = await client.staking.get_validators()
60
+
61
+ # Explorer
62
+ batch = await client.explorer.get_batch(12345)
63
+ """
64
+
65
+ def __init__(
66
+ self,
67
+ api_url: str = DEFAULT_API_URL,
68
+ rpc_url: str = DEFAULT_RPC_URL,
69
+ timeout: float = DEFAULT_TIMEOUT,
70
+ ) -> None:
71
+ api_http = HttpClient(api_url, timeout)
72
+ rpc_http = HttpClient(rpc_url, timeout)
73
+
74
+ self.rpc = RpcModule(api_http, rpc_http)
75
+ """RPC, health, network, native token methods."""
76
+
77
+ self.dex = DexModule(api_http)
78
+ """DEX trading -- orderbook, orders, positions, trades, funding, analytics."""
79
+
80
+ self.spot = SpotModule(api_http)
81
+ """Spot trading -- immediate-delivery markets."""
82
+
83
+ self.oracle = OracleModule(api_http)
84
+ """Oracle -- mark prices, health, quorum."""
85
+
86
+ self.bridge = BridgeModule(api_http)
87
+ """Bridge -- cross-chain transfers, status."""
88
+
89
+ self.staking = StakingModule(api_http)
90
+ """Staking & governance -- validators, delegation, proposals."""
91
+
92
+ self.tokenomics = TokenomicsModule(api_http)
93
+ """Tokenomics -- fees, burns, revenue share, loyalty, vesting."""
94
+
95
+ self.explorer = ExplorerModule(api_http)
96
+ """Explorer -- batches, transactions, addresses, contracts."""