dapperlabs / nfl-smart-contracts

11 stars 2 forks source link

Script fail if no data by id #12

Closed dougg0k closed 2 years ago

dougg0k commented 2 years ago

Hi, I have been trying calling these functions, while data are returned by the borrowMomentNFT

These do not work, they actually fail the script.

let setData = AllDay.getSetData(id: id)
let seriesData = AllDay.getSeriesData(id: id)
let playData = AllDay.getPlayData(id: id)
let editionData = AllDay.getEditionData(id: id)

Could you guys change so that it returns a nil/null instead of panicking the script? Otherwise the other data that would be available, are not, just because there is no data in those calls.

error: pre-condition failed: Cannot borrow set, no such id
             --> e4cf4bdc1751c65d.AllDay:283:26
dougg0k commented 2 years ago

I actually got it working by doing it this way.

let nft = col!.borrowMomentNFT(id: id)

let editionData = AllDay.getEditionData(id: nft!.editionID)
let setData = AllDay.getSetData(id: editionData!.setID)
let seriesData = AllDay.getSeriesData(id: editionData!.seriesID)
let playData = AllDay.getPlayData(id: editionData!.playID)