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
27 changes: 27 additions & 0 deletions backend/main/cadence/scripts/custom/get_nba_topshot_kings.cdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import TopShot from "TOPSHOT_ADDRESS"
import MetadataViews from "METADATA_VIEWS_ADDRESS"

pub fun main(address: Address): [UInt64] {

let account = getAccount(address)

let collectionRef = account.getCapability(/public/MomentCollection)
.borrow<&{TopShot.MomentCollectionPublic}>()!

let ids = collectionRef.getIDs()

let nftIds: [UInt64] = []

for id in ids {
let nft = collectionRef.borrowMoment(id: id)!
let view = nft.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
let metadata = view as! TopShot.TopShotMomentMetadataView

if metadata.teamAtMoment == "Sacramento Kings" {
nftIds.append(id)
}
}

return nftIds
}

Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ pub fun main(address: Address): [UInt64] {

return nftIds
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import TopShot from "TOPSHOT_ADDRESS"
import MetadataViews from "METADATA_VIEWS_ADDRESS"

pub fun main(address: Address): [UInt64] {

let account = getAccount(address)

let collectionRef = account.getCapability(/public/MomentCollection)
.borrow<&{TopShot.MomentCollectionPublic}>()!

let ids = collectionRef.getIDs()

let nftIds: [UInt64] = []

for id in ids {
let nft = collectionRef.borrowMoment(id: id)!
let view = nft.resolveView(Type<TopShot.TopShotMomentMetadataView>())!
let metadata = view as! TopShot.TopShotMomentMetadataView

if metadata.teamAtMoment == "Portland Trailblazers" {
nftIds.append(id)
}
}

return nftIds
}

16 changes: 14 additions & 2 deletions backend/main/cadence/scripts/custom/scripts.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,19 @@
{
"key": "nba-top-shot-pistons",
"name": "NBA TopShot - Detroit Pistons",
"description": "Strategy based on NBA TopShot teamAtMoment == Detroit Pistons",
"src": "get_nba_topshot.cdc"
"description": "NBA TopShot moments with teamAtMoment == Detroit Pistons",
"src": "get_nba_topshot_pistons.cdc"
},
{
"key": "nba-top-shot-kings",
"name": "NBA TopShot - Sacramento Kings",
"description": "NBA TopShot moments with teamAtMoment == Sacramento Kings",
"src": "get_nba_topshot_kings.cdc"
},
{
"key": "nba-top-shot-trailblazers",
"name": "NBA TopShot - Portland Trailblazers",
"description": "NBA TopShot moments with teamAtMoment == Portland Trailblazers",
"src": "get_nba_topshot_trailblazers.cdc"
}
]
2 changes: 1 addition & 1 deletion backend/main/models/community.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ func GetCommunitiesForHomePage(db *s.Database, params shared.PageParams) ([]*Com
}

func (c *Community) CreateCommunity(db *s.Database) error {

err := db.Conn.QueryRow(db.Context,
`
INSERT INTO communities(
Expand Down Expand Up @@ -329,7 +330,6 @@ func SearchForCommunity(db *s.Database, query string) ([]Community, error) {
communities = append(communities, c)
}

fmt.Printf("communitites : %v", communities)
return communities, nil
}

Expand Down
4 changes: 2 additions & 2 deletions backend/main/models/vote.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ type Vote struct {
Message string `json:"message"`
Voucher *shared.Voucher `json:"voucher,omitempty"`
IsCancelled bool `json:"isCancelled"`
IsEarly bool `json:"isEarly"`
IsWinning bool `json:"isWinning"`
IsEarly bool `json:"isEarly"`
IsWinning bool `json:"isWinning"`
}

type VoteWithBalance struct {
Expand Down
2 changes: 1 addition & 1 deletion backend/main/server/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (a *App) Initialize() {

// when running "make proposals" sets db to dev not test
arg := flag.String("db", "", "database type")
flag.Bool("ipfs-override", false, "overrides ipfs call")
flag.Bool("ipfs-override", true, "overrides ipfs call")
flag.Int("port", 5001, "port")
flag.Int("amount", 4, "Amount of proposals to create")

Expand Down
15 changes: 9 additions & 6 deletions backend/main/server/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -394,14 +394,17 @@ func (h *Helpers) validateVote(p models.Proposal, v models.Vote) error {
return err
}

voteMessageToValidate := fmt.Sprintf("%s:%s:%s",
voucher.Arguments[0]["value"],
voucher.Arguments[1]["value"],
voucher.Arguments[2]["value"],
)
message := voucher.Arguments[0]["value"]

messageBytes, err := hex.DecodeString(message)
if err != nil {
log.Error().Err(err)
return err
}

// validate proper message format
//<proposalId>:<choice>:<timestamp>
if err := models.ValidateVoteMessage(voteMessageToValidate, p); err != nil {
if err := models.ValidateVoteMessage(string(messageBytes), p); err != nil {
log.Error().Err(err)
return err
}
Expand Down
3 changes: 2 additions & 1 deletion backend/main/strategies/custom_script.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ func (cs *CustomScript) queryNFTs(
balance *models.Balance,
) error {
scriptName := cs.FlowAdapter.CustomScriptsMap[*strategy.Contract.Script].Src
scriptPath := fmt.Sprintf("./main/cadence/scripts/custom/%s", scriptName)
scriptPath := fmt.Sprintf("./main/cadence/scripts/custom/%s", scriptName)

nftIds, err := cs.FlowAdapter.GetNFTIds(
balance.Addr,
&strategy.Contract,
Expand Down
Loading