-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ec84efa
commit 5381cbe
Showing
131 changed files
with
17,319 additions
and
3,791 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
============= | ||
API Reference | ||
============= | ||
|
||
Introduction | ||
____________ | ||
|
||
|
||
:ref:`collectivegovernance`_ implements a flexible approach to voting to support a variety of communities. Each community can define the individuals who may participate in governance decision making by defining a 'VoterClass' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
=============== | ||
Getting Started | ||
=============== | ||
|
||
|
||
:ref:`Collective Governance <collectivegovernance>` implements a flexible approach to voting to support a wide variety of communities. Each community can define the individuals who may participate in governance decision making by defining a :ref:`VoterClass <VoterClass>`. The VoterClass defines the characteristics of the voting population and determines if the wallet is in or out for a particular vote. | ||
|
||
|
||
Types of VoterClass: | ||
|
||
* Open Voting | ||
* ERC-721 Token (including ERC-721 Enumerable) | ||
* Pool Voting - based on a specific list of voters | ||
|
||
|
||
Once the proper VoterClass has been established, an online community can build a new Governance Contract. The :ref:`<GovernanceBuilder>` provides a convienient method to create a new Governance Contract. | ||
|
||
To build a GovernanceBuilder a VoterClass must be provided, specified by the address as well as one or more :ref:`<Supervisors>` who may configure voting parameters as well as veto vote outcomes which are not in the best interest of the community. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
.. Collective Governance documentation master file | ||
.. _collectivegovernance: | ||
|
||
================================================= | ||
Collective Governance | ||
================================================= | ||
|
||
------------------------------------------------- | ||
Open Source Community Governance Smart Contract | ||
------------------------------------------------- | ||
|
||
This is an Ethereum based smart contract with support for open voting and token voting. It is open for all communities on the public blockchain. | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Contents: | ||
|
||
gettingstarted | ||
javascript_example | ||
license | ||
|
||
.. _deployment: | ||
|
||
Deployment Location | ||
=================== | ||
|
||
|
||
Görli Testnet | ||
_____________ | ||
|
||
|
||
===================== ========================================== =========== =================== | ||
Contract Eth Address Version Description | ||
===================== ========================================== =========== =================== | ||
CollectiveGovernance 0x833b33A274DB2b26a030bEF1DF0A3981f01C1364 0.8.1 Governance Contract | ||
===================== ========================================== =========== =================== | ||
|
||
|
||
Project Links | ||
============= | ||
* `GitHub`_ | ||
* `JavaScript Reference`_ | ||
|
||
.. _GitHub: https://github.com/momentranks/collective-governance-v1 | ||
.. _JavaScript Reference: https://github.com/momentranks/collective_governance_js | ||
|
||
|
||
Indices and tables | ||
================== | ||
|
||
* :ref:`genindex` | ||
* :ref:`modindex` | ||
* :ref:`search` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
=============== | ||
Getting Started | ||
=============== | ||
|
||
|
||
:ref:`Collective Governance <collectivegovernance>` implements a flexible approach to voting to support a wide variety of communities. Each community can define the individuals who may participate in governance decision making by defining a ref:`Voter Class <VoterClass>`. The VoterClass defines the characteristics of the voting population and determines if the wallet is in or out for a particular vote. | ||
|
||
|
||
Types of VoterClass | ||
* Open Voting | ||
* ERC-721 Token (including ERC-721 Enumerable) | ||
* Pool Voting - based on a specific list of voters | ||
|
||
|
||
Once the proper VoterClass has been established, an online community can build a new Governance Contract. The :ref:`<GovernanceBuilder>` provides a convienient method to create a new Governance Contract. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
JavaScript Examples | ||
=================== | ||
|
||
Examples based on `JavaScript Reference`_. ABI files are available from `GitHub`_ | ||
|
||
.. _javascript: | ||
|
||
VoterClass | ||
---------- | ||
|
||
The first step is to build a VoterClass for your project. This can be reused for all future projects and voting. | ||
|
||
.. code-block:: javascript | ||
const voterClassFactory = new VoterClassFactory(...); | ||
const classAddress = await voterClassFactory.createERC721(config.tokenContract, 1); | ||
logger.info(`VoterClass created at ${classAddress}`); | ||
Make a note of the Ethereum address for the class you created. For example `0x6bAc373e27f844259F3B79A6E7dAFf3868eBDc13 <https://goerli.etherscan.io/address/0x6bAc373e27f844259F3B79A6E7dAFf3868eBDc13>`_ | ||
|
||
Governance | ||
---------- | ||
|
||
The next step is to build the Governance Contract for your community. This will take the VoterClass as an argument and reuse it for all future votes. | ||
|
||
.. code-block:: javascript | ||
const governanceBuilder = new GovernanceBuilder(config.abiPath, config.builderAddress, web3, wallet, config.getGas()); | ||
const name = await governanceBuilder.name(); | ||
logger.info(name); | ||
await governanceBuilder.aGovernance(); | ||
await governanceBuilder.withSupervisor(wallet.getAddress()); | ||
await governanceBuilder.withVoterClassAddress(config.voterClass); | ||
const governanceAddress = await governanceBuilder.build(); | ||
logger.info(`Governance contract created at ${governanceAddress}`); | ||
Make a note of the address of the created contract as this will be used for all future governance calls. | ||
|
||
|
||
Voting | ||
______ | ||
|
||
Now you can create proposals using the governance contract. | ||
|
||
.. code-block:: javascript | ||
const web3 = new Web3(config.rpcUrl); | ||
const wallet = new EthWallet(config.privateKey, web3); | ||
wallet.connect(); | ||
logger.info(`Wallet connected: ${wallet.getAddress()}`); | ||
const governance = new CollectiveGovernance(config.abiPath, config.contractAddress, web3, wallet, config.getGas()); | ||
logger.info(`Connected to contract: ${config.contractAddress}`); | ||
const name = await governance.name(); | ||
const version = await governance.version(); | ||
logger.info(`${name}: ${version}`); | ||
const storageAddress = await governance.getStorageAddress(); | ||
const storage = new Storage(config.abiPath, storageAddress, web3); | ||
const storageName = await storage.name(); | ||
const storageVersion = await storage.version(); | ||
logger.info(`${storageName}: ${storageVersion}`); | ||
const proposalId = await governance.propose(); | ||
Next configure the proposal and open voting | ||
|
||
.. code-block:: javascript | ||
await governance.configure(proposalId, 1, 5); | ||
const quorum = await storage.quorumRequired(proposalId); | ||
const duration = await storage.voteDuration(proposalId); | ||
logger.info(`New Vote - ${proposalId}: quorum=${quorum}, duration=${duration}`); | ||
await governance.openVote(proposalId); | ||
logger.info('Voting is open...'); | ||
Finally just vote | ||
|
||
.. code-block:: javascript | ||
await governance.voteFor(proposalId); | ||
.. _GitHub: https://github.com/momentranks/collective-governance-v1 | ||
.. _JavaScript Reference: https://github.com/momentranks/collective_governance_js | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
BSD 3-Clause License | ||
____________________ | ||
|
||
.. _license: | ||
|
||
Copyright (c) 2022, Collective.XYZ | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
1. Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
2. Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
3. Neither the name of the copyright holder nor the names of its | ||
contributors may be used to endorse or promote products derived from | ||
this software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE | ||
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | ||
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | ||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | ||
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
/* | ||
* _sphinx_javascript_frameworks_compat.js | ||
* ~~~~~~~~~~ | ||
* | ||
* Compatability shim for jQuery and underscores.js. | ||
* | ||
* WILL BE REMOVED IN Sphinx 6.0 | ||
* xref RemovedInSphinx60Warning | ||
* | ||
*/ | ||
|
||
/** | ||
* select a different prefix for underscore | ||
*/ | ||
$u = _.noConflict(); | ||
|
||
|
||
/** | ||
* small helper function to urldecode strings | ||
* | ||
* See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent#Decoding_query_parameters_from_a_URL | ||
*/ | ||
jQuery.urldecode = function(x) { | ||
if (!x) { | ||
return x | ||
} | ||
return decodeURIComponent(x.replace(/\+/g, ' ')); | ||
}; | ||
|
||
/** | ||
* small helper function to urlencode strings | ||
*/ | ||
jQuery.urlencode = encodeURIComponent; | ||
|
||
/** | ||
* This function returns the parsed url parameters of the | ||
* current request. Multiple values per key are supported, | ||
* it will always return arrays of strings for the value parts. | ||
*/ | ||
jQuery.getQueryParameters = function(s) { | ||
if (typeof s === 'undefined') | ||
s = document.location.search; | ||
var parts = s.substr(s.indexOf('?') + 1).split('&'); | ||
var result = {}; | ||
for (var i = 0; i < parts.length; i++) { | ||
var tmp = parts[i].split('=', 2); | ||
var key = jQuery.urldecode(tmp[0]); | ||
var value = jQuery.urldecode(tmp[1]); | ||
if (key in result) | ||
result[key].push(value); | ||
else | ||
result[key] = [value]; | ||
} | ||
return result; | ||
}; | ||
|
||
/** | ||
* highlight a given string on a jquery object by wrapping it in | ||
* span elements with the given class name. | ||
*/ | ||
jQuery.fn.highlightText = function(text, className) { | ||
function highlight(node, addItems) { | ||
if (node.nodeType === 3) { | ||
var val = node.nodeValue; | ||
var pos = val.toLowerCase().indexOf(text); | ||
if (pos >= 0 && | ||
!jQuery(node.parentNode).hasClass(className) && | ||
!jQuery(node.parentNode).hasClass("nohighlight")) { | ||
var span; | ||
var isInSVG = jQuery(node).closest("body, svg, foreignObject").is("svg"); | ||
if (isInSVG) { | ||
span = document.createElementNS("http://www.w3.org/2000/svg", "tspan"); | ||
} else { | ||
span = document.createElement("span"); | ||
span.className = className; | ||
} | ||
span.appendChild(document.createTextNode(val.substr(pos, text.length))); | ||
node.parentNode.insertBefore(span, node.parentNode.insertBefore( | ||
document.createTextNode(val.substr(pos + text.length)), | ||
node.nextSibling)); | ||
node.nodeValue = val.substr(0, pos); | ||
if (isInSVG) { | ||
var rect = document.createElementNS("http://www.w3.org/2000/svg", "rect"); | ||
var bbox = node.parentElement.getBBox(); | ||
rect.x.baseVal.value = bbox.x; | ||
rect.y.baseVal.value = bbox.y; | ||
rect.width.baseVal.value = bbox.width; | ||
rect.height.baseVal.value = bbox.height; | ||
rect.setAttribute('class', className); | ||
addItems.push({ | ||
"parent": node.parentNode, | ||
"target": rect}); | ||
} | ||
} | ||
} | ||
else if (!jQuery(node).is("button, select, textarea")) { | ||
jQuery.each(node.childNodes, function() { | ||
highlight(this, addItems); | ||
}); | ||
} | ||
} | ||
var addItems = []; | ||
var result = this.each(function() { | ||
highlight(this, addItems); | ||
}); | ||
for (var i = 0; i < addItems.length; ++i) { | ||
jQuery(addItems[i].parent).before(addItems[i].target); | ||
} | ||
return result; | ||
}; | ||
|
||
/* | ||
* backward compatibility for jQuery.browser | ||
* This will be supported until firefox bug is fixed. | ||
*/ | ||
if (!jQuery.browser) { | ||
jQuery.uaMatch = function(ua) { | ||
ua = ua.toLowerCase(); | ||
|
||
var match = /(chrome)[ \/]([\w.]+)/.exec(ua) || | ||
/(webkit)[ \/]([\w.]+)/.exec(ua) || | ||
/(opera)(?:.*version|)[ \/]([\w.]+)/.exec(ua) || | ||
/(msie) ([\w.]+)/.exec(ua) || | ||
ua.indexOf("compatible") < 0 && /(mozilla)(?:.*? rv:([\w.]+)|)/.exec(ua) || | ||
[]; | ||
|
||
return { | ||
browser: match[ 1 ] || "", | ||
version: match[ 2 ] || "0" | ||
}; | ||
}; | ||
jQuery.browser = {}; | ||
jQuery.browser[jQuery.uaMatch(navigator.userAgent).browser] = true; | ||
} |
Oops, something went wrong.