From 8f11e54ef2325142b7d9731662da43c27dec0eb4 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 17:44:30 +0200 Subject: [PATCH 1/6] Apply introduction page feedback --- src/pages/core.mdx | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/pages/core.mdx b/src/pages/core.mdx index 706b353f..f64537c7 100644 --- a/src/pages/core.mdx +++ b/src/pages/core.mdx @@ -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. We assume you have basic knowledge of Rust and Cargo (its standard build system) ## 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: @@ -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)) From 9cbe456d9b1eb2e365e8f3b0f2eebdb9ecd410cf Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 17:45:23 +0200 Subject: [PATCH 2/6] Apply installation page feedback --- src/pages/core/installation.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/core/installation.mdx b/src/pages/core/installation.mdx index 42422315..a950e1ed 100644 --- a/src/pages/core/installation.mdx +++ b/src/pages/core/installation.mdx @@ -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. From 9eafaf65502d26c8f673c63f49c876a4f99543fd Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 17:49:24 +0200 Subject: [PATCH 3/6] Apply some entrypoints feedback --- src/pages/core/entrypoints.mdx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/pages/core/entrypoints.mdx b/src/pages/core/entrypoints.mdx index d986be9e..7089ec0a 100644 --- a/src/pages/core/entrypoints.mdx +++ b/src/pages/core/entrypoints.mdx @@ -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. @@ -36,8 +36,8 @@ use it when needed!" When defining an entrypoint, it is important to use the correct types for the parameters and return type. Incorrect types will cause errors when trying to call the contract. -
In the following sections we will take a look at all possible entrypoints, including the - correct function signature. +
In the following sections we will take a look at all possible entrypoints, including the correct + function signature.
@@ -69,7 +69,7 @@ your own types. ### Predefined types -#### `Deps`/`DepsMut` +#### [`Deps`]/[`DepsMut`] These structs provide you access to the: @@ -81,7 +81,7 @@ 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. @@ -89,7 +89,7 @@ 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. @@ -114,7 +114,8 @@ struct CustomInstantiateMsg { 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.
Without `#[cw_serde]` @@ -136,3 +137,8 @@ struct CustomInstantiateMsg {
+ +[`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 From a8a1147be47fe015743e18a704df71929ad7671b Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 17:53:51 +0200 Subject: [PATCH 4/6] Remove OOP equivalency --- src/pages/core/entrypoints/instantiate.mdx | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/pages/core/entrypoints/instantiate.mdx b/src/pages/core/entrypoints/instantiate.mdx index df8382c9..a494266b 100644 --- a/src/pages/core/entrypoints/instantiate.mdx +++ b/src/pages/core/entrypoints/instantiate.mdx @@ -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.
From ed8b416a2ad76900844e626c3522afb1e32de89d Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Mon, 12 Aug 2024 18:03:01 +0200 Subject: [PATCH 5/6] Add disclaimer --- src/pages/core/architecture/pinning.mdx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pages/core/architecture/pinning.mdx b/src/pages/core/architecture/pinning.mdx index 7fd571c4..06d2695a 100644 --- a/src/pages/core/architecture/pinning.mdx +++ b/src/pages/core/architecture/pinning.mdx @@ -6,6 +6,11 @@ import { Callout } from "nextra/components"; # Contract pinning + + 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. + + 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). @@ -85,5 +90,4 @@ which required certain contracts to be executed in every block. https://medium.com/confio/neutron-case-study-optimizing-gas-usage-with-contract-pinning-5970a109c706 [^1]: https://github.com/CosmWasm/wasmd/pull/1799 - [^2]: https://github.com/CosmWasm/cosmwasm/issues/2034 From 16e915a7e60b468afe1b93e7962f7b7a6cf66e9c Mon Sep 17 00:00:00 2001 From: "autofix-ci[bot]" <114827586+autofix-ci[bot]@users.noreply.github.com> Date: Mon, 12 Aug 2024 16:13:00 +0000 Subject: [PATCH 6/6] [autofix.ci] apply automated fixes --- src/pages/core/architecture/pinning.mdx | 1 + src/pages/core/entrypoints.mdx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/pages/core/architecture/pinning.mdx b/src/pages/core/architecture/pinning.mdx index 06d2695a..a1d7df38 100644 --- a/src/pages/core/architecture/pinning.mdx +++ b/src/pages/core/architecture/pinning.mdx @@ -90,4 +90,5 @@ which required certain contracts to be executed in every block. https://medium.com/confio/neutron-case-study-optimizing-gas-usage-with-contract-pinning-5970a109c706 [^1]: https://github.com/CosmWasm/wasmd/pull/1799 + [^2]: https://github.com/CosmWasm/cosmwasm/issues/2034 diff --git a/src/pages/core/entrypoints.mdx b/src/pages/core/entrypoints.mdx index 7089ec0a..4d4ec736 100644 --- a/src/pages/core/entrypoints.mdx +++ b/src/pages/core/entrypoints.mdx @@ -36,8 +36,8 @@ use it when needed!" When defining an entrypoint, it is important to use the correct types for the parameters and return type. Incorrect types will cause errors when trying to call the contract. -
In the following sections we will take a look at all possible entrypoints, including the correct - function signature. +
In the following sections we will take a look at all possible entrypoints, including the + correct function signature.