tesseract_protocol_test/lib.rs
1//===------------ mod.rs --------------------------------------------===//
2// Copyright 2021, Tesseract Systems, Inc.
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//===----------------------------------------------------------------------===//
16
17#![feature(async_closure)]
18
19#[cfg(feature = "client")]
20pub mod client;
21
22#[cfg(feature = "service")]
23pub mod service;
24
25use std::sync::Arc;
26use async_trait::async_trait;
27
28use serde::{Deserialize, Serialize};
29
30use tesseract_one::Protocol;
31use tesseract_one::error::Result;
32
33#[derive(Default, Clone, Copy)]
34pub enum Test {
35 #[default]
36 Protocol,
37}
38
39impl Protocol for Test {
40 fn id(&self) -> String {
41 "test".to_owned()
42 }
43}
44
45#[derive(Serialize, Deserialize)]
46pub struct SignTransactionRequest {
47 transaction: String,
48}
49
50#[derive(Serialize, Deserialize)]
51pub struct SignTransactionResponse {
52 signed: String,
53}
54
55#[async_trait]
56pub trait TestService {
57 async fn sign_transaction(self: Arc<Self>, transaction: &str) -> Result<String>;
58}