Skip to content

Commit 1d1283e

Browse files
authored
chore: remove providers deployment support (#1004)
* chore: remove providers support * chore: remove unused code * fix: remove unnecesary flag * test: fix register_fails_wrong_chain
1 parent 5f0673c commit 1d1283e

9 files changed

Lines changed: 68 additions & 1413 deletions

File tree

crates/pop-chains/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ pub mod bench;
1010
mod build;
1111
/// Provides functionality to construct, encode, sign, and submit chain extrinsics.
1212
mod call;
13-
/// Deployment providers' metadata and utility functions.
14-
mod deployer_providers;
1513
/// Error types and handling for the crate.
1614
mod errors;
1715
/// Code generation utilities.
@@ -26,6 +24,8 @@ pub mod omni_node;
2624
pub mod registry;
2725
/// Relay chain interaction and management.
2826
mod relay;
27+
/// Supported chains and their RPC endpoints.
28+
mod supported_chains;
2929
/// Template definitions and processing.
3030
mod templates;
3131
/// Common traits used throughout the crate.
@@ -62,12 +62,12 @@ pub use call::{
6262
},
6363
parse_and_format_events, set_up_client, sign_and_submit_extrinsic, submit_signed_extrinsic,
6464
};
65-
pub use deployer_providers::{DeploymentProvider, SupportedChains};
6665
pub use errors::Error;
6766
pub use indexmap::IndexSet;
6867
pub use new_chain::instantiate_template_dir;
6968
pub use new_pallet::{TemplatePalletConfig, create_pallet_template, new_pallet_options::*};
7069
pub use relay::{RelayChain, Reserved, clear_dmpq};
70+
pub use supported_chains::SupportedChains;
7171
pub use try_runtime::{
7272
TryRuntimeCliCommand, binary::*, parse, parse_try_state_string, run_try_runtime,
7373
shared_parameters::*, state, try_state_details, try_state_label, upgrade_checks_details,

crates/pop-chains/src/deployer_providers.rs renamed to crates/pop-chains/src/supported_chains.rs

Lines changed: 1 addition & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,80 +1,7 @@
11
// SPDX-License-Identifier: GPL-3.0
22

33
use std::time::{SystemTime, UNIX_EPOCH};
4-
use strum::{EnumMessage as _, EnumProperty as _};
5-
use strum_macros::{AsRefStr, Display, EnumMessage, EnumProperty, EnumString, VariantArray};
6-
7-
/// Supported deployment providers.
8-
#[derive(
9-
AsRefStr,
10-
Clone,
11-
Debug,
12-
Display,
13-
EnumMessage,
14-
EnumString,
15-
EnumProperty,
16-
Eq,
17-
PartialEq,
18-
VariantArray,
19-
)]
20-
pub enum DeploymentProvider {
21-
/// Polkadot Deployment Portal (PDP). This provider enables seamless deployment of Polkadot
22-
/// Native Chains through the Polkadot Cloud.
23-
#[strum(
24-
ascii_case_insensitive,
25-
serialize = "pdp",
26-
message = "Polkadot Deployment Portal",
27-
detailed_message = "Effortlessly deploy Polkadot Native Chains on the Polkadot Cloud",
28-
props(
29-
BaseURL = "https://staging.deploypolkadot.xyz",
30-
CollatorKeysURI = "/api/public/v1/parachains/{para_id}/collators/{chain_name}",
31-
DeployURI = "/api/public/v1/parachains/{para_id}/resources",
32-
)
33-
)]
34-
PDP,
35-
}
36-
37-
impl DeploymentProvider {
38-
/// Returns the name of the provider.
39-
pub fn name(&self) -> &'static str {
40-
self.get_message().unwrap_or_default()
41-
}
42-
43-
/// Returns the detailed description of the provider.
44-
pub fn description(&self) -> &'static str {
45-
self.get_detailed_message().unwrap_or_default()
46-
}
47-
48-
/// Returns the base URL of the provider.
49-
pub fn base_url(&self) -> &'static str {
50-
self.get_str("BaseURL").unwrap_or("")
51-
}
52-
53-
/// Constructs the full URI for querying collator keys.
54-
///
55-
/// # Arguments
56-
/// * `relay_chain_name` - The name of the relay chain where deployment will occur.
57-
/// * `id` - The ID for which collator keys are being requested.
58-
pub fn get_collator_keys_uri(&self, relay_chain_name: &str, id: u32) -> String {
59-
self.get_str("CollatorKeysURI")
60-
.map(|template| {
61-
template
62-
.replace("{para_id}", &id.to_string())
63-
.replace("{chain_name}", relay_chain_name)
64-
})
65-
.unwrap_or_default()
66-
}
67-
68-
/// Constructs the full URI for deploying a parachain.
69-
///
70-
/// # Arguments
71-
/// * `id` - The ID that is being deployed.
72-
pub fn get_deploy_uri(&self, id: u32) -> String {
73-
self.get_str("DeployURI")
74-
.map(|template| template.replace("{para_id}", &id.to_string()))
75-
.unwrap_or_default()
76-
}
77-
}
4+
use strum_macros::{Display, EnumString, VariantArray};
785

