Skip to content

Commit

Permalink
feat: cargo scripts, workspace optimize and oracle contract
Browse files Browse the repository at this point in the history
  • Loading branch information
emidev98 committed Jun 15, 2023
1 parent 70cb79a commit 9d81883
Show file tree
Hide file tree
Showing 27 changed files with 157 additions and 253 deletions.
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,16 @@
node_modules
target
# Build results
/target
/artifacts
# Cargo+Git helper file (https://github.com/rust-lang/cargo/blob/0.44.1/src/cargo/sources/git/utils.rs#L320-L327)
.cargo-ok

# Text file backups
**/*.rs.bk

# macOS
.DS_Store

# IDEs
*.iml
.idea
48 changes: 17 additions & 31 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
[workspace]
members = [
"contracts/*",
"packages/*",
]
exclude = [
"contracts/alliance-hub",
"contracts/cw-alliance-oracle",
"packages/alliance-protocol",
]
exclude = []

[workspace.package]
version = "0.1.0"
edition = "2021"
license = "Apache-2.0"
repository = "https://github.com/terra-money/alliance-protocol"
homepage = "https://github.com/terra-money/alliance-protocol"
documentation = "https://github.com/terra-money/alliance-protocol"
rust-version = "1.68.2"

[profile.dev]
overflow-checks = false
Expand All @@ -31,5 +40,4 @@ serde = { version = "1.0.152", default-features = false, features = ["derive"] }
terra-proto-rs = { version = "3.0.1", default-features = false}
thiserror = { version = "1.0.38" }
cw2 = "1.0.1"
alliance-protocol = { path = "./packages/alliance-protocol" }
alliance-oracle = { path = "./packages/alliance-oracle" }
alliance-protocol = { path = "./packages/alliance-protocol" }
40 changes: 40 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[config]
# Set this to `false` to run the tasks at workspace root directory and not on the members
default_to_workspace = false
# Set this to `true` to avoid clashes with core commands (e.g. `cargo make publish` vs `cargo publish`)
skip_core_tasks = true

[tasks.fmt]
command = "cargo"
args = ["fmt", "--all", "--check"]

[tasks.test]
command = "cargo"
args = ["test", "--locked"]

[tasks.lint]
command = "cargo"
args = ["clippy", "--tests", "--", "-D", "warnings"]

[tasks.build]
command = "cargo"
args = [
"build",
"--release",
"--locked",
"--target", "wasm32-unknown-unknown",
]

[tasks.optimize]
script = """
if [[ $(arch) == "arm64" ]]; then
image="cosmwasm/workspace-optimizer-arm64"
else
image="cosmwasm/workspace-optimizer"
fi
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="$(basename "$(pwd)")_cache",target=/code/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
${image}:0.12.12
"""
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Development

Considering the Rust is installed in your system you have to use the wasm32 compiler and install cargo-make.

```sh
$ rustup default stable
$ rustup target add wasm32-unknown-unknown
$ cargo install --force cargo-make
```

There are few available commands to run on development:

Validate the code has been formatted correctly:
```sh
$ cargo make fmt
```

Run the tests written for the smart contracts
```sh
$ cargo make test
```

Lint the code
```sh
$ cargo make lint
```

Build the code
```sh
$ cargo make build
```

Optimize the built code
```sh
$ cargo make optimize
```
4 changes: 0 additions & 4 deletions contracts/alliance-hub/.cargo/config

This file was deleted.

8 changes: 6 additions & 2 deletions contracts/alliance-hub/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ authors = ["Terra Money <[email protected]>"]
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",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
crate-type = ["cdylib", "rlib"]

[features]
backtraces = ["cosmwasm-std/backtraces"]
library = []

[dependencies]
cosmwasm-std = { workspace = true }
Expand Down
4 changes: 0 additions & 4 deletions contracts/alliance-oracle/.cargo/config

This file was deleted.

15 changes: 0 additions & 15 deletions contracts/alliance-oracle/.gitignore

This file was deleted.

17 changes: 0 additions & 17 deletions contracts/alliance-oracle/.gitpod.Dockerfile

This file was deleted.

10 changes: 0 additions & 10 deletions contracts/alliance-oracle/.gitpod.yml

This file was deleted.

106 changes: 0 additions & 106 deletions contracts/alliance-oracle/README.md

This file was deleted.

5 changes: 0 additions & 5 deletions contracts/alliance-oracle/cargo-generate.toml

This file was deleted.

13 changes: 0 additions & 13 deletions contracts/alliance-oracle/src/utils.rs

This file was deleted.

File renamed without changes.
Loading

0 comments on commit 9d81883

Please sign in to comment.