Skip to content

Commit

Permalink
Storefront creation
Browse files Browse the repository at this point in the history
  • Loading branch information
lealobanov committed Dec 10, 2024
1 parent d289e4f commit 66875ed
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions cadence/transactions/create_nft_listing.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,25 @@ transaction {
let tokenReceiver: Capability<&{FungibleToken.Receiver}>

prepare(signer: auth(Storage, Capabilities) &Account) {
// Check if a storefront exists
if signer.capabilities.get<auth(NFTStorefront.CreateListing) &NFTStorefront.Storefront>(
NFTStorefront.StorefrontPublicPath
) == nil {
// Create and save a new storefront resource
signer.storage.save(
<-NFTStorefront.createStorefront(),
to: NFTStorefront.StorefrontStoragePath
)

// Issue and publish the storefront capability
let storefrontCapability = signer.capabilities.storage.issue<auth(NFTStorefront.CreateListing) &NFTStorefront.Storefront>(
NFTStorefront.StorefrontStoragePath
)
signer.capabilities.publish(storefrontCapability, at: NFTStorefront.StorefrontPublicPath)

log("Storefront created and capability published.")
}

// Retrieve the storefront capability with the correct entitlement
let storefrontCap = signer.capabilities.get<auth(NFTStorefront.CreateListing) &NFTStorefront.Storefront>(
NFTStorefront.StorefrontPublicPath
Expand Down

0 comments on commit 66875ed

Please sign in to comment.