Skip to content

Commit cf3d471

Browse files
authored
Enable view functions on System Chains (#981)
FRAME "View Functions" (paritytech/polkadot-sdk#216) support was implemented and released in Polkadot SDK with paritytech/polkadot-sdk#4722, but it was never exposed on the System Chains' runtimes. This PR adds the missing `execute_view_function()` to all System Chains' Runtime APIs.
1 parent 2bef006 commit cf3d471

14 files changed

Lines changed: 122 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66

77
## [1.9.3] 21.10.2025
88

9+
### Added
10+
- Enable view functions on System Chains([polkadot-fellows/runtimes/pull/981](https://github.com/polkadot-fellows/runtimes/pull/981))
11+
12+
## [1.9.3] 21.10.2025
13+
914
### Fixed
1015

1116
- [BHP](https://github.com/polkadot-fellows/runtimes/pull/978) Add missing snowbridge runtime API to the BridgeHub

relay/kusama/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3032,6 +3032,15 @@ sp_api::impl_runtime_apis! {
30323032
}
30333033
}
30343034

3035+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
3036+
fn execute_view_function(
3037+
id: frame_support::view_functions::ViewFunctionId,
3038+
input: Vec<u8>
3039+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
3040+
Runtime::execute_view_function(id, input)
3041+
}
3042+
}
3043+
30353044
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
30363045
fn account_nonce(account: AccountId) -> Nonce {
30373046
System::account_nonce(account)

relay/polkadot/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2780,6 +2780,15 @@ sp_api::impl_runtime_apis! {
27802780
}
27812781
}
27822782

2783+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
2784+
fn execute_view_function(
2785+
id: frame_support::view_functions::ViewFunctionId,
2786+
input: Vec<u8>
2787+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
2788+
Runtime::execute_view_function(id, input)
2789+
}
2790+
}
2791+
27832792
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
27842793
fn account_nonce(account: AccountId) -> Nonce {
27852794
System::account_nonce(account)

system-parachains/asset-hubs/asset-hub-kusama/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2372,6 +2372,15 @@ pallet_revive::impl_runtime_apis_plus_revive!(
23722372
}
23732373
}
23742374

2375+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
2376+
fn execute_view_function(
2377+
id: frame_support::view_functions::ViewFunctionId,
2378+
input: Vec<u8>
2379+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
2380+
Runtime::execute_view_function(id, input)
2381+
}
2382+
}
2383+
23752384
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
23762385
fn account_nonce(account: AccountId) -> Nonce {
23772386
System::account_nonce(account)

system-parachains/asset-hubs/asset-hub-polkadot/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,6 +2140,15 @@ impl_runtime_apis! {
21402140
}
21412141
}
21422142

2143+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
2144+
fn execute_view_function(
2145+
id: frame_support::view_functions::ViewFunctionId,
2146+
input: Vec<u8>
2147+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
2148+
Runtime::execute_view_function(id, input)
2149+
}
2150+
}
2151+
21432152
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
21442153
fn account_nonce(account: AccountId) -> Nonce {
21452154
System::account_nonce(account)

system-parachains/bridge-hubs/bridge-hub-kusama/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,6 +1102,15 @@ impl_runtime_apis! {
11021102
}
11031103
}
11041104

1105+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
1106+
fn execute_view_function(
1107+
id: frame_support::view_functions::ViewFunctionId,
1108+
input: Vec<u8>
1109+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
1110+
Runtime::execute_view_function(id, input)
1111+
}
1112+
}
1113+
11051114
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
11061115
fn account_nonce(account: AccountId) -> Nonce {
11071116
System::account_nonce(account)

system-parachains/bridge-hubs/bridge-hub-polkadot/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,6 +1175,15 @@ impl_runtime_apis! {
11751175
}
11761176
}
11771177

1178+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
1179+
fn execute_view_function(
1180+
id: frame_support::view_functions::ViewFunctionId,
1181+
input: Vec<u8>
1182+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
1183+
Runtime::execute_view_function(id, input)
1184+
}
1185+
}
1186+
11781187
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
11791188
fn account_nonce(account: AccountId) -> Nonce {
11801189
System::account_nonce(account)

system-parachains/collectives/collectives-polkadot/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1205,6 +1205,15 @@ impl_runtime_apis! {
12051205
}
12061206
}
12071207

1208+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
1209+
fn execute_view_function(
1210+
id: frame_support::view_functions::ViewFunctionId,
1211+
input: Vec<u8>
1212+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
1213+
Runtime::execute_view_function(id, input)
1214+
}
1215+
}
1216+
12081217
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
12091218
fn account_nonce(account: AccountId) -> Nonce {
12101219
System::account_nonce(account)

system-parachains/coretime/coretime-kusama/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,6 +1025,15 @@ impl_runtime_apis! {
10251025
}
10261026
}
10271027

1028+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
1029+
fn execute_view_function(
1030+
id: frame_support::view_functions::ViewFunctionId,
1031+
input: Vec<u8>
1032+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
1033+
Runtime::execute_view_function(id, input)
1034+
}
1035+
}
1036+
10281037
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
10291038
fn account_nonce(account: AccountId) -> Nonce {
10301039
System::account_nonce(account)

system-parachains/coretime/coretime-polkadot/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,6 +1037,15 @@ impl_runtime_apis! {
10371037
}
10381038
}
10391039

1040+
impl frame_support::view_functions::runtime_api::RuntimeViewFunction<Block> for Runtime {
1041+
fn execute_view_function(
1042+
id: frame_support::view_functions::ViewFunctionId,
1043+
input: Vec<u8>
1044+
) -> Result<Vec<u8>, frame_support::view_functions::ViewFunctionDispatchError> {
1045+
Runtime::execute_view_function(id, input)
1046+
}
1047+
}
1048+
10401049
impl frame_system_rpc_runtime_api::AccountNonceApi<Block, AccountId, Nonce> for Runtime {
10411050
fn account_nonce(account: AccountId) -> Nonce {
10421051
System::account_nonce(account)

0 commit comments

Comments
 (0)