Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: TON PoC #130

Draft
wants to merge 4 commits into
base: dev
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,592 changes: 1,032 additions & 560 deletions Cargo.lock

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ members = [
"token-core/tcx-tester",
"token-core/tcx-eth2",
"token-core/tcx-eth",
"token-core/tcx-ton",
"token-core/tcx-common",
"token-core/tcx-migration",
"token-core/tcx-libs/ed25519-dalek-bip32",
Expand Down
6 changes: 3 additions & 3 deletions imkey-core/ikc-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ edition = "2018"
hyper = { version = "=0.14.23", features = ["full"] }
hyper-tls = "=0.5.0"
hyper-timeout = "=0.4.1"
serde = { version = "=1.0.147", features = ["derive"] }
serde_derive = "=1.0.147"
serde = { version = "=1.0.210", features = ["derive"] }
serde_derive = "=1.0.210"
serde_json = "=1.0.89"
hex = "=0.4.3"
tokio = { version = "=1.28.2", features = ["full"] }
regex = "=1.9.3"
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
num-traits = "=0.2.19"
num-integer = "=0.1.45"
prost = "=0.11.2"
bytes = "=1.4.0"
Expand Down
6 changes: 3 additions & 3 deletions imkey-core/ikc-device/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ edition = "2018"
[dependencies]
ikc-common = {path = "../ikc-common"}
ikc-transport = {path = "../ikc-transport"}
serde = { version = "=1.0.147", features = ["derive"] }
serde_derive = "=1.0.147"
serde = { version = "=1.0.210", features = ["derive"] }
serde_derive = "=1.0.210"
serde_json = "=1.0.89"
base64 = "=0.13.1"
hex = "=0.4.3"
Expand All @@ -21,7 +21,7 @@ rsa = "=0.7.2"
lazy_static = "=1.4.0"
regex = "=1.9.3"
anyhow = "=1.0.79"
log = {version = "=0.4.17", features = ["std"]}
log = {version = "=0.4.22", features = ["std"]}
prost = "=0.11.2"
prost-types = "=0.11.2"
bytes = "=1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion imkey-core/ikc-wallet/coin-bch/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] }
tiny-bip39 = "=1.0.0"
anyhow = "=1.0.79"
hex = "=0.4.3"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
bitcoin_hashes = "=0.11.0"
num-bigint = "=0.4.3"
Expand Down
2 changes: 1 addition & 1 deletion imkey-core/ikc-wallet/coin-btc-fork/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] }
tiny-bip39 = "=1.0.0"
anyhow = "=1.0.79"
hex = "=0.4.3"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
bitcoin_hashes = "=0.11.0"
num-bigint = "=0.4.3"
Expand Down
6 changes: 3 additions & 3 deletions imkey-core/ikc-wallet/coin-cosmos/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ hex = "=0.4.3"
bitcoin = "=0.29.2"
secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] }
bech32 = "=0.9.1"
serde = { version = "=1.0.147", features = ["derive"] }
serde_derive = "=1.0.147"
serde = { version = "=1.0.210", features = ["derive"] }
serde_derive = "=1.0.210"
serde_json = { version = "=1.0.89", default-features = false, features = ["alloc"] }
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
num-traits = "=0.2.19"
num-integer = "=0.1.45"
base64 = "=0.13.1"
anyhow = "=1.0.79"
Expand Down
6 changes: 3 additions & 3 deletions imkey-core/ikc-wallet/coin-ethereum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ keccak-hash = "=0.10.0"
lazy_static = "=1.4.0"
rustc-hex = "=2.1.0"
serde_json = "=1.0.89"
serde = { version = "=1.0.147", features = ["derive"] }
serde_derive = "=1.0.147"
serde = { version = "=1.0.210", features = ["derive"] }
serde_derive = "=1.0.210"
jsonrpc-core = "=18.0.0"
bitcoin = "=0.29.2"
bitcoin_hashes = "=0.11.0"
Expand All @@ -27,7 +27,7 @@ regex = "=1.9.3"
tiny-keccak = { version = "=2.0.2", features = ["keccak"] }
anyhow = "=1.0.79"
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
num-traits = "=0.2.19"
num-integer = "=0.1.45"
bytes = "=1.4.0"
prost = "=0.11.2"
Expand Down
4 changes: 2 additions & 2 deletions imkey-core/ikc-wallet/coin-filecoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ hex = "=0.4.3"
secp256k1 = {version ="=0.24.3", features = ["rand", "recovery"] }
bech32 = "=0.9.1"
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
num-traits = "=0.2.19"
num-integer = "=0.1.45"
base64 = "=0.13.1"
anyhow = "=1.0.79"
Expand All @@ -28,7 +28,7 @@ linked-hash-map = { version = "=0.5.6", features = ["serde_impl"] }

