-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implementing OmniAccount related native calls in the omni-executor (#…
- Loading branch information
Showing
39 changed files
with
15,450 additions
and
7,532 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
121 changes: 121 additions & 0 deletions
121
tee-worker/omni-executor/executor-primitives/src/validation_data.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
// Copyright 2020-2024 Trust Computing GmbH. | ||
// This file is part of Litentry. | ||
// | ||
// Litentry is free software: you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License as published by | ||
// the Free Software Foundation, either version 3 of the License, or | ||
// (at your option) any later version. | ||
// | ||
// Litentry is distributed in the hope that it will be useful, | ||
// but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
// GNU General Public License for more details. | ||
// | ||
// You should have received a copy of the GNU General Public License | ||
// along with Litentry. If not, see <https://www.gnu.org/licenses/>. | ||
|
||
use crate::signature::HeimaMultiSignature; | ||
use parity_scale_codec::{Decode, Encode, MaxEncodedLen}; | ||
use scale_info::TypeInfo; | ||
use serde::{Deserialize, Serialize}; | ||
use sp_core::{bounded_vec::BoundedVec, ConstU32}; | ||
|
||
// The size limit value should be 128 otherwise the message size will exceed the limit while link identity. | ||
pub type ValidationString = BoundedVec<u8, ConstU32<128>>; | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
pub enum TwitterValidationData { | ||
PublicTweet { tweet_id: ValidationString }, | ||
OAuth2 { code: ValidationString, state: ValidationString, redirect_uri: ValidationString }, | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
pub enum DiscordValidationData { | ||
PublicMessage { | ||
channel_id: ValidationString, | ||
message_id: ValidationString, | ||
guild_id: ValidationString, | ||
}, | ||
OAuth2 { | ||
code: ValidationString, | ||
redirect_uri: ValidationString, | ||
}, | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
pub struct EmailValidationData { | ||
pub email: ValidationString, | ||
pub verification_code: ValidationString, | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
pub struct Web3CommonValidationData { | ||
pub message: ValidationString, // or String if under std | ||
pub signature: HeimaMultiSignature, | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
#[allow(non_camel_case_types)] | ||
pub enum Web2ValidationData { | ||
#[codec(index = 0)] | ||
Twitter(TwitterValidationData), | ||
#[codec(index = 1)] | ||
Discord(DiscordValidationData), | ||
#[codec(index = 2)] | ||
Email(EmailValidationData), | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
#[allow(non_camel_case_types)] | ||
pub enum Web3ValidationData { | ||
#[codec(index = 0)] | ||
Substrate(Web3CommonValidationData), | ||
#[codec(index = 1)] | ||
Evm(Web3CommonValidationData), | ||
#[codec(index = 2)] | ||
Bitcoin(Web3CommonValidationData), | ||
#[codec(index = 3)] | ||
Solana(Web3CommonValidationData), | ||
} | ||
|
||
impl Web3ValidationData { | ||
pub fn message(&self) -> &ValidationString { | ||
match self { | ||
Self::Substrate(data) => &data.message, | ||
Self::Evm(data) => &data.message, | ||
Self::Bitcoin(data) => &data.message, | ||
Self::Solana(data) => &data.message, | ||
} | ||
} | ||
|
||
pub fn signature(&self) -> &HeimaMultiSignature { | ||
match self { | ||
Self::Substrate(data) => &data.signature, | ||
Self::Evm(data) => &data.signature, | ||
Self::Bitcoin(data) => &data.signature, | ||
Self::Solana(data) => &data.signature, | ||
} | ||
} | ||
} | ||
|
||
#[derive( | ||
Serialize, Deserialize, Encode, Decode, Clone, Debug, PartialEq, Eq, TypeInfo, MaxEncodedLen, | ||
)] | ||
pub enum ValidationData { | ||
#[codec(index = 0)] | ||
Web2(Web2ValidationData), | ||
#[codec(index = 1)] | ||
Web3(Web3ValidationData), | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.