diff --git a/.gitignore b/.gitignore index 4341a5df..08b7dbe9 100644 --- a/.gitignore +++ b/.gitignore @@ -9,7 +9,7 @@ build/ .env -pubspec.lock +**/pubspec.lock rust/target rust/Cargo.lock @@ -30,7 +30,6 @@ _main.dart *.log *.pyc *.swp -.DS_Store .atom/ .buildlog/ .history @@ -39,7 +38,6 @@ _main.dart # IntelliJ related *.ipr *.iws -.idea/ # The .vscode folder contains launch configuration and tasks you configure in # VS Code which you may wish to be included in version control, so this line @@ -47,14 +45,9 @@ _main.dart #.vscode/ # Flutter/Dart/Pub related -pubspec.lock pubspec_overrides.yaml **/doc/api/ -.dart_tool/ -.packages -build/ .pub-cache/ -.pub/ .flutter-plugins .flutter-plugins-dependencies diff --git a/analysis_options.yaml b/analysis_options.yaml index 326b990b..d419afc5 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,6 +1,8 @@ -include: package:flutter_lints/flutter.yaml +include: package:lints/recommended.yaml analyzer: + errors: + invalid_annotation_target: ignore exclude: - 'packages/**/**.g.dart' - 'packages/**/**.freezed.dart' diff --git a/melos.yaml b/melos.yaml index 661a0d9b..060f2754 100644 --- a/melos.yaml +++ b/melos.yaml @@ -4,6 +4,9 @@ repository: https://github.com/AstroxNetwork/agent_dart packages: - packages/** +ignore: + - 'packages/agent_dart/cargokit/build_tool' + ide: intellij: enabled: true diff --git a/packages/agent_dart/agent_dart.iml b/packages/agent_dart/agent_dart.iml index 8fd214fe..64d7623d 100644 --- a/packages/agent_dart/agent_dart.iml +++ b/packages/agent_dart/agent_dart.iml @@ -21,10 +21,13 @@ + + + - + \ No newline at end of file diff --git a/packages/agent_dart/android/CMakeLists.txt b/packages/agent_dart/android/CMakeLists.txt deleted file mode 100644 index bba01cfa..00000000 --- a/packages/agent_dart/android/CMakeLists.txt +++ /dev/null @@ -1,34 +0,0 @@ -set(LibraryVersion "agent_dart-v0.0.0") # generated; do not edit - -# Unlike the Windows & Linux CMakeLists.txt, this Android equivalent is just here -# to download the Android binaries into src/main/jniLibs/ and does not build anything. -# The binary download/extraction is difficult to do concisely in Groovy/Gradle, -# at least across host platforms, so we are just reusing our Linux/Windows logic. - -# The Flutter tooling requires that developers have CMake 3.10 or later -# installed. You should not increase this version, as doing so will cause -# the plugin to fail to compile for some customers of the plugin. -cmake_minimum_required(VERSION 3.10) - -# Project-level configuration. -set(PROJECT_NAME "agent_dart") # Should match the name field in the pubspec.yaml. -project(PROJECT_NAME) - -# Download the binaries if they are not already present. -set(LibRoot "${CMAKE_CURRENT_SOURCE_DIR}/src/main/jniLibs") -set(ArchivePath "${CMAKE_CURRENT_SOURCE_DIR}/${LibraryVersion}.tar.gz") -if(NOT EXISTS ${ArchivePath}) - file(DOWNLOAD - "https://github.com/AstroxNetwork/agent_dart/releases/download/${LibraryVersion}/android.tar.gz" - ${ArchivePath} - TLS_VERIFY ON - ) -endif() - -# Extract the binaries, overriding any already present. -file(REMOVE_RECURSE ${LibRoot}) -file(MAKE_DIRECTORY ${LibRoot}) -execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath} - WORKING_DIRECTORY ${LibRoot} -) \ No newline at end of file diff --git a/packages/agent_dart/android/build.gradle b/packages/agent_dart/android/build.gradle index a50e5ff2..a1eacec8 100644 --- a/packages/agent_dart/android/build.gradle +++ b/packages/agent_dart/android/build.gradle @@ -1,16 +1,17 @@ +// The Android Gradle Plugin builds the native code with the Android NDK. + group 'com.astrox.agent_dart' -version '1.0-SNAPSHOT' +version '1.0.0-SNAPSHOT' buildscript { - ext.kotlin_version = '1.6.10' repositories { google() mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:7.0.2' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" + // The Android Gradle Plugin knows how to build native code with the NDK. + classpath 'com.android.tools.build:gradle:7.3.0' } } @@ -22,22 +23,37 @@ rootProject.allprojects { } apply plugin: 'com.android.library' -apply plugin: 'kotlin-android' android { - compileSdkVersion 31 + if (project.android.hasProperty("namespace")) { + namespace 'com.astrox.agent_dart' + } + + // Bumping the plugin compileSdkVersion requires all clients of this plugin + // to bump the version in their app. + compileSdkVersion 33 defaultConfig { - minSdkVersion 16 + minSdkVersion 19 } - // Trigger the binary download/update over in CMakeLists.txt - externalNativeBuild { - cmake { - path "CMakeLists.txt" - } + // Use the NDK version + // declared in /android/app/build.gradle file of the Flutter project. + // Replace it with a version number if this plugin requires a specfic NDK version. + // (e.g. ndkVersion "23.1.7779620") + ndkVersion android.ndkVersion + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 } } dependencies { } + +apply from: "../cargokit/gradle/plugin.gradle" +cargokit { + manifestDir = "../../agent_dart_ffi/native/agent_dart" + libname = "agent_dart" +} diff --git a/packages/agent_dart/android/gradle.properties b/packages/agent_dart/android/gradle.properties deleted file mode 100644 index 94adc3a3..00000000 --- a/packages/agent_dart/android/gradle.properties +++ /dev/null @@ -1,3 +0,0 @@ -org.gradle.jvmargs=-Xmx1536M -android.useAndroidX=true -android.enableJetifier=true diff --git a/packages/agent_dart/android/gradle/wrapper/gradle-wrapper.properties b/packages/agent_dart/android/gradle/wrapper/gradle-wrapper.properties deleted file mode 100644 index 3c9d0852..00000000 --- a/packages/agent_dart/android/gradle/wrapper/gradle-wrapper.properties +++ /dev/null @@ -1,5 +0,0 @@ -distributionBase=GRADLE_USER_HOME -distributionPath=wrapper/dists -zipStoreBase=GRADLE_USER_HOME -zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip diff --git a/packages/agent_dart/android/src/main/kotlin/com/astrox/agent_dart/AgentDartPlugin.kt b/packages/agent_dart/android/src/main/kotlin/com/astrox/agent_dart/AgentDartPlugin.kt deleted file mode 100644 index 29f095db..00000000 --- a/packages/agent_dart/android/src/main/kotlin/com/astrox/agent_dart/AgentDartPlugin.kt +++ /dev/null @@ -1,35 +0,0 @@ -package com.astrox.agent_dart - -import androidx.annotation.NonNull - -import io.flutter.embedding.engine.plugins.FlutterPlugin -import io.flutter.plugin.common.MethodCall -import io.flutter.plugin.common.MethodChannel -import io.flutter.plugin.common.MethodChannel.MethodCallHandler -import io.flutter.plugin.common.MethodChannel.Result - -/** AgentDartPlugin */ -class AgentDartPlugin: FlutterPlugin, MethodCallHandler { - /// The MethodChannel that will the communication between Flutter and native Android - /// - /// This local reference serves to register the plugin with the Flutter Engine and unregister it - /// when the Flutter Engine is detached from the Activity - private lateinit var channel : MethodChannel - - override fun onAttachedToEngine(@NonNull flutterPluginBinding: FlutterPlugin.FlutterPluginBinding) { - channel = MethodChannel(flutterPluginBinding.binaryMessenger, "agent_dart") - channel.setMethodCallHandler(this) - } - - override fun onMethodCall(@NonNull call: MethodCall, @NonNull result: Result) { - if (call.method == "getPlatformVersion") { - result.success("Android ${android.os.Build.VERSION.RELEASE}") - } else { - result.notImplemented() - } - } - - override fun onDetachedFromEngine(@NonNull binding: FlutterPlugin.FlutterPluginBinding) { - channel.setMethodCallHandler(null) - } -} diff --git a/packages/agent_dart/cargokit/.gitignore b/packages/agent_dart/cargokit/.gitignore new file mode 100644 index 00000000..cf145183 --- /dev/null +++ b/packages/agent_dart/cargokit/.gitignore @@ -0,0 +1,3 @@ +target +.dart_tool +*.iml diff --git a/packages/agent_dart/cargokit/LICENSE b/packages/agent_dart/cargokit/LICENSE new file mode 100644 index 00000000..d33a5fea --- /dev/null +++ b/packages/agent_dart/cargokit/LICENSE @@ -0,0 +1,42 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +Copyright 2022 Matej Knopp + +================================================================================ + +MIT LICENSE + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS +OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +================================================================================ + +APACHE LICENSE, VERSION 2.0 + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. + diff --git a/packages/agent_dart/cargokit/README b/packages/agent_dart/cargokit/README new file mode 100644 index 00000000..398474db --- /dev/null +++ b/packages/agent_dart/cargokit/README @@ -0,0 +1,11 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +Experimental repository to provide glue for seamlessly integrating cargo build +with flutter plugins and packages. + +See https://matejknopp.com/post/flutter_plugin_in_rust_with_no_prebuilt_binaries/ +for a tutorial on how to use Cargokit. + +Example plugin available at https://github.com/irondash/hello_rust_ffi_plugin. + diff --git a/packages/agent_dart/cargokit/build_pod.sh b/packages/agent_dart/cargokit/build_pod.sh new file mode 100644 index 00000000..ed0e0d98 --- /dev/null +++ b/packages/agent_dart/cargokit/build_pod.sh @@ -0,0 +1,58 @@ +#!/bin/sh +set -e + +BASEDIR=$(dirname "$0") + +# Workaround for https://github.com/dart-lang/pub/issues/4010 +BASEDIR=$(cd "$BASEDIR" ; pwd -P) + +# Remove XCode SDK from path. Otherwise this breaks tool compilation when building iOS project +NEW_PATH=`echo $PATH | tr ":" "\n" | grep -v "Contents/Developer/" | tr "\n" ":"` + +export PATH=${NEW_PATH%?} # remove trailing : + +env + +# Platform name (macosx, iphoneos, iphonesimulator) +export CARGOKIT_DARWIN_PLATFORM_NAME=$PLATFORM_NAME + +# Arctive architectures (arm64, armv7, x86_64), space separated. +export CARGOKIT_DARWIN_ARCHS=$ARCHS + +# Current build configuration (Debug, Release) +export CARGOKIT_CONFIGURATION=$CONFIGURATION + +# Path to directory containing Cargo.toml. +export CARGOKIT_MANIFEST_DIR=$PODS_TARGET_SRCROOT/$1 + +# Temporary directory for build artifacts. +export CARGOKIT_TARGET_TEMP_DIR=$TARGET_TEMP_DIR + +# Output directory for final artifacts. +export CARGOKIT_OUTPUT_DIR=$PODS_CONFIGURATION_BUILD_DIR/$PRODUCT_NAME + +# Directory to store built tool artifacts. +export CARGOKIT_TOOL_TEMP_DIR=$TARGET_TEMP_DIR/build_tool + +# Directory inside root project. Not necessarily the top level directory of root project. +export CARGOKIT_ROOT_PROJECT_DIR=$SRCROOT + +FLUTTER_EXPORT_BUILD_ENVIRONMENT=( + "$PODS_ROOT/../Flutter/ephemeral/flutter_export_environment.sh" # macOS + "$PODS_ROOT/../Flutter/flutter_export_environment.sh" # iOS +) + +for path in "${FLUTTER_EXPORT_BUILD_ENVIRONMENT[@]}" +do + if [[ -f "$path" ]]; then + source "$path" + fi +done + +sh "$BASEDIR/run_build_tool.sh" build-pod "$@" + +# Make a symlink from built framework to phony file, which will be used as input to +# build script. This should force rebuild (podspec currently doesn't support alwaysOutOfDate +# attribute on custom build phase) +ln -fs "$OBJROOT/XCBuildData/build.db" "${BUILT_PRODUCTS_DIR}/cargokit_phony" +ln -fs "${BUILT_PRODUCTS_DIR}/${EXECUTABLE_PATH}" "${BUILT_PRODUCTS_DIR}/cargokit_phony_out" diff --git a/packages/agent_dart/cargokit/build_tool/README.md b/packages/agent_dart/cargokit/build_tool/README.md new file mode 100644 index 00000000..a878c279 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/README.md @@ -0,0 +1,5 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +A sample command-line application with an entrypoint in `bin/`, library code +in `lib/`, and example unit test in `test/`. diff --git a/packages/agent_dart/cargokit/build_tool/analysis_options.yaml b/packages/agent_dart/cargokit/build_tool/analysis_options.yaml new file mode 100644 index 00000000..0e16a8b0 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/analysis_options.yaml @@ -0,0 +1,34 @@ +# This is copied from Cargokit (which is the official way to use it currently) +# Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +# This file configures the static analysis results for your project (errors, +# warnings, and lints). +# +# This enables the 'recommended' set of lints from `package:lints`. +# This set helps identify many issues that may lead to problems when running +# or consuming Dart code, and enforces writing Dart using a single, idiomatic +# style and format. +# +# If you want a smaller set of lints you can change this to specify +# 'package:lints/core.yaml'. These are just the most critical lints +# (the recommended set includes the core lints). +# The core lints are also what is used by pub.dev for scoring packages. + +include: package:lints/recommended.yaml + +# Uncomment the following section to specify additional rules. + +linter: + rules: + - prefer_relative_imports + - directives_ordering + +# analyzer: +# exclude: +# - path/to/excluded/files/** + +# For more information about the core and recommended set of lints, see +# https://dart.dev/go/core-lints + +# For additional information about configuring this file, see +# https://dart.dev/guides/language/analysis-options diff --git a/packages/agent_dart/cargokit/build_tool/bin/build_tool.dart b/packages/agent_dart/cargokit/build_tool/bin/build_tool.dart new file mode 100644 index 00000000..268eb524 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/bin/build_tool.dart @@ -0,0 +1,8 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'package:build_tool/build_tool.dart' as build_tool; + +void main(List arguments) { + build_tool.runMain(arguments); +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/build_tool.dart b/packages/agent_dart/cargokit/build_tool/lib/build_tool.dart new file mode 100644 index 00000000..7c1bb750 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/build_tool.dart @@ -0,0 +1,8 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'src/build_tool.dart' as build_tool; + +Future runMain(List args) async { + return build_tool.runMain(args); +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/android_environment.dart b/packages/agent_dart/cargokit/build_tool/lib/src/android_environment.dart new file mode 100644 index 00000000..15fc9eed --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/android_environment.dart @@ -0,0 +1,195 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; +import 'dart:isolate'; +import 'dart:math' as math; + +import 'package:collection/collection.dart'; +import 'package:path/path.dart' as path; +import 'package:version/version.dart'; + +import 'target.dart'; +import 'util.dart'; + +class AndroidEnvironment { + AndroidEnvironment({ + required this.sdkPath, + required this.ndkVersion, + required this.minSdkVersion, + required this.targetTempDir, + required this.target, + }); + + static void clangLinkerWrapper(List args) { + final clang = Platform.environment['_CARGOKIT_NDK_LINK_CLANG']; + if (clang == null) { + throw Exception( + "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_CLANG env var"); + } + final target = Platform.environment['_CARGOKIT_NDK_LINK_TARGET']; + if (target == null) { + throw Exception( + "cargo-ndk rustc linker: didn't find _CARGOKIT_NDK_LINK_TARGET env var"); + } + + runCommand(clang, [ + target, + ...args, + ]); + } + + /// Full path to Android SDK. + final String sdkPath; + + /// Full version of Android NDK. + final String ndkVersion; + + /// Minimum supported SDK version. + final int minSdkVersion; + + /// Target directory for build artifacts. + final String targetTempDir; + + /// Target being built. + final Target target; + + bool ndkIsInstalled() { + final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); + final ndkPackageXml = File(path.join(ndkPath, 'package.xml')); + return ndkPackageXml.existsSync(); + } + + void installNdk({ + required String javaHome, + }) { + final sdkManagerExtension = Platform.isWindows ? '.bat' : ''; + final sdkManager = path.join( + sdkPath, + 'cmdline-tools', + 'latest', + 'bin', + 'sdkmanager$sdkManagerExtension', + ); + + log.info('Installing NDK $ndkVersion'); + runCommand(sdkManager, [ + '--install', + 'ndk;$ndkVersion', + ], environment: { + 'JAVA_HOME': javaHome, + }); + } + + Future> buildEnvironment() async { + final hostArch = Platform.isMacOS + ? "darwin-x86_64" + : (Platform.isLinux ? "linux-x86_64" : "windows-x86_64"); + + final ndkPath = path.join(sdkPath, 'ndk', ndkVersion); + final toolchainPath = path.join( + ndkPath, + 'toolchains', + 'llvm', + 'prebuilt', + hostArch, + 'bin', + ); + + final minSdkVersion = + math.max(target.androidMinSdkVersion!, this.minSdkVersion); + + final exe = Platform.isWindows ? '.exe' : ''; + + final arKey = 'AR_${target.rust}'; + final arValue = ['${target.rust}-ar', 'llvm-ar', 'llvm-ar.exe'] + .map((e) => path.join(toolchainPath, e)) + .firstWhereOrNull((element) => File(element).existsSync()); + if (arValue == null) { + throw Exception('Failed to find ar for $target in $toolchainPath'); + } + + final targetArg = '--target=${target.rust}$minSdkVersion'; + + final ccKey = 'CC_${target.rust}'; + final ccValue = path.join(toolchainPath, 'clang$exe'); + final cfFlagsKey = 'CFLAGS_${target.rust}'; + final cFlagsValue = targetArg; + + final cxxKey = 'CXX_${target.rust}'; + final cxxValue = path.join(toolchainPath, 'clang++$exe'); + final cxxFlagsKey = 'CXXFLAGS_${target.rust}'; + final cxxFlagsValue = targetArg; + + final linkerKey = + 'cargo_target_${target.rust.replaceAll('-', '_')}_linker'.toUpperCase(); + + final ranlibKey = 'RANLIB_${target.rust}'; + final ranlibValue = path.join(toolchainPath, 'llvm-ranlib$exe'); + + final ndkVersionParsed = Version.parse(ndkVersion); + final rustFlagsKey = 'CARGO_ENCODED_RUSTFLAGS'; + final rustFlagsValue = _libGccWorkaround(targetTempDir, ndkVersionParsed); + + final runRustTool = + Platform.isWindows ? 'run_build_tool.cmd' : 'run_build_tool.sh'; + + final packagePath = (await Isolate.resolvePackageUri( + Uri.parse('package:build_tool/buildtool.dart')))! + .toFilePath(); + final selfPath = path.canonicalize(path.join( + packagePath, + '..', + '..', + '..', + runRustTool, + )); + + // Make sure that run_build_tool is working properly even initially launched directly + // through dart run. + final toolTempDir = + Platform.environment['CARGOKIT_TOOL_TEMP_DIR'] ?? targetTempDir; + + return { + arKey: arValue, + ccKey: ccValue, + cfFlagsKey: cFlagsValue, + cxxKey: cxxValue, + cxxFlagsKey: cxxFlagsValue, + ranlibKey: ranlibValue, + rustFlagsKey: rustFlagsValue, + linkerKey: selfPath, + // Recognized by main() so we know when we're acting as a wrapper + '_CARGOKIT_NDK_LINK_TARGET': targetArg, + '_CARGOKIT_NDK_LINK_CLANG': ccValue, + 'CARGOKIT_TOOL_TEMP_DIR': toolTempDir, + }; + } + + // Workaround for libgcc missing in NDK23, inspired by cargo-ndk + String _libGccWorkaround(String buildDir, Version ndkVersion) { + final workaroundDir = path.join( + buildDir, + 'cargokit', + 'libgcc_workaround', + '${ndkVersion.major}', + ); + Directory(workaroundDir).createSync(recursive: true); + if (ndkVersion.major >= 23) { + File(path.join(workaroundDir, 'libgcc.a')) + .writeAsStringSync('INPUT(-lunwind)'); + } else { + // Other way around, untested, forward libgcc.a from libunwind once Rust + // gets updated for NDK23+. + File(path.join(workaroundDir, 'libunwind.a')) + .writeAsStringSync('INPUT(-lgcc)'); + } + + var rustFlags = Platform.environment['CARGO_ENCODED_RUSTFLAGS'] ?? ''; + if (rustFlags.isNotEmpty) { + rustFlags = '$rustFlags\x1f'; + } + rustFlags = '$rustFlags-L\x1f$workaroundDir'; + return rustFlags; + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/artifacts_provider.dart b/packages/agent_dart/cargokit/build_tool/lib/src/artifacts_provider.dart new file mode 100644 index 00000000..e608cece --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/artifacts_provider.dart @@ -0,0 +1,266 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:ed25519_edwards/ed25519_edwards.dart'; +import 'package:http/http.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; + +import 'builder.dart'; +import 'crate_hash.dart'; +import 'options.dart'; +import 'precompile_binaries.dart'; +import 'rustup.dart'; +import 'target.dart'; + +class Artifact { + /// File system location of the artifact. + final String path; + + /// Actual file name that the artifact should have in destination folder. + final String finalFileName; + + AritifactType get type { + if (finalFileName.endsWith('.dll') || + finalFileName.endsWith('.dll.lib') || + finalFileName.endsWith('.pdb') || + finalFileName.endsWith('.so') || + finalFileName.endsWith('.dylib')) { + return AritifactType.dylib; + } else if (finalFileName.endsWith('.lib') || finalFileName.endsWith('.a')) { + return AritifactType.staticlib; + } else { + throw Exception('Unknown artifact type for $finalFileName'); + } + } + + Artifact({ + required this.path, + required this.finalFileName, + }); +} + +final _log = Logger('artifacts_provider'); + +class ArtifactProvider { + ArtifactProvider({ + required this.environment, + required this.userOptions, + }); + + final BuildEnvironment environment; + final CargokitUserOptions userOptions; + + Future>> getArtifacts(List targets) async { + final result = await _getPrecompiledArtifacts(targets); + + final pendingTargets = List.of(targets); + pendingTargets.removeWhere((element) => result.containsKey(element)); + + if (pendingTargets.isEmpty) { + return result; + } + + final rustup = Rustup(); + for (final target in targets) { + final builder = RustBuilder(target: target, environment: environment); + builder.prepare(rustup); + _log.info('Building ${environment.crateInfo.packageName} for $target'); + final targetDir = await builder.build(); + // For local build accept both static and dynamic libraries. + final artifactNames = { + ...getArtifactNames( + target: target, + libraryName: environment.crateInfo.packageName, + aritifactType: AritifactType.dylib, + remote: false, + ), + ...getArtifactNames( + target: target, + libraryName: environment.crateInfo.packageName, + aritifactType: AritifactType.staticlib, + remote: false, + ) + }; + final artifacts = artifactNames + .map((artifactName) => Artifact( + path: path.join(targetDir, artifactName), + finalFileName: artifactName, + )) + .where((element) => File(element.path).existsSync()) + .toList(); + result[target] = artifacts; + } + return result; + } + + Future>> _getPrecompiledArtifacts( + List targets) async { + if (userOptions.usePrecompiledBinaries == false) { + _log.info('Precompiled binaries are disabled'); + return {}; + } + if (environment.crateOptions.precompiledBinaries == null) { + _log.fine('Precompiled binaries not enabled for this crate'); + return {}; + } + + final start = Stopwatch()..start(); + final crateHash = CrateHash.compute(environment.manifestDir, + tempStorage: environment.targetTempDir); + _log.fine( + 'Computed crate hash $crateHash in ${start.elapsedMilliseconds}ms'); + + final downloadedArtifactsDir = + path.join(environment.targetTempDir, 'precompiled', crateHash); + Directory(downloadedArtifactsDir).createSync(recursive: true); + + final res = >{}; + + for (final target in targets) { + final requiredArtifacts = getArtifactNames( + target: target, + libraryName: environment.crateInfo.packageName, + remote: true, + ); + final artifactsForTarget = []; + + for (final artifact in requiredArtifacts) { + final fileName = PrecompileBinaries.fileName(target, artifact); + final downloadedPath = path.join(downloadedArtifactsDir, fileName); + if (!File(downloadedPath).existsSync()) { + final signatureFileName = + PrecompileBinaries.signatureFileName(target, artifact); + await _tryDownloadArtifacts( + crateHash: crateHash, + fileName: fileName, + signatureFileName: signatureFileName, + finalPath: downloadedPath, + ); + } + if (File(downloadedPath).existsSync()) { + artifactsForTarget.add(Artifact( + path: downloadedPath, + finalFileName: artifact, + )); + } else { + break; + } + } + + // Only provide complete set of artifacts. + if (artifactsForTarget.length == requiredArtifacts.length) { + _log.fine('Found precompiled artifacts for $target'); + res[target] = artifactsForTarget; + } + } + + return res; + } + + static Future _get(Uri url, {Map? headers}) async { + int attempt = 0; + const maxAttempts = 10; + while (true) { + try { + return await get(url, headers: headers); + } on SocketException catch (e) { + // Try to detect reset by peer error and retry. + if (attempt++ < maxAttempts && + (e.osError?.errorCode == 54 || e.osError?.errorCode == 10054)) { + _log.severe( + 'Failed to download $url: $e, attempt $attempt of $maxAttempts, will retry...'); + await Future.delayed(Duration(seconds: 1)); + continue; + } else { + rethrow; + } + } + } + } + + Future _tryDownloadArtifacts({ + required String crateHash, + required String fileName, + required String signatureFileName, + required String finalPath, + }) async { + final precompiledBinaries = environment.crateOptions.precompiledBinaries!; + final prefix = precompiledBinaries.uriPrefix; + final url = Uri.parse('$prefix$crateHash/$fileName'); + final signatureUrl = Uri.parse('$prefix$crateHash/$signatureFileName'); + _log.fine('Downloading signature from $signatureUrl'); + final signature = await _get(signatureUrl); + if (signature.statusCode == 404) { + _log.warning( + 'Precompiled binaries not available for crate hash $crateHash ($fileName)'); + return; + } + if (signature.statusCode != 200) { + _log.severe( + 'Failed to download signature $signatureUrl: status ${signature.statusCode}'); + return; + } + _log.fine('Downloading binary from $url'); + final res = await _get(url); + if (res.statusCode != 200) { + _log.severe('Failed to download binary $url: status ${res.statusCode}'); + return; + } + if (verify( + precompiledBinaries.publicKey, res.bodyBytes, signature.bodyBytes)) { + File(finalPath).writeAsBytesSync(res.bodyBytes); + } else { + _log.shout('Signature verification failed! Ignoring binary.'); + } + } +} + +enum AritifactType { + staticlib, + dylib, +} + +AritifactType artifactTypeForTarget(Target target) { + if (target.darwinPlatform != null) { + return AritifactType.staticlib; + } else { + return AritifactType.dylib; + } +} + +List getArtifactNames({ + required Target target, + required String libraryName, + required bool remote, + AritifactType? aritifactType, +}) { + aritifactType ??= artifactTypeForTarget(target); + if (target.darwinArch != null) { + if (aritifactType == AritifactType.staticlib) { + return ['lib$libraryName.a']; + } else { + return ['lib$libraryName.dylib']; + } + } else if (target.rust.contains('-windows-')) { + if (aritifactType == AritifactType.staticlib) { + return ['$libraryName.lib']; + } else { + return [ + '$libraryName.dll', + '$libraryName.dll.lib', + if (!remote) '$libraryName.pdb' + ]; + } + } else if (target.rust.contains('-linux-')) { + if (aritifactType == AritifactType.staticlib) { + return ['lib$libraryName.a']; + } else { + return ['lib$libraryName.so']; + } + } else { + throw Exception("Unsupported target: ${target.rust}"); + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/build_cmake.dart b/packages/agent_dart/cargokit/build_tool/lib/src/build_cmake.dart new file mode 100644 index 00000000..6f3b2a4e --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/build_cmake.dart @@ -0,0 +1,40 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:path/path.dart' as path; + +import 'artifacts_provider.dart'; +import 'builder.dart'; +import 'environment.dart'; +import 'options.dart'; +import 'target.dart'; + +class BuildCMake { + final CargokitUserOptions userOptions; + + BuildCMake({required this.userOptions}); + + Future build() async { + final targetPlatform = Environment.targetPlatform; + final target = Target.forFlutterName(Environment.targetPlatform); + if (target == null) { + throw Exception("Unknown target platform: $targetPlatform"); + } + + final environment = BuildEnvironment.fromEnvironment(isAndroid: false); + final provider = + ArtifactProvider(environment: environment, userOptions: userOptions); + final artifacts = await provider.getArtifacts([target]); + + final libs = artifacts[target]!; + + for (final lib in libs) { + if (lib.type == AritifactType.dylib) { + File(lib.path) + .copySync(path.join(Environment.outputDir, lib.finalFileName)); + } + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/build_gradle.dart b/packages/agent_dart/cargokit/build_tool/lib/src/build_gradle.dart new file mode 100644 index 00000000..7e61fcbb --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/build_gradle.dart @@ -0,0 +1,49 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; + +import 'artifacts_provider.dart'; +import 'builder.dart'; +import 'environment.dart'; +import 'options.dart'; +import 'target.dart'; + +final log = Logger('build_gradle'); + +class BuildGradle { + BuildGradle({required this.userOptions}); + + final CargokitUserOptions userOptions; + + Future build() async { + final targets = Environment.targetPlatforms.map((arch) { + final target = Target.forFlutterName(arch); + if (target == null) { + throw Exception( + "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); + } + return target; + }).toList(); + + final environment = BuildEnvironment.fromEnvironment(isAndroid: true); + final provider = + ArtifactProvider(environment: environment, userOptions: userOptions); + final artifacts = await provider.getArtifacts(targets); + + for (final target in targets) { + final libs = artifacts[target]!; + final outputDir = path.join(Environment.outputDir, target.android!); + Directory(outputDir).createSync(recursive: true); + + for (final lib in libs) { + if (lib.type == AritifactType.dylib) { + File(lib.path).copySync(path.join(outputDir, lib.finalFileName)); + } + } + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/build_pod.dart b/packages/agent_dart/cargokit/build_tool/lib/src/build_pod.dart new file mode 100644 index 00000000..8a9c0db5 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/build_pod.dart @@ -0,0 +1,89 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:path/path.dart' as path; + +import 'artifacts_provider.dart'; +import 'builder.dart'; +import 'environment.dart'; +import 'options.dart'; +import 'target.dart'; +import 'util.dart'; + +class BuildPod { + BuildPod({required this.userOptions}); + + final CargokitUserOptions userOptions; + + Future build() async { + final targets = Environment.darwinArchs.map((arch) { + final target = Target.forDarwin( + platformName: Environment.darwinPlatformName, darwinAarch: arch); + if (target == null) { + throw Exception( + "Unknown darwin target or platform: $arch, ${Environment.darwinPlatformName}"); + } + return target; + }).toList(); + + final environment = BuildEnvironment.fromEnvironment(isAndroid: false); + final provider = + ArtifactProvider(environment: environment, userOptions: userOptions); + final artifacts = await provider.getArtifacts(targets); + + void performLipo(String targetFile, Iterable sourceFiles) { + runCommand("lipo", [ + '-create', + ...sourceFiles, + '-output', + targetFile, + ]); + } + + final outputDir = Environment.outputDir; + + Directory(outputDir).createSync(recursive: true); + + final staticLibs = artifacts.values + .expand((element) => element) + .where((element) => element.type == AritifactType.staticlib) + .toList(); + final dynamicLibs = artifacts.values + .expand((element) => element) + .where((element) => element.type == AritifactType.dylib) + .toList(); + + final libName = environment.crateInfo.packageName; + + // If there is static lib, use it and link it with pod + if (staticLibs.isNotEmpty) { + final finalTargetFile = path.join(outputDir, "lib$libName.a"); + performLipo(finalTargetFile, staticLibs.map((e) => e.path)); + } else { + // Otherwise try to replace bundle dylib with our dylib + final bundlePaths = [ + '$libName.framework/Versions/A/$libName', + '$libName.framework/$libName', + ]; + + for (final bundlePath in bundlePaths) { + final targetFile = path.join(outputDir, bundlePath); + if (File(targetFile).existsSync()) { + performLipo(targetFile, dynamicLibs.map((e) => e.path)); + + // Replace absolute id with @rpath one so that it works properly + // when moved to Frameworks. + runCommand("install_name_tool", [ + '-id', + '@rpath/$bundlePath', + targetFile, + ]); + return; + } + } + throw Exception('Unable to find bundle for dynamic library'); + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/build_tool.dart b/packages/agent_dart/cargokit/build_tool/lib/src/build_tool.dart new file mode 100644 index 00000000..c8f36981 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/build_tool.dart @@ -0,0 +1,271 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:args/command_runner.dart'; +import 'package:ed25519_edwards/ed25519_edwards.dart'; +import 'package:github/github.dart'; +import 'package:hex/hex.dart'; +import 'package:logging/logging.dart'; + +import 'android_environment.dart'; +import 'build_cmake.dart'; +import 'build_gradle.dart'; +import 'build_pod.dart'; +import 'logging.dart'; +import 'options.dart'; +import 'precompile_binaries.dart'; +import 'target.dart'; +import 'util.dart'; +import 'verify_binaries.dart'; + +final log = Logger('build_tool'); + +abstract class BuildCommand extends Command { + Future runBuildCommand(CargokitUserOptions options); + + @override + Future run() async { + final options = CargokitUserOptions.load(); + + if (options.verboseLogging || + Platform.environment['CARGOKIT_VERBOSE'] == '1') { + enableVerboseLogging(); + } + + await runBuildCommand(options); + } +} + +class BuildPodCommand extends BuildCommand { + @override + final name = 'build-pod'; + + @override + final description = 'Build cocoa pod library'; + + @override + Future runBuildCommand(CargokitUserOptions options) async { + final build = BuildPod(userOptions: options); + await build.build(); + } +} + +class BuildGradleCommand extends BuildCommand { + @override + final name = 'build-gradle'; + + @override + final description = 'Build android library'; + + @override + Future runBuildCommand(CargokitUserOptions options) async { + final build = BuildGradle(userOptions: options); + await build.build(); + } +} + +class BuildCMakeCommand extends BuildCommand { + @override + final name = 'build-cmake'; + + @override + final description = 'Build CMake library'; + + @override + Future runBuildCommand(CargokitUserOptions options) async { + final build = BuildCMake(userOptions: options); + await build.build(); + } +} + +class GenKeyCommand extends Command { + @override + final name = 'gen-key'; + + @override + final description = 'Generate key pair for signing precompiled binaries'; + + @override + void run() { + final kp = generateKey(); + final private = HEX.encode(kp.privateKey.bytes); + final public = HEX.encode(kp.publicKey.bytes); + print("Private Key: $private"); + print("Public Key: $public"); + } +} + +class PrecompileBinariesCommand extends Command { + PrecompileBinariesCommand() { + argParser + ..addOption( + 'repository', + mandatory: true, + help: 'Github repository slug in format owner/name', + ) + ..addOption( + 'manifest-dir', + mandatory: true, + help: 'Directory containing Cargo.toml', + ) + ..addMultiOption('target', + help: 'Rust target triple of artifact to build.\n' + 'Can be specified multiple times or omitted in which case\n' + 'all targets for current platform will be built.') + ..addOption( + 'android-sdk-location', + help: 'Location of Android SDK (if available)', + ) + ..addOption( + 'android-ndk-version', + help: 'Android NDK version (if available)', + ) + ..addOption( + 'android-min-sdk-version', + help: 'Android minimum rquired version (if available)', + ) + ..addOption( + 'temp-dir', + help: 'Directory to store temporary build artifacts', + ) + ..addFlag( + "verbose", + abbr: "v", + defaultsTo: false, + help: "Enable verbose logging", + ); + } + + @override + final name = 'precompile-binaries'; + + @override + final description = 'Prebuild and upload binaries\n' + 'Private key must be passed through PRIVATE_KEY environment variable. ' + 'Use gen_key through generate priave key.\n' + 'Github token must be passed as GITHUB_TOKEN environment variable.\n'; + + @override + Future run() async { + final verbose = argResults!['verbose'] as bool; + if (verbose) { + enableVerboseLogging(); + } + + final privateKeyString = Platform.environment['PRIVATE_KEY']; + if (privateKeyString == null) { + throw ArgumentError('Missing PRIVATE_KEY environment variable'); + } + final githubToken = Platform.environment['GITHUB_TOKEN']; + if (githubToken == null) { + throw ArgumentError('Missing GITHUB_TOKEN environment variable'); + } + final privateKey = HEX.decode(privateKeyString); + if (privateKey.length != 64) { + throw ArgumentError('Private key must be 64 bytes long'); + } + final manifestDir = argResults!['manifest-dir'] as String; + if (!Directory(manifestDir).existsSync()) { + throw ArgumentError('Manifest directory does not exist: $manifestDir'); + } + String? androidMinSdkVersionString = + argResults!['android-min-sdk-version'] as String?; + int? androidMinSdkVersion; + if (androidMinSdkVersionString != null) { + androidMinSdkVersion = int.tryParse(androidMinSdkVersionString); + if (androidMinSdkVersion == null) { + throw ArgumentError( + 'Invalid android-min-sdk-version: $androidMinSdkVersionString'); + } + } + final targetStrigns = argResults!['target'] as List; + final targets = targetStrigns.map((target) { + final res = Target.forRustTriple(target); + if (res == null) { + throw ArgumentError('Invalid target: $target'); + } + return res; + }).toList(growable: false); + final precompileBinaries = PrecompileBinaries( + privateKey: PrivateKey(privateKey), + githubToken: githubToken, + manifestDir: manifestDir, + repositorySlug: RepositorySlug.full(argResults!['repository'] as String), + targets: targets, + androidSdkLocation: argResults!['android-sdk-location'] as String?, + androidNdkVersion: argResults!['android-ndk-version'] as String?, + androidMinSdkVersion: androidMinSdkVersion, + tempDir: argResults!['temp-dir'] as String?, + ); + + await precompileBinaries.run(); + } +} + +class VerifyBinariesCommand extends Command { + VerifyBinariesCommand() { + argParser.addOption( + 'manifest-dir', + mandatory: true, + help: 'Directory containing Cargo.toml', + ); + } + + @override + final name = "verify-binaries"; + + @override + final description = 'Verifies published binaries\n' + 'Checks whether there is a binary published for each targets\n' + 'and checks the signature.'; + + @override + Future run() async { + final manifestDir = argResults!['manifest-dir'] as String; + final verifyBinaries = VerifyBinaries( + manifestDir: manifestDir, + ); + await verifyBinaries.run(); + } +} + +Future runMain(List args) async { + try { + // Init logging before options are loaded + initLogging(); + + if (Platform.environment['_CARGOKIT_NDK_LINK_TARGET'] != null) { + return AndroidEnvironment.clangLinkerWrapper(args); + } + + final runner = CommandRunner('build_tool', 'Cargokit built_tool') + ..addCommand(BuildPodCommand()) + ..addCommand(BuildGradleCommand()) + ..addCommand(BuildCMakeCommand()) + ..addCommand(GenKeyCommand()) + ..addCommand(PrecompileBinariesCommand()) + ..addCommand(VerifyBinariesCommand()); + + await runner.run(args); + } on ArgumentError catch (e) { + stderr.writeln(e.toString()); + exit(1); + } catch (e, s) { + log.severe(kDoubleSeparator); + log.severe('Cargokit BuildTool failed with error:'); + log.severe(kSeparator); + log.severe(e); + // This tells user to install Rust, there's no need to pollute the log with + // stack trace. + if (e is! RustupNotFoundException) { + log.severe(kSeparator); + log.severe(s); + log.severe(kSeparator); + log.severe('BuildTool arguments: $args'); + } + log.severe(kDoubleSeparator); + exit(1); + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/builder.dart b/packages/agent_dart/cargokit/build_tool/lib/src/builder.dart new file mode 100644 index 00000000..84c46e4f --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/builder.dart @@ -0,0 +1,198 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'package:collection/collection.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; + +import 'android_environment.dart'; +import 'cargo.dart'; +import 'environment.dart'; +import 'options.dart'; +import 'rustup.dart'; +import 'target.dart'; +import 'util.dart'; + +final _log = Logger('builder'); + +enum BuildConfiguration { + debug, + release, + profile, +} + +extension on BuildConfiguration { + bool get isDebug => this == BuildConfiguration.debug; + String get rustName => switch (this) { + BuildConfiguration.debug => 'debug', + BuildConfiguration.release => 'release', + BuildConfiguration.profile => 'release', + }; +} + +class BuildException implements Exception { + final String message; + + BuildException(this.message); + + @override + String toString() { + return 'BuildException: $message'; + } +} + +class BuildEnvironment { + final BuildConfiguration configuration; + final CargokitCrateOptions crateOptions; + final String targetTempDir; + final String manifestDir; + final CrateInfo crateInfo; + + final bool isAndroid; + final String? androidSdkPath; + final String? androidNdkVersion; + final int? androidMinSdkVersion; + final String? javaHome; + + BuildEnvironment({ + required this.configuration, + required this.crateOptions, + required this.targetTempDir, + required this.manifestDir, + required this.crateInfo, + required this.isAndroid, + this.androidSdkPath, + this.androidNdkVersion, + this.androidMinSdkVersion, + this.javaHome, + }); + + static BuildConfiguration parseBuildConfiguration(String value) { + // XCode configuration adds the flavor to configuration name. + final firstSegment = value.split('-').first; + final buildConfiguration = BuildConfiguration.values.firstWhereOrNull( + (e) => e.name == firstSegment, + ); + if (buildConfiguration == null) { + _log.warning('Unknown build configuraiton $value, will assume release'); + return BuildConfiguration.release; + } + return buildConfiguration; + } + + static BuildEnvironment fromEnvironment({ + required bool isAndroid, + }) { + final buildConfiguration = + parseBuildConfiguration(Environment.configuration); + final manifestDir = Environment.manifestDir; + final crateOptions = CargokitCrateOptions.load( + manifestDir: manifestDir, + ); + final crateInfo = CrateInfo.load(manifestDir); + return BuildEnvironment( + configuration: buildConfiguration, + crateOptions: crateOptions, + targetTempDir: Environment.targetTempDir, + manifestDir: manifestDir, + crateInfo: crateInfo, + isAndroid: isAndroid, + androidSdkPath: isAndroid ? Environment.sdkPath : null, + androidNdkVersion: isAndroid ? Environment.ndkVersion : null, + androidMinSdkVersion: + isAndroid ? int.parse(Environment.minSdkVersion) : null, + javaHome: isAndroid ? Environment.javaHome : null, + ); + } +} + +class RustBuilder { + final Target target; + final BuildEnvironment environment; + + RustBuilder({ + required this.target, + required this.environment, + }); + + void prepare( + Rustup rustup, + ) { + final toolchain = _toolchain; + if (rustup.installedTargets(toolchain) == null) { + rustup.installToolchain(toolchain); + } + if (toolchain == 'nightly') { + rustup.installRustSrcForNightly(); + } + if (!rustup.installedTargets(toolchain)!.contains(target.rust)) { + rustup.installTarget(target.rust, toolchain: toolchain); + } + } + + CargoBuildOptions? get _buildOptions => + environment.crateOptions.cargo[environment.configuration]; + + String get _toolchain => _buildOptions?.toolchain.name ?? 'stable'; + + /// Returns the path of directory containing build artifacts. + Future build() async { + final extraArgs = _buildOptions?.flags ?? []; + final manifestPath = path.join(environment.manifestDir, 'Cargo.toml'); + runCommand( + 'rustup', + [ + 'run', + _toolchain, + 'cargo', + 'build', + ...extraArgs, + '--manifest-path', + manifestPath, + '-p', + environment.crateInfo.packageName, + if (!environment.configuration.isDebug) '--release', + '--target', + target.rust, + '--target-dir', + environment.targetTempDir, + ], + environment: await _buildEnvironment(), + ); + return path.join( + environment.targetTempDir, + target.rust, + environment.configuration.rustName, + ); + } + + Future> _buildEnvironment() async { + if (target.android == null) { + return {}; + } else { + final sdkPath = environment.androidSdkPath; + final ndkVersion = environment.androidNdkVersion; + final minSdkVersion = environment.androidMinSdkVersion; + if (sdkPath == null) { + throw BuildException('androidSdkPath is not set'); + } + if (ndkVersion == null) { + throw BuildException('androidNdkVersion is not set'); + } + if (minSdkVersion == null) { + throw BuildException('androidMinSdkVersion is not set'); + } + final env = AndroidEnvironment( + sdkPath: sdkPath, + ndkVersion: ndkVersion, + minSdkVersion: minSdkVersion, + targetTempDir: environment.targetTempDir, + target: target, + ); + if (!env.ndkIsInstalled() && environment.javaHome != null) { + env.installNdk(javaHome: environment.javaHome!); + } + return env.buildEnvironment(); + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/cargo.dart b/packages/agent_dart/cargokit/build_tool/lib/src/cargo.dart new file mode 100644 index 00000000..0d8958ff --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/cargo.dart @@ -0,0 +1,48 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:path/path.dart' as path; +import 'package:toml/toml.dart'; + +class ManifestException { + ManifestException(this.message, {required this.fileName}); + + final String? fileName; + final String message; + + @override + String toString() { + if (fileName != null) { + return 'Failed to parse package manifest at $fileName: $message'; + } else { + return 'Failed to parse package manifest: $message'; + } + } +} + +class CrateInfo { + CrateInfo({required this.packageName}); + + final String packageName; + + static CrateInfo parseManifest(String manifest, {final String? fileName}) { + final toml = TomlDocument.parse(manifest); + final package = toml.toMap()['package']; + if (package == null) { + throw ManifestException('Missing package section', fileName: fileName); + } + final name = package['name']; + if (name == null) { + throw ManifestException('Missing package name', fileName: fileName); + } + return CrateInfo(packageName: name); + } + + static CrateInfo load(String manifestDir) { + final manifestFile = File(path.join(manifestDir, 'Cargo.toml')); + final manifest = manifestFile.readAsStringSync(); + return parseManifest(manifest, fileName: manifestFile.path); + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/crate_hash.dart b/packages/agent_dart/cargokit/build_tool/lib/src/crate_hash.dart new file mode 100644 index 00000000..0c4d88d1 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/crate_hash.dart @@ -0,0 +1,124 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:convert'; +import 'dart:io'; +import 'dart:typed_data'; + +import 'package:collection/collection.dart'; +import 'package:convert/convert.dart'; +import 'package:crypto/crypto.dart'; +import 'package:path/path.dart' as path; + +class CrateHash { + /// Computes a hash uniquely identifying crate content. This takes into account + /// content all all .rs files inside the src directory, as well as Cargo.toml, + /// Cargo.lock, build.rs and cargokit.yaml. + /// + /// If [tempStorage] is provided, computed hash is stored in a file in that directory + /// and reused on subsequent calls if the crate content hasn't changed. + static String compute(String manifestDir, {String? tempStorage}) { + return CrateHash._( + manifestDir: manifestDir, + tempStorage: tempStorage, + )._compute(); + } + + CrateHash._({ + required this.manifestDir, + required this.tempStorage, + }); + + String _compute() { + final files = getFiles(); + final tempStorage = this.tempStorage; + if (tempStorage != null) { + final quickHash = _computeQuickHash(files); + final quickHashFolder = Directory(path.join(tempStorage, 'crate_hash')); + quickHashFolder.createSync(recursive: true); + final quickHashFile = File(path.join(quickHashFolder.path, quickHash)); + if (quickHashFile.existsSync()) { + return quickHashFile.readAsStringSync(); + } + final hash = _computeHash(files); + quickHashFile.writeAsStringSync(hash); + return hash; + } else { + return _computeHash(files); + } + } + + /// Computes a quick hash based on files stat (without reading contents). This + /// is used to cache the real hash, which is slower to compute since it involves + /// reading every single file. + String _computeQuickHash(List files) { + final output = AccumulatorSink(); + final input = sha256.startChunkedConversion(output); + + final data = ByteData(8); + for (final file in files) { + input.add(utf8.encode(file.path)); + final stat = file.statSync(); + data.setUint64(0, stat.size); + input.add(data.buffer.asUint8List()); + data.setUint64(0, stat.modified.millisecondsSinceEpoch); + input.add(data.buffer.asUint8List()); + } + + input.close(); + return base64Url.encode(output.events.single.bytes); + } + + String _computeHash(List files) { + final output = AccumulatorSink(); + final input = sha256.startChunkedConversion(output); + + void addTextFile(File file) { + // text Files are hashed by lines in case we're dealing with github checkout + // that auto-converts line endings. + final splitter = LineSplitter(); + if (file.existsSync()) { + final data = file.readAsStringSync(); + final lines = splitter.convert(data); + for (final line in lines) { + input.add(utf8.encode(line)); + } + } + } + + for (final file in files) { + addTextFile(file); + } + + input.close(); + final res = output.events.single; + + // Truncate to 128bits. + final hash = res.bytes.sublist(0, 16); + return hex.encode(hash); + } + + List getFiles() { + final src = Directory(path.join(manifestDir, 'src')); + final files = src + .listSync(recursive: true, followLinks: false) + .whereType() + .toList(); + files.sortBy((element) => element.path); + void addFile(String relative) { + final file = File(path.join(manifestDir, relative)); + if (file.existsSync()) { + files.add(file); + } + } + + addFile('Cargo.toml'); + addFile('Cargo.lock'); + addFile('build.rs'); + addFile('cargokit.yaml'); + return files; + } + + final String manifestDir; + final String? tempStorage; +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/environment.dart b/packages/agent_dart/cargokit/build_tool/lib/src/environment.dart new file mode 100644 index 00000000..996483a1 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/environment.dart @@ -0,0 +1,68 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +extension on String { + String resolveSymlink() => File(this).resolveSymbolicLinksSync(); +} + +class Environment { + /// Current build configuration (debug or release). + static String get configuration => + _getEnv("CARGOKIT_CONFIGURATION").toLowerCase(); + + static bool get isDebug => configuration == 'debug'; + static bool get isRelease => configuration == 'release'; + + /// Temporary directory where Rust build artifacts are placed. + static String get targetTempDir => _getEnv("CARGOKIT_TARGET_TEMP_DIR"); + + /// Final output directory where the build artifacts are placed. + static String get outputDir => _getEnvPath('CARGOKIT_OUTPUT_DIR'); + + /// Path to the crate manifest (containing Cargo.toml). + static String get manifestDir => _getEnvPath('CARGOKIT_MANIFEST_DIR'); + + /// Directory inside root project. Not necessarily root folder. Symlinks are + /// not resolved on purpose. + static String get rootProjectDir => _getEnv('CARGOKIT_ROOT_PROJECT_DIR'); + + // Pod + + /// Platform name (macosx, iphoneos, iphonesimulator). + static String get darwinPlatformName => + _getEnv("CARGOKIT_DARWIN_PLATFORM_NAME"); + + /// List of architectures to build for (arm64, armv7, x86_64). + static List get darwinArchs => + _getEnv("CARGOKIT_DARWIN_ARCHS").split(' '); + + // Gradle + static String get minSdkVersion => _getEnv("CARGOKIT_MIN_SDK_VERSION"); + static String get ndkVersion => _getEnv("CARGOKIT_NDK_VERSION"); + static String get sdkPath => _getEnvPath("CARGOKIT_SDK_DIR"); + static String get javaHome => _getEnvPath("CARGOKIT_JAVA_HOME"); + static List get targetPlatforms => + _getEnv("CARGOKIT_TARGET_PLATFORMS").split(','); + + // CMAKE + static String get targetPlatform => _getEnv("CARGOKIT_TARGET_PLATFORM"); + + static String _getEnv(String key) { + final res = Platform.environment[key]; + if (res == null) { + throw Exception("Missing environment variable $key"); + } + return res; + } + + static String _getEnvPath(String key) { + final res = _getEnv(key); + if (Directory(res).existsSync()) { + return res.resolveSymlink(); + } else { + return res; + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/logging.dart b/packages/agent_dart/cargokit/build_tool/lib/src/logging.dart new file mode 100644 index 00000000..5edd4fd1 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/logging.dart @@ -0,0 +1,52 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:logging/logging.dart'; + +const String kSeparator = "--"; +const String kDoubleSeparator = "=="; + +bool _lastMessageWasSeparator = false; + +void _log(LogRecord rec) { + final prefix = '${rec.level.name}: '; + final out = rec.level == Level.SEVERE ? stderr : stdout; + if (rec.message == kSeparator) { + if (!_lastMessageWasSeparator) { + out.write(prefix); + out.writeln('-' * 80); + _lastMessageWasSeparator = true; + } + return; + } else if (rec.message == kDoubleSeparator) { + out.write(prefix); + out.writeln('=' * 80); + _lastMessageWasSeparator = true; + return; + } + out.write(prefix); + out.writeln(rec.message); + _lastMessageWasSeparator = false; +} + +void initLogging() { + Logger.root.level = Level.INFO; + Logger.root.onRecord.listen((LogRecord rec) { + final lines = rec.message.split('\n'); + for (final line in lines) { + if (line.isNotEmpty || lines.length == 1 || line != lines.last) { + _log(LogRecord( + rec.level, + line, + rec.loggerName, + )); + } + } + }); +} + +void enableVerboseLogging() { + Logger.root.level = Level.ALL; +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/options.dart b/packages/agent_dart/cargokit/build_tool/lib/src/options.dart new file mode 100644 index 00000000..22aef1d3 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/options.dart @@ -0,0 +1,309 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:collection/collection.dart'; +import 'package:ed25519_edwards/ed25519_edwards.dart'; +import 'package:hex/hex.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; +import 'package:source_span/source_span.dart'; +import 'package:yaml/yaml.dart'; + +import 'builder.dart'; +import 'environment.dart'; +import 'rustup.dart'; + +final _log = Logger('options'); + +/// A class for exceptions that have source span information attached. +class SourceSpanException implements Exception { + // This is a getter so that subclasses can override it. + /// A message describing the exception. + String get message => _message; + final String _message; + + // This is a getter so that subclasses can override it. + /// The span associated with this exception. + /// + /// This may be `null` if the source location can't be determined. + SourceSpan? get span => _span; + final SourceSpan? _span; + + SourceSpanException(this._message, this._span); + + /// Returns a string representation of `this`. + /// + /// [color] may either be a [String], a [bool], or `null`. If it's a string, + /// it indicates an ANSI terminal color escape that should be used to + /// highlight the span's text. If it's `true`, it indicates that the text + /// should be highlighted using the default color. If it's `false` or `null`, + /// it indicates that the text shouldn't be highlighted. + @override + String toString({Object? color}) { + if (span == null) return message; + return 'Error on ${span!.message(message, color: color)}'; + } +} + +enum Toolchain { + stable, + beta, + nightly, +} + +class CargoBuildOptions { + final Toolchain toolchain; + final List flags; + + CargoBuildOptions({ + required this.toolchain, + required this.flags, + }); + + static Toolchain _toolchainFromNode(YamlNode node) { + if (node case YamlScalar(value: String name)) { + final toolchain = + Toolchain.values.firstWhereOrNull((element) => element.name == name); + if (toolchain != null) { + return toolchain; + } + } + throw SourceSpanException( + 'Unknown toolchain. Must be one of ${Toolchain.values.map((e) => e.name)}.', + node.span); + } + + static CargoBuildOptions parse(YamlNode node) { + if (node is! YamlMap) { + throw SourceSpanException('Cargo options must be a map', node.span); + } + Toolchain toolchain = Toolchain.stable; + List flags = []; + for (final MapEntry(:key, :value) in node.nodes.entries) { + if (key case YamlScalar(value: 'toolchain')) { + toolchain = _toolchainFromNode(value); + } else if (key case YamlScalar(value: 'extra_flags')) { + if (value case YamlList(nodes: List list)) { + if (list.every((element) { + if (element case YamlScalar(value: String _)) { + return true; + } + return false; + })) { + flags = list.map((e) => e.value as String).toList(); + continue; + } + } + throw SourceSpanException( + 'Extra flags must be a list of strings', value.span); + } else { + throw SourceSpanException( + 'Unknown cargo option type. Must be "toolchain" or "extra_flags".', + key.span); + } + } + return CargoBuildOptions(toolchain: toolchain, flags: flags); + } +} + +extension on YamlMap { + /// Map that extracts keys so that we can do map case check on them. + Map get valueMap => + nodes.map((key, value) => MapEntry(key.value, value)); +} + +class PrecompiledBinaries { + final String uriPrefix; + final PublicKey publicKey; + + PrecompiledBinaries({ + required this.uriPrefix, + required this.publicKey, + }); + + static PublicKey _publicKeyFromHex(String key, SourceSpan? span) { + final bytes = HEX.decode(key); + if (bytes.length != 32) { + throw SourceSpanException( + 'Invalid public key. Must be 32 bytes long.', span); + } + return PublicKey(bytes); + } + + static PrecompiledBinaries parse(YamlNode node) { + if (node case YamlMap(valueMap: Map map)) { + if (map + case { + 'url_prefix': YamlNode urlPrefixNode, + 'public_key': YamlNode publicKeyNode, + }) { + final urlPrefix = switch (urlPrefixNode) { + YamlScalar(value: String urlPrefix) => urlPrefix, + _ => throw SourceSpanException( + 'Invalid URL prefix value.', urlPrefixNode.span), + }; + final publicKey = switch (publicKeyNode) { + YamlScalar(value: String publicKey) => + _publicKeyFromHex(publicKey, publicKeyNode.span), + _ => throw SourceSpanException( + 'Invalid public key value.', publicKeyNode.span), + }; + return PrecompiledBinaries( + uriPrefix: urlPrefix, + publicKey: publicKey, + ); + } + } + throw SourceSpanException( + 'Invalid precompiled binaries value. ' + 'Expected Map with "url_prefix" and "public_key".', + node.span); + } +} + +/// Cargokit options specified for Rust crate. +class CargokitCrateOptions { + CargokitCrateOptions({ + this.cargo = const {}, + this.precompiledBinaries, + }); + + final Map cargo; + final PrecompiledBinaries? precompiledBinaries; + + static CargokitCrateOptions parse(YamlNode node) { + if (node is! YamlMap) { + throw SourceSpanException('Cargokit options must be a map', node.span); + } + final options = {}; + PrecompiledBinaries? precompiledBinaries; + + for (final entry in node.nodes.entries) { + if (entry + case MapEntry( + key: YamlScalar(value: 'cargo'), + value: YamlNode node, + )) { + if (node is! YamlMap) { + throw SourceSpanException('Cargo options must be a map', node.span); + } + for (final MapEntry(:YamlNode key, :value) in node.nodes.entries) { + if (key case YamlScalar(value: String name)) { + final configuration = BuildConfiguration.values + .firstWhereOrNull((element) => element.name == name); + if (configuration != null) { + options[configuration] = CargoBuildOptions.parse(value); + continue; + } + } + throw SourceSpanException( + 'Unknown build configuration. Must be one of ${BuildConfiguration.values.map((e) => e.name)}.', + key.span); + } + } else if (entry.key case YamlScalar(value: 'precompiled_binaries')) { + precompiledBinaries = PrecompiledBinaries.parse(entry.value); + } else { + throw SourceSpanException( + 'Unknown cargokit option type. Must be "cargo" or "precompiled_binaries".', + entry.key.span); + } + } + return CargokitCrateOptions( + cargo: options, + precompiledBinaries: precompiledBinaries, + ); + } + + static CargokitCrateOptions load({ + required String manifestDir, + }) { + final uri = Uri.file(path.join(manifestDir, "cargokit.yaml")); + final file = File.fromUri(uri); + if (file.existsSync()) { + final contents = loadYamlNode(file.readAsStringSync(), sourceUrl: uri); + return parse(contents); + } else { + return CargokitCrateOptions(); + } + } +} + +class CargokitUserOptions { + // When Rustup is installed always build locally unless user opts into + // using precompiled binaries. + static bool defaultUsePrecompiledBinaries() { + return Rustup.executablePath() == null; + } + + CargokitUserOptions({ + required this.usePrecompiledBinaries, + required this.verboseLogging, + }); + + CargokitUserOptions._() + : usePrecompiledBinaries = defaultUsePrecompiledBinaries(), + verboseLogging = false; + + static CargokitUserOptions parse(YamlNode node) { + if (node is! YamlMap) { + throw SourceSpanException('Cargokit options must be a map', node.span); + } + bool usePrecompiledBinaries = defaultUsePrecompiledBinaries(); + bool verboseLogging = false; + + for (final entry in node.nodes.entries) { + if (entry.key case YamlScalar(value: 'use_precompiled_binaries')) { + if (entry.value case YamlScalar(value: bool value)) { + usePrecompiledBinaries = value; + continue; + } + throw SourceSpanException( + 'Invalid value for "use_precompiled_binaries". Must be a boolean.', + entry.value.span); + } else if (entry.key case YamlScalar(value: 'verbose_logging')) { + if (entry.value case YamlScalar(value: bool value)) { + verboseLogging = value; + continue; + } + throw SourceSpanException( + 'Invalid value for "verbose_logging". Must be a boolean.', + entry.value.span); + } else { + throw SourceSpanException( + 'Unknown cargokit option type. Must be "use_precompiled_binaries" or "verbose_logging".', + entry.key.span); + } + } + return CargokitUserOptions( + usePrecompiledBinaries: usePrecompiledBinaries, + verboseLogging: verboseLogging, + ); + } + + static CargokitUserOptions load() { + String fileName = "cargokit_options.yaml"; + var userProjectDir = Directory(Environment.rootProjectDir); + + while (userProjectDir.parent.path != userProjectDir.path) { + final configFile = File(path.join(userProjectDir.path, fileName)); + if (configFile.existsSync()) { + final contents = loadYamlNode( + configFile.readAsStringSync(), + sourceUrl: configFile.uri, + ); + final res = parse(contents); + if (res.verboseLogging) { + _log.info('Found user options file at ${configFile.path}'); + } + return res; + } + userProjectDir = userProjectDir.parent; + } + return CargokitUserOptions._(); + } + + final bool usePrecompiledBinaries; + final bool verboseLogging; +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/precompile_binaries.dart b/packages/agent_dart/cargokit/build_tool/lib/src/precompile_binaries.dart new file mode 100644 index 00000000..c27f4195 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/precompile_binaries.dart @@ -0,0 +1,202 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:ed25519_edwards/ed25519_edwards.dart'; +import 'package:github/github.dart'; +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; + +import 'artifacts_provider.dart'; +import 'builder.dart'; +import 'cargo.dart'; +import 'crate_hash.dart'; +import 'options.dart'; +import 'rustup.dart'; +import 'target.dart'; + +final _log = Logger('precompile_binaries'); + +class PrecompileBinaries { + PrecompileBinaries({ + required this.privateKey, + required this.githubToken, + required this.repositorySlug, + required this.manifestDir, + required this.targets, + this.androidSdkLocation, + this.androidNdkVersion, + this.androidMinSdkVersion, + this.tempDir, + }); + + final PrivateKey privateKey; + final String githubToken; + final RepositorySlug repositorySlug; + final String manifestDir; + final List targets; + final String? androidSdkLocation; + final String? androidNdkVersion; + final int? androidMinSdkVersion; + final String? tempDir; + + static String fileName(Target target, String name) { + return '${target.rust}_$name'; + } + + static String signatureFileName(Target target, String name) { + return '${target.rust}_$name.sig'; + } + + Future run() async { + final crateInfo = CrateInfo.load(manifestDir); + + final targets = List.of(this.targets); + if (targets.isEmpty) { + targets.addAll([ + ...Target.buildableTargets(), + if (androidSdkLocation != null) ...Target.androidTargets(), + ]); + } + + _log.info('Precompiling binaries for $targets'); + + final hash = CrateHash.compute(manifestDir); + _log.info('Computed crate hash: $hash'); + + final String tagName = 'precompiled_$hash'; + + final github = GitHub(auth: Authentication.withToken(githubToken)); + final repo = github.repositories; + final release = await _getOrCreateRelease( + repo: repo, + tagName: tagName, + packageName: crateInfo.packageName, + hash: hash, + ); + + final tempDir = this.tempDir != null + ? Directory(this.tempDir!) + : Directory.systemTemp.createTempSync('precompiled_'); + + tempDir.createSync(recursive: true); + + final crateOptions = CargokitCrateOptions.load( + manifestDir: manifestDir, + ); + + final buildEnvironment = BuildEnvironment( + configuration: BuildConfiguration.release, + crateOptions: crateOptions, + targetTempDir: tempDir.path, + manifestDir: manifestDir, + crateInfo: crateInfo, + isAndroid: androidSdkLocation != null, + androidSdkPath: androidSdkLocation, + androidNdkVersion: androidNdkVersion, + androidMinSdkVersion: androidMinSdkVersion, + ); + + final rustup = Rustup(); + + for (final target in targets) { + final artifactNames = getArtifactNames( + target: target, + libraryName: crateInfo.packageName, + remote: true, + ); + + if (artifactNames.every((name) { + final fileName = PrecompileBinaries.fileName(target, name); + return (release.assets ?? []).any((e) => e.name == fileName); + })) { + _log.info("All artifacts for $target already exist - skipping"); + continue; + } + + _log.info('Building for $target'); + + final builder = + RustBuilder(target: target, environment: buildEnvironment); + builder.prepare(rustup); + final res = await builder.build(); + + final assets = []; + for (final name in artifactNames) { + final file = File(path.join(res, name)); + if (!file.existsSync()) { + throw Exception('Missing artifact: ${file.path}'); + } + + final data = file.readAsBytesSync(); + final create = CreateReleaseAsset( + name: PrecompileBinaries.fileName(target, name), + contentType: "application/octet-stream", + assetData: data, + ); + final signature = sign(privateKey, data); + final signatureCreate = CreateReleaseAsset( + name: signatureFileName(target, name), + contentType: "application/octet-stream", + assetData: signature, + ); + bool verified = verify(public(privateKey), data, signature); + if (!verified) { + throw Exception('Signature verification failed'); + } + assets.add(create); + assets.add(signatureCreate); + } + _log.info('Uploading assets: ${assets.map((e) => e.name)}'); + for (final asset in assets) { + // This seems to be failing on CI so do it one by one + int retryCount = 0; + while (true) { + try { + await repo.uploadReleaseAssets(release, [asset]); + break; + } on Exception catch (e) { + if (retryCount == 10) { + rethrow; + } + ++retryCount; + _log.shout( + 'Upload failed (attempt $retryCount, will retry): ${e.toString()}'); + await Future.delayed(Duration(seconds: 2)); + } + } + } + } + + _log.info('Cleaning up'); + tempDir.deleteSync(recursive: true); + } + + Future _getOrCreateRelease({ + required RepositoriesService repo, + required String tagName, + required String packageName, + required String hash, + }) async { + Release release; + try { + _log.info('Fetching release $tagName'); + release = await repo.getReleaseByTagName(repositorySlug, tagName); + } on ReleaseNotFound { + _log.info('Release not found - creating release $tagName'); + release = await repo.createRelease( + repositorySlug, + CreateRelease.from( + tagName: tagName, + name: 'Precompiled binaries ${hash.substring(0, 8)}', + targetCommitish: null, + isDraft: false, + isPrerelease: false, + body: 'Precompiled binaries for crate $packageName, ' + 'crate hash $hash.', + )); + } + return release; + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/rustup.dart b/packages/agent_dart/cargokit/build_tool/lib/src/rustup.dart new file mode 100644 index 00000000..0ac8d086 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/rustup.dart @@ -0,0 +1,136 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:collection/collection.dart'; +import 'package:path/path.dart' as path; + +import 'util.dart'; + +class _Toolchain { + _Toolchain( + this.name, + this.targets, + ); + + final String name; + final List targets; +} + +class Rustup { + List? installedTargets(String toolchain) { + final targets = _installedTargets(toolchain); + return targets != null ? List.unmodifiable(targets) : null; + } + + void installToolchain(String toolchain) { + log.info("Installing Rust toolchain: $toolchain"); + runCommand("rustup", ['toolchain', 'install', toolchain]); + _installedToolchains + .add(_Toolchain(toolchain, _getInstalledTargets(toolchain))); + } + + void installTarget( + String target, { + required String toolchain, + }) { + log.info("Installing Rust target: $target"); + runCommand("rustup", [ + 'target', + 'add', + '--toolchain', + toolchain, + target, + ]); + _installedTargets(toolchain)?.add(target); + } + + final List<_Toolchain> _installedToolchains; + + Rustup() : _installedToolchains = _getInstalledToolchains(); + + List? _installedTargets(String toolchain) => _installedToolchains + .firstWhereOrNull( + (e) => e.name == toolchain || e.name.startsWith('$toolchain-')) + ?.targets; + + static List<_Toolchain> _getInstalledToolchains() { + String extractToolchainName(String line) { + // ignore (default) after toolchain name + final parts = line.split(' '); + return parts[0]; + } + + final res = runCommand("rustup", ['toolchain', 'list']); + + // To list all non-custom toolchains, we need to filter out lines that + // don't start with "stable", "beta", or "nightly". + Pattern nonCustom = RegExp(r"^(stable|beta|nightly)"); + final lines = res.stdout + .toString() + .split('\n') + .where((e) => e.isNotEmpty && e.startsWith(nonCustom)) + .map(extractToolchainName) + .toList(growable: true); + + return lines + .map( + (name) => _Toolchain( + name, + _getInstalledTargets(name), + ), + ) + .toList(growable: true); + } + + static List _getInstalledTargets(String toolchain) { + final res = runCommand("rustup", [ + 'target', + 'list', + '--toolchain', + toolchain, + '--installed', + ]); + final lines = res.stdout + .toString() + .split('\n') + .where((e) => e.isNotEmpty) + .toList(growable: true); + return lines; + } + + bool _didInstallRustSrcForNightly = false; + + void installRustSrcForNightly() { + if (_didInstallRustSrcForNightly) { + return; + } + // Useful for -Z build-std + runCommand( + "rustup", + ['component', 'add', 'rust-src', '--toolchain', 'nightly'], + ); + _didInstallRustSrcForNightly = true; + } + + static String? executablePath() { + final envPath = Platform.environment['PATH']; + final envPathSeparator = Platform.isWindows ? ';' : ':'; + final home = Platform.isWindows + ? Platform.environment['USERPROFILE'] + : Platform.environment['HOME']; + final paths = [ + if (home != null) path.join(home, '.cargo', 'bin'), + if (envPath != null) ...envPath.split(envPathSeparator), + ]; + for (final p in paths) { + final rustup = Platform.isWindows ? 'rustup.exe' : 'rustup'; + final rustupPath = path.join(p, rustup); + if (File(rustupPath).existsSync()) { + return rustupPath; + } + } + return null; + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/target.dart b/packages/agent_dart/cargokit/build_tool/lib/src/target.dart new file mode 100644 index 00000000..6fbc58b6 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/target.dart @@ -0,0 +1,140 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:collection/collection.dart'; + +import 'util.dart'; + +class Target { + Target({ + required this.rust, + this.flutter, + this.android, + this.androidMinSdkVersion, + this.darwinPlatform, + this.darwinArch, + }); + + static final all = [ + Target( + rust: 'armv7-linux-androideabi', + flutter: 'android-arm', + android: 'armeabi-v7a', + androidMinSdkVersion: 16, + ), + Target( + rust: 'aarch64-linux-android', + flutter: 'android-arm64', + android: 'arm64-v8a', + androidMinSdkVersion: 21, + ), + Target( + rust: 'i686-linux-android', + flutter: 'android-x86', + android: 'x86', + androidMinSdkVersion: 16, + ), + Target( + rust: 'x86_64-linux-android', + flutter: 'android-x64', + android: 'x86_64', + androidMinSdkVersion: 21, + ), + Target( + rust: 'x86_64-pc-windows-msvc', + flutter: 'windows-x64', + ), + Target( + rust: 'x86_64-unknown-linux-gnu', + flutter: 'linux-x64', + ), + Target( + rust: 'aarch64-unknown-linux-gnu', + flutter: 'linux-arm64', + ), + Target( + rust: 'x86_64-apple-darwin', + darwinPlatform: 'macosx', + darwinArch: 'x86_64', + ), + Target( + rust: 'aarch64-apple-darwin', + darwinPlatform: 'macosx', + darwinArch: 'arm64', + ), + Target( + rust: 'aarch64-apple-ios', + darwinPlatform: 'iphoneos', + darwinArch: 'arm64', + ), + Target( + rust: 'aarch64-apple-ios-sim', + darwinPlatform: 'iphonesimulator', + darwinArch: 'arm64', + ), + Target( + rust: 'x86_64-apple-ios', + darwinPlatform: 'iphonesimulator', + darwinArch: 'x86_64', + ), + ]; + + static Target? forFlutterName(String flutterName) { + return all.firstWhereOrNull((element) => element.flutter == flutterName); + } + + static Target? forDarwin({ + required String platformName, + required String darwinAarch, + }) { + return all.firstWhereOrNull((element) => // + element.darwinPlatform == platformName && + element.darwinArch == darwinAarch); + } + + static Target? forRustTriple(String triple) { + return all.firstWhereOrNull((element) => element.rust == triple); + } + + static List androidTargets() { + return all + .where((element) => element.android != null) + .toList(growable: false); + } + + /// Returns buildable targets on current host platform ignoring Android targets. + static List buildableTargets() { + if (Platform.isLinux) { + // Right now we don't support cross-compiling on Linux. So we just return + // the host target. + final arch = runCommand('arch', []).stdout as String; + if (arch.trim() == 'aarch64') { + return [Target.forRustTriple('aarch64-unknown-linux-gnu')!]; + } else { + return [Target.forRustTriple('x86_64-unknown-linux-gnu')!]; + } + } + return all.where((target) { + if (Platform.isWindows) { + return target.rust.contains('-windows-'); + } else if (Platform.isMacOS) { + return target.darwinPlatform != null; + } + return false; + }).toList(growable: false); + } + + @override + String toString() { + return rust; + } + + final String? flutter; + final String rust; + final String? android; + final int? androidMinSdkVersion; + final String? darwinPlatform; + final String? darwinArch; +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/util.dart b/packages/agent_dart/cargokit/build_tool/lib/src/util.dart new file mode 100644 index 00000000..8bb6a872 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/util.dart @@ -0,0 +1,172 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:convert'; +import 'dart:io'; + +import 'package:logging/logging.dart'; +import 'package:path/path.dart' as path; + +import 'logging.dart'; +import 'rustup.dart'; + +final log = Logger("process"); + +class CommandFailedException implements Exception { + final String executable; + final List arguments; + final ProcessResult result; + + CommandFailedException({ + required this.executable, + required this.arguments, + required this.result, + }); + + @override + String toString() { + final stdout = result.stdout.toString().trim(); + final stderr = result.stderr.toString().trim(); + return [ + "External Command: $executable ${arguments.map((e) => '"$e"').join(' ')}", + "Returned Exit Code: ${result.exitCode}", + kSeparator, + "STDOUT:", + if (stdout.isNotEmpty) stdout, + kSeparator, + "STDERR:", + if (stderr.isNotEmpty) stderr, + ].join('\n'); + } +} + +class TestRunCommandArgs { + final String executable; + final List arguments; + final String? workingDirectory; + final Map? environment; + final bool includeParentEnvironment; + final bool runInShell; + final Encoding? stdoutEncoding; + final Encoding? stderrEncoding; + + TestRunCommandArgs({ + required this.executable, + required this.arguments, + this.workingDirectory, + this.environment, + this.includeParentEnvironment = true, + this.runInShell = false, + this.stdoutEncoding, + this.stderrEncoding, + }); +} + +class TestRunCommandResult { + TestRunCommandResult({ + this.pid = 1, + this.exitCode = 0, + this.stdout = '', + this.stderr = '', + }); + + final int pid; + final int exitCode; + final String stdout; + final String stderr; +} + +TestRunCommandResult Function(TestRunCommandArgs args)? testRunCommandOverride; + +ProcessResult runCommand( + String executable, + List arguments, { + String? workingDirectory, + Map? environment, + bool includeParentEnvironment = true, + bool runInShell = false, + Encoding? stdoutEncoding = systemEncoding, + Encoding? stderrEncoding = systemEncoding, +}) { + if (testRunCommandOverride != null) { + final result = testRunCommandOverride!(TestRunCommandArgs( + executable: executable, + arguments: arguments, + workingDirectory: workingDirectory, + environment: environment, + includeParentEnvironment: includeParentEnvironment, + runInShell: runInShell, + stdoutEncoding: stdoutEncoding, + stderrEncoding: stderrEncoding, + )); + return ProcessResult( + result.pid, + result.exitCode, + result.stdout, + result.stderr, + ); + } + log.finer('Running command $executable ${arguments.join(' ')}'); + final res = Process.runSync( + _resolveExecutable(executable), + arguments, + workingDirectory: workingDirectory, + environment: environment, + includeParentEnvironment: includeParentEnvironment, + runInShell: runInShell, + stderrEncoding: stderrEncoding, + stdoutEncoding: stdoutEncoding, + ); + if (res.exitCode != 0) { + throw CommandFailedException( + executable: executable, + arguments: arguments, + result: res, + ); + } else { + return res; + } +} + +class RustupNotFoundException implements Exception { + @override + String toString() { + return [ + ' ', + 'rustup not found in PATH.', + ' ', + 'Maybe you need to install Rust? It only takes a minute:', + ' ', + if (Platform.isWindows) 'https://www.rust-lang.org/tools/install', + if (hasHomebrewRustInPath()) ...[ + '\$ brew unlink rust # Unlink homebrew Rust from PATH', + ], + if (!Platform.isWindows) + "\$ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh", + ' ', + ].join('\n'); + } + + static bool hasHomebrewRustInPath() { + if (!Platform.isMacOS) { + return false; + } + final envPath = Platform.environment['PATH'] ?? ''; + final paths = envPath.split(':'); + return paths.any((p) { + return p.contains('homebrew') && File(path.join(p, 'rustc')).existsSync(); + }); + } +} + +String _resolveExecutable(String executable) { + if (executable == 'rustup') { + final resolved = Rustup.executablePath(); + if (resolved != null) { + return resolved; + } + throw RustupNotFoundException(); + } else { + return executable; + } +} diff --git a/packages/agent_dart/cargokit/build_tool/lib/src/verify_binaries.dart b/packages/agent_dart/cargokit/build_tool/lib/src/verify_binaries.dart new file mode 100644 index 00000000..2366b57b --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/lib/src/verify_binaries.dart @@ -0,0 +1,84 @@ +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import 'dart:io'; + +import 'package:ed25519_edwards/ed25519_edwards.dart'; +import 'package:http/http.dart'; + +import 'artifacts_provider.dart'; +import 'cargo.dart'; +import 'crate_hash.dart'; +import 'options.dart'; +import 'precompile_binaries.dart'; +import 'target.dart'; + +class VerifyBinaries { + VerifyBinaries({ + required this.manifestDir, + }); + + final String manifestDir; + + Future run() async { + final crateInfo = CrateInfo.load(manifestDir); + + final config = CargokitCrateOptions.load(manifestDir: manifestDir); + final precompiledBinaries = config.precompiledBinaries; + if (precompiledBinaries == null) { + stdout.writeln('Crate does not support precompiled binaries.'); + } else { + final crateHash = CrateHash.compute(manifestDir); + stdout.writeln('Crate hash: $crateHash'); + + for (final target in Target.all) { + final message = 'Checking ${target.rust}...'; + stdout.write(message.padRight(40)); + stdout.flush(); + + final artifacts = getArtifactNames( + target: target, + libraryName: crateInfo.packageName, + remote: true, + ); + + final prefix = precompiledBinaries.uriPrefix; + + bool ok = true; + + for (final artifact in artifacts) { + final fileName = PrecompileBinaries.fileName(target, artifact); + final signatureFileName = + PrecompileBinaries.signatureFileName(target, artifact); + + final url = Uri.parse('$prefix$crateHash/$fileName'); + final signatureUrl = + Uri.parse('$prefix$crateHash/$signatureFileName'); + + final signature = await get(signatureUrl); + if (signature.statusCode != 200) { + stdout.writeln('MISSING'); + ok = false; + break; + } + final asset = await get(url); + if (asset.statusCode != 200) { + stdout.writeln('MISSING'); + ok = false; + break; + } + + if (!verify(precompiledBinaries.publicKey, asset.bodyBytes, + signature.bodyBytes)) { + stdout.writeln('INVALID SIGNATURE'); + ok = false; + } + } + + if (ok) { + stdout.writeln('OK'); + } + } + } + } +} diff --git a/packages/agent_dart/cargokit/build_tool/pubspec.yaml b/packages/agent_dart/cargokit/build_tool/pubspec.yaml new file mode 100644 index 00000000..18c61e33 --- /dev/null +++ b/packages/agent_dart/cargokit/build_tool/pubspec.yaml @@ -0,0 +1,33 @@ +# This is copied from Cargokit (which is the official way to use it currently) +# Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +name: build_tool +description: Cargokit build_tool. Facilitates the build of Rust crate during Flutter application build. +publish_to: none +version: 1.0.0 + +environment: + sdk: ">=3.0.0 <4.0.0" + +# Add regular dependencies here. +dependencies: + # these are pinned on purpose because the bundle_tool_runner doesn't have + # pubspec.lock. See run_build_tool.sh + logging: 1.2.0 + path: 1.8.0 + version: 3.0.0 + collection: 1.18.0 + ed25519_edwards: 0.3.1 + hex: 0.2.0 + yaml: 3.1.2 + source_span: 1.10.0 + github: 9.17.0 + args: 2.4.2 + crypto: 3.0.3 + convert: 3.1.1 + http: 1.1.0 + toml: 0.14.0 + +dev_dependencies: + lints: ^2.1.0 + test: ^1.24.0 diff --git a/packages/agent_dart/cargokit/cmake/cargokit.cmake b/packages/agent_dart/cargokit/cmake/cargokit.cmake new file mode 100644 index 00000000..ddd05df9 --- /dev/null +++ b/packages/agent_dart/cargokit/cmake/cargokit.cmake @@ -0,0 +1,99 @@ +SET(cargokit_cmake_root "${CMAKE_CURRENT_LIST_DIR}/..") + +# Workaround for https://github.com/dart-lang/pub/issues/4010 +get_filename_component(cargokit_cmake_root "${cargokit_cmake_root}" REALPATH) + +if(WIN32) + # REALPATH does not properly resolve symlinks on windows :-/ + execute_process(COMMAND powershell -ExecutionPolicy Bypass -File "${CMAKE_CURRENT_LIST_DIR}/resolve_symlinks.ps1" "${cargokit_cmake_root}" OUTPUT_VARIABLE cargokit_cmake_root OUTPUT_STRIP_TRAILING_WHITESPACE) +endif() + +# Arguments +# - target: CMAKE target to which rust library is linked +# - manifest_dir: relative path from current folder to directory containing cargo manifest +# - lib_name: cargo package name +# - any_symbol_name: name of any exported symbol from the library. +# used on windows to force linking with library. +function(apply_cargokit target manifest_dir lib_name any_symbol_name) + + set(CARGOKIT_LIB_NAME "${lib_name}") + set(CARGOKIT_LIB_FULL_NAME "${CMAKE_SHARED_MODULE_PREFIX}${CARGOKIT_LIB_NAME}${CMAKE_SHARED_MODULE_SUFFIX}") + if (CMAKE_CONFIGURATION_TYPES) + set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/$") + set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/$/${CARGOKIT_LIB_FULL_NAME}") + else() + set(CARGOKIT_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}") + set(OUTPUT_LIB "${CMAKE_CURRENT_BINARY_DIR}/${CARGOKIT_LIB_FULL_NAME}") + endif() + set(CARGOKIT_TEMP_DIR "${CMAKE_CURRENT_BINARY_DIR}/cargokit_build") + + if (FLUTTER_TARGET_PLATFORM) + set(CARGOKIT_TARGET_PLATFORM "${FLUTTER_TARGET_PLATFORM}") + else() + set(CARGOKIT_TARGET_PLATFORM "windows-x64") + endif() + + set(CARGOKIT_ENV + "CARGOKIT_CMAKE=${CMAKE_COMMAND}" + "CARGOKIT_CONFIGURATION=$" + "CARGOKIT_MANIFEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/${manifest_dir}" + "CARGOKIT_TARGET_TEMP_DIR=${CARGOKIT_TEMP_DIR}" + "CARGOKIT_OUTPUT_DIR=${CARGOKIT_OUTPUT_DIR}" + "CARGOKIT_TARGET_PLATFORM=${CARGOKIT_TARGET_PLATFORM}" + "CARGOKIT_TOOL_TEMP_DIR=${CARGOKIT_TEMP_DIR}/tool" + "CARGOKIT_ROOT_PROJECT_DIR=${CMAKE_SOURCE_DIR}" + ) + + if (WIN32) + set(SCRIPT_EXTENSION ".cmd") + set(IMPORT_LIB_EXTENSION ".lib") + else() + set(SCRIPT_EXTENSION ".sh") + set(IMPORT_LIB_EXTENSION "") + execute_process(COMMAND chmod +x "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}") + endif() + + # Using generators in custom command is only supported in CMake 3.20+ + if (CMAKE_CONFIGURATION_TYPES AND ${CMAKE_VERSION} VERSION_LESS "3.20.0") + foreach(CONFIG IN LISTS CMAKE_CONFIGURATION_TYPES) + add_custom_command( + OUTPUT + "${CMAKE_CURRENT_BINARY_DIR}/${CONFIG}/${CARGOKIT_LIB_FULL_NAME}" + "${CMAKE_CURRENT_BINARY_DIR}/_phony_" + COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} + "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake + VERBATIM + ) + endforeach() + else() + add_custom_command( + OUTPUT + ${OUTPUT_LIB} + "${CMAKE_CURRENT_BINARY_DIR}/_phony_" + COMMAND ${CMAKE_COMMAND} -E env ${CARGOKIT_ENV} + "${cargokit_cmake_root}/run_build_tool${SCRIPT_EXTENSION}" build-cmake + VERBATIM + ) + endif() + + + set_source_files_properties("${CMAKE_CURRENT_BINARY_DIR}/_phony_" PROPERTIES SYMBOLIC TRUE) + + if (TARGET ${target}) + # If we have actual cmake target provided create target and make existing + # target depend on it + add_custom_target("${target}_cargokit" DEPENDS ${OUTPUT_LIB}) + add_dependencies("${target}" "${target}_cargokit") + target_link_libraries("${target}" PRIVATE "${OUTPUT_LIB}${IMPORT_LIB_EXTENSION}") + if(WIN32) + target_link_options(${target} PRIVATE "/INCLUDE:${any_symbol_name}") + endif() + else() + # Otherwise (FFI) just use ALL to force building always + add_custom_target("${target}_cargokit" ALL DEPENDS ${OUTPUT_LIB}) + endif() + + # Allow adding the output library to plugin bundled libraries + set("${target}_cargokit_lib" ${OUTPUT_LIB} PARENT_SCOPE) + +endfunction() diff --git a/packages/agent_dart/cargokit/cmake/resolve_symlinks.ps1 b/packages/agent_dart/cargokit/cmake/resolve_symlinks.ps1 new file mode 100644 index 00000000..3d10d283 --- /dev/null +++ b/packages/agent_dart/cargokit/cmake/resolve_symlinks.ps1 @@ -0,0 +1,27 @@ +function Resolve-Symlinks { + [CmdletBinding()] + [OutputType([string])] + param( + [Parameter(Position = 0, Mandatory, ValueFromPipeline, ValueFromPipelineByPropertyName)] + [string] $Path + ) + + [string] $separator = '/' + [string[]] $parts = $Path.Split($separator) + + [string] $realPath = '' + foreach ($part in $parts) { + if ($realPath -and !$realPath.EndsWith($separator)) { + $realPath += $separator + } + $realPath += $part + $item = Get-Item $realPath + if ($item.Target) { + $realPath = $item.Target.Replace('\', '/') + } + } + $realPath +} + +$path=Resolve-Symlinks -Path $args[0] +Write-Host $path diff --git a/packages/agent_dart/cargokit/gradle/plugin.gradle b/packages/agent_dart/cargokit/gradle/plugin.gradle new file mode 100644 index 00000000..d39953be --- /dev/null +++ b/packages/agent_dart/cargokit/gradle/plugin.gradle @@ -0,0 +1,180 @@ +package cargokit.gradle +/// This is copied from Cargokit (which is the official way to use it currently) +/// Details: https://fzyzcjy.github.io/flutter_rust_bridge/manual/integrate/builtin + +import java.nio.file.Paths +import org.apache.tools.ant.taskdefs.condition.Os + +CargoKitPlugin.file = buildscript.sourceFile + +apply plugin: CargoKitPlugin + +class CargoKitExtension { + String manifestDir; // Relative path to folder containing Cargo.toml + String libname; // Library name within Cargo.toml. Must be a cdylib +} + +abstract class CargoKitBuildTask extends DefaultTask { + + @Input + String buildMode + + @Input + String buildDir + + @Input + String outputDir + + @Input + String ndkVersion + + @Input + String sdkDirectory + + @Input + int compileSdkVersion; + + @Input + int minSdkVersion; + + @Input + String pluginFile + + @Input + List targetPlatforms + + @TaskAction + def build() { + if (project.cargokit.manifestDir == null) { + throw new GradleException("Property 'manifestDir' must be set on cargokit extension"); + } + + if (project.cargokit.libname == null) { + throw new GradleException("Property 'libname' must be set on cargokit extension"); + } + + def executableName = Os.isFamily(Os.FAMILY_WINDOWS) ? "run_build_tool.cmd" : "run_build_tool.sh" + def path = Paths.get(new File(pluginFile).parent, "..", executableName); + + def manifestDir = Paths.get(project.buildscript.sourceFile.parent, project.cargokit.manifestDir) + + def rootProjectDir = project.rootProject.projectDir + + if (!Os.isFamily(Os.FAMILY_WINDOWS)) { + project.exec { + commandLine 'chmod', '+x', path + } + } + + project.exec { + executable path + args "build-gradle" + environment "CARGOKIT_ROOT_PROJECT_DIR", rootProjectDir + environment "CARGOKIT_TOOL_TEMP_DIR", "${buildDir}/build_tool" + environment "CARGOKIT_MANIFEST_DIR", manifestDir + environment "CARGOKIT_CONFIGURATION", buildMode + environment "CARGOKIT_TARGET_TEMP_DIR", buildDir + environment "CARGOKIT_OUTPUT_DIR", outputDir + environment "CARGOKIT_NDK_VERSION", ndkVersion + environment "CARGOKIT_SDK_DIR", sdkDirectory + environment "CARGOKIT_COMPILE_SDK_VERSION", compileSdkVersion + environment "CARGOKIT_MIN_SDK_VERSION", minSdkVersion + environment "CARGOKIT_TARGET_PLATFORMS", targetPlatforms.join(",") + environment "CARGOKIT_JAVA_HOME", System.properties['java.home'] + } + } +} + +class CargoKitPlugin implements Plugin { + + static String file; + + private Plugin findFlutterPlugin(Project rootProject) { + _findFlutterPlugin(rootProject.childProjects) + } + + private Plugin _findFlutterPlugin(Map projects) { + for (project in projects) { + for (plugin in project.value.getPlugins()) { + if (plugin.class.name == "FlutterPlugin") { + return plugin; + } + } + def plugin = _findFlutterPlugin(project.value.childProjects); + if (plugin != null) { + return plugin; + } + } + return null; + } + + @Override + void apply(Project project) { + def plugin = findFlutterPlugin(project.rootProject); + + project.extensions.create("cargokit", CargoKitExtension) + + if (plugin == null) { + print("Flutter plugin not found, CargoKit plugin will not be applied.") + return; + } + + def cargoBuildDir = "${project.buildDir}/build" + + // Determine if the project is an application or library + def isApplication = plugin.project.plugins.hasPlugin('com.android.application') + def variants = isApplication ? plugin.project.android.applicationVariants : plugin.project.android.libraryVariants + + variants.all { variant -> + + final buildType = variant.buildType.name + + def cargoOutputDir = "${project.buildDir}/jniLibs/${buildType}"; + def jniLibs = project.android.sourceSets.maybeCreate(buildType).jniLibs; + jniLibs.srcDir(new File(cargoOutputDir)) + + def platforms = plugin.getTargetPlatforms().collect() + + // Same thing addFlutterDependencies does in flutter.gradle + if (buildType == "debug") { + platforms.add("android-x86") + platforms.add("android-x64") + } + + // The task name depends on plugin properties, which are not available + // at this point + project.getGradle().afterProject { + def taskName = "cargokitCargoBuild${project.cargokit.libname.capitalize()}${buildType.capitalize()}"; + + if (project.tasks.findByName(taskName)) { + return + } + + if (plugin.project.android.ndkVersion == null) { + throw new GradleException("Please set 'android.ndkVersion' in 'app/build.gradle'.") + } + + def task = project.tasks.create(taskName, CargoKitBuildTask.class) { + buildMode = variant.buildType.name + buildDir = cargoBuildDir + outputDir = cargoOutputDir + ndkVersion = plugin.project.android.ndkVersion + sdkDirectory = plugin.project.android.sdkDirectory + minSdkVersion = plugin.project.android.defaultConfig.minSdkVersion.apiLevel as int + compileSdkVersion = plugin.project.android.compileSdkVersion.substring(8) as int + targetPlatforms = platforms + pluginFile = CargoKitPlugin.file + } + def onTask = { newTask -> + if (newTask.name == "merge${buildType.capitalize()}NativeLibs") { + newTask.dependsOn task + // Fix gradle 7.4.2 not picking up JNI library changes + newTask.outputs.upToDateWhen { false } + } + } + project.tasks.each onTask + project.tasks.whenTaskAdded onTask + } + } + } +} diff --git a/packages/agent_dart/cargokit/run_build_tool.cmd b/packages/agent_dart/cargokit/run_build_tool.cmd new file mode 100644 index 00000000..c45d0aa8 --- /dev/null +++ b/packages/agent_dart/cargokit/run_build_tool.cmd @@ -0,0 +1,91 @@ +@echo off +setlocal + +setlocal ENABLEDELAYEDEXPANSION + +SET BASEDIR=%~dp0 + +if not exist "%CARGOKIT_TOOL_TEMP_DIR%" ( + mkdir "%CARGOKIT_TOOL_TEMP_DIR%" +) +cd /D "%CARGOKIT_TOOL_TEMP_DIR%" + +SET BUILD_TOOL_PKG_DIR=%BASEDIR%build_tool +SET DART=%FLUTTER_ROOT%\bin\cache\dart-sdk\bin\dart + +set BUILD_TOOL_PKG_DIR_POSIX=%BUILD_TOOL_PKG_DIR:\=/% + +( + echo name: build_tool_runner + echo version: 1.0.0 + echo publish_to: none + echo. + echo environment: + echo sdk: '^>=3.0.0 ^<4.0.0' + echo. + echo dependencies: + echo build_tool: + echo path: %BUILD_TOOL_PKG_DIR_POSIX% +) >pubspec.yaml + +if not exist bin ( + mkdir bin +) + +( + echo import 'package:build_tool/build_tool.dart' as build_tool; + echo void main^(List^ args^) ^{ + echo build_tool.runMain^(args^); + echo ^} +) >bin\build_tool_runner.dart + +SET PRECOMPILED=bin\build_tool_runner.dill + +REM To detect changes in package we compare output of DIR /s (recursive) +set PREV_PACKAGE_INFO=.dart_tool\package_info.prev +set CUR_PACKAGE_INFO=.dart_tool\package_info.cur + +DIR "%BUILD_TOOL_PKG_DIR%" /s > "%CUR_PACKAGE_INFO%_orig" + +REM Last line in dir output is free space on harddrive. That is bound to +REM change between invocation so we need to remove it +( + Set "Line=" + For /F "UseBackQ Delims=" %%A In ("%CUR_PACKAGE_INFO%_orig") Do ( + SetLocal EnableDelayedExpansion + If Defined Line Echo !Line! + EndLocal + Set "Line=%%A") +) >"%CUR_PACKAGE_INFO%" +DEL "%CUR_PACKAGE_INFO%_orig" + +REM Compare current directory listing with previous +FC /B "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" > nul 2>&1 + +If %ERRORLEVEL% neq 0 ( + REM Changed - copy current to previous and remove precompiled kernel + if exist "%PREV_PACKAGE_INFO%" ( + DEL "%PREV_PACKAGE_INFO%" + ) + MOVE /Y "%CUR_PACKAGE_INFO%" "%PREV_PACKAGE_INFO%" + if exist "%PRECOMPILED%" ( + DEL "%PRECOMPILED%" + ) +) + +REM There is no CUR_PACKAGE_INFO it was renamed in previous step to %PREV_PACKAGE_INFO% +REM which means we need to do pub get and precompile +if not exist "%PRECOMPILED%" ( + echo Running pub get in "%cd%" + "%DART%" pub get --no-precompile + "%DART%" compile kernel bin/build_tool_runner.dart +) + +"%DART%" "%PRECOMPILED%" %* + +REM 253 means invalid snapshot version. +If %ERRORLEVEL% equ 253 ( + "%DART%" pub get --no-precompile + "%DART%" compile kernel bin/build_tool_runner.dart + "%DART%" "%PRECOMPILED%" %* +) diff --git a/packages/agent_dart/cargokit/run_build_tool.sh b/packages/agent_dart/cargokit/run_build_tool.sh new file mode 100644 index 00000000..6e594a23 --- /dev/null +++ b/packages/agent_dart/cargokit/run_build_tool.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash + +set -e + +BASEDIR=$(dirname "$0") + +mkdir -p "$CARGOKIT_TOOL_TEMP_DIR" + +cd "$CARGOKIT_TOOL_TEMP_DIR" + +# Write a very simple bin package in temp folder that depends on build_tool package +# from Cargokit. This is done to ensure that we don't pollute Cargokit folder +# with .dart_tool contents. + +BUILD_TOOL_PKG_DIR="$BASEDIR/build_tool" + +if [[ -z $FLUTTER_ROOT ]]; then # not defined + DART=dart +else + DART="$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart" +fi + +cat << EOF > "pubspec.yaml" +name: build_tool_runner +version: 1.0.0 +publish_to: none + +environment: + sdk: '>=3.0.0 <4.0.0' + +dependencies: + build_tool: + path: "$BUILD_TOOL_PKG_DIR" +EOF + +mkdir -p "bin" + +cat << EOF > "bin/build_tool_runner.dart" +import 'package:build_tool/build_tool.dart' as build_tool; +void main(List args) { + build_tool.runMain(args); +} +EOF + +# Create alias for `shasum` if it does not exist and `sha1sum` exists +if ! [ -x "$(command -v shasum)" ] && [ -x "$(command -v sha1sum)" ]; then + shopt -s expand_aliases + alias shasum="sha1sum" +fi + +# Dart run will not cache any package that has a path dependency, which +# is the case for our build_tool_runner. So instead we precompile the package +# ourselves. +# To invalidate the cached kernel we use the hash of ls -LR of the build_tool +# package directory. This should be good enough, as the build_tool package +# itself is not meant to have any path dependencies. + +if [[ "$OSTYPE" == "darwin"* ]]; then + PACKAGE_HASH=$(ls -lTR "$BUILD_TOOL_PKG_DIR" | shasum) +else + PACKAGE_HASH=$(ls -lR --full-time "$BUILD_TOOL_PKG_DIR" | shasum) +fi + +PACKAGE_HASH_FILE=".package_hash" + +if [ -f "$PACKAGE_HASH_FILE" ]; then + EXISTING_HASH=$(cat "$PACKAGE_HASH_FILE") + if [ "$PACKAGE_HASH" != "$EXISTING_HASH" ]; then + rm "$PACKAGE_HASH_FILE" + fi +fi + +# Run pub get if needed. +if [ ! -f "$PACKAGE_HASH_FILE" ]; then + "$DART" pub get --no-precompile + "$DART" compile kernel bin/build_tool_runner.dart + echo "$PACKAGE_HASH" > "$PACKAGE_HASH_FILE" +fi + +set +e + +"$DART" bin/build_tool_runner.dill "$@" + +exit_code=$? + +# 253 means invalid snapshot version. +if [ $exit_code == 253 ]; then + "$DART" pub get --no-precompile + "$DART" compile kernel bin/build_tool_runner.dart + "$DART" bin/build_tool_runner.dill "$@" + exit_code=$? +fi + +exit $exit_code diff --git a/packages/agent_dart/example/agent_dart_example.iml b/packages/agent_dart/example/agent_dart_example.iml index 55c2aa15..0ef0be79 100644 --- a/packages/agent_dart/example/agent_dart_example.iml +++ b/packages/agent_dart/example/agent_dart_example.iml @@ -23,6 +23,12 @@ + + + + + + diff --git a/packages/agent_dart/ios/Assets/.gitkeep b/packages/agent_dart/ios/Assets/.gitkeep deleted file mode 100644 index e2487db8..00000000 --- a/packages/agent_dart/ios/Assets/.gitkeep +++ /dev/null @@ -1,5 +0,0 @@ -// Copyright (c) 2021 neeboo@github.com -// -// This software is released under the MIT License. -// https://opensource.org/licenses/MIT - diff --git a/packages/agent_dart/ios/Classes/EnforceBundling.swift b/packages/agent_dart/ios/Classes/EnforceBundling.swift deleted file mode 100644 index 67e89f5d..00000000 --- a/packages/agent_dart/ios/Classes/EnforceBundling.swift +++ /dev/null @@ -1,4 +0,0 @@ -public func dummyMethodToEnforceBundling() -> Int64 { - return dummy_method_to_enforce_bundling() -} -let dummyVar = dummyMethodToEnforceBundling(); \ No newline at end of file diff --git a/packages/agent_dart/ios/Classes/bridge_generated.h b/packages/agent_dart/ios/Classes/bridge_generated.h deleted file mode 100644 index 5bed6c46..00000000 --- a/packages/agent_dart/ios/Classes/bridge_generated.h +++ /dev/null @@ -1,1247 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -#define ECB 0 - -#define CBC 1 - -#define CFB1 2 - -#define CFB2 3 - -#define CFB4 5 - -#define OFB1 14 - -#define OFB2 15 - -#define OFB4 17 - -#define OFB8 21 - -#define OFB16 29 - -#define CTR1 30 - -#define CTR2 31 - -#define CTR4 33 - -#define CTR8 37 - -#define CTR16 45 - -#define CHUNK 64 - -#define MODBYTES 48 - -#define BASEBITS 58 - -#define NLEN (1 + (((8 * MODBYTES) - 1) / BASEBITS)) - -#define DNLEN (2 * NLEN) - -#define HBITS (BASEBITS / 2) - - - -#define BIGBITS (MODBYTES * 8) - - - - - -#define BLS_OK 0 - -#define BLS_FAIL -1 - -#define WEIERSTRASS 0 - -#define EDWARDS 1 - -#define MONTGOMERY 2 - -#define NOT 0 - -#define BN 1 - -#define BLS12 2 - -#define BLS24 3 - -#define BLS48 4 - -#define D_TYPE 0 - -#define M_TYPE 1 - -#define POSITIVEX 0 - -#define NEGATIVEX 1 - -#define CURVETYPE WEIERSTRASS - -#define CURVE_A 0 - -#define CURVE_PAIRING_TYPE BLS12 - -#define SEXTIC_TWIST M_TYPE - -#define SIGN_OF_X NEGATIVEX - -#define ATE_BITS 65 - -#define G2_TABLE 69 - -#define HTC_ISO 11 - -#define HTC_ISO_G2 3 - -#define ALLOW_ALT_COMPRESS true - -#define HASH_TYPE 32 - -#define AESKEY 16 - -#define NOT_SPECIAL 0 - -#define PSEUDO_MERSENNE 1 - -#define MONTGOMERY_FRIENDLY 2 - -#define GENERALISED_MERSENNE 3 - -#define NEGATOWER 0 - -#define POSITOWER 1 - -#define MODBITS 381 - -#define PM1D2 1 - -#define RIADZ 11 - -#define RIADZG2A -2 - -#define RIADZG2B -1 - -#define MODTYPE NOT_SPECIAL - -#define QNRI 0 - -#define TOWER NEGATOWER - -#define FEXCESS (((int32_t)1 << 25) - 1) - - - -#define BIG_ENDIAN_SIGN false - -#define ZERO 0 - -#define ONE 1 - -#define SPARSEST 2 - -#define SPARSER 3 - -#define SPARSE 4 - -#define DENSE 5 - - - - - -#define BAD_PARAMS -11 - -#define INVALID_POINT -14 - -#define WRONG_ORDER -18 - -#define BAD_PIN -19 - -#define MAXPIN 10000 - -#define PBLEN 14 - -#define CURVE_COF_I 0 - -#define CURVE_B_I 4 - -#define USE_GLV true - -#define USE_GS_G2 true - -#define USE_GS_GT true - -#define GT_STRONG false - -#define MC_SHA2 2 - -#define MC_SHA3 3 - -#define HASH224 28 - -#define HASH256 32 - -#define HASH384 48 - -#define HASH512 64 - -#define SHAKE128 16 - -#define SHAKE256 32 - -#define KEY_LENGTH 32 - -#define KEY_LENGTH_AES (KEY_LENGTH / 2) - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_PhraseToSeedReq { - struct wire_uint_8_list *phrase; - struct wire_uint_8_list *password; -} wire_PhraseToSeedReq; - -typedef struct wire_SeedToKeyReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *path; -} wire_SeedToKeyReq; - -typedef struct wire_BLSVerifyReq { - struct wire_uint_8_list *signature; - struct wire_uint_8_list *message; - struct wire_uint_8_list *public_key; -} wire_BLSVerifyReq; - -typedef struct wire_ED25519FromSeedReq { - struct wire_uint_8_list *seed; -} wire_ED25519FromSeedReq; - -typedef struct wire_ED25519SignReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *message; -} wire_ED25519SignReq; - -typedef struct wire_ED25519VerifyReq { - struct wire_uint_8_list *sig; - struct wire_uint_8_list *message; - struct wire_uint_8_list *pub_key; -} wire_ED25519VerifyReq; - -typedef struct wire_Secp256k1FromSeedReq { - struct wire_uint_8_list *seed; -} wire_Secp256k1FromSeedReq; - -typedef struct wire_Secp256k1SignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; -} wire_Secp256k1SignWithSeedReq; - -typedef struct wire_Secp256k1SignWithRngReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *private_bytes; -} wire_Secp256k1SignWithRngReq; - -typedef struct wire_Secp256k1VerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_Secp256k1VerifyReq; - -typedef struct wire_Secp256k1ShareSecretReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *public_key_raw_bytes; -} wire_Secp256k1ShareSecretReq; - -typedef struct wire_Secp256k1RecoverReq { - struct wire_uint_8_list *message_pre_hashed; - struct wire_uint_8_list *signature_bytes; - uint8_t *chain_id; -} wire_Secp256k1RecoverReq; - -typedef struct wire_P256FromSeedReq { - struct wire_uint_8_list *seed; -} wire_P256FromSeedReq; - -typedef struct wire_P256SignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; -} wire_P256SignWithSeedReq; - -typedef struct wire_P256VerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_P256VerifyReq; - -typedef struct wire_P256ShareSecretReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *public_key_raw_bytes; -} wire_P256ShareSecretReq; - -typedef struct wire_SchnorrFromSeedReq { - struct wire_uint_8_list *seed; -} wire_SchnorrFromSeedReq; - -typedef struct wire_SchnorrSignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; - struct wire_uint_8_list *aux_rand; -} wire_SchnorrSignWithSeedReq; - -typedef struct wire_SchnorrVerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_SchnorrVerifyReq; - -typedef struct wire_AesEncryptReq { - struct wire_uint_8_list *key; - struct wire_uint_8_list *iv; - struct wire_uint_8_list *message; -} wire_AesEncryptReq; - -typedef struct wire_AesDecryptReq { - struct wire_uint_8_list *key; - struct wire_uint_8_list *iv; - struct wire_uint_8_list *cipher_text; -} wire_AesDecryptReq; - -typedef struct wire_PBKDFDeriveReq { - struct wire_uint_8_list *password; - struct wire_uint_8_list *salt; - uint32_t c; -} wire_PBKDFDeriveReq; - -typedef struct wire_ScriptDeriveReq { - struct wire_uint_8_list *password; - struct wire_uint_8_list *salt; - uint32_t n; - uint32_t p; - uint32_t r; -} wire_ScriptDeriveReq; - -typedef struct wire_ElectrumConfig { - struct wire_uint_8_list *url; - struct wire_uint_8_list *socks5; - uint8_t retry; - uint8_t *timeout; - uint64_t stop_gap; - bool validate_domain; -} wire_ElectrumConfig; - -typedef struct wire_BlockchainConfig_Electrum { - struct wire_ElectrumConfig *config; -} wire_BlockchainConfig_Electrum; - -typedef struct wire_EsploraConfig { - struct wire_uint_8_list *base_url; - struct wire_uint_8_list *proxy; - uint8_t *concurrency; - uint64_t stop_gap; - uint64_t *timeout; -} wire_EsploraConfig; - -typedef struct wire_BlockchainConfig_Esplora { - struct wire_EsploraConfig *config; -} wire_BlockchainConfig_Esplora; - -typedef struct wire_UserPass { - struct wire_uint_8_list *username; - struct wire_uint_8_list *password; -} wire_UserPass; - -typedef struct wire_RpcSyncParams { - uint64_t start_script_count; - uint64_t start_time; - bool force_start_time; - uint64_t poll_rate_sec; -} wire_RpcSyncParams; - -typedef struct wire_RpcConfig { - struct wire_uint_8_list *url; - struct wire_uint_8_list *auth_cookie; - struct wire_UserPass *auth_user_pass; - int32_t network; - struct wire_uint_8_list *wallet_name; - struct wire_RpcSyncParams *sync_params; -} wire_RpcConfig; - -typedef struct wire_BlockchainConfig_Rpc { - struct wire_RpcConfig *config; -} wire_BlockchainConfig_Rpc; - -typedef union BlockchainConfigKind { - struct wire_BlockchainConfig_Electrum *Electrum; - struct wire_BlockchainConfig_Esplora *Esplora; - struct wire_BlockchainConfig_Rpc *Rpc; -} BlockchainConfigKind; - -typedef struct wire_BlockchainConfig { - int32_t tag; - union BlockchainConfigKind *kind; -} wire_BlockchainConfig; - -typedef struct wire_BlockchainInstance { - const void *ptr; -} wire_BlockchainInstance; - -typedef struct wire_WalletInstance { - const void *ptr; -} wire_WalletInstance; - -typedef struct wire_Script { - struct wire_uint_8_list *internal; -} wire_Script; - -typedef struct wire_ScriptAmount { - struct wire_Script script; - uint64_t amount; -} wire_ScriptAmount; - -typedef struct wire_list_script_amount { - struct wire_ScriptAmount *ptr; - int32_t len; -} wire_list_script_amount; - -typedef struct wire_TxBytes { - struct wire_uint_8_list *tx_id; - struct wire_uint_8_list *bytes; -} wire_TxBytes; - -typedef struct wire_list_tx_bytes { - struct wire_TxBytes *ptr; - int32_t len; -} wire_list_tx_bytes; - -typedef struct wire_OutPoint { - struct wire_uint_8_list *txid; - uint32_t vout; -} wire_OutPoint; - -typedef struct wire_list_out_point { - struct wire_OutPoint *ptr; - int32_t len; -} wire_list_out_point; - -typedef struct wire_TxOutForeign { - uint64_t value; - struct wire_uint_8_list *script_pubkey; -} wire_TxOutForeign; - -typedef struct wire_ForeignUtxo { - struct wire_OutPoint outpoint; - struct wire_TxOutForeign txout; -} wire_ForeignUtxo; - -typedef struct wire_list_foreign_utxo { - struct wire_ForeignUtxo *ptr; - int32_t len; -} wire_list_foreign_utxo; - -typedef struct wire_RbfValue_RbfDefault { - -} wire_RbfValue_RbfDefault; - -typedef struct wire_RbfValue_Value { - uint32_t field0; -} wire_RbfValue_Value; - -typedef union RbfValueKind { - struct wire_RbfValue_RbfDefault *RbfDefault; - struct wire_RbfValue_Value *Value; -} RbfValueKind; - -typedef struct wire_RbfValue { - int32_t tag; - union RbfValueKind *kind; -} wire_RbfValue; - -typedef struct wire_BdkDescriptor { - const void *ptr; -} wire_BdkDescriptor; - -typedef struct wire_DatabaseConfig_Memory { - -} wire_DatabaseConfig_Memory; - -typedef struct wire_SqliteDbConfiguration { - struct wire_uint_8_list *path; -} wire_SqliteDbConfiguration; - -typedef struct wire_DatabaseConfig_Sqlite { - struct wire_SqliteDbConfiguration *config; -} wire_DatabaseConfig_Sqlite; - -typedef struct wire_SledDbConfiguration { - struct wire_uint_8_list *path; - struct wire_uint_8_list *tree_name; -} wire_SledDbConfiguration; - -typedef struct wire_DatabaseConfig_Sled { - struct wire_SledDbConfiguration *config; -} wire_DatabaseConfig_Sled; - -typedef union DatabaseConfigKind { - struct wire_DatabaseConfig_Memory *Memory; - struct wire_DatabaseConfig_Sqlite *Sqlite; - struct wire_DatabaseConfig_Sled *Sled; -} DatabaseConfigKind; - -typedef struct wire_DatabaseConfig { - int32_t tag; - union DatabaseConfigKind *kind; -} wire_DatabaseConfig; - -typedef struct wire_AddressIndex_NewIndex { - -} wire_AddressIndex_NewIndex; - -typedef struct wire_AddressIndex_LastUnused { - -} wire_AddressIndex_LastUnused; - -typedef struct wire_AddressIndex_Peek { - uint32_t index; -} wire_AddressIndex_Peek; - -typedef struct wire_AddressIndex_Reset { - uint32_t index; -} wire_AddressIndex_Reset; - -typedef union AddressIndexKind { - struct wire_AddressIndex_NewIndex *NewIndex; - struct wire_AddressIndex_LastUnused *LastUnused; - struct wire_AddressIndex_Peek *Peek; - struct wire_AddressIndex_Reset *Reset; -} AddressIndexKind; - -typedef struct wire_AddressIndex { - int32_t tag; - union AddressIndexKind *kind; -} wire_AddressIndex; - -typedef struct wire_SignOptions { - bool trust_witness_utxo; - uint32_t *assume_height; - bool allow_all_sighashes; - bool remove_partial_sigs; - bool try_finalize; - bool finalize_mine_only; - bool sign_with_tap_internal_key; - bool allow_grinding; -} wire_SignOptions; - -typedef struct DartCObject *WireSyncReturn; - -typedef int64_t Chunk; - -#define BMASK ((1 << BASEBITS) - 1) - -#define HMASK ((1 << HBITS) - 1) - - - -#define TMASK ((1 << TBITS) - 1) - -#define MCONST 140737475470229501 - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_mnemonic_phrase_to_seed(int64_t port_, struct wire_PhraseToSeedReq *req); - -void wire_mnemonic_seed_to_key(int64_t port_, struct wire_SeedToKeyReq *req); - -void wire_hex_bytes_to_wif(int64_t port_, struct wire_uint_8_list *hex, int32_t network); - -void wire_bls_init(int64_t port_); - -void wire_bls_verify(int64_t port_, struct wire_BLSVerifyReq *req); - -void wire_ed25519_from_seed(int64_t port_, struct wire_ED25519FromSeedReq *req); - -void wire_ed25519_sign(int64_t port_, struct wire_ED25519SignReq *req); - -void wire_ed25519_verify(int64_t port_, struct wire_ED25519VerifyReq *req); - -void wire_secp256k1_from_seed(int64_t port_, struct wire_Secp256k1FromSeedReq *req); - -void wire_secp256k1_sign(int64_t port_, struct wire_Secp256k1SignWithSeedReq *req); - -void wire_secp256k1_sign_with_rng(int64_t port_, struct wire_Secp256k1SignWithRngReq *req); - -void wire_secp256k1_sign_recoverable(int64_t port_, struct wire_Secp256k1SignWithSeedReq *req); - -void wire_secp256k1_verify(int64_t port_, struct wire_Secp256k1VerifyReq *req); - -void wire_secp256k1_get_shared_secret(int64_t port_, struct wire_Secp256k1ShareSecretReq *req); - -void wire_secp256k1_recover(int64_t port_, struct wire_Secp256k1RecoverReq *req); - -void wire_p256_from_seed(int64_t port_, struct wire_P256FromSeedReq *req); - -void wire_p256_sign(int64_t port_, struct wire_P256SignWithSeedReq *req); - -void wire_p256_verify(int64_t port_, struct wire_P256VerifyReq *req); - -void wire_p256_get_shared_secret(int64_t port_, struct wire_P256ShareSecretReq *req); - -void wire_schnorr_from_seed(int64_t port_, struct wire_SchnorrFromSeedReq *req); - -void wire_schnorr_sign(int64_t port_, struct wire_SchnorrSignWithSeedReq *req); - -void wire_schnorr_verify(int64_t port_, struct wire_SchnorrVerifyReq *req); - -void wire_aes_128_ctr_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_128_ctr_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_aes_256_cbc_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_256_cbc_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_aes_256_gcm_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_256_gcm_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_pbkdf2_derive_key(int64_t port_, struct wire_PBKDFDeriveReq *req); - -void wire_scrypt_derive_key(int64_t port_, struct wire_ScriptDeriveReq *req); - -void wire_create_blockchain__static_method__Api(int64_t port_, - struct wire_BlockchainConfig *config); - -void wire_get_height__static_method__Api(int64_t port_, struct wire_BlockchainInstance blockchain); - -void wire_get_blockchain_hash__static_method__Api(int64_t port_, - uint32_t blockchain_height, - struct wire_BlockchainInstance blockchain); - -void wire_estimate_fee__static_method__Api(int64_t port_, - uint64_t target, - struct wire_BlockchainInstance blockchain); - -void wire_broadcast__static_method__Api(int64_t port_, - struct wire_uint_8_list *tx, - struct wire_BlockchainInstance blockchain); - -void wire_get_tx__static_method__Api(int64_t port_, - struct wire_uint_8_list *tx, - struct wire_BlockchainInstance blockchain); - -void wire_create_transaction__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_tx_txid__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_weight__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_size__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_vsize__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_serialize_tx__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_coin_base__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_explicitly_rbf__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_lock_time_enabled__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_version__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_lock_time__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_input__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_output__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_serialize_psbt__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_txid__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_extract_tx__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_fee_rate__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_fee_amount__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_combine_psbt__static_method__Api(int64_t port_, - struct wire_uint_8_list *psbt_str, - struct wire_uint_8_list *other); - -void wire_json_serialize__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_get_inputs__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_tx_builder_finish__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_list_script_amount *recipients, - struct wire_list_tx_bytes *txs, - struct wire_list_out_point *unspendable, - struct wire_list_foreign_utxo *foreign_utxos, - int32_t change_policy, - bool manually_selected_only, - float *fee_rate, - uint64_t *fee_absolute, - bool drain_wallet, - struct wire_Script *drain_to, - struct wire_RbfValue *rbf, - struct wire_uint_8_list *data, - bool *shuffle_utxo); - -void wire_tx_cal_fee_finish__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_list_script_amount *recipients, - struct wire_list_tx_bytes *txs, - struct wire_list_out_point *unspendable, - struct wire_list_foreign_utxo *foreign_utxos, - int32_t change_policy, - bool manually_selected_only, - float *fee_rate, - uint64_t *fee_absolute, - bool drain_wallet, - struct wire_Script *drain_to, - struct wire_RbfValue *rbf, - struct wire_uint_8_list *data, - bool *shuffle_utxo); - -void wire_bump_fee_tx_builder_finish__static_method__Api(int64_t port_, - struct wire_uint_8_list *txid, - float fee_rate, - struct wire_uint_8_list *allow_shrinking, - struct wire_WalletInstance wallet, - bool enable_rbf, - bool keep_change, - uint32_t *n_sequence); - -void wire_create_descriptor__static_method__Api(int64_t port_, - struct wire_uint_8_list *descriptor, - int32_t network); - -void wire_import_single_wif__static_method__Api(int64_t port_, - struct wire_uint_8_list *wif, - struct wire_uint_8_list *address_type, - int32_t network); - -void wire_new_bip44_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip44_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip44_tr_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip44_tr_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip49_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip49_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip84_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip84_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip86_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip86_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_as_string_private__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor); - -void wire_as_string__static_method__Api(int64_t port_, struct wire_BdkDescriptor descriptor); - -void wire_derive_address_at__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor, - uint32_t index, - int32_t network); - -void wire_create_descriptor_secret__static_method__Api(int64_t port_, - int32_t network, - struct wire_uint_8_list *mnemonic, - struct wire_uint_8_list *password); - -void wire_create_derived_descriptor_secret__static_method__Api(int64_t port_, - int32_t network, - struct wire_uint_8_list *mnemonic, - struct wire_uint_8_list *path, - struct wire_uint_8_list *password); - -void wire_descriptor_secret_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret); - -void wire_extend_descriptor_secret__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *path); - -void wire_derive_descriptor_secret__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *path); - -void wire_as_secret_bytes__static_method__Api(int64_t port_, struct wire_uint_8_list *secret); - -void wire_as_public__static_method__Api(int64_t port_, struct wire_uint_8_list *secret); - -void wire_get_pub_from_secret_bytes__static_method__Api(int64_t port_, - struct wire_uint_8_list *bytes); - -void wire_create_derivation_path__static_method__Api(int64_t port_, struct wire_uint_8_list *path); - -void wire_descriptor_public_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *public_key); - -void wire_master_finterprint__static_method__Api(int64_t port_, struct wire_uint_8_list *xpub); - -void wire_create_descriptor_public__static_method__Api(int64_t port_, - struct wire_uint_8_list *xpub, - struct wire_uint_8_list *path, - bool derive); - -void wire_to_public_string__static_method__Api(int64_t port_, struct wire_uint_8_list *xpub); - -void wire_create_script__static_method__Api(int64_t port_, - struct wire_uint_8_list *raw_output_script); - -void wire_create_address__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_address_from_script__static_method__Api(int64_t port_, - struct wire_Script *script, - int32_t network); - -void wire_address_to_script_pubkey__static_method__Api(int64_t port_, - struct wire_uint_8_list *address); - -void wire_payload__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_address_network__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_get_address_type__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_create_wallet__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor, - struct wire_BdkDescriptor *change_descriptor, - int32_t network, - struct wire_DatabaseConfig *database_config); - -void wire_get_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_AddressIndex *address_index); - -void wire_get_internal_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_AddressIndex *address_index); - -void wire_sync_wallet__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_BlockchainInstance blockchain); - -void wire_sync_wallet_thread__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_BlockchainInstance blockchain); - -void wire_get_balance__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_list_unspent_outputs__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet); - -void wire_get_transactions__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - bool include_raw); - -void wire_sign__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_uint_8_list *psbt_str, - struct wire_SignOptions *sign_options); - -void wire_wallet_network__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_list_unspent__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_cache_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - uint32_t cache_size); - -void wire_generate_seed_from_word_count__static_method__Api(int64_t port_, int32_t word_count); - -void wire_generate_seed_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *mnemonic); - -void wire_generate_seed_from_entropy__static_method__Api(int64_t port_, - struct wire_uint_8_list *entropy); - -void wire_bip322_sign_segwit__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *message); - -void wire_bip322_sign_taproot__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *message); - -struct wire_BdkDescriptor new_BdkDescriptor(void); - -struct wire_BlockchainInstance new_BlockchainInstance(void); - -struct wire_WalletInstance new_WalletInstance(void); - -struct wire_BdkDescriptor *new_box_autoadd_BdkDescriptor_0(void); - -struct wire_AddressIndex *new_box_autoadd_address_index_0(void); - -struct wire_AesDecryptReq *new_box_autoadd_aes_decrypt_req_0(void); - -struct wire_AesEncryptReq *new_box_autoadd_aes_encrypt_req_0(void); - -struct wire_BlockchainConfig *new_box_autoadd_blockchain_config_0(void); - -struct wire_BLSVerifyReq *new_box_autoadd_bls_verify_req_0(void); - -bool *new_box_autoadd_bool_0(bool value); - -struct wire_DatabaseConfig *new_box_autoadd_database_config_0(void); - -struct wire_ED25519FromSeedReq *new_box_autoadd_ed_25519_from_seed_req_0(void); - -struct wire_ED25519SignReq *new_box_autoadd_ed_25519_sign_req_0(void); - -struct wire_ED25519VerifyReq *new_box_autoadd_ed_25519_verify_req_0(void); - -struct wire_ElectrumConfig *new_box_autoadd_electrum_config_0(void); - -struct wire_EsploraConfig *new_box_autoadd_esplora_config_0(void); - -float *new_box_autoadd_f32_0(float value); - -struct wire_P256FromSeedReq *new_box_autoadd_p_256_from_seed_req_0(void); - -struct wire_P256ShareSecretReq *new_box_autoadd_p_256_share_secret_req_0(void); - -struct wire_P256SignWithSeedReq *new_box_autoadd_p_256_sign_with_seed_req_0(void); - -struct wire_P256VerifyReq *new_box_autoadd_p_256_verify_req_0(void); - -struct wire_PBKDFDeriveReq *new_box_autoadd_pbkdf_derive_req_0(void); - -struct wire_PhraseToSeedReq *new_box_autoadd_phrase_to_seed_req_0(void); - -struct wire_RbfValue *new_box_autoadd_rbf_value_0(void); - -struct wire_RpcConfig *new_box_autoadd_rpc_config_0(void); - -struct wire_RpcSyncParams *new_box_autoadd_rpc_sync_params_0(void); - -struct wire_SchnorrFromSeedReq *new_box_autoadd_schnorr_from_seed_req_0(void); - -struct wire_SchnorrSignWithSeedReq *new_box_autoadd_schnorr_sign_with_seed_req_0(void); - -struct wire_SchnorrVerifyReq *new_box_autoadd_schnorr_verify_req_0(void); - -struct wire_Script *new_box_autoadd_script_0(void); - -struct wire_ScriptDeriveReq *new_box_autoadd_script_derive_req_0(void); - -struct wire_Secp256k1FromSeedReq *new_box_autoadd_secp_256_k_1_from_seed_req_0(void); - -struct wire_Secp256k1RecoverReq *new_box_autoadd_secp_256_k_1_recover_req_0(void); - -struct wire_Secp256k1ShareSecretReq *new_box_autoadd_secp_256_k_1_share_secret_req_0(void); - -struct wire_Secp256k1SignWithRngReq *new_box_autoadd_secp_256_k_1_sign_with_rng_req_0(void); - -struct wire_Secp256k1SignWithSeedReq *new_box_autoadd_secp_256_k_1_sign_with_seed_req_0(void); - -struct wire_Secp256k1VerifyReq *new_box_autoadd_secp_256_k_1_verify_req_0(void); - -struct wire_SeedToKeyReq *new_box_autoadd_seed_to_key_req_0(void); - -struct wire_SignOptions *new_box_autoadd_sign_options_0(void); - -struct wire_SledDbConfiguration *new_box_autoadd_sled_db_configuration_0(void); - -struct wire_SqliteDbConfiguration *new_box_autoadd_sqlite_db_configuration_0(void); - -uint32_t *new_box_autoadd_u32_0(uint32_t value); - -uint64_t *new_box_autoadd_u64_0(uint64_t value); - -uint8_t *new_box_autoadd_u8_0(uint8_t value); - -struct wire_UserPass *new_box_autoadd_user_pass_0(void); - -struct wire_list_foreign_utxo *new_list_foreign_utxo_0(int32_t len); - -struct wire_list_out_point *new_list_out_point_0(int32_t len); - -struct wire_list_script_amount *new_list_script_amount_0(int32_t len); - -struct wire_list_tx_bytes *new_list_tx_bytes_0(int32_t len); - -struct wire_uint_8_list *new_uint_8_list_0(int32_t len); - -void drop_opaque_BdkDescriptor(const void *ptr); - -const void *share_opaque_BdkDescriptor(const void *ptr); - -void drop_opaque_BlockchainInstance(const void *ptr); - -const void *share_opaque_BlockchainInstance(const void *ptr); - -void drop_opaque_WalletInstance(const void *ptr); - -const void *share_opaque_WalletInstance(const void *ptr); - -union AddressIndexKind *inflate_AddressIndex_Peek(void); - -union AddressIndexKind *inflate_AddressIndex_Reset(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Electrum(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Esplora(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Rpc(void); - -union DatabaseConfigKind *inflate_DatabaseConfig_Sqlite(void); - -union DatabaseConfigKind *inflate_DatabaseConfig_Sled(void); - -union RbfValueKind *inflate_RbfValue_Value(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -static int64_t dummy_method_to_enforce_bundling(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_mnemonic_phrase_to_seed); - dummy_var ^= ((int64_t) (void*) wire_mnemonic_seed_to_key); - dummy_var ^= ((int64_t) (void*) wire_hex_bytes_to_wif); - dummy_var ^= ((int64_t) (void*) wire_bls_init); - dummy_var ^= ((int64_t) (void*) wire_bls_verify); - dummy_var ^= ((int64_t) (void*) wire_ed25519_from_seed); - dummy_var ^= ((int64_t) (void*) wire_ed25519_sign); - dummy_var ^= ((int64_t) (void*) wire_ed25519_verify); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_from_seed); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign_with_rng); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign_recoverable); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_verify); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_get_shared_secret); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_recover); - dummy_var ^= ((int64_t) (void*) wire_p256_from_seed); - dummy_var ^= ((int64_t) (void*) wire_p256_sign); - dummy_var ^= ((int64_t) (void*) wire_p256_verify); - dummy_var ^= ((int64_t) (void*) wire_p256_get_shared_secret); - dummy_var ^= ((int64_t) (void*) wire_schnorr_from_seed); - dummy_var ^= ((int64_t) (void*) wire_schnorr_sign); - dummy_var ^= ((int64_t) (void*) wire_schnorr_verify); - dummy_var ^= ((int64_t) (void*) wire_aes_128_ctr_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_128_ctr_decrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_cbc_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_cbc_decrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_gcm_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_gcm_decrypt); - dummy_var ^= ((int64_t) (void*) wire_pbkdf2_derive_key); - dummy_var ^= ((int64_t) (void*) wire_scrypt_derive_key); - dummy_var ^= ((int64_t) (void*) wire_create_blockchain__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_height__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_blockchain_hash__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_estimate_fee__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_broadcast__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_transaction__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_txid__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_weight__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_size__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_vsize__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_serialize_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_coin_base__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_explicitly_rbf__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_lock_time_enabled__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_version__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_lock_time__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_input__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_output__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_serialize_psbt__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_txid__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_extract_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_fee_rate__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_fee_amount__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_combine_psbt__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_json_serialize__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_inputs__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_builder_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_cal_fee_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bump_fee_tx_builder_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_import_single_wif__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_tr_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_tr_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip49_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip49_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip84_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip84_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip86_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip86_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_string_private__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_derive_address_at__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_derived_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_extend_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_derive_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_secret_bytes__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_pub_from_secret_bytes__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_derivation_path__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_descriptor_public_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_master_finterprint__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_to_public_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_script__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_from_script__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_to_script_pubkey__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_payload__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_network__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_address_type__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_wallet__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_internal_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sync_wallet__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sync_wallet_thread__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_balance__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_list_unspent_outputs__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_transactions__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sign__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_wallet_network__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_list_unspent__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_cache_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_word_count__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_entropy__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bip322_sign_segwit__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bip322_sign_taproot__static_method__Api); - dummy_var ^= ((int64_t) (void*) new_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) new_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) new_WalletInstance); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_BdkDescriptor_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_address_index_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_aes_decrypt_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_aes_encrypt_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_blockchain_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_bls_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_bool_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_database_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_sign_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_electrum_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_esplora_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_f32_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_share_secret_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_pbkdf_derive_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_phrase_to_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rbf_value_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_sync_params_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_script_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_script_derive_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_recover_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_share_secret_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_sign_with_rng_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_seed_to_key_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sign_options_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sled_db_configuration_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sqlite_db_configuration_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u32_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u64_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u8_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_user_pass_0); - dummy_var ^= ((int64_t) (void*) new_list_foreign_utxo_0); - dummy_var ^= ((int64_t) (void*) new_list_out_point_0); - dummy_var ^= ((int64_t) (void*) new_list_script_amount_0); - dummy_var ^= ((int64_t) (void*) new_list_tx_bytes_0); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); - dummy_var ^= ((int64_t) (void*) drop_opaque_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) share_opaque_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) drop_opaque_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) share_opaque_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) drop_opaque_WalletInstance); - dummy_var ^= ((int64_t) (void*) share_opaque_WalletInstance); - dummy_var ^= ((int64_t) (void*) inflate_AddressIndex_Peek); - dummy_var ^= ((int64_t) (void*) inflate_AddressIndex_Reset); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Electrum); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Esplora); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Rpc); - dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sqlite); - dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sled); - dummy_var ^= ((int64_t) (void*) inflate_RbfValue_Value); - dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/packages/agent_dart/ios/Classes/dummy_file.c b/packages/agent_dart/ios/Classes/dummy_file.c new file mode 100644 index 00000000..e06dab99 --- /dev/null +++ b/packages/agent_dart/ios/Classes/dummy_file.c @@ -0,0 +1 @@ +// This is an empty file to force CocoaPods to create a framework. diff --git a/packages/agent_dart/ios/Frameworks/.gitkeep b/packages/agent_dart/ios/Frameworks/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/agent_dart/ios/agent_dart.podspec b/packages/agent_dart/ios/agent_dart.podspec index 47a93d24..6ace087e 100644 --- a/packages/agent_dart/ios/agent_dart.podspec +++ b/packages/agent_dart/ios/agent_dart.podspec @@ -1,37 +1,45 @@ -release_tag_name = 'agent_dart-v0.0.0' # generated; do not edit +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint agent_dart.podspec` to validate before publishing. +# +Pod::Spec.new do |s| + s.name = 'agent_dart' + s.version = '1.0.0' + s.license = { :file => '../LICENSE' } + s.homepage = 'https://github.com/AstroxNetwork/agent_dart' + s.authors = { 'AstroX Dev' => 'dev@astrox.network' } + s.summary = 'iOS/macOS Flutter bindings for agent_dart' -# We cannot distribute the XCFramework alongside the library directly, -# so we have to fetch the correct version here. -framework_name = 'AgentDart.xcframework' -remote_zip_name = "#{framework_name}.zip" -url = "https://github.com/AstroxNetwork/agent_dart/releases/download/#{release_tag_name}/#{remote_zip_name}" -local_zip_name = "#{release_tag_name}.zip" -` -cd Frameworks -rm -rf #{framework_name} + # This will ensure the source files in Classes/ are included in the native + # builds of apps using this FFI plugin. Podspec does not support relative + # paths, so Classes contains a forwarder C file that relatively imports + # `../src/*` so that the C sources can be shared among all target platforms. + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' -if [ ! -f #{local_zip_name} ] -then - curl -L #{url} -o #{local_zip_name} -fi + s.dependency 'Flutter' + s.platform = :ios, '11.0' + # Flutter.framework does not contain a i386 slice. + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES', 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386' } + s.swift_version = '5.0' -unzip #{local_zip_name} -cd - -` + s.ios.deployment_target = '11.0' + s.osx.deployment_target = '10.11' -Pod::Spec.new do |spec| - spec.name = 'agent_dart' - spec.version = '0.0.1' - spec.license = { :file => '../LICENSE' } - spec.homepage = 'https://github.com/AstroxNetwork/agent_dart' - spec.authors = { 'AstroX Dev' => 'dev@astrox.network' } - spec.summary = 'iOS/macOS Flutter bindings for agent_dart' - - spec.source = { :path => '.' } - spec.source_files = 'Classes/**/*' - spec.public_header_files = 'Classes/**/*.h' - spec.vendored_frameworks = "Frameworks/#{framework_name}" - - spec.ios.deployment_target = '11.0' - spec.osx.deployment_target = '10.11' -end \ No newline at end of file + s.script_phase = { + :name => 'Build Rust library', + # First argument is relative path to the `rust` folder, second is name of rust library + :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../agent_dart_ffi/native/agent_dart agent_dart', + :execution_position => :before_compile, + :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], + # Let XCode know that the static library referenced in -force_load below is + # created by this build step. + :output_files => ["${BUILT_PRODUCTS_DIR}/libagent_dart.a"], + } + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + # Flutter.framework does not contain a i386 slice. + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', + 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libagent_dart.a', + } +end diff --git a/packages/agent_dart/linux/CMakeLists.txt b/packages/agent_dart/linux/CMakeLists.txt index 7524637c..fc0dd8ce 100644 --- a/packages/agent_dart/linux/CMakeLists.txt +++ b/packages/agent_dart/linux/CMakeLists.txt @@ -1,38 +1,19 @@ -set(LibraryVersion "agent_dart-v0.0.0") # generated; do not edit - # The Flutter tooling requires that developers have CMake 3.10 or later # installed. You should not increase this version, as doing so will cause # the plugin to fail to compile for some customers of the plugin. cmake_minimum_required(VERSION 3.10) # Project-level configuration. -set(PROJECT_NAME "agent_dart") # Should match the name field in the pubspec.yaml. +set(PROJECT_NAME "agent_dart") project(${PROJECT_NAME} LANGUAGES CXX) -# Download the binaries if they are not already present. -set(LibRoot "${CMAKE_CURRENT_SOURCE_DIR}/${LibraryVersion}") -set(ArchivePath "${LibRoot}.tar.gz") -if(NOT EXISTS ${ArchivePath}) - file(DOWNLOAD - "https://github.com/AstroxNetwork/agent_dart/releases/download/${LibraryVersion}/other.tar.gz" - ${ArchivePath} - TLS_VERIFY ON - ) -endif() - -# Extract the binaries, overriding any already present. -file(REMOVE_RECURSE "linux-arm64") -file(REMOVE_RECURSE "linux-x64") -execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) +include("../cargokit/cmake/cargokit.cmake") +apply_cargokit(${PROJECT_NAME} ../../agent_dart_ffi/native/agent_dart agent_dart "") -set(LIBRARY_NAME "agent_dart") # Should match the library name you used to generate. # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an # external build triggered from this build file. -set(${PROJECT_NAME}_bundled_libraries - "${CMAKE_CURRENT_SOURCE_DIR}/${FLUTTER_TARGET_PLATFORM}/lib${LIBRARY_NAME}.so" +set(agent_dart_bundled_libraries + "${${PROJECT_NAME}_cargokit_lib}" PARENT_SCOPE ) diff --git a/packages/agent_dart/linux/agent_dart_plugin.cc b/packages/agent_dart/linux/agent_dart_plugin.cc deleted file mode 100644 index 2a862ba2..00000000 --- a/packages/agent_dart/linux/agent_dart_plugin.cc +++ /dev/null @@ -1,70 +0,0 @@ -#include "include/agent_dart/agent_dart_plugin.h" - -#include -#include -#include - -#include - -#define AGENT_DART_PLUGIN(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST((obj), agent_dart_plugin_get_type(), \ - AgentDartPlugin)) - -struct _AgentDartPlugin { - GObject parent_instance; -}; - -G_DEFINE_TYPE(AgentDartPlugin, agent_dart_plugin, g_object_get_type()) - -// Called when a method call is received from Flutter. -static void agent_dart_plugin_handle_method_call( - AgentDartPlugin* self, - FlMethodCall* method_call) { - g_autoptr(FlMethodResponse) response = nullptr; - - const gchar* method = fl_method_call_get_name(method_call); - - if (strcmp(method, "getPlatformVersion") == 0) { - struct utsname uname_data = {}; - uname(&uname_data); - g_autofree gchar *version = g_strdup_printf("Linux %s", uname_data.version); - g_autoptr(FlValue) result = fl_value_new_string(version); - response = FL_METHOD_RESPONSE(fl_method_success_response_new(result)); - } else { - response = FL_METHOD_RESPONSE(fl_method_not_implemented_response_new()); - } - - fl_method_call_respond(method_call, response, nullptr); -} - -static void agent_dart_plugin_dispose(GObject* object) { - G_OBJECT_CLASS(agent_dart_plugin_parent_class)->dispose(object); -} - -static void agent_dart_plugin_class_init(AgentDartPluginClass* klass) { - G_OBJECT_CLASS(klass)->dispose = agent_dart_plugin_dispose; -} - -static void agent_dart_plugin_init(AgentDartPlugin* self) {} - -static void method_call_cb(FlMethodChannel* channel, FlMethodCall* method_call, - gpointer user_data) { - AgentDartPlugin* plugin = AGENT_DART_PLUGIN(user_data); - agent_dart_plugin_handle_method_call(plugin, method_call); -} - -void agent_dart_plugin_register_with_registrar(FlPluginRegistrar* registrar) { - AgentDartPlugin* plugin = AGENT_DART_PLUGIN( - g_object_new(agent_dart_plugin_get_type(), nullptr)); - - g_autoptr(FlStandardMethodCodec) codec = fl_standard_method_codec_new(); - g_autoptr(FlMethodChannel) channel = - fl_method_channel_new(fl_plugin_registrar_get_messenger(registrar), - "agent_dart", - FL_METHOD_CODEC(codec)); - fl_method_channel_set_method_call_handler(channel, method_call_cb, - g_object_ref(plugin), - g_object_unref); - - g_object_unref(plugin); -} diff --git a/packages/agent_dart/linux/include/agent_dart/agent_dart_plugin.h b/packages/agent_dart/linux/include/agent_dart/agent_dart_plugin.h deleted file mode 100644 index 2e22f62b..00000000 --- a/packages/agent_dart/linux/include/agent_dart/agent_dart_plugin.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef FLUTTER_PLUGIN_AGENT_DART_PLUGIN_H_ -#define FLUTTER_PLUGIN_AGENT_DART_PLUGIN_H_ - -#include - -G_BEGIN_DECLS - -#ifdef FLUTTER_PLUGIN_IMPL -#define FLUTTER_PLUGIN_EXPORT __attribute__((visibility("default"))) -#else -#define FLUTTER_PLUGIN_EXPORT -#endif - -typedef struct _AgentDartPlugin AgentDartPlugin; -typedef struct { - GObjectClass parent_class; -} AgentDartPluginClass; - -FLUTTER_PLUGIN_EXPORT GType agent_dart_plugin_get_type(); - -FLUTTER_PLUGIN_EXPORT void agent_dart_plugin_register_with_registrar( - FlPluginRegistrar* registrar); - -G_END_DECLS - -#endif // FLUTTER_PLUGIN_AGENT_DART_PLUGIN_H_ diff --git a/packages/agent_dart/linux/libagent_dart.so b/packages/agent_dart/linux/libagent_dart.so deleted file mode 100755 index b029af57..00000000 Binary files a/packages/agent_dart/linux/libagent_dart.so and /dev/null differ diff --git a/packages/agent_dart/macos/Classes/EnforceBundling.swift b/packages/agent_dart/macos/Classes/EnforceBundling.swift deleted file mode 100644 index f95cacb9..00000000 --- a/packages/agent_dart/macos/Classes/EnforceBundling.swift +++ /dev/null @@ -1,4 +0,0 @@ -public func dummyMethodToEnforceBundling() -> Int64 { - return dummy_method_to_enforce_bundling() -} -let dummyVar = dummyMethodToEnforceBundling(); diff --git a/packages/agent_dart/macos/Classes/bridge_generated.h b/packages/agent_dart/macos/Classes/bridge_generated.h deleted file mode 100644 index 5bed6c46..00000000 --- a/packages/agent_dart/macos/Classes/bridge_generated.h +++ /dev/null @@ -1,1247 +0,0 @@ -#include -#include -#include -typedef struct _Dart_Handle* Dart_Handle; - -#define ECB 0 - -#define CBC 1 - -#define CFB1 2 - -#define CFB2 3 - -#define CFB4 5 - -#define OFB1 14 - -#define OFB2 15 - -#define OFB4 17 - -#define OFB8 21 - -#define OFB16 29 - -#define CTR1 30 - -#define CTR2 31 - -#define CTR4 33 - -#define CTR8 37 - -#define CTR16 45 - -#define CHUNK 64 - -#define MODBYTES 48 - -#define BASEBITS 58 - -#define NLEN (1 + (((8 * MODBYTES) - 1) / BASEBITS)) - -#define DNLEN (2 * NLEN) - -#define HBITS (BASEBITS / 2) - - - -#define BIGBITS (MODBYTES * 8) - - - - - -#define BLS_OK 0 - -#define BLS_FAIL -1 - -#define WEIERSTRASS 0 - -#define EDWARDS 1 - -#define MONTGOMERY 2 - -#define NOT 0 - -#define BN 1 - -#define BLS12 2 - -#define BLS24 3 - -#define BLS48 4 - -#define D_TYPE 0 - -#define M_TYPE 1 - -#define POSITIVEX 0 - -#define NEGATIVEX 1 - -#define CURVETYPE WEIERSTRASS - -#define CURVE_A 0 - -#define CURVE_PAIRING_TYPE BLS12 - -#define SEXTIC_TWIST M_TYPE - -#define SIGN_OF_X NEGATIVEX - -#define ATE_BITS 65 - -#define G2_TABLE 69 - -#define HTC_ISO 11 - -#define HTC_ISO_G2 3 - -#define ALLOW_ALT_COMPRESS true - -#define HASH_TYPE 32 - -#define AESKEY 16 - -#define NOT_SPECIAL 0 - -#define PSEUDO_MERSENNE 1 - -#define MONTGOMERY_FRIENDLY 2 - -#define GENERALISED_MERSENNE 3 - -#define NEGATOWER 0 - -#define POSITOWER 1 - -#define MODBITS 381 - -#define PM1D2 1 - -#define RIADZ 11 - -#define RIADZG2A -2 - -#define RIADZG2B -1 - -#define MODTYPE NOT_SPECIAL - -#define QNRI 0 - -#define TOWER NEGATOWER - -#define FEXCESS (((int32_t)1 << 25) - 1) - - - -#define BIG_ENDIAN_SIGN false - -#define ZERO 0 - -#define ONE 1 - -#define SPARSEST 2 - -#define SPARSER 3 - -#define SPARSE 4 - -#define DENSE 5 - - - - - -#define BAD_PARAMS -11 - -#define INVALID_POINT -14 - -#define WRONG_ORDER -18 - -#define BAD_PIN -19 - -#define MAXPIN 10000 - -#define PBLEN 14 - -#define CURVE_COF_I 0 - -#define CURVE_B_I 4 - -#define USE_GLV true - -#define USE_GS_G2 true - -#define USE_GS_GT true - -#define GT_STRONG false - -#define MC_SHA2 2 - -#define MC_SHA3 3 - -#define HASH224 28 - -#define HASH256 32 - -#define HASH384 48 - -#define HASH512 64 - -#define SHAKE128 16 - -#define SHAKE256 32 - -#define KEY_LENGTH 32 - -#define KEY_LENGTH_AES (KEY_LENGTH / 2) - -typedef struct DartCObject DartCObject; - -typedef int64_t DartPort; - -typedef bool (*DartPostCObjectFnType)(DartPort port_id, void *message); - -typedef struct wire_uint_8_list { - uint8_t *ptr; - int32_t len; -} wire_uint_8_list; - -typedef struct wire_PhraseToSeedReq { - struct wire_uint_8_list *phrase; - struct wire_uint_8_list *password; -} wire_PhraseToSeedReq; - -typedef struct wire_SeedToKeyReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *path; -} wire_SeedToKeyReq; - -typedef struct wire_BLSVerifyReq { - struct wire_uint_8_list *signature; - struct wire_uint_8_list *message; - struct wire_uint_8_list *public_key; -} wire_BLSVerifyReq; - -typedef struct wire_ED25519FromSeedReq { - struct wire_uint_8_list *seed; -} wire_ED25519FromSeedReq; - -typedef struct wire_ED25519SignReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *message; -} wire_ED25519SignReq; - -typedef struct wire_ED25519VerifyReq { - struct wire_uint_8_list *sig; - struct wire_uint_8_list *message; - struct wire_uint_8_list *pub_key; -} wire_ED25519VerifyReq; - -typedef struct wire_Secp256k1FromSeedReq { - struct wire_uint_8_list *seed; -} wire_Secp256k1FromSeedReq; - -typedef struct wire_Secp256k1SignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; -} wire_Secp256k1SignWithSeedReq; - -typedef struct wire_Secp256k1SignWithRngReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *private_bytes; -} wire_Secp256k1SignWithRngReq; - -typedef struct wire_Secp256k1VerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_Secp256k1VerifyReq; - -typedef struct wire_Secp256k1ShareSecretReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *public_key_raw_bytes; -} wire_Secp256k1ShareSecretReq; - -typedef struct wire_Secp256k1RecoverReq { - struct wire_uint_8_list *message_pre_hashed; - struct wire_uint_8_list *signature_bytes; - uint8_t *chain_id; -} wire_Secp256k1RecoverReq; - -typedef struct wire_P256FromSeedReq { - struct wire_uint_8_list *seed; -} wire_P256FromSeedReq; - -typedef struct wire_P256SignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; -} wire_P256SignWithSeedReq; - -typedef struct wire_P256VerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_P256VerifyReq; - -typedef struct wire_P256ShareSecretReq { - struct wire_uint_8_list *seed; - struct wire_uint_8_list *public_key_raw_bytes; -} wire_P256ShareSecretReq; - -typedef struct wire_SchnorrFromSeedReq { - struct wire_uint_8_list *seed; -} wire_SchnorrFromSeedReq; - -typedef struct wire_SchnorrSignWithSeedReq { - struct wire_uint_8_list *msg; - struct wire_uint_8_list *seed; - struct wire_uint_8_list *aux_rand; -} wire_SchnorrSignWithSeedReq; - -typedef struct wire_SchnorrVerifyReq { - struct wire_uint_8_list *message_hash; - struct wire_uint_8_list *signature_bytes; - struct wire_uint_8_list *public_key_bytes; -} wire_SchnorrVerifyReq; - -typedef struct wire_AesEncryptReq { - struct wire_uint_8_list *key; - struct wire_uint_8_list *iv; - struct wire_uint_8_list *message; -} wire_AesEncryptReq; - -typedef struct wire_AesDecryptReq { - struct wire_uint_8_list *key; - struct wire_uint_8_list *iv; - struct wire_uint_8_list *cipher_text; -} wire_AesDecryptReq; - -typedef struct wire_PBKDFDeriveReq { - struct wire_uint_8_list *password; - struct wire_uint_8_list *salt; - uint32_t c; -} wire_PBKDFDeriveReq; - -typedef struct wire_ScriptDeriveReq { - struct wire_uint_8_list *password; - struct wire_uint_8_list *salt; - uint32_t n; - uint32_t p; - uint32_t r; -} wire_ScriptDeriveReq; - -typedef struct wire_ElectrumConfig { - struct wire_uint_8_list *url; - struct wire_uint_8_list *socks5; - uint8_t retry; - uint8_t *timeout; - uint64_t stop_gap; - bool validate_domain; -} wire_ElectrumConfig; - -typedef struct wire_BlockchainConfig_Electrum { - struct wire_ElectrumConfig *config; -} wire_BlockchainConfig_Electrum; - -typedef struct wire_EsploraConfig { - struct wire_uint_8_list *base_url; - struct wire_uint_8_list *proxy; - uint8_t *concurrency; - uint64_t stop_gap; - uint64_t *timeout; -} wire_EsploraConfig; - -typedef struct wire_BlockchainConfig_Esplora { - struct wire_EsploraConfig *config; -} wire_BlockchainConfig_Esplora; - -typedef struct wire_UserPass { - struct wire_uint_8_list *username; - struct wire_uint_8_list *password; -} wire_UserPass; - -typedef struct wire_RpcSyncParams { - uint64_t start_script_count; - uint64_t start_time; - bool force_start_time; - uint64_t poll_rate_sec; -} wire_RpcSyncParams; - -typedef struct wire_RpcConfig { - struct wire_uint_8_list *url; - struct wire_uint_8_list *auth_cookie; - struct wire_UserPass *auth_user_pass; - int32_t network; - struct wire_uint_8_list *wallet_name; - struct wire_RpcSyncParams *sync_params; -} wire_RpcConfig; - -typedef struct wire_BlockchainConfig_Rpc { - struct wire_RpcConfig *config; -} wire_BlockchainConfig_Rpc; - -typedef union BlockchainConfigKind { - struct wire_BlockchainConfig_Electrum *Electrum; - struct wire_BlockchainConfig_Esplora *Esplora; - struct wire_BlockchainConfig_Rpc *Rpc; -} BlockchainConfigKind; - -typedef struct wire_BlockchainConfig { - int32_t tag; - union BlockchainConfigKind *kind; -} wire_BlockchainConfig; - -typedef struct wire_BlockchainInstance { - const void *ptr; -} wire_BlockchainInstance; - -typedef struct wire_WalletInstance { - const void *ptr; -} wire_WalletInstance; - -typedef struct wire_Script { - struct wire_uint_8_list *internal; -} wire_Script; - -typedef struct wire_ScriptAmount { - struct wire_Script script; - uint64_t amount; -} wire_ScriptAmount; - -typedef struct wire_list_script_amount { - struct wire_ScriptAmount *ptr; - int32_t len; -} wire_list_script_amount; - -typedef struct wire_TxBytes { - struct wire_uint_8_list *tx_id; - struct wire_uint_8_list *bytes; -} wire_TxBytes; - -typedef struct wire_list_tx_bytes { - struct wire_TxBytes *ptr; - int32_t len; -} wire_list_tx_bytes; - -typedef struct wire_OutPoint { - struct wire_uint_8_list *txid; - uint32_t vout; -} wire_OutPoint; - -typedef struct wire_list_out_point { - struct wire_OutPoint *ptr; - int32_t len; -} wire_list_out_point; - -typedef struct wire_TxOutForeign { - uint64_t value; - struct wire_uint_8_list *script_pubkey; -} wire_TxOutForeign; - -typedef struct wire_ForeignUtxo { - struct wire_OutPoint outpoint; - struct wire_TxOutForeign txout; -} wire_ForeignUtxo; - -typedef struct wire_list_foreign_utxo { - struct wire_ForeignUtxo *ptr; - int32_t len; -} wire_list_foreign_utxo; - -typedef struct wire_RbfValue_RbfDefault { - -} wire_RbfValue_RbfDefault; - -typedef struct wire_RbfValue_Value { - uint32_t field0; -} wire_RbfValue_Value; - -typedef union RbfValueKind { - struct wire_RbfValue_RbfDefault *RbfDefault; - struct wire_RbfValue_Value *Value; -} RbfValueKind; - -typedef struct wire_RbfValue { - int32_t tag; - union RbfValueKind *kind; -} wire_RbfValue; - -typedef struct wire_BdkDescriptor { - const void *ptr; -} wire_BdkDescriptor; - -typedef struct wire_DatabaseConfig_Memory { - -} wire_DatabaseConfig_Memory; - -typedef struct wire_SqliteDbConfiguration { - struct wire_uint_8_list *path; -} wire_SqliteDbConfiguration; - -typedef struct wire_DatabaseConfig_Sqlite { - struct wire_SqliteDbConfiguration *config; -} wire_DatabaseConfig_Sqlite; - -typedef struct wire_SledDbConfiguration { - struct wire_uint_8_list *path; - struct wire_uint_8_list *tree_name; -} wire_SledDbConfiguration; - -typedef struct wire_DatabaseConfig_Sled { - struct wire_SledDbConfiguration *config; -} wire_DatabaseConfig_Sled; - -typedef union DatabaseConfigKind { - struct wire_DatabaseConfig_Memory *Memory; - struct wire_DatabaseConfig_Sqlite *Sqlite; - struct wire_DatabaseConfig_Sled *Sled; -} DatabaseConfigKind; - -typedef struct wire_DatabaseConfig { - int32_t tag; - union DatabaseConfigKind *kind; -} wire_DatabaseConfig; - -typedef struct wire_AddressIndex_NewIndex { - -} wire_AddressIndex_NewIndex; - -typedef struct wire_AddressIndex_LastUnused { - -} wire_AddressIndex_LastUnused; - -typedef struct wire_AddressIndex_Peek { - uint32_t index; -} wire_AddressIndex_Peek; - -typedef struct wire_AddressIndex_Reset { - uint32_t index; -} wire_AddressIndex_Reset; - -typedef union AddressIndexKind { - struct wire_AddressIndex_NewIndex *NewIndex; - struct wire_AddressIndex_LastUnused *LastUnused; - struct wire_AddressIndex_Peek *Peek; - struct wire_AddressIndex_Reset *Reset; -} AddressIndexKind; - -typedef struct wire_AddressIndex { - int32_t tag; - union AddressIndexKind *kind; -} wire_AddressIndex; - -typedef struct wire_SignOptions { - bool trust_witness_utxo; - uint32_t *assume_height; - bool allow_all_sighashes; - bool remove_partial_sigs; - bool try_finalize; - bool finalize_mine_only; - bool sign_with_tap_internal_key; - bool allow_grinding; -} wire_SignOptions; - -typedef struct DartCObject *WireSyncReturn; - -typedef int64_t Chunk; - -#define BMASK ((1 << BASEBITS) - 1) - -#define HMASK ((1 << HBITS) - 1) - - - -#define TMASK ((1 << TBITS) - 1) - -#define MCONST 140737475470229501 - -void store_dart_post_cobject(DartPostCObjectFnType ptr); - -Dart_Handle get_dart_object(uintptr_t ptr); - -void drop_dart_object(uintptr_t ptr); - -uintptr_t new_dart_opaque(Dart_Handle handle); - -intptr_t init_frb_dart_api_dl(void *obj); - -void wire_mnemonic_phrase_to_seed(int64_t port_, struct wire_PhraseToSeedReq *req); - -void wire_mnemonic_seed_to_key(int64_t port_, struct wire_SeedToKeyReq *req); - -void wire_hex_bytes_to_wif(int64_t port_, struct wire_uint_8_list *hex, int32_t network); - -void wire_bls_init(int64_t port_); - -void wire_bls_verify(int64_t port_, struct wire_BLSVerifyReq *req); - -void wire_ed25519_from_seed(int64_t port_, struct wire_ED25519FromSeedReq *req); - -void wire_ed25519_sign(int64_t port_, struct wire_ED25519SignReq *req); - -void wire_ed25519_verify(int64_t port_, struct wire_ED25519VerifyReq *req); - -void wire_secp256k1_from_seed(int64_t port_, struct wire_Secp256k1FromSeedReq *req); - -void wire_secp256k1_sign(int64_t port_, struct wire_Secp256k1SignWithSeedReq *req); - -void wire_secp256k1_sign_with_rng(int64_t port_, struct wire_Secp256k1SignWithRngReq *req); - -void wire_secp256k1_sign_recoverable(int64_t port_, struct wire_Secp256k1SignWithSeedReq *req); - -void wire_secp256k1_verify(int64_t port_, struct wire_Secp256k1VerifyReq *req); - -void wire_secp256k1_get_shared_secret(int64_t port_, struct wire_Secp256k1ShareSecretReq *req); - -void wire_secp256k1_recover(int64_t port_, struct wire_Secp256k1RecoverReq *req); - -void wire_p256_from_seed(int64_t port_, struct wire_P256FromSeedReq *req); - -void wire_p256_sign(int64_t port_, struct wire_P256SignWithSeedReq *req); - -void wire_p256_verify(int64_t port_, struct wire_P256VerifyReq *req); - -void wire_p256_get_shared_secret(int64_t port_, struct wire_P256ShareSecretReq *req); - -void wire_schnorr_from_seed(int64_t port_, struct wire_SchnorrFromSeedReq *req); - -void wire_schnorr_sign(int64_t port_, struct wire_SchnorrSignWithSeedReq *req); - -void wire_schnorr_verify(int64_t port_, struct wire_SchnorrVerifyReq *req); - -void wire_aes_128_ctr_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_128_ctr_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_aes_256_cbc_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_256_cbc_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_aes_256_gcm_encrypt(int64_t port_, struct wire_AesEncryptReq *req); - -void wire_aes_256_gcm_decrypt(int64_t port_, struct wire_AesDecryptReq *req); - -void wire_pbkdf2_derive_key(int64_t port_, struct wire_PBKDFDeriveReq *req); - -void wire_scrypt_derive_key(int64_t port_, struct wire_ScriptDeriveReq *req); - -void wire_create_blockchain__static_method__Api(int64_t port_, - struct wire_BlockchainConfig *config); - -void wire_get_height__static_method__Api(int64_t port_, struct wire_BlockchainInstance blockchain); - -void wire_get_blockchain_hash__static_method__Api(int64_t port_, - uint32_t blockchain_height, - struct wire_BlockchainInstance blockchain); - -void wire_estimate_fee__static_method__Api(int64_t port_, - uint64_t target, - struct wire_BlockchainInstance blockchain); - -void wire_broadcast__static_method__Api(int64_t port_, - struct wire_uint_8_list *tx, - struct wire_BlockchainInstance blockchain); - -void wire_get_tx__static_method__Api(int64_t port_, - struct wire_uint_8_list *tx, - struct wire_BlockchainInstance blockchain); - -void wire_create_transaction__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_tx_txid__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_weight__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_size__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_vsize__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_serialize_tx__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_coin_base__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_explicitly_rbf__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_is_lock_time_enabled__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_version__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_lock_time__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_input__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_output__static_method__Api(int64_t port_, struct wire_uint_8_list *tx); - -void wire_serialize_psbt__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_txid__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_extract_tx__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_fee_rate__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_psbt_fee_amount__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_combine_psbt__static_method__Api(int64_t port_, - struct wire_uint_8_list *psbt_str, - struct wire_uint_8_list *other); - -void wire_json_serialize__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_get_inputs__static_method__Api(int64_t port_, struct wire_uint_8_list *psbt_str); - -void wire_tx_builder_finish__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_list_script_amount *recipients, - struct wire_list_tx_bytes *txs, - struct wire_list_out_point *unspendable, - struct wire_list_foreign_utxo *foreign_utxos, - int32_t change_policy, - bool manually_selected_only, - float *fee_rate, - uint64_t *fee_absolute, - bool drain_wallet, - struct wire_Script *drain_to, - struct wire_RbfValue *rbf, - struct wire_uint_8_list *data, - bool *shuffle_utxo); - -void wire_tx_cal_fee_finish__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_list_script_amount *recipients, - struct wire_list_tx_bytes *txs, - struct wire_list_out_point *unspendable, - struct wire_list_foreign_utxo *foreign_utxos, - int32_t change_policy, - bool manually_selected_only, - float *fee_rate, - uint64_t *fee_absolute, - bool drain_wallet, - struct wire_Script *drain_to, - struct wire_RbfValue *rbf, - struct wire_uint_8_list *data, - bool *shuffle_utxo); - -void wire_bump_fee_tx_builder_finish__static_method__Api(int64_t port_, - struct wire_uint_8_list *txid, - float fee_rate, - struct wire_uint_8_list *allow_shrinking, - struct wire_WalletInstance wallet, - bool enable_rbf, - bool keep_change, - uint32_t *n_sequence); - -void wire_create_descriptor__static_method__Api(int64_t port_, - struct wire_uint_8_list *descriptor, - int32_t network); - -void wire_import_single_wif__static_method__Api(int64_t port_, - struct wire_uint_8_list *wif, - struct wire_uint_8_list *address_type, - int32_t network); - -void wire_new_bip44_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip44_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip44_tr_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip44_tr_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip49_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip49_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip84_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip84_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_new_bip86_descriptor__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *secret_key, - int32_t network); - -void wire_new_bip86_public__static_method__Api(int64_t port_, - int32_t key_chain_kind, - struct wire_uint_8_list *public_key, - int32_t network, - struct wire_uint_8_list *fingerprint); - -void wire_as_string_private__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor); - -void wire_as_string__static_method__Api(int64_t port_, struct wire_BdkDescriptor descriptor); - -void wire_derive_address_at__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor, - uint32_t index, - int32_t network); - -void wire_create_descriptor_secret__static_method__Api(int64_t port_, - int32_t network, - struct wire_uint_8_list *mnemonic, - struct wire_uint_8_list *password); - -void wire_create_derived_descriptor_secret__static_method__Api(int64_t port_, - int32_t network, - struct wire_uint_8_list *mnemonic, - struct wire_uint_8_list *path, - struct wire_uint_8_list *password); - -void wire_descriptor_secret_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret); - -void wire_extend_descriptor_secret__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *path); - -void wire_derive_descriptor_secret__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *path); - -void wire_as_secret_bytes__static_method__Api(int64_t port_, struct wire_uint_8_list *secret); - -void wire_as_public__static_method__Api(int64_t port_, struct wire_uint_8_list *secret); - -void wire_get_pub_from_secret_bytes__static_method__Api(int64_t port_, - struct wire_uint_8_list *bytes); - -void wire_create_derivation_path__static_method__Api(int64_t port_, struct wire_uint_8_list *path); - -void wire_descriptor_public_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *public_key); - -void wire_master_finterprint__static_method__Api(int64_t port_, struct wire_uint_8_list *xpub); - -void wire_create_descriptor_public__static_method__Api(int64_t port_, - struct wire_uint_8_list *xpub, - struct wire_uint_8_list *path, - bool derive); - -void wire_to_public_string__static_method__Api(int64_t port_, struct wire_uint_8_list *xpub); - -void wire_create_script__static_method__Api(int64_t port_, - struct wire_uint_8_list *raw_output_script); - -void wire_create_address__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_address_from_script__static_method__Api(int64_t port_, - struct wire_Script *script, - int32_t network); - -void wire_address_to_script_pubkey__static_method__Api(int64_t port_, - struct wire_uint_8_list *address); - -void wire_payload__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_address_network__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_get_address_type__static_method__Api(int64_t port_, struct wire_uint_8_list *address); - -void wire_create_wallet__static_method__Api(int64_t port_, - struct wire_BdkDescriptor descriptor, - struct wire_BdkDescriptor *change_descriptor, - int32_t network, - struct wire_DatabaseConfig *database_config); - -void wire_get_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_AddressIndex *address_index); - -void wire_get_internal_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_AddressIndex *address_index); - -void wire_sync_wallet__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_BlockchainInstance blockchain); - -void wire_sync_wallet_thread__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_BlockchainInstance blockchain); - -void wire_get_balance__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_list_unspent_outputs__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet); - -void wire_get_transactions__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - bool include_raw); - -void wire_sign__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - struct wire_uint_8_list *psbt_str, - struct wire_SignOptions *sign_options); - -void wire_wallet_network__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_list_unspent__static_method__Api(int64_t port_, struct wire_WalletInstance wallet); - -void wire_cache_address__static_method__Api(int64_t port_, - struct wire_WalletInstance wallet, - uint32_t cache_size); - -void wire_generate_seed_from_word_count__static_method__Api(int64_t port_, int32_t word_count); - -void wire_generate_seed_from_string__static_method__Api(int64_t port_, - struct wire_uint_8_list *mnemonic); - -void wire_generate_seed_from_entropy__static_method__Api(int64_t port_, - struct wire_uint_8_list *entropy); - -void wire_bip322_sign_segwit__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *message); - -void wire_bip322_sign_taproot__static_method__Api(int64_t port_, - struct wire_uint_8_list *secret, - struct wire_uint_8_list *message); - -struct wire_BdkDescriptor new_BdkDescriptor(void); - -struct wire_BlockchainInstance new_BlockchainInstance(void); - -struct wire_WalletInstance new_WalletInstance(void); - -struct wire_BdkDescriptor *new_box_autoadd_BdkDescriptor_0(void); - -struct wire_AddressIndex *new_box_autoadd_address_index_0(void); - -struct wire_AesDecryptReq *new_box_autoadd_aes_decrypt_req_0(void); - -struct wire_AesEncryptReq *new_box_autoadd_aes_encrypt_req_0(void); - -struct wire_BlockchainConfig *new_box_autoadd_blockchain_config_0(void); - -struct wire_BLSVerifyReq *new_box_autoadd_bls_verify_req_0(void); - -bool *new_box_autoadd_bool_0(bool value); - -struct wire_DatabaseConfig *new_box_autoadd_database_config_0(void); - -struct wire_ED25519FromSeedReq *new_box_autoadd_ed_25519_from_seed_req_0(void); - -struct wire_ED25519SignReq *new_box_autoadd_ed_25519_sign_req_0(void); - -struct wire_ED25519VerifyReq *new_box_autoadd_ed_25519_verify_req_0(void); - -struct wire_ElectrumConfig *new_box_autoadd_electrum_config_0(void); - -struct wire_EsploraConfig *new_box_autoadd_esplora_config_0(void); - -float *new_box_autoadd_f32_0(float value); - -struct wire_P256FromSeedReq *new_box_autoadd_p_256_from_seed_req_0(void); - -struct wire_P256ShareSecretReq *new_box_autoadd_p_256_share_secret_req_0(void); - -struct wire_P256SignWithSeedReq *new_box_autoadd_p_256_sign_with_seed_req_0(void); - -struct wire_P256VerifyReq *new_box_autoadd_p_256_verify_req_0(void); - -struct wire_PBKDFDeriveReq *new_box_autoadd_pbkdf_derive_req_0(void); - -struct wire_PhraseToSeedReq *new_box_autoadd_phrase_to_seed_req_0(void); - -struct wire_RbfValue *new_box_autoadd_rbf_value_0(void); - -struct wire_RpcConfig *new_box_autoadd_rpc_config_0(void); - -struct wire_RpcSyncParams *new_box_autoadd_rpc_sync_params_0(void); - -struct wire_SchnorrFromSeedReq *new_box_autoadd_schnorr_from_seed_req_0(void); - -struct wire_SchnorrSignWithSeedReq *new_box_autoadd_schnorr_sign_with_seed_req_0(void); - -struct wire_SchnorrVerifyReq *new_box_autoadd_schnorr_verify_req_0(void); - -struct wire_Script *new_box_autoadd_script_0(void); - -struct wire_ScriptDeriveReq *new_box_autoadd_script_derive_req_0(void); - -struct wire_Secp256k1FromSeedReq *new_box_autoadd_secp_256_k_1_from_seed_req_0(void); - -struct wire_Secp256k1RecoverReq *new_box_autoadd_secp_256_k_1_recover_req_0(void); - -struct wire_Secp256k1ShareSecretReq *new_box_autoadd_secp_256_k_1_share_secret_req_0(void); - -struct wire_Secp256k1SignWithRngReq *new_box_autoadd_secp_256_k_1_sign_with_rng_req_0(void); - -struct wire_Secp256k1SignWithSeedReq *new_box_autoadd_secp_256_k_1_sign_with_seed_req_0(void); - -struct wire_Secp256k1VerifyReq *new_box_autoadd_secp_256_k_1_verify_req_0(void); - -struct wire_SeedToKeyReq *new_box_autoadd_seed_to_key_req_0(void); - -struct wire_SignOptions *new_box_autoadd_sign_options_0(void); - -struct wire_SledDbConfiguration *new_box_autoadd_sled_db_configuration_0(void); - -struct wire_SqliteDbConfiguration *new_box_autoadd_sqlite_db_configuration_0(void); - -uint32_t *new_box_autoadd_u32_0(uint32_t value); - -uint64_t *new_box_autoadd_u64_0(uint64_t value); - -uint8_t *new_box_autoadd_u8_0(uint8_t value); - -struct wire_UserPass *new_box_autoadd_user_pass_0(void); - -struct wire_list_foreign_utxo *new_list_foreign_utxo_0(int32_t len); - -struct wire_list_out_point *new_list_out_point_0(int32_t len); - -struct wire_list_script_amount *new_list_script_amount_0(int32_t len); - -struct wire_list_tx_bytes *new_list_tx_bytes_0(int32_t len); - -struct wire_uint_8_list *new_uint_8_list_0(int32_t len); - -void drop_opaque_BdkDescriptor(const void *ptr); - -const void *share_opaque_BdkDescriptor(const void *ptr); - -void drop_opaque_BlockchainInstance(const void *ptr); - -const void *share_opaque_BlockchainInstance(const void *ptr); - -void drop_opaque_WalletInstance(const void *ptr); - -const void *share_opaque_WalletInstance(const void *ptr); - -union AddressIndexKind *inflate_AddressIndex_Peek(void); - -union AddressIndexKind *inflate_AddressIndex_Reset(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Electrum(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Esplora(void); - -union BlockchainConfigKind *inflate_BlockchainConfig_Rpc(void); - -union DatabaseConfigKind *inflate_DatabaseConfig_Sqlite(void); - -union DatabaseConfigKind *inflate_DatabaseConfig_Sled(void); - -union RbfValueKind *inflate_RbfValue_Value(void); - -void free_WireSyncReturn(WireSyncReturn ptr); - -static int64_t dummy_method_to_enforce_bundling(void) { - int64_t dummy_var = 0; - dummy_var ^= ((int64_t) (void*) wire_mnemonic_phrase_to_seed); - dummy_var ^= ((int64_t) (void*) wire_mnemonic_seed_to_key); - dummy_var ^= ((int64_t) (void*) wire_hex_bytes_to_wif); - dummy_var ^= ((int64_t) (void*) wire_bls_init); - dummy_var ^= ((int64_t) (void*) wire_bls_verify); - dummy_var ^= ((int64_t) (void*) wire_ed25519_from_seed); - dummy_var ^= ((int64_t) (void*) wire_ed25519_sign); - dummy_var ^= ((int64_t) (void*) wire_ed25519_verify); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_from_seed); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign_with_rng); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_sign_recoverable); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_verify); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_get_shared_secret); - dummy_var ^= ((int64_t) (void*) wire_secp256k1_recover); - dummy_var ^= ((int64_t) (void*) wire_p256_from_seed); - dummy_var ^= ((int64_t) (void*) wire_p256_sign); - dummy_var ^= ((int64_t) (void*) wire_p256_verify); - dummy_var ^= ((int64_t) (void*) wire_p256_get_shared_secret); - dummy_var ^= ((int64_t) (void*) wire_schnorr_from_seed); - dummy_var ^= ((int64_t) (void*) wire_schnorr_sign); - dummy_var ^= ((int64_t) (void*) wire_schnorr_verify); - dummy_var ^= ((int64_t) (void*) wire_aes_128_ctr_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_128_ctr_decrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_cbc_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_cbc_decrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_gcm_encrypt); - dummy_var ^= ((int64_t) (void*) wire_aes_256_gcm_decrypt); - dummy_var ^= ((int64_t) (void*) wire_pbkdf2_derive_key); - dummy_var ^= ((int64_t) (void*) wire_scrypt_derive_key); - dummy_var ^= ((int64_t) (void*) wire_create_blockchain__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_height__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_blockchain_hash__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_estimate_fee__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_broadcast__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_transaction__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_txid__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_weight__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_size__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_vsize__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_serialize_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_coin_base__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_explicitly_rbf__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_is_lock_time_enabled__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_version__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_lock_time__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_input__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_output__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_serialize_psbt__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_txid__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_extract_tx__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_fee_rate__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_psbt_fee_amount__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_combine_psbt__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_json_serialize__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_inputs__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_builder_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_tx_cal_fee_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bump_fee_tx_builder_finish__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_import_single_wif__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_tr_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip44_tr_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip49_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip49_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip84_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip84_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip86_descriptor__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_new_bip86_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_string_private__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_derive_address_at__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_derived_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_descriptor_secret_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_extend_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_derive_descriptor_secret__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_secret_bytes__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_as_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_pub_from_secret_bytes__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_derivation_path__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_descriptor_public_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_master_finterprint__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_descriptor_public__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_to_public_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_script__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_from_script__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_to_script_pubkey__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_payload__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_address_network__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_address_type__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_create_wallet__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_internal_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sync_wallet__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sync_wallet_thread__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_balance__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_list_unspent_outputs__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_get_transactions__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_sign__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_wallet_network__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_list_unspent__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_cache_address__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_word_count__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_string__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_generate_seed_from_entropy__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bip322_sign_segwit__static_method__Api); - dummy_var ^= ((int64_t) (void*) wire_bip322_sign_taproot__static_method__Api); - dummy_var ^= ((int64_t) (void*) new_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) new_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) new_WalletInstance); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_BdkDescriptor_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_address_index_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_aes_decrypt_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_aes_encrypt_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_blockchain_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_bls_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_bool_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_database_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_sign_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_ed_25519_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_electrum_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_esplora_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_f32_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_share_secret_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_p_256_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_pbkdf_derive_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_phrase_to_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rbf_value_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_config_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_rpc_sync_params_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_schnorr_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_script_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_script_derive_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_from_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_recover_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_share_secret_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_sign_with_rng_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_sign_with_seed_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_secp_256_k_1_verify_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_seed_to_key_req_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sign_options_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sled_db_configuration_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_sqlite_db_configuration_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u32_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u64_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_u8_0); - dummy_var ^= ((int64_t) (void*) new_box_autoadd_user_pass_0); - dummy_var ^= ((int64_t) (void*) new_list_foreign_utxo_0); - dummy_var ^= ((int64_t) (void*) new_list_out_point_0); - dummy_var ^= ((int64_t) (void*) new_list_script_amount_0); - dummy_var ^= ((int64_t) (void*) new_list_tx_bytes_0); - dummy_var ^= ((int64_t) (void*) new_uint_8_list_0); - dummy_var ^= ((int64_t) (void*) drop_opaque_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) share_opaque_BdkDescriptor); - dummy_var ^= ((int64_t) (void*) drop_opaque_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) share_opaque_BlockchainInstance); - dummy_var ^= ((int64_t) (void*) drop_opaque_WalletInstance); - dummy_var ^= ((int64_t) (void*) share_opaque_WalletInstance); - dummy_var ^= ((int64_t) (void*) inflate_AddressIndex_Peek); - dummy_var ^= ((int64_t) (void*) inflate_AddressIndex_Reset); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Electrum); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Esplora); - dummy_var ^= ((int64_t) (void*) inflate_BlockchainConfig_Rpc); - dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sqlite); - dummy_var ^= ((int64_t) (void*) inflate_DatabaseConfig_Sled); - dummy_var ^= ((int64_t) (void*) inflate_RbfValue_Value); - dummy_var ^= ((int64_t) (void*) free_WireSyncReturn); - dummy_var ^= ((int64_t) (void*) store_dart_post_cobject); - dummy_var ^= ((int64_t) (void*) get_dart_object); - dummy_var ^= ((int64_t) (void*) drop_dart_object); - dummy_var ^= ((int64_t) (void*) new_dart_opaque); - return dummy_var; -} diff --git a/packages/agent_dart/macos/Classes/dummy_file.c b/packages/agent_dart/macos/Classes/dummy_file.c new file mode 100644 index 00000000..e06dab99 --- /dev/null +++ b/packages/agent_dart/macos/Classes/dummy_file.c @@ -0,0 +1 @@ +// This is an empty file to force CocoaPods to create a framework. diff --git a/packages/agent_dart/macos/Frameworks/.gitkeep b/packages/agent_dart/macos/Frameworks/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/packages/agent_dart/macos/agent_dart.podspec b/packages/agent_dart/macos/agent_dart.podspec index 8b9c4674..5ab3d9f9 100644 --- a/packages/agent_dart/macos/agent_dart.podspec +++ b/packages/agent_dart/macos/agent_dart.podspec @@ -1,38 +1,44 @@ -release_tag_name = 'agent_dart-v0.0.0' # generated; do not edit - -# We cannot distribute the XCFramework alongside the library directly, -# so we have to fetch the correct version here. -framework_name = 'AgentDart.xcframework' -remote_zip_name = "#{framework_name}.zip" -url = "https://github.com/AstroxNetwork/agent_dart/releases/download/#{release_tag_name}/#{remote_zip_name}" -local_zip_name = "#{release_tag_name}.zip" -` -cd Frameworks -rm -rf #{framework_name} - -if [ ! -f #{local_zip_name} ] -then - curl -L #{url} -o #{local_zip_name} -fi - -unzip #{local_zip_name} -cd - -` +# +# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html. +# Run `pod lib lint agent_dart.podspec` to validate before publishing. +# +Pod::Spec.new do |spec| + s.name = 'agent_dart' + s.version = '1.0.0' + s.license = { :file => '../LICENSE' } + s.homepage = 'https://github.com/AstroxNetwork/agent_dart' + s.authors = { 'AstroX Dev' => 'dev@astrox.network' } + s.summary = 'iOS/macOS Flutter bindings for agent_dart' + # This will ensure the source files in Classes/ are included in the native + # builds of apps using this FFI plugin. Podspec does not support relative + # paths, so Classes contains a forwarder C file that relatively imports + # `../src/*` so that the C sources can be shared among all target platforms. + s.source = { :path => '.' } + s.source_files = 'Classes/**/*' -Pod::Spec.new do |spec| - spec.name = 'agent_dart' - spec.version = '0.0.1' - spec.license = { :file => '../LICENSE' } - spec.homepage = 'https://github.com/AstroxNetwork/agent_dart' - spec.authors = { 'AstroX Dev' => 'dev@astrox.network' } - spec.summary = 'iOS/macOS Flutter bindings for agent_dart' + s.dependency 'FlutterMacOS' + s.platform = :osx, '10.11' + s.pod_target_xcconfig = { 'DEFINES_MODULE' => 'YES' } + s.swift_version = '5.0' - spec.source = { :path => '.' } - spec.source_files = 'Classes/**/*' - spec.public_header_files = 'Classes/**/*.h' - spec.vendored_frameworks = "Frameworks/#{framework_name}" + s.ios.deployment_target = '11.0' + s.osx.deployment_target = '10.11' - spec.ios.deployment_target = '11.0' - spec.osx.deployment_target = '10.11' -end \ No newline at end of file + s.script_phase = { + :name => 'Build Rust library', + # First argument is relative path to the `rust` folder, second is name of rust library + :script => 'sh "$PODS_TARGET_SRCROOT/../cargokit/build_pod.sh" ../../agent_dart_ffi/native/agent_dart agent_dart', + :execution_position => :before_compile, + :input_files => ['${BUILT_PRODUCTS_DIR}/cargokit_phony'], + # Let XCode know that the static library referenced in -force_load below is + # created by this build step. + :output_files => ["${BUILT_PRODUCTS_DIR}/libagent_dart.a"], + } + s.pod_target_xcconfig = { + 'DEFINES_MODULE' => 'YES', + # Flutter.framework does not contain a i386 slice. + 'EXCLUDED_ARCHS[sdk=iphonesimulator*]' => 'i386', + 'OTHER_LDFLAGS' => '-force_load ${BUILT_PRODUCTS_DIR}/libagent_dart.a', + } +end diff --git a/packages/agent_dart/pubspec.yaml b/packages/agent_dart/pubspec.yaml index 98d48b38..4a4b1bcc 100644 --- a/packages/agent_dart/pubspec.yaml +++ b/packages/agent_dart/pubspec.yaml @@ -7,8 +7,8 @@ issue_tracker: https://github.com/AstroxNetwork/agent_dart/issues publish_to: none environment: - sdk: ^3.3.0 - flutter: '>=3.19.0' + sdk: '>=3.4.0 <4.0.0' + flutter: '>=3.22.0' dependencies: flutter: diff --git a/packages/agent_dart/windows/CMakeLists.txt b/packages/agent_dart/windows/CMakeLists.txt index cdf591e0..43209a76 100644 --- a/packages/agent_dart/windows/CMakeLists.txt +++ b/packages/agent_dart/windows/CMakeLists.txt @@ -1,9 +1,3 @@ -set(LibraryVersion "agent_dart-v0.0.0") # generated; do not edit - -# TODO Remove this workaround once Flutter supports Windows ARM. -# https://github.com/flutter/flutter/issues/116196 -set(FLUTTER_TARGET_PLATFORM windows-x64) - # The Flutter tooling requires that developers have a version of Visual Studio # installed that includes CMake 3.14 or later. You should not increase this # version, as doing so will cause the plugin to fail to compile for some @@ -11,33 +5,16 @@ set(FLUTTER_TARGET_PLATFORM windows-x64) cmake_minimum_required(VERSION 3.14) # Project-level configuration. -set(PROJECT_NAME "agent_dart") # Should match the name field in the pubspec.yaml. +set(PROJECT_NAME "agent_dart") project(${PROJECT_NAME} LANGUAGES CXX) -# Download the binaries if they are not already present. -set(LibRoot "${CMAKE_CURRENT_SOURCE_DIR}/${LibraryVersion}") -set(ArchivePath "${LibRoot}.tar.gz") -if(NOT EXISTS ${ArchivePath}) - file(DOWNLOAD - "https://github.com/AstroxNetwork/agent_dart/releases/download/${LibraryVersion}/other.tar.gz" - ${ArchivePath} - TLS_VERIFY ON - ) -endif() - -# Extract the binaries, overriding any already present. -file(REMOVE_RECURSE "windows-arm64") -file(REMOVE_RECURSE "windows-x64") -execute_process( - COMMAND ${CMAKE_COMMAND} -E tar xzf ${ArchivePath} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} -) +include("../cargokit/cmake/cargokit.cmake") +apply_cargokit(${PROJECT_NAME} ../../agent_dart_ffi/native/agent_dart agent_dart "") -set(LIBRARY_NAME "agent_dart") # Should match the library name you used to generate. # List of absolute paths to libraries that should be bundled with the plugin. # This list could contain prebuilt libraries, or libraries created by an # external build triggered from this build file. -set(${PROJECT_NAME}_bundled_libraries - "${CMAKE_CURRENT_SOURCE_DIR}/${FLUTTER_TARGET_PLATFORM}/${LIBRARY_NAME}.dll" +set(agent_dart_bundled_libraries + "${${PROJECT_NAME}_cargokit_lib}" PARENT_SCOPE ) diff --git a/packages/agent_dart_base/analysis_options.yaml b/packages/agent_dart_base/analysis_options.yaml new file mode 100644 index 00000000..8f10768f --- /dev/null +++ b/packages/agent_dart_base/analysis_options.yaml @@ -0,0 +1,10 @@ +include: ../../analysis_options.yaml + +analyzer: + exclude: + - lib/**.freezed.dart + - lib/**.g.dart + +linter: + rules: + constant_identifier_names: false diff --git a/packages/agent_dart_base/lib/agent/actor.dart b/packages/agent_dart_base/lib/agent/actor.dart index 9d8358ab..ba5536ce 100644 --- a/packages/agent_dart_base/lib/agent/actor.dart +++ b/packages/agent_dart_base/lib/agent/actor.dart @@ -22,7 +22,9 @@ class ActorCallError extends AgentFetchError { 'Call failed:', ' Canister: ${canisterId.toText()}', ' Method: $methodName ($type)', - ...props.entries.map((n) => " '${n.key}': ${jsonEncode(props[n])}"), + ...props.entries.map( + (n) => " '${n.key}': ${jsonEncode(props[n.value])}", + ), ].join('\n'); throw e; } diff --git a/packages/agent_dart_base/lib/agent/agent.dart b/packages/agent_dart_base/lib/agent/agent.dart index 38d79cc0..45405cbe 100644 --- a/packages/agent_dart_base/lib/agent/agent.dart +++ b/packages/agent_dart_base/lib/agent/agent.dart @@ -1,4 +1,5 @@ -/// Sub folders +// Sub folders + export './agent/index.dart'; export './canisters/index.dart'; export './crypto/index.dart'; diff --git a/packages/agent_dart_base/lib/agent/agent/api.dart b/packages/agent_dart_base/lib/agent/agent/api.dart index 39880185..63d1e642 100644 --- a/packages/agent_dart_base/lib/agent/agent/api.dart +++ b/packages/agent_dart_base/lib/agent/agent/api.dart @@ -169,8 +169,8 @@ abstract class Agent { /// endpoint. Future status(); - /// Send a query call to a canister. See - /// {@link https://sdk.dfinity.org/docs/interface-spec/#http-query | the interface spec}. + /// Send a query call to a canister. See the interface spec + /// https://sdk.dfinity.org/docs/interface-spec/#http-query. /// @param canisterId The Principal of the Canister to send the query to. Sending a query to /// the management canister is not supported (as it has no meaning from an agent). /// @param options Options to use to create and send the query. diff --git a/packages/agent_dart_base/lib/agent/agent/http/index.dart b/packages/agent_dart_base/lib/agent/agent/http/index.dart index d78f663e..00d6e4ac 100644 --- a/packages/agent_dart_base/lib/agent/agent/http/index.dart +++ b/packages/agent_dart_base/lib/agent/agent/http/index.dart @@ -274,7 +274,7 @@ class HttpAgent implements Agent { throw AgentFetchError( statusCode: response['statusCode'], statusText: response['statusText'], - body: response[body], + body: response['body'], ); } @@ -345,7 +345,7 @@ class HttpAgent implements Agent { throw AgentFetchError( statusCode: response['statusCode'], statusText: response['statusText'], - body: response[body], + body: response['body'], ); } @@ -399,7 +399,7 @@ class HttpAgent implements Agent { throw AgentFetchError( statusCode: response['statusCode'], statusText: response['statusText'], - body: response[body], + body: response['body'], ); } diff --git a/packages/agent_dart_base/lib/agent/agent/http/types.dart b/packages/agent_dart_base/lib/agent/agent/http/types.dart index 82af3c9d..0c2ef37c 100644 --- a/packages/agent_dart_base/lib/agent/agent/http/types.dart +++ b/packages/agent_dart_base/lib/agent/agent/http/types.dart @@ -209,12 +209,12 @@ typedef HttpAgentRequestTransformFnCall = Future Function( class HttpResponseBody extends ResponseBody { const HttpResponseBody({ - bool? ok, - int? status, - String? statusText, + super.ok, + super.status, + super.statusText, this.body, this.arrayBuffer, - }) : super(ok: ok, status: status, statusText: statusText); + }); factory HttpResponseBody.fromJson(Map map) { return HttpResponseBody( diff --git a/packages/agent_dart_base/lib/agent/crypto/keystore/util.dart b/packages/agent_dart_base/lib/agent/crypto/keystore/util.dart index 51f6e466..95d07f2b 100644 --- a/packages/agent_dart_base/lib/agent/crypto/keystore/util.dart +++ b/packages/agent_dart_base/lib/agent/crypto/keystore/util.dart @@ -23,7 +23,7 @@ Future _encryptPhraseAsync({ required Uint8List iv, required String message, }) { - return AgentDartFFI.impl.aes128CtrEncrypt( + return aes128CtrEncrypt( req: AesEncryptReq(key: key, iv: iv, message: message.plainToU8a()), ); } @@ -33,7 +33,7 @@ Future _encryptPhraseAsync256({ required Uint8List iv, required String message, }) { - return AgentDartFFI.impl.aes256GcmEncrypt( + return aes256GcmEncrypt( req: AesEncryptReq(key: key, iv: iv, message: message.plainToU8a()), ); } @@ -43,7 +43,7 @@ Future _decryptPhraseAsync({ required Uint8List iv, required Uint8List cipherText, }) { - return AgentDartFFI.impl.aes128CtrDecrypt( + return aes128CtrDecrypt( req: AesDecryptReq(key: key, iv: iv, cipherText: cipherText), ); } @@ -53,7 +53,7 @@ Future _decryptPhraseAsync256({ required Uint8List iv, required Uint8List cipherText, }) { - return AgentDartFFI.impl.aes256GcmDecrypt( + return aes256GcmDecrypt( req: AesDecryptReq(key: key, iv: iv, cipherText: cipherText), ); } @@ -73,7 +73,7 @@ Future nativeDeriveKey({ final Uint8List rightBits; if (kdf == 'scrypt') { - final scryptKey = await AgentDartFFI.impl.scryptDeriveKey( + final scryptKey = await scryptDeriveKey( req: ScriptDeriveReq( n: kdfParams['n'], p: kdfParams['p'], @@ -89,7 +89,7 @@ Future nativeDeriveKey({ [...scryptKey.leftBits, ...scryptKey.rightBits], ); } else { - final scryptKey = await AgentDartFFI.impl.pbkdf2DeriveKey( + final scryptKey = await pbkdf2DeriveKey( req: PBKDFDeriveReq( c: 262144, password: passphrase.plainToU8a(), diff --git a/packages/agent_dart_base/lib/agent/ord/addressStats.freezed.dart b/packages/agent_dart_base/lib/agent/ord/addressStats.freezed.dart deleted file mode 100644 index f50ddec8..00000000 --- a/packages/agent_dart_base/lib/agent/ord/addressStats.freezed.dart +++ /dev/null @@ -1,429 +0,0 @@ -// coverage:ignore-file -// GENERATED CODE - DO NOT MODIFY BY HAND -// ignore_for_file: type=lint -// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark - -part of 'addressStats.dart'; - -// ************************************************************************** -// FreezedGenerator -// ************************************************************************** - -T _$identity(T value) => value; - -final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); - -AddressStats _$AddressStatsFromJson(Map json) { - return _AddressStats.fromJson(json); -} - -/// @nodoc -mixin _$AddressStats { - String get address => throw _privateConstructorUsedError; - set address(String value) => throw _privateConstructorUsedError; - StatsItem get chain_stats => throw _privateConstructorUsedError; - set chain_stats(StatsItem value) => throw _privateConstructorUsedError; - StatsItem get mempool_stats => throw _privateConstructorUsedError; - set mempool_stats(StatsItem value) => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $AddressStatsCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $AddressStatsCopyWith<$Res> { - factory $AddressStatsCopyWith( - AddressStats value, $Res Function(AddressStats) then) = - _$AddressStatsCopyWithImpl<$Res, AddressStats>; - @useResult - $Res call({String address, StatsItem chain_stats, StatsItem mempool_stats}); - - $StatsItemCopyWith<$Res> get chain_stats; - $StatsItemCopyWith<$Res> get mempool_stats; -} - -/// @nodoc -class _$AddressStatsCopyWithImpl<$Res, $Val extends AddressStats> - implements $AddressStatsCopyWith<$Res> { - _$AddressStatsCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? address = null, - Object? chain_stats = null, - Object? mempool_stats = null, - }) { - return _then(_value.copyWith( - address: null == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String, - chain_stats: null == chain_stats - ? _value.chain_stats - : chain_stats // ignore: cast_nullable_to_non_nullable - as StatsItem, - mempool_stats: null == mempool_stats - ? _value.mempool_stats - : mempool_stats // ignore: cast_nullable_to_non_nullable - as StatsItem, - ) as $Val); - } - - @override - @pragma('vm:prefer-inline') - $StatsItemCopyWith<$Res> get chain_stats { - return $StatsItemCopyWith<$Res>(_value.chain_stats, (value) { - return _then(_value.copyWith(chain_stats: value) as $Val); - }); - } - - @override - @pragma('vm:prefer-inline') - $StatsItemCopyWith<$Res> get mempool_stats { - return $StatsItemCopyWith<$Res>(_value.mempool_stats, (value) { - return _then(_value.copyWith(mempool_stats: value) as $Val); - }); - } -} - -/// @nodoc -abstract class _$$_AddressStatsCopyWith<$Res> - implements $AddressStatsCopyWith<$Res> { - factory _$$_AddressStatsCopyWith( - _$_AddressStats value, $Res Function(_$_AddressStats) then) = - __$$_AddressStatsCopyWithImpl<$Res>; - @override - @useResult - $Res call({String address, StatsItem chain_stats, StatsItem mempool_stats}); - - @override - $StatsItemCopyWith<$Res> get chain_stats; - @override - $StatsItemCopyWith<$Res> get mempool_stats; -} - -/// @nodoc -class __$$_AddressStatsCopyWithImpl<$Res> - extends _$AddressStatsCopyWithImpl<$Res, _$_AddressStats> - implements _$$_AddressStatsCopyWith<$Res> { - __$$_AddressStatsCopyWithImpl( - _$_AddressStats _value, $Res Function(_$_AddressStats) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? address = null, - Object? chain_stats = null, - Object? mempool_stats = null, - }) { - return _then(_$_AddressStats( - address: null == address - ? _value.address - : address // ignore: cast_nullable_to_non_nullable - as String, - chain_stats: null == chain_stats - ? _value.chain_stats - : chain_stats // ignore: cast_nullable_to_non_nullable - as StatsItem, - mempool_stats: null == mempool_stats - ? _value.mempool_stats - : mempool_stats // ignore: cast_nullable_to_non_nullable - as StatsItem, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$_AddressStats implements _AddressStats { - _$_AddressStats( - {required this.address, - required this.chain_stats, - required this.mempool_stats}); - - factory _$_AddressStats.fromJson(Map json) => - _$$_AddressStatsFromJson(json); - - @override - String address; - @override - StatsItem chain_stats; - @override - StatsItem mempool_stats; - - @override - String toString() { - return 'AddressStats(address: $address, chain_stats: $chain_stats, mempool_stats: $mempool_stats)'; - } - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$_AddressStatsCopyWith<_$_AddressStats> get copyWith => - __$$_AddressStatsCopyWithImpl<_$_AddressStats>(this, _$identity); - - @override - Map toJson() { - return _$$_AddressStatsToJson( - this, - ); - } -} - -abstract class _AddressStats implements AddressStats { - factory _AddressStats( - {required String address, - required StatsItem chain_stats, - required StatsItem mempool_stats}) = _$_AddressStats; - - factory _AddressStats.fromJson(Map json) = - _$_AddressStats.fromJson; - - @override - String get address; - set address(String value); - @override - StatsItem get chain_stats; - set chain_stats(StatsItem value); - @override - StatsItem get mempool_stats; - set mempool_stats(StatsItem value); - @override - @JsonKey(ignore: true) - _$$_AddressStatsCopyWith<_$_AddressStats> get copyWith => - throw _privateConstructorUsedError; -} - -StatsItem _$StatsItemFromJson(Map json) { - return _StatsItem.fromJson(json); -} - -/// @nodoc -mixin _$StatsItem { - int get funded_txo_count => throw _privateConstructorUsedError; - int get funded_txo_sum => throw _privateConstructorUsedError; - int get spent_txo_count => throw _privateConstructorUsedError; - int get spent_txo_sum => throw _privateConstructorUsedError; - int get tx_count => throw _privateConstructorUsedError; - - Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) - $StatsItemCopyWith get copyWith => - throw _privateConstructorUsedError; -} - -/// @nodoc -abstract class $StatsItemCopyWith<$Res> { - factory $StatsItemCopyWith(StatsItem value, $Res Function(StatsItem) then) = - _$StatsItemCopyWithImpl<$Res, StatsItem>; - @useResult - $Res call( - {int funded_txo_count, - int funded_txo_sum, - int spent_txo_count, - int spent_txo_sum, - int tx_count}); -} - -/// @nodoc -class _$StatsItemCopyWithImpl<$Res, $Val extends StatsItem> - implements $StatsItemCopyWith<$Res> { - _$StatsItemCopyWithImpl(this._value, this._then); - - // ignore: unused_field - final $Val _value; - // ignore: unused_field - final $Res Function($Val) _then; - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? funded_txo_count = null, - Object? funded_txo_sum = null, - Object? spent_txo_count = null, - Object? spent_txo_sum = null, - Object? tx_count = null, - }) { - return _then(_value.copyWith( - funded_txo_count: null == funded_txo_count - ? _value.funded_txo_count - : funded_txo_count // ignore: cast_nullable_to_non_nullable - as int, - funded_txo_sum: null == funded_txo_sum - ? _value.funded_txo_sum - : funded_txo_sum // ignore: cast_nullable_to_non_nullable - as int, - spent_txo_count: null == spent_txo_count - ? _value.spent_txo_count - : spent_txo_count // ignore: cast_nullable_to_non_nullable - as int, - spent_txo_sum: null == spent_txo_sum - ? _value.spent_txo_sum - : spent_txo_sum // ignore: cast_nullable_to_non_nullable - as int, - tx_count: null == tx_count - ? _value.tx_count - : tx_count // ignore: cast_nullable_to_non_nullable - as int, - ) as $Val); - } -} - -/// @nodoc -abstract class _$$_StatsItemCopyWith<$Res> implements $StatsItemCopyWith<$Res> { - factory _$$_StatsItemCopyWith( - _$_StatsItem value, $Res Function(_$_StatsItem) then) = - __$$_StatsItemCopyWithImpl<$Res>; - @override - @useResult - $Res call( - {int funded_txo_count, - int funded_txo_sum, - int spent_txo_count, - int spent_txo_sum, - int tx_count}); -} - -/// @nodoc -class __$$_StatsItemCopyWithImpl<$Res> - extends _$StatsItemCopyWithImpl<$Res, _$_StatsItem> - implements _$$_StatsItemCopyWith<$Res> { - __$$_StatsItemCopyWithImpl( - _$_StatsItem _value, $Res Function(_$_StatsItem) _then) - : super(_value, _then); - - @pragma('vm:prefer-inline') - @override - $Res call({ - Object? funded_txo_count = null, - Object? funded_txo_sum = null, - Object? spent_txo_count = null, - Object? spent_txo_sum = null, - Object? tx_count = null, - }) { - return _then(_$_StatsItem( - funded_txo_count: null == funded_txo_count - ? _value.funded_txo_count - : funded_txo_count // ignore: cast_nullable_to_non_nullable - as int, - funded_txo_sum: null == funded_txo_sum - ? _value.funded_txo_sum - : funded_txo_sum // ignore: cast_nullable_to_non_nullable - as int, - spent_txo_count: null == spent_txo_count - ? _value.spent_txo_count - : spent_txo_count // ignore: cast_nullable_to_non_nullable - as int, - spent_txo_sum: null == spent_txo_sum - ? _value.spent_txo_sum - : spent_txo_sum // ignore: cast_nullable_to_non_nullable - as int, - tx_count: null == tx_count - ? _value.tx_count - : tx_count // ignore: cast_nullable_to_non_nullable - as int, - )); - } -} - -/// @nodoc -@JsonSerializable() -class _$_StatsItem implements _StatsItem { - _$_StatsItem( - {required this.funded_txo_count, - required this.funded_txo_sum, - required this.spent_txo_count, - required this.spent_txo_sum, - required this.tx_count}); - - factory _$_StatsItem.fromJson(Map json) => - _$$_StatsItemFromJson(json); - - @override - final int funded_txo_count; - @override - final int funded_txo_sum; - @override - final int spent_txo_count; - @override - final int spent_txo_sum; - @override - final int tx_count; - - @override - String toString() { - return 'StatsItem(funded_txo_count: $funded_txo_count, funded_txo_sum: $funded_txo_sum, spent_txo_count: $spent_txo_count, spent_txo_sum: $spent_txo_sum, tx_count: $tx_count)'; - } - - @override - bool operator ==(dynamic other) { - return identical(this, other) || - (other.runtimeType == runtimeType && - other is _$_StatsItem && - (identical(other.funded_txo_count, funded_txo_count) || - other.funded_txo_count == funded_txo_count) && - (identical(other.funded_txo_sum, funded_txo_sum) || - other.funded_txo_sum == funded_txo_sum) && - (identical(other.spent_txo_count, spent_txo_count) || - other.spent_txo_count == spent_txo_count) && - (identical(other.spent_txo_sum, spent_txo_sum) || - other.spent_txo_sum == spent_txo_sum) && - (identical(other.tx_count, tx_count) || - other.tx_count == tx_count)); - } - - @JsonKey(ignore: true) - @override - int get hashCode => Object.hash(runtimeType, funded_txo_count, funded_txo_sum, - spent_txo_count, spent_txo_sum, tx_count); - - @JsonKey(ignore: true) - @override - @pragma('vm:prefer-inline') - _$$_StatsItemCopyWith<_$_StatsItem> get copyWith => - __$$_StatsItemCopyWithImpl<_$_StatsItem>(this, _$identity); - - @override - Map toJson() { - return _$$_StatsItemToJson( - this, - ); - } -} - -abstract class _StatsItem implements StatsItem { - factory _StatsItem( - {required final int funded_txo_count, - required final int funded_txo_sum, - required final int spent_txo_count, - required final int spent_txo_sum, - required final int tx_count}) = _$_StatsItem; - - factory _StatsItem.fromJson(Map json) = - _$_StatsItem.fromJson; - - @override - int get funded_txo_count; - @override - int get funded_txo_sum; - @override - int get spent_txo_count; - @override - int get spent_txo_sum; - @override - int get tx_count; - @override - @JsonKey(ignore: true) - _$$_StatsItemCopyWith<_$_StatsItem> get copyWith => - throw _privateConstructorUsedError; -} diff --git a/packages/agent_dart_base/lib/agent/ord/addressStats.g.dart b/packages/agent_dart_base/lib/agent/ord/addressStats.g.dart deleted file mode 100644 index 503641a6..00000000 --- a/packages/agent_dart_base/lib/agent/ord/addressStats.g.dart +++ /dev/null @@ -1,40 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'addressStats.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$_AddressStats _$$_AddressStatsFromJson(Map json) => - _$_AddressStats( - address: json['address'] as String, - chain_stats: - StatsItem.fromJson(json['chain_stats'] as Map), - mempool_stats: - StatsItem.fromJson(json['mempool_stats'] as Map), - ); - -Map _$$_AddressStatsToJson(_$_AddressStats instance) => - { - 'address': instance.address, - 'chain_stats': instance.chain_stats, - 'mempool_stats': instance.mempool_stats, - }; - -_$_StatsItem _$$_StatsItemFromJson(Map json) => _$_StatsItem( - funded_txo_count: json['funded_txo_count'] as int, - funded_txo_sum: json['funded_txo_sum'] as int, - spent_txo_count: json['spent_txo_count'] as int, - spent_txo_sum: json['spent_txo_sum'] as int, - tx_count: json['tx_count'] as int, - ); - -Map _$$_StatsItemToJson(_$_StatsItem instance) => - { - 'funded_txo_count': instance.funded_txo_count, - 'funded_txo_sum': instance.funded_txo_sum, - 'spent_txo_count': instance.spent_txo_count, - 'spent_txo_sum': instance.spent_txo_sum, - 'tx_count': instance.tx_count, - }; diff --git a/packages/agent_dart_base/lib/agent/ord/addressUtxo.g.dart b/packages/agent_dart_base/lib/agent/ord/addressUtxo.g.dart deleted file mode 100644 index 4ca2a8d6..00000000 --- a/packages/agent_dart_base/lib/agent/ord/addressUtxo.g.dart +++ /dev/null @@ -1,38 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'addressUtxo.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$_AddressUtxo _$$_AddressUtxoFromJson(Map json) => - _$_AddressUtxo( - txid: json['txid'] as String, - vout: json['vout'] as int, - value: json['value'] as int, - status: TxStatus.fromJson(json['status'] as Map), - ); - -Map _$$_AddressUtxoToJson(_$_AddressUtxo instance) => - { - 'txid': instance.txid, - 'vout': instance.vout, - 'value': instance.value, - 'status': instance.status, - }; - -_$_TxStatus _$$_TxStatusFromJson(Map json) => _$_TxStatus( - confirmed: json['confirmed'] as bool, - block_height: json['block_height'] as int?, - block_hash: json['block_hash'] as String?, - block_time: json['block_time'] as int?, - ); - -Map _$$_TxStatusToJson(_$_TxStatus instance) => - { - 'confirmed': instance.confirmed, - 'block_height': instance.block_height, - 'block_hash': instance.block_hash, - 'block_time': instance.block_time, - }; diff --git a/packages/agent_dart_base/lib/agent/ord/addressStats.dart b/packages/agent_dart_base/lib/agent/ord/address_stats.dart similarity index 57% rename from packages/agent_dart_base/lib/agent/ord/addressStats.dart rename to packages/agent_dart_base/lib/agent/ord/address_stats.dart index 138cb1d0..246e8415 100644 --- a/packages/agent_dart_base/lib/agent/ord/addressStats.dart +++ b/packages/agent_dart_base/lib/agent/ord/address_stats.dart @@ -18,15 +18,15 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -part 'addressStats.freezed.dart'; -part 'addressStats.g.dart'; +part 'address_stats.freezed.dart'; +part 'address_stats.g.dart'; -@unfreezed +@freezed class AddressStats with _$AddressStats { - factory AddressStats({ + const factory AddressStats({ required String address, - required StatsItem chain_stats, - required StatsItem mempool_stats, + @JsonKey(name: 'chain_stats') required StatsItem chainStats, + @JsonKey(name: 'mempool_stats') required StatsItem mempoolStats, }) = _AddressStats; factory AddressStats.fromJson(Map json) => @@ -35,12 +35,12 @@ class AddressStats with _$AddressStats { @freezed class StatsItem with _$StatsItem { - factory StatsItem({ - required int funded_txo_count, - required int funded_txo_sum, - required int spent_txo_count, - required int spent_txo_sum, - required int tx_count, + const factory StatsItem({ + @JsonKey(name: 'funded_utxo_count') required int fundedUtxoCount, + @JsonKey(name: 'funded_utxo_sum') required int fundedUtxoSum, + @JsonKey(name: 'spent_utxo_count') required int spentUtxoCount, + @JsonKey(name: 'spent_utxo_sum') required int spentUtxoSum, + @JsonKey(name: 'tx_count') required int txCount, }) = _StatsItem; factory StatsItem.fromJson(Map json) => diff --git a/packages/agent_dart_base/lib/agent/ord/address_stats.freezed.dart b/packages/agent_dart_base/lib/agent/ord/address_stats.freezed.dart new file mode 100644 index 00000000..c78d0b06 --- /dev/null +++ b/packages/agent_dart_base/lib/agent/ord/address_stats.freezed.dart @@ -0,0 +1,468 @@ +// coverage:ignore-file +// GENERATED CODE - DO NOT MODIFY BY HAND +// ignore_for_file: type=lint +// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark + +part of 'address_stats.dart'; + +// ************************************************************************** +// FreezedGenerator +// ************************************************************************** + +T _$identity(T value) => value; + +final _privateConstructorUsedError = UnsupportedError( + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); + +AddressStats _$AddressStatsFromJson(Map json) { + return _AddressStats.fromJson(json); +} + +/// @nodoc +mixin _$AddressStats { + String get address => throw _privateConstructorUsedError; + @JsonKey(name: 'chain_stats') + StatsItem get chainStats => throw _privateConstructorUsedError; + @JsonKey(name: 'mempool_stats') + StatsItem get mempoolStats => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $AddressStatsCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $AddressStatsCopyWith<$Res> { + factory $AddressStatsCopyWith( + AddressStats value, $Res Function(AddressStats) then) = + _$AddressStatsCopyWithImpl<$Res, AddressStats>; + @useResult + $Res call( + {String address, + @JsonKey(name: 'chain_stats') StatsItem chainStats, + @JsonKey(name: 'mempool_stats') StatsItem mempoolStats}); + + $StatsItemCopyWith<$Res> get chainStats; + $StatsItemCopyWith<$Res> get mempoolStats; +} + +/// @nodoc +class _$AddressStatsCopyWithImpl<$Res, $Val extends AddressStats> + implements $AddressStatsCopyWith<$Res> { + _$AddressStatsCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? address = null, + Object? chainStats = null, + Object? mempoolStats = null, + }) { + return _then(_value.copyWith( + address: null == address + ? _value.address + : address // ignore: cast_nullable_to_non_nullable + as String, + chainStats: null == chainStats + ? _value.chainStats + : chainStats // ignore: cast_nullable_to_non_nullable + as StatsItem, + mempoolStats: null == mempoolStats + ? _value.mempoolStats + : mempoolStats // ignore: cast_nullable_to_non_nullable + as StatsItem, + ) as $Val); + } + + @override + @pragma('vm:prefer-inline') + $StatsItemCopyWith<$Res> get chainStats { + return $StatsItemCopyWith<$Res>(_value.chainStats, (value) { + return _then(_value.copyWith(chainStats: value) as $Val); + }); + } + + @override + @pragma('vm:prefer-inline') + $StatsItemCopyWith<$Res> get mempoolStats { + return $StatsItemCopyWith<$Res>(_value.mempoolStats, (value) { + return _then(_value.copyWith(mempoolStats: value) as $Val); + }); + } +} + +/// @nodoc +abstract class _$$AddressStatsImplCopyWith<$Res> + implements $AddressStatsCopyWith<$Res> { + factory _$$AddressStatsImplCopyWith( + _$AddressStatsImpl value, $Res Function(_$AddressStatsImpl) then) = + __$$AddressStatsImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {String address, + @JsonKey(name: 'chain_stats') StatsItem chainStats, + @JsonKey(name: 'mempool_stats') StatsItem mempoolStats}); + + @override + $StatsItemCopyWith<$Res> get chainStats; + @override + $StatsItemCopyWith<$Res> get mempoolStats; +} + +/// @nodoc +class __$$AddressStatsImplCopyWithImpl<$Res> + extends _$AddressStatsCopyWithImpl<$Res, _$AddressStatsImpl> + implements _$$AddressStatsImplCopyWith<$Res> { + __$$AddressStatsImplCopyWithImpl( + _$AddressStatsImpl _value, $Res Function(_$AddressStatsImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? address = null, + Object? chainStats = null, + Object? mempoolStats = null, + }) { + return _then(_$AddressStatsImpl( + address: null == address + ? _value.address + : address // ignore: cast_nullable_to_non_nullable + as String, + chainStats: null == chainStats + ? _value.chainStats + : chainStats // ignore: cast_nullable_to_non_nullable + as StatsItem, + mempoolStats: null == mempoolStats + ? _value.mempoolStats + : mempoolStats // ignore: cast_nullable_to_non_nullable + as StatsItem, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$AddressStatsImpl implements _AddressStats { + const _$AddressStatsImpl( + {required this.address, + @JsonKey(name: 'chain_stats') required this.chainStats, + @JsonKey(name: 'mempool_stats') required this.mempoolStats}); + + factory _$AddressStatsImpl.fromJson(Map json) => + _$$AddressStatsImplFromJson(json); + + @override + final String address; + @override + @JsonKey(name: 'chain_stats') + final StatsItem chainStats; + @override + @JsonKey(name: 'mempool_stats') + final StatsItem mempoolStats; + + @override + String toString() { + return 'AddressStats(address: $address, chainStats: $chainStats, mempoolStats: $mempoolStats)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$AddressStatsImpl && + (identical(other.address, address) || other.address == address) && + (identical(other.chainStats, chainStats) || + other.chainStats == chainStats) && + (identical(other.mempoolStats, mempoolStats) || + other.mempoolStats == mempoolStats)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, address, chainStats, mempoolStats); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$AddressStatsImplCopyWith<_$AddressStatsImpl> get copyWith => + __$$AddressStatsImplCopyWithImpl<_$AddressStatsImpl>(this, _$identity); + + @override + Map toJson() { + return _$$AddressStatsImplToJson( + this, + ); + } +} + +abstract class _AddressStats implements AddressStats { + const factory _AddressStats( + {required final String address, + @JsonKey(name: 'chain_stats') required final StatsItem chainStats, + @JsonKey(name: 'mempool_stats') + required final StatsItem mempoolStats}) = _$AddressStatsImpl; + + factory _AddressStats.fromJson(Map json) = + _$AddressStatsImpl.fromJson; + + @override + String get address; + @override + @JsonKey(name: 'chain_stats') + StatsItem get chainStats; + @override + @JsonKey(name: 'mempool_stats') + StatsItem get mempoolStats; + @override + @JsonKey(ignore: true) + _$$AddressStatsImplCopyWith<_$AddressStatsImpl> get copyWith => + throw _privateConstructorUsedError; +} + +StatsItem _$StatsItemFromJson(Map json) { + return _StatsItem.fromJson(json); +} + +/// @nodoc +mixin _$StatsItem { + @JsonKey(name: 'funded_utxo_count') + int get fundedUtxoCount => throw _privateConstructorUsedError; + @JsonKey(name: 'funded_utxo_sum') + int get fundedUtxoSum => throw _privateConstructorUsedError; + @JsonKey(name: 'spent_utxo_count') + int get spentUtxoCount => throw _privateConstructorUsedError; + @JsonKey(name: 'spent_utxo_sum') + int get spentUtxoSum => throw _privateConstructorUsedError; + @JsonKey(name: 'tx_count') + int get txCount => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $StatsItemCopyWith get copyWith => + throw _privateConstructorUsedError; +} + +/// @nodoc +abstract class $StatsItemCopyWith<$Res> { + factory $StatsItemCopyWith(StatsItem value, $Res Function(StatsItem) then) = + _$StatsItemCopyWithImpl<$Res, StatsItem>; + @useResult + $Res call( + {@JsonKey(name: 'funded_utxo_count') int fundedUtxoCount, + @JsonKey(name: 'funded_utxo_sum') int fundedUtxoSum, + @JsonKey(name: 'spent_utxo_count') int spentUtxoCount, + @JsonKey(name: 'spent_utxo_sum') int spentUtxoSum, + @JsonKey(name: 'tx_count') int txCount}); +} + +/// @nodoc +class _$StatsItemCopyWithImpl<$Res, $Val extends StatsItem> + implements $StatsItemCopyWith<$Res> { + _$StatsItemCopyWithImpl(this._value, this._then); + + // ignore: unused_field + final $Val _value; + // ignore: unused_field + final $Res Function($Val) _then; + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fundedUtxoCount = null, + Object? fundedUtxoSum = null, + Object? spentUtxoCount = null, + Object? spentUtxoSum = null, + Object? txCount = null, + }) { + return _then(_value.copyWith( + fundedUtxoCount: null == fundedUtxoCount + ? _value.fundedUtxoCount + : fundedUtxoCount // ignore: cast_nullable_to_non_nullable + as int, + fundedUtxoSum: null == fundedUtxoSum + ? _value.fundedUtxoSum + : fundedUtxoSum // ignore: cast_nullable_to_non_nullable + as int, + spentUtxoCount: null == spentUtxoCount + ? _value.spentUtxoCount + : spentUtxoCount // ignore: cast_nullable_to_non_nullable + as int, + spentUtxoSum: null == spentUtxoSum + ? _value.spentUtxoSum + : spentUtxoSum // ignore: cast_nullable_to_non_nullable + as int, + txCount: null == txCount + ? _value.txCount + : txCount // ignore: cast_nullable_to_non_nullable + as int, + ) as $Val); + } +} + +/// @nodoc +abstract class _$$StatsItemImplCopyWith<$Res> + implements $StatsItemCopyWith<$Res> { + factory _$$StatsItemImplCopyWith( + _$StatsItemImpl value, $Res Function(_$StatsItemImpl) then) = + __$$StatsItemImplCopyWithImpl<$Res>; + @override + @useResult + $Res call( + {@JsonKey(name: 'funded_utxo_count') int fundedUtxoCount, + @JsonKey(name: 'funded_utxo_sum') int fundedUtxoSum, + @JsonKey(name: 'spent_utxo_count') int spentUtxoCount, + @JsonKey(name: 'spent_utxo_sum') int spentUtxoSum, + @JsonKey(name: 'tx_count') int txCount}); +} + +/// @nodoc +class __$$StatsItemImplCopyWithImpl<$Res> + extends _$StatsItemCopyWithImpl<$Res, _$StatsItemImpl> + implements _$$StatsItemImplCopyWith<$Res> { + __$$StatsItemImplCopyWithImpl( + _$StatsItemImpl _value, $Res Function(_$StatsItemImpl) _then) + : super(_value, _then); + + @pragma('vm:prefer-inline') + @override + $Res call({ + Object? fundedUtxoCount = null, + Object? fundedUtxoSum = null, + Object? spentUtxoCount = null, + Object? spentUtxoSum = null, + Object? txCount = null, + }) { + return _then(_$StatsItemImpl( + fundedUtxoCount: null == fundedUtxoCount + ? _value.fundedUtxoCount + : fundedUtxoCount // ignore: cast_nullable_to_non_nullable + as int, + fundedUtxoSum: null == fundedUtxoSum + ? _value.fundedUtxoSum + : fundedUtxoSum // ignore: cast_nullable_to_non_nullable + as int, + spentUtxoCount: null == spentUtxoCount + ? _value.spentUtxoCount + : spentUtxoCount // ignore: cast_nullable_to_non_nullable + as int, + spentUtxoSum: null == spentUtxoSum + ? _value.spentUtxoSum + : spentUtxoSum // ignore: cast_nullable_to_non_nullable + as int, + txCount: null == txCount + ? _value.txCount + : txCount // ignore: cast_nullable_to_non_nullable + as int, + )); + } +} + +/// @nodoc +@JsonSerializable() +class _$StatsItemImpl implements _StatsItem { + const _$StatsItemImpl( + {@JsonKey(name: 'funded_utxo_count') required this.fundedUtxoCount, + @JsonKey(name: 'funded_utxo_sum') required this.fundedUtxoSum, + @JsonKey(name: 'spent_utxo_count') required this.spentUtxoCount, + @JsonKey(name: 'spent_utxo_sum') required this.spentUtxoSum, + @JsonKey(name: 'tx_count') required this.txCount}); + + factory _$StatsItemImpl.fromJson(Map json) => + _$$StatsItemImplFromJson(json); + + @override + @JsonKey(name: 'funded_utxo_count') + final int fundedUtxoCount; + @override + @JsonKey(name: 'funded_utxo_sum') + final int fundedUtxoSum; + @override + @JsonKey(name: 'spent_utxo_count') + final int spentUtxoCount; + @override + @JsonKey(name: 'spent_utxo_sum') + final int spentUtxoSum; + @override + @JsonKey(name: 'tx_count') + final int txCount; + + @override + String toString() { + return 'StatsItem(fundedUtxoCount: $fundedUtxoCount, fundedUtxoSum: $fundedUtxoSum, spentUtxoCount: $spentUtxoCount, spentUtxoSum: $spentUtxoSum, txCount: $txCount)'; + } + + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$StatsItemImpl && + (identical(other.fundedUtxoCount, fundedUtxoCount) || + other.fundedUtxoCount == fundedUtxoCount) && + (identical(other.fundedUtxoSum, fundedUtxoSum) || + other.fundedUtxoSum == fundedUtxoSum) && + (identical(other.spentUtxoCount, spentUtxoCount) || + other.spentUtxoCount == spentUtxoCount) && + (identical(other.spentUtxoSum, spentUtxoSum) || + other.spentUtxoSum == spentUtxoSum) && + (identical(other.txCount, txCount) || other.txCount == txCount)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash(runtimeType, fundedUtxoCount, fundedUtxoSum, + spentUtxoCount, spentUtxoSum, txCount); + + @JsonKey(ignore: true) + @override + @pragma('vm:prefer-inline') + _$$StatsItemImplCopyWith<_$StatsItemImpl> get copyWith => + __$$StatsItemImplCopyWithImpl<_$StatsItemImpl>(this, _$identity); + + @override + Map toJson() { + return _$$StatsItemImplToJson( + this, + ); + } +} + +abstract class _StatsItem implements StatsItem { + const factory _StatsItem( + {@JsonKey(name: 'funded_utxo_count') required final int fundedUtxoCount, + @JsonKey(name: 'funded_utxo_sum') required final int fundedUtxoSum, + @JsonKey(name: 'spent_utxo_count') required final int spentUtxoCount, + @JsonKey(name: 'spent_utxo_sum') required final int spentUtxoSum, + @JsonKey(name: 'tx_count') required final int txCount}) = _$StatsItemImpl; + + factory _StatsItem.fromJson(Map json) = + _$StatsItemImpl.fromJson; + + @override + @JsonKey(name: 'funded_utxo_count') + int get fundedUtxoCount; + @override + @JsonKey(name: 'funded_utxo_sum') + int get fundedUtxoSum; + @override + @JsonKey(name: 'spent_utxo_count') + int get spentUtxoCount; + @override + @JsonKey(name: 'spent_utxo_sum') + int get spentUtxoSum; + @override + @JsonKey(name: 'tx_count') + int get txCount; + @override + @JsonKey(ignore: true) + _$$StatsItemImplCopyWith<_$StatsItemImpl> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/packages/agent_dart_base/lib/agent/ord/address_stats.g.dart b/packages/agent_dart_base/lib/agent/ord/address_stats.g.dart new file mode 100644 index 00000000..9fcb7ca7 --- /dev/null +++ b/packages/agent_dart_base/lib/agent/ord/address_stats.g.dart @@ -0,0 +1,41 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address_stats.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$AddressStatsImpl _$$AddressStatsImplFromJson(Map json) => + _$AddressStatsImpl( + address: json['address'] as String, + chainStats: + StatsItem.fromJson(json['chain_stats'] as Map), + mempoolStats: + StatsItem.fromJson(json['mempool_stats'] as Map), + ); + +Map _$$AddressStatsImplToJson(_$AddressStatsImpl instance) => + { + 'address': instance.address, + 'chain_stats': instance.chainStats, + 'mempool_stats': instance.mempoolStats, + }; + +_$StatsItemImpl _$$StatsItemImplFromJson(Map json) => + _$StatsItemImpl( + fundedUtxoCount: (json['funded_utxo_count'] as num).toInt(), + fundedUtxoSum: (json['funded_utxo_sum'] as num).toInt(), + spentUtxoCount: (json['spent_utxo_count'] as num).toInt(), + spentUtxoSum: (json['spent_utxo_sum'] as num).toInt(), + txCount: (json['tx_count'] as num).toInt(), + ); + +Map _$$StatsItemImplToJson(_$StatsItemImpl instance) => + { + 'funded_utxo_count': instance.fundedUtxoCount, + 'funded_utxo_sum': instance.fundedUtxoSum, + 'spent_utxo_count': instance.spentUtxoCount, + 'spent_utxo_sum': instance.spentUtxoSum, + 'tx_count': instance.txCount, + }; diff --git a/packages/agent_dart_base/lib/agent/ord/addressUtxo.dart b/packages/agent_dart_base/lib/agent/ord/address_utxo.dart similarity index 77% rename from packages/agent_dart_base/lib/agent/ord/addressUtxo.dart rename to packages/agent_dart_base/lib/agent/ord/address_utxo.dart index 0d155f9d..33073646 100644 --- a/packages/agent_dart_base/lib/agent/ord/addressUtxo.dart +++ b/packages/agent_dart_base/lib/agent/ord/address_utxo.dart @@ -24,12 +24,12 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -part 'addressUtxo.freezed.dart'; -part 'addressUtxo.g.dart'; +part 'address_utxo.freezed.dart'; +part 'address_utxo.g.dart'; @freezed class AddressUtxo with _$AddressUtxo { - factory AddressUtxo({ + const factory AddressUtxo({ required String txid, required int vout, required int value, @@ -40,13 +40,13 @@ class AddressUtxo with _$AddressUtxo { _$AddressUtxoFromJson(json); } -@unfreezed +@freezed class TxStatus with _$TxStatus { - factory TxStatus({ + const factory TxStatus({ required bool confirmed, - int? block_height, - String? block_hash, - int? block_time, + @JsonKey(name: 'block_height') required int? blockHeight, + @JsonKey(name: 'block_hash') required String? blockHash, + @JsonKey(name: 'block_time') required int? blockTime, }) = _TxStatus; factory TxStatus.fromJson(Map json) => diff --git a/packages/agent_dart_base/lib/agent/ord/addressUtxo.freezed.dart b/packages/agent_dart_base/lib/agent/ord/address_utxo.freezed.dart similarity index 57% rename from packages/agent_dart_base/lib/agent/ord/addressUtxo.freezed.dart rename to packages/agent_dart_base/lib/agent/ord/address_utxo.freezed.dart index 6fc503f0..05070420 100644 --- a/packages/agent_dart_base/lib/agent/ord/addressUtxo.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/address_utxo.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'addressUtxo.dart'; +part of 'address_utxo.dart'; // ************************************************************************** // FreezedGenerator @@ -12,7 +12,7 @@ part of 'addressUtxo.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); AddressUtxo _$AddressUtxoFromJson(Map json) { return _AddressUtxo.fromJson(json); @@ -90,11 +90,11 @@ class _$AddressUtxoCopyWithImpl<$Res, $Val extends AddressUtxo> } /// @nodoc -abstract class _$$_AddressUtxoCopyWith<$Res> +abstract class _$$AddressUtxoImplCopyWith<$Res> implements $AddressUtxoCopyWith<$Res> { - factory _$$_AddressUtxoCopyWith( - _$_AddressUtxo value, $Res Function(_$_AddressUtxo) then) = - __$$_AddressUtxoCopyWithImpl<$Res>; + factory _$$AddressUtxoImplCopyWith( + _$AddressUtxoImpl value, $Res Function(_$AddressUtxoImpl) then) = + __$$AddressUtxoImplCopyWithImpl<$Res>; @override @useResult $Res call({String txid, int vout, int value, TxStatus status}); @@ -104,11 +104,11 @@ abstract class _$$_AddressUtxoCopyWith<$Res> } /// @nodoc -class __$$_AddressUtxoCopyWithImpl<$Res> - extends _$AddressUtxoCopyWithImpl<$Res, _$_AddressUtxo> - implements _$$_AddressUtxoCopyWith<$Res> { - __$$_AddressUtxoCopyWithImpl( - _$_AddressUtxo _value, $Res Function(_$_AddressUtxo) _then) +class __$$AddressUtxoImplCopyWithImpl<$Res> + extends _$AddressUtxoCopyWithImpl<$Res, _$AddressUtxoImpl> + implements _$$AddressUtxoImplCopyWith<$Res> { + __$$AddressUtxoImplCopyWithImpl( + _$AddressUtxoImpl _value, $Res Function(_$AddressUtxoImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -119,7 +119,7 @@ class __$$_AddressUtxoCopyWithImpl<$Res> Object? value = null, Object? status = null, }) { - return _then(_$_AddressUtxo( + return _then(_$AddressUtxoImpl( txid: null == txid ? _value.txid : txid // ignore: cast_nullable_to_non_nullable @@ -142,15 +142,15 @@ class __$$_AddressUtxoCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_AddressUtxo implements _AddressUtxo { - _$_AddressUtxo( +class _$AddressUtxoImpl implements _AddressUtxo { + const _$AddressUtxoImpl( {required this.txid, required this.vout, required this.value, required this.status}); - factory _$_AddressUtxo.fromJson(Map json) => - _$$_AddressUtxoFromJson(json); + factory _$AddressUtxoImpl.fromJson(Map json) => + _$$AddressUtxoImplFromJson(json); @override final String txid; @@ -167,10 +167,10 @@ class _$_AddressUtxo implements _AddressUtxo { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_AddressUtxo && + other is _$AddressUtxoImpl && (identical(other.txid, txid) || other.txid == txid) && (identical(other.vout, vout) || other.vout == vout) && (identical(other.value, value) || other.value == value) && @@ -184,26 +184,26 @@ class _$_AddressUtxo implements _AddressUtxo { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_AddressUtxoCopyWith<_$_AddressUtxo> get copyWith => - __$$_AddressUtxoCopyWithImpl<_$_AddressUtxo>(this, _$identity); + _$$AddressUtxoImplCopyWith<_$AddressUtxoImpl> get copyWith => + __$$AddressUtxoImplCopyWithImpl<_$AddressUtxoImpl>(this, _$identity); @override Map toJson() { - return _$$_AddressUtxoToJson( + return _$$AddressUtxoImplToJson( this, ); } } abstract class _AddressUtxo implements AddressUtxo { - factory _AddressUtxo( + const factory _AddressUtxo( {required final String txid, required final int vout, required final int value, - required final TxStatus status}) = _$_AddressUtxo; + required final TxStatus status}) = _$AddressUtxoImpl; factory _AddressUtxo.fromJson(Map json) = - _$_AddressUtxo.fromJson; + _$AddressUtxoImpl.fromJson; @override String get txid; @@ -215,7 +215,7 @@ abstract class _AddressUtxo implements AddressUtxo { TxStatus get status; @override @JsonKey(ignore: true) - _$$_AddressUtxoCopyWith<_$_AddressUtxo> get copyWith => + _$$AddressUtxoImplCopyWith<_$AddressUtxoImpl> get copyWith => throw _privateConstructorUsedError; } @@ -226,13 +226,12 @@ TxStatus _$TxStatusFromJson(Map json) { /// @nodoc mixin _$TxStatus { bool get confirmed => throw _privateConstructorUsedError; - set confirmed(bool value) => throw _privateConstructorUsedError; - int? get block_height => throw _privateConstructorUsedError; - set block_height(int? value) => throw _privateConstructorUsedError; - String? get block_hash => throw _privateConstructorUsedError; - set block_hash(String? value) => throw _privateConstructorUsedError; - int? get block_time => throw _privateConstructorUsedError; - set block_time(int? value) => throw _privateConstructorUsedError; + @JsonKey(name: 'block_height') + int? get blockHeight => throw _privateConstructorUsedError; + @JsonKey(name: 'block_hash') + String? get blockHash => throw _privateConstructorUsedError; + @JsonKey(name: 'block_time') + int? get blockTime => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -246,7 +245,10 @@ abstract class $TxStatusCopyWith<$Res> { _$TxStatusCopyWithImpl<$Res, TxStatus>; @useResult $Res call( - {bool confirmed, int? block_height, String? block_hash, int? block_time}); + {bool confirmed, + @JsonKey(name: 'block_height') int? blockHeight, + @JsonKey(name: 'block_hash') String? blockHash, + @JsonKey(name: 'block_time') int? blockTime}); } /// @nodoc @@ -263,74 +265,78 @@ class _$TxStatusCopyWithImpl<$Res, $Val extends TxStatus> @override $Res call({ Object? confirmed = null, - Object? block_height = freezed, - Object? block_hash = freezed, - Object? block_time = freezed, + Object? blockHeight = freezed, + Object? blockHash = freezed, + Object? blockTime = freezed, }) { return _then(_value.copyWith( confirmed: null == confirmed ? _value.confirmed : confirmed // ignore: cast_nullable_to_non_nullable as bool, - block_height: freezed == block_height - ? _value.block_height - : block_height // ignore: cast_nullable_to_non_nullable + blockHeight: freezed == blockHeight + ? _value.blockHeight + : blockHeight // ignore: cast_nullable_to_non_nullable as int?, - block_hash: freezed == block_hash - ? _value.block_hash - : block_hash // ignore: cast_nullable_to_non_nullable + blockHash: freezed == blockHash + ? _value.blockHash + : blockHash // ignore: cast_nullable_to_non_nullable as String?, - block_time: freezed == block_time - ? _value.block_time - : block_time // ignore: cast_nullable_to_non_nullable + blockTime: freezed == blockTime + ? _value.blockTime + : blockTime // ignore: cast_nullable_to_non_nullable as int?, ) as $Val); } } /// @nodoc -abstract class _$$_TxStatusCopyWith<$Res> implements $TxStatusCopyWith<$Res> { - factory _$$_TxStatusCopyWith( - _$_TxStatus value, $Res Function(_$_TxStatus) then) = - __$$_TxStatusCopyWithImpl<$Res>; +abstract class _$$TxStatusImplCopyWith<$Res> + implements $TxStatusCopyWith<$Res> { + factory _$$TxStatusImplCopyWith( + _$TxStatusImpl value, $Res Function(_$TxStatusImpl) then) = + __$$TxStatusImplCopyWithImpl<$Res>; @override @useResult $Res call( - {bool confirmed, int? block_height, String? block_hash, int? block_time}); + {bool confirmed, + @JsonKey(name: 'block_height') int? blockHeight, + @JsonKey(name: 'block_hash') String? blockHash, + @JsonKey(name: 'block_time') int? blockTime}); } /// @nodoc -class __$$_TxStatusCopyWithImpl<$Res> - extends _$TxStatusCopyWithImpl<$Res, _$_TxStatus> - implements _$$_TxStatusCopyWith<$Res> { - __$$_TxStatusCopyWithImpl( - _$_TxStatus _value, $Res Function(_$_TxStatus) _then) +class __$$TxStatusImplCopyWithImpl<$Res> + extends _$TxStatusCopyWithImpl<$Res, _$TxStatusImpl> + implements _$$TxStatusImplCopyWith<$Res> { + __$$TxStatusImplCopyWithImpl( + _$TxStatusImpl _value, $Res Function(_$TxStatusImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @override $Res call({ Object? confirmed = null, - Object? block_height = freezed, - Object? block_hash = freezed, - Object? block_time = freezed, + Object? blockHeight = freezed, + Object? blockHash = freezed, + Object? blockTime = freezed, }) { - return _then(_$_TxStatus( + return _then(_$TxStatusImpl( confirmed: null == confirmed ? _value.confirmed : confirmed // ignore: cast_nullable_to_non_nullable as bool, - block_height: freezed == block_height - ? _value.block_height - : block_height // ignore: cast_nullable_to_non_nullable + blockHeight: freezed == blockHeight + ? _value.blockHeight + : blockHeight // ignore: cast_nullable_to_non_nullable as int?, - block_hash: freezed == block_hash - ? _value.block_hash - : block_hash // ignore: cast_nullable_to_non_nullable + blockHash: freezed == blockHash + ? _value.blockHash + : blockHash // ignore: cast_nullable_to_non_nullable as String?, - block_time: freezed == block_time - ? _value.block_time - : block_time // ignore: cast_nullable_to_non_nullable + blockTime: freezed == blockTime + ? _value.blockTime + : blockTime // ignore: cast_nullable_to_non_nullable as int?, )); } @@ -338,67 +344,91 @@ class __$$_TxStatusCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_TxStatus implements _TxStatus { - _$_TxStatus( +class _$TxStatusImpl implements _TxStatus { + const _$TxStatusImpl( {required this.confirmed, - this.block_height, - this.block_hash, - this.block_time}); + @JsonKey(name: 'block_height') required this.blockHeight, + @JsonKey(name: 'block_hash') required this.blockHash, + @JsonKey(name: 'block_time') required this.blockTime}); - factory _$_TxStatus.fromJson(Map json) => - _$$_TxStatusFromJson(json); + factory _$TxStatusImpl.fromJson(Map json) => + _$$TxStatusImplFromJson(json); @override - bool confirmed; + final bool confirmed; @override - int? block_height; + @JsonKey(name: 'block_height') + final int? blockHeight; @override - String? block_hash; + @JsonKey(name: 'block_hash') + final String? blockHash; @override - int? block_time; + @JsonKey(name: 'block_time') + final int? blockTime; @override String toString() { - return 'TxStatus(confirmed: $confirmed, block_height: $block_height, block_hash: $block_hash, block_time: $block_time)'; + return 'TxStatus(confirmed: $confirmed, blockHeight: $blockHeight, blockHash: $blockHash, blockTime: $blockTime)'; } + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TxStatusImpl && + (identical(other.confirmed, confirmed) || + other.confirmed == confirmed) && + (identical(other.blockHeight, blockHeight) || + other.blockHeight == blockHeight) && + (identical(other.blockHash, blockHash) || + other.blockHash == blockHash) && + (identical(other.blockTime, blockTime) || + other.blockTime == blockTime)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => + Object.hash(runtimeType, confirmed, blockHeight, blockHash, blockTime); + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_TxStatusCopyWith<_$_TxStatus> get copyWith => - __$$_TxStatusCopyWithImpl<_$_TxStatus>(this, _$identity); + _$$TxStatusImplCopyWith<_$TxStatusImpl> get copyWith => + __$$TxStatusImplCopyWithImpl<_$TxStatusImpl>(this, _$identity); @override Map toJson() { - return _$$_TxStatusToJson( + return _$$TxStatusImplToJson( this, ); } } abstract class _TxStatus implements TxStatus { - factory _TxStatus( - {required bool confirmed, - int? block_height, - String? block_hash, - int? block_time}) = _$_TxStatus; + const factory _TxStatus( + {required final bool confirmed, + @JsonKey(name: 'block_height') required final int? blockHeight, + @JsonKey(name: 'block_hash') required final String? blockHash, + @JsonKey(name: 'block_time') required final int? blockTime}) = + _$TxStatusImpl; - factory _TxStatus.fromJson(Map json) = _$_TxStatus.fromJson; + factory _TxStatus.fromJson(Map json) = + _$TxStatusImpl.fromJson; @override bool get confirmed; - set confirmed(bool value); @override - int? get block_height; - set block_height(int? value); + @JsonKey(name: 'block_height') + int? get blockHeight; @override - String? get block_hash; - set block_hash(String? value); + @JsonKey(name: 'block_hash') + String? get blockHash; @override - int? get block_time; - set block_time(int? value); + @JsonKey(name: 'block_time') + int? get blockTime; @override @JsonKey(ignore: true) - _$$_TxStatusCopyWith<_$_TxStatus> get copyWith => + _$$TxStatusImplCopyWith<_$TxStatusImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/address_utxo.g.dart b/packages/agent_dart_base/lib/agent/ord/address_utxo.g.dart new file mode 100644 index 00000000..ca47bc98 --- /dev/null +++ b/packages/agent_dart_base/lib/agent/ord/address_utxo.g.dart @@ -0,0 +1,39 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'address_utxo.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$AddressUtxoImpl _$$AddressUtxoImplFromJson(Map json) => + _$AddressUtxoImpl( + txid: json['txid'] as String, + vout: (json['vout'] as num).toInt(), + value: (json['value'] as num).toInt(), + status: TxStatus.fromJson(json['status'] as Map), + ); + +Map _$$AddressUtxoImplToJson(_$AddressUtxoImpl instance) => + { + 'txid': instance.txid, + 'vout': instance.vout, + 'value': instance.value, + 'status': instance.status, + }; + +_$TxStatusImpl _$$TxStatusImplFromJson(Map json) => + _$TxStatusImpl( + confirmed: json['confirmed'] as bool, + blockHeight: (json['block_height'] as num?)?.toInt(), + blockHash: json['block_hash'] as String?, + blockTime: (json['block_time'] as num?)?.toInt(), + ); + +Map _$$TxStatusImplToJson(_$TxStatusImpl instance) => + { + 'confirmed': instance.confirmed, + 'block_height': instance.blockHeight, + 'block_hash': instance.blockHash, + 'block_time': instance.blockTime, + }; diff --git a/packages/agent_dart_base/lib/agent/ord/blockstream.dart b/packages/agent_dart_base/lib/agent/ord/blockstream.dart index 6a4a9af2..b7aeb1f6 100644 --- a/packages/agent_dart_base/lib/agent/ord/blockstream.dart +++ b/packages/agent_dart_base/lib/agent/ord/blockstream.dart @@ -1,12 +1,12 @@ import 'dart:convert'; import 'package:agent_dart_base/agent/agent.dart'; -import 'package:agent_dart_base/agent/ord/addressStats.dart'; -import 'package:agent_dart_base/agent/ord/addressUtxo.dart'; -import 'package:agent_dart_base/agent/ord/service.dart'; -import 'package:agent_dart_base/agent/ord/tx.dart'; +import 'address_stats.dart'; +import 'address_utxo.dart'; import 'client.dart'; +import 'service.dart'; +import 'tx.dart'; enum TxsFilter { All, Confirmed, Unconfirmed } @@ -34,7 +34,7 @@ class BlockStreamApi { _override = override; } - DataResponse _decodeReponse(SubmitResponse response) { + DataResponse _decodeResponse(SubmitResponse response) { final body = response.toJson()['body']; final data = jsonDecode(body)['data']; return DataResponse( @@ -43,7 +43,7 @@ class BlockStreamApi { ); } - DataResponse _decodeGetReponse(SubmitResponse response) { + DataResponse _decodeGetResponse(SubmitResponse response) { final body = response.toJson()['body']; final data = jsonDecode(body); @@ -55,29 +55,29 @@ class BlockStreamApi { Future getTx(String txId) async { final response = await _client.httpGet( - '/tx/${txId}', + '/tx/$txId', {}, _override, ); - return Tx.fromJson(_decodeGetReponse(response).data); + return Tx.fromJson(_decodeGetResponse(response).data); } Future getAddressStats(String address) async { final response = await _client.httpGet( - '/address/${address}', + '/address/$address', {}, _override, ); - return AddressStats.fromJson(_decodeGetReponse(response).data); + return AddressStats.fromJson(_decodeGetResponse(response).data); } Future> getAddressUtxo(String address) async { final response = await _client.httpGet( - '/address/${address}/utxo', + '/address/$address/utxo', {}, _override, ); - return (_decodeGetReponse(response).data as List) + return (_decodeGetResponse(response).data as List) .map((e) => AddressUtxo.fromJson(e as Map)) .toList(); } @@ -87,21 +87,21 @@ class BlockStreamApi { TxsFilter filter = TxsFilter.All, String? lastSeenTxId, }) async { - final prefix = '/address/${address}/txs'; - var thePrefix; + final prefix = '/address/$address/txs'; + String thePrefix; var id = ''; if (lastSeenTxId != null) { - id = '/${lastSeenTxId}'; + id = '/$lastSeenTxId'; } switch (filter) { case TxsFilter.All: thePrefix = prefix; break; case TxsFilter.Confirmed: - thePrefix = prefix + '/chain'; + thePrefix = '$prefix/chain'; break; case TxsFilter.Unconfirmed: - thePrefix = prefix + '/mempool'; + thePrefix = '$prefix/mempool'; break; } @@ -110,14 +110,14 @@ class BlockStreamApi { {}, _override, ); - return (_decodeGetReponse(response).data as List) + return (_decodeGetResponse(response).data as List) .map((e) => Tx.fromJson(e as Map)) .toList(); } Future getTxHex(String txId) async { final response = await _client.httpGet( - '/tx/${txId}/hex', + '/tx/$txId/hex', {}, _override, ); diff --git a/packages/agent_dart_base/lib/agent/ord/inscription.dart b/packages/agent_dart_base/lib/agent/ord/inscription.dart index 3a983699..a06169b7 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscription.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription.dart @@ -5,11 +5,11 @@ part 'inscription.g.dart'; @freezed class Inscription with _$Inscription { - factory Inscription({ + const factory Inscription({ required String id, required int offset, - int? number, - int? num, + required int? number, + required int? num, }) = _Inscription; factory Inscription.fromJson(Map json) => diff --git a/packages/agent_dart_base/lib/agent/ord/inscription.freezed.dart b/packages/agent_dart_base/lib/agent/ord/inscription.freezed.dart index cd3def06..fca4b8ce 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscription.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription.freezed.dart @@ -12,7 +12,7 @@ part of 'inscription.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); Inscription _$InscriptionFromJson(Map json) { return _Inscription.fromJson(json); @@ -80,22 +80,22 @@ class _$InscriptionCopyWithImpl<$Res, $Val extends Inscription> } /// @nodoc -abstract class _$$_InscriptionCopyWith<$Res> +abstract class _$$InscriptionImplCopyWith<$Res> implements $InscriptionCopyWith<$Res> { - factory _$$_InscriptionCopyWith( - _$_Inscription value, $Res Function(_$_Inscription) then) = - __$$_InscriptionCopyWithImpl<$Res>; + factory _$$InscriptionImplCopyWith( + _$InscriptionImpl value, $Res Function(_$InscriptionImpl) then) = + __$$InscriptionImplCopyWithImpl<$Res>; @override @useResult $Res call({String id, int offset, int? number, int? num}); } /// @nodoc -class __$$_InscriptionCopyWithImpl<$Res> - extends _$InscriptionCopyWithImpl<$Res, _$_Inscription> - implements _$$_InscriptionCopyWith<$Res> { - __$$_InscriptionCopyWithImpl( - _$_Inscription _value, $Res Function(_$_Inscription) _then) +class __$$InscriptionImplCopyWithImpl<$Res> + extends _$InscriptionCopyWithImpl<$Res, _$InscriptionImpl> + implements _$$InscriptionImplCopyWith<$Res> { + __$$InscriptionImplCopyWithImpl( + _$InscriptionImpl _value, $Res Function(_$InscriptionImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -106,7 +106,7 @@ class __$$_InscriptionCopyWithImpl<$Res> Object? number = freezed, Object? num = freezed, }) { - return _then(_$_Inscription( + return _then(_$InscriptionImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable @@ -129,12 +129,15 @@ class __$$_InscriptionCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_Inscription implements _Inscription { - _$_Inscription( - {required this.id, required this.offset, this.number, this.num}); +class _$InscriptionImpl implements _Inscription { + const _$InscriptionImpl( + {required this.id, + required this.offset, + required this.number, + required this.num}); - factory _$_Inscription.fromJson(Map json) => - _$$_InscriptionFromJson(json); + factory _$InscriptionImpl.fromJson(Map json) => + _$$InscriptionImplFromJson(json); @override final String id; @@ -151,10 +154,10 @@ class _$_Inscription implements _Inscription { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_Inscription && + other is _$InscriptionImpl && (identical(other.id, id) || other.id == id) && (identical(other.offset, offset) || other.offset == offset) && (identical(other.number, number) || other.number == number) && @@ -168,26 +171,26 @@ class _$_Inscription implements _Inscription { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_InscriptionCopyWith<_$_Inscription> get copyWith => - __$$_InscriptionCopyWithImpl<_$_Inscription>(this, _$identity); + _$$InscriptionImplCopyWith<_$InscriptionImpl> get copyWith => + __$$InscriptionImplCopyWithImpl<_$InscriptionImpl>(this, _$identity); @override Map toJson() { - return _$$_InscriptionToJson( + return _$$InscriptionImplToJson( this, ); } } abstract class _Inscription implements Inscription { - factory _Inscription( + const factory _Inscription( {required final String id, required final int offset, - final int? number, - final int? num}) = _$_Inscription; + required final int? number, + required final int? num}) = _$InscriptionImpl; factory _Inscription.fromJson(Map json) = - _$_Inscription.fromJson; + _$InscriptionImpl.fromJson; @override String get id; @@ -199,6 +202,6 @@ abstract class _Inscription implements Inscription { int? get num; @override @JsonKey(ignore: true) - _$$_InscriptionCopyWith<_$_Inscription> get copyWith => + _$$InscriptionImplCopyWith<_$InscriptionImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/inscription.g.dart b/packages/agent_dart_base/lib/agent/ord/inscription.g.dart index a4316a8b..18174ab2 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscription.g.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription.g.dart @@ -6,15 +6,15 @@ part of 'inscription.dart'; // JsonSerializableGenerator // ************************************************************************** -_$_Inscription _$$_InscriptionFromJson(Map json) => - _$_Inscription( +_$InscriptionImpl _$$InscriptionImplFromJson(Map json) => + _$InscriptionImpl( id: json['id'] as String, - offset: json['offset'] as int, - number: json['number'] as int?, - num: json['num'] as int?, + offset: (json['offset'] as num).toInt(), + number: (json['number'] as num?)?.toInt(), + num: (json['num'] as num?)?.toInt(), ); -Map _$$_InscriptionToJson(_$_Inscription instance) => +Map _$$InscriptionImplToJson(_$InscriptionImpl instance) => { 'id': instance.id, 'offset': instance.offset, diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.dart b/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.dart deleted file mode 100644 index 3c93912e..00000000 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.dart +++ /dev/null @@ -1,40 +0,0 @@ -// "id": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", -// "address": "bc1pt4varhu4ha80a8c50hr7le9fcvk7rrhxevq6f4u7w607c5p5x3ssw9fyuf", -// "output_value": 546, -// "preview": "https://unisat.io/api/v1/inscription/preview/text/6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", -// "content": "https://static.unisat.io/inscription/content/6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", -// "content_length": 414, -// "content_type": "text/plain;charset=utf-8", -// "timestamp": "1970-01-01 00:00:00 UTC", -// "genesis_transaction": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00", -// "location": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00:0:0", -// "output": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00:0", -// "offset": 0, -// "content_body": "" - -import 'package:freezed_annotation/freezed_annotation.dart'; - -part 'inscriptionDetail.freezed.dart'; -part 'inscriptionDetail.g.dart'; - -@freezed -class InscriptionDetail with _$InscriptionDetail { - factory InscriptionDetail({ - required String id, - required String address, - required int output_value, - required String preview, - required String content, - required int content_length, - required String content_type, - required String timestamp, - required String genesis_transaction, - required String location, - required String output, - required int offset, - required String content_body, - }) = _InscriptionDetail; - - factory InscriptionDetail.fromJson(Map json) => - _$InscriptionDetailFromJson(json); -} diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.g.dart b/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.g.dart deleted file mode 100644 index 084e3918..00000000 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.g.dart +++ /dev/null @@ -1,42 +0,0 @@ -// GENERATED CODE - DO NOT MODIFY BY HAND - -part of 'inscriptionDetail.dart'; - -// ************************************************************************** -// JsonSerializableGenerator -// ************************************************************************** - -_$_InscriptionDetail _$$_InscriptionDetailFromJson(Map json) => - _$_InscriptionDetail( - id: json['id'] as String, - address: json['address'] as String, - output_value: json['output_value'] as int, - preview: json['preview'] as String, - content: json['content'] as String, - content_length: json['content_length'] as int, - content_type: json['content_type'] as String, - timestamp: json['timestamp'] as String, - genesis_transaction: json['genesis_transaction'] as String, - location: json['location'] as String, - output: json['output'] as String, - offset: json['offset'] as int, - content_body: json['content_body'] as String, - ); - -Map _$$_InscriptionDetailToJson( - _$_InscriptionDetail instance) => - { - 'id': instance.id, - 'address': instance.address, - 'output_value': instance.output_value, - 'preview': instance.preview, - 'content': instance.content, - 'content_length': instance.content_length, - 'content_type': instance.content_type, - 'timestamp': instance.timestamp, - 'genesis_transaction': instance.genesis_transaction, - 'location': instance.location, - 'output': instance.output, - 'offset': instance.offset, - 'content_body': instance.content_body, - }; diff --git a/packages/agent_dart_base/lib/agent/ord/inscription_detail.dart b/packages/agent_dart_base/lib/agent/ord/inscription_detail.dart new file mode 100644 index 00000000..fe14e177 --- /dev/null +++ b/packages/agent_dart_base/lib/agent/ord/inscription_detail.dart @@ -0,0 +1,40 @@ +// "id": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", +// "address": "bc1pt4varhu4ha80a8c50hr7le9fcvk7rrhxevq6f4u7w607c5p5x3ssw9fyuf", +// "output_value": 546, +// "preview": "https://unisat.io/api/v1/inscription/preview/text/6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", +// "content": "https://static.unisat.io/inscription/content/6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00i0", +// "content_length": 414, +// "content_type": "text/plain;charset=utf-8", +// "timestamp": "1970-01-01 00:00:00 UTC", +// "genesis_transaction": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00", +// "location": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00:0:0", +// "output": "6d814a4fd8711688755c3ffbb3a08415fd555fec61e431888f2a0a25c94a3b00:0", +// "offset": 0, +// "content_body": "" + +import 'package:freezed_annotation/freezed_annotation.dart'; + +part 'inscription_detail.freezed.dart'; +part 'inscription_detail.g.dart'; + +@freezed +class InscriptionDetail with _$InscriptionDetail { + const factory InscriptionDetail({ + required String id, + required String address, + @JsonKey(name: 'output_value') required int outputValue, + required String preview, + required String content, + @JsonKey(name: 'content_length') required int contentLength, + @JsonKey(name: 'content_type') required String contentType, + required String timestamp, + @JsonKey(name: 'genesis_transaction') required String genesisTransaction, + required String location, + required String output, + required int offset, + @JsonKey(name: 'content_body') required String contentBody, + }) = _InscriptionDetail; + + factory InscriptionDetail.fromJson(Map json) => + _$InscriptionDetailFromJson(json); +} diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.freezed.dart b/packages/agent_dart_base/lib/agent/ord/inscription_detail.freezed.dart similarity index 55% rename from packages/agent_dart_base/lib/agent/ord/inscriptionDetail.freezed.dart rename to packages/agent_dart_base/lib/agent/ord/inscription_detail.freezed.dart index 7d109dd7..3eea2a33 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionDetail.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription_detail.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'inscriptionDetail.dart'; +part of 'inscription_detail.dart'; // ************************************************************************** // FreezedGenerator @@ -12,7 +12,7 @@ part of 'inscriptionDetail.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); InscriptionDetail _$InscriptionDetailFromJson(Map json) { return _InscriptionDetail.fromJson(json); @@ -22,17 +22,22 @@ InscriptionDetail _$InscriptionDetailFromJson(Map json) { mixin _$InscriptionDetail { String get id => throw _privateConstructorUsedError; String get address => throw _privateConstructorUsedError; - int get output_value => throw _privateConstructorUsedError; + @JsonKey(name: 'output_value') + int get outputValue => throw _privateConstructorUsedError; String get preview => throw _privateConstructorUsedError; String get content => throw _privateConstructorUsedError; - int get content_length => throw _privateConstructorUsedError; - String get content_type => throw _privateConstructorUsedError; + @JsonKey(name: 'content_length') + int get contentLength => throw _privateConstructorUsedError; + @JsonKey(name: 'content_type') + String get contentType => throw _privateConstructorUsedError; String get timestamp => throw _privateConstructorUsedError; - String get genesis_transaction => throw _privateConstructorUsedError; + @JsonKey(name: 'genesis_transaction') + String get genesisTransaction => throw _privateConstructorUsedError; String get location => throw _privateConstructorUsedError; String get output => throw _privateConstructorUsedError; int get offset => throw _privateConstructorUsedError; - String get content_body => throw _privateConstructorUsedError; + @JsonKey(name: 'content_body') + String get contentBody => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -49,17 +54,17 @@ abstract class $InscriptionDetailCopyWith<$Res> { $Res call( {String id, String address, - int output_value, + @JsonKey(name: 'output_value') int outputValue, String preview, String content, - int content_length, - String content_type, + @JsonKey(name: 'content_length') int contentLength, + @JsonKey(name: 'content_type') String contentType, String timestamp, - String genesis_transaction, + @JsonKey(name: 'genesis_transaction') String genesisTransaction, String location, String output, int offset, - String content_body}); + @JsonKey(name: 'content_body') String contentBody}); } /// @nodoc @@ -77,17 +82,17 @@ class _$InscriptionDetailCopyWithImpl<$Res, $Val extends InscriptionDetail> $Res call({ Object? id = null, Object? address = null, - Object? output_value = null, + Object? outputValue = null, Object? preview = null, Object? content = null, - Object? content_length = null, - Object? content_type = null, + Object? contentLength = null, + Object? contentType = null, Object? timestamp = null, - Object? genesis_transaction = null, + Object? genesisTransaction = null, Object? location = null, Object? output = null, Object? offset = null, - Object? content_body = null, + Object? contentBody = null, }) { return _then(_value.copyWith( id: null == id @@ -98,9 +103,9 @@ class _$InscriptionDetailCopyWithImpl<$Res, $Val extends InscriptionDetail> ? _value.address : address // ignore: cast_nullable_to_non_nullable as String, - output_value: null == output_value - ? _value.output_value - : output_value // ignore: cast_nullable_to_non_nullable + outputValue: null == outputValue + ? _value.outputValue + : outputValue // ignore: cast_nullable_to_non_nullable as int, preview: null == preview ? _value.preview @@ -110,21 +115,21 @@ class _$InscriptionDetailCopyWithImpl<$Res, $Val extends InscriptionDetail> ? _value.content : content // ignore: cast_nullable_to_non_nullable as String, - content_length: null == content_length - ? _value.content_length - : content_length // ignore: cast_nullable_to_non_nullable + contentLength: null == contentLength + ? _value.contentLength + : contentLength // ignore: cast_nullable_to_non_nullable as int, - content_type: null == content_type - ? _value.content_type - : content_type // ignore: cast_nullable_to_non_nullable + contentType: null == contentType + ? _value.contentType + : contentType // ignore: cast_nullable_to_non_nullable as String, timestamp: null == timestamp ? _value.timestamp : timestamp // ignore: cast_nullable_to_non_nullable as String, - genesis_transaction: null == genesis_transaction - ? _value.genesis_transaction - : genesis_transaction // ignore: cast_nullable_to_non_nullable + genesisTransaction: null == genesisTransaction + ? _value.genesisTransaction + : genesisTransaction // ignore: cast_nullable_to_non_nullable as String, location: null == location ? _value.location @@ -138,44 +143,44 @@ class _$InscriptionDetailCopyWithImpl<$Res, $Val extends InscriptionDetail> ? _value.offset : offset // ignore: cast_nullable_to_non_nullable as int, - content_body: null == content_body - ? _value.content_body - : content_body // ignore: cast_nullable_to_non_nullable + contentBody: null == contentBody + ? _value.contentBody + : contentBody // ignore: cast_nullable_to_non_nullable as String, ) as $Val); } } /// @nodoc -abstract class _$$_InscriptionDetailCopyWith<$Res> +abstract class _$$InscriptionDetailImplCopyWith<$Res> implements $InscriptionDetailCopyWith<$Res> { - factory _$$_InscriptionDetailCopyWith(_$_InscriptionDetail value, - $Res Function(_$_InscriptionDetail) then) = - __$$_InscriptionDetailCopyWithImpl<$Res>; + factory _$$InscriptionDetailImplCopyWith(_$InscriptionDetailImpl value, + $Res Function(_$InscriptionDetailImpl) then) = + __$$InscriptionDetailImplCopyWithImpl<$Res>; @override @useResult $Res call( {String id, String address, - int output_value, + @JsonKey(name: 'output_value') int outputValue, String preview, String content, - int content_length, - String content_type, + @JsonKey(name: 'content_length') int contentLength, + @JsonKey(name: 'content_type') String contentType, String timestamp, - String genesis_transaction, + @JsonKey(name: 'genesis_transaction') String genesisTransaction, String location, String output, int offset, - String content_body}); + @JsonKey(name: 'content_body') String contentBody}); } /// @nodoc -class __$$_InscriptionDetailCopyWithImpl<$Res> - extends _$InscriptionDetailCopyWithImpl<$Res, _$_InscriptionDetail> - implements _$$_InscriptionDetailCopyWith<$Res> { - __$$_InscriptionDetailCopyWithImpl( - _$_InscriptionDetail _value, $Res Function(_$_InscriptionDetail) _then) +class __$$InscriptionDetailImplCopyWithImpl<$Res> + extends _$InscriptionDetailCopyWithImpl<$Res, _$InscriptionDetailImpl> + implements _$$InscriptionDetailImplCopyWith<$Res> { + __$$InscriptionDetailImplCopyWithImpl(_$InscriptionDetailImpl _value, + $Res Function(_$InscriptionDetailImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -183,19 +188,19 @@ class __$$_InscriptionDetailCopyWithImpl<$Res> $Res call({ Object? id = null, Object? address = null, - Object? output_value = null, + Object? outputValue = null, Object? preview = null, Object? content = null, - Object? content_length = null, - Object? content_type = null, + Object? contentLength = null, + Object? contentType = null, Object? timestamp = null, - Object? genesis_transaction = null, + Object? genesisTransaction = null, Object? location = null, Object? output = null, Object? offset = null, - Object? content_body = null, + Object? contentBody = null, }) { - return _then(_$_InscriptionDetail( + return _then(_$InscriptionDetailImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable @@ -204,9 +209,9 @@ class __$$_InscriptionDetailCopyWithImpl<$Res> ? _value.address : address // ignore: cast_nullable_to_non_nullable as String, - output_value: null == output_value - ? _value.output_value - : output_value // ignore: cast_nullable_to_non_nullable + outputValue: null == outputValue + ? _value.outputValue + : outputValue // ignore: cast_nullable_to_non_nullable as int, preview: null == preview ? _value.preview @@ -216,21 +221,21 @@ class __$$_InscriptionDetailCopyWithImpl<$Res> ? _value.content : content // ignore: cast_nullable_to_non_nullable as String, - content_length: null == content_length - ? _value.content_length - : content_length // ignore: cast_nullable_to_non_nullable + contentLength: null == contentLength + ? _value.contentLength + : contentLength // ignore: cast_nullable_to_non_nullable as int, - content_type: null == content_type - ? _value.content_type - : content_type // ignore: cast_nullable_to_non_nullable + contentType: null == contentType + ? _value.contentType + : contentType // ignore: cast_nullable_to_non_nullable as String, timestamp: null == timestamp ? _value.timestamp : timestamp // ignore: cast_nullable_to_non_nullable as String, - genesis_transaction: null == genesis_transaction - ? _value.genesis_transaction - : genesis_transaction // ignore: cast_nullable_to_non_nullable + genesisTransaction: null == genesisTransaction + ? _value.genesisTransaction + : genesisTransaction // ignore: cast_nullable_to_non_nullable as String, location: null == location ? _value.location @@ -244,9 +249,9 @@ class __$$_InscriptionDetailCopyWithImpl<$Res> ? _value.offset : offset // ignore: cast_nullable_to_non_nullable as int, - content_body: null == content_body - ? _value.content_body - : content_body // ignore: cast_nullable_to_non_nullable + contentBody: null == contentBody + ? _value.contentBody + : contentBody // ignore: cast_nullable_to_non_nullable as String, )); } @@ -254,43 +259,47 @@ class __$$_InscriptionDetailCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_InscriptionDetail implements _InscriptionDetail { - _$_InscriptionDetail( +class _$InscriptionDetailImpl implements _InscriptionDetail { + const _$InscriptionDetailImpl( {required this.id, required this.address, - required this.output_value, + @JsonKey(name: 'output_value') required this.outputValue, required this.preview, required this.content, - required this.content_length, - required this.content_type, + @JsonKey(name: 'content_length') required this.contentLength, + @JsonKey(name: 'content_type') required this.contentType, required this.timestamp, - required this.genesis_transaction, + @JsonKey(name: 'genesis_transaction') required this.genesisTransaction, required this.location, required this.output, required this.offset, - required this.content_body}); + @JsonKey(name: 'content_body') required this.contentBody}); - factory _$_InscriptionDetail.fromJson(Map json) => - _$$_InscriptionDetailFromJson(json); + factory _$InscriptionDetailImpl.fromJson(Map json) => + _$$InscriptionDetailImplFromJson(json); @override final String id; @override final String address; @override - final int output_value; + @JsonKey(name: 'output_value') + final int outputValue; @override final String preview; @override final String content; @override - final int content_length; + @JsonKey(name: 'content_length') + final int contentLength; @override - final String content_type; + @JsonKey(name: 'content_type') + final String contentType; @override final String timestamp; @override - final String genesis_transaction; + @JsonKey(name: 'genesis_transaction') + final String genesisTransaction; @override final String location; @override @@ -298,38 +307,39 @@ class _$_InscriptionDetail implements _InscriptionDetail { @override final int offset; @override - final String content_body; + @JsonKey(name: 'content_body') + final String contentBody; @override String toString() { - return 'InscriptionDetail(id: $id, address: $address, output_value: $output_value, preview: $preview, content: $content, content_length: $content_length, content_type: $content_type, timestamp: $timestamp, genesis_transaction: $genesis_transaction, location: $location, output: $output, offset: $offset, content_body: $content_body)'; + return 'InscriptionDetail(id: $id, address: $address, outputValue: $outputValue, preview: $preview, content: $content, contentLength: $contentLength, contentType: $contentType, timestamp: $timestamp, genesisTransaction: $genesisTransaction, location: $location, output: $output, offset: $offset, contentBody: $contentBody)'; } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_InscriptionDetail && + other is _$InscriptionDetailImpl && (identical(other.id, id) || other.id == id) && (identical(other.address, address) || other.address == address) && - (identical(other.output_value, output_value) || - other.output_value == output_value) && + (identical(other.outputValue, outputValue) || + other.outputValue == outputValue) && (identical(other.preview, preview) || other.preview == preview) && (identical(other.content, content) || other.content == content) && - (identical(other.content_length, content_length) || - other.content_length == content_length) && - (identical(other.content_type, content_type) || - other.content_type == content_type) && + (identical(other.contentLength, contentLength) || + other.contentLength == contentLength) && + (identical(other.contentType, contentType) || + other.contentType == contentType) && (identical(other.timestamp, timestamp) || other.timestamp == timestamp) && - (identical(other.genesis_transaction, genesis_transaction) || - other.genesis_transaction == genesis_transaction) && + (identical(other.genesisTransaction, genesisTransaction) || + other.genesisTransaction == genesisTransaction) && (identical(other.location, location) || other.location == location) && (identical(other.output, output) || other.output == output) && (identical(other.offset, offset) || other.offset == offset) && - (identical(other.content_body, content_body) || - other.content_body == content_body)); + (identical(other.contentBody, contentBody) || + other.contentBody == contentBody)); } @JsonKey(ignore: true) @@ -338,70 +348,76 @@ class _$_InscriptionDetail implements _InscriptionDetail { runtimeType, id, address, - output_value, + outputValue, preview, content, - content_length, - content_type, + contentLength, + contentType, timestamp, - genesis_transaction, + genesisTransaction, location, output, offset, - content_body); + contentBody); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_InscriptionDetailCopyWith<_$_InscriptionDetail> get copyWith => - __$$_InscriptionDetailCopyWithImpl<_$_InscriptionDetail>( + _$$InscriptionDetailImplCopyWith<_$InscriptionDetailImpl> get copyWith => + __$$InscriptionDetailImplCopyWithImpl<_$InscriptionDetailImpl>( this, _$identity); @override Map toJson() { - return _$$_InscriptionDetailToJson( + return _$$InscriptionDetailImplToJson( this, ); } } abstract class _InscriptionDetail implements InscriptionDetail { - factory _InscriptionDetail( - {required final String id, - required final String address, - required final int output_value, - required final String preview, - required final String content, - required final int content_length, - required final String content_type, - required final String timestamp, - required final String genesis_transaction, - required final String location, - required final String output, - required final int offset, - required final String content_body}) = _$_InscriptionDetail; + const factory _InscriptionDetail( + {required final String id, + required final String address, + @JsonKey(name: 'output_value') required final int outputValue, + required final String preview, + required final String content, + @JsonKey(name: 'content_length') required final int contentLength, + @JsonKey(name: 'content_type') required final String contentType, + required final String timestamp, + @JsonKey(name: 'genesis_transaction') + required final String genesisTransaction, + required final String location, + required final String output, + required final int offset, + @JsonKey(name: 'content_body') required final String contentBody}) = + _$InscriptionDetailImpl; factory _InscriptionDetail.fromJson(Map json) = - _$_InscriptionDetail.fromJson; + _$InscriptionDetailImpl.fromJson; @override String get id; @override String get address; @override - int get output_value; + @JsonKey(name: 'output_value') + int get outputValue; @override String get preview; @override String get content; @override - int get content_length; + @JsonKey(name: 'content_length') + int get contentLength; @override - String get content_type; + @JsonKey(name: 'content_type') + String get contentType; @override String get timestamp; @override - String get genesis_transaction; + @JsonKey(name: 'genesis_transaction') + String get genesisTransaction; @override String get location; @override @@ -409,9 +425,10 @@ abstract class _InscriptionDetail implements InscriptionDetail { @override int get offset; @override - String get content_body; + @JsonKey(name: 'content_body') + String get contentBody; @override @JsonKey(ignore: true) - _$$_InscriptionDetailCopyWith<_$_InscriptionDetail> get copyWith => + _$$InscriptionDetailImplCopyWith<_$InscriptionDetailImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/inscription_detail.g.dart b/packages/agent_dart_base/lib/agent/ord/inscription_detail.g.dart new file mode 100644 index 00000000..a6c32eeb --- /dev/null +++ b/packages/agent_dart_base/lib/agent/ord/inscription_detail.g.dart @@ -0,0 +1,43 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'inscription_detail.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$InscriptionDetailImpl _$$InscriptionDetailImplFromJson( + Map json) => + _$InscriptionDetailImpl( + id: json['id'] as String, + address: json['address'] as String, + outputValue: (json['output_value'] as num).toInt(), + preview: json['preview'] as String, + content: json['content'] as String, + contentLength: (json['content_length'] as num).toInt(), + contentType: json['content_type'] as String, + timestamp: json['timestamp'] as String, + genesisTransaction: json['genesis_transaction'] as String, + location: json['location'] as String, + output: json['output'] as String, + offset: (json['offset'] as num).toInt(), + contentBody: json['content_body'] as String, + ); + +Map _$$InscriptionDetailImplToJson( + _$InscriptionDetailImpl instance) => + { + 'id': instance.id, + 'address': instance.address, + 'output_value': instance.outputValue, + 'preview': instance.preview, + 'content': instance.content, + 'content_length': instance.contentLength, + 'content_type': instance.contentType, + 'timestamp': instance.timestamp, + 'genesis_transaction': instance.genesisTransaction, + 'location': instance.location, + 'output': instance.output, + 'offset': instance.offset, + 'content_body': instance.contentBody, + }; diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.dart b/packages/agent_dart_base/lib/agent/ord/inscription_item.dart similarity index 89% rename from packages/agent_dart_base/lib/agent/ord/inscriptionItem.dart rename to packages/agent_dart_base/lib/agent/ord/inscription_item.dart index b789698e..704eecca 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription_item.dart @@ -20,18 +20,19 @@ // } import 'package:freezed_annotation/freezed_annotation.dart'; -import './inscriptionDetail.dart'; -part 'inscriptionItem.freezed.dart'; -part 'inscriptionItem.g.dart'; +import './inscription_detail.dart'; + +part 'inscription_item.freezed.dart'; +part 'inscription_item.g.dart'; @freezed class InscriptionItem with _$InscriptionItem { - factory InscriptionItem({ + const factory InscriptionItem({ required String id, required InscriptionDetail detail, - int? number, - int? num, + required int? number, + required int? num, }) = _InscriptionItem; factory InscriptionItem.fromJson(Map json) => diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.freezed.dart b/packages/agent_dart_base/lib/agent/ord/inscription_item.freezed.dart similarity index 78% rename from packages/agent_dart_base/lib/agent/ord/inscriptionItem.freezed.dart rename to packages/agent_dart_base/lib/agent/ord/inscription_item.freezed.dart index 3d11d041..2ec1ee55 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription_item.freezed.dart @@ -3,7 +3,7 @@ // ignore_for_file: type=lint // ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark -part of 'inscriptionItem.dart'; +part of 'inscription_item.dart'; // ************************************************************************** // FreezedGenerator @@ -12,7 +12,7 @@ part of 'inscriptionItem.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); InscriptionItem _$InscriptionItemFromJson(Map json) { return _InscriptionItem.fromJson(json); @@ -90,11 +90,11 @@ class _$InscriptionItemCopyWithImpl<$Res, $Val extends InscriptionItem> } /// @nodoc -abstract class _$$_InscriptionItemCopyWith<$Res> +abstract class _$$InscriptionItemImplCopyWith<$Res> implements $InscriptionItemCopyWith<$Res> { - factory _$$_InscriptionItemCopyWith( - _$_InscriptionItem value, $Res Function(_$_InscriptionItem) then) = - __$$_InscriptionItemCopyWithImpl<$Res>; + factory _$$InscriptionItemImplCopyWith(_$InscriptionItemImpl value, + $Res Function(_$InscriptionItemImpl) then) = + __$$InscriptionItemImplCopyWithImpl<$Res>; @override @useResult $Res call({String id, InscriptionDetail detail, int? number, int? num}); @@ -104,11 +104,11 @@ abstract class _$$_InscriptionItemCopyWith<$Res> } /// @nodoc -class __$$_InscriptionItemCopyWithImpl<$Res> - extends _$InscriptionItemCopyWithImpl<$Res, _$_InscriptionItem> - implements _$$_InscriptionItemCopyWith<$Res> { - __$$_InscriptionItemCopyWithImpl( - _$_InscriptionItem _value, $Res Function(_$_InscriptionItem) _then) +class __$$InscriptionItemImplCopyWithImpl<$Res> + extends _$InscriptionItemCopyWithImpl<$Res, _$InscriptionItemImpl> + implements _$$InscriptionItemImplCopyWith<$Res> { + __$$InscriptionItemImplCopyWithImpl( + _$InscriptionItemImpl _value, $Res Function(_$InscriptionItemImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -119,7 +119,7 @@ class __$$_InscriptionItemCopyWithImpl<$Res> Object? number = freezed, Object? num = freezed, }) { - return _then(_$_InscriptionItem( + return _then(_$InscriptionItemImpl( id: null == id ? _value.id : id // ignore: cast_nullable_to_non_nullable @@ -142,12 +142,15 @@ class __$$_InscriptionItemCopyWithImpl<$Res> /// @nodoc @JsonSerializable() -class _$_InscriptionItem implements _InscriptionItem { - _$_InscriptionItem( - {required this.id, required this.detail, this.number, this.num}); +class _$InscriptionItemImpl implements _InscriptionItem { + const _$InscriptionItemImpl( + {required this.id, + required this.detail, + required this.number, + required this.num}); - factory _$_InscriptionItem.fromJson(Map json) => - _$$_InscriptionItemFromJson(json); + factory _$InscriptionItemImpl.fromJson(Map json) => + _$$InscriptionItemImplFromJson(json); @override final String id; @@ -164,10 +167,10 @@ class _$_InscriptionItem implements _InscriptionItem { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_InscriptionItem && + other is _$InscriptionItemImpl && (identical(other.id, id) || other.id == id) && (identical(other.detail, detail) || other.detail == detail) && (identical(other.number, number) || other.number == number) && @@ -181,26 +184,27 @@ class _$_InscriptionItem implements _InscriptionItem { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_InscriptionItemCopyWith<_$_InscriptionItem> get copyWith => - __$$_InscriptionItemCopyWithImpl<_$_InscriptionItem>(this, _$identity); + _$$InscriptionItemImplCopyWith<_$InscriptionItemImpl> get copyWith => + __$$InscriptionItemImplCopyWithImpl<_$InscriptionItemImpl>( + this, _$identity); @override Map toJson() { - return _$$_InscriptionItemToJson( + return _$$InscriptionItemImplToJson( this, ); } } abstract class _InscriptionItem implements InscriptionItem { - factory _InscriptionItem( + const factory _InscriptionItem( {required final String id, required final InscriptionDetail detail, - final int? number, - final int? num}) = _$_InscriptionItem; + required final int? number, + required final int? num}) = _$InscriptionItemImpl; factory _InscriptionItem.fromJson(Map json) = - _$_InscriptionItem.fromJson; + _$InscriptionItemImpl.fromJson; @override String get id; @@ -212,6 +216,6 @@ abstract class _InscriptionItem implements InscriptionItem { int? get num; @override @JsonKey(ignore: true) - _$$_InscriptionItemCopyWith<_$_InscriptionItem> get copyWith => + _$$InscriptionItemImplCopyWith<_$InscriptionItemImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.g.dart b/packages/agent_dart_base/lib/agent/ord/inscription_item.g.dart similarity index 60% rename from packages/agent_dart_base/lib/agent/ord/inscriptionItem.g.dart rename to packages/agent_dart_base/lib/agent/ord/inscription_item.g.dart index ac72dce5..d7ee56fb 100644 --- a/packages/agent_dart_base/lib/agent/ord/inscriptionItem.g.dart +++ b/packages/agent_dart_base/lib/agent/ord/inscription_item.g.dart @@ -1,21 +1,23 @@ // GENERATED CODE - DO NOT MODIFY BY HAND -part of 'inscriptionItem.dart'; +part of 'inscription_item.dart'; // ************************************************************************** // JsonSerializableGenerator // ************************************************************************** -_$_InscriptionItem _$$_InscriptionItemFromJson(Map json) => - _$_InscriptionItem( +_$InscriptionItemImpl _$$InscriptionItemImplFromJson( + Map json) => + _$InscriptionItemImpl( id: json['id'] as String, detail: InscriptionDetail.fromJson(json['detail'] as Map), - number: json['number'] as int?, - num: json['num'] as int?, + number: (json['number'] as num?)?.toInt(), + num: (json['num'] as num?)?.toInt(), ); -Map _$$_InscriptionItemToJson(_$_InscriptionItem instance) => +Map _$$InscriptionItemImplToJson( + _$InscriptionItemImpl instance) => { 'id': instance.id, 'detail': instance.detail, diff --git a/packages/agent_dart_base/lib/agent/ord/service.dart b/packages/agent_dart_base/lib/agent/ord/service.dart index 50ed4868..423fd14c 100644 --- a/packages/agent_dart_base/lib/agent/ord/service.dart +++ b/packages/agent_dart_base/lib/agent/ord/service.dart @@ -1,7 +1,7 @@ import 'dart:convert'; import 'package:agent_dart_base/agent/agent.dart'; -import 'package:agent_dart_base/agent/ord/inscriptionItem.dart'; +import 'package:agent_dart_base/agent/ord/inscription_item.dart'; import 'package:agent_dart_base/agent/ord/utxo.dart'; import 'client.dart'; diff --git a/packages/agent_dart_base/lib/agent/ord/tx.dart b/packages/agent_dart_base/lib/agent/ord/tx.dart index 705b580a..9edfb6fb 100644 --- a/packages/agent_dart_base/lib/agent/ord/tx.dart +++ b/packages/agent_dart_base/lib/agent/ord/tx.dart @@ -14,14 +14,14 @@ import 'package:freezed_annotation/freezed_annotation.dart'; -import 'addressUtxo.dart'; +import 'address_utxo.dart'; part 'tx.freezed.dart'; part 'tx.g.dart'; -@unfreezed +@freezed class Tx with _$Tx { - factory Tx({ + const factory Tx({ required String txid, required int version, required int locktime, @@ -36,17 +36,17 @@ class Tx with _$Tx { factory Tx.fromJson(Map json) => _$TxFromJson(json); } -@unfreezed +@freezed class Vin with _$Vin { - factory Vin({ - required String txid, - required int vout, - required Vout prevout, - required String scriptsig, - required String scriptsig_asm, - required List witness, - required bool is_coinbase, - required int sequence, + const factory Vin({ + @JsonKey(name: 'txid') required String txid, + @JsonKey(name: 'vout') required int vout, + @JsonKey(name: 'prevout') required Vout prevout, + @JsonKey(name: 'scriptsig') required String scriptSig, + @JsonKey(name: 'scriptsig_asm') required String scriptsigAsm, + @JsonKey(name: 'witness') required List witness, + @JsonKey(name: 'is_coinbase') required bool isCoinbase, + @JsonKey(name: 'sequence') required int sequence, }) = _Vin; factory Vin.fromJson(Map json) => _$VinFromJson(json); @@ -54,12 +54,12 @@ class Vin with _$Vin { @freezed class Vout with _$Vout { - factory Vout({ - required String scriptpubkey, - required String scriptpubkey_asm, - required String scriptpubkey_type, - required String scriptpubkey_address, - required int value, + const factory Vout({ + @JsonKey(name: 'scriptpubkey') required String scriptPubkey, + @JsonKey(name: 'scriptpubkey_asm') required String scriptpubkeyAsm, + @JsonKey(name: 'scriptpubkey_type') required String scriptpubkeyType, + @JsonKey(name: 'scriptpubkey_address') required String scriptpubkeyAddress, + @JsonKey(name: 'value') required int value, }) = _Vout; factory Vout.fromJson(Map json) => _$VoutFromJson(json); diff --git a/packages/agent_dart_base/lib/agent/ord/tx.freezed.dart b/packages/agent_dart_base/lib/agent/ord/tx.freezed.dart index 12c84a24..41e4b21e 100644 --- a/packages/agent_dart_base/lib/agent/ord/tx.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/tx.freezed.dart @@ -12,7 +12,7 @@ part of 'tx.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); Tx _$TxFromJson(Map json) { return _Tx.fromJson(json); @@ -21,23 +21,14 @@ Tx _$TxFromJson(Map json) { /// @nodoc mixin _$Tx { String get txid => throw _privateConstructorUsedError; - set txid(String value) => throw _privateConstructorUsedError; int get version => throw _privateConstructorUsedError; - set version(int value) => throw _privateConstructorUsedError; int get locktime => throw _privateConstructorUsedError; - set locktime(int value) => throw _privateConstructorUsedError; List get vin => throw _privateConstructorUsedError; - set vin(List value) => throw _privateConstructorUsedError; List get vout => throw _privateConstructorUsedError; - set vout(List value) => throw _privateConstructorUsedError; int get size => throw _privateConstructorUsedError; - set size(int value) => throw _privateConstructorUsedError; int get weight => throw _privateConstructorUsedError; - set weight(int value) => throw _privateConstructorUsedError; int get fee => throw _privateConstructorUsedError; - set fee(int value) => throw _privateConstructorUsedError; TxStatus get status => throw _privateConstructorUsedError; - set status(TxStatus value) => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -135,9 +126,9 @@ class _$TxCopyWithImpl<$Res, $Val extends Tx> implements $TxCopyWith<$Res> { } /// @nodoc -abstract class _$$_TxCopyWith<$Res> implements $TxCopyWith<$Res> { - factory _$$_TxCopyWith(_$_Tx value, $Res Function(_$_Tx) then) = - __$$_TxCopyWithImpl<$Res>; +abstract class _$$TxImplCopyWith<$Res> implements $TxCopyWith<$Res> { + factory _$$TxImplCopyWith(_$TxImpl value, $Res Function(_$TxImpl) then) = + __$$TxImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -156,9 +147,9 @@ abstract class _$$_TxCopyWith<$Res> implements $TxCopyWith<$Res> { } /// @nodoc -class __$$_TxCopyWithImpl<$Res> extends _$TxCopyWithImpl<$Res, _$_Tx> - implements _$$_TxCopyWith<$Res> { - __$$_TxCopyWithImpl(_$_Tx _value, $Res Function(_$_Tx) _then) +class __$$TxImplCopyWithImpl<$Res> extends _$TxCopyWithImpl<$Res, _$TxImpl> + implements _$$TxImplCopyWith<$Res> { + __$$TxImplCopyWithImpl(_$TxImpl _value, $Res Function(_$TxImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -174,7 +165,7 @@ class __$$_TxCopyWithImpl<$Res> extends _$TxCopyWithImpl<$Res, _$_Tx> Object? fee = null, Object? status = null, }) { - return _then(_$_Tx( + return _then(_$TxImpl( txid: null == txid ? _value.txid : txid // ignore: cast_nullable_to_non_nullable @@ -188,11 +179,11 @@ class __$$_TxCopyWithImpl<$Res> extends _$TxCopyWithImpl<$Res, _$_Tx> : locktime // ignore: cast_nullable_to_non_nullable as int, vin: null == vin - ? _value.vin + ? _value._vin : vin // ignore: cast_nullable_to_non_nullable as List, vout: null == vout - ? _value.vout + ? _value._vout : vout // ignore: cast_nullable_to_non_nullable as List, size: null == size @@ -217,102 +208,140 @@ class __$$_TxCopyWithImpl<$Res> extends _$TxCopyWithImpl<$Res, _$_Tx> /// @nodoc @JsonSerializable() -class _$_Tx implements _Tx { - _$_Tx( +class _$TxImpl implements _Tx { + const _$TxImpl( {required this.txid, required this.version, required this.locktime, - required this.vin, - required this.vout, + required final List vin, + required final List vout, required this.size, required this.weight, required this.fee, - required this.status}); + required this.status}) + : _vin = vin, + _vout = vout; - factory _$_Tx.fromJson(Map json) => _$$_TxFromJson(json); + factory _$TxImpl.fromJson(Map json) => + _$$TxImplFromJson(json); @override - String txid; + final String txid; @override - int version; + final int version; @override - int locktime; + final int locktime; + final List _vin; @override - List vin; + List get vin { + if (_vin is EqualUnmodifiableListView) return _vin; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_vin); + } + + final List _vout; @override - List vout; + List get vout { + if (_vout is EqualUnmodifiableListView) return _vout; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_vout); + } + @override - int size; + final int size; @override - int weight; + final int weight; @override - int fee; + final int fee; @override - TxStatus status; + final TxStatus status; @override String toString() { return 'Tx(txid: $txid, version: $version, locktime: $locktime, vin: $vin, vout: $vout, size: $size, weight: $weight, fee: $fee, status: $status)'; } + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$TxImpl && + (identical(other.txid, txid) || other.txid == txid) && + (identical(other.version, version) || other.version == version) && + (identical(other.locktime, locktime) || + other.locktime == locktime) && + const DeepCollectionEquality().equals(other._vin, _vin) && + const DeepCollectionEquality().equals(other._vout, _vout) && + (identical(other.size, size) || other.size == size) && + (identical(other.weight, weight) || other.weight == weight) && + (identical(other.fee, fee) || other.fee == fee) && + (identical(other.status, status) || other.status == status)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + txid, + version, + locktime, + const DeepCollectionEquality().hash(_vin), + const DeepCollectionEquality().hash(_vout), + size, + weight, + fee, + status); + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_TxCopyWith<_$_Tx> get copyWith => - __$$_TxCopyWithImpl<_$_Tx>(this, _$identity); + _$$TxImplCopyWith<_$TxImpl> get copyWith => + __$$TxImplCopyWithImpl<_$TxImpl>(this, _$identity); @override Map toJson() { - return _$$_TxToJson( + return _$$TxImplToJson( this, ); } } abstract class _Tx implements Tx { - factory _Tx( - {required String txid, - required int version, - required int locktime, - required List vin, - required List vout, - required int size, - required int weight, - required int fee, - required TxStatus status}) = _$_Tx; + const factory _Tx( + {required final String txid, + required final int version, + required final int locktime, + required final List vin, + required final List vout, + required final int size, + required final int weight, + required final int fee, + required final TxStatus status}) = _$TxImpl; - factory _Tx.fromJson(Map json) = _$_Tx.fromJson; + factory _Tx.fromJson(Map json) = _$TxImpl.fromJson; @override String get txid; - set txid(String value); @override int get version; - set version(int value); @override int get locktime; - set locktime(int value); @override List get vin; - set vin(List value); @override List get vout; - set vout(List value); @override int get size; - set size(int value); @override int get weight; - set weight(int value); @override int get fee; - set fee(int value); @override TxStatus get status; - set status(TxStatus value); @override @JsonKey(ignore: true) - _$$_TxCopyWith<_$_Tx> get copyWith => throw _privateConstructorUsedError; + _$$TxImplCopyWith<_$TxImpl> get copyWith => + throw _privateConstructorUsedError; } Vin _$VinFromJson(Map json) { @@ -321,22 +350,22 @@ Vin _$VinFromJson(Map json) { /// @nodoc mixin _$Vin { + @JsonKey(name: 'txid') String get txid => throw _privateConstructorUsedError; - set txid(String value) => throw _privateConstructorUsedError; + @JsonKey(name: 'vout') int get vout => throw _privateConstructorUsedError; - set vout(int value) => throw _privateConstructorUsedError; + @JsonKey(name: 'prevout') Vout get prevout => throw _privateConstructorUsedError; - set prevout(Vout value) => throw _privateConstructorUsedError; - String get scriptsig => throw _privateConstructorUsedError; - set scriptsig(String value) => throw _privateConstructorUsedError; - String get scriptsig_asm => throw _privateConstructorUsedError; - set scriptsig_asm(String value) => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptsig') + String get scriptSig => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptsig_asm') + String get scriptsigAsm => throw _privateConstructorUsedError; + @JsonKey(name: 'witness') List get witness => throw _privateConstructorUsedError; - set witness(List value) => throw _privateConstructorUsedError; - bool get is_coinbase => throw _privateConstructorUsedError; - set is_coinbase(bool value) => throw _privateConstructorUsedError; + @JsonKey(name: 'is_coinbase') + bool get isCoinbase => throw _privateConstructorUsedError; + @JsonKey(name: 'sequence') int get sequence => throw _privateConstructorUsedError; - set sequence(int value) => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -349,14 +378,14 @@ abstract class $VinCopyWith<$Res> { _$VinCopyWithImpl<$Res, Vin>; @useResult $Res call( - {String txid, - int vout, - Vout prevout, - String scriptsig, - String scriptsig_asm, - List witness, - bool is_coinbase, - int sequence}); + {@JsonKey(name: 'txid') String txid, + @JsonKey(name: 'vout') int vout, + @JsonKey(name: 'prevout') Vout prevout, + @JsonKey(name: 'scriptsig') String scriptSig, + @JsonKey(name: 'scriptsig_asm') String scriptsigAsm, + @JsonKey(name: 'witness') List witness, + @JsonKey(name: 'is_coinbase') bool isCoinbase, + @JsonKey(name: 'sequence') int sequence}); $VoutCopyWith<$Res> get prevout; } @@ -376,10 +405,10 @@ class _$VinCopyWithImpl<$Res, $Val extends Vin> implements $VinCopyWith<$Res> { Object? txid = null, Object? vout = null, Object? prevout = null, - Object? scriptsig = null, - Object? scriptsig_asm = null, + Object? scriptSig = null, + Object? scriptsigAsm = null, Object? witness = null, - Object? is_coinbase = null, + Object? isCoinbase = null, Object? sequence = null, }) { return _then(_value.copyWith( @@ -395,21 +424,21 @@ class _$VinCopyWithImpl<$Res, $Val extends Vin> implements $VinCopyWith<$Res> { ? _value.prevout : prevout // ignore: cast_nullable_to_non_nullable as Vout, - scriptsig: null == scriptsig - ? _value.scriptsig - : scriptsig // ignore: cast_nullable_to_non_nullable + scriptSig: null == scriptSig + ? _value.scriptSig + : scriptSig // ignore: cast_nullable_to_non_nullable as String, - scriptsig_asm: null == scriptsig_asm - ? _value.scriptsig_asm - : scriptsig_asm // ignore: cast_nullable_to_non_nullable + scriptsigAsm: null == scriptsigAsm + ? _value.scriptsigAsm + : scriptsigAsm // ignore: cast_nullable_to_non_nullable as String, witness: null == witness ? _value.witness : witness // ignore: cast_nullable_to_non_nullable as List, - is_coinbase: null == is_coinbase - ? _value.is_coinbase - : is_coinbase // ignore: cast_nullable_to_non_nullable + isCoinbase: null == isCoinbase + ? _value.isCoinbase + : isCoinbase // ignore: cast_nullable_to_non_nullable as bool, sequence: null == sequence ? _value.sequence @@ -428,29 +457,29 @@ class _$VinCopyWithImpl<$Res, $Val extends Vin> implements $VinCopyWith<$Res> { } /// @nodoc -abstract class _$$_VinCopyWith<$Res> implements $VinCopyWith<$Res> { - factory _$$_VinCopyWith(_$_Vin value, $Res Function(_$_Vin) then) = - __$$_VinCopyWithImpl<$Res>; +abstract class _$$VinImplCopyWith<$Res> implements $VinCopyWith<$Res> { + factory _$$VinImplCopyWith(_$VinImpl value, $Res Function(_$VinImpl) then) = + __$$VinImplCopyWithImpl<$Res>; @override @useResult $Res call( - {String txid, - int vout, - Vout prevout, - String scriptsig, - String scriptsig_asm, - List witness, - bool is_coinbase, - int sequence}); + {@JsonKey(name: 'txid') String txid, + @JsonKey(name: 'vout') int vout, + @JsonKey(name: 'prevout') Vout prevout, + @JsonKey(name: 'scriptsig') String scriptSig, + @JsonKey(name: 'scriptsig_asm') String scriptsigAsm, + @JsonKey(name: 'witness') List witness, + @JsonKey(name: 'is_coinbase') bool isCoinbase, + @JsonKey(name: 'sequence') int sequence}); @override $VoutCopyWith<$Res> get prevout; } /// @nodoc -class __$$_VinCopyWithImpl<$Res> extends _$VinCopyWithImpl<$Res, _$_Vin> - implements _$$_VinCopyWith<$Res> { - __$$_VinCopyWithImpl(_$_Vin _value, $Res Function(_$_Vin) _then) +class __$$VinImplCopyWithImpl<$Res> extends _$VinCopyWithImpl<$Res, _$VinImpl> + implements _$$VinImplCopyWith<$Res> { + __$$VinImplCopyWithImpl(_$VinImpl _value, $Res Function(_$VinImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -459,13 +488,13 @@ class __$$_VinCopyWithImpl<$Res> extends _$VinCopyWithImpl<$Res, _$_Vin> Object? txid = null, Object? vout = null, Object? prevout = null, - Object? scriptsig = null, - Object? scriptsig_asm = null, + Object? scriptSig = null, + Object? scriptsigAsm = null, Object? witness = null, - Object? is_coinbase = null, + Object? isCoinbase = null, Object? sequence = null, }) { - return _then(_$_Vin( + return _then(_$VinImpl( txid: null == txid ? _value.txid : txid // ignore: cast_nullable_to_non_nullable @@ -478,21 +507,21 @@ class __$$_VinCopyWithImpl<$Res> extends _$VinCopyWithImpl<$Res, _$_Vin> ? _value.prevout : prevout // ignore: cast_nullable_to_non_nullable as Vout, - scriptsig: null == scriptsig - ? _value.scriptsig - : scriptsig // ignore: cast_nullable_to_non_nullable + scriptSig: null == scriptSig + ? _value.scriptSig + : scriptSig // ignore: cast_nullable_to_non_nullable as String, - scriptsig_asm: null == scriptsig_asm - ? _value.scriptsig_asm - : scriptsig_asm // ignore: cast_nullable_to_non_nullable + scriptsigAsm: null == scriptsigAsm + ? _value.scriptsigAsm + : scriptsigAsm // ignore: cast_nullable_to_non_nullable as String, witness: null == witness - ? _value.witness + ? _value._witness : witness // ignore: cast_nullable_to_non_nullable as List, - is_coinbase: null == is_coinbase - ? _value.is_coinbase - : is_coinbase // ignore: cast_nullable_to_non_nullable + isCoinbase: null == isCoinbase + ? _value.isCoinbase + : isCoinbase // ignore: cast_nullable_to_non_nullable as bool, sequence: null == sequence ? _value.sequence @@ -504,95 +533,144 @@ class __$$_VinCopyWithImpl<$Res> extends _$VinCopyWithImpl<$Res, _$_Vin> /// @nodoc @JsonSerializable() -class _$_Vin implements _Vin { - _$_Vin( - {required this.txid, - required this.vout, - required this.prevout, - required this.scriptsig, - required this.scriptsig_asm, - required this.witness, - required this.is_coinbase, - required this.sequence}); - - factory _$_Vin.fromJson(Map json) => _$$_VinFromJson(json); +class _$VinImpl implements _Vin { + const _$VinImpl( + {@JsonKey(name: 'txid') required this.txid, + @JsonKey(name: 'vout') required this.vout, + @JsonKey(name: 'prevout') required this.prevout, + @JsonKey(name: 'scriptsig') required this.scriptSig, + @JsonKey(name: 'scriptsig_asm') required this.scriptsigAsm, + @JsonKey(name: 'witness') required final List witness, + @JsonKey(name: 'is_coinbase') required this.isCoinbase, + @JsonKey(name: 'sequence') required this.sequence}) + : _witness = witness; + + factory _$VinImpl.fromJson(Map json) => + _$$VinImplFromJson(json); + + @override + @JsonKey(name: 'txid') + final String txid; + @override + @JsonKey(name: 'vout') + final int vout; + @override + @JsonKey(name: 'prevout') + final Vout prevout; + @override + @JsonKey(name: 'scriptsig') + final String scriptSig; + @override + @JsonKey(name: 'scriptsig_asm') + final String scriptsigAsm; + final List _witness; + @override + @JsonKey(name: 'witness') + List get witness { + if (_witness is EqualUnmodifiableListView) return _witness; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_witness); + } @override - String txid; - @override - int vout; - @override - Vout prevout; - @override - String scriptsig; - @override - String scriptsig_asm; - @override - List witness; - @override - bool is_coinbase; + @JsonKey(name: 'is_coinbase') + final bool isCoinbase; @override - int sequence; + @JsonKey(name: 'sequence') + final int sequence; @override String toString() { - return 'Vin(txid: $txid, vout: $vout, prevout: $prevout, scriptsig: $scriptsig, scriptsig_asm: $scriptsig_asm, witness: $witness, is_coinbase: $is_coinbase, sequence: $sequence)'; + return 'Vin(txid: $txid, vout: $vout, prevout: $prevout, scriptSig: $scriptSig, scriptsigAsm: $scriptsigAsm, witness: $witness, isCoinbase: $isCoinbase, sequence: $sequence)'; } + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$VinImpl && + (identical(other.txid, txid) || other.txid == txid) && + (identical(other.vout, vout) || other.vout == vout) && + (identical(other.prevout, prevout) || other.prevout == prevout) && + (identical(other.scriptSig, scriptSig) || + other.scriptSig == scriptSig) && + (identical(other.scriptsigAsm, scriptsigAsm) || + other.scriptsigAsm == scriptsigAsm) && + const DeepCollectionEquality().equals(other._witness, _witness) && + (identical(other.isCoinbase, isCoinbase) || + other.isCoinbase == isCoinbase) && + (identical(other.sequence, sequence) || + other.sequence == sequence)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + txid, + vout, + prevout, + scriptSig, + scriptsigAsm, + const DeepCollectionEquality().hash(_witness), + isCoinbase, + sequence); + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_VinCopyWith<_$_Vin> get copyWith => - __$$_VinCopyWithImpl<_$_Vin>(this, _$identity); + _$$VinImplCopyWith<_$VinImpl> get copyWith => + __$$VinImplCopyWithImpl<_$VinImpl>(this, _$identity); @override Map toJson() { - return _$$_VinToJson( + return _$$VinImplToJson( this, ); } } abstract class _Vin implements Vin { - factory _Vin( - {required String txid, - required int vout, - required Vout prevout, - required String scriptsig, - required String scriptsig_asm, - required List witness, - required bool is_coinbase, - required int sequence}) = _$_Vin; + const factory _Vin( + {@JsonKey(name: 'txid') required final String txid, + @JsonKey(name: 'vout') required final int vout, + @JsonKey(name: 'prevout') required final Vout prevout, + @JsonKey(name: 'scriptsig') required final String scriptSig, + @JsonKey(name: 'scriptsig_asm') required final String scriptsigAsm, + @JsonKey(name: 'witness') required final List witness, + @JsonKey(name: 'is_coinbase') required final bool isCoinbase, + @JsonKey(name: 'sequence') required final int sequence}) = _$VinImpl; - factory _Vin.fromJson(Map json) = _$_Vin.fromJson; + factory _Vin.fromJson(Map json) = _$VinImpl.fromJson; @override + @JsonKey(name: 'txid') String get txid; - set txid(String value); @override + @JsonKey(name: 'vout') int get vout; - set vout(int value); @override + @JsonKey(name: 'prevout') Vout get prevout; - set prevout(Vout value); @override - String get scriptsig; - set scriptsig(String value); + @JsonKey(name: 'scriptsig') + String get scriptSig; @override - String get scriptsig_asm; - set scriptsig_asm(String value); + @JsonKey(name: 'scriptsig_asm') + String get scriptsigAsm; @override + @JsonKey(name: 'witness') List get witness; - set witness(List value); @override - bool get is_coinbase; - set is_coinbase(bool value); + @JsonKey(name: 'is_coinbase') + bool get isCoinbase; @override + @JsonKey(name: 'sequence') int get sequence; - set sequence(int value); @override @JsonKey(ignore: true) - _$$_VinCopyWith<_$_Vin> get copyWith => throw _privateConstructorUsedError; + _$$VinImplCopyWith<_$VinImpl> get copyWith => + throw _privateConstructorUsedError; } Vout _$VoutFromJson(Map json) { @@ -601,10 +679,15 @@ Vout _$VoutFromJson(Map json) { /// @nodoc mixin _$Vout { - String get scriptpubkey => throw _privateConstructorUsedError; - String get scriptpubkey_asm => throw _privateConstructorUsedError; - String get scriptpubkey_type => throw _privateConstructorUsedError; - String get scriptpubkey_address => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptpubkey') + String get scriptPubkey => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptpubkey_asm') + String get scriptpubkeyAsm => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptpubkey_type') + String get scriptpubkeyType => throw _privateConstructorUsedError; + @JsonKey(name: 'scriptpubkey_address') + String get scriptpubkeyAddress => throw _privateConstructorUsedError; + @JsonKey(name: 'value') int get value => throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @@ -618,11 +701,11 @@ abstract class $VoutCopyWith<$Res> { _$VoutCopyWithImpl<$Res, Vout>; @useResult $Res call( - {String scriptpubkey, - String scriptpubkey_asm, - String scriptpubkey_type, - String scriptpubkey_address, - int value}); + {@JsonKey(name: 'scriptpubkey') String scriptPubkey, + @JsonKey(name: 'scriptpubkey_asm') String scriptpubkeyAsm, + @JsonKey(name: 'scriptpubkey_type') String scriptpubkeyType, + @JsonKey(name: 'scriptpubkey_address') String scriptpubkeyAddress, + @JsonKey(name: 'value') int value}); } /// @nodoc @@ -638,28 +721,28 @@ class _$VoutCopyWithImpl<$Res, $Val extends Vout> @pragma('vm:prefer-inline') @override $Res call({ - Object? scriptpubkey = null, - Object? scriptpubkey_asm = null, - Object? scriptpubkey_type = null, - Object? scriptpubkey_address = null, + Object? scriptPubkey = null, + Object? scriptpubkeyAsm = null, + Object? scriptpubkeyType = null, + Object? scriptpubkeyAddress = null, Object? value = null, }) { return _then(_value.copyWith( - scriptpubkey: null == scriptpubkey - ? _value.scriptpubkey - : scriptpubkey // ignore: cast_nullable_to_non_nullable + scriptPubkey: null == scriptPubkey + ? _value.scriptPubkey + : scriptPubkey // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_asm: null == scriptpubkey_asm - ? _value.scriptpubkey_asm - : scriptpubkey_asm // ignore: cast_nullable_to_non_nullable + scriptpubkeyAsm: null == scriptpubkeyAsm + ? _value.scriptpubkeyAsm + : scriptpubkeyAsm // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_type: null == scriptpubkey_type - ? _value.scriptpubkey_type - : scriptpubkey_type // ignore: cast_nullable_to_non_nullable + scriptpubkeyType: null == scriptpubkeyType + ? _value.scriptpubkeyType + : scriptpubkeyType // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_address: null == scriptpubkey_address - ? _value.scriptpubkey_address - : scriptpubkey_address // ignore: cast_nullable_to_non_nullable + scriptpubkeyAddress: null == scriptpubkeyAddress + ? _value.scriptpubkeyAddress + : scriptpubkeyAddress // ignore: cast_nullable_to_non_nullable as String, value: null == value ? _value.value @@ -670,50 +753,52 @@ class _$VoutCopyWithImpl<$Res, $Val extends Vout> } /// @nodoc -abstract class _$$_VoutCopyWith<$Res> implements $VoutCopyWith<$Res> { - factory _$$_VoutCopyWith(_$_Vout value, $Res Function(_$_Vout) then) = - __$$_VoutCopyWithImpl<$Res>; +abstract class _$$VoutImplCopyWith<$Res> implements $VoutCopyWith<$Res> { + factory _$$VoutImplCopyWith( + _$VoutImpl value, $Res Function(_$VoutImpl) then) = + __$$VoutImplCopyWithImpl<$Res>; @override @useResult $Res call( - {String scriptpubkey, - String scriptpubkey_asm, - String scriptpubkey_type, - String scriptpubkey_address, - int value}); + {@JsonKey(name: 'scriptpubkey') String scriptPubkey, + @JsonKey(name: 'scriptpubkey_asm') String scriptpubkeyAsm, + @JsonKey(name: 'scriptpubkey_type') String scriptpubkeyType, + @JsonKey(name: 'scriptpubkey_address') String scriptpubkeyAddress, + @JsonKey(name: 'value') int value}); } /// @nodoc -class __$$_VoutCopyWithImpl<$Res> extends _$VoutCopyWithImpl<$Res, _$_Vout> - implements _$$_VoutCopyWith<$Res> { - __$$_VoutCopyWithImpl(_$_Vout _value, $Res Function(_$_Vout) _then) +class __$$VoutImplCopyWithImpl<$Res> + extends _$VoutCopyWithImpl<$Res, _$VoutImpl> + implements _$$VoutImplCopyWith<$Res> { + __$$VoutImplCopyWithImpl(_$VoutImpl _value, $Res Function(_$VoutImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @override $Res call({ - Object? scriptpubkey = null, - Object? scriptpubkey_asm = null, - Object? scriptpubkey_type = null, - Object? scriptpubkey_address = null, + Object? scriptPubkey = null, + Object? scriptpubkeyAsm = null, + Object? scriptpubkeyType = null, + Object? scriptpubkeyAddress = null, Object? value = null, }) { - return _then(_$_Vout( - scriptpubkey: null == scriptpubkey - ? _value.scriptpubkey - : scriptpubkey // ignore: cast_nullable_to_non_nullable + return _then(_$VoutImpl( + scriptPubkey: null == scriptPubkey + ? _value.scriptPubkey + : scriptPubkey // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_asm: null == scriptpubkey_asm - ? _value.scriptpubkey_asm - : scriptpubkey_asm // ignore: cast_nullable_to_non_nullable + scriptpubkeyAsm: null == scriptpubkeyAsm + ? _value.scriptpubkeyAsm + : scriptpubkeyAsm // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_type: null == scriptpubkey_type - ? _value.scriptpubkey_type - : scriptpubkey_type // ignore: cast_nullable_to_non_nullable + scriptpubkeyType: null == scriptpubkeyType + ? _value.scriptpubkeyType + : scriptpubkeyType // ignore: cast_nullable_to_non_nullable as String, - scriptpubkey_address: null == scriptpubkey_address - ? _value.scriptpubkey_address - : scriptpubkey_address // ignore: cast_nullable_to_non_nullable + scriptpubkeyAddress: null == scriptpubkeyAddress + ? _value.scriptpubkeyAddress + : scriptpubkeyAddress // ignore: cast_nullable_to_non_nullable as String, value: null == value ? _value.value @@ -725,88 +810,102 @@ class __$$_VoutCopyWithImpl<$Res> extends _$VoutCopyWithImpl<$Res, _$_Vout> /// @nodoc @JsonSerializable() -class _$_Vout implements _Vout { - _$_Vout( - {required this.scriptpubkey, - required this.scriptpubkey_asm, - required this.scriptpubkey_type, - required this.scriptpubkey_address, - required this.value}); +class _$VoutImpl implements _Vout { + const _$VoutImpl( + {@JsonKey(name: 'scriptpubkey') required this.scriptPubkey, + @JsonKey(name: 'scriptpubkey_asm') required this.scriptpubkeyAsm, + @JsonKey(name: 'scriptpubkey_type') required this.scriptpubkeyType, + @JsonKey(name: 'scriptpubkey_address') required this.scriptpubkeyAddress, + @JsonKey(name: 'value') required this.value}); - factory _$_Vout.fromJson(Map json) => _$$_VoutFromJson(json); + factory _$VoutImpl.fromJson(Map json) => + _$$VoutImplFromJson(json); @override - final String scriptpubkey; + @JsonKey(name: 'scriptpubkey') + final String scriptPubkey; @override - final String scriptpubkey_asm; + @JsonKey(name: 'scriptpubkey_asm') + final String scriptpubkeyAsm; @override - final String scriptpubkey_type; + @JsonKey(name: 'scriptpubkey_type') + final String scriptpubkeyType; @override - final String scriptpubkey_address; + @JsonKey(name: 'scriptpubkey_address') + final String scriptpubkeyAddress; @override + @JsonKey(name: 'value') final int value; @override String toString() { - return 'Vout(scriptpubkey: $scriptpubkey, scriptpubkey_asm: $scriptpubkey_asm, scriptpubkey_type: $scriptpubkey_type, scriptpubkey_address: $scriptpubkey_address, value: $value)'; + return 'Vout(scriptPubkey: $scriptPubkey, scriptpubkeyAsm: $scriptpubkeyAsm, scriptpubkeyType: $scriptpubkeyType, scriptpubkeyAddress: $scriptpubkeyAddress, value: $value)'; } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$_Vout && - (identical(other.scriptpubkey, scriptpubkey) || - other.scriptpubkey == scriptpubkey) && - (identical(other.scriptpubkey_asm, scriptpubkey_asm) || - other.scriptpubkey_asm == scriptpubkey_asm) && - (identical(other.scriptpubkey_type, scriptpubkey_type) || - other.scriptpubkey_type == scriptpubkey_type) && - (identical(other.scriptpubkey_address, scriptpubkey_address) || - other.scriptpubkey_address == scriptpubkey_address) && + other is _$VoutImpl && + (identical(other.scriptPubkey, scriptPubkey) || + other.scriptPubkey == scriptPubkey) && + (identical(other.scriptpubkeyAsm, scriptpubkeyAsm) || + other.scriptpubkeyAsm == scriptpubkeyAsm) && + (identical(other.scriptpubkeyType, scriptpubkeyType) || + other.scriptpubkeyType == scriptpubkeyType) && + (identical(other.scriptpubkeyAddress, scriptpubkeyAddress) || + other.scriptpubkeyAddress == scriptpubkeyAddress) && (identical(other.value, value) || other.value == value)); } @JsonKey(ignore: true) @override - int get hashCode => Object.hash(runtimeType, scriptpubkey, scriptpubkey_asm, - scriptpubkey_type, scriptpubkey_address, value); + int get hashCode => Object.hash(runtimeType, scriptPubkey, scriptpubkeyAsm, + scriptpubkeyType, scriptpubkeyAddress, value); @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_VoutCopyWith<_$_Vout> get copyWith => - __$$_VoutCopyWithImpl<_$_Vout>(this, _$identity); + _$$VoutImplCopyWith<_$VoutImpl> get copyWith => + __$$VoutImplCopyWithImpl<_$VoutImpl>(this, _$identity); @override Map toJson() { - return _$$_VoutToJson( + return _$$VoutImplToJson( this, ); } } abstract class _Vout implements Vout { - factory _Vout( - {required final String scriptpubkey, - required final String scriptpubkey_asm, - required final String scriptpubkey_type, - required final String scriptpubkey_address, - required final int value}) = _$_Vout; + const factory _Vout( + {@JsonKey(name: 'scriptpubkey') required final String scriptPubkey, + @JsonKey(name: 'scriptpubkey_asm') required final String scriptpubkeyAsm, + @JsonKey(name: 'scriptpubkey_type') + required final String scriptpubkeyType, + @JsonKey(name: 'scriptpubkey_address') + required final String scriptpubkeyAddress, + @JsonKey(name: 'value') required final int value}) = _$VoutImpl; - factory _Vout.fromJson(Map json) = _$_Vout.fromJson; + factory _Vout.fromJson(Map json) = _$VoutImpl.fromJson; @override - String get scriptpubkey; + @JsonKey(name: 'scriptpubkey') + String get scriptPubkey; @override - String get scriptpubkey_asm; + @JsonKey(name: 'scriptpubkey_asm') + String get scriptpubkeyAsm; @override - String get scriptpubkey_type; + @JsonKey(name: 'scriptpubkey_type') + String get scriptpubkeyType; @override - String get scriptpubkey_address; + @JsonKey(name: 'scriptpubkey_address') + String get scriptpubkeyAddress; @override + @JsonKey(name: 'value') int get value; @override @JsonKey(ignore: true) - _$$_VoutCopyWith<_$_Vout> get copyWith => throw _privateConstructorUsedError; + _$$VoutImplCopyWith<_$VoutImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/tx.g.dart b/packages/agent_dart_base/lib/agent/ord/tx.g.dart index c4c43dc1..652fb76d 100644 --- a/packages/agent_dart_base/lib/agent/ord/tx.g.dart +++ b/packages/agent_dart_base/lib/agent/ord/tx.g.dart @@ -6,23 +6,23 @@ part of 'tx.dart'; // JsonSerializableGenerator // ************************************************************************** -_$_Tx _$$_TxFromJson(Map json) => _$_Tx( +_$TxImpl _$$TxImplFromJson(Map json) => _$TxImpl( txid: json['txid'] as String, - version: json['version'] as int, - locktime: json['locktime'] as int, + version: (json['version'] as num).toInt(), + locktime: (json['locktime'] as num).toInt(), vin: (json['vin'] as List) .map((e) => Vin.fromJson(e as Map)) .toList(), vout: (json['vout'] as List) .map((e) => Vout.fromJson(e as Map)) .toList(), - size: json['size'] as int, - weight: json['weight'] as int, - fee: json['fee'] as int, + size: (json['size'] as num).toInt(), + weight: (json['weight'] as num).toInt(), + fee: (json['fee'] as num).toInt(), status: TxStatus.fromJson(json['status'] as Map), ); -Map _$$_TxToJson(_$_Tx instance) => { +Map _$$TxImplToJson(_$TxImpl instance) => { 'txid': instance.txid, 'version': instance.version, 'locktime': instance.locktime, @@ -34,41 +34,42 @@ Map _$$_TxToJson(_$_Tx instance) => { 'status': instance.status, }; -_$_Vin _$$_VinFromJson(Map json) => _$_Vin( +_$VinImpl _$$VinImplFromJson(Map json) => _$VinImpl( txid: json['txid'] as String, - vout: json['vout'] as int, + vout: (json['vout'] as num).toInt(), prevout: Vout.fromJson(json['prevout'] as Map), - scriptsig: json['scriptsig'] as String, - scriptsig_asm: json['scriptsig_asm'] as String, + scriptSig: json['scriptsig'] as String, + scriptsigAsm: json['scriptsig_asm'] as String, witness: (json['witness'] as List).map((e) => e as String).toList(), - is_coinbase: json['is_coinbase'] as bool, - sequence: json['sequence'] as int, + isCoinbase: json['is_coinbase'] as bool, + sequence: (json['sequence'] as num).toInt(), ); -Map _$$_VinToJson(_$_Vin instance) => { +Map _$$VinImplToJson(_$VinImpl instance) => { 'txid': instance.txid, 'vout': instance.vout, 'prevout': instance.prevout, - 'scriptsig': instance.scriptsig, - 'scriptsig_asm': instance.scriptsig_asm, + 'scriptsig': instance.scriptSig, + 'scriptsig_asm': instance.scriptsigAsm, 'witness': instance.witness, - 'is_coinbase': instance.is_coinbase, + 'is_coinbase': instance.isCoinbase, 'sequence': instance.sequence, }; -_$_Vout _$$_VoutFromJson(Map json) => _$_Vout( - scriptpubkey: json['scriptpubkey'] as String, - scriptpubkey_asm: json['scriptpubkey_asm'] as String, - scriptpubkey_type: json['scriptpubkey_type'] as String, - scriptpubkey_address: json['scriptpubkey_address'] as String, - value: json['value'] as int, +_$VoutImpl _$$VoutImplFromJson(Map json) => _$VoutImpl( + scriptPubkey: json['scriptpubkey'] as String, + scriptpubkeyAsm: json['scriptpubkey_asm'] as String, + scriptpubkeyType: json['scriptpubkey_type'] as String, + scriptpubkeyAddress: json['scriptpubkey_address'] as String, + value: (json['value'] as num).toInt(), ); -Map _$$_VoutToJson(_$_Vout instance) => { - 'scriptpubkey': instance.scriptpubkey, - 'scriptpubkey_asm': instance.scriptpubkey_asm, - 'scriptpubkey_type': instance.scriptpubkey_type, - 'scriptpubkey_address': instance.scriptpubkey_address, +Map _$$VoutImplToJson(_$VoutImpl instance) => + { + 'scriptpubkey': instance.scriptPubkey, + 'scriptpubkey_asm': instance.scriptpubkeyAsm, + 'scriptpubkey_type': instance.scriptpubkeyType, + 'scriptpubkey_address': instance.scriptpubkeyAddress, 'value': instance.value, }; diff --git a/packages/agent_dart_base/lib/agent/ord/utxo.dart b/packages/agent_dart_base/lib/agent/ord/utxo.dart index d4da7afd..173ea335 100644 --- a/packages/agent_dart_base/lib/agent/ord/utxo.dart +++ b/packages/agent_dart_base/lib/agent/ord/utxo.dart @@ -5,9 +5,9 @@ import 'inscription.dart'; part 'utxo.freezed.dart'; part 'utxo.g.dart'; -@unfreezed +@freezed class Utxo with _$Utxo { - factory Utxo({ + const factory Utxo({ required String txId, required int outputIndex, required int satoshis, diff --git a/packages/agent_dart_base/lib/agent/ord/utxo.freezed.dart b/packages/agent_dart_base/lib/agent/ord/utxo.freezed.dart index c5e620e7..53b3225a 100644 --- a/packages/agent_dart_base/lib/agent/ord/utxo.freezed.dart +++ b/packages/agent_dart_base/lib/agent/ord/utxo.freezed.dart @@ -12,7 +12,7 @@ part of 'utxo.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); Utxo _$UtxoFromJson(Map json) { return _Utxo.fromJson(json); @@ -21,18 +21,11 @@ Utxo _$UtxoFromJson(Map json) { /// @nodoc mixin _$Utxo { String get txId => throw _privateConstructorUsedError; - set txId(String value) => throw _privateConstructorUsedError; int get outputIndex => throw _privateConstructorUsedError; - set outputIndex(int value) => throw _privateConstructorUsedError; int get satoshis => throw _privateConstructorUsedError; - set satoshis(int value) => throw _privateConstructorUsedError; String get scriptPk => throw _privateConstructorUsedError; - set scriptPk(String value) => throw _privateConstructorUsedError; int get addressType => throw _privateConstructorUsedError; - set addressType(int value) => throw _privateConstructorUsedError; List get inscriptions => throw _privateConstructorUsedError; - set inscriptions(List value) => - throw _privateConstructorUsedError; Map toJson() => throw _privateConstructorUsedError; @JsonKey(ignore: true) @@ -103,9 +96,10 @@ class _$UtxoCopyWithImpl<$Res, $Val extends Utxo> } /// @nodoc -abstract class _$$_UtxoCopyWith<$Res> implements $UtxoCopyWith<$Res> { - factory _$$_UtxoCopyWith(_$_Utxo value, $Res Function(_$_Utxo) then) = - __$$_UtxoCopyWithImpl<$Res>; +abstract class _$$UtxoImplCopyWith<$Res> implements $UtxoCopyWith<$Res> { + factory _$$UtxoImplCopyWith( + _$UtxoImpl value, $Res Function(_$UtxoImpl) then) = + __$$UtxoImplCopyWithImpl<$Res>; @override @useResult $Res call( @@ -118,9 +112,10 @@ abstract class _$$_UtxoCopyWith<$Res> implements $UtxoCopyWith<$Res> { } /// @nodoc -class __$$_UtxoCopyWithImpl<$Res> extends _$UtxoCopyWithImpl<$Res, _$_Utxo> - implements _$$_UtxoCopyWith<$Res> { - __$$_UtxoCopyWithImpl(_$_Utxo _value, $Res Function(_$_Utxo) _then) +class __$$UtxoImplCopyWithImpl<$Res> + extends _$UtxoCopyWithImpl<$Res, _$UtxoImpl> + implements _$$UtxoImplCopyWith<$Res> { + __$$UtxoImplCopyWithImpl(_$UtxoImpl _value, $Res Function(_$UtxoImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -133,7 +128,7 @@ class __$$_UtxoCopyWithImpl<$Res> extends _$UtxoCopyWithImpl<$Res, _$_Utxo> Object? addressType = null, Object? inscriptions = null, }) { - return _then(_$_Utxo( + return _then(_$UtxoImpl( txId: null == txId ? _value.txId : txId // ignore: cast_nullable_to_non_nullable @@ -155,7 +150,7 @@ class __$$_UtxoCopyWithImpl<$Res> extends _$UtxoCopyWithImpl<$Res, _$_Utxo> : addressType // ignore: cast_nullable_to_non_nullable as int, inscriptions: null == inscriptions - ? _value.inscriptions + ? _value._inscriptions : inscriptions // ignore: cast_nullable_to_non_nullable as List, )); @@ -164,79 +159,110 @@ class __$$_UtxoCopyWithImpl<$Res> extends _$UtxoCopyWithImpl<$Res, _$_Utxo> /// @nodoc @JsonSerializable() -class _$_Utxo implements _Utxo { - _$_Utxo( +class _$UtxoImpl implements _Utxo { + const _$UtxoImpl( {required this.txId, required this.outputIndex, required this.satoshis, required this.scriptPk, required this.addressType, - required this.inscriptions}); + required final List inscriptions}) + : _inscriptions = inscriptions; - factory _$_Utxo.fromJson(Map json) => _$$_UtxoFromJson(json); + factory _$UtxoImpl.fromJson(Map json) => + _$$UtxoImplFromJson(json); @override - String txId; + final String txId; @override - int outputIndex; + final int outputIndex; @override - int satoshis; + final int satoshis; @override - String scriptPk; + final String scriptPk; @override - int addressType; + final int addressType; + final List _inscriptions; @override - List inscriptions; + List get inscriptions { + if (_inscriptions is EqualUnmodifiableListView) return _inscriptions; + // ignore: implicit_dynamic_type + return EqualUnmodifiableListView(_inscriptions); + } @override String toString() { return 'Utxo(txId: $txId, outputIndex: $outputIndex, satoshis: $satoshis, scriptPk: $scriptPk, addressType: $addressType, inscriptions: $inscriptions)'; } + @override + bool operator ==(Object other) { + return identical(this, other) || + (other.runtimeType == runtimeType && + other is _$UtxoImpl && + (identical(other.txId, txId) || other.txId == txId) && + (identical(other.outputIndex, outputIndex) || + other.outputIndex == outputIndex) && + (identical(other.satoshis, satoshis) || + other.satoshis == satoshis) && + (identical(other.scriptPk, scriptPk) || + other.scriptPk == scriptPk) && + (identical(other.addressType, addressType) || + other.addressType == addressType) && + const DeepCollectionEquality() + .equals(other._inscriptions, _inscriptions)); + } + + @JsonKey(ignore: true) + @override + int get hashCode => Object.hash( + runtimeType, + txId, + outputIndex, + satoshis, + scriptPk, + addressType, + const DeepCollectionEquality().hash(_inscriptions)); + @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$_UtxoCopyWith<_$_Utxo> get copyWith => - __$$_UtxoCopyWithImpl<_$_Utxo>(this, _$identity); + _$$UtxoImplCopyWith<_$UtxoImpl> get copyWith => + __$$UtxoImplCopyWithImpl<_$UtxoImpl>(this, _$identity); @override Map toJson() { - return _$$_UtxoToJson( + return _$$UtxoImplToJson( this, ); } } abstract class _Utxo implements Utxo { - factory _Utxo( - {required String txId, - required int outputIndex, - required int satoshis, - required String scriptPk, - required int addressType, - required List inscriptions}) = _$_Utxo; + const factory _Utxo( + {required final String txId, + required final int outputIndex, + required final int satoshis, + required final String scriptPk, + required final int addressType, + required final List inscriptions}) = _$UtxoImpl; - factory _Utxo.fromJson(Map json) = _$_Utxo.fromJson; + factory _Utxo.fromJson(Map json) = _$UtxoImpl.fromJson; @override String get txId; - set txId(String value); @override int get outputIndex; - set outputIndex(int value); @override int get satoshis; - set satoshis(int value); @override String get scriptPk; - set scriptPk(String value); @override int get addressType; - set addressType(int value); @override List get inscriptions; - set inscriptions(List value); @override @JsonKey(ignore: true) - _$$_UtxoCopyWith<_$_Utxo> get copyWith => throw _privateConstructorUsedError; + _$$UtxoImplCopyWith<_$UtxoImpl> get copyWith => + throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/agent/ord/utxo.g.dart b/packages/agent_dart_base/lib/agent/ord/utxo.g.dart index 9e320c95..a2b802f6 100644 --- a/packages/agent_dart_base/lib/agent/ord/utxo.g.dart +++ b/packages/agent_dart_base/lib/agent/ord/utxo.g.dart @@ -6,18 +6,19 @@ part of 'utxo.dart'; // JsonSerializableGenerator // ************************************************************************** -_$_Utxo _$$_UtxoFromJson(Map json) => _$_Utxo( +_$UtxoImpl _$$UtxoImplFromJson(Map json) => _$UtxoImpl( txId: json['txId'] as String, - outputIndex: json['outputIndex'] as int, - satoshis: json['satoshis'] as int, + outputIndex: (json['outputIndex'] as num).toInt(), + satoshis: (json['satoshis'] as num).toInt(), scriptPk: json['scriptPk'] as String, - addressType: json['addressType'] as int, + addressType: (json['addressType'] as num).toInt(), inscriptions: (json['inscriptions'] as List) .map((e) => Inscription.fromJson(e as Map)) .toList(), ); -Map _$$_UtxoToJson(_$_Utxo instance) => { +Map _$$UtxoImplToJson(_$UtxoImpl instance) => + { 'txId': instance.txId, 'outputIndex': instance.outputIndex, 'satoshis': instance.satoshis, diff --git a/packages/agent_dart_base/lib/authentication/authentication.dart b/packages/agent_dart_base/lib/authentication/authentication.dart index d0c5b9ba..7e3d1c55 100644 --- a/packages/agent_dart_base/lib/authentication/authentication.dart +++ b/packages/agent_dart_base/lib/authentication/authentication.dart @@ -6,7 +6,7 @@ import 'package:agent_dart_base/principal/principal.dart'; import 'package:agent_dart_base/utils/extension.dart'; import 'package:agent_dart_base/utils/is.dart'; -/// Options for {@link createAuthenticationRequestUrl}. +/// Options for createAuthenticationRequestUrl. /// All these options may be limited further by the identity provider, /// or an error can happen. class CreateUrlOptions { @@ -23,7 +23,7 @@ class CreateUrlOptions { /// The scope of the delegation. This must contain at least one key and /// a maximum of four. This is validated in - /// {@link createAuthenticationRequestUrl} but also will be validated as part + /// createAuthenticationRequestUrl but also will be validated as part /// of the identity provider. final List scope; diff --git a/packages/agent_dart_base/lib/ffi/bls.ffi.dart b/packages/agent_dart_base/lib/ffi/bls.ffi.dart index 268bd78a..c6f6202d 100644 --- a/packages/agent_dart_base/lib/ffi/bls.ffi.dart +++ b/packages/agent_dart_base/lib/ffi/bls.ffi.dart @@ -1,7 +1,5 @@ import 'dart:typed_data'; -import 'package:agent_dart_ffi/agent_dart_ffi.dart'; - import 'bls.base.dart'; class FFIBls implements BaseBLS { @@ -9,7 +7,7 @@ class FFIBls implements BaseBLS { @override Future blsInit() async { - _isInit = await AgentDartFFI.impl.blsInit(); + _isInit = await blsInit(); return _isInit; } @@ -19,9 +17,7 @@ class FFIBls implements BaseBLS { Uint8List sig, Uint8List msg, ) { - return AgentDartFFI.impl.blsVerify( - req: BLSVerifyReq(signature: sig, message: msg, publicKey: pk), - ); + return blsVerify(pk, sig, msg); } @override diff --git a/packages/agent_dart_base/lib/identity/ed25519.dart b/packages/agent_dart_base/lib/identity/ed25519.dart index 66eabdd5..e568ae64 100644 --- a/packages/agent_dart_base/lib/identity/ed25519.dart +++ b/packages/agent_dart_base/lib/identity/ed25519.dart @@ -140,7 +140,7 @@ class Ed25519KeyIdentity extends auth.SignIdentity { final Uint8List publicKey; final Uint8List secretKey; // Seed itself. - final kp = await AgentDartFFI.impl.ed25519FromSeed( + final kp = await ed25519FromSeed( req: ED25519FromSeedReq(seed: seed ?? getRandomValues()), ); publicKey = kp.publicKey; @@ -187,13 +187,13 @@ class Ed25519KeyIdentity extends auth.SignIdentity { final blob = challenge is BinaryBlob ? challenge : blobFromBuffer(challenge as ByteBuffer); - return AgentDartFFI.impl.ed25519Sign( + return ed25519Sign( req: ED25519SignReq(seed: _seed, message: blob), ); } Future verify(Uint8List signature, Uint8List message) { - return AgentDartFFI.impl.ed25519Verify( + return ed25519Verify( req: ED25519VerifyReq( message: message, sig: signature, @@ -243,7 +243,7 @@ Future fromMnemonicWithoutValidation( int offset = hardened, }) async { derivationPath ??= []; - final seed = await AgentDartFFI.impl.mnemonicPhraseToSeed( + final seed = await mnemonicPhraseToSeed( req: PhraseToSeedReq(phrase: mnemonic, password: ''), ); return fromSeedWithSlip0010(seed, derivationPath, offset: offset); diff --git a/packages/agent_dart_base/lib/identity/p256.dart b/packages/agent_dart_base/lib/identity/p256.dart index 980d21ba..69179794 100644 --- a/packages/agent_dart_base/lib/identity/p256.dart +++ b/packages/agent_dart_base/lib/identity/p256.dart @@ -177,7 +177,7 @@ Future signP256Async( Uint8List blob, Uint8List seed, ) async { - final result = await AgentDartFFI.impl.p256Sign( + final result = await p256Sign( req: P256SignWithSeedReq(seed: seed, msg: blob), ); return result.signature!; @@ -188,7 +188,7 @@ Future verifyP256Async( Uint8List signature, P256PublicKey publicKey, ) async { - final result = await AgentDartFFI.impl.p256Verify( + final result = await p256Verify( req: P256VerifyReq( messageHash: blob, signatureBytes: signature, diff --git a/packages/agent_dart_base/lib/identity/schnorr.dart b/packages/agent_dart_base/lib/identity/schnorr.dart index 2b8c17f9..78fa7bdf 100644 --- a/packages/agent_dart_base/lib/identity/schnorr.dart +++ b/packages/agent_dart_base/lib/identity/schnorr.dart @@ -151,7 +151,7 @@ Future signSchnorrAsync( Uint8List seed, { Uint8List? auxRand, }) async { - final result = await AgentDartFFI.impl.schnorrSign( + final result = await schnorrSign( req: SchnorrSignWithSeedReq(seed: seed, msg: blob, auxRand: auxRand), ); return result.signature!; @@ -162,7 +162,7 @@ Future verifySchnorrAsync( Uint8List signature, SchnorrPublicKey publicKey, ) async { - final result = await AgentDartFFI.impl.schnorrVerify( + final result = await schnorrVerify( req: SchnorrVerifyReq( messageHash: blob, signatureBytes: signature, diff --git a/packages/agent_dart_base/lib/identity/secp256k1.dart b/packages/agent_dart_base/lib/identity/secp256k1.dart index 03096c75..4427f0c7 100644 --- a/packages/agent_dart_base/lib/identity/secp256k1.dart +++ b/packages/agent_dart_base/lib/identity/secp256k1.dart @@ -180,7 +180,7 @@ Uint8List signSecp256k1(String message, BinaryBlob secretKey) { } Future signSecp256k1Async(Uint8List blob, Uint8List seed) async { - final result = await AgentDartFFI.impl.secp256K1Sign( + final result = await secp256K1Sign( req: Secp256k1SignWithSeedReq(seed: seed, msg: blob), ); return result.signature!; @@ -190,14 +190,14 @@ Future signSecp256k1Recoverable( Uint8List blob, Uint8List seed, ) async { - final result = await AgentDartFFI.impl.secp256K1SignRecoverable( + final result = await secp256K1SignRecoverable( req: Secp256k1SignWithSeedReq(seed: seed, msg: blob), ); return result.signature!; } Future signSecp256k1WithRNG(Uint8List blob, Uint8List bytes) async { - final result = await AgentDartFFI.impl.secp256K1SignWithRng( + final result = await secp256K1SignWithRng( req: Secp256k1SignWithRngReq(privateBytes: bytes, msg: blob), ); @@ -243,7 +243,7 @@ Future recoverSecp256k1PubKey( Uint8List preHashedMessage, Uint8List signature, ) async { - final result = await AgentDartFFI.impl.secp256K1Recover( + final result = await secp256K1Recover( req: Secp256k1RecoverReq( messagePreHashed: preHashedMessage, signatureBytes: signature, @@ -256,7 +256,7 @@ Future getECShareSecret( Uint8List privateKey, Uint8List rawPublicKey, ) async { - final result = await AgentDartFFI.impl.secp256K1GetSharedSecret( + final result = await secp256K1GetSharedSecret( req: Secp256k1ShareSecretReq( seed: privateKey, publicKeyRawBytes: rawPublicKey, @@ -269,7 +269,7 @@ Future getP256ShareSecret( Uint8List privateKey, Uint8List rawPublicKey, ) async { - final result = await AgentDartFFI.impl.p256GetSharedSecret( + final result = await p256GetSharedSecret( req: P256ShareSecretReq( seed: privateKey, publicKeyRawBytes: rawPublicKey, diff --git a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pb.dart b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pb.dart index 97f65014..67632493 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pb.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pb.dart @@ -1,8 +1,6 @@ -/// // Generated code. Do not modify. // source: ic_base_types/pb/v1/types.proto // -// @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields import 'dart:core' as $core; @@ -10,21 +8,24 @@ import 'dart:core' as $core; import 'package:protobuf/protobuf.dart' as $pb; class PrincipalId extends $pb.GeneratedMessage { - PrincipalId._(); factory PrincipalId({ $core.List<$core.int>? serializedId, }) { - final _result = create(); + final result = create(); if (serializedId != null) { - _result.serializedId = serializedId; + result.serializedId = serializedId; } - return _result; + return result; } + + PrincipalId._(); + factory PrincipalId.fromBuffer( $core.List<$core.int> i, [ $pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY, ]) => create()..mergeFromBuffer(i, r); + factory PrincipalId.fromJson( $core.String i, [ $pb.ExtensionRegistry r = $pb.ExtensionRegistry.EMPTY, @@ -49,10 +50,12 @@ class PrincipalId extends $pb.GeneratedMessage { $pb.PbFieldType.OY, ) ..hasRequiredFields = false; + @$core.Deprecated('Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.deepCopy] instead. ' 'Will be removed in next major version') PrincipalId clone() => PrincipalId()..mergeFromMessage(this); + @$core.Deprecated('Using this can add significant overhead to your binary. ' 'Use [GeneratedMessageGenericExtensions.rebuild] instead. ' 'Will be removed in next major version') @@ -60,10 +63,14 @@ class PrincipalId extends $pb.GeneratedMessage { super.copyWith((message) => updates(message as PrincipalId)) as PrincipalId; // ignore: deprecated_member_use $pb.BuilderInfo get info_ => _i; + @$core.pragma('dart2js:noInline') static PrincipalId create() => PrincipalId._(); + PrincipalId createEmptyInstance() => create(); + static $pb.PbList createRepeated() => $pb.PbList(); + @$core.pragma('dart2js:noInline') static PrincipalId getDefault() => _defaultInstance ??= $pb.GeneratedMessage.$_defaultFor(create); @@ -71,6 +78,7 @@ class PrincipalId extends $pb.GeneratedMessage { @$pb.TagNumber(1) $core.List<$core.int> get serializedId => $_getN(0); + @$pb.TagNumber(1) set serializedId($core.List<$core.int> v) { $_setBytes(0, v); @@ -78,6 +86,7 @@ class PrincipalId extends $pb.GeneratedMessage { @$pb.TagNumber(1) $core.bool hasSerializedId() => $_has(0); + @$pb.TagNumber(1) void clearSerializedId() => clearField(1); } @@ -104,6 +113,7 @@ class Types { $pb.PbFieldType.OB, protoName: 'tui_signed_display_q2_2021', ); + static void registerAllExtensions($pb.ExtensionRegistry registry) { registry.add(tuiSignedMessage); registry.add(tuiSignedDisplayQ22021); diff --git a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbenum.dart b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbenum.dart deleted file mode 100644 index 393ad38a..00000000 --- a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbenum.dart +++ /dev/null @@ -1,6 +0,0 @@ -/// -// Generated code. Do not modify. -// source: ic_base_types/pb/v1/types.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields diff --git a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbjson.dart b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbjson.dart index b611e128..696fca1a 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbjson.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbjson.dart @@ -1,11 +1,9 @@ -/// -import 'dart:convert' as $convert; // Generated code. Do not modify. // source: ic_base_types/pb/v1/types.proto // -// @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package +import 'dart:convert' as $convert; import 'dart:core' as $core; import 'dart:typed_data' as $typed_data; diff --git a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbserver.dart b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbserver.dart index 75075dd5..a90ab287 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbserver.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_base_types/pb/v1/types.pbserver.dart @@ -1,8 +1,6 @@ -/// // Generated code. Do not modify. // source: ic_base_types/pb/v1/types.proto // -// @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package export 'types.pb.dart'; diff --git a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pb.dart b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pb.dart index 1486c0df..f9f9f186 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pb.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pb.dart @@ -1,9 +1,7 @@ -/// // Generated code. Do not modify. // source: ic_ledger/pb/v1/types.proto // -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields +// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,no_leading_underscores_for_local_identifiers import 'dart:core' as $core; diff --git a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbenum.dart b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbenum.dart deleted file mode 100644 index e2de7eb6..00000000 --- a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbenum.dart +++ /dev/null @@ -1,6 +0,0 @@ -/// -// Generated code. Do not modify. -// source: ic_ledger/pb/v1/types.proto -// -// @dart = 2.12 -// ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields diff --git a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbjson.dart b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbjson.dart index d011f184..a6aa9b38 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbjson.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbjson.dart @@ -1,12 +1,10 @@ -/// // Generated code. Do not modify. // source: ic_ledger/pb/v1/types.proto // -// @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package -import 'dart:core' as $core; import 'dart:convert' as $convert; +import 'dart:core' as $core; import 'dart:typed_data' as $typed_data; @$core.Deprecated('Use ledgerInitDescriptor instead') diff --git a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbserver.dart b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbserver.dart index 2b22be09..7d57b48a 100644 --- a/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbserver.dart +++ b/packages/agent_dart_base/lib/protobuf/ic_ledger/pb/v1/types.pbserver.dart @@ -1,8 +1,6 @@ -/// // Generated code. Do not modify. // source: ic_ledger/pb/v1/types.proto // -// @dart = 2.12 // ignore_for_file: annotate_overrides,camel_case_types,unnecessary_const,non_constant_identifier_names,library_prefixes,unused_import,unused_shown_name,return_of_invalid_type,unnecessary_this,prefer_final_fields,deprecated_member_use_from_same_package export 'types.pb.dart'; diff --git a/packages/agent_dart_base/lib/wallet/btc/bdk/bdk.dart b/packages/agent_dart_base/lib/wallet/btc/bdk/bdk.dart index 7c370cd9..f81eb6c4 100644 --- a/packages/agent_dart_base/lib/wallet/btc/bdk/bdk.dart +++ b/packages/agent_dart_base/lib/wallet/btc/bdk/bdk.dart @@ -1,5 +1,6 @@ import 'dart:convert' show base64; import 'dart:typed_data' as typed_data; +import 'dart:typed_data'; import 'package:agent_dart_base/agent_dart_base.dart'; import 'package:agent_dart_ffi/agent_dart_ffi.dart' as bridge; @@ -23,11 +24,10 @@ class Address { /// Throws a [BdkException] if the address is not valid static Future
create({required String address}) async { try { - final res = await AgentDartFFI.impl - .createAddressStaticMethodApi(address: address); + final res = await Api.createAddress(address: address); final addressType = await getAddressType(res); return Address._(res, addressType); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -39,21 +39,19 @@ class Address { Network network, ) async { try { - final res = await AgentDartFFI.impl - .addressFromScriptStaticMethodApi(script: script, network: network); + final res = await Api.addressFromScript(script: script, network: network); final addressType = await getAddressType(res); return Address._(res, addressType); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } static Future getAddressType(String address) async { try { - final res = await AgentDartFFI.impl - .getAddressTypeStaticMethodApi(address: address); + final res = await Api.getAddressType(address: address); return AddressType.fromRaw(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -62,20 +60,18 @@ class Address { /// Future payload() async { try { - final res = - await AgentDartFFI.impl.payloadStaticMethodApi(address: address); + final res = await Api.payload(address: address); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future network() async { try { - final res = await AgentDartFFI.impl - .addressNetworkStaticMethodApi(address: address); + final res = await Api.addressNetwork(address: address); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -83,10 +79,9 @@ class Address { /// Returns the script pub key of the [Address] object Future scriptPubKey() async { try { - final res = await AgentDartFFI.impl - .addressToScriptPubkeyStaticMethodApi(address: address); + final res = await Api.addressToScriptPubkey(address: address); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -106,10 +101,9 @@ class Blockchain { /// [Blockchain] constructor static Future create({required BlockchainConfig config}) async { try { - final res = await AgentDartFFI.impl - .createBlockchainStaticMethodApi(config: config); + final res = await Api.createBlockchain(config: config); return Blockchain._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -117,12 +111,12 @@ class Blockchain { /// The function for getting block hash by block height Future getBlockHash(int height) async { try { - final res = await AgentDartFFI.impl.getBlockchainHashStaticMethodApi( + final res = await Api.getBlockchainHash( blockchainHeight: height, blockchain: _blockchain, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -130,21 +124,22 @@ class Blockchain { /// The function for getting the current height of the blockchain. Future getHeight() async { try { - final res = await AgentDartFFI.impl - .getHeightStaticMethodApi(blockchain: _blockchain); + final res = await Api.getHeight(blockchain: _blockchain); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } /// Estimate the fee rate required to confirm a transaction in a given target of blocks - Future estimateFee(int target) async { + Future estimateFee(BigInt target) async { try { - final res = await AgentDartFFI.impl - .estimateFeeStaticMethodApi(blockchain: _blockchain, target: target); + final res = await Api.estimateFee( + blockchain: _blockchain, + target: target, + ); return FeeRate._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -152,10 +147,9 @@ class Blockchain { /// The function for broadcasting a transaction Future broadcast(Transaction tx) async { try { - final txid = await AgentDartFFI.impl - .broadcastStaticMethodApi(blockchain: _blockchain, tx: tx._tx!); + final txid = await Api.broadcast(blockchain: _blockchain, tx: tx._tx!); return txid; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -163,10 +157,9 @@ class Blockchain { /// The function for getting a transaction Future getTx(String txId) async { try { - final txTring = await AgentDartFFI.impl - .getTxStaticMethodApi(blockchain: _blockchain, tx: txId); + final txTring = await Api.getTx(blockchain: _blockchain, tx: txId); return txTring; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -201,8 +194,8 @@ class BumpFeeTxBuilder { return this; } - BumpFeeTxBuilder keepChange(bool _keep) { - _keepChange = _keep; + BumpFeeTxBuilder keepChange(bool value) { + _keepChange = value; return this; } @@ -220,7 +213,7 @@ class BumpFeeTxBuilder { /// Finish building the transaction. Returns the [TxBuilderResult]. Future finish(Wallet wallet) async { try { - final res = await AgentDartFFI.impl.bumpFeeTxBuilderFinishStaticMethodApi( + final res = await Api.bumpFeeTxBuilderFinish( txid: txid.toString(), enableRbf: _enableRbf, feeRate: feeRate, @@ -234,7 +227,7 @@ class BumpFeeTxBuilder { txDetails: res.field1, bumpFeeBuilder: this, ); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -249,10 +242,9 @@ class DerivationPath { /// [DerivationPath] constructor static Future create({required String path}) async { try { - final res = await AgentDartFFI.impl - .createDerivationPathStaticMethodApi(path: path); + final res = await Api.createDerivationPath(path: path); return DerivationPath._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -276,12 +268,12 @@ class Descriptor { required Network network, }) async { try { - final res = await AgentDartFFI.impl.createDescriptorStaticMethodApi( + final res = await Api.createDescriptor( descriptor: descriptor, network: network, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -293,13 +285,13 @@ class Descriptor { required Network network, }) async { try { - final res = await AgentDartFFI.impl.importSingleWifStaticMethodApi( + final res = await Api.importSingleWif( wif: wif, addressType: addressType.raw, network: network, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -315,7 +307,7 @@ class Descriptor { try { secretKey.derivedPathPrefix = "m/44'/0'/0'/0"; secretKey.derivedIndex = 0; - final res = await AgentDartFFI.impl.newBip44DescriptorStaticMethodApi( + final res = await Api.newBip44Descriptor( secretKey: secretKey.asString(), network: network, keyChainKind: keychain, @@ -323,7 +315,7 @@ class Descriptor { final r = Descriptor._(res); r.descriptorSecretKey = secretKey; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -340,14 +332,14 @@ class Descriptor { required KeychainKind keychain, }) async { try { - final res = await AgentDartFFI.impl.newBip44PublicStaticMethodApi( + final res = await Api.newBip44Public( keyChainKind: keychain, publicKey: publicKey.asString(), network: network, fingerprint: fingerPrint, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -360,7 +352,7 @@ class Descriptor { try { secretKey.derivedPathPrefix = "m/44'/0'/0'/0"; secretKey.derivedIndex = 0; - final res = await AgentDartFFI.impl.newBip44TrDescriptorStaticMethodApi( + final res = await Api.newBip44TrDescriptor( secretKey: secretKey.asString(), network: network, keyChainKind: keychain, @@ -368,7 +360,7 @@ class Descriptor { final r = Descriptor._(res); r.descriptorSecretKey = secretKey; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -385,14 +377,14 @@ class Descriptor { required KeychainKind keychain, }) async { try { - final res = await AgentDartFFI.impl.newBip44TrPublicStaticMethodApi( + final res = await Api.newBip44TrPublic( keyChainKind: keychain, publicKey: publicKey.asString(), network: network, fingerprint: fingerPrint, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -408,7 +400,7 @@ class Descriptor { try { secretKey.derivedPathPrefix = "m/49'/0'/0'/0"; secretKey.derivedIndex = 0; - final res = await AgentDartFFI.impl.newBip49DescriptorStaticMethodApi( + final res = await Api.newBip49Descriptor( secretKey: secretKey.asString(), network: network, keyChainKind: keychain, @@ -416,7 +408,7 @@ class Descriptor { final r = Descriptor._(res); r.descriptorSecretKey = secretKey; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -433,14 +425,14 @@ class Descriptor { required KeychainKind keychain, }) async { try { - final res = await AgentDartFFI.impl.newBip49PublicStaticMethodApi( + final res = await Api.newBip49Public( keyChainKind: keychain, publicKey: publicKey.asString(), network: network, fingerprint: fingerPrint, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -456,7 +448,7 @@ class Descriptor { try { secretKey.derivedPathPrefix = "m/84'/0'/0'/0"; secretKey.derivedIndex = 0; - final res = await AgentDartFFI.impl.newBip84DescriptorStaticMethodApi( + final res = await Api.newBip84Descriptor( secretKey: secretKey.asString(), network: network, keyChainKind: keychain, @@ -464,7 +456,7 @@ class Descriptor { final r = Descriptor._(res); r.descriptorSecretKey = secretKey; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -481,14 +473,14 @@ class Descriptor { required KeychainKind keychain, }) async { try { - final res = await AgentDartFFI.impl.newBip84PublicStaticMethodApi( + final res = await Api.newBip84Public( keyChainKind: keychain, publicKey: publicKey.asString(), network: network, fingerprint: fingerPrint, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -504,7 +496,7 @@ class Descriptor { try { secretKey.derivedPathPrefix = "m/86'/0'/0'/0"; secretKey.derivedIndex = 0; - final res = await AgentDartFFI.impl.newBip86DescriptorStaticMethodApi( + final res = await Api.newBip86Descriptor( secretKey: secretKey.asString(), network: network, keyChainKind: keychain, @@ -512,7 +504,7 @@ class Descriptor { final r = Descriptor._(res); r.descriptorSecretKey = secretKey; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -529,14 +521,14 @@ class Descriptor { required KeychainKind keychain, }) async { try { - final res = await AgentDartFFI.impl.newBip86PublicStaticMethodApi( + final res = await Api.newBip86Public( keyChainKind: keychain, publicKey: publicKey.asString(), network: network, fingerprint: fingerPrint, ); return Descriptor._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -544,10 +536,9 @@ class Descriptor { ///Return the private version of the output descriptor if available, otherwise return the public version. Future asStringPrivate() async { try { - final res = await AgentDartFFI.impl - .asStringPrivateStaticMethodApi(descriptor: _descriptorInstance!); + final res = await Api.asStringPrivate(descriptor: _descriptorInstance!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -555,23 +546,22 @@ class Descriptor { ///Return the public version of the output descriptor. Future asString() async { try { - final res = await AgentDartFFI.impl - .asStringStaticMethodApi(descriptor: _descriptorInstance!); + final res = await Api.asString(descriptor: _descriptorInstance!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future deriveAddressAt(int index, Network network) async { try { - final res = await AgentDartFFI.impl.deriveAddressAtStaticMethodApi( + final res = await Api.deriveAddressAt( descriptor: _descriptorInstance!, index: index, network: network, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -591,11 +581,11 @@ class DescriptorPublicKey { ///Derive a public descriptor at a given path. Future masterFingerprint() async { try { - final res = await AgentDartFFI.impl.masterFinterprintStaticMethodApi( + final res = await Api.masterFinterprint( xpub: _descriptorPublicKey!, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -603,13 +593,13 @@ class DescriptorPublicKey { ///Derive a public descriptor at a given path. Future derive(DerivationPath derivationPath) async { try { - final res = await AgentDartFFI.impl.createDescriptorPublicStaticMethodApi( + final res = await Api.createDescriptorPublic( xpub: _descriptorPublicKey, path: derivationPath.path.toString(), derive: true, ); return DescriptorPublicKey._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -617,13 +607,13 @@ class DescriptorPublicKey { ///Extend the public descriptor with a custom path. Future extend(DerivationPath derivationPath) async { try { - final res = await AgentDartFFI.impl.createDescriptorPublicStaticMethodApi( + final res = await Api.createDescriptorPublic( xpub: _descriptorPublicKey, path: derivationPath.path.toString(), derive: false, ); return DescriptorPublicKey._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -631,10 +621,9 @@ class DescriptorPublicKey { /// [DescriptorPublicKey] constructor static Future fromString(String publicKey) async { try { - final res = await AgentDartFFI.impl - .descriptorPublicFromStringStaticMethodApi(publicKey: publicKey); + final res = await Api.descriptorPublicFromString(publicKey: publicKey); return DescriptorPublicKey._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -658,10 +647,9 @@ class DescriptorSecretKey { /// If the key is an “XPrv”, the hardened derivation steps will be applied before converting it to a public key. Future asPublic() async { try { - final xpub = await AgentDartFFI.impl - .asPublicStaticMethodApi(secret: _descriptorSecretKey); + final xpub = await Api.asPublic(secret: _descriptorSecretKey); return DescriptorPublicKey._(xpub); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -678,13 +666,13 @@ class DescriptorSecretKey { String? password, }) async { try { - final res = await AgentDartFFI.impl.createDescriptorSecretStaticMethodApi( + final res = await Api.createDescriptorSecret( network: network, mnemonic: mnemonic.asString(), password: password, ); return DescriptorSecretKey._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -697,14 +685,14 @@ class DescriptorSecretKey { // }) async { // try { // final res = await AgentDartFFI.impl - // .createDerivedDescriptorSecretStaticMethodApi( + // .Api.createDerivedDescriptorSecret( // network: network, // mnemonic: mnemonic.asString(), // path: path, // password: password); // print(res); // return DescriptorSecretKey._(res); - // } on FfiException catch (e, s) { + // } on AnyhowException catch (e, s) { // Error.throwWithStackTrace(configException(e.message), s); // } // } @@ -715,14 +703,14 @@ class DescriptorSecretKey { derivationPath = await DerivationPath.create( path: '${derivedPathPrefix!}/$index', ); - final res = await AgentDartFFI.impl.deriveDescriptorSecretStaticMethodApi( + final res = await Api.deriveDescriptorSecret( secret: _descriptorSecretKey, path: derivationPath!.path.toString(), ); final r = DescriptorSecretKey._(res); r.derivationPath = derivationPath; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -730,14 +718,14 @@ class DescriptorSecretKey { /// Derived the `XPrv` using the derivation path Future derive(DerivationPath derivationPath) async { try { - final res = await AgentDartFFI.impl.deriveDescriptorSecretStaticMethodApi( + final res = await Api.deriveDescriptorSecret( secret: _descriptorSecretKey, path: derivationPath.path.toString(), ); final r = DescriptorSecretKey._(res); r.derivationPath = derivationPath; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -745,14 +733,14 @@ class DescriptorSecretKey { /// Extends the “XPrv” using the derivation path Future extend(DerivationPath derivationPath) async { try { - final res = await AgentDartFFI.impl.extendDescriptorSecretStaticMethodApi( + final res = await Api.extendDescriptorSecret( secret: _descriptorSecretKey, path: derivationPath.path.toString(), ); final r = DescriptorSecretKey._(res); r.derivationPath = derivationPath; return r; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -760,10 +748,9 @@ class DescriptorSecretKey { /// [DescriptorSecretKey] constructor static Future fromString(String secretKey) async { try { - final res = await AgentDartFFI.impl - .descriptorSecretFromStringStaticMethodApi(secret: secretKey); + final res = await Api.descriptorSecretFromString(secret: secretKey); return DescriptorSecretKey._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -771,10 +758,9 @@ class DescriptorSecretKey { /// Get the private key as bytes. Future secretBytes() async { try { - final res = await AgentDartFFI.impl - .asSecretBytesStaticMethodApi(secret: _descriptorSecretKey); + final res = await Api.asSecretBytes(secret: _descriptorSecretKey); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -782,10 +768,9 @@ class DescriptorSecretKey { /// Get the private key as bytes. Future getPubFromBytes(Uint8List bytes) async { try { - final res = await AgentDartFFI.impl - .getPubFromSecretBytesStaticMethodApi(bytes: bytes); + final res = await Api.getPubFromSecretBytes(bytes: bytes); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -818,10 +803,9 @@ class Mnemonic { /// [Mnemonic] constructor static Future create(WordCount wordCount) async { try { - final res = await AgentDartFFI.impl - .generateSeedFromWordCountStaticMethodApi(wordCount: wordCount); + final res = await Api.generateSeedFromWordCount(wordCount: wordCount); return Mnemonic._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -837,10 +821,9 @@ class Mnemonic { /// [Mnemonic] constructor static Future fromEntropy(typed_data.Uint8List entropy) async { try { - final res = await AgentDartFFI.impl - .generateSeedFromEntropyStaticMethodApi(entropy: entropy); + final res = await Api.generateSeedFromEntropy(entropy: entropy); return Mnemonic._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -850,10 +833,9 @@ class Mnemonic { /// [Mnemonic] constructor static Future fromString(String mnemonic) async { try { - final res = await AgentDartFFI.impl - .generateSeedFromStringStaticMethodApi(mnemonic: mnemonic); + final res = await Api.generateSeedFromString(mnemonic: mnemonic); return Mnemonic._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -886,12 +868,12 @@ class PartiallySignedTransaction { PartiallySignedTransaction other, ) async { try { - final res = await AgentDartFFI.impl.combinePsbtStaticMethodApi( + final res = await Api.combinePsbt( psbtStr: psbtBase64, other: other.psbtBase64, ); return PartiallySignedTransaction(psbtBase64: res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -899,10 +881,9 @@ class PartiallySignedTransaction { /// Return the transaction as bytes. Future extractTx() async { try { - final res = - await AgentDartFFI.impl.extractTxStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.extractTx(psbtStr: psbtBase64); return Transaction._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -910,10 +891,9 @@ class PartiallySignedTransaction { /// Return feeAmount Future feeAmount() async { try { - final res = await AgentDartFFI.impl - .psbtFeeAmountStaticMethodApi(psbtStr: psbtBase64); - return res; - } on FfiException catch (e, s) { + final res = await Api.psbtFeeAmount(psbtStr: psbtBase64); + return res?.toInt(); + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -921,11 +901,10 @@ class PartiallySignedTransaction { /// Return Fee Rate Future feeRate() async { try { - final res = await AgentDartFFI.impl - .psbtFeeRateStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.psbtFeeRate(psbtStr: psbtBase64); if (res == null) return null; return FeeRate._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -933,30 +912,27 @@ class PartiallySignedTransaction { /// Return txid as string Future serialize() async { try { - final res = await AgentDartFFI.impl - .serializePsbtStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.serializePsbt(psbtStr: psbtBase64); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future> getPsbtInputs() async { try { - final res = - await AgentDartFFI.impl.getInputsStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.getInputs(psbtStr: psbtBase64); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future jsonSerialize() async { try { - final res = await AgentDartFFI.impl - .jsonSerializeStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.jsonSerialize(psbtStr: psbtBase64); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -969,10 +945,9 @@ class PartiallySignedTransaction { /// Returns the [PartiallySignedTransaction] transaction id Future txId() async { try { - final res = - await AgentDartFFI.impl.psbtTxidStaticMethodApi(psbtStr: psbtBase64); + final res = await Api.psbtTxid(psbtStr: psbtBase64); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -991,10 +966,9 @@ class Script extends bridge.Script { typed_data.Uint8List rawOutputScript, ) async { try { - final res = await AgentDartFFI.impl - .createScriptStaticMethodApi(rawOutputScript: rawOutputScript); + final res = await Api.createScript(rawOutputScript: rawOutputScript); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1011,10 +985,9 @@ class Transaction { required Uint8List transactionBytes, }) async { try { - final res = await AgentDartFFI.impl - .createTransactionStaticMethodApi(tx: transactionBytes); + final res = await Api.createTransaction(tx: transactionBytes); return Transaction._(res); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1022,110 +995,108 @@ class Transaction { ///Return the transaction bytes, bitcoin consensus encoded. Future serialize() async { try { - final res = await AgentDartFFI.impl.serializeTxStaticMethodApi(tx: _tx!); + final res = await Api.serializeTx(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future txid() async { try { - final res = await AgentDartFFI.impl.txTxidStaticMethodApi(tx: _tx!); + final res = await Api.txTxid(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } - Future weight() async { + Future weight() async { try { - final res = await AgentDartFFI.impl.weightStaticMethodApi(tx: _tx!); + final res = await Api.weight(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } - Future size() async { + Future size() async { try { - final res = await AgentDartFFI.impl.sizeStaticMethodApi(tx: _tx!); + final res = await Api.size(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } - Future vsize() async { + Future vsize() async { try { - final res = await AgentDartFFI.impl.vsizeStaticMethodApi(tx: _tx!); + final res = await Api.vsize(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future isCoinBase() async { try { - final res = await AgentDartFFI.impl.isCoinBaseStaticMethodApi(tx: _tx!); + final res = await Api.isCoinBase(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future isExplicitlyRbf() async { try { - final res = - await AgentDartFFI.impl.isExplicitlyRbfStaticMethodApi(tx: _tx!); + final res = await Api.isExplicitlyRbf(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future isLockTimeEnabled() async { try { - final res = - await AgentDartFFI.impl.isLockTimeEnabledStaticMethodApi(tx: _tx!); + final res = await Api.isLockTimeEnabled(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future version() async { try { - final res = await AgentDartFFI.impl.versionStaticMethodApi(tx: _tx!); + final res = await Api.version(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future lockTime() async { try { - final res = await AgentDartFFI.impl.lockTimeStaticMethodApi(tx: _tx!); + final res = await Api.lockTime(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future> input() async { try { - final res = await AgentDartFFI.impl.inputStaticMethodApi(tx: _tx!); + final res = await Api.input(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } Future> output() async { try { - final res = await AgentDartFFI.impl.outputStaticMethodApi(tx: _tx!); + final res = await Api.output(tx: _tx!); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1143,7 +1114,7 @@ class Transaction { class TxBuilder { final List _recipients = []; final List _utxos = []; - final List _foreign_utxos = []; + final List _foreignUtxos = []; final List _unSpendable = []; final List _txInputs = []; final List _txOutputs = []; @@ -1151,8 +1122,8 @@ class TxBuilder { bool _manuallySelectedOnly = false; double? _feeRate; - ChangeSpendPolicy _changeSpendPolicy = ChangeSpendPolicy.ChangeAllowed; - int? _feeAbsolute; + ChangeSpendPolicy _changeSpendPolicy = ChangeSpendPolicy.changeAllowed; + BigInt? _feeAbsolute; bool _drainWallet = false; bool _shuffleUtxos = false; bridge.Script? _drainTo; @@ -1170,7 +1141,7 @@ class TxBuilder { ///Add a recipient to the internal list TxBuilder addRecipient(bridge.Script script, int amount) { - _recipients.add(ScriptAmount(script: script, amount: amount)); + _recipients.add(ScriptAmount(script: script, amount: BigInt.from(amount))); return this; } @@ -1214,11 +1185,11 @@ class TxBuilder { /// /// These have priority over the “unspendable” utxos, meaning that if a utxo is present both in the “utxos” and the “unspendable” list, it will be spent. TxBuilder addForeignUtxo(OutPointExt ext) { - _foreign_utxos.add( + _foreignUtxos.add( ForeignUtxo( outpoint: OutPoint(txid: ext.txid, vout: ext.vout), txout: TxOutForeign( - value: ext.value, + value: BigInt.from(ext.value), scriptPubkey: ext.scriptPk, ), ), @@ -1261,7 +1232,7 @@ class TxBuilder { /// /// This effectively adds all the change outputs to the “unspendable” list. See TxBuilder().addUtxos TxBuilder doNotSpendChange() { - _changeSpendPolicy = ChangeSpendPolicy.ChangeForbidden; + _changeSpendPolicy = ChangeSpendPolicy.changeForbidden; return this; } @@ -1310,7 +1281,7 @@ class TxBuilder { } ///Set an absolute fee - TxBuilder feeAbsolute(int feeAmount) { + TxBuilder feeAbsolute(BigInt feeAmount) { _feeAbsolute = feeAmount; return this; } @@ -1350,7 +1321,7 @@ class TxBuilder { /// /// This effectively adds all the non-change outputs to the “unspendable” list. TxBuilder onlySpendChange() { - _changeSpendPolicy = ChangeSpendPolicy.OnlyChange; + _changeSpendPolicy = ChangeSpendPolicy.onlyChange; return this; } @@ -1360,10 +1331,10 @@ class TxBuilder { } Future calFee(Wallet wallet) async { - final res = await AgentDartFFI.impl.txCalFeeFinishStaticMethodApi( + final res = await Api.txCalFeeFinish( wallet: wallet._wallet, recipients: _recipients, - foreignUtxos: _foreign_utxos, + foreignUtxos: _foreignUtxos, txs: _txs, unspendable: _unSpendable, manuallySelectedOnly: _manuallySelectedOnly, @@ -1376,11 +1347,11 @@ class TxBuilder { changePolicy: _changeSpendPolicy, shuffleUtxo: _shuffleUtxos, ); - return res; + return res.toInt(); } int getTotalOutput() { - var total = 0; + int total = 0; for (final e in _txOutputs) { total += e.value; } @@ -1388,7 +1359,7 @@ class TxBuilder { } int getTotalInput() { - var total = 0; + int total = 0; for (final e in _txInputs) { total += e.value; } @@ -1417,10 +1388,10 @@ class TxBuilder { ); } try { - final res = await AgentDartFFI.impl.txBuilderFinishStaticMethodApi( + final res = await Api.txBuilderFinish( wallet: wallet._wallet, recipients: _recipients, - foreignUtxos: _foreign_utxos, + foreignUtxos: _foreignUtxos, unspendable: _unSpendable, manuallySelectedOnly: _manuallySelectedOnly, drainWallet: _drainWallet, @@ -1433,9 +1404,7 @@ class TxBuilder { shuffleUtxo: _shuffleUtxos, txs: _txs, ); - - final psbt = await PartiallySignedTransaction(psbtBase64: res.field0); - + final psbt = PartiallySignedTransaction(psbtBase64: res.field0); return TxBuilderResult( psbt: psbt, txDetails: res.field1, @@ -1443,7 +1412,7 @@ class TxBuilder { txInputs: _txInputs, txOutputs: _txOutputs, ); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1549,17 +1518,11 @@ class TxBuilderResult { bool? signed; int getTotalInput() { - return _txInputs.fold( - 0, - (pre, cur) => pre + cur.value, - ); + return _txInputs.fold(0, (p, v) => p + v.value); } int getTotalOutput() { - return _txOutputs.fold( - 0, - (pre, cur) => pre + cur.value, - ); + return _txOutputs.fold(0, (p, v) => p + v.value); } Future dumpTx({ @@ -1567,13 +1530,13 @@ class TxBuilderResult { }) async { final tx = await psbt.extractTx(); final size = Uint8List.fromList(await tx.serialize()).length; - final feePaid = await psbt.feeAmount(); + final feePaid = BigInt.from((await psbt.feeAmount())!); final feeRate = (await psbt.feeRate())!.asSatPerVb(); final inputs = await tx.input(); final outputs = await tx.output(); final inputStrings = []; - var totalInput = 0; + int totalInput = 0; for (int i = 0; i < _txInputs.length; i += 1) { final input = _txInputs[i]; final found = inputs.firstWhereOrNull((e) { @@ -1583,7 +1546,7 @@ class TxBuilderResult { if (found != null) { totalInput += input.value; inputStrings.add(''' - #${i} ${input.value} + #$i ${input.value} lock-size: ${input.scriptPk.toU8a().length} via ${input.txid} [${input.vout}] '''); @@ -1594,36 +1557,33 @@ class TxBuilderResult { for (int i = 0; i < outputs.length; i += 1) { final output = outputs[i]; outputString.add(''' - #${i} ${output.scriptPubkey.internal.toHex()} ${output.value} + #$i ${output.scriptPubkey.internal.toHex()} ${output.value} '''); } - final totalOutput = outputs.fold( - 0, - (previousValue, element) => previousValue + element.value, - ); + final totalOutput = outputs.fold(BigInt.zero, (p, v) => p + v.value); logPrint?.call(''' ============================================================================================== Transaction Detail txid: ${await tx.txid()} - Size: ${size} - Fee Paid: ${feePaid} - Fee Rate: ${feeRate} sat/B + Size: $size + Fee Paid: $feePaid + Fee Rate: $feeRate sat/B Detail: ${inputs.length} Inputs, ${outputs.length} Outputs ---------------------------------------------------------------------------------------------- Inputs in Sats ${inputStrings.join('\n')} - total: ${totalInput} + total: $totalInput ---------------------------------------------------------------------------------------------- Outputs in Sats ${outputString.join("\n")} - total: ${totalOutput} + total: $totalOutput ---------------------------------------------------------------------------------------------- Summary in Sats - Inputs: + ${totalInput} - Outputs: - ${totalOutput} - fee: - ${feePaid!} + Inputs: + $totalInput + Outputs: - $totalOutput + fee: - $feePaid Remain: ${totalOutput - feePaid} ============================================================================================== '''); @@ -1662,7 +1622,7 @@ class Wallet { required DatabaseConfig databaseConfig, }) async { try { - final res = await AgentDartFFI.impl.createWalletStaticMethodApi( + final res = await Api.createWallet( descriptor: descriptor._descriptorInstance!, changeDescriptor: changeDescriptor?._descriptorInstance, network: network, @@ -1674,7 +1634,7 @@ class Wallet { changeDescriptor: changeDescriptor, network: network, ); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1699,12 +1659,12 @@ class Wallet { /// If none of the keys in the descriptor are derivable (i.e. does not end with /*) then the same address will always be returned for any AddressIndex. Future getAddress({required AddressIndex addressIndex}) async { try { - final res = await AgentDartFFI.impl.getAddressStaticMethodApi( + final res = await Api.getAddress( wallet: _wallet, addressIndex: addressIndex, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1720,12 +1680,12 @@ class Wallet { required AddressIndex addressIndex, }) async { try { - final res = await AgentDartFFI.impl.getInternalAddressStaticMethodApi( + final res = await Api.getInternalAddress( wallet: _wallet, addressIndex: addressIndex, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1735,10 +1695,9 @@ class Wallet { ///Note that this method only operates on the internal database, which first needs to be Wallet().sync manually. Future getBalance() async { try { - final res = - await AgentDartFFI.impl.getBalanceStaticMethodApi(wallet: _wallet); + final res = await Api.getBalance(wallet: _wallet); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1747,9 +1706,9 @@ class Wallet { // Future getNetwork() async { // try { // final res = - // await AgentDartFFI.impl.walletNetworkStaticMethodApi(wallet: _wallet); + // await Api.walletNetwork(wallet: _wallet); // return res; - // } on FfiException catch (e, s) { + // } on AnyhowException catch (e, s) { // Error.throwWithStackTrace(configException(e.message), s); // } // } @@ -1759,35 +1718,34 @@ class Wallet { /// Note that this method only operates on the internal database, which first needs to be Wallet().sync manually. Future> listUnspent() async { try { - final res = await AgentDartFFI.impl - .listUnspentOutputsStaticMethodApi(wallet: _wallet); + final res = await Api.listUnspentOutputs(wallet: _wallet); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } - ///Sync the internal database with the [Blockchain] - Future sync(Blockchain blockchain) async { - try { - await AgentDartFFI.impl.syncWalletStaticMethodApi( - wallet: _wallet, - blockchain: blockchain._blockchain, - ); - } on FfiException catch (e, s) { - Error.throwWithStackTrace(configException(e.message), s); - } - } + // ///Sync the internal database with the [Blockchain] + // Future sync(Blockchain blockchain) async { + // try { + // await Api.syncWallet( + // wallet: _wallet, + // blockchain: blockchain._blockchain, + // ); + // } on AnyhowException catch (e, s) { + // Error.throwWithStackTrace(configException(e.message), s); + // } + // } ///Return an unsorted list of transactions made and received by the wallet Future> listTransactions(bool includeRaw) async { try { - final res = await AgentDartFFI.impl.getTransactionsStaticMethodApi( + final res = await Api.getTransactions( wallet: _wallet, includeRaw: includeRaw, ); return res; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1799,7 +1757,7 @@ class Wallet { required PartiallySignedTransaction psbt, SignOptions? signOptions, }) async { - final sbt = await AgentDartFFI.impl.signStaticMethodApi( + final sbt = await Api.sign( signOptions: signOptions, psbtStr: psbt.psbtBase64, wallet: _wallet, @@ -1815,7 +1773,7 @@ class Wallet { SignOptions? signOptions, }) async { final psbt = PartiallySignedTransaction.parse(psbtHex); - final sbt = await AgentDartFFI.impl.signStaticMethodApi( + final sbt = await Api.sign( signOptions: signOptions, psbtStr: psbt.psbtBase64, wallet: _wallet, @@ -1897,12 +1855,12 @@ class Wallet { } else { String? res; if (addressType == AddressType.P2TR) { - res = await AgentDartFFI.impl.bip322SignTaprootStaticMethodApi( + res = await Api.bip322SignTaproot( secret: kBytes, message: message, ); } else { - res = await AgentDartFFI.impl.bip322SignSegwitStaticMethodApi( + res = await Api.bip322SignSegwit( secret: kBytes, message: message, ); @@ -1917,17 +1875,14 @@ class Wallet { } Uint8List messageHandler(String message) { - final MAGIC_BYTES = 'Bitcoin Signed Message:\n'.plainToU8a(); - - final prefix1 = BufferWriter.varintBufNum(MAGIC_BYTES.toU8a().byteLength) + final magicBytes = 'Bitcoin Signed Message:\n'.plainToU8a(); + final prefix1 = BufferWriter.varintBufNum(magicBytes.toU8a().byteLength) .buffer .asUint8List(); final messageBuffer = message.plainToU8a(); final prefix2 = BufferWriter.varintBufNum(messageBuffer.length).buffer.asUint8List(); - - final buf = u8aConcat([prefix1, MAGIC_BYTES, prefix2, messageBuffer]); - + final buf = u8aConcat([prefix1, magicBytes, prefix2, messageBuffer]); return sha256Hash(buf.buffer); } @@ -1939,7 +1894,7 @@ class Wallet { final psbt = PartiallySignedTransaction.parse(psbtHex); final res = await sign(psbt: psbt, signOptions: options); return base64Decode(res.psbtBase64).toHex(); - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } @@ -1982,8 +1937,8 @@ class Wallet { txId: txId, index: i, address: addr, - value: element.value, - isMine: addr == address ? true : false, + value: element.value.toInt(), + isMine: addr.address == address, isChange: false, ), ); @@ -1999,8 +1954,8 @@ class Wallet { TxOutExt( index: i, address: addr, - value: element.value, - isMine: addr == address ? true : false, + value: element.value.toInt(), + isMine: addr.address == address, isChange: i == outputs.length - 1 ? true : false, ), ); @@ -2036,10 +1991,9 @@ class Wallet { Future cacheAddresses({required int cacheSize}) async { try { // final utxos = await ordService!.getUtxo(_selectedSigner.address); - final ins = await AgentDartFFI.impl - .cacheAddressStaticMethodApi(wallet: _wallet, cacheSize: cacheSize); + final ins = await Api.cacheAddress(wallet: _wallet, cacheSize: cacheSize); return ins; - } on FfiException catch (e, s) { + } on AnyhowException catch (e, s) { Error.throwWithStackTrace(configException(e.message), s); } } diff --git a/packages/agent_dart_base/lib/wallet/btc/bdk/bdk_exception.freezed.dart b/packages/agent_dart_base/lib/wallet/btc/bdk/bdk_exception.freezed.dart index 39188d4f..55f5323d 100644 --- a/packages/agent_dart_base/lib/wallet/btc/bdk/bdk_exception.freezed.dart +++ b/packages/agent_dart_base/lib/wallet/btc/bdk/bdk_exception.freezed.dart @@ -12,7 +12,7 @@ part of 'bdk_exception.dart'; T _$identity(T value) => value; final _privateConstructorUsedError = UnsupportedError( - 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods'); + 'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#adding-getters-and-methods-to-our-models'); /// @nodoc mixin _$BdkException { @@ -217,27 +217,27 @@ class _$BdkExceptionCopyWithImpl<$Res, $Val extends BdkException> } /// @nodoc -abstract class _$$ScriptDoesntHaveAddressFormCopyWith<$Res> { - factory _$$ScriptDoesntHaveAddressFormCopyWith( - _$ScriptDoesntHaveAddressForm value, - $Res Function(_$ScriptDoesntHaveAddressForm) then) = - __$$ScriptDoesntHaveAddressFormCopyWithImpl<$Res>; +abstract class _$$ScriptDoesntHaveAddressFormImplCopyWith<$Res> { + factory _$$ScriptDoesntHaveAddressFormImplCopyWith( + _$ScriptDoesntHaveAddressFormImpl value, + $Res Function(_$ScriptDoesntHaveAddressFormImpl) then) = + __$$ScriptDoesntHaveAddressFormImplCopyWithImpl<$Res>; } /// @nodoc -class __$$ScriptDoesntHaveAddressFormCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$ScriptDoesntHaveAddressForm> - implements _$$ScriptDoesntHaveAddressFormCopyWith<$Res> { - __$$ScriptDoesntHaveAddressFormCopyWithImpl( - _$ScriptDoesntHaveAddressForm _value, - $Res Function(_$ScriptDoesntHaveAddressForm) _then) +class __$$ScriptDoesntHaveAddressFormImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$ScriptDoesntHaveAddressFormImpl> + implements _$$ScriptDoesntHaveAddressFormImplCopyWith<$Res> { + __$$ScriptDoesntHaveAddressFormImplCopyWithImpl( + _$ScriptDoesntHaveAddressFormImpl _value, + $Res Function(_$ScriptDoesntHaveAddressFormImpl) _then) : super(_value, _then); } /// @nodoc -class _$ScriptDoesntHaveAddressForm implements ScriptDoesntHaveAddressForm { - const _$ScriptDoesntHaveAddressForm(); +class _$ScriptDoesntHaveAddressFormImpl implements ScriptDoesntHaveAddressForm { + const _$ScriptDoesntHaveAddressFormImpl(); @override String toString() { @@ -245,10 +245,10 @@ class _$ScriptDoesntHaveAddressForm implements ScriptDoesntHaveAddressForm { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$ScriptDoesntHaveAddressForm); + other is _$ScriptDoesntHaveAddressFormImpl); } @override @@ -460,29 +460,30 @@ class _$ScriptDoesntHaveAddressForm implements ScriptDoesntHaveAddressForm { } abstract class ScriptDoesntHaveAddressForm implements BdkException { - const factory ScriptDoesntHaveAddressForm() = _$ScriptDoesntHaveAddressForm; + const factory ScriptDoesntHaveAddressForm() = + _$ScriptDoesntHaveAddressFormImpl; } /// @nodoc -abstract class _$$NoRecipientsCopyWith<$Res> { - factory _$$NoRecipientsCopyWith( - _$NoRecipients value, $Res Function(_$NoRecipients) then) = - __$$NoRecipientsCopyWithImpl<$Res>; +abstract class _$$NoRecipientsImplCopyWith<$Res> { + factory _$$NoRecipientsImplCopyWith( + _$NoRecipientsImpl value, $Res Function(_$NoRecipientsImpl) then) = + __$$NoRecipientsImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NoRecipientsCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$NoRecipients> - implements _$$NoRecipientsCopyWith<$Res> { - __$$NoRecipientsCopyWithImpl( - _$NoRecipients _value, $Res Function(_$NoRecipients) _then) +class __$$NoRecipientsImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$NoRecipientsImpl> + implements _$$NoRecipientsImplCopyWith<$Res> { + __$$NoRecipientsImplCopyWithImpl( + _$NoRecipientsImpl _value, $Res Function(_$NoRecipientsImpl) _then) : super(_value, _then); } /// @nodoc -class _$NoRecipients implements NoRecipients { - const _$NoRecipients(); +class _$NoRecipientsImpl implements NoRecipients { + const _$NoRecipientsImpl(); @override String toString() { @@ -490,9 +491,9 @@ class _$NoRecipients implements NoRecipients { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$NoRecipients); + (other.runtimeType == runtimeType && other is _$NoRecipientsImpl); } @override @@ -704,22 +705,24 @@ class _$NoRecipients implements NoRecipients { } abstract class NoRecipients implements BdkException { - const factory NoRecipients() = _$NoRecipients; + const factory NoRecipients() = _$NoRecipientsImpl; } /// @nodoc -abstract class _$$GenericCopyWith<$Res> { - factory _$$GenericCopyWith(_$Generic value, $Res Function(_$Generic) then) = - __$$GenericCopyWithImpl<$Res>; +abstract class _$$GenericImplCopyWith<$Res> { + factory _$$GenericImplCopyWith( + _$GenericImpl value, $Res Function(_$GenericImpl) then) = + __$$GenericImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$GenericCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Generic> - implements _$$GenericCopyWith<$Res> { - __$$GenericCopyWithImpl(_$Generic _value, $Res Function(_$Generic) _then) +class __$$GenericImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$GenericImpl> + implements _$$GenericImplCopyWith<$Res> { + __$$GenericImplCopyWithImpl( + _$GenericImpl _value, $Res Function(_$GenericImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -727,7 +730,7 @@ class __$$GenericCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Generic( + return _then(_$GenericImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -738,8 +741,8 @@ class __$$GenericCopyWithImpl<$Res> /// @nodoc -class _$Generic implements Generic { - const _$Generic(this.e); +class _$GenericImpl implements Generic { + const _$GenericImpl(this.e); @override final String e; @@ -750,10 +753,10 @@ class _$Generic implements Generic { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Generic && + other is _$GenericImpl && (identical(other.e, e) || other.e == e)); } @@ -763,8 +766,8 @@ class _$Generic implements Generic { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$GenericCopyWith<_$Generic> get copyWith => - __$$GenericCopyWithImpl<_$Generic>(this, _$identity); + _$$GenericImplCopyWith<_$GenericImpl> get copyWith => + __$$GenericImplCopyWithImpl<_$GenericImpl>(this, _$identity); @override @optionalTypeArgs @@ -972,34 +975,34 @@ class _$Generic implements Generic { } abstract class Generic implements BdkException { - const factory Generic(final String e) = _$Generic; + const factory Generic(final String e) = _$GenericImpl; String get e; @JsonKey(ignore: true) - _$$GenericCopyWith<_$Generic> get copyWith => + _$$GenericImplCopyWith<_$GenericImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$NoUtxosSelectedCopyWith<$Res> { - factory _$$NoUtxosSelectedCopyWith( - _$NoUtxosSelected value, $Res Function(_$NoUtxosSelected) then) = - __$$NoUtxosSelectedCopyWithImpl<$Res>; +abstract class _$$NoUtxosSelectedImplCopyWith<$Res> { + factory _$$NoUtxosSelectedImplCopyWith(_$NoUtxosSelectedImpl value, + $Res Function(_$NoUtxosSelectedImpl) then) = + __$$NoUtxosSelectedImplCopyWithImpl<$Res>; } /// @nodoc -class __$$NoUtxosSelectedCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$NoUtxosSelected> - implements _$$NoUtxosSelectedCopyWith<$Res> { - __$$NoUtxosSelectedCopyWithImpl( - _$NoUtxosSelected _value, $Res Function(_$NoUtxosSelected) _then) +class __$$NoUtxosSelectedImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$NoUtxosSelectedImpl> + implements _$$NoUtxosSelectedImplCopyWith<$Res> { + __$$NoUtxosSelectedImplCopyWithImpl( + _$NoUtxosSelectedImpl _value, $Res Function(_$NoUtxosSelectedImpl) _then) : super(_value, _then); } /// @nodoc -class _$NoUtxosSelected implements NoUtxosSelected { - const _$NoUtxosSelected(); +class _$NoUtxosSelectedImpl implements NoUtxosSelected { + const _$NoUtxosSelectedImpl(); @override String toString() { @@ -1007,9 +1010,9 @@ class _$NoUtxosSelected implements NoUtxosSelected { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$NoUtxosSelected); + (other.runtimeType == runtimeType && other is _$NoUtxosSelectedImpl); } @override @@ -1221,29 +1224,29 @@ class _$NoUtxosSelected implements NoUtxosSelected { } abstract class NoUtxosSelected implements BdkException { - const factory NoUtxosSelected() = _$NoUtxosSelected; + const factory NoUtxosSelected() = _$NoUtxosSelectedImpl; } /// @nodoc -abstract class _$$OutputBelowDustLimitCopyWith<$Res> { - factory _$$OutputBelowDustLimitCopyWith(_$OutputBelowDustLimit value, - $Res Function(_$OutputBelowDustLimit) then) = - __$$OutputBelowDustLimitCopyWithImpl<$Res>; +abstract class _$$OutputBelowDustLimitImplCopyWith<$Res> { + factory _$$OutputBelowDustLimitImplCopyWith(_$OutputBelowDustLimitImpl value, + $Res Function(_$OutputBelowDustLimitImpl) then) = + __$$OutputBelowDustLimitImplCopyWithImpl<$Res>; } /// @nodoc -class __$$OutputBelowDustLimitCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$OutputBelowDustLimit> - implements _$$OutputBelowDustLimitCopyWith<$Res> { - __$$OutputBelowDustLimitCopyWithImpl(_$OutputBelowDustLimit _value, - $Res Function(_$OutputBelowDustLimit) _then) +class __$$OutputBelowDustLimitImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$OutputBelowDustLimitImpl> + implements _$$OutputBelowDustLimitImplCopyWith<$Res> { + __$$OutputBelowDustLimitImplCopyWithImpl(_$OutputBelowDustLimitImpl _value, + $Res Function(_$OutputBelowDustLimitImpl) _then) : super(_value, _then); } /// @nodoc -class _$OutputBelowDustLimit implements OutputBelowDustLimit { - const _$OutputBelowDustLimit(); +class _$OutputBelowDustLimitImpl implements OutputBelowDustLimit { + const _$OutputBelowDustLimitImpl(); @override String toString() { @@ -1251,9 +1254,10 @@ class _$OutputBelowDustLimit implements OutputBelowDustLimit { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$OutputBelowDustLimit); + (other.runtimeType == runtimeType && + other is _$OutputBelowDustLimitImpl); } @override @@ -1465,24 +1469,24 @@ class _$OutputBelowDustLimit implements OutputBelowDustLimit { } abstract class OutputBelowDustLimit implements BdkException { - const factory OutputBelowDustLimit() = _$OutputBelowDustLimit; + const factory OutputBelowDustLimit() = _$OutputBelowDustLimitImpl; } /// @nodoc -abstract class _$$InsufficientFundsCopyWith<$Res> { - factory _$$InsufficientFundsCopyWith( - _$InsufficientFunds value, $Res Function(_$InsufficientFunds) then) = - __$$InsufficientFundsCopyWithImpl<$Res>; +abstract class _$$InsufficientFundsImplCopyWith<$Res> { + factory _$$InsufficientFundsImplCopyWith(_$InsufficientFundsImpl value, + $Res Function(_$InsufficientFundsImpl) then) = + __$$InsufficientFundsImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$InsufficientFundsCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$InsufficientFunds> - implements _$$InsufficientFundsCopyWith<$Res> { - __$$InsufficientFundsCopyWithImpl( - _$InsufficientFunds _value, $Res Function(_$InsufficientFunds) _then) +class __$$InsufficientFundsImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$InsufficientFundsImpl> + implements _$$InsufficientFundsImplCopyWith<$Res> { + __$$InsufficientFundsImplCopyWithImpl(_$InsufficientFundsImpl _value, + $Res Function(_$InsufficientFundsImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -1490,7 +1494,7 @@ class __$$InsufficientFundsCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$InsufficientFunds( + return _then(_$InsufficientFundsImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -1501,8 +1505,8 @@ class __$$InsufficientFundsCopyWithImpl<$Res> /// @nodoc -class _$InsufficientFunds implements InsufficientFunds { - const _$InsufficientFunds(this.e); +class _$InsufficientFundsImpl implements InsufficientFunds { + const _$InsufficientFundsImpl(this.e); @override final String e; @@ -1513,10 +1517,10 @@ class _$InsufficientFunds implements InsufficientFunds { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$InsufficientFunds && + other is _$InsufficientFundsImpl && (identical(other.e, e) || other.e == e)); } @@ -1526,8 +1530,9 @@ class _$InsufficientFunds implements InsufficientFunds { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$InsufficientFundsCopyWith<_$InsufficientFunds> get copyWith => - __$$InsufficientFundsCopyWithImpl<_$InsufficientFunds>(this, _$identity); + _$$InsufficientFundsImplCopyWith<_$InsufficientFundsImpl> get copyWith => + __$$InsufficientFundsImplCopyWithImpl<_$InsufficientFundsImpl>( + this, _$identity); @override @optionalTypeArgs @@ -1735,34 +1740,35 @@ class _$InsufficientFunds implements InsufficientFunds { } abstract class InsufficientFunds implements BdkException { - const factory InsufficientFunds(final String e) = _$InsufficientFunds; + const factory InsufficientFunds(final String e) = _$InsufficientFundsImpl; String get e; @JsonKey(ignore: true) - _$$InsufficientFundsCopyWith<_$InsufficientFunds> get copyWith => + _$$InsufficientFundsImplCopyWith<_$InsufficientFundsImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$BnBTotalTriesExceededCopyWith<$Res> { - factory _$$BnBTotalTriesExceededCopyWith(_$BnBTotalTriesExceeded value, - $Res Function(_$BnBTotalTriesExceeded) then) = - __$$BnBTotalTriesExceededCopyWithImpl<$Res>; +abstract class _$$BnBTotalTriesExceededImplCopyWith<$Res> { + factory _$$BnBTotalTriesExceededImplCopyWith( + _$BnBTotalTriesExceededImpl value, + $Res Function(_$BnBTotalTriesExceededImpl) then) = + __$$BnBTotalTriesExceededImplCopyWithImpl<$Res>; } /// @nodoc -class __$$BnBTotalTriesExceededCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$BnBTotalTriesExceeded> - implements _$$BnBTotalTriesExceededCopyWith<$Res> { - __$$BnBTotalTriesExceededCopyWithImpl(_$BnBTotalTriesExceeded _value, - $Res Function(_$BnBTotalTriesExceeded) _then) +class __$$BnBTotalTriesExceededImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$BnBTotalTriesExceededImpl> + implements _$$BnBTotalTriesExceededImplCopyWith<$Res> { + __$$BnBTotalTriesExceededImplCopyWithImpl(_$BnBTotalTriesExceededImpl _value, + $Res Function(_$BnBTotalTriesExceededImpl) _then) : super(_value, _then); } /// @nodoc -class _$BnBTotalTriesExceeded implements BnBTotalTriesExceeded { - const _$BnBTotalTriesExceeded(); +class _$BnBTotalTriesExceededImpl implements BnBTotalTriesExceeded { + const _$BnBTotalTriesExceededImpl(); @override String toString() { @@ -1770,9 +1776,10 @@ class _$BnBTotalTriesExceeded implements BnBTotalTriesExceeded { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$BnBTotalTriesExceeded); + (other.runtimeType == runtimeType && + other is _$BnBTotalTriesExceededImpl); } @override @@ -1984,29 +1991,29 @@ class _$BnBTotalTriesExceeded implements BnBTotalTriesExceeded { } abstract class BnBTotalTriesExceeded implements BdkException { - const factory BnBTotalTriesExceeded() = _$BnBTotalTriesExceeded; + const factory BnBTotalTriesExceeded() = _$BnBTotalTriesExceededImpl; } /// @nodoc -abstract class _$$BnBNoExactMatchCopyWith<$Res> { - factory _$$BnBNoExactMatchCopyWith( - _$BnBNoExactMatch value, $Res Function(_$BnBNoExactMatch) then) = - __$$BnBNoExactMatchCopyWithImpl<$Res>; +abstract class _$$BnBNoExactMatchImplCopyWith<$Res> { + factory _$$BnBNoExactMatchImplCopyWith(_$BnBNoExactMatchImpl value, + $Res Function(_$BnBNoExactMatchImpl) then) = + __$$BnBNoExactMatchImplCopyWithImpl<$Res>; } /// @nodoc -class __$$BnBNoExactMatchCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$BnBNoExactMatch> - implements _$$BnBNoExactMatchCopyWith<$Res> { - __$$BnBNoExactMatchCopyWithImpl( - _$BnBNoExactMatch _value, $Res Function(_$BnBNoExactMatch) _then) +class __$$BnBNoExactMatchImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$BnBNoExactMatchImpl> + implements _$$BnBNoExactMatchImplCopyWith<$Res> { + __$$BnBNoExactMatchImplCopyWithImpl( + _$BnBNoExactMatchImpl _value, $Res Function(_$BnBNoExactMatchImpl) _then) : super(_value, _then); } /// @nodoc -class _$BnBNoExactMatch implements BnBNoExactMatch { - const _$BnBNoExactMatch(); +class _$BnBNoExactMatchImpl implements BnBNoExactMatch { + const _$BnBNoExactMatchImpl(); @override String toString() { @@ -2014,9 +2021,9 @@ class _$BnBNoExactMatch implements BnBNoExactMatch { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$BnBNoExactMatch); + (other.runtimeType == runtimeType && other is _$BnBNoExactMatchImpl); } @override @@ -2228,29 +2235,29 @@ class _$BnBNoExactMatch implements BnBNoExactMatch { } abstract class BnBNoExactMatch implements BdkException { - const factory BnBNoExactMatch() = _$BnBNoExactMatch; + const factory BnBNoExactMatch() = _$BnBNoExactMatchImpl; } /// @nodoc -abstract class _$$UnknownUtxoCopyWith<$Res> { - factory _$$UnknownUtxoCopyWith( - _$UnknownUtxo value, $Res Function(_$UnknownUtxo) then) = - __$$UnknownUtxoCopyWithImpl<$Res>; +abstract class _$$UnknownUtxoImplCopyWith<$Res> { + factory _$$UnknownUtxoImplCopyWith( + _$UnknownUtxoImpl value, $Res Function(_$UnknownUtxoImpl) then) = + __$$UnknownUtxoImplCopyWithImpl<$Res>; } /// @nodoc -class __$$UnknownUtxoCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$UnknownUtxo> - implements _$$UnknownUtxoCopyWith<$Res> { - __$$UnknownUtxoCopyWithImpl( - _$UnknownUtxo _value, $Res Function(_$UnknownUtxo) _then) +class __$$UnknownUtxoImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$UnknownUtxoImpl> + implements _$$UnknownUtxoImplCopyWith<$Res> { + __$$UnknownUtxoImplCopyWithImpl( + _$UnknownUtxoImpl _value, $Res Function(_$UnknownUtxoImpl) _then) : super(_value, _then); } /// @nodoc -class _$UnknownUtxo implements UnknownUtxo { - const _$UnknownUtxo(); +class _$UnknownUtxoImpl implements UnknownUtxo { + const _$UnknownUtxoImpl(); @override String toString() { @@ -2258,9 +2265,9 @@ class _$UnknownUtxo implements UnknownUtxo { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$UnknownUtxo); + (other.runtimeType == runtimeType && other is _$UnknownUtxoImpl); } @override @@ -2472,29 +2479,29 @@ class _$UnknownUtxo implements UnknownUtxo { } abstract class UnknownUtxo implements BdkException { - const factory UnknownUtxo() = _$UnknownUtxo; + const factory UnknownUtxo() = _$UnknownUtxoImpl; } /// @nodoc -abstract class _$$TransactionNotFoundCopyWith<$Res> { - factory _$$TransactionNotFoundCopyWith(_$TransactionNotFound value, - $Res Function(_$TransactionNotFound) then) = - __$$TransactionNotFoundCopyWithImpl<$Res>; +abstract class _$$TransactionNotFoundImplCopyWith<$Res> { + factory _$$TransactionNotFoundImplCopyWith(_$TransactionNotFoundImpl value, + $Res Function(_$TransactionNotFoundImpl) then) = + __$$TransactionNotFoundImplCopyWithImpl<$Res>; } /// @nodoc -class __$$TransactionNotFoundCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$TransactionNotFound> - implements _$$TransactionNotFoundCopyWith<$Res> { - __$$TransactionNotFoundCopyWithImpl( - _$TransactionNotFound _value, $Res Function(_$TransactionNotFound) _then) +class __$$TransactionNotFoundImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$TransactionNotFoundImpl> + implements _$$TransactionNotFoundImplCopyWith<$Res> { + __$$TransactionNotFoundImplCopyWithImpl(_$TransactionNotFoundImpl _value, + $Res Function(_$TransactionNotFoundImpl) _then) : super(_value, _then); } /// @nodoc -class _$TransactionNotFound implements TransactionNotFound { - const _$TransactionNotFound(); +class _$TransactionNotFoundImpl implements TransactionNotFound { + const _$TransactionNotFoundImpl(); @override String toString() { @@ -2502,9 +2509,10 @@ class _$TransactionNotFound implements TransactionNotFound { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$TransactionNotFound); + (other.runtimeType == runtimeType && + other is _$TransactionNotFoundImpl); } @override @@ -2716,29 +2724,29 @@ class _$TransactionNotFound implements TransactionNotFound { } abstract class TransactionNotFound implements BdkException { - const factory TransactionNotFound() = _$TransactionNotFound; + const factory TransactionNotFound() = _$TransactionNotFoundImpl; } /// @nodoc -abstract class _$$TransactionConfirmedCopyWith<$Res> { - factory _$$TransactionConfirmedCopyWith(_$TransactionConfirmed value, - $Res Function(_$TransactionConfirmed) then) = - __$$TransactionConfirmedCopyWithImpl<$Res>; +abstract class _$$TransactionConfirmedImplCopyWith<$Res> { + factory _$$TransactionConfirmedImplCopyWith(_$TransactionConfirmedImpl value, + $Res Function(_$TransactionConfirmedImpl) then) = + __$$TransactionConfirmedImplCopyWithImpl<$Res>; } /// @nodoc -class __$$TransactionConfirmedCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$TransactionConfirmed> - implements _$$TransactionConfirmedCopyWith<$Res> { - __$$TransactionConfirmedCopyWithImpl(_$TransactionConfirmed _value, - $Res Function(_$TransactionConfirmed) _then) +class __$$TransactionConfirmedImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$TransactionConfirmedImpl> + implements _$$TransactionConfirmedImplCopyWith<$Res> { + __$$TransactionConfirmedImplCopyWithImpl(_$TransactionConfirmedImpl _value, + $Res Function(_$TransactionConfirmedImpl) _then) : super(_value, _then); } /// @nodoc -class _$TransactionConfirmed implements TransactionConfirmed { - const _$TransactionConfirmed(); +class _$TransactionConfirmedImpl implements TransactionConfirmed { + const _$TransactionConfirmedImpl(); @override String toString() { @@ -2746,9 +2754,10 @@ class _$TransactionConfirmed implements TransactionConfirmed { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$TransactionConfirmed); + (other.runtimeType == runtimeType && + other is _$TransactionConfirmedImpl); } @override @@ -2960,24 +2969,24 @@ class _$TransactionConfirmed implements TransactionConfirmed { } abstract class TransactionConfirmed implements BdkException { - const factory TransactionConfirmed() = _$TransactionConfirmed; + const factory TransactionConfirmed() = _$TransactionConfirmedImpl; } /// @nodoc -abstract class _$$FeeRateTooLowCopyWith<$Res> { - factory _$$FeeRateTooLowCopyWith( - _$FeeRateTooLow value, $Res Function(_$FeeRateTooLow) then) = - __$$FeeRateTooLowCopyWithImpl<$Res>; +abstract class _$$FeeRateTooLowImplCopyWith<$Res> { + factory _$$FeeRateTooLowImplCopyWith( + _$FeeRateTooLowImpl value, $Res Function(_$FeeRateTooLowImpl) then) = + __$$FeeRateTooLowImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$FeeRateTooLowCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$FeeRateTooLow> - implements _$$FeeRateTooLowCopyWith<$Res> { - __$$FeeRateTooLowCopyWithImpl( - _$FeeRateTooLow _value, $Res Function(_$FeeRateTooLow) _then) +class __$$FeeRateTooLowImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$FeeRateTooLowImpl> + implements _$$FeeRateTooLowImplCopyWith<$Res> { + __$$FeeRateTooLowImplCopyWithImpl( + _$FeeRateTooLowImpl _value, $Res Function(_$FeeRateTooLowImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -2985,7 +2994,7 @@ class __$$FeeRateTooLowCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$FeeRateTooLow( + return _then(_$FeeRateTooLowImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -2996,8 +3005,8 @@ class __$$FeeRateTooLowCopyWithImpl<$Res> /// @nodoc -class _$FeeRateTooLow implements FeeRateTooLow { - const _$FeeRateTooLow(this.e); +class _$FeeRateTooLowImpl implements FeeRateTooLow { + const _$FeeRateTooLowImpl(this.e); @override final String e; @@ -3008,10 +3017,10 @@ class _$FeeRateTooLow implements FeeRateTooLow { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$FeeRateTooLow && + other is _$FeeRateTooLowImpl && (identical(other.e, e) || other.e == e)); } @@ -3021,8 +3030,8 @@ class _$FeeRateTooLow implements FeeRateTooLow { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$FeeRateTooLowCopyWith<_$FeeRateTooLow> get copyWith => - __$$FeeRateTooLowCopyWithImpl<_$FeeRateTooLow>(this, _$identity); + _$$FeeRateTooLowImplCopyWith<_$FeeRateTooLowImpl> get copyWith => + __$$FeeRateTooLowImplCopyWithImpl<_$FeeRateTooLowImpl>(this, _$identity); @override @optionalTypeArgs @@ -3230,29 +3239,29 @@ class _$FeeRateTooLow implements FeeRateTooLow { } abstract class FeeRateTooLow implements BdkException { - const factory FeeRateTooLow(final String e) = _$FeeRateTooLow; + const factory FeeRateTooLow(final String e) = _$FeeRateTooLowImpl; String get e; @JsonKey(ignore: true) - _$$FeeRateTooLowCopyWith<_$FeeRateTooLow> get copyWith => + _$$FeeRateTooLowImplCopyWith<_$FeeRateTooLowImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$FeeTooLowCopyWith<$Res> { - factory _$$FeeTooLowCopyWith( - _$FeeTooLow value, $Res Function(_$FeeTooLow) then) = - __$$FeeTooLowCopyWithImpl<$Res>; +abstract class _$$FeeTooLowImplCopyWith<$Res> { + factory _$$FeeTooLowImplCopyWith( + _$FeeTooLowImpl value, $Res Function(_$FeeTooLowImpl) then) = + __$$FeeTooLowImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$FeeTooLowCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$FeeTooLow> - implements _$$FeeTooLowCopyWith<$Res> { - __$$FeeTooLowCopyWithImpl( - _$FeeTooLow _value, $Res Function(_$FeeTooLow) _then) +class __$$FeeTooLowImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$FeeTooLowImpl> + implements _$$FeeTooLowImplCopyWith<$Res> { + __$$FeeTooLowImplCopyWithImpl( + _$FeeTooLowImpl _value, $Res Function(_$FeeTooLowImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -3260,7 +3269,7 @@ class __$$FeeTooLowCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$FeeTooLow( + return _then(_$FeeTooLowImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -3271,8 +3280,8 @@ class __$$FeeTooLowCopyWithImpl<$Res> /// @nodoc -class _$FeeTooLow implements FeeTooLow { - const _$FeeTooLow(this.e); +class _$FeeTooLowImpl implements FeeTooLow { + const _$FeeTooLowImpl(this.e); @override final String e; @@ -3283,10 +3292,10 @@ class _$FeeTooLow implements FeeTooLow { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$FeeTooLow && + other is _$FeeTooLowImpl && (identical(other.e, e) || other.e == e)); } @@ -3296,8 +3305,8 @@ class _$FeeTooLow implements FeeTooLow { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$FeeTooLowCopyWith<_$FeeTooLow> get copyWith => - __$$FeeTooLowCopyWithImpl<_$FeeTooLow>(this, _$identity); + _$$FeeTooLowImplCopyWith<_$FeeTooLowImpl> get copyWith => + __$$FeeTooLowImplCopyWithImpl<_$FeeTooLowImpl>(this, _$identity); @override @optionalTypeArgs @@ -3505,34 +3514,34 @@ class _$FeeTooLow implements FeeTooLow { } abstract class FeeTooLow implements BdkException { - const factory FeeTooLow(final String e) = _$FeeTooLow; + const factory FeeTooLow(final String e) = _$FeeTooLowImpl; String get e; @JsonKey(ignore: true) - _$$FeeTooLowCopyWith<_$FeeTooLow> get copyWith => + _$$FeeTooLowImplCopyWith<_$FeeTooLowImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$FeeRateUnavailableCopyWith<$Res> { - factory _$$FeeRateUnavailableCopyWith(_$FeeRateUnavailable value, - $Res Function(_$FeeRateUnavailable) then) = - __$$FeeRateUnavailableCopyWithImpl<$Res>; +abstract class _$$FeeRateUnavailableImplCopyWith<$Res> { + factory _$$FeeRateUnavailableImplCopyWith(_$FeeRateUnavailableImpl value, + $Res Function(_$FeeRateUnavailableImpl) then) = + __$$FeeRateUnavailableImplCopyWithImpl<$Res>; } /// @nodoc -class __$$FeeRateUnavailableCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$FeeRateUnavailable> - implements _$$FeeRateUnavailableCopyWith<$Res> { - __$$FeeRateUnavailableCopyWithImpl( - _$FeeRateUnavailable _value, $Res Function(_$FeeRateUnavailable) _then) +class __$$FeeRateUnavailableImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$FeeRateUnavailableImpl> + implements _$$FeeRateUnavailableImplCopyWith<$Res> { + __$$FeeRateUnavailableImplCopyWithImpl(_$FeeRateUnavailableImpl _value, + $Res Function(_$FeeRateUnavailableImpl) _then) : super(_value, _then); } /// @nodoc -class _$FeeRateUnavailable implements FeeRateUnavailable { - const _$FeeRateUnavailable(); +class _$FeeRateUnavailableImpl implements FeeRateUnavailable { + const _$FeeRateUnavailableImpl(); @override String toString() { @@ -3540,9 +3549,9 @@ class _$FeeRateUnavailable implements FeeRateUnavailable { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$FeeRateUnavailable); + (other.runtimeType == runtimeType && other is _$FeeRateUnavailableImpl); } @override @@ -3754,29 +3763,29 @@ class _$FeeRateUnavailable implements FeeRateUnavailable { } abstract class FeeRateUnavailable implements BdkException { - const factory FeeRateUnavailable() = _$FeeRateUnavailable; + const factory FeeRateUnavailable() = _$FeeRateUnavailableImpl; } /// @nodoc -abstract class _$$ChecksumMismatchCopyWith<$Res> { - factory _$$ChecksumMismatchCopyWith( - _$ChecksumMismatch value, $Res Function(_$ChecksumMismatch) then) = - __$$ChecksumMismatchCopyWithImpl<$Res>; +abstract class _$$ChecksumMismatchImplCopyWith<$Res> { + factory _$$ChecksumMismatchImplCopyWith(_$ChecksumMismatchImpl value, + $Res Function(_$ChecksumMismatchImpl) then) = + __$$ChecksumMismatchImplCopyWithImpl<$Res>; } /// @nodoc -class __$$ChecksumMismatchCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$ChecksumMismatch> - implements _$$ChecksumMismatchCopyWith<$Res> { - __$$ChecksumMismatchCopyWithImpl( - _$ChecksumMismatch _value, $Res Function(_$ChecksumMismatch) _then) +class __$$ChecksumMismatchImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$ChecksumMismatchImpl> + implements _$$ChecksumMismatchImplCopyWith<$Res> { + __$$ChecksumMismatchImplCopyWithImpl(_$ChecksumMismatchImpl _value, + $Res Function(_$ChecksumMismatchImpl) _then) : super(_value, _then); } /// @nodoc -class _$ChecksumMismatch implements ChecksumMismatch { - const _$ChecksumMismatch(); +class _$ChecksumMismatchImpl implements ChecksumMismatch { + const _$ChecksumMismatchImpl(); @override String toString() { @@ -3784,9 +3793,9 @@ class _$ChecksumMismatch implements ChecksumMismatch { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$ChecksumMismatch); + (other.runtimeType == runtimeType && other is _$ChecksumMismatchImpl); } @override @@ -3998,24 +4007,24 @@ class _$ChecksumMismatch implements ChecksumMismatch { } abstract class ChecksumMismatch implements BdkException { - const factory ChecksumMismatch() = _$ChecksumMismatch; + const factory ChecksumMismatch() = _$ChecksumMismatchImpl; } /// @nodoc -abstract class _$$MiniscriptCopyWith<$Res> { - factory _$$MiniscriptCopyWith( - _$Miniscript value, $Res Function(_$Miniscript) then) = - __$$MiniscriptCopyWithImpl<$Res>; +abstract class _$$MiniscriptImplCopyWith<$Res> { + factory _$$MiniscriptImplCopyWith( + _$MiniscriptImpl value, $Res Function(_$MiniscriptImpl) then) = + __$$MiniscriptImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$MiniscriptCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Miniscript> - implements _$$MiniscriptCopyWith<$Res> { - __$$MiniscriptCopyWithImpl( - _$Miniscript _value, $Res Function(_$Miniscript) _then) +class __$$MiniscriptImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$MiniscriptImpl> + implements _$$MiniscriptImplCopyWith<$Res> { + __$$MiniscriptImplCopyWithImpl( + _$MiniscriptImpl _value, $Res Function(_$MiniscriptImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -4023,7 +4032,7 @@ class __$$MiniscriptCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Miniscript( + return _then(_$MiniscriptImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -4034,8 +4043,8 @@ class __$$MiniscriptCopyWithImpl<$Res> /// @nodoc -class _$Miniscript implements Miniscript { - const _$Miniscript(this.e); +class _$MiniscriptImpl implements Miniscript { + const _$MiniscriptImpl(this.e); @override final String e; @@ -4046,10 +4055,10 @@ class _$Miniscript implements Miniscript { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Miniscript && + other is _$MiniscriptImpl && (identical(other.e, e) || other.e == e)); } @@ -4059,8 +4068,8 @@ class _$Miniscript implements Miniscript { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$MiniscriptCopyWith<_$Miniscript> get copyWith => - __$$MiniscriptCopyWithImpl<_$Miniscript>(this, _$identity); + _$$MiniscriptImplCopyWith<_$MiniscriptImpl> get copyWith => + __$$MiniscriptImplCopyWithImpl<_$MiniscriptImpl>(this, _$identity); @override @optionalTypeArgs @@ -4268,27 +4277,29 @@ class _$Miniscript implements Miniscript { } abstract class Miniscript implements BdkException { - const factory Miniscript(final String e) = _$Miniscript; + const factory Miniscript(final String e) = _$MiniscriptImpl; String get e; @JsonKey(ignore: true) - _$$MiniscriptCopyWith<_$Miniscript> get copyWith => + _$$MiniscriptImplCopyWith<_$MiniscriptImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$Bip32CopyWith<$Res> { - factory _$$Bip32CopyWith(_$Bip32 value, $Res Function(_$Bip32) then) = - __$$Bip32CopyWithImpl<$Res>; +abstract class _$$Bip32ImplCopyWith<$Res> { + factory _$$Bip32ImplCopyWith( + _$Bip32Impl value, $Res Function(_$Bip32Impl) then) = + __$$Bip32ImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$Bip32CopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Bip32> - implements _$$Bip32CopyWith<$Res> { - __$$Bip32CopyWithImpl(_$Bip32 _value, $Res Function(_$Bip32) _then) +class __$$Bip32ImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$Bip32Impl> + implements _$$Bip32ImplCopyWith<$Res> { + __$$Bip32ImplCopyWithImpl( + _$Bip32Impl _value, $Res Function(_$Bip32Impl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -4296,7 +4307,7 @@ class __$$Bip32CopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Bip32( + return _then(_$Bip32Impl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -4307,8 +4318,8 @@ class __$$Bip32CopyWithImpl<$Res> /// @nodoc -class _$Bip32 implements Bip32 { - const _$Bip32(this.e); +class _$Bip32Impl implements Bip32 { + const _$Bip32Impl(this.e); @override final String e; @@ -4319,10 +4330,10 @@ class _$Bip32 implements Bip32 { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Bip32 && + other is _$Bip32Impl && (identical(other.e, e) || other.e == e)); } @@ -4332,8 +4343,8 @@ class _$Bip32 implements Bip32 { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$Bip32CopyWith<_$Bip32> get copyWith => - __$$Bip32CopyWithImpl<_$Bip32>(this, _$identity); + _$$Bip32ImplCopyWith<_$Bip32Impl> get copyWith => + __$$Bip32ImplCopyWithImpl<_$Bip32Impl>(this, _$identity); @override @optionalTypeArgs @@ -4541,28 +4552,29 @@ class _$Bip32 implements Bip32 { } abstract class Bip32 implements BdkException { - const factory Bip32(final String e) = _$Bip32; + const factory Bip32(final String e) = _$Bip32Impl; String get e; @JsonKey(ignore: true) - _$$Bip32CopyWith<_$Bip32> get copyWith => throw _privateConstructorUsedError; + _$$Bip32ImplCopyWith<_$Bip32Impl> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$Secp256k1CopyWith<$Res> { - factory _$$Secp256k1CopyWith( - _$Secp256k1 value, $Res Function(_$Secp256k1) then) = - __$$Secp256k1CopyWithImpl<$Res>; +abstract class _$$Secp256k1ImplCopyWith<$Res> { + factory _$$Secp256k1ImplCopyWith( + _$Secp256k1Impl value, $Res Function(_$Secp256k1Impl) then) = + __$$Secp256k1ImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$Secp256k1CopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Secp256k1> - implements _$$Secp256k1CopyWith<$Res> { - __$$Secp256k1CopyWithImpl( - _$Secp256k1 _value, $Res Function(_$Secp256k1) _then) +class __$$Secp256k1ImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$Secp256k1Impl> + implements _$$Secp256k1ImplCopyWith<$Res> { + __$$Secp256k1ImplCopyWithImpl( + _$Secp256k1Impl _value, $Res Function(_$Secp256k1Impl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -4570,7 +4582,7 @@ class __$$Secp256k1CopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Secp256k1( + return _then(_$Secp256k1Impl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -4581,8 +4593,8 @@ class __$$Secp256k1CopyWithImpl<$Res> /// @nodoc -class _$Secp256k1 implements Secp256k1 { - const _$Secp256k1(this.e); +class _$Secp256k1Impl implements Secp256k1 { + const _$Secp256k1Impl(this.e); @override final String e; @@ -4593,10 +4605,10 @@ class _$Secp256k1 implements Secp256k1 { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Secp256k1 && + other is _$Secp256k1Impl && (identical(other.e, e) || other.e == e)); } @@ -4606,8 +4618,8 @@ class _$Secp256k1 implements Secp256k1 { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$Secp256k1CopyWith<_$Secp256k1> get copyWith => - __$$Secp256k1CopyWithImpl<_$Secp256k1>(this, _$identity); + _$$Secp256k1ImplCopyWith<_$Secp256k1Impl> get copyWith => + __$$Secp256k1ImplCopyWithImpl<_$Secp256k1Impl>(this, _$identity); @override @optionalTypeArgs @@ -4815,34 +4827,34 @@ class _$Secp256k1 implements Secp256k1 { } abstract class Secp256k1 implements BdkException { - const factory Secp256k1(final String e) = _$Secp256k1; + const factory Secp256k1(final String e) = _$Secp256k1Impl; String get e; @JsonKey(ignore: true) - _$$Secp256k1CopyWith<_$Secp256k1> get copyWith => + _$$Secp256k1ImplCopyWith<_$Secp256k1Impl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$MissingCachedScriptsCopyWith<$Res> { - factory _$$MissingCachedScriptsCopyWith(_$MissingCachedScripts value, - $Res Function(_$MissingCachedScripts) then) = - __$$MissingCachedScriptsCopyWithImpl<$Res>; +abstract class _$$MissingCachedScriptsImplCopyWith<$Res> { + factory _$$MissingCachedScriptsImplCopyWith(_$MissingCachedScriptsImpl value, + $Res Function(_$MissingCachedScriptsImpl) then) = + __$$MissingCachedScriptsImplCopyWithImpl<$Res>; } /// @nodoc -class __$$MissingCachedScriptsCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$MissingCachedScripts> - implements _$$MissingCachedScriptsCopyWith<$Res> { - __$$MissingCachedScriptsCopyWithImpl(_$MissingCachedScripts _value, - $Res Function(_$MissingCachedScripts) _then) +class __$$MissingCachedScriptsImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$MissingCachedScriptsImpl> + implements _$$MissingCachedScriptsImplCopyWith<$Res> { + __$$MissingCachedScriptsImplCopyWithImpl(_$MissingCachedScriptsImpl _value, + $Res Function(_$MissingCachedScriptsImpl) _then) : super(_value, _then); } /// @nodoc -class _$MissingCachedScripts implements MissingCachedScripts { - const _$MissingCachedScripts(); +class _$MissingCachedScriptsImpl implements MissingCachedScripts { + const _$MissingCachedScriptsImpl(); @override String toString() { @@ -4850,9 +4862,10 @@ class _$MissingCachedScripts implements MissingCachedScripts { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || - (other.runtimeType == runtimeType && other is _$MissingCachedScripts); + (other.runtimeType == runtimeType && + other is _$MissingCachedScriptsImpl); } @override @@ -5064,23 +5077,24 @@ class _$MissingCachedScripts implements MissingCachedScripts { } abstract class MissingCachedScripts implements BdkException { - const factory MissingCachedScripts() = _$MissingCachedScripts; + const factory MissingCachedScripts() = _$MissingCachedScriptsImpl; } /// @nodoc -abstract class _$$ElectrumCopyWith<$Res> { - factory _$$ElectrumCopyWith( - _$Electrum value, $Res Function(_$Electrum) then) = - __$$ElectrumCopyWithImpl<$Res>; +abstract class _$$ElectrumImplCopyWith<$Res> { + factory _$$ElectrumImplCopyWith( + _$ElectrumImpl value, $Res Function(_$ElectrumImpl) then) = + __$$ElectrumImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$ElectrumCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Electrum> - implements _$$ElectrumCopyWith<$Res> { - __$$ElectrumCopyWithImpl(_$Electrum _value, $Res Function(_$Electrum) _then) +class __$$ElectrumImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$ElectrumImpl> + implements _$$ElectrumImplCopyWith<$Res> { + __$$ElectrumImplCopyWithImpl( + _$ElectrumImpl _value, $Res Function(_$ElectrumImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -5088,7 +5102,7 @@ class __$$ElectrumCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Electrum( + return _then(_$ElectrumImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -5099,8 +5113,8 @@ class __$$ElectrumCopyWithImpl<$Res> /// @nodoc -class _$Electrum implements Electrum { - const _$Electrum(this.e); +class _$ElectrumImpl implements Electrum { + const _$ElectrumImpl(this.e); @override final String e; @@ -5111,10 +5125,10 @@ class _$Electrum implements Electrum { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Electrum && + other is _$ElectrumImpl && (identical(other.e, e) || other.e == e)); } @@ -5124,8 +5138,8 @@ class _$Electrum implements Electrum { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$ElectrumCopyWith<_$Electrum> get copyWith => - __$$ElectrumCopyWithImpl<_$Electrum>(this, _$identity); + _$$ElectrumImplCopyWith<_$ElectrumImpl> get copyWith => + __$$ElectrumImplCopyWithImpl<_$ElectrumImpl>(this, _$identity); @override @optionalTypeArgs @@ -5333,27 +5347,29 @@ class _$Electrum implements Electrum { } abstract class Electrum implements BdkException { - const factory Electrum(final String e) = _$Electrum; + const factory Electrum(final String e) = _$ElectrumImpl; String get e; @JsonKey(ignore: true) - _$$ElectrumCopyWith<_$Electrum> get copyWith => + _$$ElectrumImplCopyWith<_$ElectrumImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$EsploraCopyWith<$Res> { - factory _$$EsploraCopyWith(_$Esplora value, $Res Function(_$Esplora) then) = - __$$EsploraCopyWithImpl<$Res>; +abstract class _$$EsploraImplCopyWith<$Res> { + factory _$$EsploraImplCopyWith( + _$EsploraImpl value, $Res Function(_$EsploraImpl) then) = + __$$EsploraImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$EsploraCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Esplora> - implements _$$EsploraCopyWith<$Res> { - __$$EsploraCopyWithImpl(_$Esplora _value, $Res Function(_$Esplora) _then) +class __$$EsploraImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$EsploraImpl> + implements _$$EsploraImplCopyWith<$Res> { + __$$EsploraImplCopyWithImpl( + _$EsploraImpl _value, $Res Function(_$EsploraImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -5361,7 +5377,7 @@ class __$$EsploraCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Esplora( + return _then(_$EsploraImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -5372,8 +5388,8 @@ class __$$EsploraCopyWithImpl<$Res> /// @nodoc -class _$Esplora implements Esplora { - const _$Esplora(this.e); +class _$EsploraImpl implements Esplora { + const _$EsploraImpl(this.e); @override final String e; @@ -5384,10 +5400,10 @@ class _$Esplora implements Esplora { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Esplora && + other is _$EsploraImpl && (identical(other.e, e) || other.e == e)); } @@ -5397,8 +5413,8 @@ class _$Esplora implements Esplora { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$EsploraCopyWith<_$Esplora> get copyWith => - __$$EsploraCopyWithImpl<_$Esplora>(this, _$identity); + _$$EsploraImplCopyWith<_$EsploraImpl> get copyWith => + __$$EsploraImplCopyWithImpl<_$EsploraImpl>(this, _$identity); @override @optionalTypeArgs @@ -5606,27 +5622,28 @@ class _$Esplora implements Esplora { } abstract class Esplora implements BdkException { - const factory Esplora(final String e) = _$Esplora; + const factory Esplora(final String e) = _$EsploraImpl; String get e; @JsonKey(ignore: true) - _$$EsploraCopyWith<_$Esplora> get copyWith => + _$$EsploraImplCopyWith<_$EsploraImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$SledCopyWith<$Res> { - factory _$$SledCopyWith(_$Sled value, $Res Function(_$Sled) then) = - __$$SledCopyWithImpl<$Res>; +abstract class _$$SledImplCopyWith<$Res> { + factory _$$SledImplCopyWith( + _$SledImpl value, $Res Function(_$SledImpl) then) = + __$$SledImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$SledCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Sled> - implements _$$SledCopyWith<$Res> { - __$$SledCopyWithImpl(_$Sled _value, $Res Function(_$Sled) _then) +class __$$SledImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$SledImpl> + implements _$$SledImplCopyWith<$Res> { + __$$SledImplCopyWithImpl(_$SledImpl _value, $Res Function(_$SledImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -5634,7 +5651,7 @@ class __$$SledCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Sled( + return _then(_$SledImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -5645,8 +5662,8 @@ class __$$SledCopyWithImpl<$Res> /// @nodoc -class _$Sled implements Sled { - const _$Sled(this.e); +class _$SledImpl implements Sled { + const _$SledImpl(this.e); @override final String e; @@ -5657,10 +5674,10 @@ class _$Sled implements Sled { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Sled && + other is _$SledImpl && (identical(other.e, e) || other.e == e)); } @@ -5670,8 +5687,8 @@ class _$Sled implements Sled { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$SledCopyWith<_$Sled> get copyWith => - __$$SledCopyWithImpl<_$Sled>(this, _$identity); + _$$SledImplCopyWith<_$SledImpl> get copyWith => + __$$SledImplCopyWithImpl<_$SledImpl>(this, _$identity); @override @optionalTypeArgs @@ -5879,25 +5896,27 @@ class _$Sled implements Sled { } abstract class Sled implements BdkException { - const factory Sled(final String e) = _$Sled; + const factory Sled(final String e) = _$SledImpl; String get e; @JsonKey(ignore: true) - _$$SledCopyWith<_$Sled> get copyWith => throw _privateConstructorUsedError; + _$$SledImplCopyWith<_$SledImpl> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$RpcCopyWith<$Res> { - factory _$$RpcCopyWith(_$Rpc value, $Res Function(_$Rpc) then) = - __$$RpcCopyWithImpl<$Res>; +abstract class _$$RpcImplCopyWith<$Res> { + factory _$$RpcImplCopyWith(_$RpcImpl value, $Res Function(_$RpcImpl) then) = + __$$RpcImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$RpcCopyWithImpl<$Res> extends _$BdkExceptionCopyWithImpl<$Res, _$Rpc> - implements _$$RpcCopyWith<$Res> { - __$$RpcCopyWithImpl(_$Rpc _value, $Res Function(_$Rpc) _then) +class __$$RpcImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$RpcImpl> + implements _$$RpcImplCopyWith<$Res> { + __$$RpcImplCopyWithImpl(_$RpcImpl _value, $Res Function(_$RpcImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -5905,7 +5924,7 @@ class __$$RpcCopyWithImpl<$Res> extends _$BdkExceptionCopyWithImpl<$Res, _$Rpc> $Res call({ Object? e = null, }) { - return _then(_$Rpc( + return _then(_$RpcImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -5916,8 +5935,8 @@ class __$$RpcCopyWithImpl<$Res> extends _$BdkExceptionCopyWithImpl<$Res, _$Rpc> /// @nodoc -class _$Rpc implements Rpc { - const _$Rpc(this.e); +class _$RpcImpl implements Rpc { + const _$RpcImpl(this.e); @override final String e; @@ -5928,10 +5947,10 @@ class _$Rpc implements Rpc { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Rpc && + other is _$RpcImpl && (identical(other.e, e) || other.e == e)); } @@ -5941,8 +5960,8 @@ class _$Rpc implements Rpc { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$RpcCopyWith<_$Rpc> get copyWith => - __$$RpcCopyWithImpl<_$Rpc>(this, _$identity); + _$$RpcImplCopyWith<_$RpcImpl> get copyWith => + __$$RpcImplCopyWithImpl<_$RpcImpl>(this, _$identity); @override @optionalTypeArgs @@ -6150,27 +6169,29 @@ class _$Rpc implements Rpc { } abstract class Rpc implements BdkException { - const factory Rpc(final String e) = _$Rpc; + const factory Rpc(final String e) = _$RpcImpl; String get e; @JsonKey(ignore: true) - _$$RpcCopyWith<_$Rpc> get copyWith => throw _privateConstructorUsedError; + _$$RpcImplCopyWith<_$RpcImpl> get copyWith => + throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$RusqliteCopyWith<$Res> { - factory _$$RusqliteCopyWith( - _$Rusqlite value, $Res Function(_$Rusqlite) then) = - __$$RusqliteCopyWithImpl<$Res>; +abstract class _$$RusqliteImplCopyWith<$Res> { + factory _$$RusqliteImplCopyWith( + _$RusqliteImpl value, $Res Function(_$RusqliteImpl) then) = + __$$RusqliteImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$RusqliteCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$Rusqlite> - implements _$$RusqliteCopyWith<$Res> { - __$$RusqliteCopyWithImpl(_$Rusqlite _value, $Res Function(_$Rusqlite) _then) +class __$$RusqliteImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$RusqliteImpl> + implements _$$RusqliteImplCopyWith<$Res> { + __$$RusqliteImplCopyWithImpl( + _$RusqliteImpl _value, $Res Function(_$RusqliteImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -6178,7 +6199,7 @@ class __$$RusqliteCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$Rusqlite( + return _then(_$RusqliteImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -6189,8 +6210,8 @@ class __$$RusqliteCopyWithImpl<$Res> /// @nodoc -class _$Rusqlite implements Rusqlite { - const _$Rusqlite(this.e); +class _$RusqliteImpl implements Rusqlite { + const _$RusqliteImpl(this.e); @override final String e; @@ -6201,10 +6222,10 @@ class _$Rusqlite implements Rusqlite { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$Rusqlite && + other is _$RusqliteImpl && (identical(other.e, e) || other.e == e)); } @@ -6214,8 +6235,8 @@ class _$Rusqlite implements Rusqlite { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$RusqliteCopyWith<_$Rusqlite> get copyWith => - __$$RusqliteCopyWithImpl<_$Rusqlite>(this, _$identity); + _$$RusqliteImplCopyWith<_$RusqliteImpl> get copyWith => + __$$RusqliteImplCopyWithImpl<_$RusqliteImpl>(this, _$identity); @override @optionalTypeArgs @@ -6423,29 +6444,29 @@ class _$Rusqlite implements Rusqlite { } abstract class Rusqlite implements BdkException { - const factory Rusqlite(final String e) = _$Rusqlite; + const factory Rusqlite(final String e) = _$RusqliteImpl; String get e; @JsonKey(ignore: true) - _$$RusqliteCopyWith<_$Rusqlite> get copyWith => + _$$RusqliteImplCopyWith<_$RusqliteImpl> get copyWith => throw _privateConstructorUsedError; } /// @nodoc -abstract class _$$UnExpectedCopyWith<$Res> { - factory _$$UnExpectedCopyWith( - _$UnExpected value, $Res Function(_$UnExpected) then) = - __$$UnExpectedCopyWithImpl<$Res>; +abstract class _$$UnExpectedImplCopyWith<$Res> { + factory _$$UnExpectedImplCopyWith( + _$UnExpectedImpl value, $Res Function(_$UnExpectedImpl) then) = + __$$UnExpectedImplCopyWithImpl<$Res>; @useResult $Res call({String e}); } /// @nodoc -class __$$UnExpectedCopyWithImpl<$Res> - extends _$BdkExceptionCopyWithImpl<$Res, _$UnExpected> - implements _$$UnExpectedCopyWith<$Res> { - __$$UnExpectedCopyWithImpl( - _$UnExpected _value, $Res Function(_$UnExpected) _then) +class __$$UnExpectedImplCopyWithImpl<$Res> + extends _$BdkExceptionCopyWithImpl<$Res, _$UnExpectedImpl> + implements _$$UnExpectedImplCopyWith<$Res> { + __$$UnExpectedImplCopyWithImpl( + _$UnExpectedImpl _value, $Res Function(_$UnExpectedImpl) _then) : super(_value, _then); @pragma('vm:prefer-inline') @@ -6453,7 +6474,7 @@ class __$$UnExpectedCopyWithImpl<$Res> $Res call({ Object? e = null, }) { - return _then(_$UnExpected( + return _then(_$UnExpectedImpl( null == e ? _value.e : e // ignore: cast_nullable_to_non_nullable @@ -6464,8 +6485,8 @@ class __$$UnExpectedCopyWithImpl<$Res> /// @nodoc -class _$UnExpected implements UnExpected { - const _$UnExpected(this.e); +class _$UnExpectedImpl implements UnExpected { + const _$UnExpectedImpl(this.e); @override final String e; @@ -6476,10 +6497,10 @@ class _$UnExpected implements UnExpected { } @override - bool operator ==(dynamic other) { + bool operator ==(Object other) { return identical(this, other) || (other.runtimeType == runtimeType && - other is _$UnExpected && + other is _$UnExpectedImpl && (identical(other.e, e) || other.e == e)); } @@ -6489,8 +6510,8 @@ class _$UnExpected implements UnExpected { @JsonKey(ignore: true) @override @pragma('vm:prefer-inline') - _$$UnExpectedCopyWith<_$UnExpected> get copyWith => - __$$UnExpectedCopyWithImpl<_$UnExpected>(this, _$identity); + _$$UnExpectedImplCopyWith<_$UnExpectedImpl> get copyWith => + __$$UnExpectedImplCopyWithImpl<_$UnExpectedImpl>(this, _$identity); @override @optionalTypeArgs @@ -6698,10 +6719,10 @@ class _$UnExpected implements UnExpected { } abstract class UnExpected implements BdkException { - const factory UnExpected(final String e) = _$UnExpected; + const factory UnExpected(final String e) = _$UnExpectedImpl; String get e; @JsonKey(ignore: true) - _$$UnExpectedCopyWith<_$UnExpected> get copyWith => + _$$UnExpectedImplCopyWith<_$UnExpectedImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/agent_dart_base/lib/wallet/btc/bdk/buffer.dart b/packages/agent_dart_base/lib/wallet/btc/bdk/buffer.dart index 3e635401..3aa6e055 100644 --- a/packages/agent_dart_base/lib/wallet/btc/bdk/buffer.dart +++ b/packages/agent_dart_base/lib/wallet/btc/bdk/buffer.dart @@ -1,5 +1,5 @@ -/// Moved from `https://github.com/dart-bitcoin-lib/dart-buffer` -/// Buffer Reader and Buffer Writer +// Moved from `https://github.com/dart-bitcoin-lib/dart-buffer` +// Buffer Reader and Buffer Writer import 'dart:math' as math; import 'dart:typed_data'; @@ -39,8 +39,13 @@ class BufferReader { /// supporting up to 48 bits of accuracy. int getUInt([int byteLength = 0, Endian endian = Endian.little]) { if (offset + byteLength > length) { - throw IndexError(byteLength, buffer, 'IndexError', - 'Cannot get UIntLE out of bounds', buffer.lengthInBytes); + throw IndexError( + byteLength, + buffer, + 'IndexError', + 'Cannot get UIntLE out of bounds', + buffer.lengthInBytes, + ); } if (endian != Endian.little) { var val = buffer.buffer.asUint8List()[offset]; @@ -185,8 +190,13 @@ class BufferReader { /// The return value will be ByteData(n) ByteData getSlice(int n) { if (buffer.lengthInBytes < offset + n) { - throw IndexError(n, buffer, 'IndexError', - 'Cannot get slice out of bounds', buffer.lengthInBytes); + throw IndexError( + n, + buffer, + 'IndexError', + 'Cannot get slice out of bounds', + buffer.lengthInBytes, + ); } final result = buffer.buffer .asUint8List() @@ -472,21 +482,20 @@ class BufferWriter { /// Convert [ByteData] to [T] T toTypeData>() { - switch (T) { - case Uint8List: - return buffer.buffer.asUint8List() as T; - case Int8List: - return buffer.buffer.asInt8List() as T; - case Uint16List: - return buffer.buffer.asUint16List() as T; - case Int16List: - return buffer.buffer.asInt16List() as T; - case Uint32List: - return buffer.buffer.asUint32List() as T; - case Int32List: - return buffer.buffer.asInt32List() as T; - default: - throw const FormatException('Invalid Generic Type'); + if (T == Uint8List) { + return buffer.buffer.asUint8List() as T; + } else if (T == Uint16List) { + return buffer.buffer.asUint16List() as T; + } else if (T == Uint32List) { + return buffer.buffer.asUint32List() as T; + } else if (T == Int8List) { + return buffer.buffer.asInt8List() as T; + } else if (T == Int16List) { + return buffer.buffer.asInt16List() as T; + } else if (T == Int32List) { + return buffer.buffer.asInt32List() as T; + } else { + throw const FormatException('Invalid Generic Type'); } } } diff --git a/packages/agent_dart_base/lib/wallet/btc/bdk/wif.dart b/packages/agent_dart_base/lib/wallet/btc/bdk/wif.dart index 4cfcb2d3..d500318c 100644 --- a/packages/agent_dart_base/lib/wallet/btc/bdk/wif.dart +++ b/packages/agent_dart_base/lib/wallet/btc/bdk/wif.dart @@ -78,13 +78,13 @@ class WIF { this.compressed = false, }); - factory WIF.fromHex(Uint8List u8a, {Network network = Network.Bitcoin}) { - final version = network == Network.Bitcoin ? 0x80 : 0xef; + factory WIF.fromHex(Uint8List u8a, {Network network = Network.bitcoin}) { + final version = network == Network.bitcoin ? 0x80 : 0xef; return WIF(version: version, privateKey: u8a); } - factory WIF.fromString(String wif, {Network network = Network.Bitcoin}) { - final version = network == Network.Bitcoin ? 0x80 : 0xef; + factory WIF.fromString(String wif, {Network network = Network.bitcoin}) { + final version = network == Network.bitcoin ? 0x80 : 0xef; return wifDecoder.convert(wif, version); } @@ -99,9 +99,9 @@ class WIF { static Future hexToWif( String hex, { - Network network = Network.Bitcoin, + Network network = Network.bitcoin, }) { - return AgentDartFFI.impl.hexBytesToWif(hex: hex, network: network); + return hexBytesToWif(hex: hex, network: network); } @override diff --git a/packages/agent_dart_base/lib/wallet/btc_wallet.dart b/packages/agent_dart_base/lib/wallet/btc_wallet.dart index f4df8b58..9783ca2f 100644 --- a/packages/agent_dart_base/lib/wallet/btc_wallet.dart +++ b/packages/agent_dart_base/lib/wallet/btc_wallet.dart @@ -1,7 +1,8 @@ import 'dart:async'; +import 'dart:typed_data'; import 'package:agent_dart_base/agent/ord/blockstream.dart'; -import 'package:agent_dart_base/agent/ord/inscriptionItem.dart'; +import 'package:agent_dart_base/agent/ord/inscription_item.dart'; import 'package:agent_dart_base/agent/ord/service.dart'; import 'package:agent_dart_base/agent/ord/utxo.dart'; import 'package:agent_dart_base/agent_dart_base.dart'; @@ -19,7 +20,7 @@ enum BitcoinNetwork { } class ReceiverItem { - ReceiverItem({ + const ReceiverItem({ required this.address, required this.amount, }); @@ -29,7 +30,7 @@ class ReceiverItem { } class ReceiverItemWithAddress { - ReceiverItemWithAddress({ + const ReceiverItemWithAddress({ required this.address, required this.amount, }); @@ -39,7 +40,7 @@ class ReceiverItemWithAddress { } class BTCDescriptor { - BTCDescriptor({ + const BTCDescriptor({ required this.addressType, required this.descriptor, required this.network, @@ -51,7 +52,7 @@ class BTCDescriptor { } class PSBTDetail { - PSBTDetail({ + const PSBTDetail({ required this.inputs, required this.outputs, required this.fee, @@ -114,13 +115,15 @@ class TxOutExt { } class UtxoHandlers { - UtxoHandlers({required this.ins, required this.nonIns, required this.txs}); + const UtxoHandlers( + {required this.ins, required this.nonIns, required this.txs}); final List ins; final List nonIns; final List txs; } +// ignore: non_constant_identifier_names const UTXO_DUST = 546; class UnconfirmedBalance { @@ -130,8 +133,8 @@ class UnconfirmedBalance { required this.tooManyUnconfirmed, }); - int mempoolSpendTxValue = 0; - int mempoolReceiveTxValue = 0; + BigInt mempoolSpendTxValue = BigInt.zero; + BigInt mempoolReceiveTxValue = BigInt.zero; bool tooManyUnconfirmed = false; Map toJson() => { @@ -166,16 +169,16 @@ class BitcoinBalance { final Balance balance; final UnconfirmedBalance _unconfirmedBalance = UnconfirmedBalance( - mempoolReceiveTxValue: 0, - mempoolSpendTxValue: 0, + mempoolReceiveTxValue: BigInt.zero, + mempoolSpendTxValue: BigInt.zero, tooManyUnconfirmed: false, ); - void setMempoolSpendTxValue(int value) { + void setMempoolSpendTxValue(BigInt value) { _unconfirmedBalance.mempoolSpendTxValue = value; } - void setMempoolReceiveTxValue(int value) { + void setMempoolReceiveTxValue(BigInt value) { _unconfirmedBalance.mempoolReceiveTxValue = value; } @@ -199,17 +202,17 @@ class BitcoinBalance { 'total': balance.total, }; - int get total => balance.total; + BigInt get total => balance.total; - int get spendable => balance.spendable; + BigInt get spendable => balance.spendable; - int get confirmed => balance.confirmed; + BigInt get confirmed => balance.confirmed; - int get untrustedPending => balance.untrustedPending; + BigInt get untrustedPending => balance.untrustedPending; - int get trustedPending => balance.trustedPending; + BigInt get trustedPending => balance.trustedPending; - int get immature => balance.immature; + BigInt get immature => balance.immature; UnconfirmedBalance get unconfirmed => _unconfirmedBalance; } @@ -217,7 +220,7 @@ class BitcoinBalance { Future getAddressInfo({ required String phrase, required int index, - Network network = Network.Bitcoin, + Network network = Network.bitcoin, AddressType addressType = AddressType.P2TR, String? passcode, }) async { @@ -227,13 +230,13 @@ Future getAddressInfo({ addressType: addressType, passcode: passcode, ); - final descriptor = descriptors[KeychainKind.External]!; + final descriptor = descriptors[KeychainKind.extern]!; return descriptor.descriptor.deriveAddressAt(index, network); } Future getAddressInfoFromWIF({ required String wif, - Network network = Network.Bitcoin, + Network network = Network.bitcoin, AddressType addressType = AddressType.P2TR, }) async { final descriptor = await importSingleWif( @@ -247,7 +250,7 @@ Future getAddressInfoFromWIF({ Future> getDescriptors( String mnemonic, { AddressType addressType = AddressType.P2TR, - Network network = Network.Bitcoin, + Network network = Network.bitcoin, String? passcode, }) async { final mnemonicObj = await Mnemonic.fromString(mnemonic); @@ -285,7 +288,7 @@ Future> getDescriptors( Future importSingleWif( String wif, { AddressType addressType = AddressType.P2TR, - Network network = Network.Bitcoin, + Network network = Network.bitcoin, }) async { final descriptor = await Descriptor.importSingleWif( wif: wif, @@ -304,17 +307,14 @@ Future importSingleWif( ); } -enum WalletType { - HD, - Single, -} +enum WalletType { HD, Single } class BitcoinWallet { BitcoinWallet({ required this.wallet, required this.addressType, required this.descriptor, - this.network = Network.Bitcoin, + this.network = Network.bitcoin, this.ordService, this.blockStreamApi, WalletType walletType = WalletType.HD, @@ -340,7 +340,7 @@ class BitcoinWallet { SignIdentity? _signIdentity; - final int COINBASE_MATURITY = 100; + final int coinbaseMaturity = 100; void connect({OrdService? service, BlockStreamApi? api}) { ordService ??= service; @@ -364,7 +364,7 @@ class BitcoinWallet { } // Future blockchainInit({ - // Network network = Network.Bitcoin, + // Network network = Network.bitcoin, // BlockchainConfig? blockchainConfig, // }) async { // blockchain = await Blockchain.create( @@ -375,7 +375,7 @@ class BitcoinWallet { // timeout: 5, // retry: 5, // url: - // 'ssl://electrum.blockstream.info:${network == Network.Bitcoin ? 50002 : 60002}', + // 'ssl://electrum.blockstream.info:${network == Network.bitcoin ? 50002 : 60002}', // validateDomain: false, // ), // ), @@ -384,7 +384,7 @@ class BitcoinWallet { // // config: BlockchainConfig.esplora( // // config: EsploraConfig( // // baseUrl: - // // 'https://mempool.space/${(net ?? network) == Network.Bitcoin ? '' : 'testnet/'}api', // https://mempool.space/api', + // // 'https://mempool.space/${(net ?? network) == Network.bitcoin ? '' : 'testnet/'}api', // https://mempool.space/api', // // concurrency: 4, // // stopGap: 10, // // ))); @@ -392,7 +392,7 @@ class BitcoinWallet { static Future fromPhrase( String phrase, { - Network network = Network.Bitcoin, + Network network = Network.bitcoin, AddressType addressType = AddressType.P2TR, String? passcode, }) async { @@ -402,7 +402,7 @@ class BitcoinWallet { addressType: addressType, passcode: passcode, ); - final descriptor = descriptors[KeychainKind.External]!; + final descriptor = descriptors[KeychainKind.extern]!; final res = await Wallet.create( descriptor: descriptor.descriptor, changeDescriptor: descriptor.descriptor, @@ -422,7 +422,7 @@ class BitcoinWallet { static Future fromWif( String wifOrHex, { - Network network = Network.Bitcoin, + Network network = Network.bitcoin, AddressType addressType = AddressType.P2TR, WalletType walletType = WalletType.HD, }) async { @@ -458,12 +458,19 @@ class BitcoinWallet { return wallet; } + Future getDescriptorSecretKey(int? index) async { + final DescriptorSecretKey k; + if (descriptor.descriptor.descriptorSecretKey?.derivedPathPrefix != null) { + k = await descriptor.descriptor.descriptorSecretKey!.deriveIndex(index!); + } else { + k = descriptor.descriptor.descriptorSecretKey!; + } + return k; + } + // ====== Signer ====== Future getSigner(int index) async { - final k = getWalletType() == WalletType.HD - ? await descriptor.descriptor.descriptorSecretKey!.deriveIndex(index) - : descriptor.descriptor.descriptorSecretKey!; - + final k = await getDescriptorSecretKey(index); final kBytes = Uint8List.fromList(await k.secretBytes()); _publicKey = await k.getPubFromBytes(kBytes); return wallet.getAddress( @@ -510,29 +517,30 @@ class BitcoinWallet { throw Exception('blockStreamApi should be initialized first'); } address ??= _selectedSigner.address; - var immature = 0; - const trustedPending = 0; // we don't use internal key to receive - var untrustedPending = 0; - var confirmed = 0; - var mempoolSpendTxValue = 0; - var mempoolReceiveTxValue = 0; - var tooManyUnconfirmed = false; + BigInt immature = BigInt.zero; + final trustedPending = + BigInt.zero; // we don't use internal key to receive + BigInt untrustedPending = BigInt.zero; + BigInt confirmed = BigInt.zero; + BigInt mempoolSpendTxValue = BigInt.zero; + BigInt mempoolReceiveTxValue = BigInt.zero; + bool tooManyUnconfirmed = false; final utxos = await blockStreamApi!.getAddressUtxo(address); final blockHeight = await getHeight(); - for (var i = 0; i < utxos.length; i++) { + for (int i = 0; i < utxos.length; i++) { final u = utxos[i]; if (u.status.confirmed) { final tx = await getTxFromTxId(u.txid); if (await tx.isCoinBase() && - (blockHeight - u.status.block_height!) < COINBASE_MATURITY) { - immature += u.value; + (blockHeight - u.status.blockHeight!) < coinbaseMaturity) { + immature += BigInt.from(u.value); } else { - confirmed += u.value; + confirmed += BigInt.from(u.value); } } else { - untrustedPending += u.value; + untrustedPending += BigInt.from(u.value); } } final spendable = confirmed + trustedPending; @@ -540,11 +548,11 @@ class BitcoinWallet { if (includeUnconfirmed) { final txCount = (await blockStreamApi!.getAddressStats(address)) - .mempool_stats - .tx_count; + .mempoolStats + .txCount; if (txCount <= 0) { - mempoolSpendTxValue = 0; - mempoolReceiveTxValue = 0; + mempoolSpendTxValue = BigInt.zero; + mempoolReceiveTxValue = BigInt.zero; } else { if (txCount > 50) { tooManyUnconfirmed = true; @@ -558,14 +566,16 @@ class BitcoinWallet { continue; } mempoolSpendTxValue += tx.vin - .where((e) => e.prevout.scriptpubkey_address == address) - .fold(0, (prev, e) => prev + e.prevout.value); + .where((e) => e.prevout.scriptpubkeyAddress == address) + .fold( + BigInt.zero, + (prev, e) => prev + BigInt.from(e.prevout.value), + ); mempoolReceiveTxValue += tx.vout - .where((e) => e.scriptpubkey_address == address) - .fold(0, (prev, e) => prev + e.value); + .where((e) => e.scriptpubkeyAddress == address) + .fold(BigInt.zero, (prev, e) => prev + BigInt.from(e.value)); } } - total = total + mempoolReceiveTxValue + mempoolSpendTxValue; } @@ -587,7 +597,7 @@ class BitcoinWallet { )); } return finalBalance; - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -603,7 +613,7 @@ class BitcoinWallet { final utxos = await ordService!.getUtxoGet(address ?? _selectedSigner.address); return utxos; - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -616,7 +626,7 @@ class BitcoinWallet { final ins = await ordService!.getInscriptions(address ?? _selectedSigner.address); return ins; - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -627,7 +637,7 @@ class BitcoinWallet { // final res = await AgentDartFFI.impl // .psbtWalletGetTxs(wallet: _selectedSigner.getWalletReq()); // return res; - // } on FfiException catch (e) { + // } on AnyhowException catch (e) { // throw (e.message); // } // } @@ -636,7 +646,7 @@ class BitcoinWallet { try { final res = await blockStreamApi!.getBlockHeight(); return res; - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -645,7 +655,7 @@ class BitcoinWallet { // try { // final res = await blockchain.getTx(txid); // return await Transaction.create(transactionBytes: res.toU8a()); - // } on FfiException catch (e) { + // } on AnyhowException catch (e) { // throw e.message; // } // } @@ -654,7 +664,7 @@ class BitcoinWallet { try { final res = await blockStreamApi!.getTxHex(txid); return await Transaction.create(transactionBytes: res.toU8a()); - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -664,7 +674,7 @@ class BitcoinWallet { final theTx = await tx.psbt.extractTx(); return await blockStreamApi! .broadcastTx(Uint8List.fromList(await theTx.serialize()).toHex()); - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -710,7 +720,7 @@ class BitcoinWallet { .map( (e) => InscriptionValue( inscriptionId: e.id, - outputValue: e.detail.output_value, + outputValue: e.detail.outputValue, ), ) .toList(); @@ -743,27 +753,17 @@ class BitcoinWallet { return completer.future; } - Future getSafeBalance({ - String? address, - }) async { + Future getSafeBalance({String? address}) async { final xos = await handleUtxo(address: address); final nonIns = xos.nonIns; - final res = nonIns.fold( - 0, - (previousValue, element) => previousValue + element.value, - ); + final res = nonIns.fold(0, (p, v) => p + v.value); return res; } - Future getOrdinalBalance({ - String? address, - }) async { + Future getOrdinalBalance({String? address}) async { final xos = await handleUtxo(address: address); final ins = xos.ins; - final res = ins.fold( - 0, - (previousValue, element) => previousValue + element.value, - ); + final res = ins.fold(0, (p, v) => p + v.value); return res; } @@ -775,11 +775,12 @@ class BitcoinWallet { bool bigAmountFirst = true, }) async { final txr = await createSendBTC( - toAddress: toAddress, - amount: amount, - feeRate: feeRate, - useUTXOCache: useUTXOCache, - bigAmountFirst: bigAmountFirst); + toAddress: toAddress, + amount: amount, + feeRate: feeRate, + useUTXOCache: useUTXOCache, + bigAmountFirst: bigAmountFirst, + ); final signed = await sign(txr); return signed.psbt.feeAmount(); } @@ -841,8 +842,8 @@ class BitcoinWallet { var tmpSum = builder.getTotalInput(); final tempAddInputs = []; - var fee = 0; - for (var i = 0; i < nonIns.length; i++) { + int fee = 0; + for (int i = 0; i < nonIns.length; i++) { final nonOrdUtxo = nonIns[i]; if (tmpSum < outputAmount) { builder.addInput(nonOrdUtxo); @@ -853,7 +854,7 @@ class BitcoinWallet { continue; } - fee = await builder.calFee(wallet) + amount; + fee = (await builder.calFee(wallet)).toInt() + amount; if (tmpSum < outputAmount + fee) { builder.addInput(nonOrdUtxo); @@ -872,7 +873,7 @@ class BitcoinWallet { throw Exception('Balance not enough to pay network fee.'); } - final networkFee = (await builder.calNetworkFee(wallet))!; + final networkFee = (await builder.calNetworkFee(wallet))!.toInt(); if (unspent < networkFee) { throw Exception( @@ -881,7 +882,6 @@ class BitcoinWallet { } final leftAmount = unspent - networkFee; - if (leftAmount >= UTXO_DUST) { // change dummy output to true output // add dummy output @@ -890,10 +890,12 @@ class BitcoinWallet { // remove dummy output throw Exception('Output below Dust Limit of $UTXO_DUST Sats.'); } - final lastFinalFee = amount + leftAmount + await builder.calFee(wallet); + final lastFinalFee = + amount + leftAmount + (await builder.calFee(wallet)).toInt(); if (lastFinalFee > tmpSum) { throw Exception( - 'You need $lastFinalFee to finish the payment, but only $tmpSum avaliable.', + 'You need $lastFinalFee to finish the payment, ' + 'but only $tmpSum available.', ); } @@ -933,9 +935,12 @@ class BitcoinWallet { // formatted addresses final formattedAddresses = []; for (var i = 0; i < toAddresses.length; i++) { - formattedAddresses.add(ReceiverItemWithAddress( + formattedAddresses.add( + ReceiverItemWithAddress( address: await Address.create(address: toAddresses[i].address), - amount: toAddresses[i].amount)); + amount: toAddresses[i].amount, + ), + ); } final changeAddress = @@ -988,8 +993,8 @@ class BitcoinWallet { var tmpSum = builder.getTotalInput(); final tempAddInputs = []; - var fee = 0; - for (var i = 0; i < nonIns.length; i++) { + int fee = 0; + for (int i = 0; i < nonIns.length; i++) { final nonOrdUtxo = nonIns[i]; if (tmpSum < outputAmount) { builder.addInput(nonOrdUtxo); @@ -1103,9 +1108,9 @@ class BitcoinWallet { // 3.1 select inscription and proctect those unspendables final tempInputs = []; - var satoshis = 0; - var found = false; - var ordLeft = 0; + int satoshis = 0; + bool found = false; + int ordLeft = 0; for (final e in ins) { // try and find the inscription matches the inscription id final index = e.inscriptions! @@ -1174,9 +1179,9 @@ class BitcoinWallet { final outputAmount = builder.getTotalOutput(); // print('outputAmount: $outputAmount'); - var tmpSum = builder.getTotalInput(); - var fee = 0; - for (var i = 0; i < nonIns.length; i++) { + int tmpSum = builder.getTotalInput(); + int fee = 0; + for (int i = 0; i < nonIns.length; i++) { final nonOrdUtxo = nonIns[i]; if (tmpSum < outputAmount) { // manually add input to inputs @@ -1229,7 +1234,9 @@ class BitcoinWallet { if (lastFinalFee > tmpSum) { throw Exception( - 'You need $lastFinalFee to finish the payment, but only $tmpSum avaliable.'); + 'You need $lastFinalFee to finish the payment, ' + 'but only $tmpSum available.', + ); } // finish the build and get ready to dump Data @@ -1246,12 +1253,13 @@ class BitcoinWallet { bool bigAmountFirst = true, }) async { final txr = await createSendMultiInscriptions( - toAddress: toAddress, - insIds: insIds, - feeRate: feeRate, - outputValue: outputValue, - useUTXOCache: useUTXOCache, - bigAmountFirst: bigAmountFirst); + toAddress: toAddress, + insIds: insIds, + feeRate: feeRate, + outputValue: outputValue, + useUTXOCache: useUTXOCache, + bigAmountFirst: bigAmountFirst, + ); final signed = await sign(txr); return signed.psbt.feeAmount(); } @@ -1291,13 +1299,14 @@ class BitcoinWallet { // 3.1 select inscription and proctect those unspendables final tempInputs = []; - var satoshis = 0; - var found = false; - var ordLeft = 0; + int satoshis = 0; + bool found = false; + int ordLeft = 0; for (final e in ins) { // try and find the inscription matches the inscription id - final index = e.inscriptions! - .indexWhere((element) => insIds.contains(element.inscriptionId)); + final index = e.inscriptions!.indexWhere( + (element) => insIds.contains(element.inscriptionId), + ); if (index > -1) { // add to input map builder.addInput(e); @@ -1363,7 +1372,7 @@ class BitcoinWallet { // print('outputAmount: $outputAmount'); var tmpSum = builder.getTotalInput(); - var fee = 0; + int fee = 0; for (var i = 0; i < nonIns.length; i++) { final nonOrdUtxo = nonIns[i]; if (tmpSum < outputAmount) { @@ -1399,7 +1408,8 @@ class BitcoinWallet { if (unspent < networkFee!) { throw Exception( - 'Balance not enough. Need $networkFee Sats as network fee, but only $unspent BTC.', + 'Balance not enough. Need $networkFee Sats as network fee, ' + 'but only $unspent BTC.', ); } @@ -1462,9 +1472,9 @@ class BitcoinWallet { // 3.1 select inscription and proctect those unspendables final tempInputs = []; - var satoshis = 0; + int satoshis = 0; var found = false; - var ordLeft = 0; + int ordLeft = 0; for (final e in ins) { // try and find the inscription matches the inscription id final index = e.inscriptions! @@ -1536,8 +1546,8 @@ class BitcoinWallet { var tmpSum = builder.getTotalInput(); - var fee = 0; - for (var i = 0; i < nonIns.length; i++) { + int fee = 0; + for (int i = 0; i < nonIns.length; i++) { final nonOrdUtxo = nonIns[i]; if (tmpSum < outputAmount) { // manually add input to inputs @@ -1572,7 +1582,8 @@ class BitcoinWallet { if (unspent < networkFee!) { throw Exception( - 'Balance not enough. Need $networkFee Sats as network fee, but only $unspent BTC.', + 'Balance not enough. Need $networkFee Sats as network fee, ' + 'but only $unspent BTC.', ); } @@ -1590,7 +1601,9 @@ class BitcoinWallet { if (lastFinalFee > tmpSum) { throw Exception( - 'You need $lastFinalFee to finish the payment, but only $tmpSum avaliable.'); + 'You need $lastFinalFee to finish the payment, ' + 'but only $tmpSum available.', + ); } // finish the build and get ready to dump Data @@ -1622,7 +1635,7 @@ class BitcoinWallet { txDetails: buildResult.txDetails, signed: true, ); - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -1641,7 +1654,7 @@ class BitcoinWallet { return await blockStreamApi! .broadcastTx(Uint8List.fromList(await tx.serialize()).toHex()); - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -1654,7 +1667,7 @@ class BitcoinWallet { return await Future.wait( psbtHexs.map((hex) => signPsbt(hex, options: options)), ); - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } @@ -1679,8 +1692,8 @@ class BitcoinWallet { txId: txId, index: i, address: addr, - value: element.value, - isMine: addr == currentSigner().address ? true : false, + value: element.value.toInt(), + isMine: addr.address == currentSigner().address, isChange: false, ), ); @@ -1696,8 +1709,8 @@ class BitcoinWallet { TxOutExt( index: i, address: addr, - value: element.value, - isMine: addr == currentSigner().address ? true : false, + value: element.value.toInt(), + isMine: addr.address == currentSigner().address, isChange: i == outputs.length - 1 ? true : false, ), ); @@ -1727,16 +1740,14 @@ class BitcoinWallet { bool useBip322 = false, }) async { try { - final k = getWalletType() == WalletType.HD - ? await descriptor.descriptor.descriptorSecretKey! - .deriveIndex(currentIndex() ?? 0) - : descriptor.descriptor.descriptorSecretKey!; - + final k = await getDescriptorSecretKey(currentIndex()); final kBytes = Uint8List.fromList(await k.secretBytes()); if (!useBip322) { - final res = - await signSecp256k1WithRNG(wallet.messageHandler(message), kBytes); + final res = await signSecp256k1WithRNG( + wallet.messageHandler(message), + kBytes, + ); /// move v to the top, and plus 27 final v = res.sublist(64, 65); @@ -1752,30 +1763,23 @@ class BitcoinWallet { } else { String? res; if (addressType == AddressType.P2TR) { - res = await AgentDartFFI.impl.bip322SignTaprootStaticMethodApi( - secret: kBytes, message: message); + res = await Api.bip322SignTaproot(secret: kBytes, message: message); } else { - res = await AgentDartFFI.impl.bip322SignSegwitStaticMethodApi( - secret: kBytes, message: message); + res = await Api.bip322SignSegwit(secret: kBytes, message: message); } - if (toBase64) { return res; } else { return base64Decode(res).toHex(); } } - } on FfiException catch (e) { + } on AnyhowException catch (e) { throw e.message; } } Future getIdentity() async { - final k = getWalletType() == WalletType.HD - ? await descriptor.descriptor.descriptorSecretKey! - .deriveIndex(currentIndex() ?? 0) - : descriptor.descriptor.descriptorSecretKey!; - + final k = await getDescriptorSecretKey(currentIndex()); final kBytes = Uint8List.fromList(await k.secretBytes()); _signIdentity = await Secp256k1KeyIdentity.fromSecretKey(kBytes); return _signIdentity as Secp256k1KeyIdentity; diff --git a/packages/agent_dart_base/lib/wallet/keysmith.dart b/packages/agent_dart_base/lib/wallet/keysmith.dart index 1b3ff65b..dc6d3217 100644 --- a/packages/agent_dart_base/lib/wallet/keysmith.dart +++ b/packages/agent_dart_base/lib/wallet/keysmith.dart @@ -104,20 +104,20 @@ Future getECKeysAsync( int coinType = CoinType.icp, }) async { final basePath = getPathWithCoinType(coinType: coinType); - final seed = await AgentDartFFI.impl.mnemonicPhraseToSeed( + final seed = await mnemonicPhraseToSeed( req: PhraseToSeedReq(phrase: phrase, password: passphrase), ); - final prv = await AgentDartFFI.impl.mnemonicSeedToKey( + final prv = await mnemonicSeedToKey( req: SeedToKeyReq(seed: seed, path: '$basePath/0/$index'), ); - final kp = await AgentDartFFI.impl.secp256K1FromSeed( + final kp = await secp256K1FromSeed( req: Secp256k1FromSeedReq(seed: prv), ); - final kpSchnorr = await AgentDartFFI.impl.schnorrFromSeed( + final kpSchnorr = await schnorrFromSeed( req: SchnorrFromSeedReq(seed: prv), ); - final kpP256 = await AgentDartFFI.impl.p256FromSeed( + final kpP256 = await p256FromSeed( req: P256FromSeedReq(seed: prv), ); return ECKeys( @@ -130,13 +130,13 @@ Future getECKeysAsync( } Future getECkeyFromPrivateKey(Uint8List prv) async { - final kp = await AgentDartFFI.impl.secp256K1FromSeed( + final kp = await secp256K1FromSeed( req: Secp256k1FromSeedReq(seed: prv), ); - final kpSchnorr = await AgentDartFFI.impl.schnorrFromSeed( + final kpSchnorr = await schnorrFromSeed( req: SchnorrFromSeedReq(seed: prv), ); - final kpP256 = await AgentDartFFI.impl.p256FromSeed( + final kpP256 = await p256FromSeed( req: P256FromSeedReq(seed: prv), ); @@ -194,21 +194,21 @@ Uint8List? getPublicFromPrivateKeyBigInt( } Future getDerFromFFI(Uint8List seed) async { - final ffiIdentity = await AgentDartFFI.impl.secp256K1FromSeed( + final ffiIdentity = await secp256K1FromSeed( req: Secp256k1FromSeedReq(seed: seed), ); return ffiIdentity.derEncodedPublicKey; } Future getSchnorrPubFromFFI(Uint8List seed) async { - final ffiIdentity = await AgentDartFFI.impl.schnorrFromSeed( + final ffiIdentity = await schnorrFromSeed( req: SchnorrFromSeedReq(seed: seed), ); return ffiIdentity.publicKeyHash; } Future getP256DerPubFromFFI(Uint8List seed) async { - final ffiIdentity = await AgentDartFFI.impl.p256FromSeed( + final ffiIdentity = await p256FromSeed( req: P256FromSeedReq(seed: seed), ); return ffiIdentity.derEncodedPublicKey; diff --git a/packages/agent_dart_base/lib/wallet/phrase.dart b/packages/agent_dart_base/lib/wallet/phrase.dart index 13c156b5..fae7bbcd 100644 --- a/packages/agent_dart_base/lib/wallet/phrase.dart +++ b/packages/agent_dart_base/lib/wallet/phrase.dart @@ -40,7 +40,7 @@ class Phrase { List get list => _list; Future toSeed({String passphrase = ''}) { - return AgentDartFFI.impl.mnemonicPhraseToSeed( + return mnemonicPhraseToSeed( req: PhraseToSeedReq( phrase: mnemonic, password: passphrase, @@ -55,7 +55,7 @@ class Phrase { }) async { final basePath = getPathWithCoinType(coinType: coinType); final seed = await toSeed(passphrase: passphrase); - return AgentDartFFI.impl.mnemonicSeedToKey( + return mnemonicSeedToKey( req: SeedToKeyReq( seed: seed, path: '$basePath/0/$index', diff --git a/packages/agent_dart_base/pubspec.yaml b/packages/agent_dart_base/pubspec.yaml index f20751fb..26a7b7f2 100644 --- a/packages/agent_dart_base/pubspec.yaml +++ b/packages/agent_dart_base/pubspec.yaml @@ -7,7 +7,7 @@ issue_tracker: https://github.com/AstroxNetwork/agent_dart/issues publish_to: none environment: - sdk: ^3.3.0 + sdk: ^3.4.0 dependencies: agent_dart_ffi: @@ -29,7 +29,7 @@ dependencies: crypto: ^3.0.2 ffi: ^2.0.1 fixnum: ^1.0.1 - flutter_rust_bridge: 1.82.6 + flutter_rust_bridge: '>=2.0.0 <2.1.0' http: ^1.0.0 js: '>=0.6.4 <0.8.0' meta: ^1.7.0 @@ -47,7 +47,11 @@ dependencies: freezed: ^2.0.3+1 dev_dependencies: - ffigen: '>=8.0.0 <10.0.0' + lints: # transparent + ffigen: ^11.0.0 test: ^1.24.0 build_runner: ^2.4.5 json_serializable: ^6.7.0 + +false_secrets: + - test/fixture/*.pem diff --git a/packages/agent_dart_base/test/agent_dart_base_test.dart b/packages/agent_dart_base/test/agent_dart_base_test.dart index f1388bc1..85f079bc 100644 --- a/packages/agent_dart_base/test/agent_dart_base_test.dart +++ b/packages/agent_dart_base/test/agent_dart_base_test.dart @@ -9,7 +9,8 @@ import 'wallet/pem.dart' as pem; import 'wallet/signer.dart' as signer; void main() async { - matchFFI(); + ffiInit(); + // matchFFI(); agent.main(); auth.main(); candid.main(); diff --git a/packages/agent_dart_base/test/identity/delegation.dart b/packages/agent_dart_base/test/identity/delegation.dart index bf46036f..21c8877f 100644 --- a/packages/agent_dart_base/test/identity/delegation.dart +++ b/packages/agent_dart_base/test/identity/delegation.dart @@ -18,7 +18,8 @@ Future createIdentity(int seed) { // return blobFromHex(text.codeUnits.); // } void main() { - matchFFI(); + ffiInit(); + // matchFFI(); delegationTest(); } diff --git a/packages/agent_dart_base/test/identity/ed25519.dart b/packages/agent_dart_base/test/identity/ed25519.dart index f633d3c6..047e2332 100644 --- a/packages/agent_dart_base/test/identity/ed25519.dart +++ b/packages/agent_dart_base/test/identity/ed25519.dart @@ -10,7 +10,8 @@ import '../test_utils.dart'; // import 'package:agent_dart/utils/extension.dart'; void main() { - matchFFI(); + ffiInit(); + // matchFFI(); ed25519Test(); } diff --git a/packages/agent_dart_base/test/identity/identity.dart b/packages/agent_dart_base/test/identity/identity.dart index 17903b52..26c92940 100644 --- a/packages/agent_dart_base/test/identity/identity.dart +++ b/packages/agent_dart_base/test/identity/identity.dart @@ -4,7 +4,8 @@ import 'ed25519.dart' as ed25519; import 'secp256k1.dart' as secp256k1; void main() { - matchFFI(); + ffiInit(); + // matchFFI(); delegation.main(); ed25519.main(); secp256k1.main(); diff --git a/packages/agent_dart_base/test/identity/p256.dart b/packages/agent_dart_base/test/identity/p256.dart index 0d551fbe..caf8e54c 100644 --- a/packages/agent_dart_base/test/identity/p256.dart +++ b/packages/agent_dart_base/test/identity/p256.dart @@ -3,7 +3,8 @@ import 'package:test/test.dart'; import '../test_utils.dart'; void main() { - matchFFI(); + ffiInit(); + // matchFFI(); p256Test(); } diff --git a/packages/agent_dart_base/test/identity/schnorr.dart b/packages/agent_dart_base/test/identity/schnorr.dart index 4e7a8703..609d33f6 100644 --- a/packages/agent_dart_base/test/identity/schnorr.dart +++ b/packages/agent_dart_base/test/identity/schnorr.dart @@ -5,7 +5,8 @@ import 'package:test/test.dart'; import '../test_utils.dart'; void main() { - matchFFI(); + ffiInit(); + // matchFFI(); schnorrTest(); } diff --git a/packages/agent_dart_base/test/identity/secp256k1.dart b/packages/agent_dart_base/test/identity/secp256k1.dart index f9f5dc09..5cfa3fc6 100644 --- a/packages/agent_dart_base/test/identity/secp256k1.dart +++ b/packages/agent_dart_base/test/identity/secp256k1.dart @@ -3,7 +3,8 @@ import 'package:test/test.dart'; import '../test_utils.dart'; void main() { - matchFFI(); + ffiInit(); + // matchFFI(); secp256k1Test(); } diff --git a/packages/agent_dart_base/test/test_utils.dart b/packages/agent_dart_base/test/test_utils.dart index a46e5e19..6fa6d552 100644 --- a/packages/agent_dart_base/test/test_utils.dart +++ b/packages/agent_dart_base/test/test_utils.dart @@ -1,10 +1,11 @@ -import 'dart:ffi'; +// import 'dart:ffi'; import 'package:agent_dart_ffi/agent_dart_ffi.dart'; import 'package:test/test.dart'; // import 'package:p4d_rust_binding/utils/utils.dart'; const isAssertionError = TypeMatcher(); + Matcher assertionThrowsContains(String str) { return isAssertionError.having((e) => e.toString(), 'message', contains(str)); } @@ -26,49 +27,53 @@ class ErrorMessageMatcher extends TypeMatcher { item is T && (_message == null || (item as dynamic).message == _message); } -void matchFFI() { - final architech = Abi.current().toString(); - final arr = architech.split('_'); - final os = arr[0]; - final arc = arr[1]; - const dyLib = 'libagent_dart.dylib'; - const dySo = 'libagent_dart.so'; - const dyDll = 'agent_dart.dll'; - final String lib; - switch (os) { - case 'macos': - { - if (arc == 'arm64') { - lib = '../../platform-build/dylib/aarch64-apple-darwin/$dyLib'; - break; - } else { - lib = '../../platform-build/dylib/x86_64-apple-darwin/$dyLib'; - break; - } - } - case 'linux': - { - if (arc == 'arm64') { - lib = '../../platform-build/dylib/aarch64-unknown-linux-gnu/$dyLib'; - break; - } else { - lib = '../../platform-build/dylib/x86_64-unknown-linux-gnu/$dySo'; - break; - } - } - case 'windows': - { - if (arc == 'arm64') { - lib = '../../platform-build/dylib/aarch64-pc-windows-msvc/$dyDll'; - break; - } else { - lib = '../../platform-build/dylib/x86_64-pc-windows-msvc/$dyDll'; - break; - } - } - default: - throw 'Unsupported OS: $os'; - } - print(lib); - AgentDartFFI.setImpl(AgentDartImpl(DynamicLibrary.open(lib))); +Future ffiInit() { + return AgentDart.init(); } + +// void matchFFI() { +// final architech = Abi.current().toString(); +// final arr = architech.split('_'); +// final os = arr[0]; +// final arc = arr[1]; +// const dyLib = 'libagent_dart.dylib'; +// const dySo = 'libagent_dart.so'; +// const dyDll = 'agent_dart.dll'; +// final String lib; +// switch (os) { +// case 'macos': +// { +// if (arc == 'arm64') { +// lib = '../../platform-build/dylib/aarch64-apple-darwin/$dyLib'; +// break; +// } else { +// lib = '../../platform-build/dylib/x86_64-apple-darwin/$dyLib'; +// break; +// } +// } +// case 'linux': +// { +// if (arc == 'arm64') { +// lib = '../../platform-build/dylib/aarch64-unknown-linux-gnu/$dyLib'; +// break; +// } else { +// lib = '../../platform-build/dylib/x86_64-unknown-linux-gnu/$dySo'; +// break; +// } +// } +// case 'windows': +// { +// if (arc == 'arm64') { +// lib = '../../platform-build/dylib/aarch64-pc-windows-msvc/$dyDll'; +// break; +// } else { +// lib = '../../platform-build/dylib/x86_64-pc-windows-msvc/$dyDll'; +// break; +// } +// } +// default: +// throw 'Unsupported OS: $os'; +// } +// print(lib); +// AgentDartFFI.setImpl(AgentDartImpl(DynamicLibrary.open(lib))); +// } diff --git a/packages/agent_dart_base/test/wallet/btc_wallet.dart b/packages/agent_dart_base/test/wallet/btc_wallet.dart index 0270fe86..bdd8f04a 100644 --- a/packages/agent_dart_base/test/wallet/btc_wallet.dart +++ b/packages/agent_dart_base/test/wallet/btc_wallet.dart @@ -9,11 +9,12 @@ import 'package:test/test.dart'; import '../test_utils.dart'; void main() { - matchFFI(); - btc_wallet(); + ffiInit(); + // matchFFI(); + btcWalletTests(); } -void btc_wallet() { +void btcWalletTests() { final ord = OrdService( host: 'unisat.io/api', override: const OverrideOptions( @@ -36,9 +37,9 @@ void btc_wallet() { Future getWallet() async { final wallet = await BitcoinWallet.fromPhrase( - (await Mnemonic.create(WordCount.Words12)).asString(), + (await Mnemonic.create(WordCount.words12)).asString(), addressType: AddressType.P2PKHTR, - network: Network.Testnet, + network: Network.testnet, passcode: '123456', ); @@ -49,7 +50,7 @@ void btc_wallet() { } test('get address by seedphrase and index', () async { - final phrase = (await Mnemonic.create(WordCount.Words12)).asString(); + final phrase = (await Mnemonic.create(WordCount.words12)).asString(); final address = await getAddressInfo( phrase: phrase, index: 0, diff --git a/packages/agent_dart_ffi/.flutter_rust_bridge.yml b/packages/agent_dart_ffi/.flutter_rust_bridge.bak.yml similarity index 90% rename from packages/agent_dart_ffi/.flutter_rust_bridge.yml rename to packages/agent_dart_ffi/.flutter_rust_bridge.bak.yml index 9b253f00..d76f8008 100644 --- a/packages/agent_dart_ffi/.flutter_rust_bridge.yml +++ b/packages/agent_dart_ffi/.flutter_rust_bridge.bak.yml @@ -8,3 +8,5 @@ c_output: extra_c_output_path: - '../agent_dart/ios/Classes/' - '../agent_dart/macos/Classes/' +llvm_path: + - 'X:\SDK\LLVM' diff --git a/packages/agent_dart_ffi/analysis_options.yaml b/packages/agent_dart_ffi/analysis_options.yaml new file mode 100644 index 00000000..bb0acefd --- /dev/null +++ b/packages/agent_dart_ffi/analysis_options.yaml @@ -0,0 +1,5 @@ +include: ../../analysis_options.yaml + +analyzer: + exclude: + - 'lib/src/**' diff --git a/packages/agent_dart_ffi/flutter_rust_bridge.yaml b/packages/agent_dart_ffi/flutter_rust_bridge.yaml new file mode 100644 index 00000000..1bf8590c --- /dev/null +++ b/packages/agent_dart_ffi/flutter_rust_bridge.yaml @@ -0,0 +1,4 @@ +dart_entrypoint_class_name: AgentDart +rust_input: crate::api +rust_root: native/agent_dart +dart_output: lib/src diff --git a/packages/agent_dart_ffi/lib/agent_dart_ffi.dart b/packages/agent_dart_ffi/lib/agent_dart_ffi.dart index cd63a351..f741a763 100644 --- a/packages/agent_dart_ffi/lib/agent_dart_ffi.dart +++ b/packages/agent_dart_ffi/lib/agent_dart_ffi.dart @@ -1,13 +1,21 @@ -import 'src/bridge_generated.dart' show Network; +import 'src/bdk/types.dart' show Network; -export 'src/bridge_generated.dart'; -export 'src/ffi.dart'; +export 'src/api.dart'; +export 'src/bdk/blockchain.dart'; +export 'src/bdk/types.dart'; +export 'src/bdk/wallet.dart'; +export 'src/frb_generated.dart' show AgentDart; +export 'src/lib.dart'; +export 'src/p256.dart'; +export 'src/schnorr.dart'; +export 'src/secp256k1.dart'; +export 'src/types.dart'; const _networkNameMap = >{ - Network.Bitcoin: {'livenet', 'mainnet'}, - Network.Testnet: {'testnet'}, - Network.Regtest: {'regtest'}, - Network.Signet: {'signet'}, + Network.bitcoin: {'livenet', 'mainnet'}, + Network.testnet: {'testnet'}, + Network.regtest: {'regtest'}, + Network.signet: {'signet'}, }; extension AgentDartFFIBitcoinNetworkExtension on Network { diff --git a/packages/agent_dart_ffi/lib/src/api.dart b/packages/agent_dart_ffi/lib/src/api.dart new file mode 100644 index 00000000..ca6051cd --- /dev/null +++ b/packages/agent_dart_ffi/lib/src/api.dart @@ -0,0 +1,608 @@ +// This file is automatically generated, so please do not edit it. +// Generated by `flutter_rust_bridge`@ 2.0.0. + +// ignore_for_file: invalid_use_of_internal_member, unused_import, unnecessary_import + +import 'bdk/blockchain.dart'; +import 'bdk/types.dart'; +import 'bdk/wallet.dart'; +import 'frb_generated.dart'; +import 'lib.dart'; +import 'p256.dart'; +import 'package:flutter_rust_bridge/flutter_rust_bridge_for_generated.dart'; +import 'schnorr.dart'; +import 'secp256k1.dart'; +import 'types.dart'; + +// These functions are ignored because they are not marked as `pub`: `descriptor_secret_config` +// These types are ignored because they are not used by any `pub` functions: `RUNTIME` +// These function are ignored because they are on traits that is not defined in current crate (put an empty `#[frb]` on it to unignore): `deref`, `initialize` + +/// -------------------- +/// mnemonic +/// -------------------- +/// create_phrase +/// phrase_to_seed +/// seed_to_key +Future mnemonicPhraseToSeed({required PhraseToSeedReq req}) => + AgentDart.instance.api.crateApiMnemonicPhraseToSeed(req: req); + +Future mnemonicSeedToKey({required SeedToKeyReq req}) => + AgentDart.instance.api.crateApiMnemonicSeedToKey(req: req); + +/// -------------------- +/// WIF +/// -------------------- +/// hex_bytes_to_wif +Future hexBytesToWif({required String hex, required Network network}) => + AgentDart.instance.api.crateApiHexBytesToWif(hex: hex, network: network); + +/// -------------------- +/// bls +/// -------------------- +/// bls_init +/// bls_verify +Future blsInit() => AgentDart.instance.api.crateApiBlsInit(); + +Future blsVerify({required BLSVerifyReq req}) => + AgentDart.instance.api.crateApiBlsVerify(req: req); + +/// -------------- +/// ed25519 +/// -------------------- +/// ed25519_from_seed +/// ed25519_sign +/// ed25519_verify +Future ed25519FromSeed({required ED25519FromSeedReq req}) => + AgentDart.instance.api.crateApiEd25519FromSeed(req: req); + +Future ed25519Sign({required ED25519SignReq req}) => + AgentDart.instance.api.crateApiEd25519Sign(req: req); + +Future ed25519Verify({required ED25519VerifyReq req}) => + AgentDart.instance.api.crateApiEd25519Verify(req: req); + +/// --------------------- +/// secp256k1 +/// --------------------- +Future secp256K1FromSeed( + {required Secp256k1FromSeedReq req}) => + AgentDart.instance.api.crateApiSecp256K1FromSeed(req: req); + +Future secp256K1Sign({required Secp256k1SignWithSeedReq req}) => + AgentDart.instance.api.crateApiSecp256K1Sign(req: req); + +Future secp256K1SignWithRng( + {required Secp256k1SignWithRngReq req}) => + AgentDart.instance.api.crateApiSecp256K1SignWithRng(req: req); + +Future secp256K1SignRecoverable( + {required Secp256k1SignWithSeedReq req}) => + AgentDart.instance.api.crateApiSecp256K1SignRecoverable(req: req); + +Future secp256K1Verify({required Secp256k1VerifyReq req}) => + AgentDart.instance.api.crateApiSecp256K1Verify(req: req); + +Future secp256K1GetSharedSecret( + {required Secp256k1ShareSecretReq req}) => + AgentDart.instance.api.crateApiSecp256K1GetSharedSecret(req: req); + +Future secp256K1Recover({required Secp256k1RecoverReq req}) => + AgentDart.instance.api.crateApiSecp256K1Recover(req: req); + +/// --------------------- +/// secp256k1 +/// --------------------- +Future p256FromSeed({required P256FromSeedReq req}) => + AgentDart.instance.api.crateApiP256FromSeed(req: req); + +Future p256Sign({required P256SignWithSeedReq req}) => + AgentDart.instance.api.crateApiP256Sign(req: req); + +Future p256Verify({required P256VerifyReq req}) => + AgentDart.instance.api.crateApiP256Verify(req: req); + +Future p256GetSharedSecret({required P256ShareSecretReq req}) => + AgentDart.instance.api.crateApiP256GetSharedSecret(req: req); + +/// --------------------- +/// schnorr +/// --------------------- +Future schnorrFromSeed( + {required SchnorrFromSeedReq req}) => + AgentDart.instance.api.crateApiSchnorrFromSeed(req: req); + +Future schnorrSign({required SchnorrSignWithSeedReq req}) => + AgentDart.instance.api.crateApiSchnorrSign(req: req); + +Future schnorrVerify({required SchnorrVerifyReq req}) => + AgentDart.instance.api.crateApiSchnorrVerify(req: req); + +/// --------------------- +/// aes +/// --------------------- +Future aes128CtrEncrypt({required AesEncryptReq req}) => + AgentDart.instance.api.crateApiAes128CtrEncrypt(req: req); + +Future aes128CtrDecrypt({required AesDecryptReq req}) => + AgentDart.instance.api.crateApiAes128CtrDecrypt(req: req); + +Future aes256CbcEncrypt({required AesEncryptReq req}) => + AgentDart.instance.api.crateApiAes256CbcEncrypt(req: req); + +Future aes256CbcDecrypt({required AesDecryptReq req}) => + AgentDart.instance.api.crateApiAes256CbcDecrypt(req: req); + +Future aes256GcmEncrypt({required AesEncryptReq req}) => + AgentDart.instance.api.crateApiAes256GcmEncrypt(req: req); + +Future aes256GcmDecrypt({required AesDecryptReq req}) => + AgentDart.instance.api.crateApiAes256GcmDecrypt(req: req); + +Future pbkdf2DeriveKey({required PBKDFDeriveReq req}) => + AgentDart.instance.api.crateApiPbkdf2DeriveKey(req: req); + +Future scryptDeriveKey({required ScriptDeriveReq req}) => + AgentDart.instance.api.crateApiScryptDeriveKey(req: req); + +// Rust type: RustOpaqueMoi +abstract class BdkDescriptor implements RustOpaqueInterface {} + +// Rust type: RustOpaqueMoi +abstract class BlockchainInstance implements RustOpaqueInterface {} + +class Api { + const Api(); + + static Future addressFromScript( + {required Script script, required Network network}) => + AgentDart.instance.api + .crateApiApiAddressFromScript(script: script, network: network); + + static Future addressNetwork({required String address}) => + AgentDart.instance.api.crateApiApiAddressNetwork(address: address); + + static Future