diff --git a/.github/workflows/bindings-native-publish.yml b/.github/workflows/bindings-native-publish.yml index 0001c74..7a4bebf 100644 --- a/.github/workflows/bindings-native-publish.yml +++ b/.github/workflows/bindings-native-publish.yml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-13, ubuntu-20.04, windows-2022] + os: [macos-13, macos-13-xlarge, ubuntu-20.04, windows-2022] steps: - uses: actions/checkout@v3 @@ -24,7 +24,7 @@ jobs: - name: Select Xcode uses: maxim-lobanov/setup-xcode@v1 - if: matrix.os == 'macos-13' + if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' with: xcode-version: '14.3' @@ -47,11 +47,11 @@ jobs: - name: Set deployment target (macOS) run: echo "MACOSX_DEPLOYMENT_TARGET=10.14" >> $GITHUB_ENV - if: matrix.os == 'macos-13' + if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' - name: Get current date run: echo "CURRENT_DATE=$(date +'%Y-%m-%d')" >> $GITHUB_ENV - if: matrix.os == 'macos-13' || ${{ startsWith(matrix.os, 'ubuntu') }} + if: matrix.os == 'macos-13' || matrix.os == 'macos-13-xlarge' || ${{ startsWith(matrix.os, 'ubuntu') }} - name: Get current date if: matrix.os == 'windows-2022' @@ -94,6 +94,14 @@ jobs: - name: Cargo build run: cargo build --release + + - name: Rename file (MacOS/arm64) + run: mv target/release/libiota_sdk.dylib target/release/libiota_sdk_arm64.dylib + if: matrix.os == 'macos-13-xlarge' + + - name: Rename file (MacOS/amd64) + run: mv target/release/libiota_sdk.dylib target/release/libiota_sdk_amd64.dylib + if: matrix.os == 'macos-13' - name: Upload package to Github release uses: softprops/action-gh-release@v1 @@ -102,6 +110,8 @@ jobs: files: | target/release/libiota_sdk.so target/release/iota_sdk.dll - target/release/libiota_sdk.dylib + target/release/libiota_sdk_arm64.dylib + target/release/libiota_sdk_amd64.dylib + fail_on_unmatched_files: false tag_name: ${{ steps.prepare_release.outputs.tag_name }} \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml index c1a490d..ce80e41 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "iota-sdk-native-bindings" -version = "0.1.0" +version = "0.1.1" authors = [ "IOTA Stiftung" ] edition = "2021" description = "Native wrapper for the IOTA SDK library" @@ -22,7 +22,7 @@ default = ["std"] std = ["zeroize/std"] [dependencies] -iota-sdk-bindings-core = { git = "https://github.com/iotaledger/iota-sdk.git", rev = "8f57f0c50f555b5e62f78ebf0177fc71b78f0396", default-features = false, features = [ +iota-sdk-bindings-core = { git = "https://github.com/iotaledger/iota-sdk.git", branch = "develop", default-features = false, features = [ "events", "rocksdb", "ledger_nano", diff --git a/src/wallet.rs b/src/wallet.rs index 53942ac..d8bb4eb 100644 --- a/src/wallet.rs +++ b/src/wallet.rs @@ -112,28 +112,34 @@ unsafe fn internal_listen_wallet( events_ptr: *const c_char, handler: extern "C" fn(*const c_char), ) -> Result { + log::debug!("ON LISTEN WALLET BEGIN"); + let wallet = { assert!(!wallet_ptr.is_null()); &mut *wallet_ptr }; let events_string = CStr::from_ptr(events_ptr).to_str().unwrap(); - let rust_events = serde_json::from_str::>(events_string); + let rust_events = serde_json::from_str::>(events_string); if rust_events.is_err() { - return Ok(false); + return Err(Error {error: rust_events.unwrap_err().to_string() }); } - let mut wallet_events: Vec = Vec::new(); - for event in rust_events.unwrap() { - let event = match serde_json::from_str::(&event) { - Ok(event) => event, + let rust_events_unwrapped = rust_events.unwrap(); + log::debug!("ON LISTEN WALLET"); + + let mut event_types: Vec = Vec::with_capacity(rust_events_unwrapped.len()); + for event_id in rust_events_unwrapped { + let wallet_event_type = + WalletEventType::try_from(event_id); + + match wallet_event_type { + Ok(event) => event_types.push(event), Err(e) => { - debug!("Wrong event to listen! {e:?}"); - return Ok(false); + return Err(Error { error: e }); } - }; - wallet_events.push(event); + } } crate::block_on(async { @@ -143,13 +149,16 @@ unsafe fn internal_listen_wallet( .await .as_ref() .expect("wallet got destroyed") - .listen(wallet_events, move |event_data| { + .listen(event_types, move |event_data| { if let Ok(event_str) = serde_json::to_string(event_data) { let s = CString::new(event_str).unwrap(); + + log::debug!("Calling handler"); + handler(s.into_raw()) } }) - .await + .await; }); Ok(true)