Skip to content

Commit

Permalink
Add recipient feature, prices and custom RPC to domains pallet (#226)
Browse files Browse the repository at this point in the history
* Add recipient field to register domain (#220)

* Add beneficiary field for registering domains

- Introduce DomainDeposit structure
  - Change `domain_deposit` type in `DomainMeta` structure: `Balance` to `DomainDeposit`
- Fix clippy warnings

* Remove force_register_domain

* Update transaction_version to 5

* Fix mocks and tests

* Fix runtime

* Add migration to domains pallet

* Add recipient field to DomainRegistered event

* Fix benchmarks

* Add prices configs to domains pallet (#221)

* Remove MaxPromoDomainsPerAccount

* Update spec_version to 27

* Improve docs

- Changed MinDomainLength to 4 (to allow domains purchase with less chars in it)

---------

Co-authored-by: Alex Siman <[email protected]>

* Add custom RPC to domains pallet (#223)

* Add more tests to domains pallet (#224)

---------

Co-authored-by: Alex Siman <[email protected]>

* Fix migration, try-runtime and weights (#227)

* Update weights

* Bump crates version to 0.1.9 (#228)

* Update Cargo.lock

---------

Co-authored-by: Alex Siman <[email protected]>
  • Loading branch information
F3Joule and siman authored Aug 10, 2023
1 parent 2fad6ce commit e2201df
Show file tree
Hide file tree
Showing 51 changed files with 879 additions and 312 deletions.
70 changes: 48 additions & 22 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion integration-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'integration-tests'
version = '0.1.8'
version = '0.1.9'
authors = ['DappForce <[email protected]>']
edition = '2021'
license = 'GPL-3.0-only'
Expand Down
3 changes: 2 additions & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "subsocial-collator"
version = "0.1.8"
version = "0.1.9"
build = "build.rs"
authors = ["DappForce <[email protected]>"]
edition = "2021"
Expand All @@ -21,6 +21,7 @@ jsonrpsee = { version = "0.16.2", features = ["server"] }

# Local
subsocial-parachain-runtime = { path = "../runtime" }
pallet-domains-rpc = { path = "../pallets/domains/rpc" }

# Substrate
frame-benchmarking = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
Expand Down
5 changes: 4 additions & 1 deletion node/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,20 @@ where
+ Sync
+ 'static,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: pallet_domains_rpc::DomainsRuntimeApi<Block, Balance>,
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Nonce>,
C::Api: BlockBuilder<Block>,
P: TransactionPool + Sync + Send + 'static,
{
use pallet_transaction_payment_rpc::{TransactionPayment, TransactionPaymentApiServer};
use pallet_domains_rpc::{Domains, DomainsApiServer};
use substrate_frame_rpc_system::{System, SystemApiServer};

let mut module = RpcExtension::new(());
let FullDeps { client, pool, deny_unsafe } = deps;

module.merge(System::new(client.clone(), pool, deny_unsafe).into_rpc())?;
module.merge(TransactionPayment::new(client).into_rpc())?;
module.merge(TransactionPayment::new(client.clone()).into_rpc())?;
module.merge(Domains::new(client).into_rpc())?;
Ok(module)
}
2 changes: 1 addition & 1 deletion pallets/account-follows/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'pallet-account-follows'
version = '0.1.8'
version = '0.1.9'
authors = ['DappForce <[email protected]>']
edition = '2021'
license = 'GPL-3.0-only'
Expand Down
2 changes: 1 addition & 1 deletion pallets/account-follows/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'profile-follows-rpc'
version = '0.7.3'
version = '0.1.9'
authors = ['DappForce <[email protected]>']
edition = '2018'
license = 'GPL-3.0-only'
Expand Down
2 changes: 1 addition & 1 deletion pallets/account-follows/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = 'profile-follows-runtime-api'
version = '0.7.3'
version = '0.1.9'
authors = ['DappForce <[email protected]>']
edition = '2018'
license = 'GPL-3.0-only'
Expand Down
4 changes: 2 additions & 2 deletions pallets/domains/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "pallet-domains"
version = "0.1.8"
version = "0.1.9"
authors = ["DappForce <[email protected]>"]
edition = "2018"
edition = "2021"
license = "GPL-3.0-only"
homepage = "https://subsocial.network"
repository = "https://github.com/dappforce/subsocial-parachain"
Expand Down
24 changes: 24 additions & 0 deletions pallets/domains/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
[package]
name = "pallet-domains-rpc"
version = "0.1.9"
authors = ["DappForce <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
homepage = "https://subsocial.network"
repository = "https://github.com/dappforce/subsocial-parachain"
description = "RPC interface for the domains pallet."
keywords = ["blockchain", "cryptocurrency", "social-network", "news-feed", "marketplace"]
categories = ["cryptography::cryptocurrencies"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0" }
jsonrpsee = { version = "0.16.2", features = ["client-core", "server", "macros"] }
pallet-domains-rpc-runtime-api = { path = "./runtime-api" }
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-rpc = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.37" }
29 changes: 29 additions & 0 deletions pallets/domains/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "pallet-domains-rpc-runtime-api"
version = "0.1.9"
authors = ["DappForce <[email protected]>"]
edition = "2021"
license = "GPL-3.0-only"
homepage = "https://subsocial.network"
repository = "https://github.com/dappforce/subsocial-parachain"
description = "RPC runtime API for the domains pallet."
keywords = ["blockchain", "cryptocurrency", "social-network", "news-feed", "marketplace"]
categories = ["cryptography::cryptocurrencies"]

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0", default-features = false, features = ["derive"] }
sp-api = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.37', default-features = false }
sp-runtime = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.37', default-features = false }
sp-std = { git = 'https://github.com/paritytech/substrate', branch = 'polkadot-v0.9.37', default-features = false }

[features]
default = ["std"]
std = [
"codec/std",
"sp-api/std",
"sp-runtime/std",
"sp-std/std",
]
15 changes: 15 additions & 0 deletions pallets/domains/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//! Runtime API definition for domains pallet.

#![cfg_attr(not(feature = "std"), no_std)]

use codec::Codec;
use sp_runtime::traits::MaybeDisplay;
use sp_std::vec::Vec;

sp_api::decl_runtime_apis! {
pub trait DomainsApi<Balance> where
Balance: Codec + MaybeDisplay,
{
fn calculate_price(subdomain: Vec<u8>) -> Option<Balance>;
}
}
Loading

0 comments on commit e2201df

Please sign in to comment.