Skip to content

Commit

Permalink
Merge pull request #387 from andkononykhin/rc-0.10.0
Browse files Browse the repository at this point in the history
[ST-553] Release candidate for 0.10.0
  • Loading branch information
jovfer authored May 31, 2019
2 parents 2ce0d54 + d8746a8 commit e820bba
Show file tree
Hide file tree
Showing 48 changed files with 815 additions and 261 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 0.10.0
* Updated `build_set_txn_fees_handler` function to accept any aliases.
* Updated `build_payment_req_handler` function to accept and to handle `Transaction Author Agreement` passed inside `extra_json`.
* bugfixes

## 0.9.7
* Updated logging initialization to use libindy pattern.
* bugfixes
Expand Down
2 changes: 1 addition & 1 deletion devops/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ FPM_P_VENDOR := Sovrin
FPM_P_DESCRIPTION := libsovtoken written in Rust
FPM_P_NAME = $(PACKAGE_NAME)
FPM_P_VERSION ?= $(SRC_VERSION)
FPM_P_DEPENDS = libindy(>=1.8.3)
FPM_P_DEPENDS = libindy(>=1.9.0)
FPM_P_OUTPUT_DIR = $(LIB_TARGET_DIR)
FPM_ARGS = $(LIB_DYNAMIC)=/usr/lib/

Expand Down
4 changes: 2 additions & 2 deletions devops/aws-codebuild/Jenkinsfile.cd
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ gitHubUserCredId = env.GITHUB_BOT_USER ?: 'sovbot-github'
sovrinPackagingRepo = env.SOVRIN_PACKAGING_REPO ?: 'https://github.com/sovrin-foundation/sovrin-packaging'
sovrinPackagingBranch = env.SOVRIN_PACKAGING_BRANCH ?: 'master'
LIBINDY_STREAM = "stable"
LIBINDY_VERSION = "1.8.3"
LIBINDY_VERSION = "1.9.0"

def downloadPackagingUtils() {
git branch: sovrinPackagingBranch, credentialsId: gitHubUserCredId, url: sovrinPackagingRepo
Expand Down Expand Up @@ -512,4 +512,4 @@ def getSuffix() {

def setupRust() {
shell("rustup default 1.32.0")
}
}
2 changes: 1 addition & 1 deletion devops/aws-codebuild/Jenkinsfile.ci
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ logger = sovLibrary.Logger.new(this)
notifier = sovLibrary.Notifier.new(this)
logger.setGlobalLevel('TRACE')
LIBINDY_STREAM = "stable"
LIBINDY_VERSION = "1.8.3"
LIBINDY_VERSION = "1.9.0"

def nodeLabels = [
codeBuild: env.LIBSOVTOKEN_CODEBUILD_NODE_LABEL ?: 'codebuild',
Expand Down
4 changes: 2 additions & 2 deletions devops/docker/base/xenial/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ RUN cd /tmp \
# need for libsodium to be reachable via pkg-config (sodiumoxide uses it)
ENV PKG_CONFIG_PATH /usr/local/lib/pkgconfig:$PKG_CONFIG_PATH # TODO ??? is it really needed

ENV LIBINDY_VERSION=1.8.3
ENV LIBINDY_VERSION=1.9.0
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 68DB5E88 \
&& echo "deb https://repo.sovrin.org/sdk/deb xenial stable" >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y --no-install-recommends \
Expand All @@ -47,4 +47,4 @@ RUN cd /tmp/libsovtoken \
# TODO CMD ENTRYPOINT ...


ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.20.0
ENV LIBSOVTOKEN_BASE_ENV_VERSION=0.25.0
10 changes: 5 additions & 5 deletions devops/docker/ci/xenial/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM sovrin/libsovtoken:base-xenial-0.20.0
FROM sovrin/libsovtoken:base-xenial-0.25.0
# TODO LABEL maintainer="Name <email-address>"

ARG LIBINDY_CRYPTO_VERSION
Expand Down Expand Up @@ -36,10 +36,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
# or python3-rocksdb are not specified here)
ENV LIBINDY_CRYPTO_VERSION ${LIBINDY_CRYPTO_VERSION:-0.4.5}
ENV PYTHON3_INDY_CRYPTO_VERSION ${PYTHON3_INDY_CRYPTO_VERSION:-0.4.5}
ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.6.53}
ENV INDY_PLENUM_VERSION ${INDY_PLENUM_VERSION:-1.8.0}
ENV INDY_ANONCREDS_VERSION ${INDY_ANONCREDS_VERSION:-1.0.11}
ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.6.78}
ENV TOKEN_VER ${TOKEN_VER:-0.9.5}
ENV INDY_NODE_VERSION ${INDY_NODE_VERSION:-1.8.0}
ENV TOKEN_VER ${TOKEN_VER:-0.9.12}
RUN echo "deb https://repo.sovrin.org/sdk/deb xenial stable" >> /etc/apt/sources.list
RUN echo "deb https://repo.sovrin.org/deb xenial stable" >> /etc/apt/sources.list \
&& apt-get update && apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -69,4 +69,4 @@ COPY libsovtoken-ci-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/libsovtoken-ci-entrypoint.sh
ENTRYPOINT ["libsovtoken-ci-entrypoint.sh"]

