Skip to content

Commit

Permalink
Merge pull request #1765 from onflow/bastian/improve-documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
turbolent authored Jul 7, 2022
2 parents 3db7348 + 6b91eab commit 86b481e
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 810 deletions.
21 changes: 11 additions & 10 deletions docs/language/accounts.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -163,10 +163,10 @@ to the `prepare` phase of the transaction.
fun getAuthAccount(_ address: Address): AuthAccount
```

This `AuthAccount` object can perform all operations associated with authorized accounts,
and as such this function is only available in scripts,
which discard their changes upon completion.
Attempting to use this function outside of a script will cause a type error.
This `AuthAccount` object can perform all operations associated with authorized accounts,
and as such this function is only available in scripts,
which discard their changes upon completion.
Attempting to use this function outside of a script will cause a type error.

## Account Creation

Expand Down Expand Up @@ -198,7 +198,8 @@ struct AccountKey {
let isRevoked: Bool
}
```
Refer the [PublicKey](crypto/#publickey) section for more details on the creation and validity of public keys.

Refer to the [`PublicKey` section](crypto/#publickey) for more details on the creation and validity of public keys.

### Account Key API
Account key API provides a set of functions to manage account keys.
Expand Down Expand Up @@ -393,7 +394,7 @@ to all its stored objects.

Reads the type of an object from the account's storage which is stored under the given path, or nil if no object is stored under the given path.

If there is an object stored, the type of the object is returned without modifying the stored object.
If there is an object stored, the type of the object is returned without modifying the stored object.

The path must be a storage path, i.e., only the domain `storage` is allowed

Expand All @@ -410,7 +411,7 @@ to all its stored objects.
A type argument for the parameter must be provided explicitly.

The type `T` must be a supertype of the type of the loaded object.
If it is not, execution will abort with an error.
If it is not, execution will abort with an error.
The given type does not necessarily need to be exactly the same as the type of the loaded object.

The path must be a storage path, i.e., only the domain `storage` is allowed.
Expand All @@ -427,7 +428,7 @@ to all its stored objects.
A type argument for the parameter must be provided explicitly.

The type `T` must be a supertype of the type of the copied structure.
If it is not, execution will abort with an error.
If it is not, execution will abort with an error.
The given type does not necessarily need to be exactly the same as
the type of the copied structure.

Expand Down Expand Up @@ -532,7 +533,7 @@ This is possible using the `borrow` function of an `AuthAccount`:
A type argument for the parameter must be provided explicitly.
The type argument must be a reference to any type (`&Any`; `Any` is the supertype of all types).
It must be possible to create the given reference type `T` for the stored / borrowed object.
If it is not, execution will abort with an error.
If it is not, execution will abort with an error.
The given type does not necessarily need to 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.
Expand Down Expand Up @@ -609,7 +610,7 @@ An account's storage is limited by its storage capacity.

An account's storage used is the sum of the size of all the data that is stored in an account (in MB).
An account's storage capacity is a value that is calculated from the amount of FLOW
that is stored in the account's main FLOW token vault.
that is stored in the account's main FLOW token vault.

At the end of every transaction, the storage used is compared to the storage capacity.
For all accounts involved in the transaction, if the account's storage used is greater than its storage capacity, the transaction will fail.
Expand Down
11 changes: 3 additions & 8 deletions docs/language/built-in-functions.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ title: Built-in Functions
```

## assert

`cadence•fun assert(_ condition: Bool, message: String)`

Terminates the program if the given condition is false,
Expand All @@ -23,6 +24,7 @@ title: Built-in Functions
The message argument is optional.

## unsafeRandom

`cadence•fun unsafeRandom(): UInt64`

Returns a pseudo-random number.
Expand All @@ -34,20 +36,13 @@ title: Built-in Functions

## RLP

<Callout type="info">

🚧 Status: This API is going to be available in an upcoming release of Cadence

</Callout>


RLP (Recursive Length Prefix) serialization allows the encoding of arbitrarily nested arrays of binary data.

Cadence provides RLP decoding functions in the built-in `RLP` contract, which does not need to be imported.

- `cadence•fun decodeString(_ input: [UInt8]): [UInt8]`

Decodes an RLP-encoded byte array (called string in the context of RLP).
Decodes an RLP-encoded byte array (called string in the context of RLP).
The byte array should only contain of a single encoded value for a string; if the encoded value type does not match, or it has trailing unnecessary bytes, the program aborts.
If any error is encountered while decoding, the program aborts.

Expand Down
Loading

0 comments on commit 86b481e

Please sign in to comment.