-
Notifications
You must be signed in to change notification settings - Fork 109
0xmovses/sec signing integration #1023
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
Draft
0xmovses
wants to merge
10
commits into
l-monninger/secure-signing-e2e-integration
Choose a base branch
from
0xmovses/sec-signing-integration
base: l-monninger/secure-signing-e2e-integration
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
ab26911
create: initial setup for mint op
0xmovses 3262f96
fix: grab maptos k
0xmovses f88ee4a
update: build burn tx
0xmovses 2938f80
fix: pk
0xmovses 1a07ac2
feat: complete burn call
0xmovses 9321937
chore: add comment for reviewer
0xmovses ca3ad11
fix: typo
0xmovses d9f682d
important feat: add emoji to CLI helper output
0xmovses d9d3f6b
add basic mint ops and structure
0xmovses 13d27c8
fix: build
0xmovses File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
158 changes: 158 additions & 0 deletions
158
networks/movement/movement-full-node/src/admin/ops/burn.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,158 @@ | ||
| #[allow(unused_imports)] | ||
| use anyhow::Context; | ||
| use tokio::process::Command; | ||
| use crate::common_args::MovementArgs; | ||
| use aptos_sdk::{coin_client::CoinClient, move_types::language_storage::StructTag, rest_client::{Client, FaucetClient}, transaction_builder::TransactionBuilder, types::{chain_id::ChainId, transaction::{EntryFunction, Script, TransactionArgument}, LocalAccount}}; | ||
| use clap::Parser; | ||
| use once_cell::sync::Lazy; | ||
| use url::Url; | ||
| use std::{fs, str::FromStr, time::{SystemTime, UNIX_EPOCH}}; | ||
| use aptos_sdk::{ | ||
| coin_client::CoinClient, | ||
| crypto::{SigningKey, ValidCryptoMaterialStringExt}, | ||
| move_types::{ | ||
| identifier::Identifier, | ||
| language_storage::{ModuleId, TypeTag}, | ||
| }, | ||
| rest_client::{Client, FaucetClient, Transaction}, | ||
| transaction_builder::TransactionFactory, | ||
| types::{account_address::AccountAddress, transaction::TransactionPayload}, | ||
| }; | ||
|
|
||
| #[derive(Debug, Parser, Clone)] | ||
| #[clap(rename_all = "kebab-case", about = "Mints and locks tokens.")] | ||
| pub struct Burn { | ||
| #[clap(flatten)] | ||
| pub movement_args: MovementArgs, | ||
| } | ||
|
|
||
| static SUZUKA_CONFIG: Lazy<movement_config::Config> = Lazy::new(|| { | ||
| let dot_movement = dot_movement::DotMovement::try_from_env().unwrap(); | ||
| let config = dot_movement.try_get_config_from_json::<movement_config::Config>().unwrap(); | ||
| config | ||
| }); | ||
|
|
||
| // :!:>section_1c | ||
| static NODE_URL: Lazy<Url> = Lazy::new(|| { | ||
| let node_connection_address = SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .client | ||
| .maptos_rest_connection_hostname | ||
| .clone(); | ||
| let node_connection_port = SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .client | ||
| .maptos_rest_connection_port | ||
| .clone(); | ||
|
|
||
| let node_connection_url = | ||
| format!("http://{}:{}", node_connection_address, node_connection_port); | ||
|
|
||
| Url::from_str(node_connection_url.as_str()).unwrap() | ||
| }); | ||
|
|
||
| static FAUCET_URL: Lazy<Url> = Lazy::new(|| { | ||
| let faucet_listen_address = SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .client | ||
| .maptos_faucet_rest_connection_hostname | ||
| .clone(); | ||
| let faucet_listen_port = SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .client | ||
| .maptos_faucet_rest_connection_port | ||
| .clone(); | ||
|
|
||
| let faucet_listen_url = format!("http://{}:{}", faucet_listen_address, faucet_listen_port); | ||
|
|
||
| Url::from_str(faucet_listen_url.as_str()).unwrap() | ||
| }); | ||
|
|
||
| static MAPTOS_PRIVATE_KEY: Lazy<Url> = Lazy::new(|| { | ||
| let pk= SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .chain | ||
| .maptos_private_key | ||
| .clone(); | ||
|
|
||
| Url::from_str(pk).unwrap() | ||
| }); | ||
|
|
||
| const DEAD_ADDRESS: &str = "000000000000000000000000000000000000000000000000000000000000dead"; | ||
|
|
||
| impl Burn { | ||
|
|
||
| pub async fn execute(&self) -> Result<(), anyhow::Error> { | ||
| let rest_client = Client::new(NODE_URL.clone()); | ||
| let faucet_client = FaucetClient::new(FAUCET_URL.clone(), NODE_URL.clone()); | ||
| let coin_client = CoinClient::new(&rest_client); | ||
| let dead_address = AccountAddress::from_str(DEAD_ADDRESS)?; | ||
| let chain_id = rest_client | ||
| .get_index() | ||
| .await | ||
| .context("failed to get chain ID")? | ||
| .inner() | ||
| .chain_id; | ||
|
|
||
| let mut core_resources_account: LocalAccount = LocalAccount::from_private_key( | ||
| MAPTOS_PRIVATE_KEY.clone().as_str(), | ||
| 0, | ||
| )?; | ||
|
|
||
| tracing::info!("Created core resources account"); | ||
| tracing::debug!("core_resources_account address: {}", core_resources_account.address()); | ||
|
|
||
| // Create account for transactions and gas collection | ||
| let private_key = SUZUKA_CONFIG | ||
| .execution_config | ||
| .maptos_config | ||
| .chain | ||
| .maptos_private_key | ||
| .to_string(); | ||
|
|
||
| // I know that we shouldn't compile on cmd execution, but we can optimise this later. | ||
| let compile_status = Command::new("movement") | ||
| .args([ | ||
| "move", | ||
| "compile", | ||
| "--package-dir", | ||
| "networks/movement/movement-full-node/ops/move-modules", | ||
| ]) | ||
| .status() | ||
| .await | ||
| .expect("Failed to execute `movement compile` command"); | ||
|
|
||
| let code = fs::read("networks/movement/movement-full-node/ops/move-modules/burn_from.move")?; | ||
|
|
||
| let args = vec![TransactionArgument::Address(dead_address), TransactionArgument::U64(1), TransactionArgument::U8Vector(StructTag { | ||
| address: AccountAddress::from_hex_literal("0x1")?, | ||
| module: Identifier::new("coin")?, | ||
| name: Identifier::new("BurnCapability")?, | ||
| type_args: vec![StructTag{ | ||
| address: AccountAddress::from_hex_literal("0x1")?, | ||
| module: Identifier::new("aptos_coin")?, | ||
| name: Identifier::new("AptosCoin")?, | ||
| type_args: vec![], | ||
| }.into()], | ||
| }.access_vector())]; | ||
|
|
||
| let script_payload = TransactionPayload::Script(Script::new(code, vec![], args)); | ||
|
|
||
| let tx_response = rest_client.submit_and_wait(&core_resources_account.sign_with_transaction_builder( | ||
| TransactionBuilder::new( | ||
| script_payload, | ||
| SystemTime::now().duration_since(UNIX_EPOCH)?.as_secs() + 60, | ||
| ChainId::new(chain_id), | ||
| ).sequence_number(core_resources_account.sequence_number()) | ||
| )).await?; | ||
|
|
||
| tracing::info!("Transaction submitted: {:?}", tx_response); | ||
|
|
||
| Ok(()) | ||
| } | ||
| } | ||
12 changes: 3 additions & 9 deletions
12
...ment-full-node/src/admin/ops/mint_lock.rs → .../movement-full-node/src/admin/ops/mint.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,15 +1,9 @@ | ||
| use clap::Parser; | ||
| use crate::common_args::MovementArgs; | ||
| use clap::Parser; | ||
|
|
||
| #[derive(Debug, Parser, Clone)] | ||
| #[clap(rename_all = "kebab-case", about = "Mints and locks tokens.")] | ||
| pub struct MintLock { | ||
| pub struct Mint { | ||
| #[clap(flatten)] | ||
| pub movement_args: MovementArgs, | ||
| } | ||
|
|
||
| impl MintLock { | ||
| pub async fn execute(&self) -> Result<(), anyhow::Error> { | ||
| Ok(()) | ||
| } | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,17 +1,20 @@ | ||
| pub mod mint_lock; | ||
| pub mod mint; | ||
| pub mod burn; | ||
|
|
||
| use clap::Subcommand; | ||
|
|
||
| #[derive(Subcommand, Debug)] | ||
| #[clap(rename_all = "kebab-case", about = "Commands for bespoke network operations")] | ||
| pub enum Ops { | ||
| MintLock(mint_lock::MintLock), | ||
| Mint(mint::Mint), | ||
| Burn(burn::Burn), | ||
| } | ||
|
|
||
| impl Ops { | ||
| pub async fn execute(&self) -> Result<(), anyhow::Error> { | ||
| match self { | ||
| Ops::MintLock(mint_lock) => mint_lock.execute().await, | ||
| Ops::Mint(mint) => mint.execute().await, | ||
| Ops::Burn(burn) => burn.execute().await, | ||
| } | ||
| } | ||
| } |
12 changes: 12 additions & 0 deletions
12
networks/movement/movement-full-node/src/admin/ops/move-modules/burn_from.move
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| script { | ||
| use aptos_framework::aptos_account; | ||
| use aptos_framework::aptos_governance; | ||
| use aptos_framework::coin; | ||
| use aptos_framework::coin::{BurnCapability}; | ||
| use aptos_framework::aptos_coin::AptosCoin; | ||
|
|
||
|
|
||
| fun burn_from(core_resources: &signer, account: address, amount: u64, burn_cap: &BurnCapability<AptosCoin>) { | ||
| coin::burn_from<AptosCoin>(account, amount, burn_cap); | ||
| } | ||
| } |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull the changes from here and use the
try_raw_private_keymethod: #1018