Skip to content

Commit 58404e0

Browse files
authored
Merge pull request #128 from automata-network/cf/anydao
Add daoportal to ContextFree
2 parents d67eaea + 93b4033 commit 58404e0

File tree

5 files changed

+54
-5
lines changed

5 files changed

+54
-5
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rpc/src/daoportal.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ compile_error!("Feature 1 and 2 are mutually exclusive and cannot be enabled tog
88
use automata_primitives::{AccountId, Block, BlockId, Index};
99
// #[cfg(feature = "automata")]
1010
// use automata_runtime::apis::DAOPortalApi as DAOPortalRuntimeApi;
11-
// #[cfg(feature = "contextfree")]
12-
// use contextfree_runtime::apis::DAOPortalApi as DAOPortalRuntimeApi;
11+
#[cfg(feature = "contextfree")]
12+
use contextfree_runtime::apis::DAOPortalApi as DAOPortalRuntimeApi;
1313
#[cfg(feature = "finitestate")]
1414
use finitestate_runtime::apis::DAOPortalApi as DAOPortalRuntimeApi;
1515

runtime/contextfree/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ pallet-liveness = { default-features = false, git = 'https://github.com/automata
8181
pallet-bridge = { default-features = false, git = 'https://github.com/automata-network/automata-common', version = '0.1.0'}
8282
pallet-bridgetransfer = { default-features = false, git = 'https://github.com/automata-network/automata-common', version = '0.1.0'}
8383
pallet-game = { default-features = false, git = 'https://github.com/automata-network/automata-common', branch = 'main' }
84+
pallet-daoportal = { default-features = false, git = 'https://github.com/automata-network/automata-common', branch = 'main' }
8485
automata-primitives = { default-features = false, path = "../../primitives" }
8586
automata-runtime-common = { path = "../common", default-features = false }
8687

@@ -130,6 +131,7 @@ std = [
130131
'pallet-utility/std',
131132
'pallet-vesting/std',
132133
'pallet-game/std',
134+
'pallet-daoportal/std',
133135
'serde',
134136
'sp-api/std',
135137
'sp-block-builder/std',

runtime/contextfree/src/apis.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
// use automata_primitives::{AccountId, Hash};
2-
// use sp_std::vec::Vec;
1+
use automata_primitives::{AccountId, Hash};
2+
use pallet_daoportal::datastructures::{DAOProposal, Project, ProjectId, ProposalId};
3+
use sp_std::vec::Vec;
34

45
sp_api::decl_runtime_apis! {
56
pub trait TransferApi {
@@ -8,4 +9,12 @@ sp_api::decl_runtime_apis! {
89
signature_raw_bytes: [u8; 65]
910
) -> Result<(), ()>;
1011
}
12+
13+
pub trait DAOPortalApi {
14+
fn get_projects() -> Vec<(ProjectId, Project<AccountId>)>;
15+
16+
fn get_proposals(project_id: ProjectId) -> Vec<(ProposalId, DAOProposal<AccountId>)>;
17+
18+
fn get_all_proposals() -> Vec<(ProjectId, ProposalId, DAOProposal<AccountId>)>;
19+
}
1120
}

runtime/contextfree/src/lib.rs

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ pub fn wasm_binary_unwrap() -> &'static [u8] {
1919
use codec::{Decode, Encode};
2020
use fp_rpc::TransactionStatus;
2121
use frame_system::{EnsureOneOf, EnsureRoot};
22+
use pallet_daoportal::datastructures::{DAOProposal, Project, ProjectId, ProposalId};
2223
use pallet_grandpa::fg_primitives;
2324
use pallet_grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};
2425
use pallet_im_online::sr25519::AuthorityId as ImOnlinedId;
@@ -125,7 +126,7 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
125126
// `spec_version`, and `authoring_version` are the same between Wasm and native.
126127
// This value is set to 100 to notify Polkadot-JS App (https://polkadot.js.org/apps) to use
127128
// the compatible custom types.
128-
spec_version: 1004,
129+
spec_version: 1005,
129130
impl_version: 1,
130131
apis: RUNTIME_API_VERSIONS,
131132
transaction_version: 1,
@@ -180,6 +181,7 @@ impl Contains<Call> for CallFilter {
180181
| Call::BridgeTransfer(_)
181182
| Call::ChainBridge(_)
182183
| Call::ElectionProviderMultiPhase(_)
184+
| Call::DAOPortal(_)
183185
| Call::Democracy(_)
184186
| Call::Council(_)
185187
| Call::TechnicalCommittee(_)
@@ -555,6 +557,26 @@ impl pallet_game::Config for Runtime {
555557
type WeightInfo = pallet_game::weights::SubstrateWeight<Runtime>;
556558
}
557559

560+
parameter_types! {
561+
pub const MinDuration: u64 = 3600000;
562+
pub const MaxDuration: u64 = 2592000000;
563+
pub const MaxOptionCount: u8 = 10;
564+
pub const MaxWorkspace: u32 = 10;
565+
pub const MaxStrategy: u32 = 10;
566+
}
567+
568+
impl pallet_daoportal::Config for Runtime {
569+
type Event = Event;
570+
type Currency = Balances;
571+
type MinDuration = MinDuration;
572+
type MaxDuration = MaxDuration;
573+
type MaxOptionCount = MaxOptionCount;
574+
type MaxWorkspace = MaxWorkspace;
575+
type MaxStrategy = MaxStrategy;
576+
type UnixTime = Timestamp;
577+
type DAOPortalWeightInfo = pallet_daoportal::weights::SubstrateWeight<Runtime>;
578+
}
579+
558580
impl pallet_sudo::Config for Runtime {
559581
type Event = Event;
560582
type Call = Call;
@@ -1053,6 +1075,7 @@ construct_runtime!(
10531075
ChainBridge: pallet_bridge::{Pallet, Call, Storage, Event<T>},
10541076
BridgeTransfer: pallet_bridgetransfer::{Pallet, Call, Event<T>},
10551077
Game: pallet_game::{Pallet, Call, Storage, Event<T>},
1078+
DAOPortal: pallet_daoportal::{Pallet, Call, Storage, Event<T>},
10561079
}
10571080
);
10581081

@@ -1275,6 +1298,20 @@ impl_runtime_apis! {
12751298
// }
12761299
// }
12771300

1301+
impl apis::DAOPortalApi<Block> for Runtime {
1302+
fn get_projects() -> Vec<(ProjectId, Project<AccountId>)> {
1303+
DAOPortal::get_projects()
1304+
}
1305+
1306+
fn get_proposals(project_id: ProjectId) -> Vec<(ProjectId, DAOProposal<AccountId>)> {
1307+
DAOPortal::get_proposals(project_id)
1308+
}
1309+
1310+
fn get_all_proposals() -> Vec<(ProjectId, ProposalId, DAOProposal<AccountId>)> {
1311+
DAOPortal::get_all_proposals()
1312+
}
1313+
}
1314+
12781315
impl fp_rpc::EthereumRuntimeRPCApi<Block> for Runtime {
12791316
fn chain_id() -> u64 {
12801317
<Runtime as pallet_evm::Config>::ChainId::get()

0 commit comments

Comments
 (0)