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

fix: A8 wrong network in VC #2904

Merged
merged 2 commits into from
Jul 18, 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
15 changes: 14 additions & 1 deletion primitives/core/src/assertion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,15 @@ pub enum Assertion {
Dynamic(DynamicParams)
}

const A8_SUPPORTED_NETWORKS: [Web3Network; 6] = [
Web3Network::Polkadot,
Web3Network::Kusama,
Web3Network::Litentry,
Web3Network::Litmus,
Web3Network::Khala,
Web3Network::Ethereum,
];

impl Assertion {
// Given an assertion enum type, retrieve the supported web3 networks.
// So we limit the network types on the assertion definition level.
Expand All @@ -164,7 +173,11 @@ impl Assertion {
Self::VIP3MembershipCard(..) |
Self::WeirdoGhostGangHolder => vec![Web3Network::Ethereum],
// total tx over `networks`
Self::A8(network) => network.to_vec(),
Self::A8(networks) => networks
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How do you think just add a filter to filter out types, which is NOT Litentry, Litmus, Polkadot, Kusama, Khala, or Ethereum ?
Then we don't need to create a new type A8SupportedNetwork.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the client pass in the wrong networks? Shouldn't this be fixed at client side first?

But sure we could a second check logic here

And yes we can simply filter out unwanted types, or retain only desired ones

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kailai-Wang this is the leftover of refactoring of shifting network type from link_identity to request_vc. From IDHub point of view, they always wish the all supported networks. So they don't do any filtering at client side. We did the magic within get_eligible_identities().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refactored to only filter instead creating new types.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the leftover of refactoring of shifting network type from link_identity to request_vc. From IDHub point of view, they always wish the all supported networks. So they don't do any filtering at client side. We did the magic within get_eligible_identities().

I doubt that's related.

The main motivation here was to have a struct to represent exactly the accepted values for A8. Clients must specify one of them to get the right assertion.

.into_iter()
.filter(|network| A8_SUPPORTED_NETWORKS.contains(*network))
.cloned()
.collect::<Vec<_>>(),
// Achainable Assertions
Self::Achainable(arg) => arg.chains(),
// OneBlock Assertion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default {
},
},
AssertionSupportedNetwork: {
_enum: ["Litentry", "Litmus", "LitentryRococo", "Polkadot", "Kusama", "Khala", "Ethereum", "TestNet"],
_enum: ["Polkadot", "Kusama", "Litentry", "Litmus", "__UnsupportedLitentryRococo", "Khala", "__UnsupportedSubstrateTestnet", "Ethereum"],
},
DynamicParams: {
smart_contract_id: "[u8;20]",
Expand Down