Skip to content

Commit

Permalink
chore(nns): Add api <--> internal type conversions (#393)
Browse files Browse the repository at this point in the history
### Why
To improve build times, we want other parts of the build to not depend
on the entire governance crate. Additionally, we want to separate API
types from internal governance types so that they can evolve
independently. This is a first mechanical step towards that end.
### Changes
This MR creates type conversions from governance types to api types. It
does not yet use them, but allows Governance to start using them (in
followup MRs) in the main canister file.
  • Loading branch information
max-dfinity authored Jul 17, 2024
1 parent 9a3aa19 commit d732d9d
Show file tree
Hide file tree
Showing 6 changed files with 4,522 additions and 2 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions rs/nns/governance/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,14 @@ BASE_DEPENDENCIES = [
# dependencies (`DEPENDENCIES`), or `DEPENDENCIES_WITH_TEST_FEATURES` feature previews.
DEPENDENCIES = BASE_DEPENDENCIES + [
"//rs/nns/constants",
"//rs/nns/governance/api",
"//rs/nns/sns-wasm",
"//rs/sns/init",
"//rs/sns/swap",
]

DEPENDENCIES_WITH_TEST_FEATURES = BASE_DEPENDENCIES + [
"//rs/nns/governance/api:api--test_feature",
"//rs/nns/constants:constants--test_feature",
"//rs/nns/sns-wasm:sns-wasm--test_feature",
"//rs/sns/init:init--test_feature",
Expand Down
1 change: 1 addition & 0 deletions rs/nns/governance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ ic-neurons-fund = { path = "../../nervous_system/neurons_fund" }
ic-nns-common = { path = "../common" }
ic-nns-constants = { path = "../constants" }
ic-nns-gtc-accounts = { path = "../gtc_accounts" }
ic-nns-governance-api = { path = "./api" }
ic-protobuf = { path = "../../protobuf" }
ic-sns-init = { path = "../../sns/init" } # This is just for a couple of PB definitions.
ic-sns-root = { path = "../../sns/root" } # This is just for a couple of PB definitions.
Expand Down
23 changes: 21 additions & 2 deletions rs/nns/governance/api/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ BASE_DEPENDENCIES = [
"//rs/protobuf",
"//rs/rosetta-api/icp_ledger",
"//rs/sns/root",
"//rs/sns/swap",
"//rs/types/base_types",
"//rs/types/types",
"//rs/utils",
Expand All @@ -27,7 +26,13 @@ BASE_DEPENDENCIES = [

# Each target declared in this file may choose either these (release-ready)
# dependencies (`DEPENDENCIES`), or `DEPENDENCIES_WITH_TEST_FEATURES` feature previews.
DEPENDENCIES = BASE_DEPENDENCIES
DEPENDENCIES = BASE_DEPENDENCIES + [
"//rs/sns/swap",
]

DEPENDENCIES_WITH_TEST_FEATURES = BASE_DEPENDENCIES + [
"//rs/sns/swap:swap--test_feature",
]

MACRO_DEPENDENCIES = [
# Keep sorted.
Expand All @@ -49,5 +54,19 @@ rust_library(
deps = DEPENDENCIES,
)

rust_library(
name = "api--test_feature",
srcs = glob(
["src/**/*.rs"],
exclude = ["**/*tests.rs"],
),
aliases = ALIASES,
crate_features = ["test"],
crate_name = "ic_nns_governance_api",
proc_macro_deps = MACRO_DEPENDENCIES,
version = "0.9.0",
deps = DEPENDENCIES_WITH_TEST_FEATURES,
)

# needed for check_generated_files test
exports_files(["src"])
Loading

0 comments on commit d732d9d

Please sign in to comment.