Skip to content

Commit aab2357

Browse files
committed
rename to_json_dapp() to to_js_eip12;
1 parent e517131 commit aab2357

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

bindings/ergo-lib-wasm/src/ergo_box.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,9 @@ impl ErgoBox {
170170
.map_err(|e| JsValue::from_str(&format!("{}", e)))
171171
}
172172

173-
/// JSON representation (same as [`Self::to_json`],
174-
/// but with box value encoding as string)
175-
pub fn to_json_dapp(&self) -> Result<JsValue, JsValue> {
173+
/// JSON representation according to EIP-12 https://github.com/ergoplatform/eips/pull/23
174+
/// (similar to [`Self::to_json`], but with box value and token amount encoding as strings)
175+
pub fn to_js_eip12(&self) -> Result<JsValue, JsValue> {
176176
let box_dapp: ErgoBoxJsonDapp = self.0.clone().into();
177177
JsValue::from_serde(&box_dapp).map_err(|e| JsValue::from_str(&format!("{}", e)))
178178
}

bindings/ergo-lib-wasm/src/transaction.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,9 @@ impl Transaction {
7777
.map_err(|e| JsValue::from_str(&format!("{}", e)))
7878
}
7979

80-
/// JSON representation (same as [`Self::to_json`],
81-
/// but with box value and token amount encoding as strings)
82-
pub fn to_json_dapp(&self) -> Result<JsValue, JsValue> {
80+
/// JSON representation according to EIP-12 https://github.com/ergoplatform/eips/pull/23
81+
/// (similar to [`Self::to_json`], but with box value and token amount encoding as strings)
82+
pub fn to_js_eip12(&self) -> Result<JsValue, JsValue> {
8383
let tx_dapp: TransactionJsonDapp = self.0.clone().into();
8484
JsValue::from_serde(&tx_dapp).map_err(|e| JsValue::from_str(&format!("{}", e)))
8585
}
@@ -152,9 +152,9 @@ impl UnsignedTransaction {
152152
.map_err(|e| JsValue::from_str(&format!("{}", e)))
153153
}
154154

155-
/// JSON representation (same as [`Self::to_json`],
156-
/// but with box value and token amount encoding as strings)
157-
pub fn to_json_dapp(&self) -> Result<JsValue, JsValue> {
155+
/// JSON representation according to EIP-12 https://github.com/ergoplatform/eips/pull/23
156+
/// (similar to [`Self::to_json`], but with box value and token amount encoding as strings)
157+
pub fn to_js_eip12(&self) -> Result<JsValue, JsValue> {
158158
let tx_dapp: UnsignedTransactionJsonDapp = self.0.clone().into();
159159
JsValue::from_serde(&tx_dapp).map_err(|e| JsValue::from_str(&format!("{}", e)))
160160
}

bindings/ergo-lib-wasm/tests/test_box.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ it('ErgoBox.to_json_dapp() test', async () => {
3737
"spentTransactionId": null,
3838
"mainChain": true
3939
}]).get(0);
40-
const j_obj = box.to_json_dapp();
40+
const j_obj = box.to_js_eip12();
4141
assert(j_obj instanceof Object);
4242
assert(j_obj.value == "2875858910", "should be a string of '2875858910'");
4343
assert(j_obj.assets[0].amount == "99999999998", "should be a string of '99999999998'");

ergo-lib/CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
88
## [Unreleased] - ReleaseDate
99

1010
### Added
11-
- WASM `to_json_dapp()` (along `to_json_dapp()`) that encodes the same JSON as `to_json()` but box value and token amount encodes as strings to avoid accuracy loss in JS [#346](https://github.com/ergoplatform/sigma-rust/pull/346);
11+
- WASM `to_js_eip12()` (along `to_json()`) that encodes JSON according to [EIP-12](https://github.com/ergoplatform/eips/pull/23) (similar to JSON by `to_json()`, but box value and token amount encodes as strings to avoid accuracy loss in JS) [#346](https://github.com/ergoplatform/sigma-rust/pull/346);
1212
- `Coll.slice` [#309](https://github.com/ergoplatform/sigma-rust/pull/309);
1313
- Byte-wise XOR for byte arrays [#310](https://github.com/ergoplatform/sigma-rust/pull/310);
1414
- `Constant::from_i64_str_array` and `to_i64_str_array` for `Coll[Long]` encoding [#311](https://github.com/ergoplatform/sigma-rust/pull/311);

0 commit comments

Comments
 (0)