Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestion: Fix/authorized flovatar ref #20

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 4 additions & 6 deletions contracts/Flovatar.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -827,19 +827,17 @@ contract Flovatar: NonFungibleToken{
}
}

/*
// borrowFlovatarPrivate returns a borrowed reference to a Flovatar using the Private interface
// so that the caller can read data and call methods from it, like setting the optional components.
access(all)
fun borrowFlovatarPrivate(id: UInt64): &{Flovatar.Private}?{
access(Flovatar.PrivateEnt)
fun borrowFlovatarPrivate(id: UInt64): auth(Flovatar.PrivateEnt) &Flovatar.NFT?{
if self.ownedNFTs[id] != nil{
let ref = (&self.ownedNFTs[id] as &{NonFungibleToken.NFT}?)!
return ref as! &Flovatar.NFT
let ref = (&self.ownedNFTs[id] as auth(Flovatar.PrivateEnt) &{NonFungibleToken.NFT}?)!
return ref as! auth(Flovatar.PrivateEnt) &Flovatar.NFT
} else{
return nil
}
}
*/


access(all)
Expand Down
6 changes: 3 additions & 3 deletions scripts-transactions/flovatar-set-name.tx.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ transaction(
name: String
) {

let flovatarCollection: &Flovatar.Collection
let flovatarCollection: auth(Flovatar.PrivateEnt) &Flovatar.Collection
let vaultCap: Capability<&FlovatarDustToken.Vault>
let temporaryVault: @{FungibleToken.Vault}

prepare(account: auth(Storage) &Account) {
self.flovatarCollection = account.storage.borrow<&Flovatar.Collection>(from: Flovatar.CollectionStoragePath)!
self.flovatarCollection = account.storage.borrow<auth(Flovatar.PrivateEnt) &Flovatar.Collection>(from: Flovatar.CollectionStoragePath)!

self.vaultCap = account.capabilities.get<&FlovatarDustToken.Vault>(FlovatarDustToken.VaultReceiverPath)

Expand All @@ -26,7 +26,7 @@ transaction(

execute {

let flovatar = self.flovatarCollection.borrowFlovatar(id: flovatarId)! as! auth(Flovatar.PrivateEnt) &Flovatar.NFT
let flovatar = self.flovatarCollection.borrowFlovatarPrivate(id: flovatarId)!

flovatar.setName(name: name, vault: <- self.temporaryVault)
}
Expand Down