796
/// Supported chains with its public RPC endpoints.
807
#[derive(Debug, Clone, Copy, PartialEq, Eq, EnumString, Display, VariantArray, clap::ValueEnum)]
@@ -204,40 +131,6 @@ mod tests {
204131
use super::*;
205132
use strum::VariantArray;
206133

207-
#[test]
208-
fn get_name_works() {
209-
assert_eq!(DeploymentProvider::PDP.name(), "Polkadot Deployment Portal");
210-
}
211-
212-
#[test]
213-
fn get_description_works() {
214-
assert_eq!(
215-
DeploymentProvider::PDP.description(),
216-
"Effortlessly deploy Polkadot Native Chains on the Polkadot Cloud"
217-
);
218-
}
219-
220-
#[test]
221-
fn base_url_works() {
222-
let provider = DeploymentProvider::PDP;
223-
assert_eq!(provider.base_url(), "https://staging.deploypolkadot.xyz");
224-
}
225-
226-
#[test]
227-
fn get_collator_keys_uri_works() {
228-
let provider = DeploymentProvider::PDP;
229-
assert_eq!(
230-
provider.get_collator_keys_uri("paseo", 2000),
231-
"/api/public/v1/parachains/2000/collators/paseo"
232-
);
233-
}
234-
235-
#[test]
236-
fn get_deploy_uri_works() {
237-
let provider = DeploymentProvider::PDP;
238-
assert_eq!(provider.get_deploy_uri(2000), "/api/public/v1/parachains/2000/resources");
239-
}
240-
241134
#[test]
242135
fn ensures_get_rpc_url_returns_valid_url() {
243136
for chain in SupportedChains::VARIANTS {

crates/pop-chains/src/templates.rs

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ pub enum ChainTemplate {
102102
Repository = "https://github.com/r0gue-io/base-parachain",
103103
Network = "./network.toml",
104104
License = "Unlicense",
105-
DeploymentName = "POP_STANDARD"
106105
)
107106
)]
108107
Standard,
@@ -117,7 +116,6 @@ pub enum ChainTemplate {
117116
Repository = "https://github.com/r0gue-io/assets-parachain",
118117
Network = "./network.toml",
119118
License = "Unlicense",
120-
DeploymentName = "POP_ASSETS"
121119
)
122120
)]
123121
Assets,
@@ -131,7 +129,6 @@ pub enum ChainTemplate {
131129
Repository = "https://github.com/r0gue-io/contracts-parachain",
132130
Network = "./network.toml",
133131
License = "Unlicense",
134-
DeploymentName = "POP_CONTRACTS"
135132
)
136133
)]
137134
Contracts,
@@ -147,7 +144,6 @@ pub enum ChainTemplate {
147144
SupportedVersions = "v1.0.0,v2.0.1,v2.0.3,v3.0.0,v4.0.0",
148145
IsAudited = "true",
149146
License = "GPL-3.0",
150-
DeploymentName = "OZ_GENERIC"
151147
)
152148
)]
153149
OpenZeppelinGeneric,
@@ -163,7 +159,6 @@ pub enum ChainTemplate {
163159
SupportedVersions = "v2.0.3,v3.0.0,v4.0.0",
164160
IsAudited = "true",
165161
License = "GPL-3.0",
166-
DeploymentName = "OZ_EVM"
167162
)
168163
)]
169164
OpenZeppelinEVM,
@@ -177,7 +172,6 @@ pub enum ChainTemplate {
177172
Repository = "https://github.com/paritytech/polkadot-sdk-parachain-template",
178173
Network = "./zombienet.toml",
179174
License = "Unlicense",
180-
DeploymentName = "PARITY_GENERIC"
181175
)
182176
)]
183177
ParityGeneric,
@@ -245,28 +239,6 @@ impl ChainTemplate {
245239
self.get_str("License")
246240
}
247241

