Skip to content

Commit

Permalink
Add library feature flag, update docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanfrey committed Sep 30, 2020
1 parent cf8bcae commit 557b95d
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 54 deletions.
6 changes: 5 additions & 1 deletion CONTRACTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ rm .cargo-ok
git add .
```

Now, integrate it into the CI system
Now, integrate it into the CI and build system

1. Edit `.circleci/config.yml`, copy an existing contracts job and replace the name.
Then add your new job to the jobs list on top. (eg. copy `contracts_cw1_whitelist`
Expand All @@ -31,6 +31,10 @@ to `workflows.test.jobs`)
1. Set the `version` variable in `Cargo.toml` to the same version as `packages/cw20`.
For example, "0.2.1" rather than the default "0.1.0"

1. Edit the root `Cargo.toml` file and add a `profile.release.package.CONTRACT_NAME`
section, just like `profile.release.package.cw1-subkeys`, but with your
package name.

1. Run `cargo build && cargo test` in the new contract dir

1. Commit all changes and push the branch. Open a PR and ensure the CI runs this.
13 changes: 10 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
[workspace]
members = ["packages/*", "contracts/*"]

[profile.release.package.cw20-atomic-swap]
[profile.release.package.cw1-subkeys]
opt-level = 3
debug = false
debug-assertions = false
codegen-units = 1
incremental = false

[profile.release.package.cw1-subkeys]
[profile.release.package.cw1-whitelist]
opt-level = 3
debug = false
debug-assertions = false
codegen-units = 1
incremental = false

[profile.release.package.cw1-whitelist]
[profile.release.package.cw20-atomic-swap]
opt-level = 3
debug = false
debug-assertions = false
Expand Down Expand Up @@ -43,6 +43,13 @@ debug-assertions = false
codegen-units = 1
incremental = false

[profile.release.package.cw721-base]
opt-level = 3
debug = false
debug-assertions = false
codegen-units = 1
incremental = false

[profile.release]
rpath = false
lto = true
Expand Down
17 changes: 3 additions & 14 deletions contracts/cw721-base/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,18 @@ edition = "2018"

exclude = [
# Those files are rust-optimizer artifacts. You might want to commit them for convenience but they should not be part of the source code publication.
"contract.wasm",
"hash.txt",
"artifacts/*",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[lib]
crate-type = ["cdylib", "rlib"]

[profile.release]
opt-level = 3
debug = false
rpath = false
lto = true
debug-assertions = false
codegen-units = 1
panic = 'abort'
incremental = false
overflow-checks = true

[features]
# for more explicit tests, cargo test --features=backtraces
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all init/handle/query exports
library = []

[dependencies]
cosmwasm-std = { version = "0.10.1" }
Expand Down
38 changes: 2 additions & 36 deletions contracts/cw721-base/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,5 @@ pub mod contract;
pub mod msg;
pub mod state;

#[cfg(target_arch = "wasm32")]
mod wasm {
use super::contract;
use cosmwasm_std::{
do_handle, do_init, do_query, ExternalApi, ExternalQuerier, ExternalStorage,
};

#[no_mangle]
extern "C" fn init(env_ptr: u32, msg_ptr: u32) -> u32 {
do_init(
&contract::init::<ExternalStorage, ExternalApi, ExternalQuerier>,
env_ptr,
msg_ptr,
)
}

#[no_mangle]
extern "C" fn handle(env_ptr: u32, msg_ptr: u32) -> u32 {
do_handle(
&contract::handle::<ExternalStorage, ExternalApi, ExternalQuerier>,
env_ptr,
msg_ptr,
)
}

#[no_mangle]
extern "C" fn query(msg_ptr: u32) -> u32 {
do_query(
&contract::query::<ExternalStorage, ExternalApi, ExternalQuerier>,
msg_ptr,
)
}

// Other C externs like cosmwasm_vm_version_1, allocate, deallocate are available
// automatically because we `use cosmwasm_std`.
}
#[cfg(all(target_arch = "wasm32", not(feature = "library")))]
cosmwasm_std::create_entry_points!(contract);

0 comments on commit 557b95d

Please sign in to comment.