Contract 9c6d98820f17229236d4f7be9c49204f12192b30bf94094c8c8c7c8389adecef

← Back to Index 📥 Download WASM

Meta

Description Tansu - Soroban Versioning
home_domain tansu.dev
rssdkver 23.0.3#6aa930b08eabfd578b7824a0d5de473cbd958282
rsver 1.90.0
source_repo tupui/soroban-versioning

Instances

  • CDXINK2T3P46M4LWK35FVIXXHJ2XHAS4FOVCGVPJ63YV5OVTM24IY5BI

Interface

Setup anonymous voting for a project.

Configures BLS12-381 cryptographic primitives for anonymous voting. Only the contract admin can call this function.

Arguments

  • env - The environment object
  • project_key - Unique identifier for the project
  • public_key - Asymmetric public key to be used for vote encryption

Panics

  • If the caller is not the contract admin
fn anonymous_voting_setup(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    public_key: soroban_sdk::String,
)

Get the anonymous voting configuration for a project.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • types::AnonymousVoteConfig - The anonymous voting configuration

Panics

  • If no anonymous voting configuration exists for the project
fn get_anonymous_voting_config(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
) -> AnonymousVoteConfig

Build vote commitments from votes and seeds for anonymous voting.

Creates BLS12-381 commitments for each vote using the formula: C = g^vote * h^seed where g and h are generator points.

Note: This function does not consider voting weights, which are applied during the tallying phase. Calling this on the smart contract would reveal the votes and seeds, so it must be run either in simulation or client-side.

Arguments

  • env - The environment object
  • project_key - Unique identifier for the project
  • votes - Vector of vote choices (0=abstain, 1=approve, 2=reject)
  • seeds - Vector of random seeds for each vote

Returns

  • Vec<BytesN<96>> - Vector of vote commitments (one per vote)

Panics

  • If no anonymous voting configuration exists for the project
fn build_commitments_from_votes(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    votes: soroban_sdk::Vec,
    seeds: soroban_sdk::Vec,
) -> soroban_sdk::Vec>

Create a new proposal for a project.

The proposer is automatically added to the abstain group. By creating a proposal, the proposer incur a collateral which is repaid upon execution of the proposal unless the proposal is revoked. This is a deterrent mechanism.

Arguments

  • env - The environment object
  • proposer - Address of the proposal creator
  • project_key - Unique identifier for the project
  • title - Title of the proposal
  • ipfs - IPFS content identifier describing the proposal
  • voting_ends_at - UNIX timestamp when voting ends
  • public_voting - Whether voting is public or anonymous
  • [Option<outcomes_contract>] - Outcome contract address

Returns

  • u32 - The ID of the created proposal.

Panics

  • If the title is too long
  • If the voting period is invalid
  • If the project doesn't exist
fn create_proposal(
    env: soroban_sdk::Env,
    proposer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    title: soroban_sdk::String,
    ipfs: soroban_sdk::String,
    voting_ends_at: u64,
    public_voting: bool,
    outcomes_contract: Option,
) -> u32

Revoke a proposal.

Useful if there was some spam or bad intent. That will prevent the collateral to be claimed back.

Arguments

  • env - The environment object
  • maintainer - Address of the proposal creator
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to vote on

Panics

  • If the proposal is not active anymore
  • If the maintainer is not authorized
fn revoke_proposal(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
)

Cast a vote on a proposal.

Allows a member to vote on a proposal. The vote can be either public or anonymous depending on the proposal configuration. For public votes, the choice and weight are visible. For anonymous votes, only the weight is visible, and the choice is encrypted.

Arguments

  • env - The environment object
  • voter - The address of the voter
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to vote on
  • vote - The vote data (public or anonymous)

Panics

  • If the voter has already voted
  • If the voting period has ended
  • If the proposal is not active anymore
  • If the proposal doesn't exist
  • If the voter's weight exceeds their maximum allowed weight
  • If the voter is not a member of the project
fn vote(
    env: soroban_sdk::Env,
    voter: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    vote: Vote,
)

Execute a vote after the voting period ends.

Processes the voting results and determines the final status of the proposal. For public votes, the results are calculated directly from vote counts. For anonymous votes, tallies and seeds are validated against vote commitments to ensure the results are correct.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer executing the proposal
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to execute
  • [Option<tallies>] - decoded tally values (scaled by weights), respectively Approve, reject and abstain
  • [Option<seeds>] - decoded seed values (scaled by weights), respectively Approve, reject and abstain

