Skip to content

Commit

Permalink
Merge branch 'sainati/remove-pub-priv-docs' of github.com:onflow/docs…
Browse files Browse the repository at this point in the history
… into sainati/entitlement-docs
  • Loading branch information
dsainati1 committed Jul 14, 2023
2 parents 12e46f9 + 81e4a0e commit 21d8c0c
Show file tree
Hide file tree
Showing 24 changed files with 825 additions and 343 deletions.
185 changes: 124 additions & 61 deletions docs/cadence/language/accounts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,12 @@ access(all) struct PublicAccount {
/// The keys assigned to the account.
access(all) let keys: PublicAccount.Keys
/// The capabilities of the account.
pub let capabilities: PublicAccount.Capabilities
/// All public paths of this account.
access(all) let publicPaths: [PublicPath]
/// Returns the capability at the given public path.
access(all) fun getCapability<T: &Any>(_ path: PublicPath): Capability<T>
/// Returns the target path of the capability at the given public or private path,
/// or nil if there exists no capability at the given path.
access(all) fun getLinkTarget(_ path: CapabilityPath): Path?
/// Iterate over all the public paths of an account.
/// passing each path and type in turn to the provided callback function.
///
Expand Down Expand Up @@ -91,6 +87,17 @@ access(all) struct PublicAccount {
/// The total number of unrevoked keys in this account.
access(all) let count: UInt64
}
pub struct Capabilities {
/// get returns the storage capability at the given path, if one was stored there.
pub fun get<T: &Any>(_ path: PublicPath): Capability<T>?
/// borrow gets the storage capability at the given path, and borrows the capability if it exists.
///
/// Returns nil if the capability does not exist or cannot be borrowed using the given type.
/// The function is equivalent to `get(path)?.borrow()`.
pub fun borrow<T: &Any>(_ path: PublicPath): T?
}
}
```

Expand Down Expand Up @@ -140,6 +147,9 @@ access(all) struct AuthAccount {
/// The inbox allows bootstrapping (sending and receiving) capabilities.
access(all) let inbox: AuthAccount.Inbox
/// The capabilities of the account.
pub let capabilities: AuthAccount.Capabilities
/// All public paths of this account.
access(all) let publicPaths: [PublicPath]
Expand All @@ -149,12 +159,6 @@ access(all) struct AuthAccount {
/// All storage paths of this account.
access(all) let storagePaths: [StoragePath]
// Account storage API (see the section below for documentation)
// Provides a API for bootstrapping (sending and receiving) capabilities
let inbox: AuthAccount.Inbox
/// Saves the given object into the account's storage at the given path.
///
/// Resources are moved into storage, and structures are copied.
Expand Down Expand Up @@ -215,50 +219,15 @@ access(all) struct AuthAccount {
/// The path must be a storage path, i.e., only the domain `storage` is allowed
access(all) fun borrow<T: &Any>(from: StoragePath): T?
/// Returns true if the object in account storage under the given path satisfies the given type,
/// Returns true if the object in account storage under the given path satisfies the given type,
/// i.e. could be borrowed using the given type.
///
/// The given type must not necessarily be exactly the same as the type of the borrowed object.
///
/// The path must be a storage path, i.e., only the domain `storage` is allowed.
access(all) fun check<T: Any>(from: StoragePath): Bool
/// Creates a capability at the given public or private path,
/// which targets the given public, private, or storage path.
///
/// The target path leads to the object that will provide the functionality defined by this capability.
///
/// The given type defines how the capability can be borrowed, i.e., how the stored value can be accessed.
///
/// Returns nil if a link for the given capability path already exists, or the newly created capability if not.
///
/// It is not necessary for the target path to lead to a valid object; the target path could be empty,
/// or could lead to an object which does not provide the necessary type interface:
/// The link function does **not** check if the target path is valid/exists at the time the capability is created
/// and does **not** check if the target value conforms to the given type.
///
/// The link is latent.
///
/// The target value might be stored after the link is created,
/// and the target value might be moved out after the link has been created.
access(all) fun link<T: &Any>(_ newCapabilityPath: CapabilityPath, target: Path): Capability<T>?
/// Creates a capability at the given public or private path which targets this account.
///
/// Returns nil if a link for the given capability path already exists, or the newly created capability if not.
access(all) fun linkAccount(_ newCapabilityPath: PrivatePath): Capability<&AuthAccount>?
/// Returns the capability at the given private or public path.
access(all) fun getCapability<T: &Any>(_ path: CapabilityPath): Capability<T>
/// Returns the target path of the capability at the given public or private path,
/// or nil if there exists no capability at the given path.
access(all) fun getLinkTarget(_ path: CapabilityPath): Path?
/// Removes the capability at the given public or private path.
access(all) fun unlink(_ path: CapabilityPath)
/// Iterate over all the public paths of an account.
/// Iterate over all the public paths of an account,
/// passing each path and type in turn to the provided callback function.
///
/// The callback function takes two arguments:
Expand All @@ -267,11 +236,16 @@ access(all) struct AuthAccount {
///
/// Iteration is stopped early if the callback function returns `false`.
///
/// The order of iteration, as well as the behavior of adding or removing objects from storage during iteration,
/// is undefined.
access(all) fun forEachPublic(_ function: ((PublicPath, Type): Bool))
/// The order of iteration is undefined.
///
/// If an object is stored under a new public path,
/// or an existing object is removed from a public path,
/// then the callback must stop iteration by returning false.
/// Otherwise, iteration aborts.
///
access(all) fun forEachPublic(_ function: fun(PublicPath, Type): Bool)
/// Iterate over all the private paths of an account.
/// Iterate over all the private paths of an account,
/// passing each path and type in turn to the provided callback function.
///
/// The callback function takes two arguments:
Expand All @@ -280,11 +254,15 @@ access(all) struct AuthAccount {
///
/// Iteration is stopped early if the callback function returns `false`.
///
/// The order of iteration, as well as the behavior of adding or removing objects from storage during iteration,
/// is undefined.
access(all) fun forEachPrivate(_ function: ((PrivatePath, Type): Bool))
/// The order of iteration is undefined.
///
/// If an object is stored under a new private path,
/// or an existing object is removed from a private path,
/// then the callback must stop iteration by returning false.
/// Otherwise, iteration aborts.
access(all) fun forEachPrivate(_ function: fun(PrivatePath, Type): Bool)
/// Iterate over all the stored paths of an account.
/// Iterate over all the stored paths of an account,
/// passing each path and type in turn to the provided callback function.
///
/// The callback function takes two arguments:
Expand All @@ -293,9 +271,11 @@ access(all) struct AuthAccount {
///
/// Iteration is stopped early if the callback function returns `false`.
///
/// The order of iteration, as well as the behavior of adding or removing objects from storage during iteration,
/// is undefined.
access(all) fun forEachStored(_ function: ((StoragePath, Type): Bool))
/// If an object is stored under a new storage path,
/// or an existing object is removed from a storage path,
/// then the callback must stop iteration by returning false.
/// Otherwise, iteration aborts.
access(all) fun forEachStored(_ function: fun(StoragePath, Type): Bool)
access(all) struct Contracts {
Expand Down Expand Up @@ -383,6 +363,7 @@ access(all) struct AuthAccount {
/// passing each key in turn to the provided function.
///
/// Iteration is stopped early if the function returns `false`.
///
/// The order of iteration is undefined.
access(all) fun forEach(_ function: fun(AccountKey): Bool)
Expand Down Expand Up @@ -411,6 +392,88 @@ access(all) struct AuthAccount {
/// Errors if the Capability under that name does not match the provided type.
access(all) fun claim<T: &Any>(_ name: String, provider: Address): Capability<T>?
}
pub struct Capabilities {
/// The storage capabilities of the account.
pub let storage: AuthAccount.StorageCapabilities
/// The account capabilities of the account.
pub let account: AuthAccount.AccountCapabilities
/// Returns the capability at the given public path.
/// Returns nil if the capability does not exist,
/// or if the given type is not a supertype of the capability's borrow type.
pub fun get<T: &Any>(_ path: PublicPath): Capability<T>?
/// Borrows the capability at the given public path.
/// Returns nil if the capability does not exist, or cannot be borrowed using the given type.
/// The function is equivalent to `get(path)?.borrow()`.
pub fun borrow<T: &Any>(_ path: PublicPath): T?
/// Publish the capability at the given public path.
///
/// If there is already a capability published under the given path, the program aborts.
///
/// The path must be a public path, i.e., only the domain `public` is allowed.
pub fun publish(_ capability: Capability, at: PublicPath)
/// Unpublish the capability published at the given path.
///
/// Returns the capability if one was published at the path.
/// Returns nil if no capability was published at the path.
pub fun unpublish(_ path: PublicPath): Capability?
}
pub struct StorageCapabilities {
/// Get the storage capability controller for the capability with the specified ID.
///
/// Returns nil if the ID does not reference an existing storage capability.
pub fun getController(byCapabilityID: UInt64): &StorageCapabilityController?
/// Get all storage capability controllers for capabilities that target this storage path
pub fun getControllers(forPath: StoragePath): [&StorageCapabilityController]
/// Iterate over all storage capability controllers for capabilities that target this storage path,
/// passing a reference to each controller to the provided callback function.
///
/// Iteration is stopped early if the callback function returns `false`.
///
/// If a new storage capability controller is issued for the path,
/// an existing storage capability controller for the path is deleted,
/// or a storage capability controller is retargeted from or to the path,
/// then the callback must stop iteration by returning false.
/// Otherwise, iteration aborts.
pub fun forEachController(forPath: StoragePath, _ function: fun(&StorageCapabilityController): Bool)
/// Issue/create a new storage capability.
pub fun issue<T: &Any>(_ path: StoragePath): Capability<T>
}
pub struct AccountCapabilities {
/// Get capability controller for capability with the specified ID.
///
/// Returns nil if the ID does not reference an existing account capability.
pub fun getController(byCapabilityID: UInt64): &AccountCapabilityController?
/// Get all capability controllers for all account capabilities.
pub fun getControllers(): [&AccountCapabilityController]
/// Iterate over all account capability controllers for all account capabilities,
/// passing a reference to each controller to the provided callback function.
///
/// Iteration is stopped early if the callback function returns `false`.
///
/// If a new account capability controller is issued for the account,
/// or an existing account capability controller for the account is deleted,
/// then the callback must stop iteration by returning false.
/// Otherwise, iteration aborts.
pub fun forEachController(_ function: (&AccountCapabilityController): Bool)
/// Issue/create a new account capability.
pub fun issue<T: &AuthAccount{}>(): Capability<T>
}
}
```

