Skip to content

Commit

Permalink
Generated code
Browse files Browse the repository at this point in the history
  • Loading branch information
i5hi committed Oct 16, 2024
1 parent 006e0ee commit 70e0e12
Show file tree
Hide file tree
Showing 5 changed files with 343 additions and 269 deletions.
22 changes: 15 additions & 7 deletions lib/src/generated/api/error.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,21 @@

import '../frb_generated.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'error.freezed.dart';

///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
/// Possible errors emitted
@freezed
class LwkError with _$LwkError implements FrbException {
const factory LwkError({
required String msg,
}) = _LwkError;
class LwkError implements FrbException {
final String msg;

const LwkError({
required this.msg,
});

@override
int get hashCode => msg.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is LwkError && runtimeType == other.runtimeType && msg == other.msg;
}
229 changes: 177 additions & 52 deletions lib/src/generated/api/types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,23 @@
import '../frb_generated.dart';
import 'error.dart';
import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart';
import 'package:freezed_annotation/freezed_annotation.dart' hide protected;
part 'types.freezed.dart';

// The type `AssetIdBTreeMapInt` is not used by any `pub` functions, thus it is ignored.
// The type `AssetIdHashMapInt` is not used by any `pub` functions, thus it is ignored.
// The type `AssetIdMapUInt` is not used by any `pub` functions, thus it is ignored.

@freezed
class Address with _$Address {
const Address._();
const factory Address({
required String standard,
required String confidential,
required int index,
}) = _Address;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class Address {
final String standard;
final String confidential;
final int index;

const Address({
required this.standard,
required this.confidential,
required this.index,
});

static Future<Address> addressFromScript(
{required Network network,
required String script,
Expand All @@ -36,14 +38,41 @@ class Address with _$Address {
{required String addressString, dynamic hint}) =>
LwkCore.instance.api
.addressValidate(addressString: addressString, hint: hint);

@override
int get hashCode =>
standard.hashCode ^ confidential.hashCode ^ index.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Address &&
runtimeType == other.runtimeType &&
standard == other.standard &&
confidential == other.confidential &&
index == other.index;
}

@freezed
class Balance with _$Balance {
const factory Balance({
required String assetId,
required int value,
}) = _Balance;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class Balance {
final String assetId;
final int value;

const Balance({
required this.assetId,
required this.value,
});

@override
int get hashCode => assetId.hashCode ^ value.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Balance &&
runtimeType == other.runtimeType &&
assetId == other.assetId &&
value == other.value;
}

class Blockchain {
Expand All @@ -62,17 +91,32 @@ class Blockchain {
other is Blockchain && runtimeType == other.runtimeType;
}

///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
enum Network {
mainnet,
testnet,
}

@freezed
class OutPoint with _$OutPoint {
const factory OutPoint({
required String txid,
required int vout,
}) = _OutPoint;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class OutPoint {
final String txid;
final int vout;

const OutPoint({
required this.txid,
required this.vout,
});

@override
int get hashCode => txid.hashCode ^ vout.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is OutPoint &&
runtimeType == other.runtimeType &&
txid == other.txid &&
vout == other.vout;
}

class PsetAmounts {
Expand All @@ -96,38 +140,119 @@ class PsetAmounts {
balances == other.balances;
}

@freezed
class Tx with _$Tx {
const factory Tx({
int? timestamp,
required String kind,
required List<Balance> balances,
required String txid,
required List<TxOut> outputs,
required List<TxOut> inputs,
required int fee,
int? height,
required String unblindedUrl,
required int vsize,
}) = _Tx;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class Tx {
final int? timestamp;
final String kind;
final List<Balance> balances;
final String txid;
final List<TxOut> outputs;
final List<TxOut> inputs;
final int fee;
final int? height;
final String unblindedUrl;
final int vsize;

const Tx({
this.timestamp,
required this.kind,
required this.balances,
required this.txid,
required this.outputs,
required this.inputs,
required this.fee,
this.height,
required this.unblindedUrl,
required this.vsize,
});

@override
int get hashCode =>
timestamp.hashCode ^
kind.hashCode ^
balances.hashCode ^
txid.hashCode ^
outputs.hashCode ^
inputs.hashCode ^
fee.hashCode ^
height.hashCode ^
unblindedUrl.hashCode ^
vsize.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is Tx &&
runtimeType == other.runtimeType &&
timestamp == other.timestamp &&
kind == other.kind &&
balances == other.balances &&
txid == other.txid &&
outputs == other.outputs &&
inputs == other.inputs &&
fee == other.fee &&
height == other.height &&
unblindedUrl == other.unblindedUrl &&
vsize == other.vsize;
}

@freezed
class TxOut with _$TxOut {
const factory TxOut({
required String scriptPubkey,
required OutPoint outpoint,
int? height,
required TxOutSecrets unblinded,
}) = _TxOut;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class TxOut {
final String scriptPubkey;
final OutPoint outpoint;
final int? height;
final TxOutSecrets unblinded;

const TxOut({
required this.scriptPubkey,
required this.outpoint,
this.height,
required this.unblinded,
});

@override
int get hashCode =>
scriptPubkey.hashCode ^
outpoint.hashCode ^
height.hashCode ^
unblinded.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TxOut &&
runtimeType == other.runtimeType &&
scriptPubkey == other.scriptPubkey &&
outpoint == other.outpoint &&
height == other.height &&
unblinded == other.unblinded;
}

@freezed
class TxOutSecrets with _$TxOutSecrets {
const factory TxOutSecrets({
required int value,
required String valueBf,
required String asset,
required String assetBf,
}) = _TxOutSecrets;
///frb_encoded(235b66726228646172745f6d657461646174613d2822667265657a65642229295d)
class TxOutSecrets {
final int value;
final String valueBf;
final String asset;
final String assetBf;

const TxOutSecrets({
required this.value,
required this.valueBf,
required this.asset,
required this.assetBf,
});

@override
int get hashCode =>
value.hashCode ^ valueBf.hashCode ^ asset.hashCode ^ assetBf.hashCode;

@override
bool operator ==(Object other) =>
identical(this, other) ||
other is TxOutSecrets &&
runtimeType == other.runtimeType &&
value == other.value &&
valueBf == other.valueBf &&
asset == other.asset &&
assetBf == other.assetBf;
}
10 changes: 3 additions & 7 deletions lib/src/generated/frb_generated.io.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1193,14 +1193,10 @@ class LwkCoreWire implements BaseWire {
_dummy_method_to_enforce_bundlingPtr.asFunction<int Function()>();
}

typedef DartPostCObjectFnType
= ffi.Pointer<ffi.NativeFunction<DartPostCObjectFnTypeFunction>>;
typedef DartPostCObjectFnTypeFunction = ffi.Bool Function(
DartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartDartPostCObjectFnTypeFunction = bool Function(
DartDartPort port_id, ffi.Pointer<ffi.Void> message);
typedef DartPostCObjectFnType = ffi.Pointer<
ffi.NativeFunction<
ffi.Bool Function(DartPort port_id, ffi.Pointer<ffi.Void> message)>>;
typedef DartPort = ffi.Int64;
typedef DartDartPort = int;

final class wire_cst_list_prim_u_8_strict extends ffi.Struct {
external ffi.Pointer<ffi.Uint8> ptr;
Expand Down
Loading

0 comments on commit 70e0e12

Please sign in to comment.