Skip to content

Commit d70cf3f

Browse files
committed
fix camel case and other PR feedback
1 parent ae3830b commit d70cf3f

File tree

5 files changed

+28
-29
lines changed

5 files changed

+28
-29
lines changed

tests/NFTStorefrontV2_test.cdc

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,8 +222,7 @@ fun testBuyItem() {
222222
listingID, // listing resource id
223223
seller.address, // storefront address
224224
seller.address, // commision recipient
225-
nftTypeIdentifier, // nft type
226-
ftTypeIdentifier // ft type
225+
nftTypeIdentifier // nft type
227226
],
228227
)
229228
let txResult = Test.executeTransaction(tx)
@@ -563,8 +562,7 @@ fun testSellMaliciousListing() {
563562
listingID, // listing resource id
564563
exampleNFTAccount.address, // storefront address
565564
exampleNFTAccount.address, // commision recipient
566-
nftTypeIdentifier, // nft type
567-
ftTypeIdentifier // ft type
565+
nftTypeIdentifier // nft type
568566
],
569567
)
570568
txResult = Test.executeTransaction(tx)

transactions/buy_item.cdc

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,30 +15,23 @@ import "MetadataViews"
1515
transaction(listingResourceID: UInt64,
1616
storefrontAddress: Address,
1717
commissionRecipient: Address?,
18-
nftTypeIdentifier: String,
19-
ftTypeIdentifier: String) {
18+
nftTypeIdentifier: String) {
2019

2120
let paymentVault: @{FungibleToken.Vault}
22-
let NFTReceiver: &{NonFungibleToken.Receiver}
21+
let nftReceiver: &{NonFungibleToken.Receiver}
2322
let storefront: &{NFTStorefrontV2.StorefrontPublic}
2423
let listing: &{NFTStorefrontV2.ListingPublic}
2524
var commissionRecipientCap: Capability<&{FungibleToken.Receiver}>?
2625

2726
prepare(acct: auth(BorrowValue) &Account) {
28-
27+
2928
// Get the metadata views for the NFT and FT types that are used in this transaction
3029
let collectionData = MetadataViews.resolveContractViewFromTypeIdentifier(
3130
resourceTypeIdentifier: nftTypeIdentifier,
3231
viewType: Type<MetadataViews.NFTCollectionData>()
3332
) as? MetadataViews.NFTCollectionData
3433
?? panic("Could not construct valid NFT type and view from identifier \(nftTypeIdentifier)")
3534

36-
let vaultData = MetadataViews.resolveContractViewFromTypeIdentifier(
37-
resourceTypeIdentifier: ftTypeIdentifier,
38-
viewType: Type<FungibleTokenMetadataViews.FTVaultData>()
39-
) as? FungibleTokenMetadataViews.FTVaultData
40-
?? panic("Could not construct valid FT type and view from identifier \(ftTypeIdentifier)")
41-
4235
self.commissionRecipientCap = nil
4336
// Access the storefront public resource of the seller to purchase the listing.
4437
self.storefront = getAccount(storefrontAddress).capabilities.borrow<&{NFTStorefrontV2.StorefrontPublic}>(
@@ -50,13 +43,21 @@ transaction(listingResourceID: UInt64,
5043
?? panic("Could not get a listing with ID \(listingResourceID) from the storefront in account \(storefrontAddress)")
5144
let price = self.listing.getDetails().salePrice
5245

46+
let vaultType = self.listing.getDetails().salePaymentVaultType
47+
48+
let vaultData = MetadataViews.resolveContractViewFromTypeIdentifier(
49+
resourceTypeIdentifier: vaultType.identifier,
50+
viewType: Type<FungibleTokenMetadataViews.FTVaultData>()
51+
) as? FungibleTokenMetadataViews.FTVaultData
52+
?? panic("Could not construct valid FT type and view from identifier \(vaultType.identifier)")
53+
5354
// Access the vault of the buyer to pay the sale price of the listing.
5455
let mainVault = acct.storage.borrow<auth(FungibleToken.Withdraw) &{FungibleToken.Vault}>(from: vaultData.storagePath)
5556
?? panic("The signer does not store an Vault object at the path \(vaultData.storagePath)"
5657
.concat(". The signer must initialize their account with this vault first!"))
5758
self.paymentVault <- mainVault.withdraw(amount: price)
5859

59-
self.NFTReceiver = acct.capabilities.borrow<&{NonFungibleToken.Receiver}>(collectionData.publicPath)
60+
self.nftReceiver = acct.capabilities.borrow<&{NonFungibleToken.Receiver}>(collectionData.publicPath)
6061
?? panic("Cannot borrow an NFT collection receiver from the signer's account at path \(collectionData.publicPath).")
6162

6263
// Fetch the commission amt.
@@ -83,6 +84,6 @@ transaction(listingResourceID: UInt64,
8384
commissionRecipient: self.commissionRecipientCap
8485
)
8586
// Deposit the NFT in the buyer's collection.
86-
self.NFTReceiver.deposit(token: <-item)
87+
self.nftReceiver.deposit(token: <-item)
8788
}
8889
}

transactions/sell_item.cdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ transaction(
2828
) {
2929

3030
let tokenReceiver: Capability<&{FungibleToken.Receiver}>
31-
let NFTProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
31+
let nftProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
3232
let storefront: auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront
3333
var saleCuts: [NFTStorefrontV2.SaleCut]
3434
var marketplacesCapability: [Capability<&{FungibleToken.Receiver}>]
@@ -70,7 +70,7 @@ transaction(
7070

7171
// Receiver for the sale cut.
7272
self.tokenReceiver = acct.capabilities.get<&{FungibleToken.Receiver}>(vaultData.receiverPath)
73-
assert(self.tokenReceiver.borrow() != nil, message: "Missing or mis-typed Fungible Token receiver")
73+
assert(self.tokenReceiver.borrow() != nil, message: "Missing or mis-typed Fungible Token receiver for token \(ftTypeIdentifier) at path \(vaultData.receiverPath)")
7474

7575
var nftProviderCap: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? = nil
7676
// check if there is an existing capability/capability controller for the storage path
@@ -91,7 +91,7 @@ transaction(
9191
}
9292
assert(nftProviderCap?.check() ?? false, message: "Could not assign Provider Capability")
9393

94-
self.NFTProvider = nftProviderCap!
94+
self.nftProvider = nftProviderCap!
9595

9696
let collection = acct.capabilities.borrow<&{NonFungibleToken.Collection}>(
9797
collectionData.publicPath
@@ -144,7 +144,7 @@ transaction(
144144

145145
// Create listing
146146
self.storefront.createListing(
147-
nftProviderCapability: self.NFTProvider,
147+
nftProviderCapability: self.nftProvider,
148148
nftType: nftType,
149149
nftID: saleItemID,
150150
salePaymentVaultType: ftType,

transactions/sell_item_and_replace_current_listing.cdc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ transaction(
2828
) {
2929

3030
let tokenReceiver: Capability<&{FungibleToken.Receiver}>
31-
let NFTProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
31+
let nftProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
3232
let storefront: auth(NFTStorefrontV2.CreateListing, NFTStorefrontV2.RemoveListing) &NFTStorefrontV2.Storefront
3333
var saleCuts: [NFTStorefrontV2.SaleCut]
3434
var marketplacesCapability: [Capability<&{FungibleToken.Receiver}>]
@@ -95,7 +95,7 @@ transaction(
9595
}
9696
assert(nftProviderCap?.check() ?? false, message: "Could not assign Provider Capability")
9797

98-
self.NFTProvider = nftProviderCap!
98+
self.nftProvider = nftProviderCap!
9999

100100
let collection = acct.capabilities.borrow<&{NonFungibleToken.Collection}>(
101101
collectionData.publicPath
@@ -128,7 +128,7 @@ transaction(
128128
amount: effectiveSaleItemPrice - totalRoyaltyCut
129129
)
130130
)
131-
assert(self.NFTProvider.borrow() != nil, message: "Missing or mis-typed NFT Collection provider")
131+
assert(self.nftProvider.borrow() != nil, message: "Missing or mis-typed NFT Collection provider")
132132

133133
self.storefront = acct.storage.borrow<auth(NFTStorefrontV2.CreateListing, NFTStorefrontV2.RemoveListing) &NFTStorefrontV2.Storefront>(
134134
from: NFTStorefrontV2.StorefrontStoragePath
@@ -159,7 +159,7 @@ transaction(
159159
}
160160
// Create listing
161161
self.storefront.createListing(
162-
nftProviderCapability: self.NFTProvider,
162+
nftProviderCapability: self.nftProvider,
163163
nftType: nftType,
164164
nftID: saleItemID,
165165
salePaymentVaultType: ftType,

transactions/sell_item_with_marketplace_cut.cdc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ transaction(
2727
ftTypeIdentifier: String
2828
) {
2929
let ftReceiver: Capability<&{FungibleToken.Receiver}>
30-
let NFTProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
30+
let nftProvider: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>
3131
let storefront: auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront
3232
var saleCuts: [NFTStorefrontV2.SaleCut]
3333
var marketplacesCapability: [Capability<&{FungibleToken.Receiver}>]
@@ -71,7 +71,7 @@ transaction(
7171
self.ftReceiver = acct.capabilities.get<&{FungibleToken.Receiver}>(vaultData.receiverPath)
7272
assert(
7373
self.ftReceiver.borrow() != nil,
74-
message: "Missing or mis-typed Fungible Token receiver"
74+
message: "Missing or mis-typed Fungible Token receiver for token \(ftTypeIdentifier) at path \(vaultData.receiverPath)"
7575
)
7676

7777
var nftProviderCap: Capability<auth(NonFungibleToken.Withdraw) &{NonFungibleToken.Collection}>? = nil
@@ -93,7 +93,7 @@ transaction(
9393
}
9494
assert(nftProviderCap?.check() ?? false, message: "Could not assign Provider Capability")
9595

96-
self.NFTProvider = nftProviderCap!
96+
self.nftProvider = nftProviderCap!
9797

9898
let collection = acct.capabilities.borrow<&{NonFungibleToken.Collection}>(
9999
collectionData.publicPath
@@ -124,7 +124,7 @@ transaction(
124124
amount: saleItemPrice - totalRoyaltyCut - saleItemPrice * marketPlaceSaleCutPercentage
125125
)
126126
)
127-
assert(self.NFTProvider.borrow() != nil, message: "Missing or mis-typed NFT Collection provider")
127+
assert(self.nftProvider.borrow() != nil, message: "Missing or mis-typed NFT Collection provider")
128128

129129
self.storefront = acct.storage.borrow<auth(NFTStorefrontV2.CreateListing) &NFTStorefrontV2.Storefront>(
130130
from: NFTStorefrontV2.StorefrontStoragePath
@@ -150,7 +150,7 @@ transaction(
150150

151151
// Create listing
152152
self.storefront.createListing(
153-
nftProviderCapability: self.NFTProvider,
153+
nftProviderCapability: self.nftProvider,
154154
nftType: nftType,
155155
nftID: saleItemID,
156156
salePaymentVaultType: ftType,

0 commit comments

Comments
 (0)