Compare commits
No commits in common. "1261a585e6f775049e772bccae55233a9fa04b05" and "504969834a66c7c161e16aa312ed5afef9f17f98" have entirely different histories.
1261a585e6
...
504969834a
5 changed files with 10 additions and 27 deletions
6
app/Main.hs
Normal file
6
app/Main.hs
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Main where
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = putStrLn "Zcash Utilities for Haskell"
|
|
@ -17,13 +17,13 @@ use haskell_ffi::{
|
||||||
|
|
||||||
use zcash_address::{
|
use zcash_address::{
|
||||||
Network,
|
Network,
|
||||||
unified::{Address, Encoding},
|
unified::{Address, Encoding}
|
||||||
ZcashAddress
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub enum RW {}
|
pub enum RW {}
|
||||||
pub const RW: PhantomData<RW> = PhantomData;
|
pub const RW: PhantomData<RW> = PhantomData;
|
||||||
|
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
pub extern "C" fn rust_wrapper_f4jumble(
|
pub extern "C" fn rust_wrapper_f4jumble(
|
||||||
input: *const u8,
|
input: *const u8,
|
||||||
|
@ -43,11 +43,3 @@ pub extern "C" fn rust_wrapper_ua_decode(
|
||||||
Address::decode(&input).is_ok()
|
Address::decode(&input).is_ok()
|
||||||
//marshall_to_haskell_var(&result, out, out_len, RW);
|
//marshall_to_haskell_var(&result, out, out_len, RW);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
|
||||||
pub extern "C" fn rust_wrapper_shielded_decode(
|
|
||||||
input: *const u8,
|
|
||||||
input_len: usize) -> bool {
|
|
||||||
let input: String = marshall_from_haskell_var(input, input_len, RW);
|
|
||||||
ZcashAddress::try_from_encoded(&input).is_ok()
|
|
||||||
}
|
|
||||||
|
|
|
@ -37,9 +37,3 @@ newtype CodedString = CodedString BS.ByteString
|
||||||
}
|
}
|
||||||
-> `Bool'
|
-> `Bool'
|
||||||
#}
|
#}
|
||||||
|
|
||||||
{# fun pure unsafe rust_wrapper_shielded_decode as rustWrapperIsShielded
|
|
||||||
{ toBorshVar* `BS.ByteString'&
|
|
||||||
}
|
|
||||||
-> `Bool'
|
|
||||||
#}
|
|
||||||
|
|
11
src/Zcash.hs
11
src/Zcash.hs
|
@ -1,15 +1,9 @@
|
||||||
module Zcash
|
module Zcash
|
||||||
( f4Jumble
|
( f4Jumble
|
||||||
, isValidUnifiedAddress
|
, isValidUnifiedAddress
|
||||||
, isValidShieldedAddress
|
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import C.Zcash
|
import C.Zcash (CodedString, rustWrapperF4Jumble, rustWrapperIsUA)
|
||||||
( CodedString
|
|
||||||
, rustWrapperF4Jumble
|
|
||||||
, rustWrapperIsShielded
|
|
||||||
, rustWrapperIsUA
|
|
||||||
)
|
|
||||||
import qualified Data.ByteString as BS
|
import qualified Data.ByteString as BS
|
||||||
import Foreign.Rust.Marshall.Fixed
|
import Foreign.Rust.Marshall.Fixed
|
||||||
import Foreign.Rust.Marshall.Variable
|
import Foreign.Rust.Marshall.Variable
|
||||||
|
@ -19,6 +13,3 @@ f4Jumble = withPureBorshVarBuffer . rustWrapperF4Jumble
|
||||||
|
|
||||||
isValidUnifiedAddress :: BS.ByteString -> Bool
|
isValidUnifiedAddress :: BS.ByteString -> Bool
|
||||||
isValidUnifiedAddress = rustWrapperIsUA
|
isValidUnifiedAddress = rustWrapperIsUA
|
||||||
|
|
||||||
isValidShieldedAddress :: BS.ByteString -> Bool
|
|
||||||
isValidShieldedAddress = rustWrapperIsShielded
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ library
|
||||||
rustzcash_wrapper-uninstalled
|
rustzcash_wrapper-uninstalled
|
||||||
build-depends:
|
build-depends:
|
||||||
base >=4.7 && <5
|
base >=4.7 && <5
|
||||||
, borsh >=0.2
|
, borsh
|
||||||
, bytestring
|
, bytestring
|
||||||
, foreign-rust
|
, foreign-rust
|
||||||
, text
|
, text
|
||||||
|
|
Loading…
Reference in a new issue