Returns

  • types::ProposalStatus - The final status of the proposal (Approved, Rejected, or Cancelled)

Panics

  • If the voting period hasn't ended
  • If the proposal doesn't exist
  • If the proposal is not active anymore
  • If tallies/seeds are missing for anonymous votes
  • If commitment
fn execute(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
    tallies: Option>,
    seeds: Option>,
) -> ProposalStatus

Verify vote commitment proof for anonymous voting.

Validates that the provided tallies and seeds match the vote commitments without revealing individual votes. This ensures the integrity of anonymous voting results.

The commitment is:

C = g^v * h^r (in additive notation: gv + hr),

where g, h are BLS12-381 generator points and v is the vote choice, r is the seed. Voting weight is introduced during the tallying phase.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • proposal - The proposal containing vote commitments
  • tallies - Decoded tally values [approve, reject, abstain] (scaled by weights)
  • seeds - Decoded seed values [approve, reject, abstain] (scaled by weights)

Returns

  • bool - True if all commitments match the provided tallies and seeds

Panics

  • If no anonymous voting configuration exists for the project
fn proof(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    proposal: Proposal,
    tallies: soroban_sdk::Vec,
    seeds: soroban_sdk::Vec,
) -> bool

Returns a page of proposals (0 to MAX_PROPOSALS_PER_PAGE proposals per page).

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • page - The page number (0-based)

Returns

  • types::Dao - The DAO object containing a page of proposals

Panics

  • If the page number is out of bounds
fn get_dao(env: soroban_sdk::Env, project_key: soroban_sdk::Bytes, page: u32) -> Dao

Get a single proposal by ID.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • proposal_id - The ID of the proposal to retrieve

Returns

  • types::Proposal - The proposal object

Panics

  • If the proposal doesn't exist
fn get_proposal(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    proposal_id: u32,
) -> Proposal

Add a new member to the system with metadata.

Arguments

  • env - The environment object
  • member_address - The address of the member to add
  • meta - Metadata string associated with the member (e.g., IPFS hash)

Panics

  • If the member already exists
fn add_member(
    env: soroban_sdk::Env,
    member_address: soroban_sdk::Address,
    meta: soroban_sdk::String,
)

Get member information including all project badges.

Arguments

  • env - The environment object
  • member_address - The address of the member to retrieve

Returns

  • types::Member - Member information including metadata and project badges

Panics

  • If the member doesn't exist
fn get_member(env: soroban_sdk::Env, member_address: soroban_sdk::Address) -> Member

Set badges for a member in a specific project.

This function replaces all existing badges for the member in the specified project with the new badge list. The member's maximum voting weight is calculated as the sum of all assigned badge weights.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer (must be authorized)
  • key - The project key identifier
  • member - The address of the member to set badges for
  • badges - Vector of badges to assign

Panics

  • If the maintainer is not authorized
  • If the member doesn't exist
  • If the project doesn't exist
fn set_badges(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    key: soroban_sdk::Bytes,
    member: soroban_sdk::Address,
    badges: soroban_sdk::Vec,
)

Get all badges for a specific project, organized by badge type.

Returns a structure containing vectors of member addresses for each badge type (Developer, Triage, Community, Verified).

Arguments

  • env - The environment object
  • key - The project key identifier

Returns

  • types::Badges - Structure containing member addresses for each badge type
fn get_badges(env: soroban_sdk::Env, key: soroban_sdk::Bytes) -> Badges

Get the maximum voting weight for a member in a specific project.

Calculates the sum of all badge weights for the member in the project. If no badges are assigned, returns the Default badge weight (1). This weight determines the maximum number of votes the member can cast in a single voting transaction.

Arguments

  • env - The environment object
  • project_key - The project key identifier
  • member_address - The address of the member

Returns

  • u32 - The maximum voting weight for the member

Panics

  • If the member doesn't exist
fn get_max_weight(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
    member_address: soroban_sdk::Address,
) -> u32

Initialize the Tansu contract with admin configuration.

Arguments

  • env - The environment object
  • admin - The admin address
