feat(ios,android): setup uniffi infra (#8828)

This commit is contained in:
Brooooooklyn
2024-12-10 03:43:34 +00:00
parent 95597ec139
commit adc69548ef
26 changed files with 3097 additions and 124 deletions

View File

@@ -1,7 +1,7 @@
use std::convert::TryFrom;
use affine_common::hashcash::Stamp;
use napi::{bindgen_prelude::AsyncTask, Env, JsBoolean, JsString, Result as NapiResult, Task};
use napi::{bindgen_prelude::AsyncTask, Env, Result, Task};
use napi_derive::napi;
pub struct AsyncVerifyChallengeResponse {
@@ -13,9 +13,9 @@ pub struct AsyncVerifyChallengeResponse {
#[napi]
impl Task for AsyncVerifyChallengeResponse {
type Output = bool;
type JsValue = JsBoolean;
type JsValue = bool;
fn compute(&mut self) -> NapiResult<Self::Output> {
fn compute(&mut self) -> Result<Self::Output> {
Ok(if let Ok(stamp) = Stamp::try_from(self.response.as_str()) {
stamp.check(self.bits, &self.resource)
} else {
@@ -23,8 +23,8 @@ impl Task for AsyncVerifyChallengeResponse {
})
}
fn resolve(&mut self, env: Env, output: bool) -> NapiResult<Self::JsValue> {
env.get_boolean(output)
fn resolve(&mut self, _: Env, output: bool) -> Result<Self::JsValue> {
Ok(output)
}
}
@@ -49,14 +49,14 @@ pub struct AsyncMintChallengeResponse {
#[napi]
impl Task for AsyncMintChallengeResponse {
type Output = String;
type JsValue = JsString;
type JsValue = String;
fn compute(&mut self) -> NapiResult<Self::Output> {
fn compute(&mut self) -> Result<Self::Output> {
Ok(Stamp::mint(self.resource.clone(), self.bits).format())
}
fn resolve(&mut self, env: Env, output: String) -> NapiResult<Self::JsValue> {
env.create_string(&output)
fn resolve(&mut self, _: Env, output: String) -> Result<Self::JsValue> {
Ok(output)
}
}