Skip to content

Commit 180d5ff

Browse files
committed
feat: expose func
1 parent 61a6f65 commit 180d5ff

1 file changed

Lines changed: 16 additions & 11 deletions

File tree

wallet-core/src/ffi.rs

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub unsafe extern "C" fn generate_profile(
123123
/// Filter all notes and their block height that are owned by the given keys,
124124
/// mapped to their nullifiers.
125125
#[no_mangle]
126-
pub unsafe fn map_owned(
126+
pub unsafe extern "C" fn map_owned(
127127
seed: &Seed,
128128
indexes: *const u8,
129129
notes_ptr: *const u8,
@@ -236,7 +236,7 @@ pub unsafe extern "C" fn accounts_into_raw(
236236
/// Calculate the balance info for the phoenix address at the given index for
237237
/// the given seed.
238238
#[no_mangle]
239-
pub unsafe fn balance(
239+
pub unsafe extern "C" fn balance(
240240
seed: &Seed,
241241
index: u8,
242242
notes_ptr: *const u8,
@@ -259,7 +259,7 @@ pub unsafe fn balance(
259259

260260
/// Pick the notes to be used in a transaction from an owned notes list.
261261
#[no_mangle]
262-
pub unsafe fn pick_notes(
262+
pub unsafe extern "C" fn pick_notes(
263263
seed: &Seed,
264264
index: u8,
265265
value: *const u64,
@@ -284,7 +284,7 @@ pub unsafe fn pick_notes(
284284

285285
/// Gets the bookmark from the given note.
286286
#[no_mangle]
287-
pub unsafe fn bookmarks(
287+
pub unsafe extern "C" fn bookmarks(
288288
notes_ptr: *const u8,
289289
bookmarks_ptr: *mut *mut u8,
290290
) -> ErrorCode {
@@ -327,7 +327,7 @@ impl Prove for NoOpProver {
327327
}
328328

329329
#[no_mangle]
330-
pub unsafe fn into_proven(
330+
pub unsafe extern "C" fn into_proven(
331331
tx_ptr: *const u8,
332332
proof_ptr: *const u8,
333333
proven_ptr: *mut *mut u8,
@@ -365,7 +365,7 @@ pub unsafe fn into_proven(
365365
}
366366

367367
#[no_mangle]
368-
pub unsafe fn phoenix(
368+
pub unsafe extern "C" fn phoenix(
369369
rng: &[u8; 32],
370370
seed: &Seed,
371371
sender_index: u8,
@@ -543,7 +543,7 @@ pub unsafe extern "C" fn moonlight(
543543
}
544544

545545
#[no_mangle]
546-
pub unsafe fn phoenix_to_moonlight(
546+
pub unsafe extern "C" fn phoenix_to_moonlight(
547547
rng: &[u8; 32],
548548
seed: &Seed,
549549
profile_index: u8,
@@ -634,7 +634,7 @@ pub unsafe fn phoenix_to_moonlight(
634634
}
635635

636636
#[no_mangle]
637-
pub unsafe fn moonlight_to_phoenix(
637+
pub unsafe extern "C" fn moonlight_to_phoenix(
638638
rng: &[u8; 32],
639639
seed: &Seed,
640640
profile_index: u8,
@@ -688,7 +688,7 @@ pub unsafe fn moonlight_to_phoenix(
688688
}
689689

690690
#[no_mangle]
691-
pub unsafe fn moonlight_stake(
691+
pub unsafe extern "C" fn moonlight_stake(
692692
seed: &Seed,
693693
sender_index: u8,
694694
stake_value: *const u64,
@@ -749,7 +749,7 @@ pub unsafe fn moonlight_stake(
749749
}
750750

751751
#[no_mangle]
752-
pub unsafe fn moonlight_unstake(
752+
pub unsafe extern "C" fn moonlight_unstake(
753753
rng: &[u8; 32],
754754
seed: &Seed,
755755
sender_index: u8,
@@ -819,7 +819,7 @@ pub unsafe fn moonlight_unstake(
819819
}
820820

821821
#[no_mangle]
822-
pub unsafe fn moonlight_stake_reward(
822+
pub unsafe extern "C" fn moonlight_stake_reward(
823823
rng: &[u8; 32],
824824
seed: &Seed,
825825
sender_index: u8,
@@ -934,9 +934,14 @@ pub unsafe fn create_tx_data(
934934
};
935935
let len = bytes.len().to_le_bytes();
936936

937+
#[cfg(target_family = "wasm")]
937938
let ptr = mem::malloc(4 + bytes.len() as u32);
939+
#[cfg(target_family = "wasm")]
938940
let ptr = ptr as *mut u8;
939941

942+
#[cfg(not(target_family = "wasm"))]
943+
let ptr = mem::allocate(4 + bytes.len());
944+
940945
*rkyv_ptr = ptr;
941946

942947
ptr::copy_nonoverlapping(len.as_ptr(), ptr, 4);

0 commit comments

Comments
 (0)