Skip to content

Commit

Permalink
Modify format for importing into Docusaurus
Browse files Browse the repository at this point in the history
  • Loading branch information
lsgunnlsgunn committed Nov 6, 2024
1 parent 427c434 commit a829dc1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 26 deletions.
9 changes: 4 additions & 5 deletions docs/builtins/Capabilities/compose-capability.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## compose-capability

Use `compose-capability` to compose and grant capabilities in a nested structure to control the scope of how the capabilities are applied.
By convention, capabilities are defined using all uppercase letters.
Expand All @@ -8,27 +7,27 @@ The function is only valid within the distinct `defcap` body of its outer capabi

For example, if you call `(with-capability (OUTER-CAP) OUTER-BODY)` and the `OUTER-CAP` declaration includes the `(compose-capability (INNER-CAP))` function, the `INNER-CAP` capability is granted in the scope of the `OUTER-BODY` logic.

### Basic syntax
## Basic syntax

To compose and grant a specified `CAPABILITY` within an outer capability body, use the following syntax:

```pact
(compose-capability CAPABILITY)
```

### Arguments
## Arguments

Use the following argument to specify the `CAPABILITY` for the `compose-capability` Pact function.

| Argument | Type | Description |
| --- | --- | --- |
| `CAPABILITY` | capability | Specifies the capability to include in the scope of an outer capability. |

### Return values
## Return values

The `compose-capability` function returns a boolean value to indicate success or failure in requesting the grant of the specified `CAPABILITY`.

### Examples
## Examples

The following example demonstrates how to use the `compose-capability` function within the body of the `TRANSFER` capability and include the DEBIT and CREDIT capabilities when the `with-capability` function is called:

Expand Down
9 changes: 4 additions & 5 deletions docs/builtins/Capabilities/emit-event.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
## emit-event

Use `emit-event` to emit a specified `CAPABILITY` as an event without evaluating the body of the capability.
This function fails if the specified `CAPABILITY` doesn't include the `@managed` or `@event` keyword in its declaration.

By convention, capabilities are defined using all uppercase letters.

### Basic syntax
## Basic syntax

To emit a `CAPABILITY` as an event without evaluating its body, use the following syntax:

```pact
(emit-event CAPABILITY)
```

### Arguments
## Arguments

Use the following argument to specify the `CAPABILITY` for the `emit-event` Pact function.

| Argument | Type | Description |
|------------|------|---------------------------------------------------|
| `CAPABILITY` | capability | Specifies the capability to emit as an event. |

### Return values
## Return values

The `emit-event` function returns a boolean value indicating success or failure of emitting the event.

### Examples
## Examples

The following example demonstrates how to use the `emit-event` function to emit an event for the `TRANSFER` capability with the parameters `"Bob"`, `"Alice"`, and `12.0`:

Expand Down
10 changes: 4 additions & 6 deletions docs/builtins/Capabilities/install-capability.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## install-capability

Use `install-capability` to specify and provision a managed capability.
Managed capabilities are defined in `defcap` declarations that include the `@managed` keyword. The `@managed` keyword designates a single parameter to be managed by a specified management function.
Expand All @@ -20,35 +19,34 @@ The management function for this capability would be:
(defun FOO-mgr:integer (managed:integer requested:integer) ...)
```


Any capability that has static unmanaged parameters will invoke the management function with the current managed value and that of the requested capability.
The function should perform whatever logic, presumably linear, to validate the request, and return the new managed value representing the `balance` of the request.

Note that signatures scoped to a managed capability cause the capability to be automatically provisioned in a manner similar to how capabilities are installed with this function.

By convention, capabilities are defined using all uppercase letters.

### Basic syntax
## Basic syntax

To specify and provision a managed capability, use the following syntax:

```pact
(install-capability CAPABILITY)
```

### Arguments
## Arguments

Use the following argument to specify the capability you want to install using the `install-capability` Pact function.

| Argument | Type | Description |
| --- | --- | --- |
| `CAPABILITY` | any | Specifies the capability to be installed. |

### Return value
## Return value

The `install-capability` function returns a boolean value indicating the success or failure of the installation, along with a string message providing additional information.

### Examples
## Examples

The following example demonstrates how to use the `install-capability` to install a capability named `coin.TRANSFER` with specified parameters:

Expand Down
9 changes: 4 additions & 5 deletions docs/builtins/Capabilities/require-capability.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,30 @@
## require-capability

Use `require-capability` to require a specific `CAPABILITY` to be granted before allowing the current body of code to be executed.
If the required capability isn't found in the environment, the code fails to execute.

By convention, capabilities are defined using all uppercase letters.

### Basic syntax
## Basic syntax

To test whether a specific `CAPABILITY` has been granted before executing a portion of code in a contract, use the following syntax:

```pact
(require-capability CAPABILITY)
```

### Arguments
## Arguments

Use the following argument to specify the `CAPABILITY` to be tested for using the `require-capability` Pact function.

| Argument | Type | Description |
| --- | --- | --- |
| `CAPABILITY` | | Specifies the capability that must be granted before executing a certain portion of code. |

### Return value
## Return value

The `require-capability` function returns a boolean value indicating whether the specified `CAPABILITY` exists in the environment.

### Examples
## Examples

The following example demonstrates how to use the `require-capability` function to check whether the capability to transfer funds from one source to another has been granted:

Expand Down
9 changes: 4 additions & 5 deletions docs/builtins/Capabilities/with-capability.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
## with-capability

Use `with-capability` to apply the access to a specific capability to execute a body of code.
This function ensures that an elevated privilege—defined as a capability using a `defcap` code block—is present during the execution of the provided body of code.
Expand All @@ -10,15 +9,15 @@ Nested `with-capability` calls for the same permission token detect the presence

By convention, capabilities are defined using all uppercase letters.

### Basic syntax
## Basic syntax

To request the grant of an acquired `CAPABILITY`, use the following syntax:

```pact
(with-capability CAPABILITY body)
```

### Arguments
## Arguments

Use the following arguments to specify the name of the capability and the body of expressions to be executed using the `with-capability` Pact function.

Expand All @@ -27,11 +26,11 @@ Use the following arguments to specify the name of the capability and the body o
| `CAPABILITY` | capability | Specifies the name of the capability to grant access to. |
| `body` | any | Specifies the body of expressions to be executed using the granted capability. |

### Return value
## Return value

The `with-capability` function returns the result of executing the provided body of code using the granted capability.

### Examples
## Examples

The following example demonstrates how to use the `with-capability` function to request access to the `UPDATE-USERS` capability to execute the code that updates user information:

Expand Down

0 comments on commit a829dc1

Please sign in to comment.