Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add metadata typing for libra transactions
Signed-off-by: Nassim Eddequiouaq <nass@fb.com>
- Loading branch information
Nassim Eddequiouaq
committed
Jul 13, 2020
1 parent
d703cb0
commit 21a3c06
Showing
4 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
// Copyright (c) The Libra Core Contributors | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use serde::{Deserialize, Serialize}; | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub enum MetadataType { | ||
Undefined, | ||
GeneralMetadataType(GeneralMetadata), | ||
TravelRuleMetadataType(TravelRuleMetadata), | ||
UnstructuredStringMetadataType(UnstructuredStringMetadata), | ||
} | ||
|
||
// Used for versioning of general metadata | ||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub enum GeneralMetadata { | ||
GeneralMetadataVersion0(GeneralMetadataV0), | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct GeneralMetadataV0 { | ||
// Subaddress to which the funds are being sent | ||
#[serde(with = "serde_bytes")] | ||
to_subaddress: Option<Vec<u8>>, | ||
|
||
// Subaddress from which the funds are being sent | ||
#[serde(with = "serde_bytes")] | ||
from_subaddress: Option<Vec<u8>>, | ||
|
||
// Event sequence number of referenced payment | ||
referenced_event: Option<u64>, | ||
} | ||
|
||
// Used for versioning of travel rule metadata | ||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub enum TravelRuleMetadata { | ||
TravelRuleMetadataVersion0(TravelRuleMetadataV0), | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct TravelRuleMetadataV0 { | ||
// Off-chain reference_id. Used when off-chain APIs are used. | ||
// Specifies the off-chain reference ID that was agreed upon in off-chain APIs. | ||
off_chain_reference_id: Option<String>, | ||
} | ||
|
||
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize)] | ||
pub struct UnstructuredStringMetadata { | ||
// Unstructured string metadata | ||
metadata: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters