Skip to content

Commit 9925466

Browse files
committed
Merge branch 'develop' of https://github.com/klever-io/kos-rs into feat/kos-codec
2 parents aa99560 + 98f6630 commit 9925466

File tree

7 files changed

+66
-27
lines changed

7 files changed

+66
-27
lines changed

.github/actions/bump-version.sh

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,6 @@ MAJOR_VERSION=${ADDR[0]}
99
MINOR_VERSION=${ADDR[1]}
1010
PATCH_VERSION=${ADDR[2]}
1111

12-
# Check the PR title to decide how to bump the version.
13-
if [[ "${PR_TITLE}" == "MAJOR:"* ]]; then
14-
MAJOR_VERSION=$((MAJOR_VERSION + 1))
15-
MINOR_VERSION=0
16-
PATCH_VERSION=0
17-
elif [[ "${PR_TITLE}" == "MINOR:"* ]]; then
18-
MINOR_VERSION=$((MINOR_VERSION + 1))
19-
PATCH_VERSION=0
20-
else
21-
PATCH_VERSION=$((PATCH_VERSION + 1))
22-
fi
23-
24-
# Construct the new version string.
2512
NEW_VERSION="$MAJOR_VERSION.$MINOR_VERSION.$PATCH_VERSION"
2613

27-
# Replace the version in Cargo.toml
28-
sed -i "s/version = \"$CURRENT_VERSION\"/version = \"$NEW_VERSION\"/g" Cargo.toml
29-
30-
# Print the new version to a file (or alternatively, set it as an environment variable or output variable).
3114
echo $NEW_VERSION > VERSION
32-
33-
echo "($PR_TITLE) updating $CURRENT_VERSION to $NEW_VERSION"

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ homepage = "https://klever.org/"
1515
license = "Apache-2.0"
1616
repository = "https://github.com/kleverio/kos-rs"
1717
rust-version = "1.69.0"
18-
version = "0.2.9"
18+
version = "0.2.12"
1919

2020
[workspace.dependencies]
2121
bech32 = "0.9.1"
@@ -41,4 +41,4 @@ serde_json = "1.0"
4141
lazy_static = "1.4.0"
4242
thiserror = "1.0"
4343

44-
kos = { version = "0.2.9", path = "./packages/kos", default-features = false }
44+
kos = { version = "0.2.12", path = "./packages/kos", default-features = false }

