Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: project manager #12

Draft
wants to merge 80 commits into
base: teritori-unified
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
ec523e7
feat: DA0-DA0 port
n0izn0iz Sep 18, 2023
fd76513
feat: social feed and moderation dao by @hthieu1110
n0izn0iz Sep 18, 2023
ec5f5b7
chore: remove duplicates and unversion packages
n0izn0iz Sep 18, 2023
1eea98f
chore: reset gnovm changes
n0izn0iz Sep 18, 2023
aca197f
fix: make social feed and moderation work with latest dao packages
n0izn0iz Sep 18, 2023
b56f2f8
chore: move daodao contracts under teritori dir
n0izn0iz Sep 19, 2023
649a10f
chore: move ujson under teritori dir
n0izn0iz Sep 19, 2023
98f0f52
chore: reset Makefile changes
n0izn0iz Sep 19, 2023
5df85b3
chore: move binutils under teritori dir
n0izn0iz Sep 19, 2023
a5bd681
chore: move flags_index under teritori dir
n0izn0iz Sep 19, 2023
0a53afe
chore: move havl under teritori dir
n0izn0iz Sep 19, 2023
da9c395
chore: move markdown_utils under teritori dir
n0izn0iz Sep 19, 2023
84a1832
chore: move utf16 under teritori dir
n0izn0iz Sep 19, 2023
fe9835a
chore: update modboards golden test
n0izn0iz Sep 19, 2023
3e68c65
chore: move dao_realm under teritori dir
n0izn0iz Sep 19, 2023
63dd591
chore: move dao_registry under teritori dir
n0izn0iz Sep 19, 2023
172731e
chore: fork groups into teritori dir
n0izn0iz Sep 19, 2023
8aab4d0
chore: move modboards under teritori dir
n0izn0iz Sep 19, 2023
1a61229
chore: move social_feeds under teritori dir
n0izn0iz Sep 19, 2023
8a7680e
chore: move social_feeds_dao under teritori dir
n0izn0iz Sep 19, 2023
014baa4
chore: move tori under teritori dir
n0izn0iz Sep 19, 2023
58bb506
chore: update modboards golden test
n0izn0iz Sep 19, 2023
9fd8b9b
chore: reset gnovm changes
n0izn0iz Sep 19, 2023
c67f6f7
chore: reset .gitignore changes
n0izn0iz Sep 19, 2023
6303188
feat: escrow contract by @go7066
n0izn0iz Sep 19, 2023
46c6d1e
chore: move escrow under teritori dir
n0izn0iz Sep 19, 2023
ca5525c
feat: cosmos-style voting DAO by @go7066
n0izn0iz Sep 19, 2023
c991f43
chore: move gnodaos under teritori dir
n0izn0iz Sep 19, 2023
c400d35
chore: add disclaimer in gnodaos
n0izn0iz Sep 19, 2023
8c915f3
feat: justicedao and vrf by @go7066
n0izn0iz Sep 19, 2023
77d846a
chore: move justicedao and vrf under teritori dir
n0izn0iz Sep 19, 2023
fba6d55
chore: disable test targeting test3 avl
n0izn0iz Sep 19, 2023
e8c163e
chore: move daodao contracts at teritori root
n0izn0iz Sep 19, 2023
3b03013
chore: add teritori contracts overview
n0izn0iz Sep 19, 2023
3a8cc72
feat: abstract modules config query
n0izn0iz Sep 19, 2023
a3f8d69
fix: add missing imports in gno.mods
n0izn0iz Sep 19, 2023
d3a70cd
Add CurrentRealm endpoint on Justice DAO to configure on escrow realm
go7066 Sep 20, 2023
d088ec6
feat: add tutorial to create a DAO
n0izn0iz Sep 20, 2023
308adc8
chore: clean dao core
n0izn0iz Sep 21, 2023
5ec3d6b
Merge branch 'master' into teritori-unified
moul Sep 22, 2023
d81d436
chore: add moderation DAO documentation
n0izn0iz Sep 26, 2023
6b64cfa
Merge remote-tracking branch 'origin/master' into teritori-unified
n0izn0iz Sep 26, 2023
4f75d8a
feat(ujson): add union support
n0izn0iz Sep 26, 2023
4bacc73
chore: use ujson union
n0izn0iz Sep 26, 2023
126edcd
feat: add voting durations
n0izn0iz Sep 26, 2023
a787dea
chore: clearer error messages
n0izn0iz Sep 26, 2023
139bd50
fix: pass examples CI tests
n0izn0iz Sep 27, 2023
82de5be
feat: check expiration in vote procedure
n0izn0iz Sep 27, 2023
7d9aa49
chore: typo in doc
n0izn0iz Sep 27, 2023
bebea69
chore: fmt
n0izn0iz Sep 28, 2023
cef1115
update for milestone management
go7066 Sep 29, 2023
5f8a3f9
add escrow modification and gopher20 realm
go7066 Oct 3, 2023
963175b
Add improvement thoughts on VRF
go7066 Oct 19, 2023
85ac511
improve escrow, conflict solver and justicedao
go7066 Nov 7, 2023
d06fb73
Merge branch 'teritori-unified' of github.com:TERITORI/gno into escro…
go7066 Nov 9, 2023
b4a1a50
update sellerAmount field to contractorAmount on justicedao and confl…
go7066 Nov 9, 2023
1cbf468
Render dao proposal status and vote result in string instead of integ…
go7066 Nov 10, 2023
b39684b
update vrf spec
go7066 Nov 10, 2023
515dd3e
add update for milestone status, milestone link, contract metadata ma…
go7066 Nov 23, 2023
8db3d0d
Add vrfAdmin initializer to avoid interruption during the deployment …
go7066 Dec 29, 2023
e98102b
add vrf_09 test result
go7066 Dec 29, 2023
7f4527b
apply update from yo & add low priority milestone
go7066 Jan 17, 2024
cb5b6d2
Remove activeMilestone field on contract and update relevant functions
go7066 Jan 17, 2024
d9c152f
Add contractorCandidates and add SubmitContractorCandidate function
go7066 Jan 26, 2024
9aa7cd7
Update caller to use PrevRealm instead of OrgCaller & Update SubmitFu…
go7066 Jan 29, 2024
2145d9b
fix: some bugs to make chain works
Feb 13, 2024
07cc5aa
Remove funding process on create contract when it's created by funder
go7066 Feb 13, 2024
0bdbf18
fix: make 'escrow' contract build
n0izn0iz Feb 13, 2024
6ce65e8
revert "Remove funding process on create contract when it's created b…
n0izn0iz Feb 13, 2024
659e3fb
feat: contract-wide conflict resolution
n0izn0iz Feb 14, 2024
1ca5e9f
feat: project-wide conflict resolution
n0izn0iz Feb 14, 2024
3edb90b
feat: get list candidates
Feb 14, 2024
c6bc1a1
Merge branch 'escrow_update_for_onchain_project_manager' of https://g…
Feb 14, 2024
39b0e81
fix: conflict handler after testing
n0izn0iz Feb 14, 2024
1f648ed
chore: clean contract
n0izn0iz Feb 15, 2024
de61187
chore: remove unused package
n0izn0iz Feb 15, 2024
f2ee913
Merge remote-tracking branch 'teritori/master' into escrow_update_for…
n0izn0iz Feb 15, 2024
3b9bdf9
fix: pass tests
n0izn0iz Feb 15, 2024
26fcec5
chore: Merge remote-tracking branch 'teritori/master' into teritori-u…
n0izn0iz Feb 15, 2024
da4ba79
Merge branch 'teritori-unified' into escrow_update_for_onchain_projec…
n0izn0iz Feb 15, 2024
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
34 changes: 34 additions & 0 deletions examples/gno.land/p/demo/teritori/binutils/binutils.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package binutils