base32 = "=0.4.0"
blake2b-rs = "=0.2.0"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"

forest_vm = "=0.3.2"
Expand Down
6 changes: 3 additions & 3 deletions imkey-core/ikc-wallet/coin-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ edition = "2018"
ikc-common = {path = "../../ikc-common"}
ikc-device = {path = "../../ikc-device"}
ikc-transport = {path = "../../ikc-transport"}
sp-core = "=7.0.0"
sp-core = { version = "=34.0.0", features = ["std"] }
anyhow = "=1.0.79"
hex = "=0.4.3"
prost = "=0.11.2"
prost-types = "=0.11.2"


[dev-dependencies]
sp-runtime = "=7.0.0"
sp-keyring = "=7.0.0"
sp-runtime = "=39.0.1"
#sp-keyring = "=7.0.0"
2 changes: 1 addition & 1 deletion imkey-core/ikc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2018"
[dependencies]
lazy_static = "=1.4.0"

log = {version = "=0.4.17", features = ["std"]}
log = {version = "=0.4.22", features = ["std"]}
ikc-transport = {path = "../ikc-transport"}
ikc-device = {path = "../ikc-device"}
coin-ethereum = {path = "../ikc-wallet/coin-ethereum"}
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[toolchain]
channel="nightly-2023-06-15"
channel="nightly-2024-09-23"
4 changes: 2 additions & 2 deletions token-core/tcx-btc-kin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ secp256k1 = {version ="=0.24.3", features = ["rand", "recovery", "rand-std"] }
tiny-bip39 = "=1.0.0"
bitcoin_hashes = "=0.11.0"
#bitcoinconsensus = { version = "0.19.0-2", optional = true }
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
uuid = { version = "=1.2.2", features = ["serde", "v4"] }
anyhow = { version = "=1.0.79", features = [] }
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
num-traits = "=0.2.19"
num-integer = "=0.1.45"
byteorder = "=1.4.3"
bech32 = "=0.9.1"
Expand Down
8 changes: 5 additions & 3 deletions token-core/tcx-btc-kin/src/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,16 +256,18 @@ impl<T: Address + ScriptPubkey + FromStr<Err = anyhow::Error>> KinTransaction<T>
seg_wit: params.seg_wit.clone(),
};

