Skip to content

Commit

Permalink
release: v1.0.0 (#104)
Browse files Browse the repository at this point in the history
* fix: handleMessage parameter-from to fromNid (#28)

* fix: handleMessage parameter-from to fromNid

* fix: issues fixed occured during fixes

* fix: parameter changed in rust side and docs

* style: cargo lints fixes

* chore: underscore added in parameter docs

---------

Co-authored-by: AntonAndell <[email protected]>

* fix: fee check send message (#84)

* fix: add fee check

* chore: pass build

* fix: add test for fail case

* fix: reverse fee logic

* fix: add zero check

* ci: publish xcall-multi library to maven repository (#71)

* ci: publish xcall-multi library to maven repository

* add  publish_maven.yml

* Update build.gradle

* fix maven publish 400 error, this due to initializeSonatypeStagingRepository task failed

* add workaround solution - comment maven publish block and only uncomment during publish task
 This is due to icon java plugin is only compatible with older plugin import syntax while nexus-publish plugin only works in new plugin import syntax

* add sonatype group properties variable - GROUP

* bump version - xcall-lib to 0.1.2

* docs: add maven badge and gradle implementation in README

* fix: remove unnecessary comments (#72)

* fix: remove unnecessary comment

* chore: pass build

---------

Co-authored-by: sabinchitrakar <[email protected]>

* chore: find and replace xCall -> xcall-multi in md files (#52)

* ci: enable release in an action (#103)

---------

Co-authored-by: gcranju <[email protected]>
Co-authored-by: AntonAndell <[email protected]>
Co-authored-by: ibrizsabin <[email protected]>
Co-authored-by: DeepakBomjan <[email protected]>
Co-authored-by: sabinchitrakar <[email protected]>
  • Loading branch information
6 people authored Oct 4, 2023
1 parent 7958fda commit caaf7a0
Show file tree
Hide file tree
Showing 21 changed files with 264 additions and 73 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/publish_maven.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Publish package to the Maven Central Repository

on:
release:
types: [created]

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build jar
working-directory: contracts/javascore
run: ./gradlew clean build
- name: Publish package
working-directory: contracts/javascore
run: |
# Temporary workaround - uncomment maven publish block
sed -i 's/^\/\/ //' build.gradle
./gradlew xcall-lib:publishToSonatype closeAndReleaseSonatypeStagingRepository
env:
STAGING_PROFILE_ID : ${{ secrets.STAGING_PROFILE_ID }}
OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }}
OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }}
ORG_GRADLE_PROJECT_signingKey : ${{ secrets.SIGNING_KEY }}
ORG_GRADLE_PROJECT_signingPassword : ${{ secrets.SIGNING_PASSWORD }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ jobs:
body: |
${{ steps.Changelog.outputs.changelog }}
draft: false
prerelease: true
prerelease: false

- name: Upload Javascore contracts to release
uses: svenstaro/upload-release-action@v2
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Contributing to XCall
# Contributing to xcall-multi

The following is a set of guidelines for contributing to XCall.
The following is a set of guidelines for contributing to xcall-multi.

These guidelines are subject to change. Feel free to propose changes to this document in a pull request.

Expand All @@ -14,7 +14,7 @@ Before sending your pull requests, make sure you do the following:

## Code of Conduct

The XCall project is governed by the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md). Participants are expected to uphold this code.
The xcall-multi project is governed by the [Contributor Covenant Code of Conduct](https://www.contributor-covenant.org/version/2/1/code_of_conduct/code_of_conduct.md). Participants are expected to uphold this code.

## Questions

Expand All @@ -31,17 +31,17 @@ We have a vibrant developer community and several community resources to ask que

### Reporting Bugs

Before creating bug reports, please check **[our list of issues](https://github.com/icon-project/xCall/issues)** to see if an
Before creating bug reports, please check **[our list of issues](https://github.com/icon-project/xcall-multi/issues)** to see if an
issue already exists.

> **Note:** For existing issues, please add a comment to the existing issue instead of opening a new issue. If the issue is closed and
> the problem persists, please open a new issue and include a link to the original issue in the body of your new one.
When you are creating a bug report, please fill out [the required template](https://github.com/icon-project/xCall/blob/main/.github/ISSUE_TEMPLATE/bug.md) and include as many details as possible.
When you are creating a bug report, please fill out [the required template](https://github.com/icon-project/xcall-multi/blob/main/.github/ISSUE_TEMPLATE/bug.md) and include as many details as possible.

### Contributing Code

If you want to contribute, start working through the xCall repository, navigate to the Github "issues" tab and start looking through issues. We recommend issues labeled "good first issue". These are issues that we believe are particularly well suited for newcomers. If you decide to start on an issue, leave a comment so that other people know that you're working on it. If you want to help out, but not alone, use the issue comment thread to coordinate.
If you want to contribute, start working through the xcall-multi repository, navigate to the Github "issues" tab and start looking through issues. We recommend issues labeled "good first issue". These are issues that we believe are particularly well suited for newcomers. If you decide to start on an issue, leave a comment so that other people know that you're working on it. If you want to help out, but not alone, use the issue comment thread to coordinate.

Please see the [ICON Foundation Development Guidelines](https://github.com/icon-project/community/blob/main/guidelines/technical-development/development-guidelines.md)
for information regarding our development standards and practices.
Expand Down
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
[![Project Status: Initial Release](https://img.shields.io/badge/repo%20status-active-green.svg?style=flat-square)](https://www.repostatus.org/#active)
[![License: Apache-2.0](https://img.shields.io/github/license/icon-project/xCall.svg?style=flat-square)](https://github.com/icon-project/xCall/blob/main/LICENSE)
[![Lines Of Code](https://img.shields.io/tokei/lines/github/icon-project/xCall?style=flat-square)](https://github.com/icon-project/xCall)
[![Version](https://img.shields.io/github/tag/icon-project/xCall.svg?style=flat-square)](https://github.com/icon-project/xCall)
![GitHub Workflow Status - cosmwasm](https://github.com/icon-project/xCall/actions/workflows/build-and-publish-cosmwasm.yml/badge.svg)
![GitHub Workflow Status - javascore](https://github.com/icon-project/xCall/actions/workflows/build-and-publish-javascore.yml/badge.svg)
[![License: Apache-2.0](https://img.shields.io/github/license/icon-project/xcall-multi.svg?style=flat-square)](https://github.com/icon-project/xcall-multi/blob/main/LICENSE)
[![Lines Of Code](https://img.shields.io/tokei/lines/github/icon-project/xcall-multi?style=flat-square)](https://github.com/icon-project/xcall-multi)
[![Version](https://img.shields.io/github/tag/icon-project/xcall-multi.svg?style=flat-square)](https://github.com/icon-project/xcall-multi)
![GitHub Workflow Status - cosmwasm](https://github.com/icon-project/xcall-multi/actions/workflows/build-and-publish-cosmwasm.yml/badge.svg)
![GitHub Workflow Status - javascore](https://github.com/icon-project/xcall-multi/actions/workflows/build-and-publish-javascore.yml/badge.svg)
| Language | Code Coverage |
| ----------------------------------- | ---------------------------------------------- |
| [Java](./contracts/javascore) | [![Java Cov][java-cov-badge]][java-cov-link] |
| [Rust](./contracts/cosmwasm-vm) | [![Rust Cov][rust-cov-badge]][rust-cov-link] |

[java-cov-link]: https://app.codecov.io/gh/icon-project/xCall/tree/main/contracts/javascore
[rust-cov-link]: https://app.codecov.io/gh/icon-project/xCall/tree/main/contracts/cosmwasm-vm
[java-cov-badge]: https://codecov.io/gh/icon-project/xCall/branch/main/graph/badge.svg?token=KWDB59JITE&flag=java
[rust-cov-badge]: https://codecov.io/gh/icon-project/xCall/branch/main/graph/badge.svg?token=KWDB59JITE&flag=rust
[java-cov-link]: https://app.codecov.io/gh/icon-project/xcall-multi/tree/main/contracts/javascore
[rust-cov-link]: https://app.codecov.io/gh/icon-project/xcall-multi/tree/main/contracts/cosmwasm-vm
[java-cov-badge]: https://codecov.io/gh/icon-project/xcall-multi/branch/main/graph/badge.svg?token=KWDB59JITE&flag=java
[rust-cov-badge]: https://codecov.io/gh/icon-project/xcall-multi/branch/main/graph/badge.svg?token=KWDB59JITE&flag=rust

# XCall
XCall is a cross chain messaging service built to mimic regular transaction flows across any interoperable solution.
# xcall-multi
xcall-multi is a cross chain messaging service built to mimic regular transaction flows across any interoperable solution.

For full xCall specification see [XCall Spec](./docs/adr/xcall.md).
For full xcall-multi specification see [xcall-multi Spec](./docs/adr/xcall.md).

## Building with xCall
For building dapps with xCall see official developer [docs](https://www.xcall.dev/).
## Building with xcall-multi
For building dapps with xcall-multi see official developer [docs](https://www.xcall.dev/).

### Project Structure
| Directory | Description |
Expand All @@ -33,13 +33,13 @@ For building dapps with xCall see official developer [docs](https://www.xcall.de


## Available Connection implementations
* [IBC](https://github.com/icon-project/IBC-Integration/blob/main/docs/adr/XCall_IBC_Connection.md)
* [IBC](https://github.com/icon-project/IBC-Integration/blob/main/docs/adr/xcall-multi_IBC_Connection.md)
* [Rust](https://github.com/icon-project/IBC-Integration/tree/main/contracts/cosmwasm-vm/cw-xcall-ibc-connection)
* [Java](https://github.com/icon-project/IBC-Integration/tree/main/contracts/javascore/xcall-connection)
* [BTP](https://github.com/icon-project/btp2) is supported natively and does not need a connection contract.

## Building a xCall connection
If xCall is deployed, anyone can create a new connection contract to relay messages between xCall contracts.
## Building a xcall-multi connection
If xcall-multi is deployed, anyone can create a new connection contract to relay messages between xcall-multi contracts.
To do this a connection contract has to be developed and deployed on both sides.

The base design for a connection can be found in the [xCall docs](./docs/adr/xcall.md#Connections)
The base design for a connection can be found in the [xcall-multi docs](./docs/adr/xcall.md#Connections)
2 changes: 1 addition & 1 deletion contracts/cosmwasm-vm/cw-xcall-lib/src/xcall_msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub enum ExecuteMsg {
destinations: Option<Vec<String>>,
},
HandleMessage {
from: NetId,
from_nid: NetId,
msg: Vec<u8>,
},

Expand Down
5 changes: 1 addition & 4 deletions contracts/cosmwasm-vm/cw-xcall/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,7 @@ impl<'a> CwCallService<'a> {
///
/// Returns:
///
/// a `Result<Response, ContractError>`. If the `admin` parameter is empty, it returns an `Err` with
/// the `ContractError::AdminAddressCannotBeNull` variant. If the `info.sender` is not the owner, it
/// returns an `Err` with the `ContractError::Unauthorized` variant. If an admin already exists, it
/// returns an `Err` with
/// a `Result<Response, ContractError>`
pub fn set_admin(
&self,
store: &mut dyn Storage,
Expand Down
4 changes: 2 additions & 2 deletions contracts/cosmwasm-vm/cw-xcall/src/assertion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<'a> CwCallService<'a> {
///
/// * `rollback`: `rollback` is a slice of bytes (`&[u8]`) that represents the data to be rolled back in
/// a smart contract. The function `ensure_rollback_length` checks if the length of the `rollback` slice
/// is within the maximum allowed size (`MAX_ROLLBACK_SIZE`) and
/// is within the maximum allowed size (`MAX_ROLLBACK_SIZE`) and is not empty.
///
/// Returns:
///
Expand Down Expand Up @@ -199,7 +199,7 @@ impl<'a> CwCallService<'a> {
/// smart contract on the blockchain or not. It does this by querying the blockchain through the
/// `querier` object to get information about the contract at the given `address`. If the query is
/// successful, it returns `true`, indicating that the address is a valid contract. If the query fails,
/// it returns `
/// it returns false `
fn is_contract(querier: QuerierWrapper, address: &Addr) -> bool {
querier.query_wasm_contract_info(address).is_ok()
}
13 changes: 6 additions & 7 deletions contracts/cosmwasm-vm/cw-xcall/src/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,18 @@ impl<'a> CwCallService<'a> {
/// Arguments:
///
/// * `deps`: `deps` is a `DepsMut` object, which is short for "dependencies mutable". It is a struct
/// that provides access to the contract's dependencies, such as the storage, API, and querier. The
/// `DepsMut` object is passed as a parameter to most of the
/// that provides access to the contract's dependencies, such as the storage, API, and querier.
/// * `_env`: The `_env` parameter in the `instantiate` function is of type `Env`, which represents
/// the environment in which the contract is being executed. It contains information such as the
/// current block height, the current time, and the address of the contract being executed. However,
/// in the given code snippet
/// * `info`: `info` is a struct that contains information about the message sender, such as their
/// address, the amount of tokens they sent with the message, and the maximum amount of gas they are
/// willing to pay for the transaction. This information can be used to determine whether the sender
/// is authorized to perform certain actions
/// is authorized to perform certain actions.
/// * `msg`: The `msg` parameter in the `instantiate` function is of type `InstantiateMsg` and
/// contains the message sent by the user when instantiating the contract. It can contain any custom
/// data that the user wants to pass to the contract during instantiation. The `msg` parameter is
/// used by the
///
/// data that the user wants to pass to the contract during instantiation.
/// Returns:
///
/// The `instantiate` function returns a `Result<Response, ContractError>` where `Response` is a
Expand Down Expand Up @@ -97,7 +94,9 @@ impl<'a> CwCallService<'a> {
let dests = destinations.unwrap_or(vec![]);
self.send_call_message(deps, info, env, to, data, rollback, sources, dests)
}
ExecuteMsg::HandleMessage { msg, from } => self.handle_message(deps, info, from, msg),
ExecuteMsg::HandleMessage { msg, from_nid } => {
self.handle_message(deps, info, from_nid, msg)
}
ExecuteMsg::HandleError { sn } => self.handle_error(deps, info, sn),
ExecuteMsg::ExecuteCall { request_id, data } => {
self.execute_call(deps, info, request_id, data)
Expand Down
3 changes: 1 addition & 2 deletions contracts/cosmwasm-vm/cw-xcall/src/execute_rollback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ use cosmwasm_std::{Env, Response};

use crate::error::ContractError;
use crate::events::event_rollback_executed;
use crate::state::CwCallService;
use crate::state::EXECUTE_ROLLBACK_ID;
use crate::state::{CwCallService, EXECUTE_ROLLBACK_ID};

impl<'a> CwCallService<'a> {
/// This function executes a rollback operation for a previously made call request.
Expand Down
12 changes: 12 additions & 0 deletions contracts/cosmwasm-vm/cw-xcall/src/fees.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use cosmwasm_std::Coin;
use cw_xcall_lib::network_address::NetId;

use super::*;
Expand Down Expand Up @@ -58,4 +59,15 @@ impl<'a> CwCallService<'a> {

Ok(protocol_fee + conn_total)
}

pub fn get_total_paid(&self, deps: Deps, coins: &Vec<Coin>) -> Result<u128, ContractError> {
let config = self.get_config(deps.storage)?;
let mut total = 0_u128;
for c in coins.iter() {
if c.denom == config.denom {
total += c.amount.u128();
}
}
Ok(total)
}
}
4 changes: 2 additions & 2 deletions contracts/cosmwasm-vm/cw-xcall/src/handle_call_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ impl<'a> CwCallService<'a> {
&self,
deps: DepsMut,
info: MessageInfo,
from: NetId,
from_nid: NetId,
message: Vec<u8>,
) -> Result<Response, ContractError> {
let call_service_message: CSMessage = CSMessage::try_from(message)?;

match call_service_message.message_type() {
CallServiceMessageType::CallServiceRequest => {
self.handle_request(deps, info, from, call_service_message.payload())
self.handle_request(deps, info, from_nid, call_service_message.payload())
}
CallServiceMessageType::CallServiceResponse => {
self.handle_response(deps, info, call_service_message.payload())
Expand Down
2 changes: 1 addition & 1 deletion contracts/cosmwasm-vm/cw-xcall/src/requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ impl<'a> CwCallService<'a> {
/// * `store`: `store` is a reference to a trait object of type `dyn Storage`. This is an abstract
/// type that represents a key-value store where data can be persisted. In the context of smart
/// contract development on the CosmWasm platform, `store` is typically provided by the runtime
/// environment and is
/// environment.
///
/// Returns:
///
Expand Down
17 changes: 14 additions & 3 deletions contracts/cosmwasm-vm/cw-xcall/src/send_call_message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ impl<'a> CwCallService<'a> {

let message: CSMessage = call_request.into();
let sn: i64 = if need_response { sequence_no as i64 } else { 0 };
let mut total_spent = 0_u128;

let submessages = confirmed_sources
.iter()
Expand All @@ -68,6 +69,7 @@ impl<'a> CwCallService<'a> {
.query_connection_fee(deps.as_ref(), to.nid(), need_response, r)
.and_then(|fee| {
let fund = if fee > 0 {
total_spent = total_spent.checked_add(fee).unwrap();
coins(fee, config.denom.clone())
} else {
vec![]
Expand All @@ -78,8 +80,16 @@ impl<'a> CwCallService<'a> {
});
})
.collect::<Result<Vec<SubMsg>, ContractError>>()?;
let protocol_fee = self.get_protocol_fee(deps.storage);

let total_paid = self.get_total_paid(deps.as_ref(), &info.funds)?;
let fee_handler = self.fee_handler().load(deps.storage)?;
let protocol_fee = self.get_protocol_fee(deps.as_ref().storage);
let total_fee_required = protocol_fee + total_spent;

if total_paid < total_fee_required {
return Err(ContractError::InsufficientFunds);
}
let remaining = total_paid - total_spent;

let event = event_xcall_message_sent(caller.to_string(), to.to_string(), sequence_no);
println!("{LOG_PREFIX} Sent Bank Message");
Expand All @@ -89,13 +99,14 @@ impl<'a> CwCallService<'a> {
.add_attribute("method", "send_packet")
.add_attribute("sequence_no", sequence_no.to_string())
.add_event(event);
if protocol_fee > 0 {
if remaining > 0 {
let msg = BankMsg::Send {
to_address: fee_handler,
amount: coins(protocol_fee, config.denom),
amount: coins(remaining, config.denom),
};
res = res.add_message(msg);
}

Ok(res)
}
}
Loading

0 comments on commit caaf7a0

Please sign in to comment.