[package]
name = "avalanche-types"

# "avalanche-sdk" version must be consistent with this version
# e.g., "0.0.x" in "avalanche-types" maps to "0.x.y" in "avalanche-sdk" 
version = "0.0.99" # https://crates.io/crates/avalanche-types

edition = "2021"
rust-version = "1.64"
publish = true
description = "Avalanche types"
license = "BSD-3-Clause"
homepage = "https://avax.network"
repository = "https://github.com/ava-labs/avalanche-rust/tree/main/crates/avalanche-types"
readme = "README.md"

[dependencies]
async-trait = "0.1.58" # for "key::secp256k1" sign trait
bech32 = "0.9.1"
bs58 = "0.4.0" # for "formatting", https://crates.io/crates/bs58
bytes = "1.2.1"
chrono = "0.4.22"
cmp-manager = "0.0.1"
futures = "0.3.25"
hex = "0.4.3"
lazy_static = "1.4.0"
log = "0.4.17"
prefix-manager = "0.0.2"
ring = "0.16.20"
rust-embed = "6.4.2"
rustls-pemfile = "1.0.1"
serde = { version = "1.0.147", features = ["derive"] } # https://github.com/serde-rs/serde/releases
serde_json = "1.0.87" # https://github.com/serde-rs/json/releases
serde_with = { version = "2.0.1", features = ["hex"] }
serde_yaml = "0.9.14" # https://github.com/dtolnay/serde-yaml/releases
thiserror = "1.0.37"
zerocopy = "0.6.1"

# for "jsonrpc" and "evm"
rlp = { version = "0.5.2", optional = true }
rlp-derive = { version = "0.1.0", optional = true }

# for "secp256k1" and "address"
ecdsa = { version = "0.14.8", optional = false }
hmac = { version = "0.12.1", optional = false }
k256 = { version = "0.11.6", features = ["ecdsa", "keccak256"], optional = false }
primitive-types = { version = "0.12.0", features = ["impl-rlp", "impl-serde"], optional = false } # https://crates.io/crates/primitive-types
rand = { version = "0.8.5", optional = false }
ripemd = { version = "0.1.3", optional = false }
sha2 = { version = "0.10.6", optional = false }
sha3 = { version = "0.10.6", optional = false }

# for "secp256k1" and "address"
ethers-core = { version = "1.0.0", optional = true }

# [OPTIONAL] for "libsecp256k1"
secp256k1 = { version = "0.24.1", features = ["global-context", "rand-std", "recovery"], optional = true } # https://crates.io/crates/secp256k1

# [OPTIONAL] for "aws_kms"
aws-manager = { version = "0.19.8", optional = true } # https://github.com/gyuho/aws-manager/tags
aws-sdk-kms = { version = "0.19.0", optional = true } # https://crates.io/crates/aws-sdk-kms/versions
aws-smithy-types = { version = "0.49.0", optional = true } # https://github.com/awslabs/smithy-rs/releases

# [OPTIONAL] for "cert"
rcgen = { version = "0.10.0", optional = true } # https://github.com/est31/rcgen
rsa = { version = "0.6.1", features = ["pem"], optional = true } # https://crates.io/crates/rsa
rustls = { version = "0.20.7", optional = true } # https://github.com/rustls/rustls/tags

# [OPTIONAL] for "message_compress_gzip"
flate2 = { version = "1.0.24", optional = true }

# [OPTIONAL] for "mnemonic"
bip32 = { version = "0.4.0", optional = true }
rand_core = { version = "0.6.4", features = ["std"], optional = true }

# [OPTIONAL] for "rpcchainvm"
avalanche-proto = { version = "0.16.1", features = ["aliasreader", "keystore", "sharedmemory", "subnetlookup", "rpcdb", "google_protobuf"], optional = true }
http = {version = "0.2.8", optional = true}
hyper = "0.14.20"
jsonrpc-core = {version = "18.0.0", optional = true }
jsonrpc-http-server = {version = "18.0.0", optional = true }
num-derive = { version = "0.3.3", optional = true }
num-traits = { version = "0.2.15", optional = true }
prost = { version = "0.11.0", optional = true } # prost-build requires "cmake", https://github.com/tokio-rs/prost/releases
semver = { version = "1.0.14", optional = true }
tokio = { version = "1.21.2", features = ["fs", "rt-multi-thread"], optional = true } # https://github.com/tokio-rs/tokio/releases
tokio-stream = { version = "0.1.11", features = ["net"], optional = true }
tonic = { version = "0.8.2", features = ["gzip"], optional = true } # https://github.com/hyperium/tonic/tags
tonic-health = { version = "0.7.1", optional = true }
tonic-reflection = { version = "0.5.0", optional = true }
tower-service = "0.3.2"

# [OPTIONAL] for "num_bigint"
num-bigint = { version = "0.4.3", optional = true }

[dev-dependencies]
env_logger = "0.9.1"
id-manager = "0.0.1"
random-manager = "0.0.1"
tempfile = "3.3.0"
tokio-stream = { version = "0.1.11", features = ["net"]}
tokio-test = "0.4.2"

[features]
default = [
    "cert",
    "jsonrpc",
    "message_compress_gzip",
    "mnemonic",
    "rpcchainvm",

    "evm",
    "ethers_core",  # TODO: remove

    # optional features
    # "avalanchego",
    # "aws_kms",
    # "libsecp256k1",
    # "subnet_evm",
    # "num_bigint",
]

avalanchego = []
aws_kms = ["aws-manager", "aws-sdk-kms", "aws-smithy-types"]
cert = ["rcgen", "rsa", "rustls"]
ethers_core = ["ethers-core"]
evm = ["rlp", "rlp-derive"]
jsonrpc = []
libsecp256k1 = ["secp256k1"]
message_compress_gzip = ["flate2"]
mnemonic = ["bip32", "rand_core"]
num_bigint = ["num-bigint"]
rpcchainvm = ["avalanche-proto", "http", "jsonrpc-core", "num-derive", "num-traits", "prost", "semver", "tokio", "tokio-stream", "tonic", "tonic-health", "tonic-reflection"]
subnet_evm = []

[[example]]
name = "key_cert"
required-features = ["cert"]

[[example]]
name = "key_secp256k1_aws_kms"
required-features = ["aws_kms"]

[[example]]
name = "key_secp256k1_mnemonic_derive_load"
required-features = ["mnemonic"]

[[test]]
name = "integration"
path = "tests/integration_tests.rs"
required-features = ["rpcchainvm"]

[package.metadata.cargo-udeps.ignore]
normal = ["rsa"]
development = ["id-manager", "tokio-test"]
