mm-apt 0.4.2__py3-none-any.whl → 0.5.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.
mm_apt/ans.py CHANGED
@@ -7,7 +7,7 @@ async def address_to_name(address: str, timeout: float = 5, proxy: str | None =
7
7
  res = await http_request(url, proxy=proxy, timeout=timeout)
8
8
  if res.is_err():
9
9
  return res.to_result_err()
10
- json_res = res.parse_json_body()
10
+ json_res = res.parse_json()
11
11
  if res.status_code == 200 and json_res == {}:
12
12
  return res.to_result_ok(None)
13
13
  if "name" in json_res:
@@ -20,7 +20,7 @@ async def address_to_primary_name(address: str, timeout: float = 5, proxy: str |
20
20
  res = await http_request(url, proxy=proxy, timeout=timeout)
21
21
  if res.is_err():
22
22
  return res.to_result_err()
23
- json_res = res.parse_json_body()
23
+ json_res = res.parse_json()
24
24
  if res.status_code == 200 and json_res == {}:
25
25
  return res.to_result_ok(None)
26
26
  if "name" in json_res:
mm_apt/balance.py CHANGED
@@ -3,12 +3,30 @@ from mm_result import Result
3
3
 
4
4
 
5
5
  async def get_balance(node: str, account: str, coin_type: str, timeout: float = 5, proxy: str | None = None) -> Result[int]:
6
- url = f"{node}/accounts/{account}/resource/0x1::coin::CoinStore%3C{coin_type}%3E"
7
- res = await http_request(url, proxy=proxy, timeout=timeout)
6
+ url = f"{node}/view"
7
+
8
+ if "::" in coin_type:
9
+ # Coin type (e.g., 0x1::aptos_coin::AptosCoin)
10
+ body = {
11
+ "function": "0x1::coin::balance",
12
+ "type_arguments": [coin_type],
13
+ "arguments": [account],
14
+ }
15
+ else:
16
+ # Fungible Asset metadata address
17
+ body = {
18
+ "function": "0x1::primary_fungible_store::balance",
19
+ "type_arguments": ["0x1::fungible_asset::Metadata"],
20
+ "arguments": [account, coin_type],
21
+ }
22
+
23
+ res = await http_request(url, method="POST", json=body, proxy=proxy, timeout=timeout)
8
24
  try:
9
- json_res = res.parse_json_body()
10
- if json_res.get("error_code") == "resource_not_found":
25
+ json_res = res.parse_json()
26
+ if isinstance(json_res, list) and len(json_res) > 0:
27
+ return res.to_result_ok(int(json_res[0]))
28
+ if isinstance(json_res, dict) and json_res.get("error_code") == "resource_not_found":
11
29
  return res.to_result_ok(0)
12
- return res.to_result_ok(int(json_res["data"]["coin"]["value"]))
30
+ return res.to_result_err(f"Unexpected response format: {json_res}")
13
31
  except Exception as e:
14
32
  return res.to_result_err(e)
mm_apt/coin.py CHANGED
@@ -1,2 +1,5 @@
1
1
  APTOS_COIN_TYPE = "0x1::aptos_coin::AptosCoin"
2
2
  APTOS_COIN_DECIMALS = 8
3
+
4
+ USDT_METADATA = "0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b"
5
+ USDT_DECIMALS = 6
@@ -1,5 +1,5 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mm-apt
3
- Version: 0.4.2
3
+ Version: 0.5.0
4
4
  Requires-Python: >=3.13
5
- Requires-Dist: mm-web3~=0.5.1
5
+ Requires-Dist: mm-web3~=0.5.4
@@ -0,0 +1,10 @@
1
+ mm_apt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ mm_apt/account.py,sha256=0_YyNjR3LL5EI_rCuQA5q3wTx52RyIeSIPG99CeuYNs,993
3
+ mm_apt/ans.py,sha256=0J-05gMSIoXNUXC3SJlsjKXkI0YfXf_OhOAdKxUdqzU,1172
4
+ mm_apt/balance.py,sha256=NmawTI_sPCJrgaoov5zQ4u5F8bo1dZEcWxwkvxrWEIU,1226
5
+ mm_apt/coin.py,sha256=GF9Quk_2oOSlchSS8WEwPhNR-twbeLmPCgBrSOOWDJk,175
6
+ mm_apt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ mm_apt/retry.py,sha256=rBpxL6HKApWo_So3DQvchkAEy6EZq9dtBdlE0654ZJU,429
8
+ mm_apt-0.5.0.dist-info/METADATA,sha256=p5_aoIx23X7MndQDNBABAwakJO25Cvs6D6aRK4drl_4,104
9
+ mm_apt-0.5.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ mm_apt-0.5.0.dist-info/RECORD,,
@@ -1,10 +0,0 @@
1
- mm_apt/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
- mm_apt/account.py,sha256=0_YyNjR3LL5EI_rCuQA5q3wTx52RyIeSIPG99CeuYNs,993
3
- mm_apt/ans.py,sha256=r1ynL71YILm6VpYfRejf7G3Mt_5uVlvI8AXEN9qO50g,1182
4
- mm_apt/balance.py,sha256=wy7tJCiwCyiq_GySQdV5zX9fI4jWh9vvphPDZc-dYGc,626
5
- mm_apt/coin.py,sha256=NuVFVxDcL3acXdZBLr79dbzT44bWHZP2gtLILWxTzdE,71
6
- mm_apt/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- mm_apt/retry.py,sha256=rBpxL6HKApWo_So3DQvchkAEy6EZq9dtBdlE0654ZJU,429
8
- mm_apt-0.4.2.dist-info/METADATA,sha256=y0kNCSuhr_a1naF_C7A3XvaMCGMKm_TjUa5EgPzykwA,104
9
- mm_apt-0.4.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- mm_apt-0.4.2.dist-info/RECORD,,
File without changes