Skip to content

Commit e52d2ac

Browse files
Update use-beast-market.hook.ts
1 parent 5ac6575 commit e52d2ac

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

framework/hooks/use-beast-market.hook.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,11 +219,24 @@ export default function useBeastMarket() {
219219
transaction(`
220220
import FungibleToken from 0xFungibleToken
221221
import FUSD from 0xFUSD
222+
import NonFungibleToken from 0xNonFungibleToken
223+
import MetadataViews from 0xMetadataViews
222224
import BasicBeasts from 0xBasicBeasts
223225
import BeastMarket from 0xBeastMarket
224226
225227
transaction(sellerAddress: Address, beastID: UInt64, purchaseAmount: UFix64) {
226228
prepare(acct: AuthAccount) {
229+
230+
//Link the Beast collection
231+
if acct.borrow<&BasicBeasts.Collection{BasicBeasts.BeastCollectionPublic}>(from: BasicBeasts.CollectionStoragePath) == nil {
232+
acct.save(<- BasicBeasts.createEmptyCollection(), to: BasicBeasts.CollectionStoragePath)
233+
acct.unlink(BasicBeasts.CollectionPublicPath)
234+
acct.link<&BasicBeasts.Collection{NonFungibleToken.Receiver,
235+
NonFungibleToken.CollectionPublic,
236+
BasicBeasts.BeastCollectionPublic,
237+
MetadataViews.ResolverCollection}>
238+
(BasicBeasts.CollectionPublicPath, target: BasicBeasts.CollectionStoragePath)
239+
}
227240
// borrow a reference to the signer's collection
228241
let collection = acct.borrow<&BasicBeasts.Collection>(from: BasicBeasts.CollectionStoragePath)
229242
?? panic("Could not borrow reference to the Beast Collection")

0 commit comments

Comments
 (0)