Skip to main content

state — shyshares

Package shyshares implements the shyshares-v1 ABCI state machine — a composition of the shyvoting anonymous ballot apparatus and the shywire anonymous token apparatus on one CometBFT chain.

Import path: github.com/NickCarducci/Shyware-SDK/shyshares

Architecture

shyshares composes two sub-state machines on one chain:

  • Voting sub-state — anonymous weighted ballots for governance proposals (from shyvoting)
  • Wire sub-state — anonymous token transfers for stake movement (from shywire)

Every transaction is wrapped in a tx.Envelope that routes to the correct sub-machine:

// Envelope discriminates shyvoting vs shywire sub-protocol
type Envelope struct {
Protocol string `json:"protocol"` // "shyvoting" | "shywire"
Payload json.RawMessage `json:"payload"`
}

API server

embodiments/shyshares/api/server.go registers the shares-specific REST routes on top of the shared infrastructure:

r.HandleFunc("/organizations", listOrganizations).Methods(GET)
r.HandleFunc("/organizations/{id}", getOrganization).Methods(GET)
r.HandleFunc("/memberships/{account_commitment}", getMemberships).Methods(GET)
r.HandleFunc("/proposals", listProposals, createProposal).Methods(GET, POST)
r.HandleFunc("/proposals/{id}", getProposal).Methods(GET)
r.HandleFunc("/proposals/{id}/close", closeProposal).Methods(POST)
r.HandleFunc("/ballots", submitBallot).Methods(POST)
r.HandleFunc("/tallies/{proposal_id}", getTally).Methods(GET)
r.HandleFunc("/actions", listActions).Methods(GET)
r.HandleFunc("/actions/{id}", getAction).Methods(GET)
r.HandleFunc("/actions/{id}/dispatch", dispatchAction).Methods(POST)

Wire transfer endpoints from the shywire sub-machine are available on the same server.

Tx envelope

// Wrap a voting ballot for submission to a shyshares chain
envelope, err := tx.WrapVoting(ballotTxJSON)

// Wrap a wire transfer for stake movement
envelope, err := tx.WrapWire(transferTxJSON)

The ABCI app decodes the envelope and dispatches to the appropriate sub-machine. Both sub-machines enforce their own two-list invariant independently on the same CometBFT chain.