248-
/// Returns the deployment name for the parachain if defined.
249-
pub fn deployment_name(&self) -> Option<&str> {
250-
self.get_str("DeploymentName")
251-
}
252-
253-
/// Retrieves the deployment name from the `based_on` value.
254-
pub fn deployment_name_from_based_on(based_on: &str) -> Option<String> {
255-
// OpenZeppelin special cases first (https://github.com/OpenZeppelin/polkadot-runtime-templates/pull/406)
256-
let mapped_based_on = match based_on {
257-
"OpenZeppelin EVM Template" => Some(ChainTemplate::OpenZeppelinEVM),
258-
"OpenZeppelin Generic Template" => Some(ChainTemplate::OpenZeppelinGeneric),
259-
_ => None,
260-
};
261-
if let Some(variant) = mapped_based_on {
262-
return variant.deployment_name().map(String::from);
263-
}
264-
ChainTemplate::VARIANTS
265-
.iter()
266-
.find(|variant| variant.as_ref() == based_on)
267-
.and_then(|variant| variant.deployment_name().map(String::from))
268-
}
269-
270242
/// Gets the template name, removing the provider if present.
271243
pub fn template_name_without_provider(&self) -> &str {
272244
let name = self.as_ref();
@@ -375,20 +347,6 @@ mod tests {
375347
.into()
376348
}
377349

378-
fn template_deployment_name() -> HashMap<ChainTemplate, Option<&'static str>> {
379-
[
380-
(Standard, Some("POP_STANDARD")),
381-
(Assets, Some("POP_ASSETS")),
382-
(Contracts, Some("POP_CONTRACTS")),
383-
(OpenZeppelinGeneric, Some("OZ_GENERIC")),
384-
(OpenZeppelinEVM, Some("OZ_EVM")),
385-
(ParityGeneric, Some("PARITY_GENERIC")),
386-
(TestTemplate01, None),
387-
(TestTemplate02, None),
388-
]
389-
.into()
390-
}
391-
392350
#[test]
393351
fn test_is_template_correct() {
394352
for template in ChainTemplate::VARIANTS {
@@ -445,33 +403,6 @@ mod tests {
445403
}
446404
}
447405

448-
#[test]
449-
fn deployment_name_works() {
450-
let deployment_name = template_deployment_name();
451-
for template in ChainTemplate::VARIANTS {
452-
assert_eq!(template.deployment_name(), deployment_name[template]);
453-
}
454-
}
455-
456-
#[test]
457-
fn deployment_name_from_based_on_works() {
458-
for template in ChainTemplate::VARIANTS {
459-
assert_eq!(
460-
ChainTemplate::deployment_name_from_based_on(template.as_ref()),
461-
template.deployment_name().map(String::from),
462-
);
463-
}
464-
// test special cases
465-
assert_eq!(
466-
ChainTemplate::deployment_name_from_based_on("OpenZeppelin EVM Template"),
467-
Some(OpenZeppelinEVM.deployment_name().unwrap().to_string())
468-
);
469-
assert_eq!(
470-
ChainTemplate::deployment_name_from_based_on("OpenZeppelin Generic Template"),
471-
Some(OpenZeppelinGeneric.deployment_name().unwrap().to_string())
472-
);
473-
}
474-
475406
#[test]
476407
fn test_default_template_of_provider() {
477408
let mut provider = Provider::Pop;

0 commit comments

Comments
 (0)