Skip to content

Commit

Permalink
Merge pull request #164 from onflow/brian-doyle/customize-info-admoni…
Browse files Browse the repository at this point in the history
…shments

Convert admonishments from <Callout /> to standard ::: format
  • Loading branch information
briandoyle81 authored Oct 10, 2024
2 parents 51a56bd + a27348f commit 90d7b4c
Show file tree
Hide file tree
Showing 42 changed files with 915 additions and 752 deletions.
6 changes: 4 additions & 2 deletions docs/language/accounts/contracts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -264,15 +264,17 @@ then the function aborts the program.

When the update succeeded, the function returns the [deployed contract](#deployed-contract).

<Callout type="info">
:::warning

The `update` function does **not** run the initializer of the contract again.

Updating a contract does **not** change the contract instance and its existing stored data.
A contract update only changes the code a contract.

Is only possible to update contracts in ways that keep data consistency.
[Certain restrictions apply](../contract-updatability.md).
</Callout>

:::

For example, assuming that a contract named `Test` is already deployed to the account,
and it should be updated with the following contract code:
Expand Down
6 changes: 4 additions & 2 deletions docs/language/accounts/inbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,11 @@ the function returns `nil`.
If the borrow type of the capability is not a subtype of the provided type argument,
the program aborts.

<Callout type="info">
:::tip

It is only possible to claim a capability once.
</Callout>

:::

Calling function `claim` function emits an event, `InboxValueClaimed`,
that includes the address of both the provider and the recipient,
Expand Down
10 changes: 6 additions & 4 deletions docs/language/accounts/keys.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ For each key of the account, the `forEach` function calls the given callback, pa
When the callback function returns `true` the iteration continues,
and when it returns `false`, iteration stops.

<Callout type="warning">
The `keys.get` and `keys.forEach` functions include revoked keys,
which have the `isRevoked` field set to `true`.
</Callout>
:::warning

The `keys.get` and `keys.forEach` functions include revoked keys,
which have the `isRevoked` field set to `true`.

:::

```cadence
access(all)
Expand Down
17 changes: 10 additions & 7 deletions docs/language/accounts/storage.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -419,14 +419,17 @@ If the callback function returns `false`, the iteration function stops.
The specific order in which the objects are iterated over is undefined,
as is the behavior when a path is added or removed from storage.

<Callout type="info">
The iteration functions skip broken objects.
:::warning

An object could be broken due to invalid types associated with the stored value.
For example, the contract for the stored object might have syntactic or semantic errors.
</Callout>
The iteration functions skip broken objects.

An object could be broken due to invalid types associated with the stored value.
For example, the contract for the stored object might have syntactic or semantic errors.

:::

:::warning

<Callout type="warning">
The order of iteration is undefined. Do not rely on any particular behavior.

Saving an object to a path or loading an object from storage during iteration
Expand Down Expand Up @@ -458,7 +461,7 @@ account.storage.forEachStored(fun (path: StoragePath, type: Type): Bool {
})
```

</Callout>
:::

## Storage limit

Expand Down
4 changes: 2 additions & 2 deletions docs/language/built-in-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ and [FLIP120](https://github.com/onflow/flips/pull/120) for more details.

Nevertheless, developers need to be mindful to use `revertibleRandom()` correctly:

<Callout type="warning">
:::warning

A transaction can atomically revert all its action.
It is possible for a transaction submitted by an untrusted party
to post-select favorable results and revert the transaction for unfavorable results.

</Callout>
:::

The function usage remains safe when called by a trusted party that does not
perform post-selection on the returned random numbers.
Expand Down
6 changes: 4 additions & 2 deletions docs/language/glossary.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ sidebar_position: 32
---


<Callout type="info">
:::tip

Tip: <kbd>CTRL</kbd>/<kbd>⌘</kbd> + <kbd>F</kbd> and type in the symbol or operator you want to look up.
</Callout>

:::

## `&` (ampersand)

Expand Down
6 changes: 3 additions & 3 deletions docs/language/interfaces.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -458,11 +458,11 @@ shape.area // is `54`

## Interface Nesting

<Callout type="info">
:::warning[🚧 Status]

🚧 Status: Currently only contracts and contract interfaces support nested interfaces.
Currently only contracts and contract interfaces support nested interfaces.

</Callout>
:::

Interfaces can be arbitrarily nested.
Declaring an interface inside another does not require implementing types
Expand Down
6 changes: 4 additions & 2 deletions docs/language/references.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -414,9 +414,11 @@ let r2 <- r
ref.id = 2
```

<Callout type="info">
:::tip

Invalidations of storage references are not statically caught, but only at run-time.
</Callout>

:::

## Dereferencing values

Expand Down
6 changes: 4 additions & 2 deletions docs/language/resources.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -604,11 +604,13 @@ id2 != id3 // true
id3 != id1 // true
```

<Callout type="warning">
:::warning

The details of how the identifiers are generated is an implementation detail.

Do not rely on or assume any particular behaviour in Cadence programs.
</Callout>

:::

## Resource Owner

Expand Down
6 changes: 3 additions & 3 deletions docs/language/values-and-types.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -246,12 +246,12 @@ All integer types support the following functions:

## Fixed-Point Numbers

<Callout type="info">
:::warning[🚧 Status]

🚧 Status: Currently only the 64-bit wide `Fix64` and `UFix64` types are available.
Currently only the 64-bit wide `Fix64` and `UFix64` types are available.
More fixed-point number types will be added in a future release.

</Callout>
:::

Fixed-point numbers are useful for representing fractional values.
They have a fixed number of digits after decimal point.
Expand Down
12 changes: 8 additions & 4 deletions docs/testing-framework.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ sidebar_label: Testing
The Cadence testing framework provides a convenient way to write tests for Cadence programs in Cadence.
This functionality is provided by the built-in `Test` contract.

<Callout type="info">
:::tip

The testing framework can only be used off-chain, e.g. by using the [Flow CLI](https://developers.flow.com/tools/flow-cli).
</Callout>

:::

Tests must be written in the form of a Cadence script.
A test script may contain testing functions that starts with the `test` prefix,
Expand Down Expand Up @@ -1154,10 +1156,12 @@ struct Configuration {
}
```

<Callout type="info">
:::tip

The `Blockchain.useConfiguration` is a run-time alternative for
[statically defining contract addresses in the flow.json config file](https://developers.flow.com/tools/flow-cli/flow.json/configuration.md#advanced-format).
</Callout>

:::

The configurations can be specified during the test setup as a best-practice.

Expand Down
20 changes: 11 additions & 9 deletions docs/tutorial/01-first-steps.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,17 @@ in the sidebar here and click the link in the callout box at the beginning of th

The callout boxes should look like this:

<Callout type="success">
Open the starter code for this tutorial in the Flow Playground: <br />
<a
href="https://play.flow.com/"
target="_blank"
>
https://play.flow.com/
</a>
</Callout>
:::tip

Open the starter code for this tutorial in the Flow Playground: <br />
<a
href="https://play.flow.com/"
target="_blank"
>
https://play.flow.com/
</a>

:::

When you click on one of these links, the tutorial code will open in a new tab
and the contracts, transactions, and scripts will be loaded
Expand Down
58 changes: 31 additions & 27 deletions docs/tutorial/02-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@ socialImageDescription: Hello world smart contract image.

In this tutorial, we'll write and deploy our first smart contract!

<Callout type="success">
Open the starter code for this tutorial in the Flow Playground: <br />
<a
href="https://play.flow.com/483b2f33-9e71-40aa-924a-2c5f0ead77aa"
target="_blank"
>
https://play.flow.com/483b2f33-9e71-40aa-924a-2c5f0ead77aa
</a>
The tutorial will ask you to take various actions to interact with this code.
</Callout>

<Callout type="info">
Instructions that require you to take action are always included in a callout
box like this one. These highlighted actions are all that you need to do to
get your code running, but reading the rest is necessary to understand the
language's design.
</Callout>
:::tip

Open the starter code for this tutorial in the Flow Playground: <br />
<a
href="https://play.flow.com/483b2f33-9e71-40aa-924a-2c5f0ead77aa"
target="_blank"
>
https://play.flow.com/483b2f33-9e71-40aa-924a-2c5f0ead77aa
</a>
The tutorial will ask you to take various actions to interact with this code.

:::

:::info[Action]

Instructions that require you to take action are always included in a callout
box like this one. These highlighted actions are all that you need to do to
get your code running, but reading the rest is necessary to understand the
language's design.

:::

This tutorial will walk you through an example of a smart contract that implements basic Cadence features,
including accounts, transactions, and signers.
Expand Down Expand Up @@ -86,7 +90,7 @@ Each account can have zero or more contracts and/or contract interfaces.
A contract can be freely added, removed, or updated (with some restrictions) by the owner of the account.
Now let's look at the `HelloWorld` contract that you'll be working through in this tutorial.

<Callout type="info">
:::info[Action]

If you haven't already, you'll need to follow this link to open a playground session with the Hello World contracts, transactions, and scripts pre-loaded:

Expand All @@ -98,17 +102,17 @@ If you haven't already, you'll need to follow this link to open a playground ses
https://play.flow.com/483b2f33-9e71-40aa-924a-2c5f0ead77aa
</a>

</Callout>
:::

![Playground Intro](playground-intro.png)

<Callout type="info">
:::info[Action]

Open the Account `0x06` tab with the file called
`HelloWorld.cdc` in the Contract 1 space. <br />
`HelloWorld.cdc` should contain this code:

</Callout>
:::

```cadence HelloWorld.cdc
// HelloWorld.cdc
Expand Down Expand Up @@ -190,13 +194,13 @@ In this tutorial, we use the account with the address `0x06` to store our `Hello

Now that you know what an account is in a Cadence context, you can deploy the `HelloWorld` contract to your account.

<Callout type="info">
:::info[Action]

Make sure that the account `0x06` tab is selected and that the
`HelloWorld.cdc` file is in the editor. <br />
Click the deploy button to deploy the contents of the editor to account `0x06`.

</Callout>
:::

![Deploy Contract](deploybox.png)

Expand All @@ -223,12 +227,12 @@ In addition to being able to access the authorizer's private assets,
transactions can also read and call functions in public contracts, and access public functions in other users' accounts.
For this tutorial, we use a transaction to call our `hello()` function.

<Callout type="info">
:::info[Action]

Open the transaction named `Simple Transaction` <br />
`Simple Transaction` should contain this code:

</Callout>
:::

```cadence SayHello.cdc
import HelloWorld from 0x06
Expand Down Expand Up @@ -266,12 +270,12 @@ Transactions are divided into two main phases, `prepare` and `execute`.
This executes the `hello()` function in the `HelloWorld` contract
and logs the result(`log(HelloWorld.hello())`) to the console.

<Callout type="info">
:::info[Action]

In the box at the bottom right of the editor, select Account `0x06` as the transaction signer. <br />
Click the `Send` button to submit the transaction

</Callout>
:::

You should see something like this in the transaction results at the bottom of the screen:

Expand Down
Loading

0 comments on commit 90d7b4c

Please sign in to comment.