1 个不稳定版本
0.1.0 | 2022年11月17日 |
---|
#320 在 #safe
64KB
1.5K SLoC
安全交易服务 API 客户端
使用 SDK
实例化 API 客户端
use safe_sdk::SafeClient;
/// From a chain id, by looking up hardcoded endpoints
let client = SafeClient::by_chain_id(1);
/// From mainnet ethereum
let client = SafeClient::ethereum();
/// From an endpoint/chain ID pair
let service = safe_sdk::networks::TxService { url: "". chain_id: 0};
let client = SafeClient::new(service);
实例化签名客户端
use safe_sdk::SigningClient;
/// From an ethers signer
let client = SigningClient::try_from_signer(ethers_signer);
/// From ethereum with an ethers signer
/// overrides the chain_id of the signer
let client = SigningClient::ethereum(ethers_signer);
/// From a service and signer
let service = safe_sdk::networks::TxService { url: "". chain_id: 0};
let client = SigningClient::with_service_and_signer(service, ethers_signer);
/// From an existing SafeClient
let client = safe_client.with_signer(ethers_signer);
常见安全操作
use safe_sdk::rpc::info::SafeInfoResponse;
/// Read info
let info: SafeInfoResponse = client.safe_info(safe_address).await?;
dbg!(&info.nonce); // u64 of on-chain Nonce
dbg!(&info.owners) // vec of addresses
/// Get next available nonce
let next_nonce = client.next_nonce(safe_address).await?;
/// Get SAFE msig tx history
let history = client.msig_history_builder().query(safe_address).await?;
/// Get SAFE msig tx history by nonce range
let history = client.msig_history_builder()
.min_nonce(15)
.max_nonce(25)
.query(safe_address)
.await?;
分发
let tx =
待办事项 & 粗糙边缘
- 大多数端点尚未实现。此 SDK 优先考虑自动化 TX 提交,而不是完整的 API 实现。
- 许多参数/类型尚未实现。
- API 文档不完整,我们不知道一些属性的函数。
- 与 ethers 更好的集成
- 更多对 MetaTransactionData 的 From 实现
- 一些属性是字符串类型,应将其转换为枚举
- 细化 API 响应类型
依赖项
~20–35MB
~545K SLoC