From 343058eed96500ff203692d68bab22a7ebaac755 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Mon, 19 Aug 2024 21:42:35 +0200 Subject: [PATCH 1/2] Make all meta fields optional --- libgitcash/src/transaction.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libgitcash/src/transaction.rs b/libgitcash/src/transaction.rs index 3547f8a..bccb962 100644 --- a/libgitcash/src/transaction.rs +++ b/libgitcash/src/transaction.rs @@ -30,8 +30,8 @@ impl Transaction { #[derive(Debug, Deserialize, Serialize)] pub struct TransactionMeta { - pub class: String, - pub ean: u64, + pub class: Option, + pub ean: Option, } #[derive(Debug, PartialEq, Eq, PartialOrd, Hash, Clone, Copy)] From 780ba636dcdbe30bde9f4baca1f8e47ba52df572 Mon Sep 17 00:00:00 2001 From: Danilo Bargen Date: Mon, 19 Aug 2024 21:52:30 +0200 Subject: [PATCH 2/2] Spec: Document keys --- docs/spec.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/spec.md b/docs/spec.md index 9f499ce..e1dfcd5 100644 --- a/docs/spec.md +++ b/docs/spec.md @@ -27,12 +27,28 @@ If a commit message starts with a special prefix, it will be parsed: - `Transaction: `: Create a transaction - `Revert: `: Revert a transaction -The `` is a human-readable desription of the transaction. +The `` is a human-readable description of the transaction. The data of the transaction (in TOML format) is inserted between two markers (`---` on a dedicated line). This allows adding more metadata before or after the data section, which won't be parsed. +### TOML keys + +The TOML section can use the following keys: + +- `from` (required): The source account +- `to` (required): The destination account +- `amount` (required): The amount (must fit in i32, i.e. between `-2147483648` + and `2147483647` inclusive) +- `description` (optional): A free-form string to describe the transaction +- `meta` (optional): A table containing meta information + +The following meta keys may be used, all of them are optional: + +- `class`: The product class as a string, e.g. "softdrink". +- `ean`: The EAN code as an unsigned integer. + ### Example commits Deposit some cash: