Repository: ergoplatform/sigma-rust (language: rust)

Issue:
Support `id` and 'boxId` for box id when parsing ErgoBox from JSON 



Discussion / hints:

Fix patch:
diff --git a/.travis.yml b/.travis.yml
index 13107fa74..1fb3920c9 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -20,6 +20,7 @@ matrix:
   fast_finish: true
   allow_failures:
     - rust: nightly
+    - rust: beta
 
   include:
     - name: formatting
diff --git a/ergo-lib/CHANGELOG.md b/ergo-lib/CHANGELOG.md
index 9b3cc0547..c28cb5e39 100644
--- a/ergo-lib/CHANGELOG.md
+++ b/ergo-lib/CHANGELOG.md
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
 
 <!-- next-header -->
 ## [Unreleased] - ReleaseDate
+
+### Added
+- add support for parsing ErgoBox id also from "id" JSON field name [#134](https://github.com/ergoplatform/sigma-rust/pull/134)
+
 ## [0.3.0] - 2020-11-04
 
 ### Added
diff --git a/ergo-lib/src/chain/json.rs b/ergo-lib/src/chain/json.rs
index 6d783c53e..0f6e33f2d 100644
--- a/ergo-lib/src/chain/json.rs
+++ b/ergo-lib/src/chain/json.rs
@@ -49,7 +49,7 @@ pub mod ergo_box {
 
     #[derive(Deserialize, PartialEq, Eq, Debug, Clone)]
     pub struct ErgoBoxFromJson {
-        #[serde(rename = "boxId")]
+        #[serde(rename = "boxId", alias = "id")]
         pub box_id: BoxId,
         /// amount of money associated with the box
         #[serde(rename = "value")]
@@ -208,4 +208,22 @@ mod tests {
         let b: ErgoBox = serde_json::from_str(box_json).unwrap();
         assert_eq!(b.value, 67500000000u64.try_into().unwrap());
     }
+
+    #[test]
+    fn parse_ergo_box_alternative_box_id_field_name() {
+        // check that using "id" field name instead of "boxId" also works
+        // used in explorer API
+        let box_json = r#"{
+          "id": "e56847ed19b3dc6b72828fcfb992fdf7310828cf291221269b7ffc72fd66706e",
+          "value": 67500000000,
+          "ergoTree": "100204a00b08cd021dde34603426402615658f1d970cfa7c7bd92ac81a8b16eeebff264d59ce4604ea02d192a39a8cc7a70173007301",
+          "assets": [],
+          "creationHeight": 284761,
+          "additionalRegisters": {},
+          "transactionId": "9148408c04c2e38a6402a7950d6157730fa7d49e9ab3b9cadec481d7769918e9",
+          "index": 1
+        }"#;
+        let b: ErgoBox = serde_json::from_str(box_json).unwrap();
+        assert_eq!(b.value, 67500000000u64.try_into().unwrap());
+    }
 }


Test patch: