-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* udpate to use dependency manager * add previewnet config as a workaround for onflow/flowkit#63 * update dependencies to point previewnet * run flow deps install to update flow.json * update cadence source code * update flow.json * update readme * update cadence scripts and readme
- Loading branch information
1 parent
624ffd7
commit ef9437c
Showing
10 changed files
with
425 additions
and
388 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Cache directory used by Cadence dependency manager | ||
imports |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
/// Script to get NFT IDs in an account's collection | ||
import "NonFungibleToken" | ||
import "ExampleNFT" | ||
|
||
/// Script to get NFT IDs in an account's collection | ||
/// | ||
pub fun main(address: Address): [UInt64] { | ||
access(all) fun main(address: Address, collectionPublicPath: PublicPath): [UInt64] { | ||
let account = getAccount(address) | ||
|
||
let collectionRef = account | ||
.getCapability(ExampleNFT.CollectionPublicPath) | ||
.borrow<&{NonFungibleToken.CollectionPublic}>() | ||
?? panic("Could not borrow capability from public collection at specified path") | ||
let collectionRef = account.capabilities.borrow<&{NonFungibleToken.Collection}>( | ||
collectionPublicPath | ||
) ?? panic("Could not borrow capability from collection at specified path") | ||
|
||
return collectionRef.getIDs() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,31 @@ | ||
import "NonFungibleToken" | ||
import "MetadataViews" | ||
import "ExampleNFT" | ||
|
||
/// This transaction is what an account would run | ||
/// to set itself up to receive NFTs | ||
import "NonFungibleToken" | ||
import "ExampleNFT" | ||
import "MetadataViews" | ||
|
||
transaction { | ||
|
||
prepare(signer: AuthAccount) { | ||
prepare(signer: auth(BorrowValue, IssueStorageCapabilityController, PublishCapability, SaveValue, UnpublishCapability) &Account) { | ||
|
||
let collectionData = ExampleNFT.resolveContractView(resourceType: nil, viewType: Type<MetadataViews.NFTCollectionData>()) as! MetadataViews.NFTCollectionData? | ||
?? panic("ViewResolver does not resolve NFTCollectionData view") | ||
|
||
// Return early if the account already has a collection | ||
if signer.borrow<&ExampleNFT.Collection>(from: ExampleNFT.CollectionStoragePath) != nil { | ||
if signer.storage.borrow<&ExampleNFT.Collection>(from: collectionData.storagePath) != nil { | ||
return | ||
} | ||
|
||
// Create a new empty collection | ||
let collection <- ExampleNFT.createEmptyCollection() | ||
let collection <- ExampleNFT.createEmptyCollection(nftType: Type<@ExampleNFT.NFT>()) | ||
|
||
// save it to the account | ||
signer.save(<-collection, to: ExampleNFT.CollectionStoragePath) | ||
signer.storage.save(<-collection, to: collectionData.storagePath) | ||
|
||
// create a public capability for the collection | ||
signer.link<&{NonFungibleToken.CollectionPublic, ExampleNFT.ExampleNFTCollectionPublic, MetadataViews.ResolverCollection}>( | ||
ExampleNFT.CollectionPublicPath, | ||
target: ExampleNFT.CollectionStoragePath | ||
) | ||
signer.capabilities.unpublish(collectionData.publicPath) | ||
let collectionCap = signer.capabilities.storage.issue<&ExampleNFT.Collection>(collectionData.storagePath) | ||
signer.capabilities.publish(collectionCap, at: collectionData.publicPath) | ||
} | ||
} |
Oops, something went wrong.