Skip to content
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

imp: added shell.nix for nix users #138

Merged
merged 6 commits into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ jobs:
steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
- uses: actions/checkout@v4
- name: golangci-lint
uses: golangci/[email protected]
with:
version: v1.59
version: v1.61
args: --timeout 5m
working-directory: e2e/interchaintestv8
build:
Expand Down Expand Up @@ -65,7 +65,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: "1.22"
go-version: "1.23"
check-latest: true
cache-dependency-path: |
e2e/interchaintestv8/go.sum
Expand Down
66 changes: 45 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,34 @@ This is a `CosmWasm` smart contract that communicates with the golang `ica/host`

## Table of Contents

<!-- TOC -->

- [`CosmWasm` ICA Controller Contract](#cosmwasm-ica-controller-contract)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Create an interchain account](#create-an-interchain-account)
- [Using `InstantiateMsg`](#using-instantiatemsg)
- [Using `ExecuteMsg::CreateChannel`](#using-executemsgcreatechannel)
- [Execute an interchain account transaction](#execute-an-interchain-account-transaction)
- [Querying the host chain](#querying-the-host-chain)
- [Execute a callback](#execute-a-callback)
- [Channel Closing and Reopening](#channel-closing-and-reopening)
- [Channel Closing](#channel-closing)
- [Channel Reopening](#channel-reopening)
- [Demo](#demo)
- [Injective Illuminate Hackathon](#injective-illuminate-hackathon)
- [XION ABSTRACTATHON](#xion-abstractathon)
- [Testing](#testing)
- [Unit tests](#unit-tests)
- [End to end tests](#end-to-end-tests)
- [Releases](#releases)
- [Limitations](#limitations)
- [Acknowledgements](#acknowledgements)
- [Table of Contents](#table-of-contents)
- [Usage](#usage)
- [Create an interchain account](#create-an-interchain-account)
- [Using `InstantiateMsg`](#using-instantiatemsg)
- [Using `ExecuteMsg::CreateChannel`](#using-executemsgcreatechannel)
- [Execute an interchain account transaction](#execute-an-interchain-account-transaction)
- [Querying the host chain](#querying-the-host-chain)
- [Execute a callback](#execute-a-callback)
- [Channel Closing and Reopening](#channel-closing-and-reopening)
- [Channel Closing](#channel-closing)
- [Channel Reopening](#channel-reopening)
- [Demo](#demo)
- [Injective Illuminate Hackathon](#injective-illuminate-hackathon)
- [XION ABSTRACTATHON](#xion-abstractathon)
- [Building](#building)
- [Prerequisites](#prerequisites)
- [Building the contract](#building-the-contract)
- [Testing](#testing)
- [Unit tests](#unit-tests)
- [End to end tests](#end-to-end-tests)
- [Releases](#releases)
- [Limitations](#limitations)
- [Acknowledgements](#acknowledgements)

<!-- /TOC -->

## Usage

Expand Down Expand Up @@ -268,6 +275,23 @@ Buying and selling and NFT from Xion on Injective using Nomos SDK and ICA contro

## Building

### Prerequisites

This project requires the following dependencies:

- [Rust](https://www.rust-lang.org/tools/install)
- [Docker](https://www.docker.com/)
- [Just](https://just.systems/man/en/introduction.html) (optional)
- [go](https://go.dev/) (for the end to end tests)

Nix users can install the dependencies (except docker) in a shell by running:

```sh
nix-shell shell.nix
```

### Building the contract

We use [cosmwasm/optimizer](https://github.com/`CosmWasm`/optimizer) docker image to build the contract. This project uses `just` as the task runner. To install `just`, run the following command:

```sh
Expand Down Expand Up @@ -305,7 +329,7 @@ This contract follows [semantic versioning](https://semver.org/), but with the f

## Limitations

This contract is not meant to be used in production. It is meant to be used as a reference implementation for how to build a `CosmWasm` contract that can communicate with the golang ica/host module. The following are some of the limitations of this contract:
The following are some of the limitations of this contract:

- The contract cannot create multiple interchain accounts. It can only create one.

Expand Down
5 changes: 4 additions & 1 deletion e2e/interchaintestv8/.golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ linters:
disable-all: true
enable:
- dogsled
- exportloopref
- copyloopvar
- errcheck
- gci
- goconst
Expand Down Expand Up @@ -42,6 +42,9 @@ issues:
- text: "ST1003:"
linters:
- stylecheck
- text: "G115:"
linters:
- gosec
# FIXME: Disabled until golangci-lint updates stylecheck with this fix:
# https://github.com/dominikh/go-tools/issues/389
- text: "ST1016:"
Expand Down
17 changes: 17 additions & 0 deletions shell.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{ pkgs ? import <nixpkgs> {}, lib ? pkgs.lib, stdenv ? pkgs.stdenv }:
let
unstable = import
(builtins.fetchTarball https://github.com/nixos/nixpkgs/tarball/ccc0c2126893dd20963580b6478d1a10a4512185)
# reuse the current configuration
{ config = pkgs.config; };
in
pkgs.mkShell {
nativeBuildInputs = with pkgs.buildPackages; [
just unstable.golangci-lint unstable.go rustup
];
# Run a command after entering the shell
shellHook = ''
echo "Entering shell with stable rust"
rustup toolchain install stable
'';
}
3 changes: 2 additions & 1 deletion src/ibc/types/packet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use super::metadata::TxEncoding;
pub const DEFAULT_TIMEOUT_SECONDS: u64 = 600;

/// `IcaPacketData` is comprised of a raw transaction, type of transaction and optional memo field.
///
/// Currently, the host only supports [protobuf](super::metadata::TxEncoding::Protobuf) or
/// [proto3json](super::metadata::TxEncoding::Proto3Json) serialized Cosmos transactions.
/// This contract only supports the protobuf encoding.
Expand Down Expand Up @@ -47,7 +48,7 @@ pub struct IcaPacketData {
impl IcaPacketData {
/// Creates a new [`IcaPacketData`]
#[must_use]
pub fn new(data: Vec<u8>, memo: Option<String>) -> Self {
pub const fn new(data: Vec<u8>, memo: Option<String>) -> Self {
Self {
r#type: 1,
data,
Expand Down
1 change: 1 addition & 0 deletions src/ibc/types/stargate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub mod channel {
use super::super::{keys, metadata};

/// Creates a new [`MsgChannelOpenInit`] for an ica channel with the given contract address.
///
/// Also generates the handshake version.
/// If the counterparty port id is not provided, [`keys::HOST_PORT_ID`] is used.
/// If the tx encoding is not provided, [`metadata::TxEncoding::Protobuf`] is used.
Expand Down
1 change: 1 addition & 0 deletions src/types/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub const ALLOW_CHANNEL_OPEN_INIT: Item<bool> = Item::new("allow_channel_open_in
pub const ALLOW_CHANNEL_CLOSE_INIT: Item<bool> = Item::new("allow_channel_close_init");

/// The item used to store the paths of an ICA query until its `SendPacket` response is received.
///
/// Once the response is received, it is moved to the [`PENDING_QUERIES`] map and deleted from this item.
/// This is used to ensure that the correct sequence is recorded for the response.
#[cfg(feature = "query")]
Expand Down
Loading