Giter Club home page Giter Club logo

cw-injective-ua's Introduction

Injective Cosmwasm Contracts

This repository contains the full source code for the core smart contracts deployed on Injective.

Contracts

These contracts hold the core logic of the system.

Contract Description
dummy A simply template for starting a new contract
atomic-order-example Example contract on how to do atomic market orders on Injective incl handling the response

Development

Environment Setup

  • Rust v1.67.0
  • wasm32-unknown-unknown target
  • Docker
  1. Install rustup
  2. Run the following
rustup default 1.67.0
rustup target add wasm32-unknown-unknown
  1. Make sure Docker is installed on your machine

Unit / Integration Test

Each contract contains Rust unit tests embedded within the contract source directories. You can run

cargo unit-test

Compiling

Go to the contract directory and run

After making sure tests pass, you can compile each contract with the following

RUSTFLAGS='-C link-arg=-s' cargo wasm
sha256sum target/wasm32-unknown-unknown/release/<CONTRACT_NAME>.wasm

Production

For production builds, run the following:

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 \
  cosmwasm/workspace-optimizer-arm64:0.12.11

This performs several optimizations which can significantly reduce the final size of the contract binaries, which will be available inside the artifacts/ directory.

Formatting

Make sure you run rustfmt before creating a PR to the repo.

To run rustfmt,

cargo fmt

Linting

You should run clippy also. This is a lint tool for Rust. It suggests more efficient/readable code. You can see the clippy document for more information.

Run

cargo clippy -- -D warnings

Testing

Developers are strongly encouraged to write unit tests for new code, and to submit new unit tests for old code. Unit tests can be compiled and run with: cargo test --all. For more details, please reference Unit Tests.

cw-injective-ua's People

Contributors

gorgos avatar darainj avatar antekm avatar maxrobot avatar tofel avatar albertchon avatar maurolacy avatar mankenavenkatesh avatar drunkenrandomwalker avatar kakysha avatar darashahriari avatar mistmorn0 avatar pyramation avatar aursen avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.