Skip to content

Commit

Permalink
Fix FFI and require Dart 3
Browse files Browse the repository at this point in the history
  • Loading branch information
MatthewLM committed Aug 8, 2023
1 parent d4b0e38 commit 9ea22bc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 29 deletions.
45 changes: 23 additions & 22 deletions coinlib/lib/src/generated/secp256k1.ffi.g.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// AUTO GENERATED FILE, DO NOT EDIT.
//
// Generated by `package:ffigen`.
// ignore_for_file: type=lint
import 'dart:ffi' as ffi;

/// Raw generated bindings to secp256k1
Expand Down Expand Up @@ -209,7 +210,7 @@ class NativeSecp256k1 {
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>
ffi.Pointer<ffi.Char> message, ffi.Pointer<ffi.Void> data)>>
fun,
ffi.Pointer<ffi.Void> data,
) {
Expand All @@ -226,8 +227,8 @@ class NativeSecp256k1 {
ffi.Pointer<secp256k1_context>,
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>,
ffi.Void Function(ffi.Pointer<ffi.Char> message,
ffi.Pointer<ffi.Void> data)>>,
ffi.Pointer<ffi.Void>)>>(
'secp256k1_context_set_illegal_callback');
late final _secp256k1_context_set_illegal_callback =
Expand All @@ -236,8 +237,8 @@ class NativeSecp256k1 {
ffi.Pointer<secp256k1_context>,
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>,
ffi.Void Function(ffi.Pointer<ffi.Char> message,
ffi.Pointer<ffi.Void> data)>>,
ffi.Pointer<ffi.Void>)>();

/// Set a callback function to be called when an internal consistency check
Expand Down Expand Up @@ -266,7 +267,7 @@ class NativeSecp256k1 {
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>
ffi.Pointer<ffi.Char> message, ffi.Pointer<ffi.Void> data)>>
fun,
ffi.Pointer<ffi.Void> data,
) {
Expand All @@ -283,17 +284,17 @@ class NativeSecp256k1 {
ffi.Pointer<secp256k1_context>,
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>,
ffi.Void Function(ffi.Pointer<ffi.Char> message,
ffi.Pointer<ffi.Void> data)>>,
ffi.Pointer<ffi.Void>)>>('secp256k1_context_set_error_callback');
late final _secp256k1_context_set_error_callback =
_secp256k1_context_set_error_callbackPtr.asFunction<
void Function(
ffi.Pointer<secp256k1_context>,
ffi.Pointer<
ffi.NativeFunction<
ffi.Void Function(
ffi.Pointer<ffi.Char>, ffi.Pointer<ffi.Void>)>>,
ffi.Void Function(ffi.Pointer<ffi.Char> message,
ffi.Pointer<ffi.Void> data)>>,
ffi.Pointer<ffi.Void>)>();

/// Create a secp256k1 scratch space object.
Expand Down Expand Up @@ -1473,11 +1474,11 @@ class NativeSecp256k1 {
ffi.Pointer<ffi.UnsignedChar>)>();
}

class max_align_t extends ffi.Opaque {}
final class max_align_t extends ffi.Opaque {}

class secp256k1_context_struct extends ffi.Opaque {}
final class secp256k1_context_struct extends ffi.Opaque {}

class secp256k1_scratch_space_struct extends ffi.Opaque {}
final class secp256k1_scratch_space_struct extends ffi.Opaque {}

/// Opaque data structure that holds a parsed and valid public key.
///
Expand All @@ -1487,7 +1488,7 @@ class secp256k1_scratch_space_struct extends ffi.Opaque {}
/// If you need to convert to a format suitable for storage or transmission,
/// use secp256k1_ec_pubkey_serialize and secp256k1_ec_pubkey_parse. To
/// compare keys, use secp256k1_ec_pubkey_cmp.
class secp256k1_pubkey extends ffi.Struct {
final class secp256k1_pubkey extends ffi.Struct {
@ffi.Array.multi([64])
external ffi.Array<ffi.UnsignedChar> data;
}
Expand All @@ -1500,7 +1501,7 @@ class secp256k1_pubkey extends ffi.Struct {
/// If you need to convert to a format suitable for storage, transmission, or
/// comparison, use the secp256k1_ecdsa_signature_serialize_* and
/// secp256k1_ecdsa_signature_parse_* functions.
class secp256k1_ecdsa_signature extends ffi.Struct {
final class secp256k1_ecdsa_signature extends ffi.Struct {
@ffi.Array.multi([64])
external ffi.Array<ffi.UnsignedChar> data;
}
Expand Down Expand Up @@ -1559,12 +1560,12 @@ typedef secp256k1_scratch_space = secp256k1_scratch_space_struct;
typedef secp256k1_nonce_function = ffi.Pointer<
ffi.NativeFunction<
ffi.Int Function(
ffi.Pointer<ffi.UnsignedChar>,
ffi.Pointer<ffi.UnsignedChar>,
ffi.Pointer<ffi.UnsignedChar>,
ffi.Pointer<ffi.UnsignedChar>,
ffi.Pointer<ffi.Void>,
ffi.UnsignedInt)>>;
ffi.Pointer<ffi.UnsignedChar> nonce32,
ffi.Pointer<ffi.UnsignedChar> msg32,
ffi.Pointer<ffi.UnsignedChar> key32,
ffi.Pointer<ffi.UnsignedChar> algo16,
ffi.Pointer<ffi.Void> data,
ffi.UnsignedInt attempt)>>;

/// Opaque data structured that holds a parsed ECDSA signature,
/// supporting pubkey recovery.
Expand All @@ -1579,7 +1580,7 @@ typedef secp256k1_nonce_function = ffi.Pointer<
/// Furthermore, it is guaranteed that identical signatures (including their
/// recoverability) will have identical representation, so they can be
/// memcmp'ed.
class secp256k1_ecdsa_recoverable_signature extends ffi.Struct {
final class secp256k1_ecdsa_recoverable_signature extends ffi.Struct {
@ffi.Array.multi([65])
external ffi.Array<ffi.UnsignedChar> data;
}
Expand Down
4 changes: 2 additions & 2 deletions coinlib/lib/src/tx/legacy_transaction.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ import 'input_signature.dart';
import 'output.dart';
import 'raw_input.dart';

class TransactionTooLarge with Exception {}
class CannotSignInput with Exception {
class TransactionTooLarge implements Exception {}
class CannotSignInput implements Exception {
final String message;
CannotSignInput(this.message);
@override
Expand Down
10 changes: 5 additions & 5 deletions coinlib/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ name: coinlib
description:
A straight-forward, modular library for Peercoin and other Satoshi-based UTXO
blockchains
version: 1.0.0-alpha
version: 1.0.0-alpha.2
repository: https://github.com/peercoin/coinlib

environment:
sdk: '>=2.19.2 <4.0.0'
sdk: '>=3.0.0 <4.0.0'

dev_dependencies:
ffigen: ^6.0.0
ffigen: ^9.0.1
lints: ^2.0.0
test: ^1.21.0

dependencies:
collection: ^1.17.1
crypto: ^3.0.2
dart_base_x: ^1.0.0
ffi: ^1.2.1
ffi: ^2.1.0
hex: ^0.2.0
path: ^1.8.0
pointycastle: ^3.7.3
Expand All @@ -29,4 +29,4 @@ ffigen:
output: 'lib/src/generated/secp256k1.ffi.g.dart'
headers:
entry-points:
- 'src/secp256k1/include/secp256k1_recovery.h'
- '../coinlib_flutter/src/secp256k1/include/secp256k1_recovery.h'

0 comments on commit 9ea22bc

Please sign in to comment.