-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
118 additions
and
109 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
extern crate napi_build; | ||
|
||
fn main() { | ||
napi_build::setup(); | ||
napi_build::setup(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,52 @@ | ||
use kitsune_p2p_timestamp::Timestamp; | ||
use holochain_zome_types::CellId; | ||
use holochain_integrity_types::{ZomeName, FunctionName}; | ||
use holo_hash::{DnaHash, AgentPubKey}; | ||
use holochain_zome_types::{ExternIO, CapSecret, ZomeCallUnsigned}; | ||
use crate::utils::*; | ||
use holo_hash::{AgentPubKey, DnaHash}; | ||
use holochain_integrity_types::{FunctionName, ZomeName}; | ||
use holochain_zome_types::CellId; | ||
use holochain_zome_types::{CapSecret, ExternIO, ZomeCallUnsigned}; | ||
use kitsune_p2p_timestamp::Timestamp; | ||
|
||
#[derive(Clone)] | ||
#[napi(object)] | ||
pub struct ZomeCallUnsignedNapi { | ||
pub cell_id: Vec<Vec<u8>>, | ||
pub zome_name: String, | ||
pub fn_name: String, | ||
pub payload: Vec<u8>, | ||
pub cap_secret: Option<Vec<u8>>, | ||
pub provenance: Vec<u8>, | ||
pub nonce: Vec<u8>, | ||
pub expires_at: i64, | ||
pub cell_id: Vec<Vec<u8>>, | ||
pub zome_name: String, | ||
pub fn_name: String, | ||
pub payload: Vec<u8>, | ||
pub cap_secret: Option<Vec<u8>>, | ||
pub provenance: Vec<u8>, | ||
pub nonce: Vec<u8>, | ||
pub expires_at: i64, | ||
} | ||
|
||
|
||
impl Into<ZomeCallUnsigned> for ZomeCallUnsignedNapi { | ||
fn into(self: Self) -> ZomeCallUnsigned { | ||
ZomeCallUnsigned { | ||
cell_id: CellId::new( | ||
DnaHash::from_raw_39(self.cell_id.get(0).unwrap().clone()).unwrap(), | ||
AgentPubKey::from_raw_39(self.cell_id.get(1).unwrap().clone()).unwrap() | ||
), | ||
zome_name: ZomeName::from(self.zome_name), | ||
fn_name: FunctionName::from(self.fn_name), | ||
payload: ExternIO::from(self.payload), | ||
cap_secret: self.cap_secret.map_or(None, |c| Some(CapSecret::from(vec_to_arr(c)))), | ||
provenance: AgentPubKey::from_raw_39(self.provenance).unwrap(), | ||
nonce: vec_to_arr(self.nonce).into(), | ||
expires_at: Timestamp(self.expires_at) | ||
fn into(self: Self) -> ZomeCallUnsigned { | ||
ZomeCallUnsigned { | ||
cell_id: CellId::new( | ||
DnaHash::from_raw_39(self.cell_id.get(0).unwrap().clone()).unwrap(), | ||
AgentPubKey::from_raw_39(self.cell_id.get(1).unwrap().clone()).unwrap(), | ||
), | ||
zome_name: ZomeName::from(self.zome_name), | ||
fn_name: FunctionName::from(self.fn_name), | ||
payload: ExternIO::from(self.payload), | ||
cap_secret: self | ||
.cap_secret | ||
.map_or(None, |c| Some(CapSecret::from(vec_to_arr(c)))), | ||
provenance: AgentPubKey::from_raw_39(self.provenance).unwrap(), | ||
nonce: vec_to_arr(self.nonce).into(), | ||
expires_at: Timestamp(self.expires_at), | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[napi(object)] | ||
pub struct ZomeCallNapi { | ||
pub cell_id: Vec<Vec<u8>>, | ||
pub zome_name: String, | ||
pub fn_name: String, | ||
pub payload: Vec<u8>, | ||
pub cap_secret: Option<Vec<u8>>, | ||
pub provenance: Vec<u8>, | ||
pub nonce: Vec<u8>, | ||
pub expires_at: i64, | ||
pub signature: Vec<u8> | ||
pub cell_id: Vec<Vec<u8>>, | ||
pub zome_name: String, | ||
pub fn_name: String, | ||
pub payload: Vec<u8>, | ||
pub cap_secret: Option<Vec<u8>>, | ||
pub provenance: Vec<u8>, | ||
pub nonce: Vec<u8>, | ||
pub expires_at: i64, | ||
pub signature: Vec<u8>, | ||
} |
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
pub fn vec_to_arr<T, const N: usize>(v: Vec<T>) -> [T; N] { | ||
v.try_into() | ||
.unwrap_or_else(|v: Vec<T>| panic!("Expected a Vec of length {} but it was {}", N, v.len())) | ||
} | ||
v.try_into() | ||
.unwrap_or_else(|v: Vec<T>| panic!("Expected a Vec of length {} but it was {}", N, v.len())) | ||
} |