packages/kos-mobile/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ mod tests {
510510
"The sender doesn't match"
511511
);
512512
assert_eq!(
513-
transaction.raw, "7b22426c6f636b223a6e756c6c2c2252617744617461223a7b2242616e647769647468466565223a313030303030302c22436861696e4944223a224d5441774e444977222c22436f6e7472616374223a5b7b22506172616d65746572223a7b22747970655f75726c223a22747970652e676f6f676c65617069732e636f6d2f70726f746f2e5472616e73666572436f6e7472616374222c2276616c7565223a224369417973796730416a38786a2f72723558475536694a2b41544932396d6e52485330573042724331767a304342674b227d2c2254797065223a6e756c6c7d5d2c2244617461223a6e756c6c2c224b417070466565223a3530303030302c224b6461466565223a6e756c6c2c224e6f6e6365223a33392c225065726d697373696f6e4944223a6e756c6c2c2253656e646572223a22354273794f6c6366325658676e4e5157595039455a6350305270504966792b75704b44385149636e794f6f3d222c2256657273696f6e223a317d2c225265636569707473223a6e756c6c2c22526573756c74223a6e756c6c2c22526573756c74436f6465223a6e756c6c2c225369676e6174757265223a5b2267555a444950537853713430516a54424d33382f4441417557546d37443154486f324b5756716869545943756d354f2b4f53577754596c6749553052674a36756e6767316375434a50636d59574e676a444b412f44413d3d225d7d",
513+
transaction.raw, "7b22426c6f636b223a6e756c6c2c2252617744617461223a7b2242616e647769647468466565223a313030303030302c22436861696e4944223a224d5441774e444977222c22436f6e7472616374223a5b7b22506172616d65746572223a7b22747970655f75726c223a22747970652e676f6f676c65617069732e636f6d2f70726f746f2e5472616e73666572436f6e7472616374222c2276616c7565223a224369417973796730416a38786a2f72723558475536694a2b41544932396d6e52485330573042724331767a304342674b227d2c2254797065223a6e756c6c7d5d2c2244617461223a6e756c6c2c224b417070466565223a3530303030302c224b4441466565223a6e756c6c2c224e6f6e6365223a33392c225065726d697373696f6e4944223a6e756c6c2c2253656e646572223a22354273794f6c6366325658676e4e5157595039455a6350305270504966792b75704b44385149636e794f6f3d222c2256657273696f6e223a317d2c225265636569707473223a6e756c6c2c22526573756c74223a6e756c6c2c22526573756c74436f6465223a6e756c6c2c225369676e6174757265223a5b2267555a444950537853713430516a54424d33382f4441417557546d37443154486f324b5756716869545943756d354f2b4f53577754596c6749553052674a36756e6767316375434a50636d59574e676a444b412f44413d3d225d7d",
514514
"The raw doesn't match"
515515
);
516516
assert_eq!(

packages/kos-web/src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ pub fn decrypt(data: &[u8], password: &str) -> Result<Vec<u8>, Error> {
3737
cipher::decrypt(data, password).map_err(|e| Error::Cipher(format!("{}", e)))
3838
}
3939

40+
/// Encrypt for GCM the given data with the given password.
41+
/// Data will have the algorithm tag prepended to it (1 byte).
42+
#[wasm_bindgen(js_name = "encrypt")]
43+
pub fn encrypt(data: &[u8], password: &str) -> Result<Vec<u8>, Error> {
44+
cipher::encrypt(cipher::CipherAlgo::GMC, data, password)
45+
.map_err(|e| Error::Cipher(format!("{}", e)))
46+
}
47+
4048
/// Create pem file from tag and data
4149
#[wasm_bindgen(js_name = "toPem")]
4250
pub fn to_pem(tag: String, data: &[u8]) -> Result<String, Error> {

packages/kos/src/chains/klv/mod.rs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,56 @@ mod test {
343343
.unwrap()
344344
);
345345
}
346+
#[test]
347+
fn test_sign_tx_5() {
348+
let pvk = hex::decode("1ab42cc412b618bdea3a599e3c9bae199ebf030895b039e9db1e30dafb12b727")
349+
.unwrap();
350+
351+
let json = r#"
352+
{
353+
"RawData": {
354+
"Nonce": 606,
355+
"Sender": "SqQFUzLDtZNzXexeY++BMVH5GTKLDMSxo72GoRqjZz0=",
356+
"Contract": [
357+
{
358+
"Parameter": {
359+
"type_url": "type.googleapis.com/proto.TransferContract",
360+
"value": "CiBI/KqGTZBj8/J8YhvX20xb9NP6l5eXRCBmJsWERlhmSRIDS0xWGMCEPQ=="
361+
}
362+
}
363+
],
364+
"Data": [
365+
""
366+
],
367+
"KAppFee": 1000000,
368+
"BandwidthFee": 2000000,
369+
"Version": 1,
370+
"ChainID": "MTA4",
371+
"KDAFee": {
372+
"KDA": "Q0hJUFMtMUdaUA==",
373+
"Amount": 688200
374+
}
375+
}
376+
}"#;
377+
let raw_tx = json.as_bytes().to_vec();
378+
379+
let tx = crate::chains::Transaction {
380+
raw_data: raw_tx,
381+
tx_hash: Vec::new(),
382+
signature: Vec::new(),
383+
options: None,
384+
};
385+
386+
let result_tx = crate::chains::klv::KLV {}.sign_tx(pvk, tx).unwrap();
387+
388+
assert_eq!(
389+
result_tx.tx_hash,
390+
vec![
391+
60, 222, 134, 3, 87, 86, 2, 184, 223, 221, 53, 134, 54, 27, 20, 178, 197, 31, 20,
392+
66, 12, 107, 186, 61, 21, 82, 78, 66, 210, 190, 124, 194
393+
]
394+
);
395+
}
346396

347397
#[test]
348398
fn test_decode_klv_tx() {

packages/kos/src/chains/klv/models.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub struct Raw {
5050
pub version: Option<u32>,
5151
#[Rename = "ChainID"]
5252
pub chain_id: String,
53-
#[Rename = "KdaFee"] // Use this to match the exact JSON field name for this field
53+
#[Rename = "KDAFee"] // Use this to match the exact JSON field name for this field
5454
pub kda_fee: ::core::option::Option<KdaFee>,
5555
}
5656

@@ -72,7 +72,7 @@ pub struct Parameter {
7272

7373
#[derive(Clone, PartialEq, Serialize, Deserialize)]
7474
pub struct KdaFee {
75-
#[Rename = "Kda"]
75+
#[Rename = "KDA"]
7676
pub kda: String,
7777
#[Rename = "Amount"]
7878
pub amount: i64,

0 commit comments

Comments
 (0)