eth_twc_sdk/types/
signed_data.rs

1//! オフチェーンで転送する署名済みバンドル。
2//!
3//! `domain` はオンチェーン `eip712Domain()` を [`crate::sign::domain_for_typed_data_sign`] で正規化したもの(ゼロ `salt` は省略されうる)。トランザクションに載せるのは送金内容と署名であり、**`domain` 本体はオンチェーンには渡さない**([`crate::send_transaction::signature_transfer`] がエンコードするのはコントラクト関数引数のみ)。
4
5use alloy::primitives::{Address, B256, Bytes, U256};
6use alloy::sol_types::Eip712Domain;
7
8use super::transfer_detail::CommittedTransferDetail;
9
10/// 単一送金+コミットメントの署名結果(型 `TransferWithCommit`)。
11#[derive(Clone, Debug)]
12pub struct SignedTransferWithCommit {
13    /// EIP-712 ドメイン(正規化済み)。
14    pub domain: Eip712Domain,
15    /// メッセージの `from`。
16    pub from: Address,
17    pub to: Address,
18    pub token: Address,
19    pub value: U256,
20    pub commitment: B256,
21    /// 署名メッセージの `validAfter`(`uint256`)。コントラクトの `validTimestamp` と整合する値(通常はブロックタイムスタンプと比較される単位)。
22    pub valid_after: U256,
23    /// 署名メッセージの `validBefore`(`uint256`)。上に同じ。
24    pub valid_before: U256,
25    /// ECDSA 署名(`bytes`)。
26    pub signature: Bytes,
27}
28
29/// `UniCommitTransfers` の署名結果。
30#[derive(Clone, Debug)]
31pub struct SignedUniCommitTransfers {
32    /// EIP-712 ドメイン。
33    pub domain: Eip712Domain,
34    pub from: Address,
35    /// オフチェーン明細(executor はメッセージ内、`Signed*` には含めない)。
36    pub details: Vec<super::transfer_detail::TransferDetail>,
37    pub commitment: B256,
38    /// [`SignedTransferWithCommit`] の `valid_after` / `valid_before` と同じ意味。
39    pub valid_after: U256,
40    pub valid_before: U256,
41    pub signature: Bytes,
42}
43
44/// `BatchTransferWithCommit` の署名結果。
45#[derive(Clone, Debug)]
46pub struct SignedBatchTransferWithCommit {
47    /// EIP-712 ドメイン。
48    pub domain: Eip712Domain,
49    pub from: Address,
50    pub details: Vec<CommittedTransferDetail>,
51    /// EIP-712 の `batchCommitment`(コントラクトの `replayGuard(from, batchCommitment)` と一致)。
52    pub batch_commitment: B256,
53    /// [`SignedTransferWithCommit`] の `valid_after` / `valid_before` と同じ意味。
54    pub valid_after: U256,
55    pub valid_before: U256,
56    pub signature: Bytes,
57}
58
59/// `CancelAuthorization` の署名結果。
60#[derive(Clone, Debug)]
61pub struct SignedCancelAuthorization {
62    /// EIP-712 ドメイン。
63    pub domain: Eip712Domain,
64    pub authorizer: Address,
65    pub commitment: B256,
66    pub signature: Bytes,
67}