diff --git a/bindings/dart-bip85/example/.gitignore b/bindings/dart-bip85/example/.gitignore index 29a3a50..79c113f 100644 --- a/bindings/dart-bip85/example/.gitignore +++ b/bindings/dart-bip85/example/.gitignore @@ -5,9 +5,11 @@ *.swp .DS_Store .atom/ +.build/ .buildlog/ .history .svn/ +.swiftpm/ migrate_working_dir/ # IntelliJ related diff --git a/bindings/dart-bip85/lib/src/rust/api/bip85.dart b/bindings/dart-bip85/lib/src/rust/api/bip85.dart index 564b62e..26d82dc 100644 --- a/bindings/dart-bip85/lib/src/rust/api/bip85.dart +++ b/bindings/dart-bip85/lib/src/rust/api/bip85.dart @@ -23,3 +23,13 @@ String toMnemonic( {required String xprv, required int wordCount, required int index}) => LibBip85.instance.api.crateApiBip85ToMnemonic( xprv: xprv, wordCount: wordCount, index: index); + +String toBase64( + {required String xprv, required int length, required int index}) => + LibBip85.instance.api + .crateApiBip85ToBase64(xprv: xprv, length: length, index: index); + +String toBase85( + {required String xprv, required int length, required int index}) => + LibBip85.instance.api + .crateApiBip85ToBase85(xprv: xprv, length: length, index: index); diff --git a/bindings/dart-bip85/lib/src/rust/frb_generated.dart b/bindings/dart-bip85/lib/src/rust/frb_generated.dart index a823ffe..ecbdee5 100644 --- a/bindings/dart-bip85/lib/src/rust/frb_generated.dart +++ b/bindings/dart-bip85/lib/src/rust/frb_generated.dart @@ -57,7 +57,7 @@ class LibBip85 String get codegenVersion => '2.0.0'; @override - int get rustContentHash => -1756544811; + int get rustContentHash => 1370172147; static const kDefaultExternalLibraryLoaderConfig = ExternalLibraryLoaderConfig( @@ -70,6 +70,12 @@ class LibBip85 abstract class LibBip85Api extends BaseApi { Uint8List crateApiBip85Derive({required String xprv, required String path}); + String crateApiBip85ToBase64( + {required String xprv, required int length, required int index}); + + String crateApiBip85ToBase85( + {required String xprv, required int length, required int index}); + String crateApiBip85ToHex( {required String xprv, required int length, required int index}); @@ -114,7 +120,7 @@ class LibBip85ApiImpl extends LibBip85ApiImplPlatform implements LibBip85Api { ); @override - String crateApiBip85ToHex( + String crateApiBip85ToBase64( {required String xprv, required int length, required int index}) { return handler.executeSync(SyncTask( callFfi: () { @@ -128,6 +134,58 @@ class LibBip85ApiImpl extends LibBip85ApiImplPlatform implements LibBip85Api { decodeSuccessData: sse_decode_String, decodeErrorData: null, ), + constMeta: kCrateApiBip85ToBase64ConstMeta, + argValues: [xprv, length, index], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiBip85ToBase64ConstMeta => const TaskConstMeta( + debugName: "to_base64", + argNames: ["xprv", "length", "index"], + ); + + @override + String crateApiBip85ToBase85( + {required String xprv, required int length, required int index}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_String(xprv, serializer); + sse_encode_u_32(length, serializer); + sse_encode_u_32(index, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 3)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: null, + ), + constMeta: kCrateApiBip85ToBase85ConstMeta, + argValues: [xprv, length, index], + apiImpl: this, + )); + } + + TaskConstMeta get kCrateApiBip85ToBase85ConstMeta => const TaskConstMeta( + debugName: "to_base85", + argNames: ["xprv", "length", "index"], + ); + + @override + String crateApiBip85ToHex( + {required String xprv, required int length, required int index}) { + return handler.executeSync(SyncTask( + callFfi: () { + final serializer = SseSerializer(generalizedFrbRustBinding); + sse_encode_String(xprv, serializer); + sse_encode_u_32(length, serializer); + sse_encode_u_32(index, serializer); + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 4)!; + }, + codec: SseCodec( + decodeSuccessData: sse_decode_String, + decodeErrorData: null, + ), constMeta: kCrateApiBip85ToHexConstMeta, argValues: [xprv, length, index], apiImpl: this, @@ -148,7 +206,7 @@ class LibBip85ApiImpl extends LibBip85ApiImplPlatform implements LibBip85Api { sse_encode_String(xprv, serializer); sse_encode_u_32(wordCount, serializer); sse_encode_u_32(index, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 3)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 5)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -172,7 +230,7 @@ class LibBip85ApiImpl extends LibBip85ApiImplPlatform implements LibBip85Api { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(xprv, serializer); sse_encode_u_32(index, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 4)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 6)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, @@ -196,7 +254,7 @@ class LibBip85ApiImpl extends LibBip85ApiImplPlatform implements LibBip85Api { final serializer = SseSerializer(generalizedFrbRustBinding); sse_encode_String(xprv, serializer); sse_encode_u_32(index, serializer); - return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 5)!; + return pdeCallFfi(generalizedFrbRustBinding, serializer, funcId: 7)!; }, codec: SseCodec( decodeSuccessData: sse_decode_String, diff --git a/bindings/dart-bip85/rust/src/frb_generated.rs b/bindings/dart-bip85/rust/src/frb_generated.rs index 4ffdde1..ecce1f1 100644 --- a/bindings/dart-bip85/rust/src/frb_generated.rs +++ b/bindings/dart-bip85/rust/src/frb_generated.rs @@ -37,7 +37,7 @@ flutter_rust_bridge::frb_generated_boilerplate!( default_rust_auto_opaque = RustAutoOpaqueMoi, ); pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_VERSION: &str = "2.0.0"; -pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = -1756544811; +pub(crate) const FLUTTER_RUST_BRIDGE_CODEGEN_CONTENT_HASH: i32 = 1370172147; // Section: executor @@ -76,6 +76,74 @@ fn wire__crate__api__bip85__derive_impl( }, ) } +fn wire__crate__api__bip85__to_base64_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "to_base64", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_xprv = ::sse_decode(&mut deserializer); + let api_length = ::sse_decode(&mut deserializer); + let api_index = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok(crate::api::bip85::to_base64( + api_xprv, api_length, api_index, + ))?; + Ok(output_ok) + })()) + }, + ) +} +fn wire__crate__api__bip85__to_base85_impl( + ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, + rust_vec_len_: i32, + data_len_: i32, +) -> flutter_rust_bridge::for_generated::WireSyncRust2DartSse { + FLUTTER_RUST_BRIDGE_HANDLER.wrap_sync::( + flutter_rust_bridge::for_generated::TaskInfo { + debug_name: "to_base85", + port: None, + mode: flutter_rust_bridge::for_generated::FfiCallMode::Sync, + }, + move || { + let message = unsafe { + flutter_rust_bridge::for_generated::Dart2RustMessageSse::from_wire( + ptr_, + rust_vec_len_, + data_len_, + ) + }; + let mut deserializer = + flutter_rust_bridge::for_generated::SseDeserializer::new(message); + let api_xprv = ::sse_decode(&mut deserializer); + let api_length = ::sse_decode(&mut deserializer); + let api_index = ::sse_decode(&mut deserializer); + deserializer.end(); + transform_result_sse::<_, ()>((move || { + let output_ok = Result::<_, ()>::Ok(crate::api::bip85::to_base85( + api_xprv, api_length, api_index, + ))?; + Ok(output_ok) + })()) + }, + ) +} fn wire__crate__api__bip85__to_hex_impl( ptr_: flutter_rust_bridge::for_generated::PlatformGeneralizedUint8ListPtr, rust_vec_len_: i32, @@ -288,10 +356,12 @@ fn pde_ffi_dispatcher_sync_impl( // Codec=Pde (Serialization + dispatch), see doc to use other codecs match func_id { 1 => wire__crate__api__bip85__derive_impl(ptr, rust_vec_len, data_len), - 2 => wire__crate__api__bip85__to_hex_impl(ptr, rust_vec_len, data_len), - 3 => wire__crate__api__bip85__to_mnemonic_impl(ptr, rust_vec_len, data_len), - 4 => wire__crate__api__bip85__to_wif_impl(ptr, rust_vec_len, data_len), - 5 => wire__crate__api__bip85__to_xprv_impl(ptr, rust_vec_len, data_len), + 2 => wire__crate__api__bip85__to_base64_impl(ptr, rust_vec_len, data_len), + 3 => wire__crate__api__bip85__to_base85_impl(ptr, rust_vec_len, data_len), + 4 => wire__crate__api__bip85__to_hex_impl(ptr, rust_vec_len, data_len), + 5 => wire__crate__api__bip85__to_mnemonic_impl(ptr, rust_vec_len, data_len), + 6 => wire__crate__api__bip85__to_wif_impl(ptr, rust_vec_len, data_len), + 7 => wire__crate__api__bip85__to_xprv_impl(ptr, rust_vec_len, data_len), _ => unreachable!(), } }