Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 115 additions & 19 deletions packages/dapi-grpc/protos/platform/v0/platform.proto
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ service Platform {
rpc getTokenTotalSupply(GetTokenTotalSupplyRequest) returns (GetTokenTotalSupplyResponse);
rpc getGroupInfo(GetGroupInfoRequest) returns (GetGroupInfoResponse);
rpc getGroupInfos(GetGroupInfosRequest) returns (GetGroupInfosResponse);
// rpc getActiveGroupActions(GetActiveGroupActionsRequest) returns (GetActiveGroupActionsResponse);
// rpc getClosedGroupActions(GetClosedGroupActionsRequest) returns (GetClosedGroupActionsResponse);
rpc getGroupActions(GetGroupActionsRequest) returns (GetGroupActionsResponse);
rpc getGroupActionSigners(GetGroupActionSignersRequest) returns (GetGroupActionSignersResponse);
}

// Proof message includes cryptographic proofs for validating responses
Expand Down Expand Up @@ -1512,70 +1512,125 @@ message GetGroupInfosResponse {
}
}

message GetActiveGroupActionsRequest {
message GetActiveGroupActionsRequestV0 {
message GetGroupActionsRequest {
enum ActionStatus {
ACTIVE = 0; // Request the active actions
CLOSED = 1; // Request the closed actions
}

message StartAtActionId {
bytes start_action_id = 1;
bool start_action_id_included = 2;
}

message GetGroupActionsRequestV0 {
bytes contract_id = 1;
uint32 group_contract_position = 2;
bool prove = 3;
ActionStatus status = 3;
optional StartAtActionId start_at_action_id = 4;
optional uint32 count = 5;
bool prove = 6;
}
oneof version {
GetActiveGroupActionsRequestV0 v0 = 1;
GetGroupActionsRequestV0 v0 = 1;
}
}

message GetActiveGroupActionsResponse {
message GetActiveGroupActionsResponseV0 {
message GetGroupActionsResponse {
message GetGroupActionsResponseV0 {
// Mint event
message MintEvent {
uint64 amount = 1; // Amount to mint
bytes recipient_id = 2; // Recipient identifier
string public_note = 3; // Public note
optional string public_note = 3; // Public note
}

// Burn event
message BurnEvent {
uint64 amount = 1; // Amount to burn
string public_note = 2; // Public note
optional string public_note = 2; // Public note
}

// Freeze event
message FreezeEvent {
bytes frozen_id = 1; // Identifier of the frozen entity
string public_note = 2; // Public note
optional string public_note = 2; // Public note
}

// Unfreeze event
message UnfreezeEvent {
bytes frozen_id = 1; // Identifier of the unfrozen entity
string public_note = 2; // Public note
optional string public_note = 2; // Public note
}

// Destroy frozen funds event
message DestroyFrozenFundsEvent {
bytes frozen_id = 1; // Identifier of the frozen entity
uint64 amount = 2; // Amount to destroy
string public_note = 3; // Public note
optional string public_note = 3; // Public note
}

// Shared encrypted note
message SharedEncryptedNote {
uint32 sender_key_index = 1; // Sender key index
uint32 recipient_key_index = 2; // Recipient key index
bytes encrypted_data = 3; // Encrypted data
}

// Personal encrypted note
message PersonalEncryptedNote {
uint32 root_encryption_key_index = 1; // Root encryption key index
uint32 derivation_encryption_key_index = 2; // Derivation encryption key index
bytes encrypted_data = 3; // Encrypted data
}

// Transfer event
message TransferEvent {
bytes recipient_id = 1; // Recipient identifier
string public_note = 2; // Public note
bytes shared_encrypted_note = 3; // Shared encrypted note
bytes personal_encrypted_note = 4; // Personal encrypted note
optional string public_note = 2; // Public note
optional SharedEncryptedNote shared_encrypted_note = 3; // Shared encrypted note
optional PersonalEncryptedNote personal_encrypted_note = 4; // Personal encrypted note
uint64 amount = 5; // Amount transferred
}

// Emergency action event
message EmergencyActionEvent {
string action_type = 1; // Emergency action type
string public_note = 2; // Public note
// Enum for emergency action types
enum ActionType {
PAUSE = 0; // Pause action
RESUME = 1; // Resume action
}

ActionType action_type = 1; // Emergency action type
optional string public_note = 2; // Public note
}

// Event associated with this action
message GroupActionEvent {
oneof event_type {
TokenEvent token_event = 1; // Token event details
DocumentEvent document_event = 2;
ContractEvent contract_event = 3;
}
}

message DocumentEvent {
oneof type {
DocumentCreateEvent create = 1; // Create event details
}
}

message DocumentCreateEvent {
bytes created_document = 1;
}

message ContractUpdateEvent {
bytes updated_contract = 1;
}

message ContractEvent {
oneof type {
ContractUpdateEvent update = 1; // Contract update event
}
}

Expand Down Expand Up @@ -1608,6 +1663,47 @@ message GetActiveGroupActionsResponse {
ResponseMetadata metadata = 3;
}
oneof version {
GetActiveGroupActionsResponseV0 v0 = 1;
GetGroupActionsResponseV0 v0 = 1;
}
}


message GetGroupActionSignersRequest {
enum ActionStatus {
ACTIVE = 0; // Request the active actions
CLOSED = 1; // Request the closed actions
}

message GetGroupActionSignersRequestV0 {
bytes contract_id = 1;
uint32 group_contract_position = 2;
ActionStatus status = 3;
bytes action_id = 4;
bool prove = 5;
}
oneof version {
GetGroupActionSignersRequestV0 v0 = 1;
}
}

message GetGroupActionSignersResponse {
message GetGroupActionSignersResponseV0 {
message GroupActionSigner {
bytes signer_id = 1;
uint32 power = 2;
}
message GroupActionSigners {
repeated GroupActionSigner signers = 1;
}

oneof result {
GroupActionSigners group_action_signers = 1;
Proof proof = 2;
}
ResponseMetadata metadata = 3;
}

oneof version {
GetGroupActionSignersResponseV0 v0 = 1;
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::balances::credits::TokenAmount;
use crate::data_contract::associated_token::token_configuration::v0::TokenConfigurationConventionV0;
use crate::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers;
use crate::data_contract::change_control_rules::ChangeControlRules;
Expand All @@ -13,13 +14,13 @@ pub trait TokenConfigurationV0Getters {
fn conventions_mut(&mut self) -> &mut TokenConfigurationConventionV0;

/// Returns the base supply.
fn base_supply(&self) -> u64;
fn base_supply(&self) -> TokenAmount;
/// Returns the base supply.
fn keeps_history(&self) -> bool;
fn start_as_paused(&self) -> bool;

/// Returns the maximum supply.
fn max_supply(&self) -> Option<u64>;
fn max_supply(&self) -> Option<TokenAmount>;

/// Returns the max supply change rules.
fn max_supply_change_rules(&self) -> &ChangeControlRules;
Expand Down Expand Up @@ -63,10 +64,10 @@ pub trait TokenConfigurationV0Setters {
fn set_conventions(&mut self, conventions: TokenConfigurationConventionV0);

/// Sets the base supply.
fn set_base_supply(&mut self, base_supply: u64);
fn set_base_supply(&mut self, base_supply: TokenAmount);

/// Sets the maximum supply.
fn set_max_supply(&mut self, max_supply: Option<u64>);
fn set_max_supply(&mut self, max_supply: Option<TokenAmount>);

/// Sets the max supply change rules.
fn set_max_supply_change_rules(&mut self, rules: ChangeControlRules);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use crate::balances::credits::TokenAmount;
use crate::data_contract::associated_token::token_configuration::accessors::v0::{
TokenConfigurationV0Getters, TokenConfigurationV0Setters,
};
Expand All @@ -22,7 +23,7 @@ impl TokenConfigurationV0Getters for TokenConfigurationV0 {
}

/// Returns the base supply.
fn base_supply(&self) -> u64 {
fn base_supply(&self) -> TokenAmount {
self.base_supply
}

Expand All @@ -37,7 +38,7 @@ impl TokenConfigurationV0Getters for TokenConfigurationV0 {
}

/// Returns the maximum supply.
fn max_supply(&self) -> Option<u64> {
fn max_supply(&self) -> Option<TokenAmount> {
self.max_supply
}

Expand Down Expand Up @@ -115,12 +116,12 @@ impl TokenConfigurationV0Setters for TokenConfigurationV0 {
}

/// Sets the base supply.
fn set_base_supply(&mut self, base_supply: u64) {
fn set_base_supply(&mut self, base_supply: TokenAmount) {
self.base_supply = base_supply;
}

/// Sets the maximum supply.
fn set_max_supply(&mut self, max_supply: Option<u64>) {
fn set_max_supply(&mut self, max_supply: Option<TokenAmount>) {
self.max_supply = max_supply;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
mod accessors;

use crate::balances::credits::TokenAmount;
use crate::data_contract::change_control_rules::authorized_action_takers::AuthorizedActionTakers;
use crate::data_contract::change_control_rules::v0::ChangeControlRulesV0;
use crate::data_contract::change_control_rules::ChangeControlRules;
Expand Down Expand Up @@ -37,10 +38,10 @@ fn default_decimals() -> u16 {
pub struct TokenConfigurationV0 {
pub conventions: TokenConfigurationConventionV0,
/// The supply at the creation of the token
pub base_supply: u64,
pub base_supply: TokenAmount,
/// The maximum supply the token can ever have
#[serde(default)]
pub max_supply: Option<u64>,
pub max_supply: Option<TokenAmount>,
/// Do we keep history, default is true.
#[serde(default = "default_keeps_history")]
pub keeps_history: bool,
Expand Down Expand Up @@ -217,4 +218,9 @@ impl TokenConfigurationV0 {
main_control_group_can_be_modified: AuthorizedActionTakers::NoOne,
}
}

pub fn with_base_supply(mut self, base_supply: TokenAmount) -> Self {
self.base_supply = base_supply;
self
}
}
29 changes: 29 additions & 0 deletions packages/rs-dpp/src/group/group_action_status.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
use anyhow::bail;

#[derive(Debug, PartialEq, PartialOrd, Clone, Eq)]
pub enum GroupActionStatus {
ActionActive,
ActionClosed,
}

impl TryFrom<u8> for GroupActionStatus {
type Error = anyhow::Error;
fn try_from(value: u8) -> Result<Self, Self::Error> {
match value {
0 => Ok(Self::ActionActive),
1 => Ok(Self::ActionClosed),
value => bail!("unrecognized action status: {}", value),
}
}
}

impl TryFrom<i32> for GroupActionStatus {
type Error = anyhow::Error;
fn try_from(value: i32) -> Result<Self, Self::Error> {
match value {
0 => Ok(Self::ActionActive),
1 => Ok(Self::ActionClosed),
value => bail!("unrecognized action status: {}", value),
}
}
}
2 changes: 2 additions & 0 deletions packages/rs-dpp/src/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ use serde::{Deserialize, Serialize};

pub mod action_event;
pub mod group_action;
pub mod group_action_status;

#[derive(Debug, Clone, Copy, Encode, Decode, PartialEq)]
pub enum GroupStateTransitionInfoStatus {
GroupStateTransitionInfoProposer(GroupContractPosition),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ use drive::drive::identity::withdrawals::paths::{
get_withdrawal_root_path, WITHDRAWAL_TRANSACTIONS_BROADCASTED_KEY,
WITHDRAWAL_TRANSACTIONS_SUM_AMOUNT_TREE_KEY,
};
use drive::drive::prefunded_specialized_balances::{
prefunded_specialized_balances_for_voting_path,
prefunded_specialized_balances_for_voting_path_vec,
};
use drive::drive::prefunded_specialized_balances::prefunded_specialized_balances_for_voting_path_vec;
use drive::drive::system::misc_path;
use drive::drive::tokens::paths::{
tokens_root_path, TOKEN_BALANCES_KEY, TOKEN_IDENTITY_INFO_KEY, TOKEN_STATUS_INFO_KEY,
Expand Down
Loading