Skip to content

Commit

Permalink
progress
Browse files Browse the repository at this point in the history
  • Loading branch information
Szegoo committed Jan 3, 2024
1 parent 7b81447 commit dc25191
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
6 changes: 6 additions & 0 deletions registry.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,11 @@
"rpc_url": "wss://acala-rpc.dwellir.com",
"para_id": 2000,
"relay_chain": "Polkadot"
},
{
"name": "Acala",
"rpc_url": "wss://acala-rpc.dwellir.com",
"para_id": 2005,
"relay_chain": "Polkadot"
}
]
21 changes: 16 additions & 5 deletions routes/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// along with RegionX. If not, see <https://www.gnu.org/licenses/>.

use crate::*;
use polkadot_core_primitives::Block;
use polkadot_core_primitives::{AccountId, Block, BlockNumber};
use rocket::{post, serde::json::Json};
use shared::{
config::config,
Expand All @@ -23,17 +23,22 @@ use shared::{
use sp_runtime::generic::SignedBlock;
use subxt::{
backend::rpc::{rpc_params, RpcClient},
tx::TxPayload,
utils::H256,
OnlineClient, PolkadotConfig,
};
use types::{BlockNumber, Parachain};
use types::Parachain;

#[subxt::subxt(runtime_metadata_path = "../artifacts/metadata.scale")]
mod polkadot {}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
#[serde(crate = "rocket::serde")]
pub struct PaymentInfo {
/// The block number in which the payment occurred.
block_number: BlockNumber,
/// The extrinsic that pays for the subscription.
extrinsic_hash: H256,
payer: AccountId,
}

#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize, Hash)]
Expand Down Expand Up @@ -96,7 +101,7 @@ curl -X POST http://127.0.0.1:8000/register_para -H "Content-Type: application/j
},
"payment_info": {
"block_number": 18881079,
"extrinsic_hash": "0x31f1a85007834dd8cc138be74da4f626db752b139043d252c047d401e5f63207"
"payer": "126X27SbhrV19mBFawys3ovkyBS87SGfYwtwa8J2FjHrtbmA"
}
}'
*/
Expand All @@ -115,8 +120,14 @@ async fn check_registration_payment(
let rpc_response = maybe_rpc_response.unwrap();

let opaque_block: SignedBlock<Block> = serde_json::from_value(rpc_response).unwrap();
let opaque_extrinsics = opaque_block.block.extrinsics;

if let Ok(online_client) = OnlineClient::<PolkadotConfig>::from_url(payment_rpc_url).await {
let payment = polkadot::tx().system().remark(vec![]);
let payment_encoded = payment.encode_call_data(&online_client.metadata()).unwrap();

println!("{:?}", opaque_block);
println!("{:?}", payment_encoded);
}
}

Ok(())
Expand Down
2 changes: 0 additions & 2 deletions types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ pub type Timestamp = u64;
/// Type used for identifying parachains.
pub type ParaId = u32;

pub type BlockNumber = u64;

#[derive(Clone, PartialEq, Eq, Debug, Serialize, Deserialize, Hash)]
#[serde(crate = "rocket::serde")]
pub enum RelayChain {
Expand Down

0 comments on commit dc25191

Please sign in to comment.