ENV LIBSOVTOKEN_CI_ENV_VERSION=0.56.0
ENV LIBSOVTOKEN_CI_ENV_VERSION=0.60.0
12 changes: 6 additions & 6 deletions devops/indy-pool/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ FROM camparra/ubuntu16.04-rocksdb

ARG uid=1000

ARG indy_stream=master
ARG indy_stream=stable


ARG indy_plenum_ver=1.6.735
ARG indy_node_ver=1.6.874
ARG indy_anoncreds_ver=1.0.32
ARG indy_plenum_ver=1.8.0
ARG indy_node_ver=1.8.0
ARG indy_anoncreds_ver=1.0.11
ARG python3_indy_crypto_ver=0.4.5
ARG indy_crypto_ver=0.4.5
ARG token_ver=0.9.6~2
ARG fees_ver=0.9.6~2
ARG token_ver=0.9.12
ARG fees_ver=0.9.12

# Install environment
RUN apt-get update -y && apt-get install -y \
Expand Down
7 changes: 4 additions & 3 deletions libsovtoken/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "libsovtoken"

version = "0.9.8"
version = "0.10.0"

authors = [
"Matt Raffel <[email protected]",
Expand All @@ -28,14 +28,15 @@ libc = "0.2.41"
log = "0.4.6"
openssl = "0.10.20"
rand = "0.3"
indy-sys = "1.8.3"
indy = "1.8.3"
indy-sys = "1.9.0"
indy = "1.9.0"
serde = "1.0.89"
serde_derive = "1.0.89"
serde_json = "1.0.39"
sha2 = "0.8.0"
sha3 = "0.8.0"
sodiumoxide = "0.0.16"
time = "0.1.42"


[dev-dependencies]
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
libindy=1.8.3=stable
libindy=1.9.0=stable
2 changes: 1 addition & 1 deletion libsovtoken/build_scripts/ios/mac/shared.functions.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.8.3/libindy.tar.gz"
export LIBINDY_IOS_BUILD_URL="https://repo.sovrin.org/ios/libindy/stable/libindy-core/1.9.0/libindy.tar.gz"
export LIBINDY_FILE=$(basename ${LIBINDY_IOS_BUILD_URL})
export LIBINDY_VERSION=$(basename $(dirname ${LIBINDY_IOS_BUILD_URL}))
export BUILD_CACHE=~/.build_libvxc/ioscache
Expand Down
30 changes: 16 additions & 14 deletions libsovtoken/src/api/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ pub extern "C" fn add_request_fees_handler(
cb: JsonCallback
) -> i32 {

trace!("api::add_request_fees_handler called did (address) >> {:?}", did);
trace!("api::add_request_fees_handler called did (address) >> {:?}", secret!(&did));
let (inputs, outputs, extra, request_json_map, cb) = match add_request_fees::deserialize_inputs(req_json, inputs_json, outputs_json, extra, cb) {
Ok(tup) => tup,
Err(error_code) => {
Expand Down Expand Up @@ -357,21 +357,22 @@ pub extern "C" fn build_payment_req_handler(
extra: *const c_char,
cb: JsonCallback
) -> i32 {
trace!("api::build_payment_req_handler called >> submitter_did (address) {:?}", submitter_did);
let (inputs, outputs, extra, cb) = match build_payment::deserialize_inputs(inputs_json, outputs_json, extra, cb) {
Ok(tup) => tup,
Err(error_code) => {
trace!("api::build_payment_req_handler << result: {:?}", error_code);
return error_code as i32;
}
};
trace!("api::build_payment_req_handler called >> submitter_did (address) {:?}", secret!(&submitter_did));
let (inputs, outputs, extra, submitter_did, cb) =
match build_payment::deserialize_inputs(inputs_json, outputs_json, extra, submitter_did, cb) {
Ok(tup) => tup,
Err(error_code) => {
trace!("api::build_payment_req_handler << result: {:?}", error_code);
return error_code as i32;
}
};

let payload = XferPayload::new(inputs, outputs, extra);

let result = payload.sign_transfer(
&CryptoSdk {},
wallet_handle,
Box::new(move |result| build_payment::handle_signing(command_handle, result, cb))
Box::new(move |result| build_payment::handle_signing(command_handle, result, submitter_did.clone(), cb))
);

let ec = match result {
Expand Down Expand Up @@ -479,7 +480,7 @@ pub extern "C" fn build_get_utxo_request_handler(command_handle: i32,
return ErrorCode::CommonInvalidStructure as i32;
}
};
debug!("api::build_get_utxo_request_handler >> wallet_handle: {:?}, payment_address: {:?}", wallet_handle, payment_address);
debug!("api::build_get_utxo_request_handler >> wallet_handle: {:?}, payment_address: {:?}", wallet_handle, secret!(&payment_address));

let utxo_request =
GetUtxoOperationRequest::new(String::from(payment_address));
Expand Down Expand Up @@ -656,15 +657,16 @@ pub extern "C" fn build_get_txn_fees_handler(
did.validate().map_err(map_err_trace!()).or(Err(ErrorCode::CommonInvalidStructure))
});

debug!("api::build_get_txn_fees_handler >> wallet_handle: {:?}, submitter_did: {:?}", wallet_handle, did);
debug!("api::build_get_txn_fees_handler >> wallet_handle: {:?}, submitter_did: {:?}", wallet_handle, secret!(&did));

let did = match opt_res_to_res_opt!(did) {
Ok(did) => did,
Err(e) => { return e as i32; }
Err(_) => None
};

let did = Some(did.unwrap_or(Did::new("LibsovtokenDid11111111".to_string())));

let get_txn_request = GetFeesRequest::new().as_request(did);
info!("Built GET_TXN_FEES request: {:?}", get_txn_request);

let request_pointer = match get_txn_request.serialize_to_pointer() {
Ok(p) => p,
Expand Down
4 changes: 3 additions & 1 deletion libsovtoken/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ extern crate rand;
extern crate serde;
extern crate sodiumoxide;
extern crate sha2;
extern crate time;
// ------------------------------------------
// crates from crate.io etc that require macro
// ------------------------------------------
Expand All @@ -33,7 +34,8 @@ extern crate sha2;
// ------------------------------------------

extern crate indy_sys; // lib-sdk project
extern crate indyrs as indy; // lib-sdk rust wrapper to get ErrorCodes
extern crate indyrs as indy;
extern crate core; // lib-sdk rust wrapper to get ErrorCodes

// ------------------------------------------
// define our crate by defining the modules in the project
Expand Down
36 changes: 21 additions & 15 deletions libsovtoken/src/logic/api_internals/add_request_fees.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
use ErrorCode;
use libc::c_char;
use logic::xfer_payload::{XferPayload, serialize_signature};
use logic::xfer_payload::{XferPayload, Extra, serialize_signature};
use logic::input::Inputs;
use logic::output::Outputs;
use serde_json;
Expand All @@ -11,12 +11,13 @@ use logic::indy_sdk_api::crypto_api::CryptoSdk;
use utils::constants::txn_types::XFER_PUBLIC;
use utils::constants::txn_fields::FEES;
use utils::constants::general::JsonCallbackUnwrapped;
use utils::txn_author_agreement::TaaAcceptance;
use sha2::{Sha256, Digest};
use hex::ToHex;

type SerdeMap = serde_json::Map<String, serde_json::value::Value>;
type AddRequestFeesCb = extern fn(command_handle_: i32, err: i32, req_with_fees_json: *const c_char) -> i32;
type DeserializedArguments = (Inputs, Outputs, Option<String>, SerdeMap, AddRequestFeesCb);
type DeserializedArguments = (Inputs, Outputs, Option<Extra>, SerdeMap, AddRequestFeesCb);

/**
* Deserializes arguments of [`add_request_fees_handler`]
Expand All @@ -28,35 +29,40 @@ pub fn deserialize_inputs (
extra: *const c_char,
cb: Option<AddRequestFeesCb>
) -> Result<DeserializedArguments, ErrorCode> {
debug!("logic::add_request_fees::deserialize_inputs >> req_json: {:?}, inputs_json: {:?}, outputs_json: {:?}", req_json, inputs_json, outputs_json);
debug!("logic::add_request_fees::deserialize_inputs >> req_json: {:?}, inputs_json: {:?}, outputs_json: {:?}", secret!(&req_json), secret!(&inputs_json), secret!(&outputs_json));

let cb = cb.ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;

let request_json = string_from_char_ptr(req_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
debug!("Converted request_json pointer into string >>> {:?}", request_json);
debug!("Converted request_json pointer into string >>> {:?}", secret!(&request_json));

let inputs_json = string_from_char_ptr(inputs_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
debug!("Converted inputs_json pointer to string >>> {:?}", inputs_json);
debug!("Converted inputs_json pointer to string >>> {:?}", secret!(&inputs_json));

let outputs_json = string_from_char_ptr(outputs_json).ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
debug!("Converted outputs_json pointer to string >>> {:?}", outputs_json);
debug!("Converted outputs_json pointer to string >>> {:?}", secret!(&outputs_json));

let extra = string_from_char_ptr(extra);
debug!("Converted extra pointer to string >>> {:?}", extra);

let inputs: Inputs = serde_json::from_str(&inputs_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
debug!("Deserialized input_json >>> {:?}", inputs);
debug!("Deserialized input_json >>> {:?}", secret!(&inputs));

let outputs: Outputs = serde_json::from_str(&outputs_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
debug!("Deserialized output_json >>> {:?}", outputs);
debug!("Deserialized output_json >>> {:?}", secret!(&outputs));

let extra: Option<Extra> = if let Some(extra_) = extra {
serde_json::from_str(&extra_).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?
} else { None };
debug!("Deserialized extra >>> {:?}", secret!(&extra));

let request_json_object: serde_json::Value = serde_json::from_str(&request_json).map_err(map_err_err!()).or(Err(ErrorCode::CommonInvalidStructure))?;
trace!("Converted request_json to serde::json::Value");

let request_json_map = request_json_object.as_object().ok_or(ErrorCode::CommonInvalidStructure).map_err(map_err_err!())?;
trace!("Converted request_json to hash_map");

debug!("Deserialized values: inputs: {:?}, outputs: {:?}, request_json_map: {:?}", inputs, outputs, request_json_map);
debug!("Deserialized values: inputs: {:?}, outputs: {:?}, request_json_map: {:?}", secret!(&inputs), secret!(&outputs), secret!(&request_json_map));
return Ok((
inputs,
outputs,
Expand Down Expand Up @@ -87,11 +93,11 @@ pub fn add_fees_to_request_and_serialize(
wallet_handle: i32,
inputs: Inputs,
outputs: Outputs,
extra: Option<String>,
extra: Option<Extra>,
request_json_map: SerdeMap,
cb: Box<Fn(Result<String, ErrorCode>) + Send + Sync>
) -> Result<(), ErrorCode> {
trace!("logic::add_request_fees::add_fees_to_request_and_serialize >> wallet_handle: {:?}, inputs: {:?}, outputs: {:?}, request_json_map: {:?}", wallet_handle, inputs, outputs, request_json_map);
trace!("logic::add_request_fees::add_fees_to_request_and_serialize >> wallet_handle: {:?}, inputs: {:?}, outputs: {:?}, request_json_map: {:?}", wallet_handle, secret!(&inputs), secret!(&outputs), secret!(&request_json_map));
let res = add_fees(wallet_handle, inputs, outputs, extra, request_json_map, Box::new(move |request_json_map_updated|{
let rm_fees = request_json_map_updated.map(|request_json_map_with_fees| serialize_request_with_fees(request_json_map_with_fees));
match rm_fees {
Expand Down Expand Up @@ -123,15 +129,15 @@ pub fn closure_cb_response(command_handle: i32, cb: JsonCallbackUnwrapped) -> im
KEEP all public methods above
*/

fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<String>, request_json_map: SerdeMap, cb: Box<Fn(Result<SerdeMap, ErrorCode>) + Send + Sync>) -> Result<(), ErrorCode> {
fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<serde_json::Value>, request_json_map: SerdeMap, cb: Box<Fn(Result<SerdeMap, ErrorCode>) + Send + Sync>) -> Result<(), ErrorCode> {
let txn_serialized = serialize_signature(request_json_map.clone().into())?;
let mut hasher = Sha256::default();
hasher.input(txn_serialized.as_bytes());
let txn_digest = Some(hasher.result().to_hex());
signed_fees(wallet_handle, inputs, outputs, extra, &txn_digest, Box::new(move |fees| {
trace!("Added fees to request_json.");
match fees {
Ok(fees) => {
Ok((fees, _)) => {
let mut map = request_json_map.clone();
map.insert(FEES.to_string(), json!([fees.inputs, fees.outputs, fees.signatures]));
cb(Ok(map.clone()));
Expand All @@ -146,15 +152,15 @@ fn add_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<
}

fn serialize_request_with_fees(request_json_map_with_fees: SerdeMap) -> Result<String, ErrorCode> {
trace!("fee_map: {:?}", request_json_map_with_fees);
trace!("fee_map: {:?}", secret!(&request_json_map_with_fees));
let serialized_request_with_fees = serde_json::to_string(&json!(request_json_map_with_fees))
.or(Err(ErrorCode::CommonInvalidStructure))?;
trace!("Serialized request_with_fees");

return Ok(serialized_request_with_fees);
}

fn signed_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<String>, txn_digest: &Option<String>, cb: Box<Fn(Result<XferPayload, ErrorCode>) + Send + Sync>) -> Result<(), ErrorCode> {
fn signed_fees(wallet_handle: i32, inputs: Inputs, outputs: Outputs, extra: Option<Extra>, txn_digest: &Option<String>, cb: Box<Fn(Result<(XferPayload, Option<TaaAcceptance>), ErrorCode>) + Send + Sync>) -> Result<(), ErrorCode> {
let fees = XferPayload::new(inputs, outputs, extra);
fees.sign_fees(&CryptoSdk{}, wallet_handle, txn_digest, cb)?;
Ok(())
Expand Down
6 changes: 3 additions & 3 deletions libsovtoken/src/logic/api_internals/create_address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ pub fn deserialize_arguments(
.ok_or(ErrorCode::CommonInvalidStructure)
.map_err(map_err_err!())?;

debug!("api::create_payment_address_handler json_config_string >> {:?}", json_config_string);
debug!("api::create_payment_address_handler json_config_string >> {:?}", secret!(&json_config_string));

// TODO: Only continue when seed is missing, not on any error.
let config = PaymentAddressConfig::from_json(&json_config_string)
.map_err(map_err_trace!())
.unwrap_or(PaymentAddressConfig { seed: "".to_string() });

debug!("api::create_payment_address_handler PaymentAddressConfig >> {:?}", config);
debug!("api::create_payment_address_handler PaymentAddressConfig >> {:?}", secret!(&config));

Ok((config, cb))
}
Expand All @@ -52,7 +52,7 @@ pub fn create_address_cb(command_handle: i32, cb: JsonCallbackUnwrapped) -> impl
return;
}

debug!("create_payment_address_handler returning payment address of '{}'", &payment_address);
debug!("create_payment_address_handler returning payment address of '{}'", secret!(&payment_address));
let payment_address_cstring = cstring_from_str(payment_address);
let payment_address_ptr = payment_address_cstring.as_ptr();

Expand Down
Loading

0 comments on commit e820bba

Please sign in to comment.