Skip to content

Commit

Permalink
πŸ‘¨πŸ»β€πŸ’» Improve documentation and test scripts (#332)
Browse files Browse the repository at this point in the history
## What?
- Add comments to migration functinos
- Remove funding assets creation from chopsticks setup
- Fix paseo to use polimec instead of politest
  • Loading branch information
JuaniRios authored Jun 24, 2024
1 parent 6279d25 commit 6a746b3
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 78 deletions.
2 changes: 1 addition & 1 deletion nodes/parachain/src/chain_spec/polimec_paseo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ pub fn get_live_chain_spec() -> GenericChainSpec {
};

GenericChainSpec::builder(
politest_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
polimec_runtime::WASM_BINARY.expect("WASM binary was not built, please build it!"),
Extensions { relay_chain: "paseo".into(), para_id: genesis_config_params.id.into() },
)
.with_name("Polimec Paseo")
Expand Down
13 changes: 13 additions & 0 deletions pallets/funding/src/functions/7_ct_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Handle the channel open request from the relay on behalf of a parachain.
/// If the parachain id belongs to a funded project with the same project id, then send an acceptance message and a request for a
/// channel in the opposite direction to the relay.
pub fn do_handle_channel_open_request(message: Instruction) -> XcmResult {
// TODO: set these constants with a proper value
const EXECUTION_DOT: MultiAsset = MultiAsset {
Expand Down Expand Up @@ -115,6 +118,8 @@ impl<T: Config> Pallet<T> {
}
}

/// Handle the channel accepted message of project->Polimec from the relay on behalf of the project parachain.
/// Start the migration readiness check for the project.
pub fn do_handle_channel_accepted(message: Instruction) -> XcmResult {
match message {
Instruction::HrmpChannelAccepted { recipient } => {
Expand Down Expand Up @@ -146,6 +151,8 @@ impl<T: Config> Pallet<T> {
}
}

/// After the bidirectional HRMP channels are established, check that the project chain has the Polimec receiver pallet,
/// and has minted the amount of CTs sold to the Polimec sovereign account.
#[transactional]
pub fn do_start_migration_readiness_check(caller: &AccountIdOf<T>, project_id: ProjectId) -> DispatchResult {
// * Get variables *
Expand Down Expand Up @@ -237,6 +244,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Handle the migration readiness check response from the project chain.
#[transactional]
pub fn do_migration_check_response(
location: MultiLocation,
Expand Down Expand Up @@ -326,6 +334,9 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Migrate all the CTs of a project for a single participant
/// This entails transferring the funds from the Polimec sovereign account to the participant account, and applying
/// a vesting schedule if necessary.
#[transactional]
pub fn do_migrate_one_participant(project_id: ProjectId, participant: AccountIdOf<T>) -> DispatchResult {
// * Get variables *
Expand Down Expand Up @@ -370,6 +381,7 @@ impl<T: Config> Pallet<T> {
Ok(())
}

/// Mark the migration item that corresponds to a single participation as confirmed or failed.
#[transactional]
pub fn do_confirm_migrations(location: MultiLocation, query_id: QueryId, response: Response) -> DispatchResult {
use xcm::v3::prelude::*;
Expand All @@ -382,6 +394,7 @@ impl<T: Config> Pallet<T> {
Error::<T>::WrongParaId
);


let status = match response {
Response::DispatchResult(MaybeErrorCode::Success) => {
Self::change_migration_status(project_id, participant.clone(), MigrationStatus::Confirmed)?;
Expand Down
2 changes: 1 addition & 1 deletion runtimes/polimec/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -279,5 +279,5 @@ try-runtime = [
on-chain-release-build = [ "sp-api/disable-logging" ]

development-settings = [
"shared-configuration/development-settings"
"shared-configuration/development-settings",
]
76 changes: 0 additions & 76 deletions scripts/chopsticks/assethub-transfers/polkadot-polimec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,79 +13,3 @@ import-storage:
{ providers: 1, data: { free: "10000000000000000" } },
],
]
# This will be deleted once Polimec has all funding assets registered in ForeignAssets pallet
ForeignAssets:
Asset:
[
[
[1984],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
[
[10],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
[
[1337],
{
owner: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
issuer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
admin: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
freezer: "0xba143e2096e073cb9cddc78e6f4969d8a02160d716a69e08214caf5339d88c42",
supply: 1000000000,
deposit: 10,
minBalance: 10,
isSufficient: false,
accounts: 1,
sufficients: 1,
approvals: 0,
status: Live,
},
],
]

Metadata:
[
[[1984], { symbol: "USDT", name: USDT, decimals: 6, isFrozen: false }],
[[10], { symbol: "DOT", name: DOT, decimals: 10, isFrozen: false }],
[[1337], { symbol: "USDC", name: USDC, decimals: 6, isFrozen: false }],
]

Account:
[
[
[1984, 15CyvMWHKwbAPQ3ekqRFWLyq3kcjU8ypMuuGfsMnxanW85WZ],
{ balance: 1000000000 },
],
[
[10, 15CyvMWHKwbAPQ3ekqRFWLyq3kcjU8ypMuuGfsMnxanW85WZ],
{ balance: 1000000000 },
],
]

0 comments on commit 6a746b3

Please sign in to comment.