Skip to content

Commit

Permalink
chore: codegen generate
Browse files Browse the repository at this point in the history
  • Loading branch information
ethicnology committed Jan 23, 2025
1 parent 8964f6e commit 222a5f6
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 10 deletions.
2 changes: 2 additions & 0 deletions bindings/dart-bip85/example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
*.swp
.DS_Store
.atom/
.build/
.buildlog/
.history
.svn/
.swiftpm/
migrate_working_dir/

# IntelliJ related
Expand Down
10 changes: 10 additions & 0 deletions bindings/dart-bip85/lib/src/rust/api/bip85.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
68 changes: 63 additions & 5 deletions bindings/dart-bip85/lib/src/rust/frb_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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});

Expand Down Expand Up @@ -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: () {
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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,
Expand Down
80 changes: 75 additions & 5 deletions bindings/dart-bip85/rust/src/frb_generated.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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::SseCodec, _>(
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 = <String>::sse_decode(&mut deserializer);
let api_length = <u32>::sse_decode(&mut deserializer);
let api_index = <u32>::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::SseCodec, _>(
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 = <String>::sse_decode(&mut deserializer);
let api_length = <u32>::sse_decode(&mut deserializer);
let api_index = <u32>::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,
Expand Down Expand Up @@ -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!(),
}
}
Expand Down

0 comments on commit 222a5f6

Please sign in to comment.