-
Notifications
You must be signed in to change notification settings - Fork 20
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
add new platform user VC: daren market #2903
Changes from 3 commits
695bbdb
f2050e9
da86dc7
0b784b1
ed5d2a2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,15 +23,17 @@ use crate::assertion::network::{all_evm_web3networks, Web3Network}; | |
#[derive(Encode, Decode, Clone, Debug, PartialEq, Eq, MaxEncodedLen, TypeInfo)] | ||
pub enum PlatformUserType { | ||
#[codec(index = 0)] | ||
KaratDaoUser, | ||
KaratDao, | ||
#[codec(index = 1)] | ||
MagicCraftStakingUser, | ||
MagicCraftStaking, | ||
#[codec(index = 2)] | ||
DarenMarket, | ||
Comment on lines
+28
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I assume this will be a breaking change for the SDK? @jonalvarezz |
||
} | ||
|
||
impl PlatformUserType { | ||
pub fn get_supported_networks(&self) -> Vec<Web3Network> { | ||
match self { | ||
Self::KaratDaoUser | Self::MagicCraftStakingUser => all_evm_web3networks(), | ||
Self::KaratDao | Self::MagicCraftStaking | Self::DarenMarket => all_evm_web3networks(), | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -242,7 +242,7 @@ export default { | |
}, | ||
// PlatformUserType | ||
PlatformUserType: { | ||
_enum: ["KaratDaoUser", "MagicCraftStakingUser"], | ||
_enum: ["KaratDao", "MagicCraftStaking", "DarenMarket"], | ||
}, | ||
Comment on lines
-245
to
246
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we will need to update client-api, but not a breaking change for client-sdk nor clients in general. |
||
// Web3NftType | ||
Web3NftType: { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -93,12 +93,26 @@ mod tests { | |
use litentry_hex_utils::decode_hex; | ||
use litentry_primitives::{Identity, IdentityNetworkTuple}; | ||
|
||
fn init() -> DataProviderConfig { | ||
fn init(platform_user_type: PlatformUserType) -> DataProviderConfig { | ||
let _ = env_logger::builder().is_test(true).try_init(); | ||
let url = run(0).unwrap() + "/karat_dao/"; | ||
|
||
let mut config = DataProviderConfig::new().unwrap(); | ||
config.set_karat_dao_api_url(url).unwrap(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm so we never set There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previously magic_craft was not tested. |
||
|
||
match platform_user_type { | ||
PlatformUserType::KaratDao => { | ||
let url = run(0).unwrap() + "/karat_dao/"; | ||
config.set_karat_dao_api_url(url).unwrap(); | ||
}, | ||
PlatformUserType::MagicCraftStaking => { | ||
let url = run(0).unwrap() + "/magic_craft/"; | ||
config.set_magic_craft_api_url(url).unwrap(); | ||
}, | ||
PlatformUserType::DarenMarket => { | ||
let url = run(0).unwrap() + "/daren_market/"; | ||
config.set_daren_market_api_url(url).unwrap(); | ||
}, | ||
}; | ||
|
||
config | ||
} | ||
|
||
|
@@ -129,11 +143,11 @@ mod tests { | |
assertion_value: bool, | ||
data_provider_config: &DataProviderConfig, | ||
) { | ||
let req = crate_assertion_build_request(PlatformUserType::KaratDaoUser, identities); | ||
let req = crate_assertion_build_request(platform_user_type.clone(), identities); | ||
|
||
match build(&req, platform_user_type.clone(), &data_provider_config) { | ||
Ok(credential) => { | ||
log::info!("build karat dao user done"); | ||
log::info!("build platform user: {:?} done", platform_user_type); | ||
assert_eq!( | ||
*(credential.credential_subject.assertions.first().unwrap()), | ||
AssertionLogic::And { | ||
|
@@ -150,14 +164,85 @@ mod tests { | |
); | ||
}, | ||
Err(e) => { | ||
panic!("build karat dao user failed with error {:?}", e); | ||
panic!("build platform user: {:?} failed with error {:?}", platform_user_type, e); | ||
}, | ||
} | ||
} | ||
|
||
#[test] | ||
fn build_karat_dao_user_works() { | ||
let data_provider_config = init(); | ||
let data_provider_config = init(PlatformUserType::KaratDao); | ||
|
||
let mut address = | ||
decode_hex("0x49ad262c49c7aa708cc2df262ed53b64a17dd5ee".as_bytes().to_vec()) | ||
.unwrap() | ||
.as_slice() | ||
.try_into() | ||
.unwrap(); | ||
let mut identities: Vec<IdentityNetworkTuple> = | ||
vec![(Identity::Evm(address), vec![Web3Network::Ethereum])]; | ||
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::KaratDao, | ||
true, | ||
&data_provider_config, | ||
); | ||
|
||
address = decode_hex("0x75438d34c9125839c8b08d21b7f3167281659e7c".as_bytes().to_vec()) | ||
.unwrap() | ||
.as_slice() | ||
.try_into() | ||
.unwrap(); | ||
identities = vec![(Identity::Evm(address), vec![Web3Network::Bsc, Web3Network::Ethereum])]; | ||
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::KaratDao, | ||
false, | ||
&data_provider_config, | ||
); | ||
} | ||
|
||
#[test] | ||
fn build_magic_craft_staking_user_works() { | ||
let data_provider_config = init(PlatformUserType::MagicCraftStaking); | ||
|
||
let mut address = | ||
decode_hex("0x49ad262c49c7aa708cc2df262ed53b64a17dd5ee".as_bytes().to_vec()) | ||
.unwrap() | ||
.as_slice() | ||
.try_into() | ||
.unwrap(); | ||
let mut identities: Vec<IdentityNetworkTuple> = | ||
vec![(Identity::Evm(address), vec![Web3Network::Ethereum])]; | ||
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::MagicCraftStaking, | ||
true, | ||
&data_provider_config, | ||
); | ||
|
||
address = decode_hex("0x75438d34c9125839c8b08d21b7f3167281659e7c".as_bytes().to_vec()) | ||
.unwrap() | ||
.as_slice() | ||
.try_into() | ||
.unwrap(); | ||
identities = vec![(Identity::Evm(address), vec![Web3Network::Bsc, Web3Network::Ethereum])]; | ||
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::MagicCraftStaking, | ||
false, | ||
&data_provider_config, | ||
); | ||
} | ||
|
||
#[test] | ||
fn build_daren_market_user_works() { | ||
let data_provider_config = init(PlatformUserType::DarenMarket); | ||
|
||
let mut address = | ||
decode_hex("0x49ad262c49c7aa708cc2df262ed53b64a17dd5ee".as_bytes().to_vec()) | ||
.unwrap() | ||
|
@@ -169,7 +254,7 @@ mod tests { | |
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::KaratDaoUser, | ||
PlatformUserType::DarenMarket, | ||
true, | ||
&data_provider_config, | ||
); | ||
|
@@ -183,7 +268,7 @@ mod tests { | |
|
||
build_and_assert_result( | ||
identities, | ||
PlatformUserType::KaratDaoUser, | ||
PlatformUserType::DarenMarket, | ||
false, | ||
&data_provider_config, | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need to change it - actually we should remove all data provider envs for bc-worker
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure. Let's do it in another PR to remove all unrelated entries.
P-935 : remove env entries