Skip to content

Commit fbc009d

Browse files
committed
Reformatted chapter 03.
1 parent a7d50c4 commit fbc009d

File tree

1 file changed

+42
-14
lines changed

1 file changed

+42
-14
lines changed

docs/tutorial/platform/03-integration.md

Lines changed: 42 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,43 +5,71 @@ description: Add the CosmWasm module to your app-chain
55

66
# Integration into Cosmos
77

8-
You have decided to add CosmWasm to your app-chain, now what? You need to add the CosmWasm module to the code of your Cosmos SDK app-chain, and integrate it as tightly as desirable. The document source for this process can be found [here](https://github.com/CosmWasm/wasmd/blob/main/INTEGRATION.md), where you can also find more detailed steps and corner cases.
8+
You have decided to add CosmWasm to your app-chain, now what?
9+
You need to add the CosmWasm module to the code of your Cosmos SDK app-chain, and integrate it as tightly as desirable.
10+
The document source for this process can be found [here](https://github.com/CosmWasm/wasmd/blob/main/INTEGRATION.md),
11+
where you can also find more detailed steps and corner cases.
912

10-
The Cosmos SDK is highly customizable. Not only can you add your own modules, you can also replace stock modules with your modified ones. Because of this customizability, the amount of work required to integrate CosmWasm into your app-chain will vary.
13+
The Cosmos SDK is highly customizable. Not only can you add your own modules, you can also replace stock modules with your modified ones.
14+
Because of this customizability, the amount of work required to integrate CosmWasm into your app-chain will vary.
1115

12-
This section is not about experimenting with CosmWasm (see [here](./04-hello-world.html) for that) or learning how to write CosmWasm smart contracts (see [here](./05-first-contract.html) for that).
16+
This section is not about experimenting with CosmWasm (see [here](./04-hello-world.md) for that)
17+
or learning how to write CosmWasm smart contracts (see [here](./05-first-contract.md) for that).
1318

1419
## Prerequisites
1520

16-
CosmWasm supports different Cosmos SDK versions, but you nonetheless have a limited choice of CosmWasm versions per Cosmos SDK versions. See the list [here](https://github.com/CosmWasm/wasmd/blob/main/INTEGRATION.md#prerequisites).
21+
CosmWasm supports different Cosmos SDK versions, but you nonetheless have a limited choice of CosmWasm versions per Cosmos SDK versions.
22+
See the list [here](https://github.com/CosmWasm/wasmd/blob/main/INTEGRATION.md#prerequisites).
1723

18-
Additionally, because of current limitations coming from `wasmvm`, only nodes running Linux or Mac on Intel CPUs are supported for production, although Mac on ARM CPUs are supported for testing.
24+
Additionally, because of current limitations coming from `wasmvm`, only nodes running Linux or Mac on Intel CPUs
25+
are supported for production, although Mac on ARM CPUs are supported for testing.
1926

2027
## If you have a stock app-chain
2128

22-
If you have the standard modules, the standard Proof-of-Stake, the standard Merkle tree storage, have not modified any modules, then these would be your steps. If this does not describe your case, this part can still inform you about the steps you will need to complete before moving on to the customized parts.
29+
If you have the standard modules, the standard Proof-of-Stake, the standard Merkle tree storage,
30+
have not modified any modules, then these would be your steps. If this does not describe your case,
31+
this part can still inform you about the steps you will need to complete before moving on to the customized parts.
2332

2433
1. You [declare the `wasmd` dependency](https://github.com/osmosis-labs/osmosis/blob/v9.0.0-rc0/go.mod#L6) just like any other.
2534
2. You [import the `x/wasm` module](https://github.com/osmosis-labs/osmosis/blob/v9.0.0-rc0/app/app.go#L11), and wire it up in `app.go`.
2635
3. You add the [two necessary ante handlers](https://github.com/osmosis-labs/osmosis/blob/v9.0.0-rc0/app/ante.go#L42-L43).
2736

28-
The [`wasmd`](https://github.com/CosmWasm/wasmd/tree/main) repository itself is an example of an integration into Gaia, the code behind the Cosmos Hub. Except that it has the `x/wasm` as code instead of a dependency. You might choose to copy the `x/wasm` folder too, but this would cost you a lot when updating.
37+
The [`wasmd`](https://github.com/CosmWasm/wasmd/tree/main) repository itself is an example of an integration into Gaia,
38+
the code behind the Cosmos Hub. Except that it has the `x/wasm` as code instead of a dependency.
39+
You might choose to copy the `x/wasm` folder too, but this would cost you a lot when updating.
2940

3041
## If you have modified stock modules
3142

3243
This really is case by case. For instance:
3344

34-
* You may have changed the underlying Merkle tree structure for storage. In this case, you need to [remove the `"iterator"`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/app/keepers/keepers.go#L563) capability from the integration.
35-
* You may have swapped Proof-of-Stake with a Proof-of-Authority. In this case, you need to [remove the `"staking"`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/app/keepers/keepers.go#L563) capability.
45+
- You may have changed the underlying Merkle tree structure for storage.
46+
In this case, you need to [remove the `"iterator"`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/app/keepers/keepers.go#L563)
47+
capability from the integration.
48+
- You may have swapped Proof-of-Stake with a Proof-of-Authority.
49+
In this case, you need to [remove the `"staking"`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/app/keepers/keepers.go#L563)
50+
capability.
3651

3752
## If you have custom Cosmos SDK modules
3853

39-
In this case, it makes sense to make it easy for smart contract developers to access your custom modules with the use of your custom messages. What you create for this purpose are called _bindings_.
54+
In this case, it makes sense to make it easy for smart contract developers to access your custom modules
55+
with the use of your custom messages. What you create for this purpose are called _bindings_.
4056

41-
The standard CosmWasm library offers `CosmosMsg::Custom` and `QueryRequest::Custom` objects for you to extend and define access to SDK modules. So first, on the Rust end, you expose [the available messages](https://github.com/osmosis-labs/bindings/blob/main/packages/bindings/src/msg.rs).
57+
The standard CosmWasm library offers `CosmosMsg::Custom` and `QueryRequest::Custom` objects for you to extend
58+
and define access to SDK modules. So first, on the Rust end,
59+
you expose [the available messages](https://github.com/osmosis-labs/bindings/blob/main/packages/bindings/src/msg.rs).
4260

43-
Then, on the app-chain end, typically in a separate module that you would call `wasmbindings`, you create a [`CustomQuerier`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/query_plugin.go) and [`CustomMessenger`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/message_plugin.go) that bind your custom messages and queries to their actual actions in your module. Then you pass these with [the CosmWasm options](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/wasm.go), to be used at the [`app` wiring](https://github.com/osmosis-labs/osmosis/blob/188abfcd15544ca07d468c0dc0169876ffde6079/app/keepers/keepers.go#L576).
61+
Then, on the app-chain end, typically in a separate module that you would call `wasmbindings`,
62+
you create a [`CustomQuerier`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/query_plugin.go)
63+
and [`CustomMessenger`](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/message_plugin.go) that bind
64+
your custom messages and queries to their actual actions in your module.
65+
Then you pass these with [the CosmWasm options](https://github.com/osmosis-labs/osmosis/blob/v25.2.0/wasmbinding/wasm.go),
66+
to be used at the [`app` wiring](https://github.com/osmosis-labs/osmosis/blob/188abfcd15544ca07d468c0dc0169876ffde6079/app/keepers/keepers.go#L576).
4467

45-
At this point, it is possible for any smart contract to call into your custom modules. In fact, you ought to let smart contracts confirm that they can by telling the CosmWasm module to expose a `requires_MY_MODULE` command, [`"osmosis"` in this example](https://github.com/osmosis-labs/osmosis/blob/188abfcd15544ca07d468c0dc0169876ffde6079/app/keepers/keepers.go#L574). This command can be checked at smart contract instantiation to avoid smart contracts with effectively un-runnable code.
68+
At this point, it is possible for any smart contract to call into your custom modules.
69+
In fact, you ought to let smart contracts confirm that they can by telling the CosmWasm module
70+
to expose a `requires_MY_MODULE` command,
71+
[`"osmosis"` in this example](https://github.com/osmosis-labs/osmosis/blob/188abfcd15544ca07d468c0dc0169876ffde6079/app/keepers/keepers.go#L574).
72+
This command can be checked at smart contract instantiation to avoid smart contracts with effectively un-runnable code.
4673

47-
Additionally, to improve the smart contract developers' experience, you ought to create valid mocks of query replies so that developers can run accurate tests.
74+
Additionally, to improve the smart contract developers' experience, you ought to create valid mocks of query replies
75+
so that developers can run accurate tests.

0 commit comments

Comments
 (0)