-
Notifications
You must be signed in to change notification settings - Fork 24
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
Removed feature interface from docs #346
Merged
Kayanski
merged 10 commits into
main
from
ani/orc-87-update-documentation-to-reflect-removed-requirement-of
Mar 28, 2024
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1cac27c
removed feature interface from docs
anistark 8a266cb
readded removed code
anistark 2410ced
Quick start
Kayanski abfbb7a
Added entry points
Kayanski b11f506
Merged with other changes
Kayanski 8315abb
Scripting fix
Kayanski 056a396
Added wams compilation help, last feature remove, remove runtime handle
Kayanski a276e0a
Update the diff and versions where this is available
Kayanski 80abf94
Update docs/src/contracts/wasm-compilation.md
Kayanski 4d40257
Nits
Kayanski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Wasm Compilation | ||
|
||
`cw-orch` was designed to help you test, deply, script and maintaint your application. None of its features include in-contract operations. cw-orch interfaces, macros and helpers can't be used inside a wasm smart contract. | ||
|
||
In case you use one of the cw-orch features inside you smart-contract, the compilation will send an error anyway, so that we are **SURE** you are not using un-intended features inside your contract. | ||
|
||
## Importing cw-orch | ||
|
||
Importing `cw-orch` as a dependency in your smart contract is not a problem. We have built this library such that every feature that cw-orch imports, uses or exports is not included when compiled for Wasm. This means that you are safe to use any cw-orch feature when developing your application, creating interfaces, exporting features, because none of it will land in your contract. | ||
|
||
In order to make sure you don't encounter wasm compilation errors, you should follow the guidelines outlined in the next section. | ||
|
||
## Guidelines | ||
|
||
### Imports | ||
|
||
Import cw-orch without a worry, this won't include unnecessary dependencies and bloat your smart-contract. Be careful of the features you import `cw-orch` with because they might increase your compile time (especially `daemon` and `osmosis-test-tube`). | ||
|
||
### Interface | ||
|
||
The interface macro itself compiles to Wasm to empty traits. So this macro can be used anywhere in your contract. This **IS** smart-contract safe: | ||
|
||
```rust,ignore | ||
{{#include ../../../contracts/counter/src/interface.rs:interface_macro}} | ||
``` | ||
|
||
However, the `Uploadable` traits implementation **IS NOT** safe for smart contracts and needs to import namely `cw-multi-test` elements that we don't remove from WASM compilation. The following code needs to be flagged to not be compiled inside Wasm contracts: | ||
|
||
```rust,ignore | ||
#[cfg(not(target_arch = "wasm32"))] | ||
{{#include ../../../contracts/counter/src/interface.rs:uploadable_impl}} | ||
``` | ||
|
||
### Entry Points | ||
|
||
The entry points are easy to work with as they compile to empty traits inside Wasm. So you can define them, import and export them in your contract without having to care about compilation targets. Furthermore, those traits are optimized out when getting your contract ready to upload on a chain. The syntax use in the 2 following examples is WASM safe: | ||
|
||
```rust,ignore | ||
{{#include ../../../contracts/counter/src/msg.rs:exec_msg}} | ||
``` | ||
|
||
```rust,ignore | ||
{{#include ../../../contracts/counter/src/lib.rs:fn_re_export}} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is the only location where we call them entry points?