Skip to content

Commit

Permalink
Version Info API Function tweak, remove 'min_compat_version' from sla…
Browse files Browse the repository at this point in the history
…te (mimblewimble#123)

* change slate version function to return list of supported slate formats

* rustfmt

* remove min_compat_version
  • Loading branch information
yeastplume authored May 30, 2019
1 parent 88e875d commit df720d1
Show file tree
Hide file tree
Showing 10 changed files with 43 additions and 37 deletions.
20 changes: 20 additions & 0 deletions Cargo.lock

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

17 changes: 8 additions & 9 deletions api/src/foreign_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ pub trait ForeignRpc {
"jsonrpc": "2.0",
"result": {
"Ok": {
"default_slate_version": 2,
"foreign_api_version": 2
"foreign_api_version": 2,
"supported_slate_versions": [
"V0",
"V1",
"V2"
]
}
}
}
Expand Down Expand Up @@ -168,7 +172,6 @@ pub trait ForeignRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -207,8 +210,7 @@ pub trait ForeignRpc {
{
"version_info": {
"version": 2,
"orig_version": 2,
"min_compat_version": 0
"orig_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
Expand Down Expand Up @@ -331,7 +333,6 @@ pub trait ForeignRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -365,8 +366,7 @@ pub trait ForeignRpc {
"params": [{
"version_info": {
"version": 2,
"orig_version": 2,
"min_compat_version": 0
"orig_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
Expand Down Expand Up @@ -499,7 +499,6 @@ pub trait ForeignRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down
10 changes: 1 addition & 9 deletions api/src/owner_rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -469,7 +468,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -533,7 +531,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -617,7 +614,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -686,7 +682,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -725,8 +720,7 @@ pub trait OwnerRpc {
{
"version_info": {
"version": 2,
"orig_version": 2,
"min_compat_version": 0
"orig_version": 2
},
"num_participants": 2,
"id": "0436430c-2b02-624c-2032-570501212b00",
Expand Down Expand Up @@ -860,7 +854,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down Expand Up @@ -1119,7 +1112,6 @@ pub trait OwnerRpc {
"offset": "d202964900000000d302964900000000d402964900000000d502964900000000"
},
"version_info": {
"min_compat_version": 0,
"orig_version": 2,
"version": 2
}
Expand Down
2 changes: 2 additions & 0 deletions libwallet/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ log = "0.4"
uuid = { version = "0.7", features = ["serde", "v4"] }
chrono = { version = "0.4.4", features = ["serde"] }
lazy_static = "1"
strum = "0.15"
strum_macros = "0.15"

grin_wallet_util = { path = "../util", version = "1.1.0-beta.3" }

Expand Down
8 changes: 5 additions & 3 deletions libwallet/src/api_impl/foreign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@
// limitations under the License.

//! Generic implementation of owner API functions
use strum::IntoEnumIterator;

use crate::grin_keychain::Keychain;
use crate::internal::{tx, updater};
use crate::slate_versions::SlateVersion;
use crate::{
slate_versions, BlockFees, CbData, Error, ErrorKind, NodeClient, Slate, TxLogEntryType,
VersionInfo, WalletBackend,
BlockFees, CbData, Error, ErrorKind, NodeClient, Slate, TxLogEntryType, VersionInfo,
WalletBackend,
};

const FOREIGN_API_VERSION: u16 = 2;
Expand All @@ -28,7 +30,7 @@ const USER_MESSAGE_MAX_LEN: usize = 256;
pub fn check_version() -> VersionInfo {
VersionInfo {
foreign_api_version: FOREIGN_API_VERSION,
default_slate_version: slate_versions::CURRENT_SLATE_VERSION,
supported_slate_versions: SlateVersion::iter().collect(),
}
}

Expand Down
3 changes: 2 additions & 1 deletion libwallet/src/api_impl/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use crate::grin_core::core::{Output, TxKernel};
use crate::grin_core::libtx::secp_ser;
use crate::grin_keychain::Identifier;
use crate::grin_util::secp::pedersen;
use crate::slate_versions::SlateVersion;
use crate::types::OutputData;

/// Send TX API Args
Expand Down Expand Up @@ -218,5 +219,5 @@ pub struct VersionInfo {
/// API version
pub foreign_api_version: u16,
/// Slate version
pub default_slate_version: u16,
pub supported_slate_versions: Vec<SlateVersion>,
}
4 changes: 4 additions & 0 deletions libwallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ extern crate log;
#[macro_use]
extern crate lazy_static;

extern crate strum;
#[macro_use]
extern crate strum_macros;

pub mod api_impl;
mod error;
mod internal;
Expand Down
9 changes: 0 additions & 9 deletions libwallet/src/slate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,6 @@ pub struct VersionCompatInfo {
pub version: u16,
/// Original version this slate was converted from
pub orig_version: u16,
/// Minimum version this slate is compatible with
pub min_compat_version: u16,
}

/// Helper just to facilitate serialization
Expand Down Expand Up @@ -240,7 +238,6 @@ impl Slate {
version_info: VersionCompatInfo {
version: CURRENT_SLATE_VERSION,
orig_version: CURRENT_SLATE_VERSION,
min_compat_version: 0,
},
}
}
Expand Down Expand Up @@ -816,15 +813,12 @@ impl From<&VersionCompatInfo> for VersionCompatInfoV2 {
let VersionCompatInfo {
version,
orig_version,
min_compat_version,
} = data;
let version = *version;
let orig_version = *orig_version;
let min_compat_version = *min_compat_version;
VersionCompatInfoV2 {
version,
orig_version,
min_compat_version,
}
}
}
Expand Down Expand Up @@ -969,15 +963,12 @@ impl From<&VersionCompatInfoV2> for VersionCompatInfo {
let VersionCompatInfoV2 {
version,
orig_version,
min_compat_version,
} = data;
let version = *version;
let orig_version = *orig_version;
let min_compat_version = *min_compat_version;
VersionCompatInfo {
version,
orig_version,
min_compat_version,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libwallet/src/slate_versions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub mod v2;
pub const CURRENT_SLATE_VERSION: u16 = 2;

/// Existing versions of the slate
#[derive(Debug, PartialEq, PartialOrd, Eq, Ord)]
#[derive(EnumIter, Serialize, Deserialize, Clone, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub enum SlateVersion {
/// V0
V0,
Expand Down
5 changes: 0 additions & 5 deletions libwallet/src/slate_versions/v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
//! * VersionCompatInfo struct created with fields and added to beginning of struct
//! version: u16
//! orig_verion: u16,
//! min_compat_version: u16
use crate::grin_core::core::transaction::{KernelFeatures, OutputFeatures};
use crate::grin_core::libtx::secp_ser;
Expand Down Expand Up @@ -84,8 +83,6 @@ pub struct VersionCompatInfoV2 {
pub version: u16,
/// Original version this slate was converted from
pub orig_version: u16,
/// Minimum version this slate is compatible with
pub min_compat_version: u16,
}

#[derive(Serialize, Deserialize, Debug, Clone)]
Expand Down Expand Up @@ -338,13 +335,11 @@ impl From<SlateV1> for SlateV2 {
} = slate;
let tx = TransactionV2::from(tx);
let version = 2;
let min_compat_version = 0;
let orig_version = orig_version as u16;
let participant_data = map_vec!(participant_data, |data| ParticipantDataV2::from(data));
let version_info = VersionCompatInfoV2 {
version,
orig_version,
min_compat_version,
};
SlateV2 {
num_participants,
Expand Down

0 comments on commit df720d1

Please sign in to comment.