let change_script = if let Some(change_address_index) = self.change_address_index && keystore.derivable() {
let change_script = if let Some(change_address_index) = self.change_address_index
&& keystore.derivable()
{
let account_path = get_account_path(&params.derivation_path)?;
let dpk = keystore.get_deterministic_public_key(params.curve, &account_path)?;
let pub_key = dpk
.derive(format!("1/{}", change_address_index).as_str())?
.public_key();

T::from_public_key(&pub_key, &coin_info)?.script_pubkey()
T::from_public_key(&pub_key, &coin_info)?.script_pubkey()
} else {
T::from_str(&self.inputs[0].address)?.script_pubkey()
T::from_str(&self.inputs[0].address)?.script_pubkey()
};

let mut sks = vec![];
Expand Down
2 changes: 1 addition & 1 deletion token-core/tcx-constants/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ tcx-common = { path = "../tcx-common" }
anyhow = { version = "=1.0.79", features = [] }
lazy_static = "=1.4.0"
serde_json = "=1.0.89"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
parking_lot = "=0.12.1"
6 changes: 3 additions & 3 deletions token-core/tcx-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ tcx-constants = {path="../tcx-constants"}
tcx-common = {path="../tcx-common"}

serde_json = "=1.0.89"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
rand = "=0.8.5"
tiny-keccak = { version = "=2.0.2", features = ["keccak"] }
scrypt = { version = "=0.10.0", default-features = false }
sha2 = "=0.10.6"
digest = "=0.10.6"
sha2 = "=0.10.8"
digest = "=0.10.7"
hmac = "=0.12.1"
aes = "=0.8.3"
ctr = "=0.9.2"
Expand Down
2 changes: 1 addition & 1 deletion token-core/tcx-filecoin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ blake2b-rs = "=0.2.0"
anyhow = { version = "=1.0.79", features = [] }
byteorder = "=1.4.3"
base32 = "=0.4.0"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
base64 = "=0.13.1"
lazy_static = "=1.4.0"
Expand Down
4 changes: 2 additions & 2 deletions token-core/tcx-keystore/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ secp256k1 = { version = "=0.24.3", features = ["rand", "recovery"] }
tiny-bip39 = "=1.0.0"
bitcoin_hashes = "=0.11.0"
uuid = { version = "=1.2.2", features = ["serde", "v4"] }
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
anyhow = { version = "=1.0.79", features = [] }
regex = "=1.9.3"
hex = "=0.4.3"

sha2 = "=0.10.6"
sha2 = "=0.10.8"
hmac-sha256 = "=1.1.6"
multihash = "=0.18.1"
lazy_static = "=1.4.0"
Expand Down
2 changes: 1 addition & 1 deletion token-core/tcx-libs/ed25519-dalek-bip32/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ std = ["derivation-path/std", "sha2/std", "ed25519-dalek/std"]

[dependencies]
derivation-path = { version = "0.2.0", default-features = false }
sha2 = { version = "0.10.1", default-features = false }
sha2 = { version = "0.10.8", default-features = false }
hmac = { version = "0.12.0", default-features = false }
ed25519-dalek = { version = "2.1.0", default-features = false, features = ["rand_core"] }

Expand Down
4 changes: 2 additions & 2 deletions token-core/tcx-migration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ bytes = "=1.4.0"
prost-types = "=0.11.2"

libc = "=0.2.140"
log = "=0.4.17"
log = "=0.4.22"
serde_json = "=1.0.89"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
anyhow = { version = "=1.0.79", features = [] }
lazy_static = "=1.4.0"
hex = "=0.4.3"
Expand Down
12 changes: 6 additions & 6 deletions token-core/tcx-primitive/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,20 +19,20 @@ hex-literal = "=0.3.4"
hex = "=0.4.3"
lazy_static = "=1.4.0"
anyhow = { version = "=1.0.79", features = [] }
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
serde_json = "=1.0.89"
tiny-bip39 = "=1.0.0"
ed25519-bip32 = "=0.3.2"
ed25519-dalek = "=2.1.0"
blake2b_simd = "=1.0.1"
blst = "=0.3.3"
num-bigint = "=0.4.3"
num-traits = "=0.2.15"
sha2 = "=0.10.6"
digest = "=0.10.6"
num-traits = "=0.2.19"
sha2 = "=0.10.8"
digest = "=0.10.7"
hkdf = "=0.12.3"

sp-core = "=7.0.0"
sp-core = { version = "=34.0.0", features = ["std"] }
regex = { version = "=1.9.3"}
schnorrkel = "=0.9.1"
schnorrkel = "=0.11.4"
thiserror = "=1.0.56"
3 changes: 2 additions & 1 deletion token-core/tcx-primitive/src/sr25519.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::ecc::{KeyError, PrivateKey as TraitPrivateKey, PublicKey as TraitPublicKey};
use crate::Result;
use schnorrkel::SecretKey;
use schnorrkel::keys::SecretKey;
use std::convert::TryFrom;
use tcx_common::{FromHex, ToHex};

Expand Down Expand Up @@ -39,6 +39,7 @@ impl TraitPrivateKey for Sr25519PrivateKey {
fn from_slice(data: &[u8]) -> Result<Self> {
let sec_key =
SecretKey::from_ed25519_bytes(data).map_err(|_| KeyError::InvalidSR25519Key)?;

Ok(Sr25519PrivateKey(Pair::from(sec_key)))
}

Expand Down
4 changes: 4 additions & 0 deletions token-core/tcx-proto/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,8 @@ fn main() {
//tcx-eth
env::set_var("OUT_DIR", "../tcx-eth/src");
prost_build::compile_protos(&["src/eth.proto"], &["src/"]).unwrap();

//tcx-ton
env::set_var("OUT_DIR", "../tcx-ton/src");
prost_build::compile_protos(&["src/ton.proto"], &["src/"]).unwrap();
}
25 changes: 25 additions & 0 deletions token-core/tcx-proto/src/ton.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
syntax = "proto3";
package transaction;




message TonRawTxIn {
string rawData = 1;
}

message TonTxOut {
string signature = 1;
}

message TonTxIn {
string from = 1;
string to = 2;
string amount = 3;
string memo = 4;
bool isJetton = 5;
string jettonAmount = 6;
uint64 queryId = 7;
int32 sequenceNo = 8;
string walletVersion = 9;
}
12 changes: 6 additions & 6 deletions token-core/tcx-substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,29 @@ tcx-primitive = { path = "../tcx-primitive" }
tcx-constants = { path = "../tcx-constants" }
tcx-common = { path = "../tcx-common" }

sp-core = "=7.0.0"
sp-core = { version = "=34.0.0", features = ["std"] }
byteorder = "=1.4.3"

prost = "=0.11.2"
bytes = "=1.4.0"
prost-types = "=0.11.2"

base58 = "=0.2.0"
codec = { package = "parity-scale-codec", default-features = false, features = ["derive"] }
codec = { package = "parity-scale-codec", version = "3.5.0", default-features = false, features = ["derive"] }
rand = "=0.8.5"

anyhow = { version = "=1.0.79", features = [] }
#tweetnacl = "0.2.1"
xsalsa20poly1305 = "=0.9.0"
serde_json = "=1.0.89"
serde = { version = "=1.0.147", features = ["derive"] }
serde = { version = "=1.0.210", features = ["derive"] }
base64 = "=0.13.1"
scrypt = { version = "=0.10.0", default-features = false }
regex = "=1.9.3"
schnorrkel = "=0.9.1"
schnorrkel = "=0.11.4"
thiserror = "=1.0.56"


[dev-dependencies]
sp-runtime = "=7.0.0"
sp-keyring = "=7.0.0"
sp-runtime = "=39.0.1"
#sp-keyring = "=7.0.0"
23 changes: 23 additions & 0 deletions token-core/tcx-ton/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "tcx-ton"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
tcx-keystore = { path = "../tcx-keystore" }
tcx-constants = { path = "../tcx-constants" }
tcx-primitive = { path = "../tcx-primitive" }
tcx-crypto = { path = "../tcx-crypto" }
tcx-common = { path = "../tcx-common" }

anyhow = { version = "=1.0.79", features = [] }
blake2b_simd = "=1.0.1"
hex = "=0.4.3"
bitcoin = "=0.29.2"
prost = "=0.11.2"
bytes = "=1.4.0"
prost-types = "=0.11.2"
tonlib-core = "0.19.1"
num-bigint = "0.4.3"
Loading
Loading