浏览代码

Merge pull request #78 from Relayz-io/silvestr/api-request

Api requests
develop
Predko Silvestr 2 年前
父节点
当前提交
94755ec591
没有帐户链接到提交者的电子邮件
共有 6 个文件被更改,包括 47 次插入1 次删除
  1. 1
    1
      .github/workflows/ci.yml
  2. 7
    0
      common-api/Cargo.toml
  3. 22
    0
      common-api/src/api.rs
  4. 12
    0
      common-api/src/headers.rs
  5. 4
    0
      common-api/src/lib.rs
  6. 1
    0
      near-rpc/src/lib.rs

+ 1
- 1
.github/workflows/ci.yml 查看文件

@@ -50,7 +50,7 @@ jobs:
50 50
         with:
51 51
           toolchain: stable
52 52
       - name: Run tests for [common-api]
53
-        run: cargo test -p common-api --tests
53
+        run: cargo test -p common-api --tests --all-features 
54 54
   tests-near:
55 55
     name: tests-near
56 56
     needs: [clippy, fmt]

+ 7
- 0
common-api/Cargo.toml 查看文件

@@ -9,14 +9,21 @@ API for signing data and shared types. Please note that all data
9 9
 structures should be serializable with "serde" and "borsh"
10 10
 """
11 11
 
12
+[features]
13
+default = ["headers", "api"]
14
+headers = ["dep:near-account-id"]
15
+api = ["dep:near-account-id", "dep:uuid"]
16
+
12 17
 [dependencies]
13 18
 bs58 = "0.4"
14 19
 borsh = "0.9"
15 20
 ed25519-dalek = "1"
16 21
 itertools = "0.10"
22
+near-account-id = { version = "0.15", optional = true }
17 23
 serde = { version = "1", default-features = false, features = ["derive"] }
18 24
 serde_json = "1"
19 25
 thiserror = "1"
26
+uuid = { version = "1", optional = true }
20 27
 x25519-dalek = { version = "1", features = ["serde"] }
21 28
 
22 29
 [dev-dependencies]

+ 22
- 0
common-api/src/api.rs 查看文件

@@ -0,0 +1,22 @@
1
+use crate::crypto::prelude::*;
2
+use near_account_id::AccountId;
3
+use serde::{Deserialize, Serialize};
4
+use std::{collections::BTreeSet, time::Duration};
5
+
6
+#[derive(Clone, Debug, Serialize, Deserialize)]
7
+pub struct PublicKeys {
8
+    pub timeout: Duration,
9
+    pub participants: BTreeSet<AccountId>,
10
+}
11
+
12
+#[derive(Clone, Debug, Serialize, Deserialize)]
13
+pub struct ExchangeMessage {
14
+    pub account_id: AccountId,
15
+    pub data: Vec<u8>,
16
+}
17
+
18
+#[derive(Clone, Debug, Serialize, Deserialize)]
19
+pub struct ParticipantInfo {
20
+    pub public_key: Ed25519PublicKey,
21
+    pub account_id: AccountId,
22
+}

+ 12
- 0
common-api/src/headers.rs 查看文件

@@ -0,0 +1,12 @@
1
+use crate::crypto::prelude::*;
2
+use near_account_id::AccountId;
3
+use serde::{Deserialize, Serialize};
4
+
5
+pub const SIGNATURE_HEADER_NAME: &str = "signature";
6
+
7
+#[derive(Debug, Serialize, Deserialize)]
8
+pub struct SignatureHeader {
9
+    pub public_key: Ed25519PublicKey,
10
+    pub account_id: AccountId,
11
+    pub signature: Ed25519Signature,
12
+}

+ 4
- 0
common-api/src/lib.rs 查看文件

@@ -1 +1,5 @@
1
+#[cfg(feature = "api")]
2
+pub mod api;
1 3
 pub mod crypto;
4
+#[cfg(feature = "headers")]
5
+pub mod headers;

+ 1
- 0
near-rpc/src/lib.rs 查看文件

@@ -2,6 +2,7 @@ mod rpc;
2 2
 pub mod utils;
3 3
 
4 4
 pub mod client;
5
+pub use near_primitives_light::{self, types::Finality};
5 6
 
6 7
 type Result<T> = std::result::Result<T, Error>;
7 8
 

正在加载...
取消
保存