import (
"encoding/binary"
"errors"
)

var ErrInvalidLengthPrefixedString = errors.New("invalid length-prefixed string")

func EncodeLengthPrefixedStringUint16BE(s string) []byte {
b := make([]byte, 2+len(s))
binary.BigEndian.PutUint16(b, uint16(len(s)))
copy(b[2:], s)
return b
}

func DecodeLengthPrefixedStringUint16BE(b []byte) (string, []byte, error) {
if len(b) < 2 {
return "", nil, ErrInvalidLengthPrefixedString
}
l := binary.BigEndian.Uint16(b)
if len(b) < 2+int(l) {
return "", nil, ErrInvalidLengthPrefixedString
}
return string(b[2 : 2+l]), b[l+2:], nil
}

func MustDecodeLengthPrefixedStringUint16BE(b []byte) (string, []byte) {
s, r, err := DecodeLengthPrefixedStringUint16BE(b)
if err != nil {
panic(err)
}
return s, r
}
1 change: 1 addition & 0 deletions examples/gno.land/p/demo/teritori/binutils/gno.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module gno.land/p/demo/teritori/binutils
183 changes: 183 additions & 0 deletions examples/gno.land/p/demo/teritori/dao_core/dao_core.gno
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
package core

import (
"std"

dao_interfaces "gno.land/p/demo/teritori/dao_interfaces"
"gno.land/p/demo/teritori/markdown_utils"
)

// TODO: add wrapper message handler to handle multiple proposal modules messages

type daoCore struct {
dao_interfaces.IDAOCore

votingModule dao_interfaces.IVotingModule
proposalModules []dao_interfaces.ActivableProposalModule
activeProposalModuleCount int
realm std.Realm
registry *dao_interfaces.MessagesRegistry
}

