Skip to content

Commit

Permalink
chore: adapt js
Browse files Browse the repository at this point in the history
Signed-off-by: Norman <[email protected]>
  • Loading branch information
n0izn0iz committed Dec 29, 2024
1 parent e247761 commit 64f288e
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 41 deletions.
3 changes: 1 addition & 2 deletions networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -4522,8 +4522,7 @@
"modboardsPkgPath": "gno.land/r/teritori/modboards",
"groupsPkgPath": "gno.land/r/teritori/groups",
"votingGroupPkgPath": "gno.land/p/teritori/dao_voting_group",
"rolesVotingGroupPkgPath": "gno.land/p/teritori/dao_voting_roles",
"rolesGroupPkgPath": "gno.land/p/teritori/dao_roles_group",
"votingRolesPkgPath": "gno.land/p/teritori/dao_voting_roles",
"daoProposalSinglePkgPath": "gno.land/p/teritori/dao_proposal_single",
"profilePkgPath": "gno.land/r/demo/profile",
"daoInterfacesPkgPath": "gno.land/p/teritori/dao_interfaces",
Expand Down
3 changes: 1 addition & 2 deletions packages/networks/gno-dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export const gnoDevNetwork: GnoNetworkInfo = {
modboardsPkgPath: "gno.land/r/teritori/modboards",
groupsPkgPath: "gno.land/r/teritori/groups",
votingGroupPkgPath: "gno.land/p/teritori/dao_voting_group",
rolesVotingGroupPkgPath: "gno.land/p/teritori/dao_voting_roles",
rolesGroupPkgPath: "gno.land/p/teritori/dao_roles_group",
votingRolesPkgPath: "gno.land/p/teritori/dao_voting_roles",
daoProposalSinglePkgPath: "gno.land/p/teritori/dao_proposal_single",
profilePkgPath: "gno.land/r/demo/profile",
daoInterfacesPkgPath: "gno.land/p/teritori/dao_interfaces",
Expand Down
3 changes: 1 addition & 2 deletions packages/networks/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ export type GnoNetworkInfo = NetworkInfoBase & {
socialFeedsPkgPath?: string;
socialFeedsDAOPkgPath?: string;
votingGroupPkgPath?: string;
rolesVotingGroupPkgPath?: string;
rolesGroupPkgPath?: string;
votingRolesPkgPath?: string;
daoProposalSinglePkgPath?: string;
daoInterfacesPkgPath?: string;
daoCorePkgPath?: string;
Expand Down
10 changes: 5 additions & 5 deletions packages/utils/gnodao/generateMembershipDAOSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ export const generateMembershipDAOSource = (
var (
daoCore dao_interfaces.IDAOCore
group *voting_group.VotingGroup
voting *voting_group.VotingGroup
registered bool
)
func init() {
votingModuleFactory := func(core dao_interfaces.IDAOCore) dao_interfaces.IVotingModule {
group = voting_group.NewVotingGroup()
voting = voting_group.NewVotingGroup()
${conf.initialMembers
.map(
(member) =>
`group.SetMemberPower("${member.address}", ${member.weight})`,
`voting.SetMemberPower("${member.address}", ${member.weight})`,
)
.join("\n\t")}
return group
return voting
}
// TODO: consider using factories that return multiple modules and handlers
Expand All @@ -63,7 +63,7 @@ export const generateMembershipDAOSource = (
messageHandlersFactories := []dao_interfaces.MessageHandlerFactory{
func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler {
return group.UpdateMembersHandler()
return voting.UpdateMembersHandler()
},
func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler {
// TODO: add a router to support multiple proposal modules
Expand Down
56 changes: 26 additions & 30 deletions packages/utils/gnodao/generateRolesDAOSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,50 @@ export const generateRolesDAOSource = (
dao_core "${network.daoCorePkgPath}"
dao_interfaces "${network.daoInterfacesPkgPath}"
proposal_single "${network.daoProposalSinglePkgPath}"
"${network.rolesGroupPkgPath}"
"${network.daoUtilsPkgPath}"
"gno.land/p/teritori/jsonutil"
"${network.profilePkgPath}"
voting_group "${network.rolesVotingGroupPkgPath}"
voting_roles "${network.votingRolesPkgPath}"
"${network.daoRegistryPkgPath}"
"${network.socialFeedsPkgPath}"
"gno.land/p/demo/json"
)
var (
daoCore dao_interfaces.IDAOCore
group *voting_group.RolesVotingGroup
roles *dao_roles_group.RolesGroup
voting *voting_roles.VotingRoles
registered bool
)
func init() {
roles = dao_roles_group.NewRolesGroup()
${(conf.roles ?? [])
.map(
(role) =>
`roles.NewRoleJSON("${role.name}", "[${(role.resources ?? [])
.map(
(resource) =>
`{\\"resource\\": \\"${resource}\\", \\"power\\": \\"999\\"}`,
)
.join(", ")}]")`,
)
.join("\n\t")}
${conf.initialMembers
.filter((member) => member.roles.length > 0)
.map((member) =>
member.roles
.map((role) => `roles.GrantRole("${member.address}", "${role}")`)
.join("\n\t"),
)
.join("\n\t")}
votingModuleFactory := func(core dao_interfaces.IDAOCore) dao_interfaces.IVotingModule {
group = voting_group.NewRolesVotingGroup(roles)
voting = voting_roles.NewVotingRoles()
${(conf.roles ?? [])
.map(
(role) =>
`voting.NewRoleJSON("${role.name}", "[${(role.resources ?? [])
.map(
(resource) =>
`{\\"resource\\": \\"${resource}\\", \\"power\\": \\"999\\"}`,
)
.join(", ")}]")`,
)
.join("\n\t")}
${conf.initialMembers
.filter((member) => member.roles.length > 0)
.map((member) =>
member.roles
.map((role) => `voting.GrantRole("${member.address}", "${role}")`)
.join("\n\t"),
)
.join("\n\t")}
${conf.initialMembers
.map(
(member) =>
`group.SetMemberPower("${member.address}", ${member.weight})`,
`voting.SetMemberPower("${member.address}", ${member.weight})`,
)
.join("\n\t")}
return group
return voting
}
Expand All @@ -88,7 +84,7 @@ func init() {
messageHandlersFactories := []dao_interfaces.MessageHandlerFactory{
func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler {
return group.UpdateMembersHandler()
return voting.UpdateMembersHandler()
},
func(core dao_interfaces.IDAOCore) dao_interfaces.MessageHandler {
// TODO: add a router to support multiple proposal modules
Expand Down Expand Up @@ -167,7 +163,7 @@ func init() {
for i, val := range vals {
obj := val.MustObject()
addr := jsonutil.MustAddress(obj["address"])
roles := roles.GetMemberRoles(addr)
roles := voting.GetMemberRoles(addr)
rolesJSON := make([]*json.Node, len(roles))
for j, role := range roles {
rolesJSON[j] = json.StringNode("", role)
Expand Down

0 comments on commit 64f288e

Please sign in to comment.