Expand Down
4 changes: 2 additions & 2 deletions docs/concepts/core-contracts/10-nft-storefront.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ As recommended above, the first step is to create and store the [Storefront reso

The next step is to create a listing under the newly created storefront resource. If the user (repetitive) already holds the storefront resource, then use the existing resource. The seller can come with multiple requirements for listing their NFTs, and We try our best to cover most of them below.

### **Scenario 1:** Selling NFTs corresponds to more than one cryptocurrency, i.e. FLOW, FUSD etc.
### **Scenario 1:** Selling NFTs corresponds to more than one cryptocurrency, i.e. FLOW, USDC etc.

The `NFTStorefrontV2` contract doesn’t support selling an NFT for multiple different currencies with a single listing. However, this can be achieved by creating multiple listings for the same NFT for each different currency.

**Example -** Alice wants to sell a kitty and is open to receiving FLOW and FUSD
**Example -** Alice wants to sell a kitty and is open to receiving FLOW and USDC

![scenario_1](https://user-images.githubusercontent.com/14581509/190966672-e1793fa3-112c-4273-b2a3-e81b8c94fd70.png)

Expand Down
2 changes: 1 addition & 1 deletion docs/concepts/flow-token/concepts.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The Service Account has administrator access to the FLOW token smart contract, s

### Network Management

The Service Account administrates other smart contracts that manage various aspects of the Flow network, such as epochs and (in the future) validator staking auctions.
The Service Account administers other smart contracts that manage various aspects of the Flow network, such as epochs and (in the future) validator staking auctions.

### Governance

Expand Down
5 changes: 3 additions & 2 deletions docs/concepts/hybrid-custody/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ perspective of a wallet or NFT marketplace.
<Callout type="warning">

Note that the documentation on Hybrid Custody covers the current state and will likely differ from the final
implementation. Builders should be aware that breaking changes may follow before reaching a final consensus on
implementation. Interested in shaping the conversation? [Join in!](https://github.com/onflow/flips/pull/72)
implementation. **Testnet is currently out of sync with docs and will be updated shortly.** Builders should be aware
that breaking changes may follow before reaching a final community consensus on implementation. Interested in
contributing? [Check out the source!](https://github.com/onflow/hybrid-custody).

</Callout>

Expand Down
Loading

0 comments on commit 21d8c0c

Please sign in to comment.