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

Address feedback by @dakom from Vercel #135

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
11 changes: 5 additions & 6 deletions src/pages/core.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ import { Callout } from "nextra/components";

# Introduction

This chapter will give you an overview over CosmWasm from a contract developer perspective, its
This chapter will give you an overview of CosmWasm from a contract developer perspective, its
capabilities, and guide you through initializing your first smart contract.

<Callout>We assume you have basic knowledge of Rust and Cargo (its standard build system)</Callout>

## What is CosmWasm?

CosmWasm is a platform for writing smart contracts for Cosmos chains using Rust and WebAssembly.
Meaning CosmWasm is your one-stop shop for developing, testing, and running smart contracts on
enabled chains.
CosmWasm is a platform for writing smart contracts for Cosmos chains using Rust and WebAssembly. It
is your one-stop shop for developing, testing, and running smart contracts on enabled chains.

## What does CosmWasm provide?
## What does CosmWasm Core provide?

For you, a contract developer, CosmWasm provides a set of high-quality primitives through our
standard library. These primitives include:
Expand All @@ -26,7 +25,7 @@ standard library. These primitives include:
- cryptographic primitives (for example, secp256k1 verification)
- interaction with the Cosmos SDK

## What does CosmWasm _not_ provide?
## What does CosmWasm Core _not_ provide?

- Abstractions to simplify contract development (for this, check out [Sylvia](/sylvia))
- Storage abstractions (for this, check out [Storey](/storey))
5 changes: 5 additions & 0 deletions src/pages/core/architecture/pinning.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ import { Callout } from "nextra/components";

# Contract pinning

<Callout type="info">
This is done by chain maintainers and not by contract developers. It's not something you need to
worry about when writing contracts but can be a fun thing to know.
</Callout>

Contract pinning is a feature of the CosmWasm virtual machine which ensures that a previously stored
compiled contract code (module) is started from a dedicated in-memory cache. Starting a module from
memory takes ~45µs compared to 1.5ms when loaded from disk (33x faster).
Expand Down
18 changes: 12 additions & 6 deletions src/pages/core/entrypoints.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import { Callout } from "nextra/components";

Entrypoints are where your contract can be called from the outside world. You can equate that to
your `main` function in C, Rust, Java, etc.
However, there is one _small_ difference: In CosmWasm, you have multiple of these entrypoints, each
one different from the last.
However, there is one _small_ difference: In CosmWasm, you have multiple entrypoints, each one
different from the last.

In this section we want to give you a quick overview over all the entrypoints and when they are
called.
Expand Down Expand Up @@ -69,7 +69,7 @@ your own types.

### Predefined types

#### `Deps`/`DepsMut`
#### [`Deps`]/[`DepsMut`]

These structs provide you access to the:

Expand All @@ -81,15 +81,15 @@ The big difference is that `DepsMut` gives you _mutable_ access to the storage.
deliberate since you, for example, can't mutate the state in the `query` endpoint. Instead of
relying on runtime errors, this is made _irrepresentable_ through Rust's type system.

#### `Env`
#### [`Env`]

This struct provides you with some information of the current state of the environment your contract
is executed in.

The information provided is, for example, the block height, chain ID, transaction info, etc.
Basically anything you'd ever want to know about the current state of the execution environment!

#### `MessageInfo`
#### [`MessageInfo`]

This struct isn't provided to every endpoint, only to a select few.

Expand All @@ -114,7 +114,8 @@ struct CustomInstantiateMsg {

<Callout>
This macro actually just expands into a bunch of `derive` attributes.
We provide this simply for your convenience, otherwise you'd have to keep track of all of these derives yourself.
We provide this simply for your convenience, otherwise you'd have to keep track of all of these derives
yourself if you want the full suite of conveniences `cosmwasm-std` has to offer.

<details>
<summary>Without `#[cw_serde]`</summary>
Expand All @@ -136,3 +137,8 @@ struct CustomInstantiateMsg {

</details>
</Callout>

[`Deps`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Deps.html
[`DepsMut`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.DepsMut.html
[`Env`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.Env.html`
[`MessageInfo`]: https://docs.rs/cosmwasm-std/latest/cosmwasm_std/struct.MessageInfo.html
7 changes: 3 additions & 4 deletions src/pages/core/entrypoints/instantiate.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,10 @@ You can imagine it as the constructor of your contract.
Note that this function is called for *each instance* of your contract
that you decide to create, not one time ever.

To equate it to OOP, your contract is a *class*, and this is the *constructor*,
and you can have *multiple instances* of the same class, and the constructor
is called once for every one of these instances.
Your contract is the *constructor*, and you can have *multiple instances* of the same contract.
Each time an instance is createDefineEnv, the constructor is called.

It is **not** a singleton.
Contracts are **not** singletons.

</Callout>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/core/installation.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { Callout } from "nextra/components";
## Setting up the environment

Before diving right into writing code, you need to install some tooling in order to compile your
contract. CosmWasm is luckily rather self-contained and therefore needs little external tooling to
contract. CosmWasm is rather self-contained and therefore needs little external tooling to
compile.
Our only external dependency is Rust, which you need to install for your platform.

Expand Down
Loading