Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion backend/main/cadence/scripts/get_nfts_ids.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub fun main(address: Address): [UInt64] {
let account = getAccount(address)

let collectionRef = account
.getCapability("TOKEN_NAME".CollectionPublicPath)
.getCapability(/public/"COLLECTION_PUBLIC_PATH")
.borrow<&{NonFungibleToken.CollectionPublic}>()
?? panic("Could not borrow capability from public collection")

Expand Down
5 changes: 2 additions & 3 deletions backend/main/models/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,8 @@ type UpdateCommunityRequestPayload struct {
}

type Strategy struct {
Name *string `json:"name,omitempty"`
shared.Contract `json:"contract,omitempty"`
RequiresSnapshot bool
Name *string `json:"name,omitempty"`
shared.Contract `json:"contract,omitempty"`
}

type CommunityType struct {
Expand Down
13 changes: 8 additions & 5 deletions backend/main/server/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,14 @@ type Strategy interface {
GetVoteWeightForBalance(vote *models.VoteWithBalance, proposal *models.Proposal) (float64, error)
InitStrategy(f *shared.FlowAdapter, db *shared.Database, sc *shared.SnapshotClient)
FetchBalance(b *models.Balance, p *models.Proposal) (*models.Balance, error)
RequiresSnapshot() bool
}

var strategyMap = map[string]Strategy{
"token-weighted-default": &strategies.TokenWeightedDefault{RequiresSnapshot: true},
"staked-token-weighted-default": &strategies.StakedTokenWeightedDefault{RequiresSnapshot: true},
"one-address-one-vote": &strategies.OneAddressOneVote{RequiresSnapshot: false},
"balance-of-nfts": &strategies.BalanceOfNfts{RequiresSnapshot: false},
"token-weighted-default": &strategies.TokenWeightedDefault{},
"staked-token-weighted-default": &strategies.StakedTokenWeightedDefault{},
"one-address-one-vote": &strategies.OneAddressOneVote{},
"balance-of-nfts": &strategies.BalanceOfNfts{},
}

const (
Expand Down Expand Up @@ -793,9 +794,11 @@ func (a *App) createProposal(w http.ResponseWriter, r *http.Request) {
return

}
s := strategyMap[*p.Strategy]
s.InitStrategy(a.FlowAdapter, a.DB, a.SnapshotClient)

var snapshotResponse *shared.SnapshotResponse
if strategy.RequiresSnapshot {
if s.RequiresSnapshot() {
snapshotResponse, err = a.SnapshotClient.TakeSnapshot(strategy.Contract)
if err != nil {
log.Error().Err(err).Msg("error taking snapshot")
Expand Down
2 changes: 2 additions & 0 deletions backend/main/shared/flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
placeholderFungibleTokenAddr = regexp.MustCompile(`"[^"\s]*FUNGIBLE_TOKEN_ADDRESS"`)
placeholderNonFungibleTokenAddr = regexp.MustCompile(`"[^"\s]*NON_FUNGIBLE_TOKEN_ADDRESS"`)
placeholderMetadataViewsAddr = regexp.MustCompile(`"[^"\s]*METADATA_VIEWS_ADDRESS"`)
placeholderCollectionPublicPath = regexp.MustCompile(`"[^"\s]*COLLECTION_PUBLIC_PATH"`)
)

func NewFlowClient(flowEnv string) *FlowAdapter {
Expand Down Expand Up @@ -354,6 +355,7 @@ func (fa *FlowAdapter) ReplaceContractPlaceholders(code string, c *Contract, isF
if isFungible {
code = placeholderFungibleTokenAddr.ReplaceAllString(code, fungibleTokenAddr)
} else {
code = placeholderCollectionPublicPath.ReplaceAllString(code, *c.Public_path)
code = placeholderNonFungibleTokenAddr.ReplaceAllString(code, nonFungibleTokenAddr)
}

Expand Down
6 changes: 4 additions & 2 deletions backend/main/strategies/balance_of_nfts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ type BalanceOfNfts struct {
s.StrategyStruct
SC s.SnapshotClient
DB *s.Database

RequiresSnapshot bool
}

func (b *BalanceOfNfts) FetchBalance(
Expand Down Expand Up @@ -98,6 +96,10 @@ func (s *BalanceOfNfts) GetVotes(
return votes, nil
}

func (s *BalanceOfNfts) RequiresSnapshot() bool {
return false
}

func (s *BalanceOfNfts) InitStrategy(
f *shared.FlowAdapter,
db *shared.Database,
Expand Down
6 changes: 4 additions & 2 deletions backend/main/strategies/one_address_one_vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ type OneAddressOneVote struct {
s.StrategyStruct
SC s.SnapshotClient
DB *s.Database

RequiresSnapshot bool
}

func (s *OneAddressOneVote) FetchBalance(
Expand Down Expand Up @@ -81,6 +79,10 @@ func (s *OneAddressOneVote) GetVotes(
return votes, nil
}

func (s *OneAddressOneVote) RequiresSnapshot() bool {
return false
}

func (s *OneAddressOneVote) InitStrategy(
f *shared.FlowAdapter,
db *shared.Database,
Expand Down
6 changes: 4 additions & 2 deletions backend/main/strategies/staked_token_weighted_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ type StakedTokenWeightedDefault struct {
s.StrategyStruct
SC s.SnapshotClient
DB *s.Database

RequiresSnapshot bool
}

func (s *StakedTokenWeightedDefault) FetchBalance(
Expand Down Expand Up @@ -111,6 +109,10 @@ func (s *StakedTokenWeightedDefault) GetVotes(
return votes, nil
}

func (s *StakedTokenWeightedDefault) RequiresSnapshot() bool {
return true
}

func (s *StakedTokenWeightedDefault) InitStrategy(
f *shared.FlowAdapter,
db *shared.Database,
Expand Down
6 changes: 4 additions & 2 deletions backend/main/strategies/token_weighted_default.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ type TokenWeightedDefault struct {
s.StrategyStruct
SC s.SnapshotClient
DB *s.Database

RequiresSnapshot bool
}

type FTBalanceResponse struct {
Expand Down Expand Up @@ -132,6 +130,10 @@ func (s *TokenWeightedDefault) GetVotes(
return votes, nil
}

func (s *TokenWeightedDefault) RequiresSnapshot() bool {
return true
}

func (s *TokenWeightedDefault) InitStrategy(
f *shared.FlowAdapter,
db *shared.Database,
Expand Down
10 changes: 5 additions & 5 deletions frontend/packages/client/src/App.sass
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ code
border: 1px solid $grey-lighter
.border-lighter-dark-grey
border: 1px solid $lighter-dark-grey
.border-dashed-dark
border: 2px dashed $lighter-dark-grey
.flex-1
flex: 1 0 0
.flex-2
Expand Down Expand Up @@ -254,7 +256,9 @@ hr
.dropdown.is-disabled
background-color: rgba(239, 239, 239, 0.3)
pointer-events: none

@media (min-width: 769px) and (max-width: 820px)
.is-hidden-connect
display: none
@media (min-width: 1024px)
.container > .navbar .navbar-brand
margin-left: 0 !important
Expand Down Expand Up @@ -530,8 +534,6 @@ span[data-tooltip]
-o-animation: fadein 0.5s
animation: fadein 0.5s

.word-break-all
word-break: break-all
.word-break
word-break: break-word
.line-clamp-2
Expand Down Expand Up @@ -561,8 +563,6 @@ span[data-tooltip]
max-width: 44px
width: 44px
text-align: center !important
.word-break-all
word-break: break-all

.pulse
.title-text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,15 +328,17 @@ export default function CommunityEditorDetails({ communityId } = {}) {
return (
<>
<CommunityMembersEditor
description="The admins will be able to edit the space settings and moderate
proposals. You must add one address per line."
description="Admins can edit community settings and moderate proposals.
We recommend at least two admin for each community, but it is not a requirement.
Please add one address per line."
type="admin"
communityId={communityId}
/>
<CommunityMembersEditor
title="Authors"
addrType="Author"
description="Authors can post proposals regardless of their voting power."
description="Authors can create and publish proposals, selecting from voting strategies set by an Admin.
Admins are automatically added as Authors."
communityId={communityId}
/>
</>
Expand Down
Loading