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

Cannot borrow as a subtype if the capability was issued with multiple interfaces #3537

Closed
SupunS opened this issue Aug 16, 2024 · 4 comments
Closed

Comments

@SupunS
Copy link
Member

SupunS commented Aug 16, 2024

Current Behavior

More details on #3533 (comment)

resource interface I1: I2 {}

resource interface I2 {}

resource interface I3 {}

 resource R: I1, I2, I3 {}

// Case-1: Issue as `{I2}` only
// Below borrowing will pass
var a = self.account.capabilities.storage.issue<&{I2}>(/storage/r)
self.account.capabilities.publish(a, at: /public/a)

// Case-2: Issue as `{I2, I3}`.
// Below borrowing will fail
var a = self.account.capabilities.storage.issue<&{I2, I3}>(/storage/r)
self.account.capabilities.publish(a, at: /public/a)

// Borrow as `{I1}`
self.account.capabilities.borrow<&{I1}>(/public/a)!

Expected Behavior

Above should work.

Steps To Reproduce

See above

Environment

- Cadence version: latest
- Network: Testnet
@SupunS
Copy link
Member Author

SupunS commented Aug 20, 2024

The exact hierarchy of interface in the use-case of https://discord.com/channels/613813861610684416/1273709822218473513 are:

                    (borrowed)     (issued)                       (issued)  
                   NFT.Receiver  ResolverCollection    aiSportsMinterCollectionPublic   
                        \              |                 /
 (issued)                \             |                /
NFT.CollectionPublic      \            |               /
                     \     \           |              /           
                       \    \          |             /
                          NFT.Collection            /
                                      \            /
                                       \          /
                                        Collection

So this is also a sibling issue, and is same as #3533

@SupunS SupunS removed the Bug Something isn't working label Aug 20, 2024
@bluesign
Copy link
Contributor

bluesign commented Aug 21, 2024

ah this makes sense, I assumed, we made NFT.CollectionPublic: NFT.Receiver but it is not the case here. Maybe it is good idea to add that also to NFT standard.

@turbolent
Copy link
Member

@SupunS So can we close this as a duplicate of #3533?

@SupunS
Copy link
Member Author

SupunS commented Aug 22, 2024

Closing since this is same as #3533

@SupunS SupunS closed this as completed Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants