You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/tutorial/platform/03-integration.md
+42-14Lines changed: 42 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,43 +5,71 @@ description: Add the CosmWasm module to your app-chain
5
5
6
6
# Integration into Cosmos
7
7
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.
9
12
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.
11
15
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).
13
18
14
19
## Prerequisites
15
20
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).
17
23
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.
19
26
20
27
## If you have a stock app-chain
21
28
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.
23
32
24
33
1. You [declare the `wasmd` dependency](https://github.com/osmosis-labs/osmosis/blob/v9.0.0-rc0/go.mod#L6) just like any other.
25
34
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`.
26
35
3. You add the [two necessary ante handlers](https://github.com/osmosis-labs/osmosis/blob/v9.0.0-rc0/app/ante.go#L42-L43).
27
36
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.
29
40
30
41
## If you have modified stock modules
31
42
32
43
This really is case by case. For instance:
33
44
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.
36
51
37
52
## If you have custom Cosmos SDK modules
38
53
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_.
40
56
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).
42
60
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).
44
67
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.
46
73
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
0 commit comments