ソースを参照

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

Api requests
develop
Predko Silvestr 2年前
コミット
94755ec591
コミッターのメールアドレスに関連付けられたアカウントが存在しません

+ 1
- 1
.github/workflows/ci.yml ファイルの表示

50
         with:
50
         with:
51
           toolchain: stable
51
           toolchain: stable
52
       - name: Run tests for [common-api]
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
   tests-near:
54
   tests-near:
55
     name: tests-near
55
     name: tests-near
56
     needs: [clippy, fmt]
56
     needs: [clippy, fmt]

+ 7
- 0
common-api/Cargo.toml ファイルの表示

9
 structures should be serializable with "serde" and "borsh"
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
 [dependencies]
17
 [dependencies]
13
 bs58 = "0.4"
18
 bs58 = "0.4"
14
 borsh = "0.9"
19
 borsh = "0.9"
15
 ed25519-dalek = "1"
20
 ed25519-dalek = "1"
16
 itertools = "0.10"
21
 itertools = "0.10"
22
+near-account-id = { version = "0.15", optional = true }
17
 serde = { version = "1", default-features = false, features = ["derive"] }
23
 serde = { version = "1", default-features = false, features = ["derive"] }
18
 serde_json = "1"
24
 serde_json = "1"
19
 thiserror = "1"
25
 thiserror = "1"
26
+uuid = { version = "1", optional = true }
20
 x25519-dalek = { version = "1", features = ["serde"] }
27
 x25519-dalek = { version = "1", features = ["serde"] }
21
 
28
 
22
 [dev-dependencies]
29
 [dev-dependencies]

+ 22
- 0
common-api/src/api.rs ファイルの表示

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 ファイルの表示

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
+#[cfg(feature = "api")]
2
+pub mod api;
1
 pub mod crypto;
3
 pub mod crypto;
4
+#[cfg(feature = "headers")]
5
+pub mod headers;

+ 1
- 0
near-rpc/src/lib.rs ファイルの表示

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

読み込み中…
キャンセル
保存