Metadata-Version: 2.4
Name: moe_fabric_gateway
Version: 0.0.6
Summary: A production-grade Python SDK for Hyperledger Fabric Gateway
Author: Fabric SDK Team
License: Apache-2.0
Project-URL: Repository, https://github.com/N791/moe-fabric-gateway-python-sdk
Project-URL: Bug Tracker, https://github.com/N791/moe-fabric-gateway-python-sdk/issues
Keywords: hyperledger,fabric,blockchain,grpc,sdk
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.11
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: grpcio>=1.62.0
Requires-Dist: grpcio-tools>=1.62.0
Requires-Dist: protobuf>=4.25.0
Requires-Dist: cryptography>=42.0.0
Requires-Dist: structlog>=24.1.0
Provides-Extra: dev
Requires-Dist: pytest>=8.0.0; extra == "dev"
Requires-Dist: pytest-asyncio>=0.23.0; extra == "dev"
Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
Requires-Dist: black>=24.0.0; extra == "dev"
Requires-Dist: isort>=5.13.0; extra == "dev"
Requires-Dist: ruff>=0.4.0; extra == "dev"
Requires-Dist: mypy>=1.9.0; extra == "dev"
Requires-Dist: grpcio-testing>=1.62.0; extra == "dev"
Requires-Dist: bandit>=1.7.0; extra == "dev"
Requires-Dist: pip-audit>=2.7.0; extra == "dev"
Requires-Dist: detect-secrets>=1.4.0; extra == "dev"
Dynamic: license-file

# 🚀 moe_fabric_gateway

> **专为 Hyperledger Fabric (v2.4+) Gateway 打造的生产级、原生异步 Python SDK。**

[![Python Version](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://www.python.org/downloads/)
[![License](https://img.shields.io/badge/License-Apache%202.0-green.svg)](https://opensource.org/licenses/Apache-2.0)
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)](https://github.com/N791/moe-fabric-gateway-python-sdk/actions)
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/N791/moe-fabric-gateway-python-sdk/actions)

`moe_fabric_gateway` 提供了一种优雅、轻量且稳健的方式与 Hyperledger Fabric 网络进行交互。它专为现代 Python 的 `asyncio` 模式精心设计，旨在为 Web3 和企业级区块链开发者提供卓越的开发者体验（DX）。

---

## ✨ 核心特性

- ⚡️ **原生异步 (asyncio)**：自底向上采用 `grpc.aio` 构建，实现完全的非阻塞 I/O。告别阻塞调用和线程池瓶颈。
- 🔒 **安全的离线证书管理**：通过离线的签名器 (`Signer`) 架构实现私钥 (`Private Key`) 的绝对隔离。私钥永远不会离开应用内存，也绝不会在网络中传输。
- 🪶 **极轻量级架构**：零 `protoc` 依赖。针对核心交易采用手写的、极其高效的 Protobuf 序列化，体积小巧，避免了 `grpcio-tools` 生成文件的臃肿。
- 🛡️ **企业级可靠性**：强制的 TLS 安全通道、内置的 gRPC 异常重试机制、Keep-Alive 参数调优，以及针对事件监听的流断线自动重连。

---

## ⚡ 快速预览

体验 `async/await` 驱动的极简 API。以下是实例化网关 (`Gateway`) 和评估交易 (`Evaluate Transaction`) 的代码示例：

```python
import asyncio
from fabric_gateway import Gateway, GatewayClient, TlsConfig, DefaultIdentity, DefaultSigner

async def main() -> None:
    # 1. 初始化身份 (Identity) 与离线签名器 (Signer)
    identity = DefaultIdentity(msp_id="Org1MSP", cert_path="cert.pem")
    signer = DefaultSigner(key_path="key.pem")

    # 2. 配置安全的 gRPC 通道 (TLS)
    tls_config = TlsConfig(tls_ca_cert_path="tls-cert.pem")
    client = GatewayClient(endpoint="localhost:7051", tls_config=tls_config)

    # 3. 连接到网关 (Gateway) 并与智能合约交互
    async with Gateway(client, identity, signer) as gateway:
        network = gateway.get_network("mychannel")
        contract = network.get_contract("basic")

        # 评估交易 (Evaluate Transaction) - 用于查询
        print("--> 评估交易: ReadAsset")
        result = await contract.evaluate_transaction("ReadAsset", "asset1")
        print(f"结果: {result.decode('utf-8')}")

if __name__ == "__main__":
    asyncio.run(main())
```

---

## 📚 目录导航

准备好深入了解了吗？请查阅 `docs/` 目录下的深度指南：

- 📖 [快速入门指南](docs/quickstart_zh-CN.md)：连接网关、查询以及提交交易 (`Submit Transaction`) 的详细分步教程。
- 🛠️ [核心 API 文档](docs/api-reference_zh-CN.md)：核心 API（包含身份 `Identity`、网关 `Gateway`、合约交互、背书 `Endorsement` 等）的详细契约说明。
- 🌍 [English Documentation](docs/README_EN.md): Documentation for English-speaking developers.

---

> 🤖 **声明**：本项目部分基础代码与文档由 AI Agent 辅助生成，并经过人工严格审计。
