From 4b37734acce6d3060e53172fce2f5856df664e30 Mon Sep 17 00:00:00 2001 From: Fabio Kenji Date: Wed, 28 Aug 2024 17:16:00 -0400 Subject: [PATCH] save cap on storage --- transactions/marketV3/create_start_sale.cdc | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/transactions/marketV3/create_start_sale.cdc b/transactions/marketV3/create_start_sale.cdc index e4419a0..9acef1c 100644 --- a/transactions/marketV3/create_start_sale.cdc +++ b/transactions/marketV3/create_start_sale.cdc @@ -13,14 +13,19 @@ transaction(tokenReceiverPath: PublicPath, beneficiaryAccount: Address, cutPerce let ownerCapability = acct.capabilities.get<&{FungibleToken.Receiver}>(tokenReceiverPath)! let beneficiaryCapability = getAccount(beneficiaryAccount).capabilities.get<&{FungibleToken.Receiver}>(tokenReceiverPath)! - let ownerCollection = acct.capabilities.storage.issue(/storage/MomentCollection) - - // get a capability for the v1 collection - var v1SaleCollection: Capability? = nil - if acct.storage.borrow<&Market.SaleCollection>(from: /storage/topshotSaleCollection) != nil { - v1SaleCollection = acct.capabilities.storage.issue(/storage/topshotSaleCollection) + let ownerCollection = acct.storage.copy>(/storage/MomentCollectionCap) + if ownerCollection == nil { + ownerCollection = acct.capabilities.storage.issue(/storage/MomentCollection) + acct.storage.save(ownerCollection, to: /storage/MomentCollectionCap) } + // get a capability for the v1 collection + var v1SaleCollection = acct.storage.copy>(/storage/topshotSaleCollectionCap) + if v1SaleCollection == nil { + v1SaleCollection = acct.capabilities.storage.issue(/storage/topshotSaleCollection) + acct.storage.save(v1SaleCollection, to: /storage/topshotSaleCollectionCap) + } + // create a new sale collection let topshotSaleCollection <- TopShotMarketV3.createSaleCollection(ownerCollection: ownerCollection, ownerCapability: ownerCapability,