func NewDAOCore(
votingModuleFactory dao_interfaces.VotingModuleFactory,
proposalModulesFactories []dao_interfaces.ProposalModuleFactory,
messageHandlersFactories []dao_interfaces.MessageHandlerFactory,
) dao_interfaces.IDAOCore {
if votingModuleFactory == nil {
panic("Missing voting module factory")
}

if len(proposalModulesFactories) == 0 {
panic("No proposal modules factories")
}

core := &daoCore{
realm: std.CurrentRealm(),
activeProposalModuleCount: len(proposalModulesFactories),
registry: dao_interfaces.NewMessagesRegistry(),
proposalModules: make([]dao_interfaces.ActivableProposalModule, len(proposalModulesFactories)),
}

core.votingModule = votingModuleFactory(core)
if core.votingModule == nil {
panic("voting module factory returned nil")
}

for i, modFactory := range proposalModulesFactories {
mod := modFactory(core)
if mod == nil {
panic("proposal module factory returned nil")
}
core.proposalModules[i] = dao_interfaces.ActivableProposalModule{
Enabled: true,
Module: mod,
}
}

// this registry is specific to gno since we can't do dynamic calls
core.registry.Register(NewUpdateVotingModuleMessageHandler(core))
core.registry.Register(NewUpdateProposalModulesMessageHandler(core))
for _, handlerFactory := range messageHandlersFactories {
handler := handlerFactory(core)
if handler == nil {
panic("message handler factory returned nil")
}
core.registry.Register(handler)
}

return core
}

// mutations

func (d *daoCore) UpdateVotingModule(newVotingModule dao_interfaces.IVotingModule) {
if std.CurrentRealm().Addr() != d.realm.Addr() { // not sure this check necessary since the ownership system should protect against mutation from other realms
panic(ErrUnauthorized)
}

// FIXME: check da0-da0 implem
d.votingModule = newVotingModule
}

func (d *daoCore) UpdateProposalModules(toAdd []dao_interfaces.IProposalModule, toDisable []int) {
if std.CurrentRealm().Addr() != d.realm.Addr() { // not sure this check necessary since the ownership system should protect against mutation from other realms
panic(ErrUnauthorized)
}

for _, module := range toAdd {
d.addProposalModule(module)
}

for _, moduleIndex := range toDisable {
module := GetProposalModule(d, moduleIndex)

if !module.Enabled {
panic(ErrModuleAlreadyDisabled)
}
module.Enabled = false

d.activeProposalModuleCount--
if d.activeProposalModuleCount == 0 {
panic("no active proposal modules") // this -> `panic(ErrNoActiveProposalModules)` triggers `panic: reflect: reflect.Value.SetString using value obtained using unexported field`
}
}
}

// queries

func (d *daoCore) ProposalModules() []dao_interfaces.ActivableProposalModule {
return d.proposalModules
}

func (d *daoCore) VotingModule() dao_interfaces.IVotingModule {
return d.votingModule
}

func (d *daoCore) VotingPowerAtHeight(address std.Address, height int64) uint64 {
return d.VotingModule().VotingPowerAtHeight(address, height)
}

func (d *daoCore) ActiveProposalModuleCount() int {
return d.activeProposalModuleCount
}

func (d *daoCore) Render(path string) string {
s := "# DAO Core\n"
s += "This is an attempt at porting [DA0-DA0 contracts](https://github.com/DA0-DA0/dao-contracts)\n"
s += markdown_utils.Indent(d.votingModule.Render(path)) + "\n"
for _, propMod := range d.proposalModules {
if !propMod.Enabled {
continue
}
s += markdown_utils.Indent(propMod.Module.Render(path)) + "\n"
}
return s
}

func (d *daoCore) Registry() *dao_interfaces.MessagesRegistry {
return d.registry
}

// TODO: move this helper in dao interfaces

func GetProposalModule(core dao_interfaces.IDAOCore, moduleIndex int) *dao_interfaces.ActivableProposalModule {
if moduleIndex < 0 {
panic("module index must be >= 0")
}
mods := core.ProposalModules()
if moduleIndex >= len(mods) {
panic("invalid module index")
}
return &mods[moduleIndex]
}

// internal

func (d *daoCore) executeMsgs(msgs []dao_interfaces.ExecutableMessage) {
for _, msg := range msgs {
d.registry.Execute(msg)
}
}

func (d *daoCore) addProposalModule(proposalMod dao_interfaces.IProposalModule) {
for _, mod := range d.proposalModules {
if mod.Module != proposalMod {
continue
}

if mod.Enabled {
panic(ErrModuleAlreadyAdded)
}
mod.Enabled = true
d.activeProposalModuleCount++
return
}

d.proposalModules = append(d.proposalModules, dao_interfaces.ActivableProposalModule{
Enabled: true,
Module: proposalMod,
})

d.activeProposalModuleCount++
}
Loading
Loading