fn __constructor(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Pause or unpause the contract (emergency stop.)

Arguments

  • env - The environment object
  • admin - The admin address
  • paused - Pause or unpause the contract operations which change ledger states.
fn pause(env: soroban_sdk::Env, admin: soroban_sdk::Address, paused: bool)

Require that the contract is not paused, panic if it is

Panics

  • If the contract is paused.
fn require_not_paused(env: soroban_sdk::Env)

Get current administrators configuration.

Arguments

  • env - The environment object

Returns

  • types::AdminsConfig - The administrators configuration
fn get_admins_config(env: soroban_sdk::Env) -> AdminsConfig

Set the Soroban Domain contract.

Arguments

  • env - The environment object
  • admin - The admin address
  • domain_contract - The new domain contract
fn set_domain_contract(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    domain_contract: Contract,
)

Set the Collateral contract.

Arguments

  • env - The environment object
  • admin - The admin address
  • collateral_contract - The new collateral contract
fn set_collateral_contract(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    collateral_contract: Contract,
)

Propose a contract upgrade.

Arguments

  • env - The environment object
  • admin - An admin address
  • new_wasm_hash - The new WASM hash
  • new_admins_config - Optional new admin configuration (None to keep current)

Panics

  • If the admin is not authorized
  • If there is already an existing proposal (cancel the previous first)
fn propose_upgrade(
    env: soroban_sdk::Env,
    admin: soroban_sdk::Address,
    new_wasm_hash: soroban_sdk::BytesN<32>,
    new_admins_config: Option,
)

Approve an upgrade proposal

Arguments

  • env - The environment object
  • admin - An admin address

Panics

  • If the admin is not authorized
  • If the admin already approved
  • If there is no upgrade to approve
fn approve_upgrade(env: soroban_sdk::Env, admin: soroban_sdk::Address)

Execute or cancel upgrade proposal

Arguments

  • env - The environment object
  • admin - An admin address
  • accept - true to accept and false to reject.

Upgrades can always be cancelled but only executed if there are enough approvals and the timelock period is over.

Panics

  • If the admin is not authorized
  • If it is too early to execute
  • If there are not enough approvals
  • If there is no upgrade to execute
fn finalize_upgrade(env: soroban_sdk::Env, admin: soroban_sdk::Address, accept: bool)

Get upgrade proposal details

fn get_upgrade_proposal(env: soroban_sdk::Env) -> UpgradeProposal

Get the current version of the contract.

Returns

  • u32 - The contract version number
fn version(env: soroban_sdk::Env) -> u32

Register a new project.

Creates a new project entry with maintainers, URL, and commit hash. Also registers the project name in the domain contract if not already registered. The project key is generated using keccak256 hash of the project name.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • name - The project name (max 15 characters)
  • maintainers - List of maintainer addresses for the project
  • url - The project's Git repository URL
  • ipfs - CID of the tansu.toml file with associated metadata

Returns

  • Bytes - The project key (keccak256 hash of the name)

Panics

  • If the project name is longer than 15 characters
  • If the project already exists
  • If the maintainer is not authorized
  • If the domain registration fails
  • If the maintainer doesn't own an existing domain
fn register(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    name: soroban_sdk::String,
    maintainers: soroban_sdk::Vec,
    url: soroban_sdk::String,
    ipfs: soroban_sdk::String,
) -> soroban_sdk::Bytes

Update the configuration of an existing project.

Allows maintainers to change the project's URL, commit hash, and maintainer list.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • key - The project key identifier
  • maintainers - New list of maintainer addresses
  • url - New Git repository URL
  • hash - New commit hash

Panics

  • If the project doesn't exist
  • If the maintainer is not authorized
fn update_config(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    key: soroban_sdk::Bytes,
    maintainers: soroban_sdk::Vec,
    url: soroban_sdk::String,
    ipfs: soroban_sdk::String,
)

Set the latest commit hash for a project.

Updates the current commit hash for the specified project.

Arguments

  • env - The environment object
  • maintainer - The address of the maintainer calling this function
  • project_key - The project key identifier
  • hash - The new commit hash

Panics

  • If the project doesn't exist
  • If the maintainer is not authorized
fn commit(
    env: soroban_sdk::Env,
    maintainer: soroban_sdk::Address,
    project_key: soroban_sdk::Bytes,
    hash: soroban_sdk::String,
)

Get the last commit hash Get the latest commit hash for a project.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • String - The current commit hash

Panics

  • If the project doesn't exist
fn get_commit(
    env: soroban_sdk::Env,
    project_key: soroban_sdk::Bytes,
) -> soroban_sdk::String

Get project information including configuration and maintainers.

Arguments

  • env - The environment object
  • project_key - The project key identifier

Returns

  • types::Project - Project information including name, config, and maintainers

Panics

  • If the project doesn't exist
fn get_project(env: soroban_sdk::Env, project_key: soroban_sdk::Bytes) -> Project

Imports

WebAssembly Text (WAT) ▶