Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: expose proposal api to calimero sdk #911

Merged
merged 39 commits into from
Nov 8, 2024

Conversation

MatejVukosav
Copy link
Member

@MatejVukosav MatejVukosav commented Oct 31, 2024

Exposed wasm create_proposal function which creates proposal in proxy contract

Copy link
Member

@xilosada xilosada left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@MatejVukosav MatejVukosav force-pushed the feat--expose-proposal-api-to-calimero-sdk branch from 7c056e9 to 2c03d07 Compare November 4, 2024 09:38
@MatejVukosav MatejVukosav self-assigned this Nov 4, 2024
@petarjuki7
Copy link
Member

petarjuki7 commented Nov 4, 2024

I added CLI capability, you can test it with:
cargo run -p meroctl -- --node-name <node_name> --home data --output-format json proxy get num-proposal-approvals <context_id> <proposal_id>

Other options are:
proposal
proposals
num-active-proposals
proposal-approvers

Also, had to make some changes in the handlers for the get APIs.

todo: better implementation of the Report trait for the structs used for proposals

@MatejVukosav MatejVukosav force-pushed the feat--expose-proposal-api-to-calimero-sdk branch from b1952c2 to 7f0ebd6 Compare November 5, 2024 02:43
@MatejVukosav MatejVukosav force-pushed the feat--expose-proposal-api-to-calimero-sdk branch from c03b79b to a91e016 Compare November 6, 2024 07:55
@MatejVukosav MatejVukosav force-pushed the feat--expose-proposal-api-to-calimero-sdk branch from 263b2fe to 683bde5 Compare November 6, 2024 09:52
crates/node/src/lib.rs Outdated Show resolved Hide resolved
…m:calimero-network/core into feat--expose-proposal-api-to-calimero-sdk
@@ -74,6 +75,7 @@ pub struct DraftProposal {
/// The actions to be executed by the proposal. One proposal can contain
/// multiple actions to execute.
actions: Vec<ProposalAction>,
approval: Option<ProposalId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is needed here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦🏽 not needed

@MatejVukosav MatejVukosav marked this pull request as ready for review November 8, 2024 05:47
…r' of github.com:calimero-network/core into feat--expose-proposal-api-to-calimero-sdk
@MatejVukosav MatejVukosav force-pushed the feat--expose-proposal-api-to-calimero-sdk branch from aadce16 to c63dcfc Compare November 8, 2024 06:19
@MatejVukosav MatejVukosav removed the request for review from danwilliams November 8, 2024 06:24
@MatejVukosav MatejVukosav merged commit fc62560 into master Nov 8, 2024
3 checks passed
@MatejVukosav MatejVukosav deleted the feat--expose-proposal-api-to-calimero-sdk branch November 8, 2024 07:17
@@ -1,6 +1,6 @@
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::time;
use std::{time, vec};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Comment on lines +275 to +276
gas: 300_000_000_000_000,
deposit: 5_000_000_000_000_000_000_000_000,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

highlighting this to come back to it

context_config.network.as_ref().into(),
context_config.contract.as_ref().into(),
)
.propose(proposal_id, signer_id.rt().unwrap(), actions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.propose(proposal_id, signer_id.rt().unwrap(), actions)
.propose(proposal_id, signer_id.rt().expect("infallible conversion"), actions)

while we want to avoid panic points, any thing that is "safe" to use unwrap, must define why that's the case

context_config.network.as_ref().into(),
context_config.contract.as_ref().into(),
)
.approve(signer_id.rt().unwrap(), proposal_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

@@ -49,6 +51,8 @@ pub enum SubCommands {
App(AppCommand),
Context(ContextCommand),
Identity(IdentityCommand),
JsonRpc(CallCommand),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad merge? this reintroduces JsonRpc

Comment on lines +449 to +458
drop(
self.ctx_manager
.propose(
context_id,
executor_public_key,
proposal_id.clone(),
actions,
)
.await,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

handle the result instead of dropping.

Comment on lines +462 to +466
drop(
self.ctx_manager
.approve(context_id, executor_public_key, approval.clone())
.await,
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Comment on lines +58 to +62
#[derive(Deserialize)]
pub struct ProposalRequest {
pub sender: String,
pub receiver: String,
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now unused?

@@ -35,7 +36,7 @@ pub enum ProposalAction {
receiver_id: AccountId,

/// The amount of tokens to transfer.
amount: u64,
amount: u128,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deposit in function call should be u128 too

@@ -74,6 +75,7 @@ pub struct DraftProposal {
/// The actions to be executed by the proposal. One proposal can contain
/// multiple actions to execute.
actions: Vec<ProposalAction>,
approval: Option<ProposalId>,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤦🏽 not needed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

6 participants