Skip to content

Commit

Permalink
Merge branch 'master' into democracy-2nd-iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
pifragile authored Feb 26, 2024
2 parents 099b12a + ad8cc43 commit 7e28164
Show file tree
Hide file tree
Showing 87 changed files with 2,222 additions and 2,543 deletions.
2,560 changes: 987 additions & 1,573 deletions Cargo.lock

Large diffs are not rendered by default.

71 changes: 71 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[workspace]
resolver = "2"
members = [
'balances',
'balances-tx-payment',
Expand All @@ -25,6 +26,76 @@ members = [
'vouches',
]

[workspace.dependencies]
# local pin
encointer-ceremonies-assignment = { path = "ceremonies/assignment", default-features = false, version = "5.0.0" }
encointer-meetup-validation = { path = "ceremonies/meetup-validation", default-features = false, version = "5.0.0" }
encointer-primitives = { path = "primitives", default-features = false, features = ["serde_derive"], version = "5.0.0" }
encointer-rpc = { path = "rpc", version = "5.0.0" }
ep-core = { path = "primitives/core", default-features = false, version = "5.0.0" }
pallet-encointer-balances = { path = "balances", default-features = false, version = "5.0.0" }
pallet-encointer-ceremonies = { path = "ceremonies", default-features = false, version = "5.0.0" }
pallet-encointer-communities = { path = "communities", default-features = false, version = "5.0.0" }
pallet-encointer-reputation-commitments = { path = "reputation-commitments", default-features = false, version = "5.0.0" }
pallet-encointer-scheduler = { path = "scheduler", default-features = false, version = "5.0.0" }
test-utils = { path = "test-utils" }
# rpc apis
encointer-balances-tx-payment-rpc-runtime-api = { path = "balances-tx-payment/rpc/runtime-api", version = "5.0.0" }
pallet-encointer-bazaar-rpc-runtime-api = { path = "bazaar/rpc/runtime-api", version = "5.0.0" }
pallet-encointer-ceremonies-rpc-runtime-api = { path = "ceremonies/rpc/runtime-api", version = "5.0.0" }
pallet-encointer-communities-rpc-runtime-api = { path = "communities/rpc/runtime-api", version = "5.0.0" }

# various
array-bytes = "6.1.0"
bs58 = { version = "0.4.0", default-features = false, features = ["alloc"] }
crc = "2.1.0"
fixed = { package = "substrate-fixed", default-features = false, version = "0.5.9" }
geohash = { package = "substrate-geohash", version = "0.13.0" }
impl-serde = { version = "0.4.0", default-features = false }
impl-trait-for-tuples = { version = "0.2.2", default-features = false }
log = { version = "0.4.20", default-features = false }
parity-scale-codec = { version = "3.6.5", default-features = false, features = ["derive", "max-encoded-len"] }
parking_lot = "0.12.1"
scale-info = { version = "2.10.0", default-features = false, features = ["derive"] }
serde = { version = "1.0.195", default-features = false, features = ["derive", "alloc"] }
thiserror = "1.0.50"

# polkadot-sdk [no_std]
frame-benchmarking = { default-features = false, version = "28.0.0" }
frame-support = { default-features = false, version = "28.0.0" }
frame-system = { default-features = false, version = "28.0.0" }
pallet-asset-tx-payment = { default-features = false, version = "28.0.0" }
pallet-balances = { default-features = false, version = "28.0.0" }
pallet-timestamp = { default-features = false, version = "27.0.0" }
pallet-transaction-payment = { default-features = false, version = "28.0.0" }
pallet-treasury = { default-features = false, version = "27.0.0" }
sp-api = { default-features = false, version = "26.0.0" }
sp-application-crypto = { default-features = false, version = "30.0.0" }
sp-arithmetic = { default-features = false, version = "23.0.0" }
sp-core = { default-features = false, version = "28.0.0" }
sp-io = { default-features = false, version = "30.0.0" }
sp-runtime = { default-features = false, version = "31.0.0" }
sp-std = { default-features = false, version = "14.0.0" }

# rpc stuff [std]
jsonrpsee = { version = "0.16.3", features = ["client-core", "server", "macros"] }
jsonrpsee-core = { version = "0.16.3" }
jsonrpsee-types = { version = "0.16.3" }
pallet-transaction-payment-rpc = { version = "30.0.0" }
sc-rpc = "29.0.0"
sc-rpc-api = "0.33.0"
sp-blockchain = "28.0.0"
sp-rpc = "26.0.0"

# dev deps
approx = "0.5.1"
itertools = "0.10.5"
rstest = "0.12.0"
serde_json = "1.0.111"
sp-inherents = "26.0.0"
sp-keyring = "31.0.0"
sp-keystore = "0.34.0"

#[patch."https://github.com/encointer/substrate-fixed"]
#substrate-fixed = { path = "../substrate-fixed"}
#
Expand Down
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ We also apply substrate's standard of serializing with `camelCase`.

### Versioning

We bump crate versions separately and tag the repository with the highest crate version
Major version must increase for polkadot-sdk release upgrades as these are always breaking changes. For convenience, all crates in this repos shall have the same major version.

We bump minor crate versions separately and tag the repository with the highest crate version

motivation: git blame should show on crate directory level if there was a change. This way, browsing the repo on github really shows when a certain pallet or crate has been touched. Even if it's only adjustments for upstream upgrades, just bump crate versions to the newest, which will be tagged globally

Expand All @@ -67,7 +69,7 @@ cargo install cargo-release
cargo tree --workspace -i ep-core
# add --execute if you're sure
cargo release publish -p ep-core -p encointer-primitives -p test-utils -p pallet-encointer-scheduler -p pallet-encointer-balances -p pallet-encointer-communities
cargo release publish -p ep-core -p encointer-primitives -p pallet-encointer-scheduler -p pallet-encointer-balances -p pallet-encointer-communities
cargo release publish -p encointer-ceremonies-assignment -p encointer-meetup-validation -p pallet-encointer-ceremonies -p pallet-encointer-bazaar -p pallet-encointer-reputation-commitments -p pallet-encointer-faucet
cargo release publish -p encointer-rpc -p encointer-balances-tx-payment -p encointer-balances-tx-payment-rpc-runtime-api -p encointer-balances-tx-payment-rpc -p pallet-encointer-bazaar-rpc-runtime-api -p pallet-encointer-bazaar-rpc -p pallet-encointer-ceremonies-rpc-runtime-api -p pallet-encointer-ceremonies-rpc -p pallet-encointer-communities-rpc-runtime-api -p pallet-encointer-communities-rpc
```
Expand Down
54 changes: 29 additions & 25 deletions balances-tx-payment/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "encointer-balances-tx-payment"
version = "2.0.0"
version = "5.0.0"
authors = ["Encointer Association <info@encointer.org>"]
edition = "2021"
description = "Balances tx payment for the Encointer blockchain runtime"
Expand All @@ -9,44 +9,48 @@ repository = "https://github.com/encointer/pallets"
license = "GPL-3.0-or-later"

[dependencies]
log = { version = "0.4.20", default-features = false }
log = { workspace = true }

encointer-primitives = { path = "../primitives", default-features = false, version = "2.0.0" }
pallet-encointer-balances = { path = "../balances", default-features = false, version = "2.0.0" }
pallet-encointer-ceremonies = { path = "../ceremonies", default-features = false, version = "2.0.0" }
encointer-primitives = { workspace = true }
pallet-encointer-balances = { workspace = true }
pallet-encointer-ceremonies = { workspace = true }

# substrate dependencies
frame-support = { default-features = false, version = "24.0.0" }
frame-system = { default-features = false, version = "24.0.0" }
pallet-asset-tx-payment = { default-features = false, version = "24.0.0" }
pallet-transaction-payment = { default-features = false, version = "24.0.0" }
sp-runtime = { default-features = false, version = "27.0.0" }
frame-support = { workspace = true }
frame-system = { workspace = true }
pallet-asset-tx-payment = { workspace = true }
pallet-transaction-payment = { workspace = true }
sp-runtime = { workspace = true }

[dev-dependencies]
codec = { package = "parity-scale-codec", version = "3.6.4", default-features = false, features = [
"derive",
] }
rstest = "0.12.0"
scale-info = { version = "2.9.0", default-features = false }
sp-io = "26.0.0"
test-utils = { path = "../test-utils" }
parity-scale-codec = { workspace = true }
rstest = { workspace = true }
scale-info = { workspace = true }
sp-io = { workspace = true, features = ["std"] }
test-utils = { workspace = true }

[features]
default = ["std"]
std = [
"log/std",

# encointer deps
"pallet-encointer-balances/std",
"pallet-encointer-ceremonies/std",
"encointer-primitives/std",

# substrate deps
"frame-support/std",
"frame-system/std",
"log/std",
"pallet-asset-tx-payment/std",
"pallet-encointer-balances/std",
"pallet-encointer-ceremonies/std",
"pallet-transaction-payment/std",
"sp-runtime/std",
]

try-runtime = ["frame-system/try-runtime"]
try-runtime = [
"frame-system/try-runtime",
"pallet-encointer-balances/try-runtime",
"pallet-encointer-ceremonies/try-runtime",
]
runtime-benchmarks = [
"frame-support/runtime-benchmarks",
"frame-system/runtime-benchmarks",
"pallet-encointer-balances/runtime-benchmarks",
"pallet-encointer-ceremonies/runtime-benchmarks",
]
40 changes: 18 additions & 22 deletions balances-tx-payment/rpc/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "encointer-balances-tx-payment-rpc"
version = "2.0.0"
version = "5.0.0"
authors = ["Encointer Association <info@encointer.org>"]
edition = "2021"
description = "Balances tx payment rpc for the Encointer blockchain runtime"
Expand All @@ -9,28 +9,24 @@ repository = "https://github.com/encointer/pallets"
license = "GPL-3.0-or-later"

[dependencies]
codec = { package = "parity-scale-codec", version = "3.6.4", default-features = false }
jsonrpsee = { version = "0.16.3", features = [
"client-core",
"server",
"macros",
] }
log = "0.4.20"
parking_lot = "0.12.0"
thiserror = "1.0.31"
jsonrpsee = { workspace = true }
log = { workspace = true, features = ["std"] }
parity-scale-codec = { workspace = true }
parking_lot = { workspace = true }
thiserror = { workspace = true }

# local deps
encointer-balances-tx-payment-rpc-runtime-api = { package = "encointer-balances-tx-payment-rpc-runtime-api", path = "runtime-api", version = "2.0.0" }
encointer-primitives = { path = "../../primitives", version = "2.0.0" }
encointer-rpc = { path = "../../rpc", version = "2.0.0" }
encointer-balances-tx-payment-rpc-runtime-api = { workspace = true }
encointer-primitives = { workspace = true }
encointer-rpc = { workspace = true }

# substrate deps
pallet-transaction-payment = { default-features = false, version = "24.0.0" }
pallet-transaction-payment-rpc = { default-features = false, version = "26.0.0" }
sc-rpc = "25.0.0"
sc-rpc-api = "0.29.0"
sp-api = "22.0.0"
sp-blockchain = "24.0.0"
sp-core = "24.0.0"
sp-rpc = "22.0.0"
sp-runtime = "27.0.0"
pallet-transaction-payment = { workspace = true, features = ["std"] }
pallet-transaction-payment-rpc = { workspace = true }
sc-rpc = { workspace = true }
sc-rpc-api = { workspace = true }
sp-api = { workspace = true, features = ["std"] }
sp-blockchain = { workspace = true }
sp-core = { workspace = true, features = ["std"] }
sp-rpc = { workspace = true }
sp-runtime = { workspace = true, features = ["std"] }
24 changes: 11 additions & 13 deletions balances-tx-payment/rpc/runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "encointer-balances-tx-payment-rpc-runtime-api"
version = "2.0.0"
version = "5.0.0"
authors = ["Encointer Association <info@encointer.org>"]
edition = "2021"
description = "Balances tx payment rpc runtime api for the Encointer blockchain runtime"
Expand All @@ -10,24 +10,22 @@ license = "GPL-3.0-or-later"

[dependencies]
# local deps
encointer-primitives = { path = "../../../primitives", default-features = false, version = "2.0.0" }
encointer-primitives = { workspace = true }

# substrate deps
codec = { package = "parity-scale-codec", version = "3.6.4", default-features = false, features = [
"derive",
] }
frame-support = { default-features = false, version = "24.0.0" }
scale-info = { version = "2.9.0", default-features = false }
sp-api = { default-features = false, version = "22.0.0" }
sp-std = { default-features = false, version = "11.0.0" }
frame-support = { workspace = true }
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
sp-api = { workspace = true }
sp-std = { workspace = true }

[features]
default = ["std"]
std = [
"codec/std",
"scale-info/std",
"encointer-primitives/std",
"frame-support/std",
"sp-std/std",
"parity-scale-codec/std",
"scale-info/std",
"sp-api/std",
"encointer-primitives/std",
"sp-std/std",
]
2 changes: 1 addition & 1 deletion balances-tx-payment/rpc/runtime-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

use core::fmt;
use frame_support::pallet_prelude::TypeInfo;
use sp_api::{Decode, Encode};
use parity_scale_codec::{Decode, Encode};
#[cfg(not(feature = "std"))]
use sp_std::vec::Vec;

Expand Down
25 changes: 8 additions & 17 deletions balances-tx-payment/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@
// You should have received a copy of the GNU General Public License
// along with Encointer. If not, see <http://www.gnu.org/licenses/>.

use codec::Codec;
use core::fmt::Display;
use encointer_balances_tx_payment_rpc_runtime_api::{
BalancesTxPaymentApi as BalancesTxPaymentApiRuntimeApi, Error,
};
use jsonrpsee::{
core::{Error as JsonRpseeError, RpcResult},
core::RpcResult,
proc_macros::rpc,
types::error::{CallError, ErrorCode, ErrorObject},
types::error::{CallError, ErrorObject},
};
pub use pallet_transaction_payment::RuntimeDispatchInfo;
use pallet_transaction_payment::{FeeDetails, InclusionFee};
use pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi;
use sp_api::{Decode, Encode, ProvideRuntimeApi};
use parity_scale_codec::Codec;
use parity_scale_codec::{Decode, Encode};
use sp_api::ProvideRuntimeApi;
use sp_blockchain::HeaderBackend;
use sp_core::Bytes;
use sp_rpc::number::NumberOrHex;
Expand Down Expand Up @@ -107,16 +108,6 @@ where
))
})?;

let try_into_rpc_balance = |value: AssetBalance| {
value.try_into().map_err(|_| {
JsonRpseeError::Call(CallError::Custom(ErrorObject::owned(
ErrorCode::InvalidParams.code(),
format!("{value} doesn't fit in NumberOrHex representation"),
None::<()>,
)))
})
};

Ok(FeeDetails {
inclusion_fee: if let Some(inclusion_fee) = fee_details.inclusion_fee {
let base_fee = api
Expand Down Expand Up @@ -147,9 +138,9 @@ where
})?;

Some(InclusionFee {
base_fee: try_into_rpc_balance(base_fee)?,
len_fee: try_into_rpc_balance(len_fee)?,
adjusted_weight_fee: try_into_rpc_balance(adjusted_weight_fee)?,
base_fee: base_fee.into(),
len_fee: len_fee.into(),
adjusted_weight_fee: adjusted_weight_fee.into(),
})
} else {
None
Expand Down
Loading

0 comments on commit 7e28164

Please sign in to comment.