1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use crate::{
blockchain::TransactionContext,
contract::ContractError,
dataapi::{TypeSchema, WireBuffer},
prelude::TransactionFn,
};
pub trait Routing {
fn route3(
&self,
tx_fn: String,
args: Vec<WireBuffer>,
return_wb: TypeSchema,
) -> Result<WireBuffer, ContractError>;
}
pub trait Metadata {
fn get_fn_metadata(&self) -> Vec<TransactionFn>;
}
pub trait Contract: Routing + Metadata {
fn name(&self) -> String;
fn get_verified_client_org(&self) -> Result<String, ContractError> {
let tx = TransactionContext::current_transaction();
let peers_msp = tx.get_peer_mspid();
let client_msp = tx.get_submitting_identity()?.get_mspid();
if peers_msp != client_msp {
Err(ContractError::from(
"Mismatch of Organization names".to_string(),
))
} else {
Ok(client_msp)
}
}
}