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

Document Account.Capabilities.exists #29

Merged
merged 1 commit into from
Dec 5, 2023
Merged
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
17 changes: 17 additions & 0 deletions versioned_docs/version-1.0/language/accounts/capabilities.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ struct Capabilities {
access(all)
view fun borrow<T: &Any>(_ path: PublicPath): T?

/// Returns true if a capability exists at the given public path.
access(all)
view fun exists(_ path: PublicPath): Bool

/// Publish the capability at the given public path.
///
/// If there is already a capability published under the given path, the program aborts.
Expand All @@ -56,6 +60,19 @@ entitlement PublishCapability
entitlement UnpublishCapability
```

## Checking the existence of public capabilities

The function `capabilities.check` determines if a public capability
was [published](#publishing-capabilities) at the given path before.

```cadence
access(all)
view fun exists(_ path: PublicPath): Bool
```

If the account has a capability published under the given path,
the function returns true, otherwise false.

## Getting public capabilities

The function `capabilities.get` obtains a public capability
Expand Down