Skip to content

Commit

Permalink
fix: docs required
Browse files Browse the repository at this point in the history
  • Loading branch information
gcranju committed Dec 19, 2024
1 parent c7dfe5e commit b8ab7f8
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 0 deletions.
58 changes: 58 additions & 0 deletions contracts/soroban/contracts/multisig/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Stellar Multisig Contract Frontend Workflow

This README explains how to build a frontend for interacting with a Stellar Multisig contract. The frontend is provided with:
- **Multisig Contract Address**: Used to call functions like `create_proposal`, `add_approval_signature`, and `execute_proposal`.
- **Multisig Account Address**: Used to fetch and interact with relevant proposals.

---

## **Features Overview**

### 1. **Create Proposal Section**
This section allows users to create proposals to upgrade a Stellar contract.

- **Inputs**:
- **Contract Address**: Address of the contract to be upgraded.
- **Contract Hash**: Hash of the new WASM code to deploy.

- **Button**: "Create Proposal".

- **Action Flow**:
1. Build a transaction to upgrade the contract(Can be taken further reference from https://github.com/icon-project/ICON-Projects-Planning/issues/510).
2. Call the `create_proposal` method on the Multisig contract, passing:
- The built transaction in XDR format.
- The Multisig Account Address for reference.

---

### 2. **Approve Proposal Section**
This section allows users to approve proposals that are in a pending state.

- **Display**:
- A list of proposals fetched from the Multisig contract, showing:
- **Proposal ID**
- **Status** (Pending, Approved, Executed).

- **Button**: "Approve" (enabled for pending proposals).

- **Action Flow**:
1. Fetch the proposal data (XDR) from the contract(Structure can be taken reference from contract).
2. Build the transaction and sign it using the signer's private key.
3. Submit the signature and `proposal_id` to the `add_approval_signature` method to approve the proposal.

---

### 3. **Execute Proposal Section**
This section allows users to execute approved proposals.

- **Display**:
- A list of approved proposals ready for execution.

- **Button**: "Execute" (enabled for approved proposals).

- **Action Flow**:
1. Fetch transaction data and signatures from the contract for execution.
2. Build the transaction using the fetched data.
3. Submit the transaction to the Stellar network for execution.

---
8 changes: 8 additions & 0 deletions contracts/soroban/contracts/multisig/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ impl ProposalContract {
Ok(())
}


pub fn add_multisig_wallet(env: Env, wallet: Address, signers: Vec<Address>, threshold: u32) -> Result<(), ContractError> {
let multisig = MultisigWallet {
signers,
Expand All @@ -25,6 +26,9 @@ impl ProposalContract {
Ok(())
}

/// Create a proposal. This proposal is identified by a proposal_id that is increased with each proposal.
/// The proposal is associated with a wallet, which is used to verify signers.
/// The proposal is approved after a number of signatures equal to the threshold of the wallet is reached.
pub fn create_proposal(env: Env, sender : Address, proposal_data: String, wallet: Address) -> Result<(), ContractError> {
sender.require_auth();
if !is_signer(&env, &wallet, sender) {
Expand All @@ -44,6 +48,9 @@ impl ProposalContract {
}


/// Add a signature to a proposal.
/// The proposal is approved after a number of signatures equal to the threshold of the wallet is reached.
/// The function returns an error if the proposal has expired, or if the sender is not a valid signer, or if the sender has already voted.
pub fn add_approval_signature(env: Env, proposal_id: u32, sender: Address, signature: String) -> Result<(), ContractError> {
sender.require_auth();
let key = states::get_proposal(&env, proposal_id);
Expand Down Expand Up @@ -72,6 +79,7 @@ impl ProposalContract {
Ok(())
}

/// Returns all active proposals. A proposal is active if it has not expired.
pub fn get_active_proposals(env: Env) -> Vec<Proposal> {
let count = states::get_count(&env);
let mut proposals = Vec::new(&env);
Expand Down

0 comments on commit b8ab7f8

Please sign in to comment.