Skip to content

Commit

Permalink
[Rust/Bitcoin/Utxo] Great Migration towards tw_bitcoin and tw_utxo (
Browse files Browse the repository at this point in the history
  • Loading branch information
lamafab authored Sep 19, 2023
1 parent 988b1e5 commit f521ce6
Show file tree
Hide file tree
Showing 92 changed files with 6,995 additions and 3,935 deletions.
23 changes: 21 additions & 2 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ members = [
"tw_number",
"tw_proto",
"tw_ronin",
"tw_utxo",
"wallet_core_rs",
]

Expand Down
2 changes: 1 addition & 1 deletion rust/coverage.stats
Original file line number Diff line number Diff line change
@@ -1 +1 @@
89.5
91.7
1 change: 1 addition & 0 deletions rust/tw_any_coin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ tw_misc = { path = "../tw_misc" }
test-utils = []

[dev-dependencies]
tw_any_coin = { path = "./", features = ["test-utils"] }
tw_encoding = { path = "../tw_encoding" }
tw_keypair = { path = "../tw_keypair", features = ["test-utils"] }
tw_memory = { path = "../tw_memory", features = ["test-utils"] }
Expand Down
20 changes: 17 additions & 3 deletions rust/tw_any_coin/tests/tw_any_address_ffi_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ fn test_any_address_derive() {

// TODO match `CoinType` when it's generated.
let expected_address = match coin.blockchain {
// By default, Bitcoin will return a P2PKH address.
BlockchainType::Bitcoin => "19cAJn4Ms8jodBBGtroBNNpCZiHAWGAq7X",
BlockchainType::Ethereum => "0xAc1ec44E4f0ca7D172B7803f6836De87Fb72b309",
BlockchainType::Ronin => "ronin:Ac1ec44E4f0ca7D172B7803f6836De87Fb72b309",
BlockchainType::Unsupported => unreachable!(),
Expand All @@ -57,6 +59,10 @@ fn test_any_address_derive() {
fn test_any_address_normalize_eth() {
for coin in supported_coin_items() {
let (denormalized, expected_normalized) = match coin.blockchain {
BlockchainType::Bitcoin => (
"19cAJn4Ms8jodBBGtroBNNpCZiHAWGAq7X",
"19cAJn4Ms8jodBBGtroBNNpCZiHAWGAq7X",
),
BlockchainType::Ethereum => (
"0xb16db98b365b1f89191996942612b14f1da4bd5f",
"0xb16Db98B365B1f89191996942612B14F1Da4Bd5f",
Expand Down Expand Up @@ -85,9 +91,14 @@ fn test_any_address_normalize_eth() {
}

#[test]
fn test_any_address_is_valid_eth() {
fn test_any_address_is_valid_coin() {
for coin in supported_coin_items() {
let valid = match coin.blockchain {
BlockchainType::Bitcoin => vec![
"1MrZNGN7mfWZiZNQttrzHjfw72jnJC2JNx",
"bc1qunq74p3h8425hr6wllevlvqqr6sezfxj262rff",
"bc1pwse34zfpvt344rvlt7tw0ngjtfh9xasc4q03avf0lk74jzjpzjuqaz7ks5",
],
BlockchainType::Ethereum => vec![
"0xb16db98b365b1f89191996942612b14f1da4bd5f",
"0xb16Db98B365B1f89191996942612B14F1Da4Bd5f",
Expand All @@ -98,7 +109,7 @@ fn test_any_address_is_valid_eth() {
"ronin:b16db98b365b1f89191996942612b14f1da4bd5f",
"ronin:b16Db98B365B1f89191996942612B14F1Da4Bd5f",
],
BlockchainType::Unsupported => unreachable!(),
_ => unreachable!(),
};

for valid_addr in valid {
Expand All @@ -109,9 +120,12 @@ fn test_any_address_is_valid_eth() {
}

#[test]
fn test_any_address_is_valid_eth_invalid() {
fn test_any_address_is_valid_coin_invalid() {
for coin in supported_coin_items() {
let invalid = match coin.blockchain {
BlockchainType::Bitcoin => {
vec!["0xb16db98b365b1f89191996942612b14f1da4bd5f"]
},
BlockchainType::Ethereum | BlockchainType::Ronin => {
vec!["b16Db98B365B1f89191996942612B14F1Da4Bd5f"]
},
Expand Down
6 changes: 6 additions & 0 deletions rust/tw_bitcoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ bitcoin = "0.30.0"
secp256k1 = { version = "0.27.0", features = [ "global-context", "rand-std" ] }
serde = { version = "1.0.163", features = [ "derive" ] }
serde_json = "1.0.96"
tw_coin_entry = { path = "../tw_coin_entry", features = ["test-utils"] }
tw_utxo = { path = "../tw_utxo" }
tw_encoding = { path = "../tw_encoding" }
tw_memory = { path = "../tw_memory" }
tw_misc = { path = "../tw_misc" }
tw_proto = { path = "../tw_proto" }
tw_keypair = { path = "../tw_keypair" }

[dev-dependencies]
wallet-core-rs = { path = "../wallet_core_rs" }
211 changes: 0 additions & 211 deletions rust/tw_bitcoin/src/brc20.rs

This file was deleted.

Loading

0 comments on commit f521ce6

Please sign in to comment.