diff --git a/.github/validate-formatting.sh b/.github/validate-formatting.sh new file mode 100755 index 00000000..847b8d84 --- /dev/null +++ b/.github/validate-formatting.sh @@ -0,0 +1,30 @@ +#!/bin/bash +if [[ $(git ls-files --modified) ]]; then + echo "" + echo "" + echo "These files are not formatted correctly:" + for f in $(git ls-files --modified); do + echo "" + echo "" + echo "-----------------------------------------------------------------" + echo "$f" + echo "-----------------------------------------------------------------" + echo "" + git --no-pager diff --unified=0 --minimal $f + echo "" + echo "-----------------------------------------------------------------" + echo "" + echo "" + done + if [[ $GITHUB_WORKFLOW ]]; then + git checkout . > /dev/null 2>&1 + fi + echo "" + echo "❌ Some files are incorrectly formatted, see above output." + echo "" + echo "To fix these locally, run: 'melos run format'." + exit 1 +else + echo "" + echo "✅ All files are formatted correctly." +fi diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4a65255d..d291425f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,7 +15,7 @@ jobs: - uses: flutter-actions/setup-flutter@v3 with: channel: stable - version: 3.19.5 + version: 3.24.3 cache: true cache-sdk: true - uses: bluefireteam/melos-action@v3 @@ -30,7 +30,7 @@ jobs: - uses: flutter-actions/setup-flutter@v3 with: channel: stable - version: 3.19.5 + version: 3.24.3 cache: true cache-sdk: true - uses: bluefireteam/melos-action@v3 @@ -44,7 +44,7 @@ jobs: - uses: flutter-actions/setup-flutter@v3 with: channel: stable - version: 3.19.5 + version: 3.24.3 cache: true cache-sdk: true - uses: bluefireteam/melos-action@v3 @@ -85,10 +85,10 @@ jobs: - uses: flutter-actions/setup-flutter@v3 with: channel: stable - version: 3.19.5 + version: 3.24.3 cache: true cache-sdk: true - uses: bluefireteam/melos-action@v3 - name: Run scarb check if: steps.changes.outputs.contracts_dir == 'true' - run: melos test:dart:unit \ No newline at end of file + run: melos test:dart:unit diff --git a/.github/workflows/code_health.yaml b/.github/workflows/code_health.yaml new file mode 100644 index 00000000..f585f051 --- /dev/null +++ b/.github/workflows/code_health.yaml @@ -0,0 +1,88 @@ +name: code_health + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +on: + pull_request: + paths-ignore: + - "docs/**" + - "**.md" + push: + branches: + - main + paths-ignore: + - "docs/**" + - "**.md" + +jobs: + analyze: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + - uses: bluefireteam/melos-action@v3 + - name: "Run Analyze" + run: melos run analyze + + pub_dry_run: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + - uses: bluefireteam/melos-action@v3 + - name: "Pub Check" + run: | + melos exec -c 1 --no-private --ignore="*example*" -- \ + dart pub publish --dry-run + + pub_get_check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4.1.7 + - uses: subosito/flutter-action@v2 + with: + channel: "stable" + cache: true + - uses: bluefireteam/melos-action@v3 + - name: "flutter pub get" + run: | + melos exec -c 1 --scope="*example*" -- \ + "flutter pub get" + + # format: + # runs-on: macos-latest + # steps: + # - uses: actions/checkout@v4.1.7 + # - uses: subosito/flutter-action@v2 + # with: + # channel: "stable" + # cache: true + # - uses: bluefireteam/melos-action@v3 + # - uses: Homebrew/actions/setup-homebrew@master + # - name: "Install Tools" + # run: | + # flutter pub global activate flutter_plugin_tools + # brew install swiftformat + # brew install clang-format + # brew link --overwrite --force clang-format + # - name: "Formatter version" + # run: | + # clang-format --version + # swiftformat --version + # - name: "Dart, Java and Objective-C " + # run: | + # flutter pub global run flutter_plugin_tools format + # ./.github/validate-formatting.sh + # - name: "Swift" + # if: ${{ success() || failure() }} + # run: | + # swiftformat . + # ./.github/validate-formatting.sh diff --git a/.github/workflows/pr_title.yaml b/.github/workflows/pr_title.yaml new file mode 100644 index 00000000..e18da945 --- /dev/null +++ b/.github/workflows/pr_title.yaml @@ -0,0 +1,20 @@ +name: pr_title + +on: + pull_request_target: + types: + - opened + - edited + - synchronize + +permissions: read-all + +env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + +jobs: + validate: + name: PR title validation + runs-on: ubuntu-latest + steps: + - uses: amannn/action-semantic-pull-request@e9fabac35e210fea40ca5b14c0da95a099eff26f diff --git a/.gitignore b/.gitignore index b5c8b009..fbb20a96 100644 --- a/.gitignore +++ b/.gitignore @@ -36,3 +36,4 @@ coverage/ # deploy for test .starkli/account_1.json pubspec_overrides.yaml +*.iml diff --git a/.swiftformat b/.swiftformat new file mode 100644 index 00000000..7f0db766 --- /dev/null +++ b/.swiftformat @@ -0,0 +1,6 @@ +--indent 2 +--maxwidth 100 +--wrapparameters afterfirst +--disable sortedImports,unusedArguments,wrapMultilineStatementBraces +--exclude Pods,**/MainFlutterWindow.swift,**/AppDelegate.swift,**/.symlinks/** +--swiftversion 5.7 diff --git a/analysis_options.yaml b/analysis_options.yaml new file mode 100644 index 00000000..9890a06a --- /dev/null +++ b/analysis_options.yaml @@ -0,0 +1,8 @@ +include: package:starklints/lints.yaml + +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" + errors: + invalid_annotation_target: ignore diff --git a/examples/nft_marketplace/.gitignore b/examples/nft_marketplace/.gitignore index 29a3a501..9545374a 100644 --- a/examples/nft_marketplace/.gitignore +++ b/examples/nft_marketplace/.gitignore @@ -41,3 +41,4 @@ app.*.map.json /android/app/debug /android/app/profile /android/app/release +pubspec_overrides.yaml diff --git a/examples/nft_marketplace/ios/Runner/AppDelegate.swift b/examples/nft_marketplace/ios/Runner/AppDelegate.swift index 70693e4a..17562970 100644 --- a/examples/nft_marketplace/ios/Runner/AppDelegate.swift +++ b/examples/nft_marketplace/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } } diff --git a/examples/nft_marketplace/ios/RunnerTests/RunnerTests.swift b/examples/nft_marketplace/ios/RunnerTests/RunnerTests.swift index 86a7c3b1..b0d10f2e 100644 --- a/examples/nft_marketplace/ios/RunnerTests/RunnerTests.swift +++ b/examples/nft_marketplace/ios/RunnerTests/RunnerTests.swift @@ -3,10 +3,8 @@ import UIKit import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/nft_marketplace/macos/Runner/AppDelegate.swift b/examples/nft_marketplace/macos/Runner/AppDelegate.swift index d53ef643..8f3dd47c 100644 --- a/examples/nft_marketplace/macos/Runner/AppDelegate.swift +++ b/examples/nft_marketplace/macos/Runner/AppDelegate.swift @@ -3,7 +3,7 @@ import FlutterMacOS @NSApplicationMain class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } + override func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool { + return true + } } diff --git a/examples/nft_marketplace/macos/Runner/MainFlutterWindow.swift b/examples/nft_marketplace/macos/Runner/MainFlutterWindow.swift index 3cc05eb2..decbd0eb 100644 --- a/examples/nft_marketplace/macos/Runner/MainFlutterWindow.swift +++ b/examples/nft_marketplace/macos/Runner/MainFlutterWindow.swift @@ -2,14 +2,14 @@ import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = frame + contentViewController = flutterViewController + setFrame(windowFrame, display: true) - RegisterGeneratedPlugins(registry: flutterViewController) + RegisterGeneratedPlugins(registry: flutterViewController) - super.awakeFromNib() - } + super.awakeFromNib() + } } diff --git a/examples/nft_marketplace/macos/RunnerTests/RunnerTests.swift b/examples/nft_marketplace/macos/RunnerTests/RunnerTests.swift index 5418c9f5..4fc85d1c 100644 --- a/examples/nft_marketplace/macos/RunnerTests/RunnerTests.swift +++ b/examples/nft_marketplace/macos/RunnerTests/RunnerTests.swift @@ -1,12 +1,10 @@ -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/nft_marketplace/pubspec.yaml b/examples/nft_marketplace/pubspec.yaml index bd4de4aa..8fd68abc 100644 --- a/examples/nft_marketplace/pubspec.yaml +++ b/examples/nft_marketplace/pubspec.yaml @@ -28,11 +28,11 @@ environment: # the latest version available on pub.dev. To see which dependencies have newer # versions available, run `flutter pub outdated`. dependencies: - ark_project: - starknet: - starknet_provider: - secure_store: - wallet_kit: + ark_project: ^0.1.0 + starknet: ^0.1.0 + starknet_provider: ^0.1.0 + secure_store: ^0.1.2 + wallet_kit: ^0.0.1 flutter: sdk: flutter diff --git a/examples/nft_marketplace/pubspec_overrides.yaml b/examples/nft_marketplace/pubspec_overrides.yaml index 5abf486a..daaa1742 100644 --- a/examples/nft_marketplace/pubspec_overrides.yaml +++ b/examples/nft_marketplace/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: ark_project,secure_store,starknet,starknet_provider +# melos_managed_dependency_overrides: ark_project,secure_store,starknet,starknet_provider,wallet_kit dependency_overrides: ark_project: path: ../../packages/ark_project @@ -8,3 +8,5 @@ dependency_overrides: path: ../../packages/starknet starknet_provider: path: ../../packages/starknet_provider + wallet_kit: + path: ../../packages/wallet_kit diff --git a/examples/starknet_cli/pubspec.yaml b/examples/starknet_cli/pubspec.yaml index 52ccca1e..36c0dcd7 100644 --- a/examples/starknet_cli/pubspec.yaml +++ b/examples/starknet_cli/pubspec.yaml @@ -6,8 +6,8 @@ environment: sdk: ^3.0.0 dependencies: - starknet: - starknet_provider: + starknet: ^0.1.0 + starknet_provider: ^0.1.0 args: ^2.4.2 csv: ^5.1.1 diff --git a/examples/starknet_counter/ios/Runner/AppDelegate.swift b/examples/starknet_counter/ios/Runner/AppDelegate.swift index 70693e4a..17562970 100644 --- a/examples/starknet_counter/ios/Runner/AppDelegate.swift +++ b/examples/starknet_counter/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } } diff --git a/examples/starknet_counter/ios/RunnerTests/RunnerTests.swift b/examples/starknet_counter/ios/RunnerTests/RunnerTests.swift index 86a7c3b1..b0d10f2e 100644 --- a/examples/starknet_counter/ios/RunnerTests/RunnerTests.swift +++ b/examples/starknet_counter/ios/RunnerTests/RunnerTests.swift @@ -3,10 +3,8 @@ import UIKit import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/starknet_counter/lib/services/counter_service.dart b/examples/starknet_counter/lib/services/counter_service.dart index 28595592..efa88029 100644 --- a/examples/starknet_counter/lib/services/counter_service.dart +++ b/examples/starknet_counter/lib/services/counter_service.dart @@ -1,20 +1,16 @@ import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; -final provider = JsonRpcProvider( - nodeUri: Uri.parse( - 'http://localhost:5050')); -final contractAddress = +final provider = JsonRpcProvider(nodeUri: Uri.parse('http://localhost:5050')); +const contractAddress = '0x05e97cdfed436cc074def1b7f357cba6c76f61e85a3431a19cc29a3327676372'; -final secretAccountAddress = +const secretAccountAddress = "0x64b48806902a367c8598f4f95c305e8c1a1acba5f082d294a43793113115691"; -final secretAccountPrivateKey = - "0x71d7bb07b9a64f6f78ac4c816aff4da9"; +const secretAccountPrivateKey = "0x71d7bb07b9a64f6f78ac4c816aff4da9"; final signeraccount = getAccount( accountAddress: Felt.fromHexString(secretAccountAddress), privateKey: Felt.fromHexString(secretAccountPrivateKey), - nodeUri: Uri.parse( - 'http://localhost:5050'), + nodeUri: Uri.parse('http://localhost:5050'), ); Future getCurrentCount() async { @@ -32,7 +28,6 @@ Future getCurrentCount() async { } Future increaseCounter() async { - print('print increment'); final response = await signeraccount.execute(functionCalls: [ FunctionCall( contractAddress: Felt.fromHexString(contractAddress), @@ -46,12 +41,10 @@ Future increaseCounter() async { error: (err) => throw Exception("Failed to execute"), ); - print('printing increment TX : $txHash'); await waitForAcceptance(transactionHash: txHash, provider: provider); } Future increaseCounterBy(String number) async { - print('print increment by '); final response = await signeraccount.execute(functionCalls: [ FunctionCall( contractAddress: Felt.fromHexString(contractAddress), @@ -65,12 +58,10 @@ Future increaseCounterBy(String number) async { error: (err) => throw Exception("Failed to execute"), ); - print('printing incrementby amount TX : $txHash'); await waitForAcceptance(transactionHash: txHash, provider: provider); } Future decreaseCounter() async { - print('decrementing.....'); final response = await signeraccount.execute(functionCalls: [ FunctionCall( contractAddress: Felt.fromHexString(contractAddress), @@ -83,6 +74,5 @@ Future decreaseCounter() async { result: (result) => result.transaction_hash, error: (err) => throw Exception("Failed to execute"), ); - print('printing decrement TX : $txHash'); await waitForAcceptance(transactionHash: txHash, provider: provider); } diff --git a/examples/starknet_counter/macos/Runner/AppDelegate.swift b/examples/starknet_counter/macos/Runner/AppDelegate.swift index d53ef643..8f3dd47c 100644 --- a/examples/starknet_counter/macos/Runner/AppDelegate.swift +++ b/examples/starknet_counter/macos/Runner/AppDelegate.swift @@ -3,7 +3,7 @@ import FlutterMacOS @NSApplicationMain class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } + override func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool { + return true + } } diff --git a/examples/starknet_counter/macos/Runner/MainFlutterWindow.swift b/examples/starknet_counter/macos/Runner/MainFlutterWindow.swift index 3cc05eb2..decbd0eb 100644 --- a/examples/starknet_counter/macos/Runner/MainFlutterWindow.swift +++ b/examples/starknet_counter/macos/Runner/MainFlutterWindow.swift @@ -2,14 +2,14 @@ import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = frame + contentViewController = flutterViewController + setFrame(windowFrame, display: true) - RegisterGeneratedPlugins(registry: flutterViewController) + RegisterGeneratedPlugins(registry: flutterViewController) - super.awakeFromNib() - } + super.awakeFromNib() + } } diff --git a/examples/starknet_counter/macos/RunnerTests/RunnerTests.swift b/examples/starknet_counter/macos/RunnerTests/RunnerTests.swift index 5418c9f5..4fc85d1c 100644 --- a/examples/starknet_counter/macos/RunnerTests/RunnerTests.swift +++ b/examples/starknet_counter/macos/RunnerTests/RunnerTests.swift @@ -1,12 +1,10 @@ -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/wallet_app/ios/Runner/AppDelegate.swift b/examples/wallet_app/ios/Runner/AppDelegate.swift index 70693e4a..17562970 100644 --- a/examples/wallet_app/ios/Runner/AppDelegate.swift +++ b/examples/wallet_app/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } } diff --git a/examples/wallet_app/ios/RunnerTests/RunnerTests.swift b/examples/wallet_app/ios/RunnerTests/RunnerTests.swift index 86a7c3b1..b0d10f2e 100644 --- a/examples/wallet_app/ios/RunnerTests/RunnerTests.swift +++ b/examples/wallet_app/ios/RunnerTests/RunnerTests.swift @@ -3,10 +3,8 @@ import UIKit import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/wallet_app/macos/Runner.xcodeproj/project.pbxproj b/examples/wallet_app/macos/Runner.xcodeproj/project.pbxproj index eb52ec05..89448c9f 100644 --- a/examples/wallet_app/macos/Runner.xcodeproj/project.pbxproj +++ b/examples/wallet_app/macos/Runner.xcodeproj/project.pbxproj @@ -258,7 +258,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0920; - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1510; ORGANIZATIONNAME = ""; TargetAttributes = { 331C80D4294CF70F00263BE5 = { diff --git a/examples/wallet_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/examples/wallet_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 24cd760e..03fc1853 100644 --- a/examples/wallet_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/examples/wallet_app/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ Bool { - return true - } + override func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool { + return true + } } diff --git a/examples/wallet_app/macos/Runner/MainFlutterWindow.swift b/examples/wallet_app/macos/Runner/MainFlutterWindow.swift index 3cc05eb2..decbd0eb 100644 --- a/examples/wallet_app/macos/Runner/MainFlutterWindow.swift +++ b/examples/wallet_app/macos/Runner/MainFlutterWindow.swift @@ -2,14 +2,14 @@ import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = frame + contentViewController = flutterViewController + setFrame(windowFrame, display: true) - RegisterGeneratedPlugins(registry: flutterViewController) + RegisterGeneratedPlugins(registry: flutterViewController) - super.awakeFromNib() - } + super.awakeFromNib() + } } diff --git a/examples/wallet_app/macos/RunnerTests/RunnerTests.swift b/examples/wallet_app/macos/RunnerTests/RunnerTests.swift index 5418c9f5..4fc85d1c 100644 --- a/examples/wallet_app/macos/RunnerTests/RunnerTests.swift +++ b/examples/wallet_app/macos/RunnerTests/RunnerTests.swift @@ -1,12 +1,10 @@ -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/examples/wallet_app/pubspec.yaml b/examples/wallet_app/pubspec.yaml index 958dae9a..03d03bc8 100644 --- a/examples/wallet_app/pubspec.yaml +++ b/examples/wallet_app/pubspec.yaml @@ -11,9 +11,9 @@ dependencies: sdk: flutter wallet_kit: starknet_provider: - ark_project: - starknet: - secure_store: + ark_project: ^0.1.0 + starknet: ^0.1.0 + secure_store: ^0.1.2 cupertino_icons: ^1.0.2 hooks_riverpod: ^2.3.6 flutter_hooks: ^0.20.5 diff --git a/examples/wallet_app/pubspec_overrides.yaml b/examples/wallet_app/pubspec_overrides.yaml index a812e91c..daaa1742 100644 --- a/examples/wallet_app/pubspec_overrides.yaml +++ b/examples/wallet_app/pubspec_overrides.yaml @@ -1,4 +1,4 @@ -# melos_managed_dependency_overrides: ark_project,secure_store,starknet,starknet_builder,starknet_provider +# melos_managed_dependency_overrides: ark_project,secure_store,starknet,starknet_provider,wallet_kit dependency_overrides: ark_project: path: ../../packages/ark_project @@ -6,7 +6,7 @@ dependency_overrides: path: ../../packages/secure_store starknet: path: ../../packages/starknet - starknet_builder: - path: ../../packages/starknet_builder starknet_provider: path: ../../packages/starknet_provider + wallet_kit: + path: ../../packages/wallet_kit diff --git a/melos.yaml b/melos.yaml index ef33e369..d89207e7 100644 --- a/melos.yaml +++ b/melos.yaml @@ -1,4 +1,5 @@ name: monorepo +repository: https://github.com/focustree/starknet.dart packages: - examples/** @@ -6,12 +7,13 @@ packages: - contracts/v$CAIRO_VERSION/** ignore: - - "examples/starknet_counter" - - "packages/wallet_kit" command: bootstrap: - usePubspecOverrides: true + runPubGetInParallel: true + version: + linkToCommits: true + workspaceChangelog: true scripts: validate-gh-actions: @@ -21,8 +23,14 @@ scripts: description: Analyze all packages exec: dart analyze --fatal-infos format: - description: Format all packages - exec: dart format . + run: | + dart pub global run flutter_plugin_tools format && swiftformat . + description: | + Formats the code of all packages (Java, Objective-C, and Dart). + - Requires `flutter_plugin_tools` (`pub global activate flutter_plugin_tools`). + - Requires `git`. + - Requires `clang-format` (can be installed via Brew on MacOS). + - Requires `swiftformat` (can be installed via Brew on macOS). format:check: description: Format check all packages exec: dart format --set-exit-if-changed . diff --git a/melos_monorepo.iml b/melos_monorepo.iml index 1c75bf0b..96815595 100644 --- a/melos_monorepo.iml +++ b/melos_monorepo.iml @@ -9,4 +9,4 @@ - \ No newline at end of file + diff --git a/packages/analysis_options.yaml b/packages/analysis_options.yaml deleted file mode 100644 index c80073d7..00000000 --- a/packages/analysis_options.yaml +++ /dev/null @@ -1,3 +0,0 @@ -analyzer: - errors: - non_nullable_equals_parameter: ignore diff --git a/packages/ark_project/example/ark_example.dart b/packages/ark_project/example/ark_example.dart index 4dcaef16..cc919db1 100644 --- a/packages/ark_project/example/ark_example.dart +++ b/packages/ark_project/example/ark_example.dart @@ -4,11 +4,12 @@ import 'package:dotenv/dotenv.dart'; final env = DotEnv(includePlatformEnvironment: true)..load(); final apiKey = env.getOrElse( 'ARK_API_KEY', - () => throw 'ARK_API_KEY not found in .env file', + () => throw Exception('ARK_API_KEY not found in .env file'), ); + final nftAddress = env.getOrElse( 'NFT_ADDRESS', - () => throw 'NFT_ADDRESS not found in .env file', + () => throw Exception('NFT_ADDRESS not found in .env file'), ); void main() async { diff --git a/packages/ark_project/lib/ark_project.dart b/packages/ark_project/lib/ark_project.dart index 938d7b9d..f470d0e4 100644 --- a/packages/ark_project/lib/ark_project.dart +++ b/packages/ark_project/lib/ark_project.dart @@ -1,8 +1,6 @@ -library; - -export 'src/ark_nft_api.dart'; -export 'src/model/nft_api.dart'; -export 'src/model/marketplace_api.dart'; +export './src/ark_nft_api.dart'; +export './src/model/marketplace_api.dart'; +export './src/model/nft_api.dart'; import './src/ark_marketplace_api.dart'; import './src/ark_nft_api.dart'; diff --git a/packages/ark_project/lib/src/ark_marketplace_api.dart b/packages/ark_project/lib/src/ark_marketplace_api.dart index d16271e8..5ff442f5 100644 --- a/packages/ark_project/lib/src/ark_marketplace_api.dart +++ b/packages/ark_project/lib/src/ark_marketplace_api.dart @@ -16,11 +16,11 @@ class ArkMarketplaceApi { ArkMarketplaceApi._internal(); - void init( - {required String apiKey, - baseUrl = 'https://api.marketplace.arkproject.dev', - chainId = "0x534e5f4d41494e" // Starknet Mainnet - }) { + void init({ + required String apiKey, + String baseUrl = 'https://api.marketplace.arkproject.dev', + String chainId = '0x534e5f4d41494e', // Starknet Mainnet + }) { this.apiKey = apiKey; this.baseUrl = baseUrl; this.chainId = chainId; @@ -28,11 +28,11 @@ class ArkMarketplaceApi { Future list( String contractAddress, { - page = 1, - itemsPerPage = 100, - buyNow = false, - sort = "price", - direction = "desc", + int page = 1, + int itemsPerPage = 100, + bool buyNow = false, + String sort = 'price', + String direction = 'desc', }) async { final queryParameters = { 'page': page.toString(), @@ -51,39 +51,53 @@ class ArkMarketplaceApi { 'Content-Type': 'application/json', }; - var response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return ListMarketplaceNFTsResponse.fromJson(jsonDecode(response.body)); - } else { + final response = await http.get(uri, headers: headers); + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return ListMarketplaceNFTsResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future getTokenMarketdata( - String contractAddress, String tokenId) async { + String contractAddress, + String tokenId, + ) async { final uri = Uri.parse( - '$baseUrl/tokens/$contractAddress/$chainId/$tokenId/marketdata'); + '$baseUrl/tokens/$contractAddress/$chainId/$tokenId/marketdata', + ); final headers = { 'x-api-key': apiKey, 'Content-Type': 'application/json', }; - var response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - final marketdataResponse = - MarketdataResponse.fromJson(jsonDecode(response.body)); - return marketdataResponse.data; - } else { + final response = await http.get(uri, headers: headers); + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + final marketdataResponse = MarketdataResponse.fromJson( + jsonDecode(response.body) as Map, + ); + return marketdataResponse.data; + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future getTokerOffers( String contractAddress, String tokenId, { - page = 1, - itemsPerPage = 100, + int page = 1, + int itemsPerPage = 100, }) async { final queryParameters = { 'page': page.toString(), @@ -99,11 +113,17 @@ class ArkMarketplaceApi { 'Content-Type': 'application/json', }; - var response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return GetTokenOffersResponse.fromJson(jsonDecode(response.body)); - } else { + final response = await http.get(uri, headers: headers); + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return GetTokenOffersResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } } diff --git a/packages/ark_project/lib/src/ark_nft_api.dart b/packages/ark_project/lib/src/ark_nft_api.dart index f11564c4..2554fbc7 100644 --- a/packages/ark_project/lib/src/ark_nft_api.dart +++ b/packages/ark_project/lib/src/ark_nft_api.dart @@ -31,16 +31,23 @@ class ArkNFTApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return GetNFTResponse.fromJson(jsonDecode(response.body)); - } else { + if (response.statusCode != 200) { throw HttpException('Failed to fetch NFT data: ${response.statusCode}'); } + + try { + return GetNFTResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future getOrderHash(String contractAddress, String tokenId) async { final uri = Uri.parse( - 'https://api-marketplace.arkproject.dev/tokens/$contractAddress/0x534e5f4d41494e/$tokenId/marketdata'); + 'https://api-marketplace.arkproject.dev/tokens/$contractAddress/0x534e5f4d41494e/$tokenId/marketdata', + ); final headers = { 'x-api-key': apiKey, 'Content-Type': 'application/json', @@ -48,7 +55,7 @@ class ArkNFTApi { final response = await http.get(uri, headers: headers); if (response.statusCode == 200) { - print(response.body); + stdout.writeln(response.body); } else { throw HttpException('Failed to fetch NFT data: ${response.statusCode}'); } @@ -75,17 +82,24 @@ class ArkNFTApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return ListNFTsResponse.fromJson(jsonDecode(response.body)); - } else { + + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return ListNFTsResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future portfolio( String accountAddress, { String? cursor, - limit = 100, + int limit = 100, }) async { final queryParameters = { 'limit': limit.toString(), @@ -100,10 +114,16 @@ class ArkNFTApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return ListNFTsResponse.fromJson(jsonDecode(response.body)); - } else { + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return ListNFTsResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } } diff --git a/packages/ark_project/lib/src/ark_orderbook_api.dart b/packages/ark_project/lib/src/ark_orderbook_api.dart index d3d51a09..a81f750b 100644 --- a/packages/ark_project/lib/src/ark_orderbook_api.dart +++ b/packages/ark_project/lib/src/ark_orderbook_api.dart @@ -31,16 +31,24 @@ class ArkOrderbookApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - final List decodedBody = jsonDecode(response.body); - return decodedBody.map((nft) => OrderBookNFT.fromJson(nft)).toList(); - } else { + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + final decodedBody = jsonDecode(response.body) as List; + return decodedBody + .map((nft) => OrderBookNFT.fromJson(nft as Map)) + .toList(); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future getOrderbookNFT( - String contractAddress, String tokenId) async { + String contractAddress, + String tokenId, + ) async { final uri = Uri.parse('$baseUrl/token/$contractAddress/$tokenId'); final headers = { 'x-api-key': apiKey, @@ -48,15 +56,23 @@ class ArkOrderbookApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return OrderBookNFT.fromJson(jsonDecode(response.body)); - } else { + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return OrderBookNFT.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } Future getOffersForNFT( - String contractAddress, String tokenId) async { + String contractAddress, + String tokenId, + ) async { final uri = Uri.parse('$baseUrl/token/$contractAddress/$tokenId/offers'); final headers = { 'x-api-key': apiKey, @@ -64,10 +80,16 @@ class ArkOrderbookApi { }; final response = await http.get(uri, headers: headers); - if (response.statusCode == 200) { - return GetOffersForTokenResponse.fromJson(jsonDecode(response.body)); - } else { + if (response.statusCode != 200) { throw HttpException('Failed to fetch data: ${response.statusCode}'); } + + try { + return GetOffersForTokenResponse.fromJson( + jsonDecode(response.body) as Map, + ); + } catch (e) { + throw const FormatException('Unexpected response body'); + } } } diff --git a/packages/ark_project/lib/src/ark_starknet.dart b/packages/ark_project/lib/src/ark_starknet.dart index 40ccb917..8e6ad891 100644 --- a/packages/ark_project/lib/src/ark_starknet.dart +++ b/packages/ark_project/lib/src/ark_starknet.dart @@ -28,9 +28,9 @@ class ArkStarknet { int? startDate, int? endDate, String currencyAddress = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", - String currencyChainId = "SN_MAIN", - String tokenChainId = "SN_MAIN", + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + String currencyChainId = 'SN_MAIN', + String tokenChainId = 'SN_MAIN', Felt? maxFee, Felt? nonce, List? additionalFunctionCalls, @@ -38,7 +38,7 @@ class ArkStarknet { startDate = startDate ?? (DateTime.now().millisecondsSinceEpoch ~/ (1000)); endDate = endDate ?? (startDate + 3 * 24 * 60 * 60); - final OrderV1 order = OrderV1( + final order = OrderV1( route: RouteType.erc721ToErc20, currencyChainId: currencyChainId, currencyAddress: currencyAddress, @@ -53,7 +53,7 @@ class ArkStarknet { startDate: startDate, endDate: endDate, brokerId: - "0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078", + '0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078', additionalData: [], ); @@ -79,25 +79,32 @@ class ArkStarknet { ...computeCalldata(order.additionalData), ]; - final response = await starknetAccount.execute(functionCalls: [ - ...additionalFunctionCalls ?? [], - FunctionCall( - contractAddress: Felt.fromHexString(nftAddress), - entryPointSelector: getSelectorByName("approve"), - calldata: [arkExecutorAddress, Felt(tokenIdBigInt), Felt.fromInt(0)], - ), - FunctionCall( - contractAddress: arkExecutorAddress, - entryPointSelector: getSelectorByName("create_order"), - calldata: callData, - ), - ], maxFee: maxFee, nonce: nonce); - - final txHash = response.when(result: (result) { - return result.transaction_hash; - }, error: (error) { - throw Exception(error.message); - }); + final response = await starknetAccount.execute( + functionCalls: [ + ...additionalFunctionCalls ?? [], + FunctionCall( + contractAddress: Felt.fromHexString(nftAddress), + entryPointSelector: getSelectorByName('approve'), + calldata: [arkExecutorAddress, Felt(tokenIdBigInt), Felt.fromInt(0)], + ), + FunctionCall( + contractAddress: arkExecutorAddress, + entryPointSelector: getSelectorByName('create_order'), + calldata: callData, + ), + ], + max_fee: maxFee, + nonce: nonce, + ); + + final txHash = response.when( + result: (result) { + return result.transaction_hash; + }, + error: (error) { + throw Exception(error.message); + }, + ); return txHash; } @@ -107,11 +114,11 @@ class ArkStarknet { required BigInt orderHash, required String tokenAddress, required BigInt tokenId, - String tokenChainId = "SN_MAIN", + String tokenChainId = 'SN_MAIN', Felt? maxFee, Felt? nonce, }) async { - final FullCancelInfo fullCancelInfo = FullCancelInfo( + final fullCancelInfo = FullCancelInfo( orderHash: orderHash, canceller: starknetAccount.accountAddress.toHexString(), tokenChainId: tokenChainId, @@ -128,19 +135,26 @@ class ArkStarknet { ...computeCalldata(fullCancelInfo.tokenId), ]; - final response = await starknetAccount.execute(functionCalls: [ - FunctionCall( - contractAddress: arkExecutorAddress, - entryPointSelector: getSelectorByName("cancel_order"), - calldata: callData, - ), - ], maxFee: maxFee, nonce: nonce); + final response = await starknetAccount.execute( + functionCalls: [ + FunctionCall( + contractAddress: arkExecutorAddress, + entryPointSelector: getSelectorByName('cancel_order'), + calldata: callData, + ), + ], + max_fee: maxFee, + nonce: nonce, + ); - final txHash = response.when(result: (result) { - return result.transaction_hash; - }, error: (error) { - throw Exception(error.message); - }); + final txHash = response.when( + result: (result) { + return result.transaction_hash; + }, + error: (error) { + throw Exception(error.message); + }, + ); return txHash; } @@ -153,9 +167,9 @@ class ArkStarknet { int? startDate, int? endDate, String currencyAddress = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", - String currencyChainId = "SN_MAIN", - String tokenChainId = "SN_MAIN", + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + String currencyChainId = 'SN_MAIN', + String tokenChainId = 'SN_MAIN', Felt? maxFee, Felt? nonce, }) async { @@ -165,7 +179,7 @@ class ArkStarknet { final bigIntAmount = BigInt.from(startAmount * 1e18); final amount = Uint256.fromBigInt(bigIntAmount); - final OrderV1 order = OrderV1( + final order = OrderV1( route: RouteType.erc20ToErc721, currencyChainId: currencyChainId, currencyAddress: currencyAddress, @@ -180,7 +194,7 @@ class ArkStarknet { startDate: startDate, endDate: endDate, brokerId: - "0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078", + '0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078', additionalData: [], ); @@ -206,24 +220,31 @@ class ArkStarknet { ...computeCalldata(order.additionalData), ]; - final response = await starknetAccount.execute(functionCalls: [ - FunctionCall( - contractAddress: Felt.fromHexString(currencyAddress), - entryPointSelector: getSelectorByName("approve"), - calldata: [arkExecutorAddress, Felt(bigIntAmount), Felt.fromInt(0)], - ), - FunctionCall( - contractAddress: arkExecutorAddress, - entryPointSelector: getSelectorByName("create_order"), - calldata: callData, - ), - ], maxFee: maxFee, nonce: nonce); - - final txHash = response.when(result: (result) { - return result.transaction_hash; - }, error: (error) { - throw Exception(error.message); - }); + final response = await starknetAccount.execute( + functionCalls: [ + FunctionCall( + contractAddress: Felt.fromHexString(currencyAddress), + entryPointSelector: getSelectorByName('approve'), + calldata: [arkExecutorAddress, Felt(bigIntAmount), Felt.fromInt(0)], + ), + FunctionCall( + contractAddress: arkExecutorAddress, + entryPointSelector: getSelectorByName('create_order'), + calldata: callData, + ), + ], + max_fee: maxFee, + nonce: nonce, + ); + + final txHash = response.when( + result: (result) { + return result.transaction_hash; + }, + error: (error) { + throw Exception(error.message); + }, + ); return txHash; } @@ -235,22 +256,23 @@ class ArkStarknet { required double startAmount, required BigInt orderHash, String currencyAddress = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", - String tokenChainId = "SN_MAIN", + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + String tokenChainId = 'SN_MAIN', Felt? maxFee, Felt? nonce, }) async { final bigIntAmount = BigInt.from(startAmount * 1e18); - final FulfillInfo fulfillInfo = FulfillInfo( - orderHash: orderHash, - relatedOrderHash: 1, - fulfiller: starknetAccount.accountAddress.toHexString(), - tokenChainId: tokenChainId, - tokenAddress: nftAddress, - tokenId: Uint256.fromIntString(tokenId), - fulfillBrokerAddress: - "0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078"); + final fulfillInfo = FulfillInfo( + orderHash: orderHash, + relatedOrderHash: 1, + fulfiller: starknetAccount.accountAddress.toHexString(), + tokenChainId: tokenChainId, + tokenAddress: nftAddress, + tokenId: Uint256.fromIntString(tokenId), + fulfillBrokerAddress: + '0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078', + ); final tokenIdBigInt = BigInt.parse(tokenId); @@ -266,24 +288,31 @@ class ArkStarknet { ...computeCalldata(fulfillInfo.fulfillBrokerAddress), ]; - final response = await starknetAccount.execute(functionCalls: [ - FunctionCall( - contractAddress: Felt.fromHexString(currencyAddress), - entryPointSelector: getSelectorByName("approve"), - calldata: [arkExecutorAddress, Felt(bigIntAmount), Felt.fromInt(0)], - ), - FunctionCall( - contractAddress: arkExecutorAddress, - entryPointSelector: getSelectorByName("fulfill_order"), - calldata: callData, - ), - ], maxFee: maxFee, nonce: nonce); - - final txHash = response.when(result: (result) { - return result.transaction_hash; - }, error: (error) { - throw Exception(error.message); - }); + final response = await starknetAccount.execute( + functionCalls: [ + FunctionCall( + contractAddress: Felt.fromHexString(currencyAddress), + entryPointSelector: getSelectorByName('approve'), + calldata: [arkExecutorAddress, Felt(bigIntAmount), Felt.fromInt(0)], + ), + FunctionCall( + contractAddress: arkExecutorAddress, + entryPointSelector: getSelectorByName('fulfill_order'), + calldata: callData, + ), + ], + max_fee: maxFee, + nonce: nonce, + ); + + final txHash = response.when( + result: (result) { + return result.transaction_hash; + }, + error: (error) { + throw Exception(error.message); + }, + ); return txHash; } @@ -294,20 +323,21 @@ class ArkStarknet { required String tokenId, required BigInt orderHash, String currencyAddress = - "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7", - String tokenChainId = "SN_MAIN", + '0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7', + String tokenChainId = 'SN_MAIN', Felt? maxFee, Felt? nonce, }) async { - final FulfillInfo fulfillInfo = FulfillInfo( - orderHash: orderHash, - relatedOrderHash: 1, - fulfiller: starknetAccount.accountAddress.toHexString(), - tokenChainId: tokenChainId, - tokenAddress: nftAddress, - tokenId: Uint256.fromIntString(tokenId), - fulfillBrokerAddress: - "0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078"); + final fulfillInfo = FulfillInfo( + orderHash: orderHash, + relatedOrderHash: 1, + fulfiller: starknetAccount.accountAddress.toHexString(), + tokenChainId: tokenChainId, + tokenAddress: nftAddress, + tokenId: Uint256.fromIntString(tokenId), + fulfillBrokerAddress: + '0xe4769a4d2f7f69c70951a003eba5c32707cef3cdfb6b27ca63567f51cdd078', + ); final tokenIdBigInt = BigInt.parse(tokenId); @@ -323,24 +353,31 @@ class ArkStarknet { ...computeCalldata(fulfillInfo.fulfillBrokerAddress), ]; - final response = await starknetAccount.execute(functionCalls: [ - FunctionCall( - contractAddress: Felt.fromHexString(nftAddress), - entryPointSelector: getSelectorByName("approve"), - calldata: [arkExecutorAddress, Felt(tokenIdBigInt), Felt.fromInt(0)], - ), - FunctionCall( - contractAddress: arkExecutorAddress, - entryPointSelector: getSelectorByName("fulfill_order"), - calldata: callData, - ), - ], maxFee: maxFee, nonce: nonce); - - final txHash = response.when(result: (result) { - return result.transaction_hash; - }, error: (error) { - throw Exception(error.message); - }); + final response = await starknetAccount.execute( + functionCalls: [ + FunctionCall( + contractAddress: Felt.fromHexString(nftAddress), + entryPointSelector: getSelectorByName('approve'), + calldata: [arkExecutorAddress, Felt(tokenIdBigInt), Felt.fromInt(0)], + ), + FunctionCall( + contractAddress: arkExecutorAddress, + entryPointSelector: getSelectorByName('fulfill_order'), + calldata: callData, + ), + ], + max_fee: maxFee, + nonce: nonce, + ); + + final txHash = response.when( + result: (result) { + return result.transaction_hash; + }, + error: (error) { + throw Exception(error.message); + }, + ); return txHash; } diff --git a/packages/ark_project/melos_ark_project.iml b/packages/ark_project/melos_ark_project.iml deleted file mode 100644 index 389d07a1..00000000 --- a/packages/ark_project/melos_ark_project.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/ark_project/pubspec.yaml b/packages/ark_project/pubspec.yaml index af6aeffb..bec836ee 100644 --- a/packages/ark_project/pubspec.yaml +++ b/packages/ark_project/pubspec.yaml @@ -7,16 +7,16 @@ environment: sdk: ">=3.0.0 <4.0.0" # Dart version constraint dependencies: - starknet: - starknet_provider: - http: ^1.2.1 - freezed_annotation: ^2.4.1 - json_annotation: ^4.8.1 + freezed_annotation: ^2.4.4 + http: ^1.2.2 + json_annotation: ^4.9.0 + starknet: ^0.1.0 + starknet_provider: ^0.1.0 dev_dependencies: - build_runner: ^2.4.9 + build_runner: ^2.4.13 dotenv: ^4.2.0 - freezed: ^2.5.2 + freezed: ^2.5.7 json_serializable: ^6.8.0 - lints: ^3.0.0 - test: ^1.24.0 + lints: ^5.0.0 + test: ^1.25.8 diff --git a/packages/ark_project/pubspec_overrides.yaml b/packages/ark_project/pubspec_overrides.yaml deleted file mode 100644 index 382e9073..00000000 --- a/packages/ark_project/pubspec_overrides.yaml +++ /dev/null @@ -1,6 +0,0 @@ -# melos_managed_dependency_overrides: starknet,starknet_provider -dependency_overrides: - starknet: - path: ../starknet - starknet_provider: - path: ../starknet_provider diff --git a/packages/secure_store/darwin/Classes/Managers/KeychainManager.swift b/packages/secure_store/darwin/Classes/Managers/KeychainManager.swift index cef02991..694917be 100644 --- a/packages/secure_store/darwin/Classes/Managers/KeychainManager.swift +++ b/packages/secure_store/darwin/Classes/Managers/KeychainManager.swift @@ -11,7 +11,7 @@ import Foundation class KeychainManager { static let securestoreCipherKey = "SecureStoreCipher" static let tagSeparator = "_" - + // Try to save or update the encrypted cipher private key to the keychain. func save(key: String, cipher: Data) { let query = [ @@ -20,39 +20,39 @@ class KeychainManager { kSecAttrSynchronizable: false, kSecAttrAccount: "\(KeychainManager.securestoreCipherKey)\(KeychainManager.tagSeparator)\(key)", ] as CFDictionary - + // Perform actions in background preventing freezing UI DispatchQueue.global(qos: .background).async { // Adds the encrypted data to the keychain let writeStatus = SecItemAdd(query, nil) - + // If data already exists, update it. if writeStatus == errSecDuplicateItem { let query = [ kSecAttrAccount: "\(KeychainManager.securestoreCipherKey)\(KeychainManager.tagSeparator)\(key)", kSecClass: kSecClassGenericPassword, ] as CFDictionary - + let attributesToUpdate = [kSecValueData: cipher] as CFDictionary SecItemUpdate(query, attributesToUpdate) } } } - + // Read the encrypted cipher private key from the keychain. func read(key: String) -> Data? { let query = [ kSecAttrAccount: "\(KeychainManager.securestoreCipherKey)\(KeychainManager.tagSeparator)\(key)", kSecClass: kSecClassGenericPassword, - kSecReturnData: true + kSecReturnData: true, ] as CFDictionary - + var result: AnyObject? SecItemCopyMatching(query, &result) - + return (result as? Data) } - + // Delete the encrypted cipher private key from the keychain. func delete(key: String) { let query = [ diff --git a/packages/secure_store/darwin/Classes/Managers/SecureEnclaveManager.swift b/packages/secure_store/darwin/Classes/Managers/SecureEnclaveManager.swift index ac293921..fa17f7bf 100644 --- a/packages/secure_store/darwin/Classes/Managers/SecureEnclaveManager.swift +++ b/packages/secure_store/darwin/Classes/Managers/SecureEnclaveManager.swift @@ -25,196 +25,213 @@ class SecureEnclaveManager { static let securestoreTag = "securestore.private.key" static let tagSeparator = "_" static let secretKeyAlgorithm = SecKeyAlgorithm.eciesEncryptionCofactorVariableIVX963SHA256AESGCM - static let keySizeBits = 256; - - // Attempts to retrieve a secret key from the Secure Enclave. If successful, it returns the key as a SecKey object. - private func getSecretKey(key: String) throws -> SecKey? { - guard let secAttrApplicationTag = "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)".data(using: .utf8) else { + static let keySizeBits = 256 + + // Attempts to retrieve a secret key from the Secure Enclave. If successful, it returns the key as + // a SecKey object. + private func getSecretKey(key: String) throws -> SecKey? { + guard let secAttrApplicationTag = + "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)" + .data(using: .utf8) else { throw SecureEnclaveErrors.tagConvertion } - + // Create a dictionary of attributes that will be used to search for the private key. - // The search criteria includes the application tag, the key type (Elliptic curve), and a limit of one result. + // The search criteria includes the application tag, the key type (Elliptic curve), and a limit + // of one result. let query: [String: Any] = [ - kSecClass as String : kSecClassKey, - kSecAttrApplicationTag as String : secAttrApplicationTag, - kSecAttrKeyType as String : kSecAttrKeyTypeEC, - kSecMatchLimit as String : kSecMatchLimitOne , - kSecReturnRef as String : true + kSecClass as String: kSecClassKey, + kSecAttrApplicationTag as String: secAttrApplicationTag, + kSecAttrKeyType as String: kSecAttrKeyTypeEC, + kSecMatchLimit as String: kSecMatchLimitOne, + kSecReturnRef as String: true, ] - + // Perform the search for the private key, and store the result in 'item'. var item: CFTypeRef? let status = SecItemCopyMatching(query as CFDictionary, &item) - + // Check the status of the search. If it failed or didn't find anything, return nil. - guard status == errSecSuccess && item != nil else { + guard status == errSecSuccess, item != nil else { // secret key was not found, return nothing return nil } - + // Cast the result to a SecKey object and return it. return (item as! SecKey) } - + // Generates a new public-private key pair and returns the private key as a SecKey object. - // The private key is created with certain attributes that are specified in the 'parameters' dictionary. - private func generateKeypair(key: String) throws -> SecKey { + // The private key is created with certain attributes that are specified in the 'parameters' + // dictionary. + private func generateKeypair(key: String) throws -> SecKey { // Create an attribute representing the application tag for the key. // The Secure Enclave uses this tag to identify the key. - guard let secAttrApplicationTag = "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)".data(using: .utf8) else { + guard let secAttrApplicationTag = + "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)" + .data(using: .utf8) else { throw SecureEnclaveErrors.tagConvertion } // Prompt for biometric authentication let biometricResult = AuthenticationUtil.promptBiometric() - if (!biometricResult) { + if !biometricResult { throw SecureEnclaveErrors.biometricNotAvailable } - + // Create an access control object that specifies how the key can be used. var accessError: Unmanaged? - var params: SecAccessControlCreateFlags; - - var accessibleParam: CFString; -#if os(macOS) - params = .userPresence - accessibleParam = kSecAttrAccessibleWhenUnlocked -#elseif os(iOS) - // Set control flag according iOS version. - if #available(iOS 11.3, *) { - params = [.privateKeyUsage, .biometryCurrentSet] - } else { - params = [.privateKeyUsage, .touchIDCurrentSet] - } - accessibleParam = kSecAttrAccessibleWhenUnlockedThisDeviceOnly -#endif - + var params: SecAccessControlCreateFlags + + var accessibleParam: CFString + #if os(macOS) + params = .userPresence + accessibleParam = kSecAttrAccessibleWhenUnlocked + #elseif os(iOS) + // Set control flag according iOS version. + if #available(iOS 11.3, *) { + params = [.privateKeyUsage, .biometryCurrentSet] + } else { + params = [.privateKeyUsage, .touchIDCurrentSet] + } + accessibleParam = kSecAttrAccessibleWhenUnlockedThisDeviceOnly + #endif + let secAttrAccessControl = - SecAccessControlCreateWithFlags( - kCFAllocatorDefault, - accessibleParam, - params, - &accessError - ) + SecAccessControlCreateWithFlags( + kCFAllocatorDefault, + accessibleParam, + params, + &accessError + ) if let error = accessError { throw SecureEnclaveErrors.access(error.takeRetainedValue().localizedDescription) } - + // Create a dictionary of attributes that will be used to generate the key pair. // The attributes specify the key type (Elliptic curve), the key size (256 bits), // key is stored permanently and will persist between application launches, // tag to retrieve the key later and access control settings for the private key - var parameters: Dictionary = [ - kSecAttrKeyType as String : kSecAttrKeyTypeEC, - kSecAttrKeySizeInBits as String : SecureEnclaveManager.keySizeBits, - kSecPrivateKeyAttrs as String : [ - kSecAttrIsPermanent as String : true, - kSecAttrApplicationTag as String : secAttrApplicationTag, - kSecAttrAccessControl as String : secAttrAccessControl! - ] + var parameters: [String: Any] = [ + kSecAttrKeyType as String: kSecAttrKeyTypeEC, + kSecAttrKeySizeInBits as String: SecureEnclaveManager.keySizeBits, + kSecPrivateKeyAttrs as String: [ + kSecAttrIsPermanent as String: true, + kSecAttrApplicationTag as String: secAttrApplicationTag, + kSecAttrAccessControl as String: secAttrAccessControl!, + ], ] - - // If the device is not a simulator, specify that the key should be stored in the Secure Enclave. + + // If the device is not a simulator, specify that the key should be stored in the Secure + // Enclave. // (secure enclave is not available on Simulator) -#if os(iOS) - if !Platform.isSimulator { - parameters[kSecAttrTokenID as String] = kSecAttrTokenIDSecureEnclave - } -#endif - + #if os(iOS) + if !Platform.isSimulator { + parameters[kSecAttrTokenID as String] = kSecAttrTokenIDSecureEnclave + } + #endif + // Generate the key pair, and store the private key in 'secKey'. var secKeyCreateRandomKeyError: Unmanaged? - guard let secKey = SecKeyCreateRandomKey((parameters as CFDictionary), &secKeyCreateRandomKeyError) else { - throw SecureEnclaveErrors.secretKeyGeneration(secKeyCreateRandomKeyError!.takeRetainedValue().localizedDescription) + guard let secKey = SecKeyCreateRandomKey(parameters as CFDictionary, + &secKeyCreateRandomKeyError) else { + throw SecureEnclaveErrors + .secretKeyGeneration(secKeyCreateRandomKeyError!.takeRetainedValue().localizedDescription) } - + return secKey } - + // This function encrypts a message using the secret key in the secure enclave. func encrypt(key: String, message: Data) throws -> Data { // Attempt to retrieve the secret key from the secure enclave. var secretKey = try getSecretKey(key: key) - - // If the secret key does not exist, generate a new key pair and save the private key in the secure enclave. - if (secretKey == nil) { + + // If the secret key does not exist, generate a new key pair and save the private key in the + // secure enclave. + if secretKey == nil { secretKey = try generateKeypair(key: key) } - + // Get the public key from the secret key. guard let publicKey = SecKeyCopyPublicKey(secretKey!) else { throw SecureEnclaveErrors.emptyPublicKey } - + // Check if the algorithm is supported for encryption with the public key. - guard SecKeyIsAlgorithmSupported(publicKey, .encrypt, SecureEnclaveManager.secretKeyAlgorithm) else { + guard SecKeyIsAlgorithmSupported(publicKey, .encrypt, SecureEnclaveManager.secretKeyAlgorithm) + else { throw SecureEnclaveErrors.unsuportedAlgorithm } - + // Encrypt the message using the public key. var error: Unmanaged? let cipherTextData = SecKeyCreateEncryptedData( publicKey, SecureEnclaveManager.secretKeyAlgorithm, message as CFData, - &error) as Data? - + &error + ) as Data? + if (error != nil) || (cipherTextData == nil) { throw SecureEnclaveErrors.encryption(error?.takeRetainedValue().localizedDescription) } - + // Return the encrypted message as a Data object. - return cipherTextData!; + return cipherTextData! } - + // Attempts to decrypt a given cipher data using a secret key retrieved from the secure enclave - func decrypt(key: String, cipherData: Data) throws -> Data? { + func decrypt(key: String, cipherData: Data) throws -> Data? { // Attempts to retrieve the secret key from the secure enclave guard let secretKey = try getSecretKey(key: key) else { throw SecureEnclaveErrors.secretKeyNotExist } - + // Checks if the secret key supports the decryption algorithm - guard SecKeyIsAlgorithmSupported(secretKey, .decrypt, SecureEnclaveManager.secretKeyAlgorithm) else { + guard SecKeyIsAlgorithmSupported(secretKey, .decrypt, SecureEnclaveManager.secretKeyAlgorithm) + else { throw SecureEnclaveErrors.unsuportedAlgorithm } - + // Attempts to decrypt the given cipher data using the secret key var error: Unmanaged? let plainTextData = SecKeyCreateDecryptedData( secretKey, SecureEnclaveManager.secretKeyAlgorithm, cipherData as CFData, - &error) as Data? - + &error + ) as Data? + if error != nil || plainTextData == nil { throw SecureEnclaveErrors.decryption(error?.takeUnretainedValue().localizedDescription) } - + // Returns the plaintext string resulting from the decryption return plainTextData } - + // Attempts to delete the secret key from the secure enclave func delete(key: String) throws { - guard let secAttrApplicationTag = "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)".data(using: .utf8) else { + guard let secAttrApplicationTag = + "\(SecureEnclaveManager.securestoreTag)\(SecureEnclaveManager.tagSeparator)\(key)" + .data(using: .utf8) else { throw SecureEnclaveErrors.tagConvertion } - + // Attempt to retrieve the secret key from the secure enclave. let secretKey = try getSecretKey(key: key) - if (secretKey == nil) { + if secretKey == nil { throw SecureEnclaveErrors.secretKeyNotExist } - + let query: [String: Any] = [ - kSecClass as String : kSecClassKey, - kSecAttrApplicationTag as String : secAttrApplicationTag + kSecClass as String: kSecClassKey, + kSecAttrApplicationTag as String: secAttrApplicationTag, ] - + // Remove the key from the secure enclave. - if (SecItemDelete(query as CFDictionary) != errSecSuccess) { + if SecItemDelete(query as CFDictionary) != errSecSuccess { throw SecureEnclaveErrors.deletion } } diff --git a/packages/secure_store/darwin/Classes/SecureStoreBridge.swift b/packages/secure_store/darwin/Classes/SecureStoreBridge.swift index a346757b..10133b89 100644 --- a/packages/secure_store/darwin/Classes/SecureStoreBridge.swift +++ b/packages/secure_store/darwin/Classes/SecureStoreBridge.swift @@ -3,15 +3,15 @@ import Foundation #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { - return [result] + [result] } private func wrapError(_ error: Any) -> [Any?] { @@ -19,13 +19,13 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } @@ -37,8 +37,8 @@ private func nilOrValue(_ value: Any?) -> T? { /// Generated class from Pigeon that represents data sent in messages. struct AndroidPromptInfos { var title: String - var subtitle: String? = nil - var description: String? = nil + var subtitle: String? + var description: String? var cancelLabel: String var confirmationRequired: Bool @@ -57,8 +57,9 @@ struct AndroidPromptInfos { confirmationRequired: confirmationRequired ) } + func toList() -> [Any?] { - return [ + [ title, subtitle, description, @@ -73,22 +74,24 @@ struct AndroidPromptInfos { /// Generated class from Pigeon that represents data sent in messages. struct AndroidOptions { /// Details of the prompt to show to the user. - var promptInfo: AndroidPromptInfos? = nil + var promptInfo: AndroidPromptInfos? /// The duration in seconds for which the authentication is valid. If the /// user sets it to -1 (default), user must authenticate each time they want /// to get or set a secret. var authenticationValidityDurationSeconds: Int64 /// Whether to use the StrongBox hardware-backed keystore. - /// This feature seems to cause [crashes](https://github.com/authpass/biometric_storage/issues/76), + /// This feature seems to cause + /// [crashes](https://github.com/authpass/biometric_storage/issues/76), /// enable with caution. var enableStrongBox: Bool static func fromList(_ list: [Any?]) -> AndroidOptions? { - var promptInfo: AndroidPromptInfos? = nil + var promptInfo: AndroidPromptInfos? if let promptInfoList: [Any?] = nilOrValue(list[0]) { promptInfo = AndroidPromptInfos.fromList(promptInfoList) } - let authenticationValidityDurationSeconds = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) + let authenticationValidityDurationSeconds = list[1] is Int64 ? list[1] as! Int64 : + Int64(list[1] as! Int32) let enableStrongBox = list[2] as! Bool return AndroidOptions( @@ -97,8 +100,9 @@ struct AndroidOptions { enableStrongBox: enableStrongBox ) } + func toList() -> [Any?] { - return [ + [ promptInfo?.toList(), authenticationValidityDurationSeconds, enableStrongBox, @@ -111,10 +115,10 @@ struct AndroidOptions { /// Generated class from Pigeon that represents data sent in messages. struct BiometricOptions { /// Android-specific options. - var androidOptions: AndroidOptions? = nil + var androidOptions: AndroidOptions? static func fromList(_ list: [Any?]) -> BiometricOptions? { - var androidOptions: AndroidOptions? = nil + var androidOptions: AndroidOptions? if let androidOptionsList: [Any?] = nilOrValue(list[0]) { androidOptions = AndroidOptions.fromList(androidOptionsList) } @@ -123,8 +127,9 @@ struct BiometricOptions { androidOptions: androidOptions ) } + func toList() -> [Any?] { - return [ + [ androidOptions?.toList(), ] } @@ -133,14 +138,14 @@ struct BiometricOptions { private class SecureStoreBridgeCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AndroidOptions.fromList(self.readValue() as! [Any?]) - case 129: - return AndroidPromptInfos.fromList(self.readValue() as! [Any?]) - case 130: - return BiometricOptions.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AndroidOptions.fromList(readValue() as! [Any?]) + case 129: + return AndroidPromptInfos.fromList(readValue() as! [Any?]) + case 130: + return BiometricOptions.fromList(readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -164,11 +169,11 @@ private class SecureStoreBridgeCodecWriter: FlutterStandardWriter { private class SecureStoreBridgeCodecReaderWriter: FlutterStandardReaderWriter { override func reader(with data: Data) -> FlutterStandardReader { - return SecureStoreBridgeCodecReader(data: data) + SecureStoreBridgeCodecReader(data: data) } override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return SecureStoreBridgeCodecWriter(data: data) + SecureStoreBridgeCodecWriter(data: data) } } @@ -178,9 +183,12 @@ class SecureStoreBridgeCodec: FlutterStandardMessageCodec { /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol SecureStoreBridge { - func storeSecret(key: String, privateKey: FlutterStandardTypedData, biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) + func storeSecret(key: String, privateKey: FlutterStandardTypedData, + biometricOptions: BiometricOptions?, + completion: @escaping (Result) -> Void) func removeSecret(key: String, completion: @escaping (Result) -> Void) - func getSecret(key: String, biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) + func getSecret(key: String, biometricOptions: BiometricOptions?, + completion: @escaping (Result) -> Void) func isBiometryAvailable() throws -> Bool } @@ -190,62 +198,82 @@ class SecureStoreBridgeSetup { static var codec: FlutterStandardMessageCodec { SecureStoreBridgeCodec.shared } /// Sets up an instance of `SecureStoreBridge` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: SecureStoreBridge?) { - let storeSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let storeSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { storeSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String let privateKeyArg = args[1] as! FlutterStandardTypedData let biometricOptionsArg: BiometricOptions? = nilOrValue(args[2]) - api.storeSecret(key: keyArg, privateKey: privateKeyArg, biometricOptions: biometricOptionsArg) { result in + api.storeSecret( + key: keyArg, + privateKey: privateKeyArg, + biometricOptions: biometricOptionsArg + ) { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case let .failure(error): + reply(wrapError(error)) } } } } else { storeSecretChannel.setMessageHandler(nil) } - let removeSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let removeSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { removeSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String api.removeSecret(key: keyArg) { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case let .failure(error): + reply(wrapError(error)) } } } } else { removeSecretChannel.setMessageHandler(nil) } - let getSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let getSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { getSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String let biometricOptionsArg: BiometricOptions? = nilOrValue(args[1]) api.getSecret(key: keyArg, biometricOptions: biometricOptionsArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) } } } } else { getSecretChannel.setMessageHandler(nil) } - let isBiometryAvailableChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let isBiometryAvailableChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { isBiometryAvailableChannel.setMessageHandler { _, reply in do { let result = try api.isBiometryAvailable() diff --git a/packages/secure_store/darwin/Classes/Utils/AuthenticationUtil.swift b/packages/secure_store/darwin/Classes/Utils/AuthenticationUtil.swift index 54411acc..50b83209 100644 --- a/packages/secure_store/darwin/Classes/Utils/AuthenticationUtil.swift +++ b/packages/secure_store/darwin/Classes/Utils/AuthenticationUtil.swift @@ -1,6 +1,6 @@ import LocalAuthentication -struct AuthenticationUtil { +enum AuthenticationUtil { // Prompt for biometric authentication static func promptBiometric() -> Bool { let context = LAContext() @@ -12,17 +12,21 @@ struct AuthenticationUtil { if !permissions { return false } - + var success = false let sema = DispatchSemaphore(value: 0) - context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate with biometrics to store private key.", reply: { (result, error) in - success = result && error == nil - sema.signal() - }) + context.evaluatePolicy( + .deviceOwnerAuthentication, + localizedReason: "Authenticate with biometrics to store private key.", + reply: { result, error in + success = result && error == nil + sema.signal() + } + ) sema.wait() return success } - + static func isBiometryAvailable() -> Bool { let context = LAContext() var error: NSError? @@ -30,7 +34,7 @@ struct AuthenticationUtil { .deviceOwnerAuthenticationWithBiometrics, error: &error ) - - return (isBiometryAvailable && error == nil) + + return isBiometryAvailable && error == nil } } diff --git a/packages/secure_store/example/ios/Runner/AppDelegate.swift b/packages/secure_store/example/ios/Runner/AppDelegate.swift index 70693e4a..17562970 100644 --- a/packages/secure_store/example/ios/Runner/AppDelegate.swift +++ b/packages/secure_store/example/ios/Runner/AppDelegate.swift @@ -1,13 +1,13 @@ -import UIKit import Flutter +import UIKit @UIApplicationMain @objc class AppDelegate: FlutterAppDelegate { - override func application( - _ application: UIApplication, - didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? - ) -> Bool { - GeneratedPluginRegistrant.register(with: self) - return super.application(application, didFinishLaunchingWithOptions: launchOptions) - } + override func application( + _ application: UIApplication, + didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? + ) -> Bool { + GeneratedPluginRegistrant.register(with: self) + return super.application(application, didFinishLaunchingWithOptions: launchOptions) + } } diff --git a/packages/secure_store/example/ios/RunnerTests/RunnerTests.swift b/packages/secure_store/example/ios/RunnerTests/RunnerTests.swift index 86a7c3b1..b0d10f2e 100644 --- a/packages/secure_store/example/ios/RunnerTests/RunnerTests.swift +++ b/packages/secure_store/example/ios/RunnerTests/RunnerTests.swift @@ -3,10 +3,8 @@ import UIKit import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/packages/secure_store/example/macos/Runner/AppDelegate.swift b/packages/secure_store/example/macos/Runner/AppDelegate.swift index d53ef643..8f3dd47c 100644 --- a/packages/secure_store/example/macos/Runner/AppDelegate.swift +++ b/packages/secure_store/example/macos/Runner/AppDelegate.swift @@ -3,7 +3,7 @@ import FlutterMacOS @NSApplicationMain class AppDelegate: FlutterAppDelegate { - override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { - return true - } + override func applicationShouldTerminateAfterLastWindowClosed(_: NSApplication) -> Bool { + return true + } } diff --git a/packages/secure_store/example/macos/Runner/MainFlutterWindow.swift b/packages/secure_store/example/macos/Runner/MainFlutterWindow.swift index 3cc05eb2..decbd0eb 100644 --- a/packages/secure_store/example/macos/Runner/MainFlutterWindow.swift +++ b/packages/secure_store/example/macos/Runner/MainFlutterWindow.swift @@ -2,14 +2,14 @@ import Cocoa import FlutterMacOS class MainFlutterWindow: NSWindow { - override func awakeFromNib() { - let flutterViewController = FlutterViewController() - let windowFrame = self.frame - self.contentViewController = flutterViewController - self.setFrame(windowFrame, display: true) + override func awakeFromNib() { + let flutterViewController = FlutterViewController() + let windowFrame = frame + contentViewController = flutterViewController + setFrame(windowFrame, display: true) - RegisterGeneratedPlugins(registry: flutterViewController) + RegisterGeneratedPlugins(registry: flutterViewController) - super.awakeFromNib() - } + super.awakeFromNib() + } } diff --git a/packages/secure_store/example/macos/RunnerTests/RunnerTests.swift b/packages/secure_store/example/macos/RunnerTests/RunnerTests.swift index 5418c9f5..4fc85d1c 100644 --- a/packages/secure_store/example/macos/RunnerTests/RunnerTests.swift +++ b/packages/secure_store/example/macos/RunnerTests/RunnerTests.swift @@ -1,12 +1,10 @@ -import FlutterMacOS import Cocoa +import FlutterMacOS import XCTest class RunnerTests: XCTestCase { - func testExample() { // If you add code to the Runner application, consider adding tests here. // See https://developer.apple.com/documentation/xctest for more information about using XCTest. } - } diff --git a/packages/secure_store/example/pubspec.yaml b/packages/secure_store/example/pubspec.yaml index c23c7992..110e604c 100644 --- a/packages/secure_store/example/pubspec.yaml +++ b/packages/secure_store/example/pubspec.yaml @@ -33,8 +33,8 @@ dependencies: # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. - cupertino_icons: ^1.0.2 - secure_store: + cupertino_icons: ^1.0.8 + secure_store: ^0.1.2 dev_dependencies: flutter_test: @@ -45,7 +45,7 @@ dev_dependencies: # activated in the `analysis_options.yaml` file located at the root of your # package. See that file for information about deactivating specific lint # rules and activating additional ones. - flutter_lints: ^2.0.0 + flutter_lints: ^5.0.0 # For information on the generic Dart part of this file, see the # following page: https://dart.dev/tools/pub/pubspec diff --git a/packages/secure_store/example/pubspec_overrides.yaml b/packages/secure_store/example/pubspec_overrides.yaml deleted file mode 100644 index 5d5f0482..00000000 --- a/packages/secure_store/example/pubspec_overrides.yaml +++ /dev/null @@ -1,4 +0,0 @@ -# melos_managed_dependency_overrides: secure_store -dependency_overrides: - secure_store: - path: ../ diff --git a/packages/secure_store/example/windows/runner/flutter_window.cpp b/packages/secure_store/example/windows/runner/flutter_window.cpp index b25e363e..12f42e0b 100644 --- a/packages/secure_store/example/windows/runner/flutter_window.cpp +++ b/packages/secure_store/example/windows/runner/flutter_window.cpp @@ -4,7 +4,7 @@ #include "flutter/generated_plugin_registrant.h" -FlutterWindow::FlutterWindow(const flutter::DartProject& project) +FlutterWindow::FlutterWindow(const flutter::DartProject &project) : project_(project) {} FlutterWindow::~FlutterWindow() {} @@ -27,9 +27,7 @@ bool FlutterWindow::OnCreate() { RegisterPlugins(flutter_controller_->engine()); SetChildContent(flutter_controller_->view()->GetNativeWindow()); - flutter_controller_->engine()->SetNextFrameCallback([&]() { - this->Show(); - }); + flutter_controller_->engine()->SetNextFrameCallback([&]() { this->Show(); }); return true; } @@ -57,9 +55,9 @@ FlutterWindow::MessageHandler(HWND hwnd, UINT const message, } switch (message) { - case WM_FONTCHANGE: - flutter_controller_->engine()->ReloadSystemFonts(); - break; + case WM_FONTCHANGE: + flutter_controller_->engine()->ReloadSystemFonts(); + break; } return Win32Window::MessageHandler(hwnd, message, wparam, lparam); diff --git a/packages/secure_store/example/windows/runner/flutter_window.h b/packages/secure_store/example/windows/runner/flutter_window.h index 6da0652f..7fa026bf 100644 --- a/packages/secure_store/example/windows/runner/flutter_window.h +++ b/packages/secure_store/example/windows/runner/flutter_window.h @@ -10,19 +10,19 @@ // A window that does nothing but host a Flutter view. class FlutterWindow : public Win32Window { - public: +public: // Creates a new FlutterWindow hosting a Flutter view running |project|. - explicit FlutterWindow(const flutter::DartProject& project); + explicit FlutterWindow(const flutter::DartProject &project); virtual ~FlutterWindow(); - protected: +protected: // Win32Window: bool OnCreate() override; void OnDestroy() override; LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept override; - private: +private: // The project to run. flutter::DartProject project_; @@ -30,4 +30,4 @@ class FlutterWindow : public Win32Window { std::unique_ptr flutter_controller_; }; -#endif // RUNNER_FLUTTER_WINDOW_H_ +#endif // RUNNER_FLUTTER_WINDOW_H_ diff --git a/packages/secure_store/example/windows/runner/main.cpp b/packages/secure_store/example/windows/runner/main.cpp index a61bf80d..6a6b7911 100644 --- a/packages/secure_store/example/windows/runner/main.cpp +++ b/packages/secure_store/example/windows/runner/main.cpp @@ -19,8 +19,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, flutter::DartProject project(L"data"); - std::vector command_line_arguments = - GetCommandLineArguments(); + std::vector command_line_arguments = GetCommandLineArguments(); project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); diff --git a/packages/secure_store/example/windows/runner/resource.h b/packages/secure_store/example/windows/runner/resource.h index 66a65d1e..d5d958dc 100644 --- a/packages/secure_store/example/windows/runner/resource.h +++ b/packages/secure_store/example/windows/runner/resource.h @@ -2,15 +2,15 @@ // Microsoft Visual C++ generated include file. // Used by Runner.rc // -#define IDI_APP_ICON 101 +#define IDI_APP_ICON 101 // Next default values for new objects // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 102 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 +#define _APS_NEXT_RESOURCE_VALUE 102 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 #endif #endif diff --git a/packages/secure_store/example/windows/runner/utils.cpp b/packages/secure_store/example/windows/runner/utils.cpp index b2b08734..ae64b590 100644 --- a/packages/secure_store/example/windows/runner/utils.cpp +++ b/packages/secure_store/example/windows/runner/utils.cpp @@ -24,7 +24,7 @@ void CreateAndAttachConsole() { std::vector GetCommandLineArguments() { // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. int argc; - wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); + wchar_t **argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); if (argv == nullptr) { return std::vector(); } @@ -41,14 +41,14 @@ std::vector GetCommandLineArguments() { return command_line_arguments; } -std::string Utf8FromUtf16(const wchar_t* utf16_string) { +std::string Utf8FromUtf16(const wchar_t *utf16_string) { if (utf16_string == nullptr) { return std::string(); } - int target_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - -1, nullptr, 0, nullptr, nullptr) - -1; // remove the trailing null character + int target_length = + ::WideCharToMultiByte(CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1, + nullptr, 0, nullptr, nullptr) - + 1; // remove the trailing null character int input_length = (int)wcslen(utf16_string); std::string utf8_string; if (target_length <= 0 || target_length > utf8_string.max_size()) { @@ -56,8 +56,8 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) { } utf8_string.resize(target_length); int converted_length = ::WideCharToMultiByte( - CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, - input_length, utf8_string.data(), target_length, nullptr, nullptr); + CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, input_length, + utf8_string.data(), target_length, nullptr, nullptr); if (converted_length == 0) { return std::string(); } diff --git a/packages/secure_store/example/windows/runner/utils.h b/packages/secure_store/example/windows/runner/utils.h index 3879d547..ff43ce2c 100644 --- a/packages/secure_store/example/windows/runner/utils.h +++ b/packages/secure_store/example/windows/runner/utils.h @@ -10,10 +10,10 @@ void CreateAndAttachConsole(); // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string // encoded in UTF-8. Returns an empty std::string on failure. -std::string Utf8FromUtf16(const wchar_t* utf16_string); +std::string Utf8FromUtf16(const wchar_t *utf16_string); // Gets the command line arguments passed in as a std::vector, // encoded in UTF-8. Returns an empty std::vector on failure. std::vector GetCommandLineArguments(); -#endif // RUNNER_UTILS_H_ +#endif // RUNNER_UTILS_H_ diff --git a/packages/secure_store/example/windows/runner/win32_window.cpp b/packages/secure_store/example/windows/runner/win32_window.cpp index 60608d0f..145247bb 100644 --- a/packages/secure_store/example/windows/runner/win32_window.cpp +++ b/packages/secure_store/example/windows/runner/win32_window.cpp @@ -11,7 +11,8 @@ namespace { /// /// Redefined in case the developer's machine has a Windows SDK older than /// version 10.0.22000.0. -/// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute +/// See: +/// https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 #endif @@ -23,8 +24,9 @@ constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; /// A value of 0 indicates apps should use dark mode. A non-zero or missing /// value indicates apps should use light mode. constexpr const wchar_t kGetPreferredBrightnessRegKey[] = - L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; -constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; + L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; +constexpr const wchar_t kGetPreferredBrightnessRegValue[] = + L"AppsUseLightTheme"; // The number of Win32Window objects that currently exist. static int g_active_window_count = 0; @@ -45,7 +47,7 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { return; } auto enable_non_client_dpi_scaling = - reinterpret_cast( + reinterpret_cast( GetProcAddress(user32_module, "EnableNonClientDpiScaling")); if (enable_non_client_dpi_scaling != nullptr) { enable_non_client_dpi_scaling(hwnd); @@ -53,15 +55,15 @@ void EnableFullDpiSupportIfAvailable(HWND hwnd) { FreeLibrary(user32_module); } -} // namespace +} // namespace // Manages the Win32Window's window class registration. class WindowClassRegistrar { - public: +public: ~WindowClassRegistrar() = default; // Returns the singleton registrar instance. - static WindowClassRegistrar* GetInstance() { + static WindowClassRegistrar *GetInstance() { if (!instance_) { instance_ = new WindowClassRegistrar(); } @@ -70,23 +72,23 @@ class WindowClassRegistrar { // Returns the name of the window class, registering the class if it hasn't // previously been registered. - const wchar_t* GetWindowClass(); + const wchar_t *GetWindowClass(); // Unregisters the window class. Should only be called if there are no // instances of the window. void UnregisterWindowClass(); - private: +private: WindowClassRegistrar() = default; - static WindowClassRegistrar* instance_; + static WindowClassRegistrar *instance_; bool class_registered_ = false; }; -WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; +WindowClassRegistrar *WindowClassRegistrar::instance_ = nullptr; -const wchar_t* WindowClassRegistrar::GetWindowClass() { +const wchar_t *WindowClassRegistrar::GetWindowClass() { if (!class_registered_) { WNDCLASS window_class{}; window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); @@ -111,21 +113,18 @@ void WindowClassRegistrar::UnregisterWindowClass() { class_registered_ = false; } -Win32Window::Win32Window() { - ++g_active_window_count; -} +Win32Window::Win32Window() { ++g_active_window_count; } Win32Window::~Win32Window() { --g_active_window_count; Destroy(); } -bool Win32Window::Create(const std::wstring& title, - const Point& origin, - const Size& size) { +bool Win32Window::Create(const std::wstring &title, const Point &origin, + const Size &size) { Destroy(); - const wchar_t* window_class = + const wchar_t *window_class = WindowClassRegistrar::GetInstance()->GetWindowClass(); const POINT target_point = {static_cast(origin.x), @@ -149,24 +148,21 @@ bool Win32Window::Create(const std::wstring& title, return OnCreate(); } -bool Win32Window::Show() { - return ShowWindow(window_handle_, SW_SHOWNORMAL); -} +bool Win32Window::Show() { return ShowWindow(window_handle_, SW_SHOWNORMAL); } // static -LRESULT CALLBACK Win32Window::WndProc(HWND const window, - UINT const message, +LRESULT CALLBACK Win32Window::WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept { if (message == WM_NCCREATE) { - auto window_struct = reinterpret_cast(lparam); + auto window_struct = reinterpret_cast(lparam); SetWindowLongPtr(window, GWLP_USERDATA, reinterpret_cast(window_struct->lpCreateParams)); - auto that = static_cast(window_struct->lpCreateParams); + auto that = static_cast(window_struct->lpCreateParams); EnableFullDpiSupportIfAvailable(window); that->window_handle_ = window; - } else if (Win32Window* that = GetThisFromHandle(window)) { + } else if (Win32Window *that = GetThisFromHandle(window)) { return that->MessageHandler(window, message, wparam, lparam); } @@ -174,48 +170,46 @@ LRESULT CALLBACK Win32Window::WndProc(HWND const window, } LRESULT -Win32Window::MessageHandler(HWND hwnd, - UINT const message, - WPARAM const wparam, +Win32Window::MessageHandler(HWND hwnd, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept { switch (message) { - case WM_DESTROY: - window_handle_ = nullptr; - Destroy(); - if (quit_on_close_) { - PostQuitMessage(0); - } - return 0; - - case WM_DPICHANGED: { - auto newRectSize = reinterpret_cast(lparam); - LONG newWidth = newRectSize->right - newRectSize->left; - LONG newHeight = newRectSize->bottom - newRectSize->top; - - SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, - newHeight, SWP_NOZORDER | SWP_NOACTIVATE); - - return 0; + case WM_DESTROY: + window_handle_ = nullptr; + Destroy(); + if (quit_on_close_) { + PostQuitMessage(0); } - case WM_SIZE: { - RECT rect = GetClientArea(); - if (child_content_ != nullptr) { - // Size and position the child window. - MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, - rect.bottom - rect.top, TRUE); - } - return 0; + return 0; + + case WM_DPICHANGED: { + auto newRectSize = reinterpret_cast(lparam); + LONG newWidth = newRectSize->right - newRectSize->left; + LONG newHeight = newRectSize->bottom - newRectSize->top; + + SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, + newHeight, SWP_NOZORDER | SWP_NOACTIVATE); + + return 0; + } + case WM_SIZE: { + RECT rect = GetClientArea(); + if (child_content_ != nullptr) { + // Size and position the child window. + MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, + rect.bottom - rect.top, TRUE); } + return 0; + } - case WM_ACTIVATE: - if (child_content_ != nullptr) { - SetFocus(child_content_); - } - return 0; + case WM_ACTIVATE: + if (child_content_ != nullptr) { + SetFocus(child_content_); + } + return 0; - case WM_DWMCOLORIZATIONCOLORCHANGED: - UpdateTheme(hwnd); - return 0; + case WM_DWMCOLORIZATIONCOLORCHANGED: + UpdateTheme(hwnd); + return 0; } return DefWindowProc(window_handle_, message, wparam, lparam); @@ -233,8 +227,8 @@ void Win32Window::Destroy() { } } -Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { - return reinterpret_cast( +Win32Window *Win32Window::GetThisFromHandle(HWND const window) noexcept { + return reinterpret_cast( GetWindowLongPtr(window, GWLP_USERDATA)); } @@ -255,9 +249,7 @@ RECT Win32Window::GetClientArea() { return frame; } -HWND Win32Window::GetHandle() { - return window_handle_; -} +HWND Win32Window::GetHandle() { return window_handle_; } void Win32Window::SetQuitOnClose(bool quit_on_close) { quit_on_close_ = quit_on_close; @@ -275,10 +267,10 @@ void Win32Window::OnDestroy() { void Win32Window::UpdateTheme(HWND const window) { DWORD light_mode; DWORD light_mode_size = sizeof(light_mode); - LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, - kGetPreferredBrightnessRegValue, - RRF_RT_REG_DWORD, nullptr, &light_mode, - &light_mode_size); + LSTATUS result = + RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, + kGetPreferredBrightnessRegValue, RRF_RT_REG_DWORD, nullptr, + &light_mode, &light_mode_size); if (result == ERROR_SUCCESS) { BOOL enable_dark_mode = light_mode == 0; diff --git a/packages/secure_store/example/windows/runner/win32_window.h b/packages/secure_store/example/windows/runner/win32_window.h index e901dde6..5a8c5a6b 100644 --- a/packages/secure_store/example/windows/runner/win32_window.h +++ b/packages/secure_store/example/windows/runner/win32_window.h @@ -11,7 +11,7 @@ // inherited from by classes that wish to specialize with custom // rendering and input handling class Win32Window { - public: +public: struct Point { unsigned int x; unsigned int y; @@ -34,7 +34,7 @@ class Win32Window { // consistent size this function will scale the inputted width and height as // as appropriate for the default monitor. The window is invisible until // |Show| is called. Returns true if the window was created successfully. - bool Create(const std::wstring& title, const Point& origin, const Size& size); + bool Create(const std::wstring &title, const Point &origin, const Size &size); // Show the current window. Returns true if the window was successfully shown. bool Show(); @@ -55,12 +55,11 @@ class Win32Window { // Return a RECT representing the bounds of the current client area. RECT GetClientArea(); - protected: +protected: // Processes and route salient window messages for mouse handling, // size change and DPI. Delegates handling of these to member overloads that // inheriting classes can handle. - virtual LRESULT MessageHandler(HWND window, - UINT const message, + virtual LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept; @@ -71,7 +70,7 @@ class Win32Window { // Called when Destroy is called. virtual void OnDestroy(); - private: +private: friend class WindowClassRegistrar; // OS callback called by message pump. Handles the WM_NCCREATE message which @@ -79,13 +78,12 @@ class Win32Window { // non-client DPI scaling so that the non-client area automatically // responds to changes in DPI. All other messages are handled by // MessageHandler. - static LRESULT CALLBACK WndProc(HWND const window, - UINT const message, + static LRESULT CALLBACK WndProc(HWND const window, UINT const message, WPARAM const wparam, LPARAM const lparam) noexcept; // Retrieves a class instance pointer for |window| - static Win32Window* GetThisFromHandle(HWND const window) noexcept; + static Win32Window *GetThisFromHandle(HWND const window) noexcept; // Update the window frame's theme to match the system theme. static void UpdateTheme(HWND const window); @@ -99,4 +97,4 @@ class Win32Window { HWND child_content_ = nullptr; }; -#endif // RUNNER_WIN32_WINDOW_H_ +#endif // RUNNER_WIN32_WINDOW_H_ diff --git a/packages/secure_store/ios/Classes/SecureStoreApi.swift b/packages/secure_store/ios/Classes/SecureStoreApi.swift index 82c379ff..9640b088 100644 --- a/packages/secure_store/ios/Classes/SecureStoreApi.swift +++ b/packages/secure_store/ios/Classes/SecureStoreApi.swift @@ -1,5 +1,5 @@ // -// SecureStore.swift +// SecureStoreApi.swift // secure_store // // Created by Dimitri Dessus on 15/02/2023. @@ -8,25 +8,27 @@ import Flutter import UIKit -class SecureStoreApi : NSObject, SecureStoreBridge { +class SecureStoreApi: NSObject, SecureStoreBridge { func removeSecret(key: String, completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() - + do { // Remove key from secure enclave try secureEnclaveManager.delete(key: key) - + // Remove cipher from keychain keychainManager.delete(key: key) - + completion(.success(())) - } catch let error { + } catch { completion(.failure(error)) } } - - func storeSecret(key: String, privateKey: FlutterStandardTypedData,biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) { + + func storeSecret(key: String, privateKey: FlutterStandardTypedData, + biometricOptions _: BiometricOptions?, + completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() @@ -34,30 +36,31 @@ class SecureStoreApi : NSObject, SecureStoreBridge { let cipher = try secureEnclaveManager.encrypt(key: key, message: privateKey.data) keychainManager.save(key: key, cipher: cipher) completion(.success(())) - } catch let error { + } catch { completion(.failure(error)) } } - - func getSecret(key: String, biometricOptions: BiometricOptions?,completion: @escaping (Result) -> Void) { + + func getSecret(key: String, biometricOptions _: BiometricOptions?, + completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() - + guard let data = keychainManager.read(key: key) else { return } - + do { let result = try secureEnclaveManager.decrypt(key: key, cipherData: data) - if let result = result { + if let result { completion(.success(FlutterStandardTypedData(bytes: result))) } - } catch let error { + } catch { completion(.failure(error)) } } - + func isBiometryAvailable() throws -> Bool { - return AuthenticationUtil.isBiometryAvailable() + AuthenticationUtil.isBiometryAvailable() } } diff --git a/packages/secure_store/ios/Classes/SecureStoreBridge.swift b/packages/secure_store/ios/Classes/SecureStoreBridge.swift index a346757b..10133b89 100644 --- a/packages/secure_store/ios/Classes/SecureStoreBridge.swift +++ b/packages/secure_store/ios/Classes/SecureStoreBridge.swift @@ -3,15 +3,15 @@ import Foundation #if os(iOS) -import Flutter + import Flutter #elseif os(macOS) -import FlutterMacOS + import FlutterMacOS #else -#error("Unsupported platform.") + #error("Unsupported platform.") #endif private func wrapResult(_ result: Any?) -> [Any?] { - return [result] + [result] } private func wrapError(_ error: Any) -> [Any?] { @@ -19,13 +19,13 @@ private func wrapError(_ error: Any) -> [Any?] { return [ flutterError.code, flutterError.message, - flutterError.details + flutterError.details, ] } return [ "\(error)", "\(type(of: error))", - "Stacktrace: \(Thread.callStackSymbols)" + "Stacktrace: \(Thread.callStackSymbols)", ] } @@ -37,8 +37,8 @@ private func nilOrValue(_ value: Any?) -> T? { /// Generated class from Pigeon that represents data sent in messages. struct AndroidPromptInfos { var title: String - var subtitle: String? = nil - var description: String? = nil + var subtitle: String? + var description: String? var cancelLabel: String var confirmationRequired: Bool @@ -57,8 +57,9 @@ struct AndroidPromptInfos { confirmationRequired: confirmationRequired ) } + func toList() -> [Any?] { - return [ + [ title, subtitle, description, @@ -73,22 +74,24 @@ struct AndroidPromptInfos { /// Generated class from Pigeon that represents data sent in messages. struct AndroidOptions { /// Details of the prompt to show to the user. - var promptInfo: AndroidPromptInfos? = nil + var promptInfo: AndroidPromptInfos? /// The duration in seconds for which the authentication is valid. If the /// user sets it to -1 (default), user must authenticate each time they want /// to get or set a secret. var authenticationValidityDurationSeconds: Int64 /// Whether to use the StrongBox hardware-backed keystore. - /// This feature seems to cause [crashes](https://github.com/authpass/biometric_storage/issues/76), + /// This feature seems to cause + /// [crashes](https://github.com/authpass/biometric_storage/issues/76), /// enable with caution. var enableStrongBox: Bool static func fromList(_ list: [Any?]) -> AndroidOptions? { - var promptInfo: AndroidPromptInfos? = nil + var promptInfo: AndroidPromptInfos? if let promptInfoList: [Any?] = nilOrValue(list[0]) { promptInfo = AndroidPromptInfos.fromList(promptInfoList) } - let authenticationValidityDurationSeconds = list[1] is Int64 ? list[1] as! Int64 : Int64(list[1] as! Int32) + let authenticationValidityDurationSeconds = list[1] is Int64 ? list[1] as! Int64 : + Int64(list[1] as! Int32) let enableStrongBox = list[2] as! Bool return AndroidOptions( @@ -97,8 +100,9 @@ struct AndroidOptions { enableStrongBox: enableStrongBox ) } + func toList() -> [Any?] { - return [ + [ promptInfo?.toList(), authenticationValidityDurationSeconds, enableStrongBox, @@ -111,10 +115,10 @@ struct AndroidOptions { /// Generated class from Pigeon that represents data sent in messages. struct BiometricOptions { /// Android-specific options. - var androidOptions: AndroidOptions? = nil + var androidOptions: AndroidOptions? static func fromList(_ list: [Any?]) -> BiometricOptions? { - var androidOptions: AndroidOptions? = nil + var androidOptions: AndroidOptions? if let androidOptionsList: [Any?] = nilOrValue(list[0]) { androidOptions = AndroidOptions.fromList(androidOptionsList) } @@ -123,8 +127,9 @@ struct BiometricOptions { androidOptions: androidOptions ) } + func toList() -> [Any?] { - return [ + [ androidOptions?.toList(), ] } @@ -133,14 +138,14 @@ struct BiometricOptions { private class SecureStoreBridgeCodecReader: FlutterStandardReader { override func readValue(ofType type: UInt8) -> Any? { switch type { - case 128: - return AndroidOptions.fromList(self.readValue() as! [Any?]) - case 129: - return AndroidPromptInfos.fromList(self.readValue() as! [Any?]) - case 130: - return BiometricOptions.fromList(self.readValue() as! [Any?]) - default: - return super.readValue(ofType: type) + case 128: + return AndroidOptions.fromList(readValue() as! [Any?]) + case 129: + return AndroidPromptInfos.fromList(readValue() as! [Any?]) + case 130: + return BiometricOptions.fromList(readValue() as! [Any?]) + default: + return super.readValue(ofType: type) } } } @@ -164,11 +169,11 @@ private class SecureStoreBridgeCodecWriter: FlutterStandardWriter { private class SecureStoreBridgeCodecReaderWriter: FlutterStandardReaderWriter { override func reader(with data: Data) -> FlutterStandardReader { - return SecureStoreBridgeCodecReader(data: data) + SecureStoreBridgeCodecReader(data: data) } override func writer(with data: NSMutableData) -> FlutterStandardWriter { - return SecureStoreBridgeCodecWriter(data: data) + SecureStoreBridgeCodecWriter(data: data) } } @@ -178,9 +183,12 @@ class SecureStoreBridgeCodec: FlutterStandardMessageCodec { /// Generated protocol from Pigeon that represents a handler of messages from Flutter. protocol SecureStoreBridge { - func storeSecret(key: String, privateKey: FlutterStandardTypedData, biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) + func storeSecret(key: String, privateKey: FlutterStandardTypedData, + biometricOptions: BiometricOptions?, + completion: @escaping (Result) -> Void) func removeSecret(key: String, completion: @escaping (Result) -> Void) - func getSecret(key: String, biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) + func getSecret(key: String, biometricOptions: BiometricOptions?, + completion: @escaping (Result) -> Void) func isBiometryAvailable() throws -> Bool } @@ -190,62 +198,82 @@ class SecureStoreBridgeSetup { static var codec: FlutterStandardMessageCodec { SecureStoreBridgeCodec.shared } /// Sets up an instance of `SecureStoreBridge` to handle messages through the `binaryMessenger`. static func setUp(binaryMessenger: FlutterBinaryMessenger, api: SecureStoreBridge?) { - let storeSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let storeSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { storeSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String let privateKeyArg = args[1] as! FlutterStandardTypedData let biometricOptionsArg: BiometricOptions? = nilOrValue(args[2]) - api.storeSecret(key: keyArg, privateKey: privateKeyArg, biometricOptions: biometricOptionsArg) { result in + api.storeSecret( + key: keyArg, + privateKey: privateKeyArg, + biometricOptions: biometricOptionsArg + ) { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case let .failure(error): + reply(wrapError(error)) } } } } else { storeSecretChannel.setMessageHandler(nil) } - let removeSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let removeSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { removeSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String api.removeSecret(key: keyArg) { result in switch result { - case .success: - reply(wrapResult(nil)) - case .failure(let error): - reply(wrapError(error)) + case .success: + reply(wrapResult(nil)) + case let .failure(error): + reply(wrapError(error)) } } } } else { removeSecretChannel.setMessageHandler(nil) } - let getSecretChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let getSecretChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { getSecretChannel.setMessageHandler { message, reply in let args = message as! [Any?] let keyArg = args[0] as! String let biometricOptionsArg: BiometricOptions? = nilOrValue(args[1]) api.getSecret(key: keyArg, biometricOptions: biometricOptionsArg) { result in switch result { - case .success(let res): - reply(wrapResult(res)) - case .failure(let error): - reply(wrapError(error)) + case let .success(res): + reply(wrapResult(res)) + case let .failure(error): + reply(wrapError(error)) } } } } else { getSecretChannel.setMessageHandler(nil) } - let isBiometryAvailableChannel = FlutterBasicMessageChannel(name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable", binaryMessenger: binaryMessenger, codec: codec) - if let api = api { + let isBiometryAvailableChannel = FlutterBasicMessageChannel( + name: "dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable", + binaryMessenger: binaryMessenger, + codec: codec + ) + if let api { isBiometryAvailableChannel.setMessageHandler { _, reply in do { let result = try api.isBiometryAvailable() diff --git a/packages/secure_store/ios/Classes/Utils/PlatformUtil.swift b/packages/secure_store/ios/Classes/Utils/PlatformUtil.swift index c68a3bb9..c9ab75a7 100644 --- a/packages/secure_store/ios/Classes/Utils/PlatformUtil.swift +++ b/packages/secure_store/ios/Classes/Utils/PlatformUtil.swift @@ -7,12 +7,12 @@ import Foundation -struct Platform { +enum Platform { static let isSimulator: Bool = { var isSim = false -#if arch(i386) || arch(x86_64) - isSim = true -#endif + #if arch(i386) || arch(x86_64) + isSim = true + #endif return isSim }() } diff --git a/packages/secure_store/lib/secure_store.dart b/packages/secure_store/lib/secure_store.dart index f264a62e..0e02880f 100644 --- a/packages/secure_store/lib/secure_store.dart +++ b/packages/secure_store/lib/secure_store.dart @@ -1,8 +1,8 @@ -import 'package:secure_store/secure_store.dart'; +import 'secure_store.dart'; export 'src/biometrics_store.dart'; -export 'src/password_store.dart'; export 'src/crypto.dart'; +export 'src/password_store.dart'; enum SecureStoreType { biometrics, diff --git a/packages/secure_store/lib/src/__generated__/secure_store_bridge.dart b/packages/secure_store/lib/src/__generated__/secure_store_bridge.dart index cf466439..5bc1f18a 100644 --- a/packages/secure_store/lib/src/__generated__/secure_store_bridge.dart +++ b/packages/secure_store/lib/src/__generated__/secure_store_bridge.dart @@ -37,7 +37,7 @@ class AndroidPromptInfos { ]; } - static AndroidPromptInfos decode(Object result) { + factory AndroidPromptInfos.decode(Object result) { result as List; return AndroidPromptInfos( title: result[0]! as String, @@ -78,7 +78,7 @@ class AndroidOptions { ]; } - static AndroidOptions decode(Object result) { + factory AndroidOptions.decode(Object result) { result as List; return AndroidOptions( promptInfo: result[0] != null @@ -105,7 +105,7 @@ class BiometricOptions { ]; } - static BiometricOptions decode(Object result) { + factory BiometricOptions.decode(Object result) { result as List; return BiometricOptions( androidOptions: result[0] != null @@ -158,11 +158,16 @@ class SecureStoreBridge { static const MessageCodec codec = _SecureStoreBridgeCodec(); - Future storeSecret(String arg_key, Uint8List arg_privateKey, - BiometricOptions? arg_biometricOptions) async { + Future storeSecret( + String arg_key, + Uint8List arg_privateKey, + BiometricOptions? arg_biometricOptions, + ) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.secure_store.SecureStoreBridge.storeSecret', + codec, + binaryMessenger: _binaryMessenger, + ); final List? replyList = await channel .send([arg_key, arg_privateKey, arg_biometricOptions]) as List?; @@ -184,8 +189,10 @@ class SecureStoreBridge { Future removeSecret(String arg_key) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.secure_store.SecureStoreBridge.removeSecret', + codec, + binaryMessenger: _binaryMessenger, + ); final List? replyList = await channel.send([arg_key]) as List?; if (replyList == null) { @@ -205,10 +212,14 @@ class SecureStoreBridge { } Future getSecret( - String arg_key, BiometricOptions? arg_biometricOptions) async { + String arg_key, + BiometricOptions? arg_biometricOptions, + ) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret', codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.secure_store.SecureStoreBridge.getSecret', + codec, + binaryMessenger: _binaryMessenger, + ); final List? replyList = await channel .send([arg_key, arg_biometricOptions]) as List?; if (replyList == null) { @@ -229,9 +240,10 @@ class SecureStoreBridge { Future isBiometryAvailable() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable', - codec, - binaryMessenger: _binaryMessenger); + 'dev.flutter.pigeon.secure_store.SecureStoreBridge.isBiometryAvailable', + codec, + binaryMessenger: _binaryMessenger, + ); final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( diff --git a/packages/secure_store/lib/src/crypto.dart b/packages/secure_store/lib/src/crypto.dart index 3eba5ec7..395ddc23 100644 --- a/packages/secure_store/lib/src/crypto.dart +++ b/packages/secure_store/lib/src/crypto.dart @@ -22,7 +22,7 @@ Uint8List encrypt({ }) { assert( iv == null || iv.length == ivLength, - "IV must be $ivLength bytes long", + 'IV must be $ivLength bytes long', ); final usedIV = iv ?? getIV(); @@ -34,8 +34,8 @@ Uint8List encrypt({ ); return Uint8List.fromList([ // Concatenate IV and cipher text to be able to decrypt it later - ...usedIV.toList(), - ...encryptedSecret.toList(), + ...usedIV, + ...encryptedSecret, ]); } @@ -70,7 +70,7 @@ Uint8List _cipherAes({ // AES works on blocks of bytes. The padding is used to always have the // same number of bytes in each block. // See https://www.ibm.com/docs/en/zos/2.4.0?topic=rules-pkcs-padding-method - PaddedBlockCipher cipher = PaddedBlockCipherImpl( + final PaddedBlockCipher cipher = PaddedBlockCipherImpl( // PKCS7Padding is the most common padding scheme. PKCS7Padding(), GCMBlockCipher(AESEngine()), diff --git a/packages/secure_store/lib/src/password_store.dart b/packages/secure_store/lib/src/password_store.dart index eb6a8287..ac74dd0b 100644 --- a/packages/secure_store/lib/src/password_store.dart +++ b/packages/secure_store/lib/src/password_store.dart @@ -1,9 +1,11 @@ +// ignore_for_file: inference_failure_on_function_invocation + import 'dart:convert'; import 'package:flutter/foundation.dart'; import 'package:hive_flutter/hive_flutter.dart'; -import 'package:secure_store/secure_store.dart'; -import 'package:secure_store/src/utils.dart'; +import '../secure_store.dart'; +import 'utils.dart'; /// A [SecureStore] that stores the private key encrypted with a password. /// @@ -14,7 +16,7 @@ class PasswordStore implements SecureStore { final Future Function()? getPassword; final Uint8List? iv; - static const boxName = "secure_store"; + static const boxName = 'secure_store'; PasswordStore({this.password, this.getPassword, this.iv}) { if (password == null && getPassword == null) { @@ -22,7 +24,7 @@ class PasswordStore implements SecureStore { } } - static init() { + static void init() { Hive.initFlutter(); } @@ -59,7 +61,7 @@ class PasswordStore implements SecureStore { Future getSecret({ required String key, }) async { - var box = await Hive.openBox(boxName); + final box = await Hive.openBox(boxName); final cipherText = box.get(key); if (cipherText == null) { @@ -70,10 +72,12 @@ class PasswordStore implements SecureStore { throw Exception('Password must be provided'); } try { - return bytesToString(decrypt( - password: stringToBytes(password!), - encryptedSecret: base64Decode(cipherText), - )); + return bytesToString( + decrypt( + password: stringToBytes(password!), + encryptedSecret: base64Decode(cipherText as String), + ), + ); } catch (e) { if (kDebugMode) { print(e); diff --git a/packages/secure_store/macos/Classes/StarknetApi.swift b/packages/secure_store/macos/Classes/StarknetApi.swift index 83406d8a..ba2502c2 100644 --- a/packages/secure_store/macos/Classes/StarknetApi.swift +++ b/packages/secure_store/macos/Classes/StarknetApi.swift @@ -1,14 +1,14 @@ // -// SecureStore.swift +// StarknetApi.swift // secure_store // // Created by Dimitri Dessus on 15/02/2023. // -import FlutterMacOS import Cocoa +import FlutterMacOS -class SecureStoreApi : NSObject, SecureStoreBridge { +class SecureStoreApi: NSObject, SecureStoreBridge { func removeSecret(key: String, completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() @@ -21,12 +21,14 @@ class SecureStoreApi : NSObject, SecureStoreBridge { keychainManager.delete(key: key) completion(.success(())) - } catch let error { + } catch { completion(.failure(error)) } } - func storeSecret(key: String, privateKey: FlutterStandardTypedData,biometricOptions: BiometricOptions?, completion: @escaping (Result) -> Void) { + func storeSecret(key: String, privateKey: FlutterStandardTypedData, + biometricOptions _: BiometricOptions?, + completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() @@ -34,30 +36,31 @@ class SecureStoreApi : NSObject, SecureStoreBridge { let cipher = try secureEnclaveManager.encrypt(key: key, message: privateKey.data) keychainManager.save(key: key, cipher: cipher) completion(.success(())) - } catch let error { + } catch { completion(.failure(error)) } } - func getSecret(key: String, biometricOptions: BiometricOptions?,completion: @escaping (Result) -> Void) { + func getSecret(key: String, biometricOptions _: BiometricOptions?, + completion: @escaping (Result) -> Void) { let secureEnclaveManager = SecureEnclaveManager() let keychainManager = KeychainManager() - + guard let data = keychainManager.read(key: key) else { return } - + do { let result = try secureEnclaveManager.decrypt(key: key, cipherData: data) - if let result = result { + if let result { completion(.success(FlutterStandardTypedData(bytes: result))) } - } catch let error { + } catch { completion(.failure(error)) } } - + func isBiometryAvailable() throws -> Bool { - return AuthenticationUtil.isBiometryAvailable() + AuthenticationUtil.isBiometryAvailable() } } diff --git a/packages/secure_store/pubspec.yaml b/packages/secure_store/pubspec.yaml index 3c5389cb..e780fc77 100644 --- a/packages/secure_store/pubspec.yaml +++ b/packages/secure_store/pubspec.yaml @@ -11,13 +11,13 @@ dependencies: flutter: sdk: flutter hive_flutter: ^1.1.0 - pointycastle: ^3.7.3 + pointycastle: ^3.9.1 dev_dependencies: - build_runner: ^2.3.3 + build_runner: ^2.4.13 flutter_test: sdk: flutter - pigeon: ^10.0.1 + pigeon: ^22.4.2 flutter: plugin: diff --git a/packages/secure_store/test/crypto_test.dart b/packages/secure_store/test/crypto_test.dart index 4574cafa..2a7dc7d1 100644 --- a/packages/secure_store/test/crypto_test.dart +++ b/packages/secure_store/test/crypto_test.dart @@ -5,44 +5,44 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:secure_store/secure_store.dart'; import 'package:secure_store/src/utils.dart'; -main() { - group("Encode/Decode", () { +void main() { + group('Encode/Decode', () { // Generated passwords with different length (from 6 to 1024 characters) final passwords = [ - "+L&y9E", - "F8v@A7", - "5ECsNAB", - "7suQP7##", - "@2_9sZL2A", - "59zme@QrLd", - "4EP-yzLCy\$y", - "cCfT75@-x+eh", - "5RGv4cfV9b&Xf", - "c^FV847hEZV^_R", - "W8%KFL5#=xgbA^F", - "=KtZ%K-7zmKz6bYW", - "PB9622n6QMJmuFTT", - "Srbf8Rtt@8Zf\$jxw", - "R6bA2dDSxrX\$vkHUC", - "E3ABheJqyF4wjVnaN7aV", - "9#8WF595#CJFhcrbRs9@X", - "fqRB_pN3V8RmJYsPgfR9!X" - "xYrDwPTFge5LwtnC4VhJHwC", - "ACBDEFGHIJKLMNOPQRSTUVWXYZ", - "Qvv!N\$G^g8\$4&58PfHH5XwEVK", - "7&8=J*WVS?2=A7tVpBaBNSc+shQN2eMa", + '+L&y9E', + 'F8v@A7', + '5ECsNAB', + '7suQP7##', + '@2_9sZL2A', + '59zme@QrLd', + r'4EP-yzLCy$y', + 'cCfT75@-x+eh', + '5RGv4cfV9b&Xf', + 'c^FV847hEZV^_R', + 'W8%KFL5#=xgbA^F', + '=KtZ%K-7zmKz6bYW', + 'PB9622n6QMJmuFTT', + r'Srbf8Rtt@8Zf$jxw', + r'R6bA2dDSxrX$vkHUC', + 'E3ABheJqyF4wjVnaN7aV', + '9#8WF595#CJFhcrbRs9@X', + 'fqRB_pN3V8RmJYsPgfR9!X', + 'xYrDwPTFge5LwtnC4VhJHwC', + 'ACBDEFGHIJKLMNOPQRSTUVWXYZ', + r'Qvv!N$G^g8$4&58PfHH5XwEVK', + '7&8=J*WVS?2=A7tVpBaBNSc+shQN2eMa', // 128 chars - "KPEj3x8^AB9e629dGQ_Bbh7Xy=S8?ruL2E\$B8TYm^QXBR?FM&=U_Mp3BEfAy@38a7PqzP_MrHQD+yqQEy?@Y!@yD3z#27aCqQ&+QvV%G*jy*Su3qHtyz+TRza?KsR3n_", + r'KPEj3x8^AB9e629dGQ_Bbh7Xy=S8?ruL2E$B8TYm^QXBR?FM&=U_Mp3BEfAy@38a7PqzP_MrHQD+yqQEy?@Y!@yD3z#27aCqQ&+QvV%G*jy*Su3qHtyz+TRza?KsR3n_', // 256 chars - "5r3%q+tyRA^cUjJyAu-bvMcBxNKLWA2kge-qAGe#%3=#%C+HQ=sYSKm!kH3PZwREtL3HKUK7QbJBZwDX%Vhp=\$m@^uZP%pDT@BaY*fyJTnp64Rt4H4hBxErWVA25#A-Am2R-!=L*#QK^Rr+p4q#DT279bq^G3MSx\$T-5_3#uVDFmqyWJgF&kaJsrXc\$#vX?hL=8Tj2&s=!-B+3q%e4j7nceM\$WSMXVh2hJXE7@3nr9rmzPZZPbB77TRYWXfAU!sW", + r'5r3%q+tyRA^cUjJyAu-bvMcBxNKLWA2kge-qAGe#%3=#%C+HQ=sYSKm!kH3PZwREtL3HKUK7QbJBZwDX%Vhp=$m@^uZP%pDT@BaY*fyJTnp64Rt4H4hBxErWVA25#A-Am2R-!=L*#QK^Rr+p4q#DT279bq^G3MSx$T-5_3#uVDFmqyWJgF&kaJsrXc$#vX?hL=8Tj2&s=!-B+3q%e4j7nceM$WSMXVh2hJXE7@3nr9rmzPZZPbB77TRYWXfAU!sW', // 512 chars - "b77Dcb#&@9M_=6Mk6mpxkhGebbqhpWSY85X^!LBK\$^_Z2m&pDAQbAHD5EG%jGSH!Hvp9=cT6RKrYLdLaJbyG*GXg3AjQjeRxkTHfzFEje2tB8G@!JHEGR&mg#!BL^PGT+\$@t9Z3Sh+8A\$pBu&\$3JuX@HQSA@M+^h=G=^khY^nS#jWDMVLaH54gHV4zze4kcg%BMeceVn@y@9RBCz@eZ9PSnkS\$VNL_6+y5xv?AQ5BK*t@FJAXp3y33*#ng!ra?8Bas2uZ@fySdPgtY=XRD@8FTzh6=cGNX4DFW^ajq6Puqy@Y7fw7+SPgvSx8ydJS2WUm86=+97PjKHNjbVL&U6G%f6QFw^-yF+d5n69Nd&E9N5kwe-zNcW_vNct^=Ezn#Ed^3d?CxGS-nFv_N_2vkVbwFhu7!\$%yU-7VF!!_=qc*+*stq^-w3u9Q+U@_hvv9p?F^S5EQ*a3JZk-BrQxcg_rNmaTkY62mr@UwL2XtG75V*8P#N^5MtHC9p=aW&7Cux5?", + r'b77Dcb#&@9M_=6Mk6mpxkhGebbqhpWSY85X^!LBK$^_Z2m&pDAQbAHD5EG%jGSH!Hvp9=cT6RKrYLdLaJbyG*GXg3AjQjeRxkTHfzFEje2tB8G@!JHEGR&mg#!BL^PGT+$@t9Z3Sh+8A$pBu&$3JuX@HQSA@M+^h=G=^khY^nS#jWDMVLaH54gHV4zze4kcg%BMeceVn@y@9RBCz@eZ9PSnkS$VNL_6+y5xv?AQ5BK*t@FJAXp3y33*#ng!ra?8Bas2uZ@fySdPgtY=XRD@8FTzh6=cGNX4DFW^ajq6Puqy@Y7fw7+SPgvSx8ydJS2WUm86=+97PjKHNjbVL&U6G%f6QFw^-yF+d5n69Nd&E9N5kwe-zNcW_vNct^=Ezn#Ed^3d?CxGS-nFv_N_2vkVbwFhu7!$%yU-7VF!!_=qc*+*stq^-w3u9Q+U@_hvv9p?F^S5EQ*a3JZk-BrQxcg_rNmaTkY62mr@UwL2XtG75V*8P#N^5MtHC9p=aW&7Cux5?', // 1024 chars - "e6DMDKSM4=DkBf3#cCeBHa\$K&k+es?U^tQtuYD8K5te-6Bn\$cvgaNZn#awdS3e\$p6p74pWH6yPAMMjX?jm57vychvA%nn+C\$3+V3SFE6eTk5Q8246fcKEQ6S!GeC-tEpd2gxBWStzDHBrN+Vp8M4x#9_^kh_&RFVZzRKeJ4JJeF%RAW^uaWc3WHZn8CVQQ@GkGcTJkZ#Pf_WT!=rHnxPTjbj9C&ezcfbP*@_NKJ9_p@+j=aj&n4\$D5B^wnDrXWy2aaNaZWnWhb!x?bX7Ln?eG6cN_SbGW\$FW&4!Q&\$vs2j+wJ=aqnctBHVDqSLpnz8RqMpRfQ7D=U4xfk8-p#F#rS&69BA2\$K_ZZL!6!^b+TBNS\$V#%kKKzvYCVq@mk8Qz7AZZ7wgmGTAPqbsG*dnVcPCKctjgmu=%%@X%UFTCe%-LSw_D9ZAS%ZR-e\$Ye3G#b6gGkv?DWLJm!z-QJtc3wL*j6NsmKJmGg2xhM@Sz6F2TG^^!-L#fk=SwF56\$sA8!tY!guUjEDZqk9\$jfqf2w=sddnJ8#jSh4vZZt!Bh?jhvaFBNPFhvN5N+E+ED_78eg?uRU#KVgFncGF=5vstQvC^%H_W@CPwmUvSsm@=EQ-P5YGMQ!HB@=gB^!pE-@CMz9EMj2eGYhn&cJG8cxk3p=u+-A=35nmaD&s_aH5C8P9dunf-MGmpq**KVHy42h2TC4AYYbp+w^m_v7sQ@4uYqtbuHC^s9^ABe=8\$wxtYFqCTt8J\$s?y\$4+pJYwF32B2-#yEyUuuEs^X\$gJH7+m!3acc?=wfj&fD8YM^Z*gS*33UcrftG^d9=savDzDDffxSk%8uM!3FE7mGxTy*A684vgWbydn+=ZXzR9bzbJ@Wdu!UnJG&k+bQ%FRA+8ahsy?%_Fkf*fCcGZVKX!PsdVYk#u_s9G&7j5^@*77pg2KHeXwc!-duk3P3DuuTg3+XZb25=K5UpEUQ3q@MkhT#?dZ9bvBvsyYLteRVh9283hMVt3tPjD^Qs?_qu8GYT%2ZtWw#f7%ka3", + r'e6DMDKSM4=DkBf3#cCeBHa$K&k+es?U^tQtuYD8K5te-6Bn$cvgaNZn#awdS3e$p6p74pWH6yPAMMjX?jm57vychvA%nn+C$3+V3SFE6eTk5Q8246fcKEQ6S!GeC-tEpd2gxBWStzDHBrN+Vp8M4x#9_^kh_&RFVZzRKeJ4JJeF%RAW^uaWc3WHZn8CVQQ@GkGcTJkZ#Pf_WT!=rHnxPTjbj9C&ezcfbP*@_NKJ9_p@+j=aj&n4$D5B^wnDrXWy2aaNaZWnWhb!x?bX7Ln?eG6cN_SbGW$FW&4!Q&$vs2j+wJ=aqnctBHVDqSLpnz8RqMpRfQ7D=U4xfk8-p#F#rS&69BA2$K_ZZL!6!^b+TBNS$V#%kKKzvYCVq@mk8Qz7AZZ7wgmGTAPqbsG*dnVcPCKctjgmu=%%@X%UFTCe%-LSw_D9ZAS%ZR-e$Ye3G#b6gGkv?DWLJm!z-QJtc3wL*j6NsmKJmGg2xhM@Sz6F2TG^^!-L#fk=SwF56$sA8!tY!guUjEDZqk9$jfqf2w=sddnJ8#jSh4vZZt!Bh?jhvaFBNPFhvN5N+E+ED_78eg?uRU#KVgFncGF=5vstQvC^%H_W@CPwmUvSsm@=EQ-P5YGMQ!HB@=gB^!pE-@CMz9EMj2eGYhn&cJG8cxk3p=u+-A=35nmaD&s_aH5C8P9dunf-MGmpq**KVHy42h2TC4AYYbp+w^m_v7sQ@4uYqtbuHC^s9^ABe=8$wxtYFqCTt8J$s?y$4+pJYwF32B2-#yEyUuuEs^X$gJH7+m!3acc?=wfj&fD8YM^Z*gS*33UcrftG^d9=savDzDDffxSk%8uM!3FE7mGxTy*A684vgWbydn+=ZXzR9bzbJ@Wdu!UnJG&k+bQ%FRA+8ahsy?%_Fkf*fCcGZVKX!PsdVYk#u_s9G&7j5^@*77pg2KHeXwc!-duk3P3DuuTg3+XZb25=K5UpEUQ3q@MkhT#?dZ9bvBvsyYLteRVh9283hMVt3tPjD^Qs?_qu8GYT%2ZtWw#f7%ka3', ]; - for (var password in passwords) { - test("Using ${password.length} chars password: $password", () { - const plainText = "azerty"; + for (final password in passwords) { + test('Using ${password.length} chars password: $password', () { + const plainText = 'azerty'; final encryptedSecret = encrypt( password: stringToBytes(password), secret: stringToBytes(plainText), @@ -56,11 +56,11 @@ main() { } }); - test("Encode with AES 256 GCM", () { - String password = "aStringOf16Bytes"; - String plainText = "azerty"; + test('Encode with AES 256 GCM', () { + const password = 'aStringOf16Bytes'; + const plainText = 'azerty'; - Uint8List encryptedSecret = encrypt( + final encryptedSecret = encrypt( password: stringToBytes(password), // Always the same IV for testing iv: Uint8List.fromList([for (int i = 0; i < ivLength; i++) i]), @@ -68,27 +68,27 @@ main() { ); expect( base64Encode(encryptedSecret), - equals("AAECAwQFBgcICQoLDA0OD7t5Gg1C4hrl8RAxdzEfIu8="), + equals('AAECAwQFBgcICQoLDA0OD7t5Gg1C4hrl8RAxdzEfIu8='), ); }); - test("Decode with AES 256 GCM", () { - String password = "aStringOf16Bytes"; - String encryptedSecret = "AAECAwQFBgcICQoLDA0OD7t5Gg1C4hrl8RAxdzEfIu8="; + test('Decode with AES 256 GCM', () { + const password = 'aStringOf16Bytes'; + const encryptedSecret = 'AAECAwQFBgcICQoLDA0OD7t5Gg1C4hrl8RAxdzEfIu8='; - Uint8List decryptedSecret = decrypt( + final decryptedSecret = decrypt( password: stringToBytes(password), encryptedSecret: base64Decode(encryptedSecret), ); - expect(utf8.decode(decryptedSecret), equals("azerty")); + expect(utf8.decode(decryptedSecret), equals('azerty')); }); // TODO This group test is not bullet proof, it might fail on occasions - group("Nonce generation", () { - for (int i = 0; i < 100; i++) { - test("Get different nonce - iteration $i", () { - Uint8List nonce1 = getIV(); - Uint8List nonce2 = getIV(); + group('Nonce generation', () { + for (var i = 0; i < 100; i++) { + test('Get different nonce - iteration $i', () { + final nonce1 = getIV(); + final nonce2 = getIV(); expect(nonce1, isNot(equals(nonce2))); }); } diff --git a/packages/starklints/.gitignore b/packages/starklints/.gitignore new file mode 100644 index 00000000..3a857904 --- /dev/null +++ b/packages/starklints/.gitignore @@ -0,0 +1,3 @@ +# https://dart.dev/guides/libraries/private-files +# Created by `dart pub` +.dart_tool/ diff --git a/packages/starklints/CHANGELOG.md b/packages/starklints/CHANGELOG.md new file mode 100644 index 00000000..effe43c8 --- /dev/null +++ b/packages/starklints/CHANGELOG.md @@ -0,0 +1,3 @@ +## 1.0.0 + +- Initial version. diff --git a/packages/starklints/README.md b/packages/starklints/README.md new file mode 100644 index 00000000..62824ef3 --- /dev/null +++ b/packages/starklints/README.md @@ -0,0 +1,19 @@ +# Starklints + +Lint rules for starknet.dart family of packages + +## Installation + +Install starklints dependency + +```bash +flutter pub add starklints --dev +``` + +## Usage + +Add the following to your `analysis_options.yaml` file: + +```yaml +include: package:starklints/lints.yaml +``` diff --git a/packages/starklints/lib/lints.yaml b/packages/starklints/lib/lints.yaml new file mode 100644 index 00000000..614b3451 --- /dev/null +++ b/packages/starklints/lib/lints.yaml @@ -0,0 +1,183 @@ +include: package:lints/recommended.yaml +analyzer: + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + # errors: + # inference_failure_on_instance_creation: ignore + # inference_failure_on_untyped_parameter: ignore + +linter: + rules: + public_member_api_docs: false + + # False positive for custom enum-like classes (such as Flutter's "Colors") + avoid_classes_with_only_static_members: false + + # False positive when the future is returned by the function + discarded_futures: false + + # Low value and lacks a quick fix + combinators_ordering: false + + # Low value and high cost to change on all files + eol_at_end_of_file: false + + # Conflicts with unused variables + no_leading_underscores_for_local_identifiers: false + + # false positive + one_member_abstracts: false + + # too verbose + prefer_final_parameters: false + + # Too verbose with little value, and this is taken care of by the Flutter devtool anyway. + diagnostic_describe_all_properties: false + + # Personal preference. I prefer "if (bool) return;" over having it in multiple lines + always_put_control_body_on_new_line: false + + # Personal preference. I don't find it more readable + cascade_invocations: false + + # Conflicts with `prefer_single_quotes` + # Single quotes are easier to type and don't compromise on readability. + prefer_double_quotes: false + + # Conflicts with `omit_local_variable_types` and other rules. + # As per Dart guidelines, we want to avoid unnecessary types to make the code + # more readable. + # See https://dart.dev/guides/language/effective-dart/design#avoid-type-annotating-initialized-local-variables + always_specify_types: false + + # Incompatible with `prefer_final_locals` + # Having immutable local variables makes larger functions more predictable + # so we will use `prefer_final_locals` instead. + unnecessary_final: false + + # Not quite suitable for Flutter, which may have a `build` method with a single + # return, but that return is still complex enough that a "body" is worth it. + prefer_expression_function_bodies: false + + # Conflicts with the convention used by flutter, which puts `Key key` + # and `@required Widget child` last. + always_put_required_named_parameters_first: false + + # This project doesn't use Flutter-style todos + flutter_style_todos: false + + # There are situations where we voluntarily want to catch everything, + # especially as a library. + avoid_catches_without_on_clauses: false + + # Boring as it sometimes force a line of 81 characters to be split in two. + # As long as we try to respect that 80 characters limit, going slightly + # above is fine. + lines_longer_than_80_chars: false + + # Conflicts with disabling `implicit-dynamic` + avoid_annotating_with_dynamic: false + + # conflicts with `prefer_relative_imports` + always_use_package_imports: false + + # Disabled for now until we have NNBD as it otherwise conflicts with `missing_return` + no_default_cases: false + + # Useful for ffi + avoid_private_typedef_functions: false + + avoid_dynamic_calls: true + avoid_print: true + avoid_slow_async_io: true + avoid_type_to_string: true + cancel_subscriptions: true + close_sinks: true + comment_references: true + deprecated_member_use_from_same_package: true + implicit_reopen: true + invalid_case_patterns: true + collection_methods_unrelated_type: true + literal_only_boolean_expressions: true + no_adjacent_strings_in_list: true + no_self_assignments: true + prefer_relative_imports: true + prefer_void_to_null: true + test_types_in_equals: true + throw_in_finally: true + unnecessary_statements: true + unsafe_html: true + sort_pub_dependencies: true + always_declare_return_types: true + avoid_bool_literals_in_conditional_expressions: true + avoid_catching_errors: true + avoid_double_and_int_checks: true + avoid_equals_and_hash_code_on_mutable_classes: true + avoid_escaping_inner_quotes: true + avoid_field_initializers_in_const_classes: true + avoid_final_parameters: true + avoid_implementing_value_types: true + avoid_js_rounded_ints: true + avoid_multiple_declarations_per_line: true + avoid_positional_boolean_parameters: true + avoid_redundant_argument_values: true + avoid_returning_this: true + avoid_setters_without_getters: true + avoid_types_on_closure_parameters: true + avoid_unused_constructor_parameters: true + avoid_void_async: true + cast_nullable_to_non_nullable: true + conditional_uri_does_not_exist: true + deprecated_consistency: true + directives_ordering: true + join_return_with_assignment: true + leading_newlines_in_multiline_strings: true + library_annotations: true + matching_super_parameters: true + missing_whitespace_between_adjacent_strings: true + no_literal_bool_comparisons: true + no_runtimeType_toString: true + noop_primitive_operations: true + omit_local_variable_types: true + only_throw_errors: true + parameter_assignments: true + prefer_asserts_in_initializer_lists: true + prefer_asserts_with_message: true + prefer_const_constructors: true + prefer_const_constructors_in_immutables: true + prefer_const_declarations: true + prefer_const_literals_to_create_immutables: true + prefer_constructors_over_static_methods: true + prefer_final_in_for_each: true + prefer_final_locals: true + prefer_foreach: true + prefer_if_elements_to_conditional_expressions: true + prefer_int_literals: true + prefer_mixin: true + prefer_null_aware_method_calls: true + prefer_single_quotes: true + require_trailing_commas: true + tighten_type_of_initializing_formals: true + type_annotate_public_apis: true + unawaited_futures: true + unnecessary_await_in_return: true + unnecessary_breaks: true + unnecessary_lambdas: true + unnecessary_library_directive: true + unnecessary_null_aware_operator_on_extension_on_nullable: true + unnecessary_null_checks: true + unnecessary_parenthesis: true + unnecessary_raw_strings: true + unreachable_from_main: true + use_enums: true + use_if_null_to_convert_nulls_to_bools: true + use_is_even_rather_than_modulo: true + use_late_for_private_fields_and_variables: true + use_named_constants: true + use_raw_strings: true + use_setters_to_change_properties: true + use_string_buffers: true + use_test_throws_matchers: true + use_to_and_as_if_applicable: true diff --git a/packages/starklints/pubspec.yaml b/packages/starklints/pubspec.yaml new file mode 100644 index 00000000..de4c5a4e --- /dev/null +++ b/packages/starklints/pubspec.yaml @@ -0,0 +1,13 @@ +name: starklints +description: Lint rules for starknet.dart family of packages +version: 0.1.0 +repository: https://github.com/focustree/starknet.dart + +environment: + sdk: ^3.5.3 + +dependencies: + lints: ^5.0.0 + +dev_dependencies: + test: ^1.25.8 diff --git a/packages/starknet/analysis_options.yaml b/packages/starknet/analysis_options.yaml deleted file mode 100644 index d5305df3..00000000 --- a/packages/starknet/analysis_options.yaml +++ /dev/null @@ -1,7 +0,0 @@ -include: package:lints/recommended.yaml - -analyzer: - errors: - invalid_annotation_target: ignore - non_constant_identifier_names: ignore - non_nullable_equals_parameter: ignore diff --git a/packages/starknet/example/examples/transfer_erc20.dart b/packages/starknet/example/examples/transfer_erc20.dart index 659041f9..d36c897e 100644 --- a/packages/starknet/example/examples/transfer_erc20.dart +++ b/packages/starknet/example/examples/transfer_erc20.dart @@ -1,16 +1,21 @@ +import 'dart:io'; + import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; final privateKey = Felt.fromInt(1234); final accountAddress = Felt.fromHexString( - "0x32d5c7a7953996056caf92ff4dd83f01ad72a3c418c05f15eb2f472d1e9c9f2"); + '0x32d5c7a7953996056caf92ff4dd83f01ad72a3c418c05f15eb2f472d1e9c9f2', +); final erc20Address = Felt.fromHexString( - "0x4e76f8708774c8162fb4da7abefb3cae94cc51cf3f9b40e0d44f24aabf8a521"); + '0x4e76f8708774c8162fb4da7abefb3cae94cc51cf3f9b40e0d44f24aabf8a521', +); final myWalletAddress = Felt.fromHexString( - "0x0367c0c4603a29Bc5aCA8E07C6A2776D7C0d325945aBB4f772f448b345Ca4Cf7"); + '0x0367c0c4603a29Bc5aCA8E07C6A2776D7C0d325945aBB4f772f448b345Ca4Cf7', +); void main() async { final provider = JsonRpcProvider(nodeUri: v010PathfinderGoerliTestnetUri); @@ -18,17 +23,23 @@ void main() async { final signer = Signer(privateKey: privateKey); final account = Account( - provider: provider, - signer: signer, - accountAddress: accountAddress, - chainId: StarknetChainId.testNet); - - final response = await account.execute(functionCalls: [ - FunctionCall( + provider: provider, + signer: signer, + accountAddress: accountAddress, + chainId: StarknetChainId.testNet, + ); + + final response = await account.execute( + functionCalls: [ + FunctionCall( contractAddress: erc20Address, - entryPointSelector: getSelectorByName("transfer"), - calldata: [myWalletAddress, Felt.fromInt(1), Felt.fromInt(0)]) - ], maxFee: Felt.fromInt(16000000000001), nonce: Felt.fromInt(3)); - - print(response); + entryPointSelector: getSelectorByName('transfer'), + calldata: [myWalletAddress, Felt.fromInt(1), Felt.fromInt(0)], + ), + ], + max_fee: Felt.fromInt(16000000000001), + nonce: Felt.fromInt(3), + ); + + stdout.writeln(response); } diff --git a/packages/starknet/lib/src/account.dart b/packages/starknet/lib/src/account.dart index a2c8a077..e71ba718 100644 --- a/packages/starknet/lib/src/account.dart +++ b/packages/starknet/lib/src/account.dart @@ -1,13 +1,16 @@ -import 'dart:typed_data'; +// ignore_for_file: non_constant_identifier_names + +import 'dart:io'; import 'package:bip32/bip32.dart' as bip32; import 'package:bip39/bip39.dart' as bip39; -import 'package:starknet/src/presets/udc.g.dart'; -import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; +import '../starknet.dart'; +import 'presets/udc.g.dart'; + enum AccountSupportedTxVersion { - @Deprecated("Transaction version 0 will be removed with Starknet alpha v0.11") + @Deprecated('Transaction version 0 will be removed with Starknet alpha v0.11') v0, v1, } @@ -34,19 +37,20 @@ class Account { blockId: blockId, contractAddress: accountAddress, ); - return (response.when( + return response.when( error: (error) { throw Exception( - "Error retrieving nonce (${error.code}): ${error.message}"); + 'Error retrieving nonce (${error.code}): ${error.message}', + ); }, result: (result) => result, - )); + ); } /// Get Estimate max fee for Invoke Tx - Future getEstimateMaxFeeForInvokeTx({ + Future getEstimatemax_feeForInvokeTx({ BlockId blockId = BlockId.latest, - String version = "0x1", + String version = '0x1', required List functionCalls, bool useLegacyCalldata = false, required Felt nonce, @@ -57,50 +61,54 @@ class Account { contractAddress: accountAddress, version: supportedTxVersion == AccountSupportedTxVersion.v1 ? 1 : 0, chainId: chainId, - entryPointSelectorName: "__execute__", nonce: nonce, useLegacyCalldata: useLegacyCalldata, ); BroadcastedTxn broadcastedTxn; - if (version == "0x1") { + if (version == '0x1') { final calldata = functionCallsToCalldata( functionCalls: functionCalls, useLegacyCalldata: useLegacyCalldata, ); broadcastedTxn = BroadcastedInvokeTxnV1( - type: "INVOKE", - maxFee: defaultMaxFee, - version: version, - signature: signature, - nonce: nonce, - senderAddress: accountAddress, - calldata: calldata); + type: 'INVOKE', + maxFee: defaultMaxFee, + version: version, + signature: signature, + nonce: nonce, + senderAddress: accountAddress, + calldata: calldata, + ); } else { final calldata = functionCallsToCalldataLegacy(functionCalls: functionCalls) + [nonce]; broadcastedTxn = BroadcastedInvokeTxnV0( - type: "INVOKE", - maxFee: defaultMaxFee, - version: version, - signature: signature, - nonce: nonce, - contractAddress: accountAddress, - entryPointSelector: getSelectorByName('__execute__'), - calldata: calldata); + type: 'INVOKE', + maxFee: defaultMaxFee, + version: version, + signature: signature, + nonce: nonce, + contractAddress: accountAddress, + entryPointSelector: getSelectorByName('__execute__'), + calldata: calldata, + ); } - final maxFee = await getMaxFeeFromBroadcastedTxn( - broadcastedTxn, blockId, feeMultiplier); + final maxFee = await getmax_feeFromBroadcastedTxn( + broadcastedTxn, + blockId, + feeMultiplier, + ); return maxFee; } /// Get Estimate max fee for Declare Tx - Future getEstimateMaxFeeForDeclareTx({ + Future getEstimatemax_feeForDeclareTx({ BlockId blockId = BlockId.latest, - String version = "0x1", + String version = '0x1', required Felt nonce, required ICompiledContract compiledContract, double feeMultiplier = 1.2, @@ -115,28 +123,32 @@ class Account { nonce: nonce, ); broadcastedTxn = BroadcastedDeclareTxn( - type: "DECLARE", - maxFee: defaultMaxFee, - version: version, - signature: signature, - nonce: nonce, - contractClass: compiledContract.compress(), - senderAddress: accountAddress); + type: 'DECLARE', + maxFee: defaultMaxFee, + version: version, + signature: signature, + nonce: nonce, + contractClass: compiledContract.compress(), + senderAddress: accountAddress, + ); } else { // V2 of BroadcastedDeclareTxn is not supported yet return defaultMaxFee; } - final maxFee = await getMaxFeeFromBroadcastedTxn( - broadcastedTxn, blockId, feeMultiplier); + final maxFee = await getmax_feeFromBroadcastedTxn( + broadcastedTxn, + blockId, + feeMultiplier, + ); return maxFee; } /// Get Estimate max fee for Deploy Tx - Future getEstimateMaxFeeForDeployAccountTx({ + Future getEstimatemax_feeForDeployAccountTx({ BlockId blockId = BlockId.latest, - String version = "0x1", + String version = '0x1', required Felt nonce, required List constructorCalldata, required Felt contractAddressSalt, @@ -152,24 +164,31 @@ class Account { ); final broadcastedTxn = BroadcastedDeployAccountTxn( - type: "DEPLOY_ACCOUNT", - version: version, - contractAddressSalt: contractAddressSalt, - constructorCalldata: constructorCalldata, - maxFee: defaultMaxFee, - nonce: nonce, - signature: signature, - classHash: classHash); + type: 'DEPLOY_ACCOUNT', + version: version, + contractAddressSalt: contractAddressSalt, + constructorCalldata: constructorCalldata, + maxFee: defaultMaxFee, + nonce: nonce, + signature: signature, + classHash: classHash, + ); - final maxFee = await getMaxFeeFromBroadcastedTxn( - broadcastedTxn, blockId, feeMultiplier); + final maxFee = await getmax_feeFromBroadcastedTxn( + broadcastedTxn, + blockId, + feeMultiplier, + ); return maxFee; } - Future getMaxFeeFromBroadcastedTxn(BroadcastedTxn broadcastedTxn, - BlockId blockId, double feeMultiplier) async { - EstimateFeeRequest estimateFeeRequest = EstimateFeeRequest( + Future getmax_feeFromBroadcastedTxn( + BroadcastedTxn broadcastedTxn, + BlockId blockId, + double feeMultiplier, + ) async { + final estimateFeeRequest = EstimateFeeRequest( request: [broadcastedTxn], blockId: blockId, simulation_flags: [], @@ -184,9 +203,9 @@ class Account { error: (error) => throw Exception(error.message), ); - final Felt overallFee = Felt.fromHexString(fee.overallFee); + final overallFee = Felt.fromHexString(fee.overallFee); //multiply by feeMultiplier - final Felt maxFee = + final maxFee = Felt.fromDouble(overallFee.toBigInt().toDouble() * feeMultiplier); return maxFee; @@ -198,31 +217,31 @@ class Account { bool useLegacyCalldata = false, bool incrementNonceIfNonceRelatedError = true, int maxAttempts = 5, - Felt? maxFee, + Felt? max_fee, Felt? nonce, }) async { nonce = nonce ?? await getNonce(); - print(nonce); + stdout.writeln(nonce); - maxFee = maxFee ?? - await getEstimateMaxFeeForInvokeTx( - functionCalls: functionCalls, - useLegacyCalldata: useLegacyCalldata, - nonce: nonce, - version: supportedTxVersion == AccountSupportedTxVersion.v1 - ? "0x1" - : "0x0"); + max_fee = max_fee ?? + await getEstimatemax_feeForInvokeTx( + functionCalls: functionCalls, + useLegacyCalldata: useLegacyCalldata, + nonce: nonce, + version: supportedTxVersion == AccountSupportedTxVersion.v1 + ? '0x1' + : '0x0', + ); - for (int attempt = 0; attempt < maxAttempts; attempt++) { + for (var attempt = 0; attempt < maxAttempts; attempt++) { final signature = signer.signTransactions( transactions: functionCalls, contractAddress: accountAddress, version: supportedTxVersion == AccountSupportedTxVersion.v1 ? 1 : 0, chainId: chainId, - entryPointSelectorName: "__execute__", nonce: nonce!, useLegacyCalldata: useLegacyCalldata, - maxFee: maxFee, + maxFee: max_fee, ); InvokeTransactionResponse response; @@ -239,7 +258,7 @@ class Account { contractAddress: accountAddress, entryPointSelector: getSelectorByName('__execute__'), calldata: calldata, - maxFee: maxFee, + maxFee: max_fee, signature: signature, ), ), @@ -257,7 +276,7 @@ class Account { senderAddress: accountAddress, calldata: calldata, signature: signature, - maxFee: maxFee, + maxFee: max_fee, nonce: nonce!, ), ), @@ -268,12 +287,12 @@ class Account { final result = response.when( result: (result) => response, error: (error) { - print('Attempt ${attempt + 1} failed: $error'); + stdout.writeln('Attempt ${attempt + 1} failed: $error'); if (attempt < maxAttempts - 1 && isNonceRelatedError(error) && incrementNonceIfNonceRelatedError) { nonce = incrementNonce(nonce!); // Increment nonce for next attempt - print('Incrementing nonce to: $nonce'); + stdout.writeln('Incrementing nonce to: $nonce'); return null; // Indicate that we should retry } else { return response; @@ -297,7 +316,7 @@ class Account { return error.message.contains('Account validation failed'); } - incrementNonce(Felt nonce) { + Felt incrementNonce(Felt nonce) { final nonceInInt = nonce.toInt(); return Felt.fromInt(nonceInInt + 1); } @@ -305,29 +324,31 @@ class Account { /// Declares a [compiledContract] Future declare({ required ICompiledContract compiledContract, - Felt? maxFee, + Felt? max_fee, Felt? nonce, // needed for v2 BigInt? compiledClassHash, CASMCompiledContract? casmCompiledContract, }) async { nonce = nonce ?? await getNonce(); - maxFee = maxFee ?? - await getEstimateMaxFeeForDeclareTx( - nonce: nonce, compiledContract: compiledContract); + max_fee = max_fee ?? + await getEstimatemax_feeForDeclareTx( + nonce: nonce, + compiledContract: compiledContract, + ); if (compiledContract is DeprecatedCompiledContract) { final signature = signer.signDeclareTransactionV1( compiledContract: compiledContract, senderAddress: accountAddress, chainId: chainId, nonce: nonce, - maxFee: maxFee, + maxFee: max_fee, ); return provider.addDeclareTransaction( DeclareTransactionRequest( declareTransaction: DeclareTransactionV1( - max_fee: maxFee, + max_fee: max_fee, nonce: nonce, contractClass: compiledContract.compress(), senderAddress: accountAddress, @@ -343,13 +364,13 @@ class Account { nonce: nonce, compiledClassHash: compiledClassHash, casmCompiledContract: casmCompiledContract, - maxFee: maxFee, + maxFee: max_fee, ); return provider.addDeclareTransaction( DeclareTransactionRequest( declareTransaction: DeclareTransactionV2( - max_fee: maxFee, + max_fee: max_fee, nonce: nonce, contractClass: compiledContract.flatten(), compiledClassHash: Felt(compiledClassHash!), @@ -410,7 +431,7 @@ class Account { )) .when( result: (result) => result, - error: ((error) => Felt.fromInt(0)), + error: (error) => Felt.fromInt(0), ); return accountClassHash != Felt.fromInt(0); } @@ -425,15 +446,15 @@ class Account { required List constructorCalldata, required Felt classHash, Felt? contractAddressSalt, - Felt? maxFee, + Felt? max_fee, Felt? nonce, }) async { final chainId = (await provider.chainId()).when( - result: (result) => Felt.fromHexString(result), + result: Felt.fromHexString, error: (error) => StarknetChainId.testNet, ); - maxFee = maxFee ?? defaultMaxFee; + max_fee = max_fee ?? defaultMaxFee; nonce = nonce ?? defaultNonce; contractAddressSalt = contractAddressSalt ?? signer.publicKey; @@ -443,7 +464,7 @@ class Account { constructorCalldata: constructorCalldata, chainId: chainId, nonce: nonce, - maxFee: maxFee, + maxFee: max_fee, ); return provider.addDeployAccountTransaction( @@ -451,7 +472,7 @@ class Account { deployAccountTransaction: DeployAccountTransactionV1( classHash: classHash, signature: signature, - maxFee: maxFee, + maxFee: max_fee, nonce: nonce, contractAddressSalt: contractAddressSalt, constructorCalldata: constructorCalldata, @@ -513,13 +534,13 @@ Account getAccount({ Felt? getDeployedContractAddress(GetTransactionReceipt txReceipt) { return txReceipt.when( result: (r) { - for (var event in r.events) { + for (final event in r.events) { // contract constructor can generate some event also if (event.fromAddress == udcAddress) { return event.data?[0]; } } - throw Exception("UDC deployer event not found"); + throw Exception('UDC deployer event not found'); }, error: (e) => throw Exception(e.message), ); @@ -573,9 +594,9 @@ class OpenzeppelinAccountDerivation implements AccountDerivation { List constructorCalldata({required Felt publicKey}) { return [ implementationClassHash, - getSelectorByName("initializer"), + getSelectorByName('initializer'), Felt.fromInt(1), - publicKey + publicKey, ]; } @@ -591,14 +612,14 @@ class OpenzeppelinAccountDerivation implements AccountDerivation { ); final deployTxHash = tx.when( result: (result) { - print( - "Account is deployed at ${result.contractAddress.toHexString()} (tx: ${result.transactionHash.toHexString()})", + stdout.writeln( + 'Account is deployed at ${result.contractAddress.toHexString()} (tx: ${result.transactionHash.toHexString()})', ); return result.transactionHash; }, error: (error) { throw Exception( - "Account deploy failed: ${error.code} ${error.message}", + 'Account deploy failed: ${error.code} ${error.message}', ); }, ); @@ -613,14 +634,14 @@ class BraavosAccountDerivation extends AccountDerivation { // FIXME: hardcoded value for testnet 2023-02-24 final classHash = Felt.fromHexString( - "0x03131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e", + '0x03131fa018d520a037686ce3efddeab8f28895662f019ca3ca18a626650f7d1e', ); /// FIXME: implementation class hash should be retrieved at runtime final implementationClassHash = Felt.fromHexString( - "0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570", + '0x5aa23d5bb71ddaa783da7ea79d405315bafa7cf0387a74f4593578c3e9e6570', ); - final initializerSelector = getSelectorByName("initializer"); + final initializerSelector = getSelectorByName('initializer'); BraavosAccountDerivation({ required this.provider, @@ -640,7 +661,7 @@ class BraavosAccountDerivation extends AccountDerivation { implementationClassHash, initializerSelector, Felt.fromInt(1), - publicKey + publicKey, ]; } @@ -663,22 +684,22 @@ class ArgentXAccountDerivation extends AccountDerivation { // FIXME: hardcoded value for testnet 2023-02-24 final classHash = Felt.fromHexString( - "0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918", + '0x025ec026985a3bf9d0cc1fe17326b245dfdc3ff89b8fde106542a3ea56c5a918', ); /// FIXME: implementation address should be retrieved at runtime final implementationAddress = Felt.fromHexString( - "0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2", + '0x33434ad846cdd5f23eb73ff09fe6fddd568284a0fb7d1be20ee482f044dabe2', ); @override Signer deriveSigner({required List mnemonic, int index = 0}) { - final seed = bip39.mnemonicToSeed(mnemonic.join(" ")); + final seed = bip39.mnemonicToSeed(mnemonic.join(' ')); final hdNodeSingleSeed = bip32.BIP32.fromSeed(seed); final hdNodeDoubleSeed = bip32.BIP32 .fromSeed(hdNodeSingleSeed.derivePath(masterPrefix).privateKey!); final child = hdNodeDoubleSeed.derivePath('$pathPrefix/$index'); - Uint8List key = child.privateKey!; + var key = child.privateKey!; key = grindKey(key); final privateKey = Felt(bytesToUnsignedInt(key)); return Signer(privateKey: privateKey); @@ -688,7 +709,7 @@ class ArgentXAccountDerivation extends AccountDerivation { List constructorCalldata({required Felt publicKey}) { return [ implementationAddress, - getSelectorByName("initialize"), + getSelectorByName('initialize'), Felt.fromInt(2), publicKey, Felt.fromInt(0), diff --git a/packages/starknet/lib/src/contract/contract.dart b/packages/starknet/lib/src/contract/contract.dart index 0a706374..d8d9143c 100644 --- a/packages/starknet/lib/src/contract/contract.dart +++ b/packages/starknet/lib/src/contract/contract.dart @@ -1,5 +1,5 @@ -import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; +import '../../starknet.dart'; class Contract { final Account account; @@ -14,8 +14,8 @@ class Contract { required Felt salt, }) { final deployerAddress = BigInt.from(0); // always zero - List elements = []; - elements.add(Felt.fromString("STARKNET_CONTRACT_ADDRESS").toBigInt()); + final elements = []; + elements.add(Felt.fromString('STARKNET_CONTRACT_ADDRESS').toBigInt()); // caller address is always zero elements.add(deployerAddress); elements.add(salt.toBigInt()); @@ -36,16 +36,16 @@ class Contract { entryPointSelector: getSelectorByName(selector), calldata: calldata, ), - blockId: BlockId.blockTag("latest"), + blockId: const BlockId.blockTag('latest'), ); - return (response.when( + return response.when( error: (error) { throw Exception(error); }, result: (result) { return result; }, - )); + ); } /// Execute contract given [selector] with [calldata] @@ -53,7 +53,7 @@ class Contract { String selector, List calldata, ) async { - final Felt maxFee = defaultMaxFee; + final maxFee = defaultMaxFee; final trx = await account.execute( functionCalls: [ @@ -63,7 +63,7 @@ class Contract { calldata: calldata, ), ], - maxFee: maxFee, + max_fee: maxFee, ); return trx; } diff --git a/packages/starknet/lib/src/contract/model/compiled_contract.dart b/packages/starknet/lib/src/contract/model/compiled_contract.dart index 9f5be70e..5ac38463 100644 --- a/packages/starknet/lib/src/contract/model/compiled_contract.dart +++ b/packages/starknet/lib/src/contract/model/compiled_contract.dart @@ -2,10 +2,11 @@ import 'dart:convert'; import 'dart:io'; import 'package:freezed_annotation/freezed_annotation.dart'; -import 'package:starknet/src/crypto/poseidon.dart'; -import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; +import '../../../starknet.dart'; +import '../../crypto/poseidon.dart'; + part 'compiled_contract.freezed.dart'; part 'compiled_contract.g.dart'; @@ -13,19 +14,22 @@ const CONTRACT_CLASS_V0_1_0 = 'CONTRACT_CLASS_V0.1.0'; const COMPILED_CLASS_V1 = 'COMPILED_CLASS_V1'; Future _readJsonFile(String filePath) async { - final bigIntPattern = "BigInt|"; + const bigIntPattern = 'BigInt|'; var input = await File(filePath).readAsString(); // Dart JSON decoder use double to represent number, // but 64 bits is not enough for Felt // so we prefix "number" by [bigIntPattern] input = input.replaceAllMapped( - RegExp(r'^(\s*"value": )(-?[0-9]+)(\s*,?)', multiLine: true), - (match) => '${match[1]}"$bigIntPattern${match[2]}"${match[3]}'); - var json = jsonDecode(input, - reviver: (key, value) => - key == "value" && value is String && value.startsWith(bigIntPattern) - ? BigInt.parse(value.replaceAll(bigIntPattern, "")) - : value); + RegExp(r'^(\s*"value": )(-?[0-9]+)(\s*,?)', multiLine: true), + (match) => '${match[1]}"$bigIntPattern${match[2]}"${match[3]}', + ); + final json = jsonDecode( + input, + reviver: (key, value) => + key == 'value' && value is String && value.startsWith(bigIntPattern) + ? BigInt.parse(value.replaceAll(bigIntPattern, '')) + : value, + ); return json; } @@ -40,34 +44,34 @@ class CompiledContract implements ICompiledContract { factory CompiledContract.fromJson(Map json) { final _contract = SierraCompiledContract.fromJson(json); - final _abiRaw = json['abi'] as List; + final _abiRaw = json['abi']! as List; return CompiledContract._(_contract, _abiRaw); } static Future fromPath(String contractPath) async { final json = await _readJsonFile(contractPath); - return CompiledContract.fromJson(json); + return CompiledContract.fromJson(json as Map); } /// Compute hashes for externals, l1 handlers and constructors /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ EntryPointsHashes _entrypointsHashes() { - List buffer = []; - for (var entrypoint in contract.entryPointsByType.external) { + final buffer = []; + for (final entrypoint in contract.entryPointsByType.external) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.functionIdx)); } final externals = poseidonHasher.hashMany(buffer); buffer.clear(); - for (var entrypoint in contract.entryPointsByType.l1Handler) { + for (final entrypoint in contract.entryPointsByType.l1Handler) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.functionIdx)); } final l1handlers = poseidonHasher.hashMany(buffer); buffer.clear(); - for (var entrypoint in contract.entryPointsByType.constructor) { + for (final entrypoint in contract.entryPointsByType.constructor) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.functionIdx)); } @@ -87,18 +91,19 @@ class CompiledContract implements ICompiledContract { FlattenSierraContractClass flatten() { final abi = PythonicJsonEncoder(sortSymbol: false).convert(abiRaw); return FlattenSierraContractClass( - sierraProgram: contract.sierraProgram - .map((e) => '0x${e.toRadixString(16)}') - .toList(), - contractClassVersion: contract.contractClassVersion, - entryPointsByType: contract.entryPointsByType, - abi: abi); + sierraProgram: contract.sierraProgram + .map((e) => '0x${e.toRadixString(16)}') + .toList(), + contractClassVersion: contract.contractClassVersion, + entryPointsByType: contract.entryPointsByType, + abi: abi, + ); } @override BigInt classHash() { - List elements = []; - if (contract.contractClassVersion == "0.1.0") { + final elements = []; + if (contract.contractClassVersion == '0.1.0') { elements.add(Felt.fromString(CONTRACT_CLASS_V0_1_0).toBigInt()); } final hashes = _entrypointsHashes(); @@ -127,7 +132,7 @@ class SierraCompiledContract with _$SierraCompiledContract { static Future fromPath(String contractPath) async { final json = await _readJsonFile(contractPath); - return SierraCompiledContract.fromJson(json); + return SierraCompiledContract.fromJson(json as Map); } } @@ -161,19 +166,19 @@ class CASMCompiledContract static Future fromPath(String contractPath) async { final json = await _readJsonFile(contractPath); - return CASMCompiledContract.fromJson(json); + return CASMCompiledContract.fromJson(json as Map); } /// Compute hashes for externals, l1 handlers and constructors /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ EntryPointsHashes _entrypointsHashes() { - List buffer = []; - for (var entrypoint in entryPointsByType.external) { + final buffer = []; + for (final entrypoint in entryPointsByType.external) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.offset)); - List builtins = []; - for (var builtin in entrypoint.builtins) { + final builtins = []; + for (final builtin in entrypoint.builtins) { builtins.add(Felt.fromString(builtin).toBigInt()); } buffer.add(poseidonHasher.hashMany(builtins)); @@ -181,12 +186,12 @@ class CASMCompiledContract final externals = poseidonHasher.hashMany(buffer); buffer.clear(); - for (var entrypoint in entryPointsByType.l1Handler) { + for (final entrypoint in entryPointsByType.l1Handler) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.offset)); - List builtins = []; - for (var builtin in entrypoint.builtins) { + final builtins = []; + for (final builtin in entrypoint.builtins) { builtins.add(Felt.fromString(builtin).toBigInt()); } buffer.add(poseidonHasher.hashMany(builtins)); @@ -194,12 +199,12 @@ class CASMCompiledContract final l1handlers = poseidonHasher.hashMany(buffer); buffer.clear(); - for (var entrypoint in entryPointsByType.constructor) { + for (final entrypoint in entryPointsByType.constructor) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.from(entrypoint.offset)); - List builtins = []; - for (var builtin in entrypoint.builtins) { + final builtins = []; + for (final builtin in entrypoint.builtins) { builtins.add(Felt.fromString(builtin).toBigInt()); } buffer.add(poseidonHasher.hashMany(builtins)); @@ -215,8 +220,8 @@ class CASMCompiledContract @override BigInt classHash() { - List elements = []; - if (compilerVersion == "1.1.0") { + final elements = []; + if (compilerVersion == '1.1.0') { elements.add(Felt.fromString(COMPILED_CLASS_V1).toBigInt()); } final hashes = _entrypointsHashes(); @@ -244,51 +249,53 @@ class DeprecatedCompiledContract _$DeprecatedCompiledContractFromJson(json); static Future fromPath( - String contractPath) async { + String contractPath, + ) async { final json = await _readJsonFile(contractPath); - return DeprecatedCompiledContract.fromJson(json); + return DeprecatedCompiledContract.fromJson(json as Map); } DeprecatedContractClass compress() { - final new_program = Map.of(program); - final program_json = PythonicJsonEncoder().convert(new_program); + final newProgram = Map.of(program); + final programJson = PythonicJsonEncoder().convert(newProgram); return DeprecatedContractClass( - program: base64.encode(gzip.encode(utf8.encode(program_json))), + program: base64.encode(gzip.encode(utf8.encode(programJson))), entryPointsByType: entryPointsByType, abi: abi, ); } Map _filtering(Map program) { - final new_program = Map.of(program); - if ((new_program["attributes"] as List).isEmpty) { + final newProgram = Map.of(program); + if ((newProgram['attributes']! as List).isEmpty) { // Remove attributes field from raw dictionary, for hash backward compatibility of // contracts deployed prior to adding this feature. - new_program.remove("attributes"); + newProgram.remove('attributes'); } else { // Remove accessible_scopes and flow_tracking_data fields from raw dictionary, for hash // backward compatibility of contracts deployed prior to adding this feature. - for (Map attr - in (new_program["attributes"] as List)) { - if ((attr["accessible_scopes"] as List).isEmpty) { - attr.remove("accessible_scopes"); + final attributes = + (newProgram['attributes']! as List).cast>(); + for (final attr in attributes) { + if ((attr['accessible_scopes']! as List).isEmpty) { + attr.remove('accessible_scopes'); } - if (attr.containsKey("flow") && - ((attr["flow"] as List).isEmpty)) { - attr.remove("flow"); + if (attr.containsKey('flow') && + ((attr['flow']! as List).isEmpty)) { + attr.remove('flow'); } } } - return new_program; + return newProgram; } /// Return program filtered and encoded as Python json.dumps String _encode() { - final new_program = _filtering(program); + final newProgram = _filtering(program); final encoded = PythonicJsonEncoder(filterRuntimeType: false).convert({ - "abi": abi, - "program": new_program, + 'abi': abi, + 'program': newProgram, }); return encoded; } @@ -296,22 +303,22 @@ class DeprecatedCompiledContract /// Compute hashes for externals, l1 handlers and constructors /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ EntryPointsHashes entrypointsHashes() { - List buffer = []; - for (var entrypoint in entryPointsByType.external) { + final buffer = []; + for (final entrypoint in entryPointsByType.external) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.parse(entrypoint.offset)); } final externals = computeHashOnElements(buffer); buffer.clear(); - for (var entrypoint in entryPointsByType.l1Handler) { + for (final entrypoint in entryPointsByType.l1Handler) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.parse(entrypoint.offset)); } final l1handlers = computeHashOnElements(buffer); buffer.clear(); - for (var entrypoint in entryPointsByType.constructor) { + for (final entrypoint in entryPointsByType.constructor) { buffer.add(entrypoint.selector.toBigInt()); buffer.add(BigInt.parse(entrypoint.offset)); } @@ -323,8 +330,8 @@ class DeprecatedCompiledContract /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ BigInt builtinsHash() { return computeHashOnElements( - (program["builtins"] as List) - .map((e) => Felt.fromString(e).toBigInt()) + (program['builtins']! as List) + .map((e) => Felt.fromString(e as String).toBigInt()) .toList(), ); } @@ -340,8 +347,8 @@ class DeprecatedCompiledContract /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ BigInt byteCodeHash() { return computeHashOnElements( - (program["data"] as List) - .map((e) => Felt.fromHexString(e).toBigInt()) + (program['data']! as List) + .map((e) => Felt.fromHexString(e as String).toBigInt()) .toList(), ); } @@ -350,7 +357,7 @@ class DeprecatedCompiledContract /// https://docs.starknet.io/documentation/architecture_and_concepts/Contracts/contract-hash/ @override BigInt classHash() { - List elements = []; + final elements = []; elements.add(BigInt.from(0)); // FIXME: API VERSION final hashes = entrypointsHashes(); elements.add(hashes.externals); @@ -398,8 +405,8 @@ class PythonicJsonEncoder extends JsonEncoder { if (filterRuntimeType) { if ((object is DeprecatedContractAbiEntry) || (object is SierraContractAbiEntry)) { - var res = object.toJson(); - res.remove("runtimeType"); + final res = object.toJson(); + res.remove('runtimeType'); return res; } } @@ -472,7 +479,7 @@ abstract class _JsonStringifier { var offset = 0; final length = s.length; for (var i = 0; i < length; i++) { - var charCode = s.codeUnitAt(i); + final charCode = s.codeUnitAt(i); if (charCode > backslash) { if (charCode >= surrogateMin) { // Possible surrogate. Check if it is unpaired. @@ -573,7 +580,7 @@ abstract class _JsonStringifier { if (writeJsonValue(object)) return; _checkCycle(object); try { - var customJson = _toEncodable(object); + final customJson = _toEncodable(object); if (!writeJsonValue(customJson)) { throw JsonUnsupportedObjectError(object, partialResult: _partialResult); } @@ -618,7 +625,7 @@ abstract class _JsonStringifier { } else if (object is Map) { _checkCycle(object); // writeMap can fail if keys are not all strings. - var success = writeMap(object); + final success = writeMap(object); _removeSeen(object); return success; } else if (object is BigInt) { @@ -647,19 +654,19 @@ abstract class _JsonStringifier { /// Serialize a [Map]. bool writeMap(Map map) { if (map.isEmpty) { - writeString("{}"); + writeString('{}'); return true; } // FIXME: workaround for freezed `union_key` present in generated json - map.remove("starkNetRuntimeTypeToRemove"); - var keyValueList = List.filled(map.length * 2, null); + map.remove('starkNetRuntimeTypeToRemove'); + final keyValueList = List.filled(map.length * 2, null); var i = 0; var allStringKeys = true; if (_sortSymbol) { map = Map.fromEntries( map.entries.toList() ..sort( - (e1, e2) => (e1.key as String).naturalCompareTo(e2.key as String), + (e1, e2) => (e1.key! as String).naturalCompareTo(e2.key! as String), ), ); } @@ -676,7 +683,7 @@ abstract class _JsonStringifier { for (var i = 0; i < keyValueList.length; i += 2) { writeString(separator); separator = ', "'; // add a space as in python json dumps - writeStringContent(keyValueList[i] as String); + writeStringContent(keyValueList[i]! as String); writeString('": '); // add a space as in python json dumps writeObject(keyValueList[i + 1]); } @@ -690,9 +697,10 @@ class _JsonStringStringifier extends _JsonStringifier { final StringSink _sink; _JsonStringStringifier( - this._sink, dynamic Function(dynamic object)? _toEncodable, - {bool? sortSymbol}) - : super(_toEncodable, sortSymbol: sortSymbol); + this._sink, + dynamic Function(dynamic object)? _toEncodable, { + bool? sortSymbol, + }) : super(_toEncodable, sortSymbol: sortSymbol); /// Convert object to a string. /// @@ -709,7 +717,7 @@ class _JsonStringStringifier extends _JsonStringifier { String? indent, { bool? sortSymbol, }) { - var output = StringBuffer(); + final output = StringBuffer(); printOn(object, output, toEncodable, indent, sortSymbol: sortSymbol); return output.toString(); } @@ -717,9 +725,13 @@ class _JsonStringStringifier extends _JsonStringifier { /// Convert object to a string, and write the result to the [output] sink. /// /// The result is written piecemally to the sink. - static void printOn(Object? object, StringSink output, - dynamic toEncodable(dynamic o)?, String? indent, - {bool? sortSymbol}) { + static void printOn( + Object? object, + StringSink output, + dynamic toEncodable(dynamic o)?, + String? indent, { + bool? sortSymbol, + }) { _JsonStringifier stringifier; stringifier = _JsonStringStringifier(output, toEncodable, sortSymbol: sortSymbol); @@ -752,8 +764,8 @@ class _JsonStringStringifier extends _JsonStringifier { extension ContractCompare on String { int naturalCompareTo(String other) { // handle case where string is an integer (for hint) - int? me = int.tryParse(this); - int? you = int.tryParse(other); + final me = int.tryParse(this); + final you = int.tryParse(other); if (me != null && you != null) { if (me == you) { return 0; diff --git a/packages/starknet/lib/src/crypto/model/pedersen_params.dart b/packages/starknet/lib/src/crypto/model/pedersen_params.dart index 0f7dc00c..4c3d446f 100644 --- a/packages/starknet/lib/src/crypto/model/pedersen_params.dart +++ b/packages/starknet/lib/src/crypto/model/pedersen_params.dart @@ -21,7 +21,8 @@ class PedersenParams with _$PedersenParams { _$PedersenParamsFromJson(json); } -const pedersenParamsJsonString = '''{ +const pedersenParamsJsonString = ''' +{ "FIELD_PRIME": 3618502788666131213697322783095070105623107215331596699973092056135872020481, "FIELD_GEN": 3, "EC_ORDER": 3618502788666131213697322783095070105526743751716087489154079457884512865583, @@ -2058,8 +2059,12 @@ const pedersenParamsJsonString = '''{ final rNumber = RegExp(r'(\d+)'); PedersenParams loadPedersenParams() { final jsonWithStringifiedNumbers = pedersenParamsJsonString.replaceAllMapped( - rNumber, (match) => '"${match.group(0)}"'); - return PedersenParams.fromJson(json.decode(jsonWithStringifiedNumbers)); + rNumber, + (match) => '"${match.group(0)}"', + ); + return PedersenParams.fromJson( + json.decode(jsonWithStringifiedNumbers) as Map, + ); } final pedersenParams = loadPedersenParams(); diff --git a/packages/starknet/lib/src/crypto/model/poseidon_params.dart b/packages/starknet/lib/src/crypto/model/poseidon_params.dart index d3f07e40..c26a1718 100644 --- a/packages/starknet/lib/src/crypto/model/poseidon_params.dart +++ b/packages/starknet/lib/src/crypto/model/poseidon_params.dart @@ -22,7 +22,8 @@ class PoseidonParams with _$PoseidonParams { _$PoseidonParamsFromJson(json); } -const poseidon3ParamsJsonString = '''{ +const poseidon3ParamsJsonString = ''' +{ "FIELD_PRIME": 3618502788666131213697322783095070105623107215331596699973092056135872020481, "RATE": 2, "CAPACITY": 1, @@ -491,8 +492,12 @@ const poseidon3ParamsJsonString = '''{ final rNumber = RegExp(r'(-?\d+)'); PoseidonParams _loadPedersenParams() { final jsonWithStringifiedNumbers = poseidon3ParamsJsonString.replaceAllMapped( - rNumber, (match) => '"${match.group(0)}"'); - return PoseidonParams.fromJson(json.decode(jsonWithStringifiedNumbers)); + rNumber, + (match) => '"${match.group(0)}"', + ); + return PoseidonParams.fromJson( + json.decode(jsonWithStringifiedNumbers) as Map, + ); } final poseidonParams = _loadPedersenParams(); diff --git a/packages/starknet/lib/src/crypto/signature.dart b/packages/starknet/lib/src/crypto/signature.dart index 113829e7..c376983b 100644 --- a/packages/starknet/lib/src/crypto/signature.dart +++ b/packages/starknet/lib/src/crypto/signature.dart @@ -1,19 +1,21 @@ import 'dart:typed_data'; import 'package:crypto/crypto.dart' as crypto; -import 'package:starknet/starknet.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import '../../starknet.dart'; const nbFieldPrimeBits = 251; final maxHash = BigInt.two.pow(nbFieldPrimeBits); +@immutable class Signature { final BigInt r; final BigInt s; - Signature(this.r, this.s); + const Signature(this.r, this.s); @override String toString() { - return "Signature($r, $s)"; + return 'Signature($r, $s)'; } @override @@ -29,24 +31,34 @@ class Signature { /// Signs a message hash using the given private key according to Starknet specs. /// /// Spec: https://github.com/starkware-libs/cairo-lang/blob/13cef109cd811474de114925ee61fd5ac84a25eb/src/starkware/crypto/starkware/crypto/signature/signature.py#L135-L171 -Signature starknet_sign( - {required BigInt privateKey, required BigInt messageHash, BigInt? seed}) { - assert(messageHash >= BigInt.zero && messageHash < maxHash, - "Message not signable."); +Signature starknetSign({ + required BigInt privateKey, + required BigInt messageHash, + BigInt? seed, +}) { + assert( + messageHash >= BigInt.zero && messageHash < maxHash, + 'Message not signable.', + ); + + var finalSeed = seed; while (true) { - final k = starknet_generateK( - privateKey: privateKey, messageHash: messageHash, seed: seed); + final k = starknetGenerateK( + privateKey: privateKey, + messageHash: messageHash, + seed: finalSeed, + ); - if (seed == null) { - seed = BigInt.one; + if (finalSeed == null) { + finalSeed = BigInt.one; } else { - seed += BigInt.one; + finalSeed += BigInt.one; } final x = (generatorPoint * k)!.x; - final BigInt r = x?.toBigInteger() as BigInt; + final r = x!.toBigInteger()!; if (!(r >= BigInt.one && r < maxHash)) { continue; } @@ -71,8 +83,11 @@ Signature starknet_sign( /// Generates a k value according to Starknet specs. /// /// Spec: https://github.com/starkware-libs/cairo-lang/blob/13cef109cd811474de114925ee61fd5ac84a25eb/src/starkware/crypto/starkware/crypto/signature/signature.py#L115-L132 -BigInt starknet_generateK( - {required BigInt privateKey, required BigInt messageHash, BigInt? seed}) { +BigInt starknetGenerateK({ + required BigInt privateKey, + required BigInt messageHash, + BigInt? seed, +}) { // Pad the message hash, for consistency with the elliptic.js library. final bytesLength = messageHash.bitLength % 8; if (bytesLength >= 1 && bytesLength <= 4 && messageHash.bitLength >= 248) { @@ -82,27 +97,29 @@ BigInt starknet_generateK( final extraEntropy = seed == null ? Uint8List(0) : bigIntToBytes(seed); return generateK( - order: pedersenParams.ecOrder, - privateKey: privateKey, - hashFunction: crypto.sha256, - data: bigIntToBytes(messageHash), - extraEntropy: extraEntropy); + order: pedersenParams.ecOrder, + privateKey: privateKey, + hashFunction: crypto.sha256, + data: bigIntToBytes(messageHash), + extraEntropy: extraEntropy, + ); } /// Generates a k value, the nonce for DSA. /// /// Spec: https://tools.ietf.org/html/rfc6979#section-3.2 -BigInt generateK( - {required BigInt order, - required BigInt privateKey, - required crypto.Hash hashFunction, - required List data, - int retryGen = 0, - List extraEntropy = const []}) { +BigInt generateK({ + required BigInt order, + required BigInt privateKey, + required crypto.Hash hashFunction, + required List data, + int retryGen = 0, + List extraEntropy = const [], +}) { final qlen = order.bitLength; - final holen = 32; // digest length is 256 bits for sha256 + const holen = 32; // digest length is 256 bits for sha256 final rolen = orderlen(order); - var bx = numberToString(privateKey, order) + + final bx = numberToString(privateKey, order) + bits2Octets(data, order) + extraEntropy; @@ -135,12 +152,13 @@ BigInt generateK( } // Step H3 - var secret = bits2Int(t, qlen); + final secret = bits2Int(t, qlen); if (secret >= BigInt.one && secret < order) { if (retryGen <= 0) { return secret; } + // ignore: parameter_assignments retryGen -= 1; } @@ -151,7 +169,7 @@ BigInt generateK( // https://tools.ietf.org/html/rfc6979#section-2.3.4 List bits2Octets(List data, BigInt order) { - var z1 = bits2Int(data, order.bitLength); + final z1 = bits2Int(data, order.bitLength); var z2 = z1 - order; if (z2 < BigInt.zero) { @@ -162,8 +180,8 @@ List bits2Octets(List data, BigInt order) { } BigInt bits2Int(List data, int qlen) { - var x = bytesToBigInt(data); - var l = data.length * 8; + final x = bytesToBigInt(data); + final l = data.length * 8; if (l > qlen) { return x >> (l - qlen); @@ -172,15 +190,15 @@ BigInt bits2Int(List data, int qlen) { } List numberToString(BigInt v, BigInt order) { - var l = orderlen(order); + final l = orderlen(order); - var vBytes = bigIntToBytes(v); - vBytes = - Uint8List.fromList([...List.filled(l - vBytes.length, 0x00), ...vBytes]); + final vBytes = bigIntToBytes(v); - return vBytes; + return Uint8List.fromList( + [...List.filled(l - vBytes.length, 0x00), ...vBytes], + ); } -orderlen(BigInt order) { +int orderlen(BigInt order) { return (order.bitLength + 7) ~/ 8; } diff --git a/packages/starknet/lib/src/signer.dart b/packages/starknet/lib/src/signer.dart index 5d0ce488..b754b182 100644 --- a/packages/starknet/lib/src/signer.dart +++ b/packages/starknet/lib/src/signer.dart @@ -1,4 +1,4 @@ -import 'package:starknet/starknet.dart'; +import '../starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; class Signer { @@ -30,21 +30,22 @@ class Signer { txHashPrefix: TransactionHashPrefix.invoke.toBigInt(), address: senderAddress.toBigInt(), version: 1, - entryPointSelector: BigInt.parse("0"), + entryPointSelector: BigInt.parse('0'), calldata: toBigIntList(calldata), maxFee: maxFee.toBigInt(), chainId: chainId.toBigInt(), additionalData: [nonce.toBigInt()], ); - print("transactionHash: ${Felt(transactionHash).toHexString()}"); + print('transactionHash: ${Felt(transactionHash).toHexString()}'); - final signature = starknet_sign( + final signature = starknetSign( privateKey: privateKey.toBigInt(), messageHash: transactionHash, seed: BigInt.from(32), ); print( - "signature: ${Felt(signature.r).toHexString()} ${Felt(signature.s).toHexString()}"); + 'signature: ${Felt(signature.r).toHexString()} ${Felt(signature.s).toHexString()}', + ); return [Felt(signature.r), Felt(signature.s)]; } @@ -55,7 +56,7 @@ class Signer { required Felt chainId, required Felt nonce, Felt? maxFee, - String entryPointSelectorName = "__execute__", + String entryPointSelectorName = '__execute__', }) { maxFee = maxFee ?? defaultMaxFee; final calldata = @@ -64,14 +65,13 @@ class Signer { final transactionHash = calculateTransactionHashCommon( txHashPrefix: TransactionHashPrefix.invoke.toBigInt(), address: contractAddress.toBigInt(), - version: 0, entryPointSelector: getSelectorByName(entryPointSelectorName).toBigInt(), calldata: toBigIntList(calldata), maxFee: maxFee.toBigInt(), chainId: chainId.toBigInt(), ); - final signature = starknet_sign( + final signature = starknetSign( privateKey: privateKey.toBigInt(), messageHash: transactionHash, seed: BigInt.from(32), @@ -87,12 +87,12 @@ class Signer { required int version, required Felt nonce, Felt? maxFee, - String entryPointSelectorName = "__execute__", + String entryPointSelectorName = '__execute__', bool useLegacyCalldata = false, }) { switch (version) { case 0: - print("Signing invoke transaction v0"); + print('Signing invoke transaction v0'); return signInvokeTransactionsV0( transactions: transactions, contractAddress: contractAddress, @@ -102,16 +102,17 @@ class Signer { maxFee: maxFee, ); case 1: - print("Signing invoke transaction v1"); + print('Signing invoke transaction v1'); return signInvokeTransactionsV1( - transactions: transactions, - senderAddress: contractAddress, - chainId: chainId, - nonce: nonce, - maxFee: maxFee, - useLegacyCalldata: useLegacyCalldata); + transactions: transactions, + senderAddress: contractAddress, + chainId: chainId, + nonce: nonce, + maxFee: maxFee, + useLegacyCalldata: useLegacyCalldata, + ); default: - throw Exception("Unsupported invoke transaction version: $version"); + throw Exception('Unsupported invoke transaction version: $version'); } } @@ -125,7 +126,7 @@ class Signer { maxFee = maxFee ?? defaultMaxFee; final classHash = compiledContract.classHash(); - final List elementsToHash = [ + final elementsToHash = [ TransactionHashPrefix.declare.toBigInt(), BigInt.from(1), senderAddress.toBigInt(), @@ -133,11 +134,11 @@ class Signer { computeHashOnElements([classHash]), maxFee.toBigInt(), chainId.toBigInt(), - nonce.toBigInt() + nonce.toBigInt(), ]; final transactionHash = computeHashOnElements(elementsToHash); - final signature = starknet_sign( + final signature = starknetSign( privateKey: privateKey.toBigInt(), messageHash: transactionHash, seed: BigInt.from(32), @@ -161,12 +162,12 @@ class Signer { classHash ??= compiledContract.classHash(); if ((compiledClassHash == null) && (casmCompiledContract == null)) { throw Exception( - "compiledClassHash is null and CASM contract not provided", + 'compiledClassHash is null and CASM contract not provided', ); } compiledClassHash ??= casmCompiledContract!.classHash(); - final List elementsToHash = [ + final elementsToHash = [ TransactionHashPrefix.declare.toBigInt(), BigInt.two, senderAddress.toBigInt(), @@ -180,7 +181,7 @@ class Signer { final transactionHash = computeHashOnElements(elementsToHash); - final signature = starknet_sign( + final signature = starknetSign( privateKey: privateKey.toBigInt(), messageHash: transactionHash, seed: BigInt.from(32), @@ -199,16 +200,17 @@ class Signer { }) { maxFee = maxFee ?? defaultMaxFee; nonce = nonce ?? defaultNonce; - print("classHash: ${classHash.toHexString()}"); - print("calldata: ${constructorCalldata.map((e) => e.toHexString())}"); - print("salt: ${contractAddressSalt.toHexString()}"); + print('classHash: ${classHash.toHexString()}'); + print('calldata: ${constructorCalldata.map((e) => e.toHexString())}'); + print('salt: ${contractAddressSalt.toHexString()}'); final contractAddress = Contract.computeAddress( classHash: classHash, calldata: constructorCalldata, salt: contractAddressSalt, ); print( - "[signDeployAccountTransactionV1] Contract address: ${contractAddress.toHexString()}"); + '[signDeployAccountTransactionV1] Contract address: ${contractAddress.toHexString()}', + ); final transactionHash = calculateTransactionHashCommon( txHashPrefix: TransactionHashPrefix.deployAccount.toBigInt(), @@ -225,7 +227,7 @@ class Signer { additionalData: [nonce.toBigInt()], ); - final signature = starknet_sign( + final signature = starknetSign( privateKey: privateKey.toBigInt(), messageHash: transactionHash, ); diff --git a/packages/starknet/lib/src/types/uint256.dart b/packages/starknet/lib/src/types/uint256.dart index 6272eaa5..705d9a41 100644 --- a/packages/starknet/lib/src/types/uint256.dart +++ b/packages/starknet/lib/src/types/uint256.dart @@ -1,10 +1,13 @@ -import 'package:starknet/starknet.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import '../../starknet.dart'; + +@immutable class Uint256 { final Felt low; // low 128 bits final Felt high; // high 128 bits - Uint256({required this.low, required this.high}); + const Uint256({required this.low, required this.high}); factory Uint256.fromInt(int number) => Uint256.fromBigInt(BigInt.from(number)); @@ -15,12 +18,12 @@ class Uint256 { factory Uint256.fromBigInt(BigInt number) { // Ensure the number fits within 256 bits if (number.bitLength > 256) { - throw Exception("BigInt too large to fit in Uint256"); + throw Exception('BigInt too large to fit in Uint256'); } // Create a mask for 128-bit - BigInt mask = BigInt.parse('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', radix: 16); - Felt low = Felt(number & mask); - Felt high = Felt((number >> 128) & mask); + final mask = BigInt.parse('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF', radix: 16); + final low = Felt(number & mask); + final high = Felt((number >> 128) & mask); return Uint256(low: low, high: high); } @@ -29,7 +32,8 @@ class Uint256 { return Uint256(low: list[0], high: list[1]); } else { throw Exception( - "Cannot parse felt list into Uint256; wrong length: ${list.length}"); + 'Cannot parse felt list into Uint256; wrong length: ${list.length}', + ); } } @@ -61,7 +65,8 @@ class Uint256 { factory Uint256.fromJson(Map json) { return Uint256( - low: Felt(BigInt.parse(json['low'])), - high: Felt(BigInt.parse(json['high']))); + low: Felt(BigInt.parse(json['low'] as String)), + high: Felt(BigInt.parse(json['high'] as String)), + ); } } diff --git a/packages/starknet/lib/src/util.dart b/packages/starknet/lib/src/util.dart index 34291522..fd6791cd 100644 --- a/packages/starknet/lib/src/util.dart +++ b/packages/starknet/lib/src/util.dart @@ -1,13 +1,14 @@ import 'dart:convert'; +import 'dart:io'; -import 'package:starknet/src/static_config.dart'; import 'package:starknet_provider/starknet_provider.dart'; +import 'static_config.dart'; import 'types/index.dart'; -prettyPrintJson(Map json) { - var encoder = JsonEncoder.withIndent(" "); - print(encoder.convert(json)); +void prettyPrintJson(Map json) { + const encoder = JsonEncoder.withIndent(' '); + stdout.writeln(encoder.convert(json)); } const _defaultInterval = Duration(seconds: 5); @@ -28,33 +29,27 @@ Future waitForState({ required List states, Duration interval = _defaultInterval, int maxRetries = _defaultMaxRetries, - Function(dynamic message)? debugLog, + void Function(dynamic message)? debugLog, }) async { - int count = 0; - bool done = false; - bool succeed = false; - String status = 'UNKNOWN'; + var count = 0; + var done = false; + var succeed = false; + var status = 'UNKNOWN'; final txHash = Felt.fromHexString(transactionHash); - while (done != true) { + while (!done) { final receipt = await provider.getTransactionReceipt(txHash); - print(receipt); + stdout.writeln(receipt); receipt.when( result: (result) { result.map( - declareTxnReceipt: (DeclareTxnReceipt receipt) => - status = receipt.execution_status, - deployTxnReceipt: (DeployTxnReceipt receipt) => - status = receipt.execution_status, - deployAccountTxnReceipt: (DeployAccountTxnReceipt receipt) => - status = receipt.execution_status, - l1HandlerTxnReceipt: (L1HandlerTxnReceipt receipt) => - status = receipt.execution_status, - pendingDeployTxnReceipt: (PendingDeployTxnReceipt receipt) => - status = 'PENDING', - pendingCommonReceiptProperties: - (PendingCommonReceiptProperties receipt) => status = 'PENDING', - invokeTxnReceipt: (InvokeTxnReceipt receipt) => + declareTxnReceipt: (receipt) => status = receipt.execution_status, + deployTxnReceipt: (receipt) => status = receipt.execution_status, + deployAccountTxnReceipt: (receipt) => status = receipt.execution_status, + l1HandlerTxnReceipt: (receipt) => status = receipt.execution_status, + pendingDeployTxnReceipt: (receipt) => status = 'PENDING', + pendingCommonReceiptProperties: (receipt) => status = 'PENDING', + invokeTxnReceipt: (receipt) => status = receipt.execution_status, ); }, error: (error) { @@ -75,7 +70,7 @@ Future waitForState({ count += 1; status = 'UNKNOWN'; debugLog?.call( - "Waiting for status of $transactionHash ($count / $maxRetries)", + 'Waiting for status of $transactionHash ($count / $maxRetries)', ); } else { done = true; @@ -107,7 +102,7 @@ Future waitForTransaction({ required JsonRpcProvider provider, Duration interval = _defaultInterval, int maxRetries = _defaultMaxRetries, - Function(dynamic message)? debugLog, + void Function(dynamic message)? debugLog, }) async { return waitForState( transactionHash: transactionHash, @@ -134,7 +129,7 @@ Future waitForAcceptance({ required Provider provider, Duration interval = _defaultInterval, int maxRetries = _defaultMaxRetries, - Function(dynamic message)? debugLog, + void Function(dynamic message)? debugLog, }) async { return waitForState( transactionHash: transactionHash, diff --git a/packages/starknet/pubspec.yaml b/packages/starknet/pubspec.yaml index e4afbfa3..eadf888c 100644 --- a/packages/starknet/pubspec.yaml +++ b/packages/starknet/pubspec.yaml @@ -1,24 +1,24 @@ name: starknet description: The Dart SDK to interact with any smart contracts on StarkNet version: 0.1.0 -repository: https://github.com/gabsn/starknet.dart +repository: https://github.com/focustree/starknet.dart environment: sdk: ">=2.17.3 <4.0.0" dependencies: - starknet_provider: bip32: ^2.0.0 bip39: ^1.0.6 - crypto: ^3.0.2 - freezed_annotation: ^2.0.3 - http: ^1.0.0 - json_annotation: ^4.5.0 - pointycastle: ^3.6.0 + crypto: ^3.0.5 + freezed_annotation: ^2.4.4 + http: ^1.2.2 + json_annotation: ^4.9.0 + pointycastle: ^3.9.1 + starknet_provider: ^1.0.0 dev_dependencies: - build_runner: ^2.1.11 - freezed: ^2.0.3+1 - json_serializable: ^6.2.0 - lints: ^2.0.0 - test: ^1.16.0 + build_runner: ^2.4.13 + freezed: ^2.5.7 + json_serializable: ^6.8.0 + lints: ^5.0.0 + test: ^1.25.8 diff --git a/packages/starknet/test/account_test.dart b/packages/starknet/test/account_test.dart index 0758bc44..8bc35a49 100644 --- a/packages/starknet/test/account_test.dart +++ b/packages/starknet/test/account_test.dart @@ -12,295 +12,387 @@ void main() { expect(nonce, equals(Felt.fromInt(0))); }); }); - group('declare cairo 0', () { - test('succeeds to declare a simple contract class hash', () async { - final balanceContract = await DeprecatedCompiledContract.fromPath( - '../../contracts/build/balance.json'); - final res = await account0.declare(compiledContract: balanceContract); - final txHash = res.when( - result: (result) { - expect( - result.classHash, - equals( - balanceClassHash, - ), - ); - expect(result.classHash, equals(Felt(balanceContract.classHash()))); - return result.transactionHash.toHexString(); - }, - error: (error) => fail(error.message), - ); - final txStatus = await waitForAcceptance( - transactionHash: txHash, - provider: account0.provider, - ); - expect(txStatus, equals(true)); - }); - test('succeeds to declare an openzeppelin contract class hash', () async { - final accountContract = await DeprecatedCompiledContract.fromPath( - '../../contracts/build/oz_account.json'); - final res = await account0.declare(compiledContract: accountContract); - final String txHash = res.when( - result: (result) { - expect(result.classHash, equals(Felt(accountContract.classHash()))); - return result.transactionHash.toHexString(); - }, - error: (error) => fail(error.message), - ); - final txStatus = await waitForAcceptance( - transactionHash: txHash, - provider: account0.provider, - ); - expect(txStatus, equals(true)); - }); - }, tags: ['integration'], skip: true); + group( + 'declare cairo 0', + () { + test('succeeds to declare a simple contract class hash', () async { + final balanceContract = await DeprecatedCompiledContract.fromPath( + '../../contracts/build/balance.json', + ); + final res = await account0.declare(compiledContract: balanceContract); + final txHash = res.when( + result: (result) { + expect( + result.classHash, + equals( + balanceClassHash, + ), + ); + expect( + result.classHash, + equals(Felt(balanceContract.classHash())), + ); + return result.transactionHash.toHexString(); + }, + error: (error) => fail(error.message), + ); + final txStatus = await waitForAcceptance( + transactionHash: txHash, + provider: account0.provider, + ); + expect(txStatus, equals(true)); + }); + test('succeeds to declare an openzeppelin contract class hash', + () async { + final accountContract = await DeprecatedCompiledContract.fromPath( + '../../contracts/build/oz_account.json', + ); + final res = await account0.declare(compiledContract: accountContract); + final txHash = res.when( + result: (result) { + expect( + result.classHash, + equals(Felt(accountContract.classHash())), + ); + return result.transactionHash.toHexString(); + }, + error: (error) => fail(error.message), + ); + final txStatus = await waitForAcceptance( + transactionHash: txHash, + provider: account0.provider, + ); + expect(txStatus, equals(true)); + }); + }, + tags: ['integration'], + skip: true, + ); - group('declare cairo 1', () { - test( - 'succeeds to declare a simple sierra contract with provided CASM file', - () async { - final sierraContract = await CompiledContract.fromPath( - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_sierra.txt'); - final compiledContract = await CASMCompiledContract.fromPath( - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_compiled.txt'); - final BigInt compiledClassHash = compiledContract.classHash(); - Felt sierraClassHash = Felt(sierraContract.classHash()); + group( + 'declare cairo 1', + () { + test( + 'succeeds to declare a simple sierra contract with provided CASM file', + () async { + final sierraContract = await CompiledContract.fromPath( + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_sierra.txt', + ); + final compiledContract = await CASMCompiledContract.fromPath( + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_compiled.txt', + ); + final compiledClassHash = compiledContract.classHash(); + final sierraClassHash = Felt(sierraContract.classHash()); - var res = await account0.declare( - compiledContract: sierraContract, - compiledClassHash: compiledClassHash, - ); - final txHash = res.when( - result: (result) { - expect( - result.classHash, - equals( - sierraClassHash, - ), - ); - return result.transactionHash.toHexString(); - }, - error: (error) => fail(error.message), - ); - final txStatus = await waitForAcceptance( - transactionHash: txHash, - provider: account0.provider, - ); - expect(txStatus, equals(true)); - // check if code is - (await account0.provider.getClass( - blockId: BlockId.blockTag('latest'), - classHash: sierraClassHash)) - .when( - result: (res) { - expect(res, isA()); - final contract = res as SierraContractClass; - expect( - contract.sierraProgram, - equals(sierraContract.contract.sierraProgram - .map((e) => Felt(e))), - ); - }, - error: (error) => fail("Shouldn't fail")); - }); - }, tags: ['integration'], skip: true); + final res = await account0.declare( + compiledContract: sierraContract, + compiledClassHash: compiledClassHash, + ); + final txHash = res.when( + result: (result) { + expect( + result.classHash, + equals( + sierraClassHash, + ), + ); + return result.transactionHash.toHexString(); + }, + error: (error) => fail(error.message), + ); + final txStatus = await waitForAcceptance( + transactionHash: txHash, + provider: account0.provider, + ); + expect(txStatus, equals(true)); + // check if code is + (await account0.provider.getClass( + blockId: BlockId.latest, + classHash: sierraClassHash, + )) + .when( + result: (res) { + expect(res, isA()); + final contract = res as SierraContractClass; + expect( + contract.sierraProgram, + equals( + sierraContract.contract.sierraProgram.map(Felt.new), + ), + ); + }, + error: (error) => fail("Shouldn't fail"), + ); + }); + }, + tags: ['integration'], + skip: true, + ); - group('deploy', () { - test('succeeds to deploy a cairo 0 contract', () async { - // Balance contract - final classHash = balanceClassHash; + group( + 'deploy', + () { + test('succeeds to deploy a cairo 0 contract', () async { + // Balance contract + final classHash = balanceClassHash; - final contractAddress = await account0 - .deploy(classHash: classHash, calldata: [Felt.fromInt(42)]); - expect(contractAddress, equals(balanceContractAddress)); - }); + final contractAddress = await account0 + .deploy(classHash: classHash, calldata: [Felt.fromInt(42)]); + expect(contractAddress, equals(balanceContractAddress)); + }); - test('succeeds to deploy a cairo 1 contract', () async { - final classHash = Felt.fromHexString( - "0x6d8ede036bb4720e6f348643221d8672bf4f0895622c32c11e57460b3b7dffc"); - final contractAddress = - await account0.deploy(classHash: classHash, calldata: [ - Felt.fromString("Starknet.dart"), - Felt.fromString("DART"), - Felt.fromInt(18), - Felt.fromInt(1000), - Felt.fromInt(0), - account0.accountAddress - ]); - expect( + test('succeeds to deploy a cairo 1 contract', () async { + final classHash = Felt.fromHexString( + '0x6d8ede036bb4720e6f348643221d8672bf4f0895622c32c11e57460b3b7dffc', + ); + final contractAddress = await account0.deploy( + classHash: classHash, + calldata: [ + Felt.fromString('Starknet.dart'), + Felt.fromString('DART'), + Felt.fromInt(18), + Felt.fromInt(1000), + Felt.fromInt(0), + account0.accountAddress, + ], + ); + expect( contractAddress, equals( Felt.fromHexString( - "0x53813135446812b36f67e5b363813df086d88544ce17c742376082b8e997e29", + '0x53813135446812b36f67e5b363813df086d88544ce17c742376082b8e997e29', ), - )); - print("Address $contractAddress"); - }); - test('succeeds to deploy an account', () async { - final accountPrivateKey = Felt.fromHexString("0x12345678"); - final accountPublicKey = Felt.fromHexString( - "0x47de619de131463cbf799d321b50c617566dc897d4be614fb3927eacd55d7ad"); - final accountConstructorCalldata = [accountPublicKey]; - final accountSigner = Signer(privateKey: accountPrivateKey); - final classHash = devnetOpenZeppelinAccountClassHash; - final maxFee = defaultMaxFee; - final provider = account0.provider; - // we have to compute account address to send token - final accountAddress = Contract.computeAddress( + ), + ); + print('Address $contractAddress'); + }); + test('succeeds to deploy an account', () async { + final accountPrivateKey = Felt.fromHexString('0x12345678'); + final accountPublicKey = Felt.fromHexString( + '0x47de619de131463cbf799d321b50c617566dc897d4be614fb3927eacd55d7ad', + ); + final accountConstructorCalldata = [accountPublicKey]; + final accountSigner = Signer(privateKey: accountPrivateKey); + final classHash = devnetOpenZeppelinAccountClassHash; + final maxFee = defaultMaxFee; + final provider = account0.provider; + // we have to compute account address to send token + final accountAddress = Contract.computeAddress( classHash: classHash, calldata: accountConstructorCalldata, - salt: Felt.fromInt(42)); + salt: Felt.fromInt(42), + ); - Felt accountClassHash = (await provider.getClassHashAt( - contractAddress: accountAddress, blockId: BlockId.latest)) - .when( - result: (result) => result, - error: ((error) => Felt.fromInt(0))); - expect(accountClassHash, equals(Felt.fromInt(0))); - // account address requires token to pay deploy fees - final txSend = await account0.send( + var accountClassHash = (await provider.getClassHashAt( + contractAddress: accountAddress, + blockId: BlockId.latest, + )) + .when( + result: (result) => result, + error: (error) => Felt.fromInt(0), + ); + expect(accountClassHash, equals(Felt.fromInt(0))); + // account address requires token to pay deploy fees + final txSend = await account0.send( recipient: accountAddress, - amount: Uint256(low: maxFee, high: Felt.fromInt(0))); - bool success = await waitForAcceptance( - transactionHash: txSend, provider: account0.provider); - expect(success, equals(true)); - final tx = await Account.deployAccount( + amount: Uint256(low: maxFee, high: Felt.fromInt(0)), + ); + final success = await waitForAcceptance( + transactionHash: txSend, + provider: account0.provider, + ); + expect(success, equals(true)); + final tx = await Account.deployAccount( classHash: accountClassHash, signer: accountSigner, provider: provider, constructorCalldata: accountConstructorCalldata, - maxFee: maxFee); - final contractAddress = tx.when( + max_fee: maxFee, + ); + final contractAddress = tx.when( result: (result) => result.contractAddress, error: (error) => - throw Exception("${error.code}: ${error.message}")); - expect(accountAddress, equals(contractAddress)); - accountClassHash = (await provider.getClassHashAt( - contractAddress: accountAddress, blockId: BlockId.latest)) - .when( - result: (result) => result, - error: ((error) => Felt.fromInt(0))); - expect(accountClassHash, equals(classHash)); - }); - // }, tags: ['integration']); - }, tags: ['integration'], skip: true); + throw Exception('${error.code}: ${error.message}'), + ); + expect(accountAddress, equals(contractAddress)); + accountClassHash = (await provider.getClassHashAt( + contractAddress: accountAddress, + blockId: BlockId.latest, + )) + .when( + result: (result) => result, + error: (error) => Felt.fromInt(0), + ); + expect(accountClassHash, equals(classHash)); + }); + // }, tags: ['integration']); + }, + tags: ['integration'], + skip: true, + ); - group('fee token', () { - test('get balance', () async { - final balance = await account1.balance(); - expect( + group( + 'fee token', + () { + test('get balance', () async { + final balance = await account1.balance(); + expect( balance, - equals(Uint256( - low: Felt(BigInt.parse("1000000000000000000000")), - high: Felt.fromInt(0)))); - }); - test('send', () async { - final previousBalance = await account1.balance(); - final txHash = await account0.send( + equals( + Uint256( + low: Felt(BigInt.parse('1000000000000000000000')), + high: Felt.fromInt(0), + ), + ), + ); + }); + test('send', () async { + final previousBalance = await account1.balance(); + final txHash = await account0.send( recipient: account1.accountAddress, - amount: Uint256(low: Felt.fromInt(100), high: Felt.fromInt(0))); - final success = await waitForAcceptance( - transactionHash: txHash, provider: account1.provider); - expect(success, equals(true)); - final newBalance = await account1.balance(); - final diffHigh = - newBalance.high.toBigInt() - previousBalance.high.toBigInt(); - final diffLow = - newBalance.low.toBigInt() - previousBalance.low.toBigInt(); - expect(diffHigh, equals(BigInt.from(0))); - expect(diffLow, equals(BigInt.from(100))); - }); + amount: Uint256(low: Felt.fromInt(100), high: Felt.fromInt(0)), + ); + final success = await waitForAcceptance( + transactionHash: txHash, + provider: account1.provider, + ); + expect(success, equals(true)); + final newBalance = await account1.balance(); + final diffHigh = + newBalance.high.toBigInt() - previousBalance.high.toBigInt(); + final diffLow = + newBalance.low.toBigInt() - previousBalance.low.toBigInt(); + expect(diffHigh, equals(BigInt.from(0))); + expect(diffLow, equals(BigInt.from(100))); + }); - test('send without enough amount', () async { - final previousBalance = await account1.balance(); - final txHash = await account0.send( + test('send without enough amount', () async { + final previousBalance = await account1.balance(); + final txHash = await account0.send( recipient: account1.accountAddress, - amount: Uint256(low: Felt.fromInt(0), high: Felt.fromInt(100))); - final success = await waitForAcceptance( - transactionHash: txHash, provider: account1.provider); - expect(success, equals(false)); - final newBalance = await account1.balance(); - expect(newBalance, equals(previousBalance)); - }); - }, tags: ['integration'], skip: true); + amount: Uint256(low: Felt.fromInt(0), high: Felt.fromInt(100)), + ); + final success = await waitForAcceptance( + transactionHash: txHash, + provider: account1.provider, + ); + expect(success, equals(false)); + final newBalance = await account1.balance(); + expect(newBalance, equals(previousBalance)); + }); + }, + tags: ['integration'], + skip: true, + ); - group('recovery from seed phrase', () { - final mnemonic = - "toward antenna indicate reject must artist expect angry fit easy cupboard require" - .split(" "); - final provider = JsonRpcProvider(nodeUri: devnetUri); - final chainId = StarknetChainId.testNet; - test('braavos account private key', () async { - Signer signer = - BraavosAccountDerivation(provider: provider, chainId: chainId) - .deriveSigner(mnemonic: mnemonic, index: 0); - expect( + group( + 'recovery from seed phrase', + () { + final mnemonic = + 'toward antenna indicate reject must artist expect angry fit easy cupboard require' + .split(' '); + final provider = JsonRpcProvider(nodeUri: devnetUri); + final chainId = StarknetChainId.testNet; + test('braavos account private key', () async { + var signer = + BraavosAccountDerivation(provider: provider, chainId: chainId) + .deriveSigner(mnemonic: mnemonic); + expect( signer.privateKey, - equals(Felt.fromHexString( - "0x079474858947854da7c14f19cb5d2edb39414d358a7da68b9436caff9dfb04a6"))); - signer = BraavosAccountDerivation(provider: provider, chainId: chainId) - .deriveSigner(mnemonic: mnemonic, index: 1); - expect( + equals( + Felt.fromHexString( + '0x079474858947854da7c14f19cb5d2edb39414d358a7da68b9436caff9dfb04a6', + ), + ), + ); + signer = + BraavosAccountDerivation(provider: provider, chainId: chainId) + .deriveSigner(mnemonic: mnemonic, index: 1); + expect( signer.privateKey, - equals(Felt.fromHexString( - "0x06b79a30ac27b1b29a559e84cfe538ea2a35e5460d58558d3d1cd8487a363633"))); - }); - test('braavos account public key', () async { - Signer signer = - BraavosAccountDerivation(provider: provider, chainId: chainId) - .deriveSigner(mnemonic: mnemonic, index: 0); - expect( + equals( + Felt.fromHexString( + '0x06b79a30ac27b1b29a559e84cfe538ea2a35e5460d58558d3d1cd8487a363633', + ), + ), + ); + }); + test('braavos account public key', () async { + var signer = + BraavosAccountDerivation(provider: provider, chainId: chainId) + .deriveSigner(mnemonic: mnemonic); + expect( signer.publicKey, - equals(Felt.fromHexString( - "0x04e633f0627b70c55eb53afdfd368c464f5767efe600e36157487bf988a2a106"))); - signer = BraavosAccountDerivation(provider: provider, chainId: chainId) - .deriveSigner(mnemonic: mnemonic, index: 1); - expect( + equals( + Felt.fromHexString( + '0x04e633f0627b70c55eb53afdfd368c464f5767efe600e36157487bf988a2a106', + ), + ), + ); + signer = + BraavosAccountDerivation(provider: provider, chainId: chainId) + .deriveSigner(mnemonic: mnemonic, index: 1); + expect( signer.publicKey, - equals(Felt.fromHexString( - "0x01ff0cdadb901570e76dc764dca53101b3c388203e0867243760d90494850d44", - ))); - }); - test('argentX account private key', () async { - final signer = ArgentXAccountDerivation() - .deriveSigner(mnemonic: mnemonic, index: 0); - expect( + equals( + Felt.fromHexString( + '0x01ff0cdadb901570e76dc764dca53101b3c388203e0867243760d90494850d44', + ), + ), + ); + }); + test('argentX account private key', () async { + final signer = + ArgentXAccountDerivation().deriveSigner(mnemonic: mnemonic); + expect( signer.privateKey, - equals(Felt.fromHexString( - "0x01c6e707d4a3528a29af0b613833e5154e311dc0aa076c41ff08d2e6e34f3d43", - ))); - }); - test('argentX account address', () async { - final signer = ArgentXAccountDerivation() - .deriveSigner(mnemonic: mnemonic, index: 0); - final accountAddress = ArgentXAccountDerivation() - .computeAddress(publicKey: signer.publicKey); - expect( + equals( + Felt.fromHexString( + '0x01c6e707d4a3528a29af0b613833e5154e311dc0aa076c41ff08d2e6e34f3d43', + ), + ), + ); + }); + test('argentX account address', () async { + final signer = + ArgentXAccountDerivation().deriveSigner(mnemonic: mnemonic); + final accountAddress = ArgentXAccountDerivation() + .computeAddress(publicKey: signer.publicKey); + expect( accountAddress, - equals(Felt.fromHexString( - "0x05035e828bf2d7332774d8a148ebad3f1f4ef67b314258cbfa8c1934baa5971b", - ))); - }); + equals( + Felt.fromHexString( + '0x05035e828bf2d7332774d8a148ebad3f1f4ef67b314258cbfa8c1934baa5971b', + ), + ), + ); + }); - test('Bug #178 error while computing public key', () async { - final mnemonic = - "rotate nice pattern oven twice upper defense exile squirrel gym script sight" - .split(" "); - final Felt privateKey = derivePrivateKey(mnemonic: mnemonic.join(' ')); - expect( + test('Bug #178 error while computing public key', () async { + final mnemonic = + 'rotate nice pattern oven twice upper defense exile squirrel gym script sight' + .split(' '); + final privateKey = derivePrivateKey(mnemonic: mnemonic.join(' ')); + expect( privateKey, equals( Felt.fromHexString( - "0xe2e4c6ab3d0942add52a707e16c844c1aa78e6c827b2e43070065a498e83bc"), - )); - final signer = Signer(privateKey: privateKey); - expect( + '0xe2e4c6ab3d0942add52a707e16c844c1aa78e6c827b2e43070065a498e83bc', + ), + ), + ); + final signer = Signer(privateKey: privateKey); + expect( signer.publicKey, equals( Felt.fromHexString( - "0x1537768ebeabb7b811c5eeb8e38d8bafc9c957051ff0f311abad2d608f29d53"), - )); - }); - }, tags: ['unit']); + '0x1537768ebeabb7b811c5eeb8e38d8bafc9c957051ff0f311abad2d608f29d53', + ), + ), + ); + }); + }, + tags: ['unit'], + ); }); } diff --git a/packages/starknet/test/contract/contract_test.dart b/packages/starknet/test/contract/contract_test.dart index 2bb28405..c194311c 100644 --- a/packages/starknet/test/contract/contract_test.dart +++ b/packages/starknet/test/contract/contract_test.dart @@ -4,139 +4,156 @@ import 'package:starknet/starknet.dart'; import 'package:test/test.dart'; void main() { - group('Contract', () { - group('Compiled contract (cairo 0)', () { - test('Compute class hash for contract without attributes', () async { - final contractPath = - '${Directory.current.path}/../../contracts/build/balance.json'; - final compiledContract = - await DeprecatedCompiledContract.fromPath(contractPath); - final classHash = compiledContract.classHash(); - expect( - classHash, - equals(balanceClassHash.toBigInt()), - ); - }); - test('Compute class hash for contract with attributes', () async { - final contractPath = - '${Directory.current.path}/../../contracts/build/oz_account.json'; - final compiledContract = - await DeprecatedCompiledContract.fromPath(contractPath); - final classHash = compiledContract.classHash(); - expect( - classHash, - equals(ozAccountClassHash.toBigInt()), - ); - }); - }, skip: true); + group( + 'Contract', + () { + group( + 'Compiled contract (cairo 0)', + () { + test('Compute class hash for contract without attributes', () async { + final contractPath = + '${Directory.current.path}/../../contracts/build/balance.json'; + final compiledContract = + await DeprecatedCompiledContract.fromPath(contractPath); + final classHash = compiledContract.classHash(); + expect( + classHash, + equals(balanceClassHash.toBigInt()), + ); + }); + test('Compute class hash for contract with attributes', () async { + final contractPath = + '${Directory.current.path}/../../contracts/build/oz_account.json'; + final compiledContract = + await DeprecatedCompiledContract.fromPath(contractPath); + final classHash = compiledContract.classHash(); + expect( + classHash, + equals(ozAccountClassHash.toBigInt()), + ); + }); + }, + skip: true, + ); - group('Compiled contract (cairo 1)', () { - test('Compute sierra class hash for ERC20 contract', () async { - final contractPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_sierra.txt'; - final expectedHashesPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20.hashes.json'; - final content = await File(expectedHashesPath).readAsString(); - final expectedHashes = await json.decode(content); - final contract = await CompiledContract.fromPath(contractPath); - final classHash = contract.classHash(); - expect( + group('Compiled contract (cairo 1)', () { + test('Compute sierra class hash for ERC20 contract', () async { + final contractPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_sierra.txt'; + final expectedHashesPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20.hashes.json'; + final content = await File(expectedHashesPath).readAsString(); + final expectedHashes = await json.decode(content) as Map; + final contract = await CompiledContract.fromPath(contractPath); + final classHash = contract.classHash(); + expect( classHash, equals( - BigInt.parse(expectedHashes["sierra_class_hash"]), - )); - }); + BigInt.parse(expectedHashes['sierra_class_hash'] as String), + ), + ); + }); - test('Compute sierra class hash for ABI types contract', () async { - final contractPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types_sierra.txt'; - final expectedHashesPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types.hashes.json'; - final content = await File(expectedHashesPath).readAsString(); - final expectedHashes = await json.decode(content); - final contract = await CompiledContract.fromPath(contractPath); - final classHash = contract.classHash(); - expect( + test('Compute sierra class hash for ABI types contract', () async { + final contractPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types_sierra.txt'; + final expectedHashesPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types.hashes.json'; + final content = await File(expectedHashesPath).readAsString(); + final expectedHashes = await json.decode(content) as Map; + final contract = await CompiledContract.fromPath(contractPath); + final classHash = contract.classHash(); + expect( classHash, equals( - BigInt.parse(expectedHashes["sierra_class_hash"]), - )); - }); + BigInt.parse(expectedHashes['sierra_class_hash'] as String), + ), + ); + }); - test('Compute compiled class hash for ERC20 contract', () async { - final contractPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_compiled.txt'; - final expectedHashesPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20.hashes.json'; - final content = await File(expectedHashesPath).readAsString(); - final expectedHashes = await json.decode(content); - final contract = await CASMCompiledContract.fromPath(contractPath); - final classHash = contract.classHash(); - expect( + test('Compute compiled class hash for ERC20 contract', () async { + final contractPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20_compiled.txt'; + final expectedHashesPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/erc20.hashes.json'; + final content = await File(expectedHashesPath).readAsString(); + final expectedHashes = await json.decode(content) as Map; + final contract = await CASMCompiledContract.fromPath(contractPath); + final classHash = contract.classHash(); + expect( classHash, equals( - BigInt.parse(expectedHashes["compiled_class_hash"]), - )); - }); + BigInt.parse(expectedHashes['compiled_class_hash'] as String), + ), + ); + }); - test('Compute compiled class hash for ABI types contract', () async { - final contractPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types_compiled.txt'; - final expectedHashesPath = - '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types.hashes.json'; - final content = await File(expectedHashesPath).readAsString(); - final expectedHashes = await json.decode(content); - final contract = await CASMCompiledContract.fromPath(contractPath); - final classHash = contract.classHash(); - expect( + test('Compute compiled class hash for ABI types contract', () async { + final contractPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types_compiled.txt'; + final expectedHashesPath = + '${Directory.current.path}/../../contracts/cairo1/artifacts/abi_types.hashes.json'; + final content = await File(expectedHashesPath).readAsString(); + final expectedHashes = await json.decode(content) as Map; + final contract = await CASMCompiledContract.fromPath(contractPath); + final classHash = contract.classHash(); + expect( classHash, equals( - BigInt.parse(expectedHashes["compiled_class_hash"]), - )); + BigInt.parse(expectedHashes['compiled_class_hash'] as String), + ), + ); + }); }); - }); - }, skip: true); + }, + skip: true, + ); - group('Contract address', () { - test('Compute contract address', () async { - // data are coming from starknet-rs - final salt = Felt.fromHexString( - "0x0018a7a329d1d85b621350f2b5fc9c64b2e57dfe708525f0aff2c90de1e5b9c8", - ); - final classHash = Felt.fromHexString( - "0x0750cd490a7cd1572411169eaa8be292325990d33c5d4733655fe6b926985062", - ); - final calldata = [Felt.fromInt(1)]; - final contractAddress = Contract.computeAddress( - classHash: classHash, - calldata: calldata, - salt: salt, - ); - expect( - contractAddress, - equals( - Felt.fromHexString( - "0x00da27ef7c3869c3a6cc6a0f7bf07a51c3e590825adba8a51cae27d815839eec", + group( + 'Contract address', + () { + test('Compute contract address', () async { + // data are coming from starknet-rs + final salt = Felt.fromHexString( + '0x0018a7a329d1d85b621350f2b5fc9c64b2e57dfe708525f0aff2c90de1e5b9c8', + ); + final classHash = Felt.fromHexString( + '0x0750cd490a7cd1572411169eaa8be292325990d33c5d4733655fe6b926985062', + ); + final calldata = [Felt.fromInt(1)]; + final contractAddress = Contract.computeAddress( + classHash: classHash, + calldata: calldata, + salt: salt, + ); + expect( + contractAddress, + equals( + Felt.fromHexString( + '0x00da27ef7c3869c3a6cc6a0f7bf07a51c3e590825adba8a51cae27d815839eec', + ), ), - ), - ); - }); + ); + }); - test('Compute account address', () async { - // devnet values - final salt = devnetAccountSalt; - final classHash = devnetAccountClassHash; - // devnet account#1 public key - final publicKey = devnetAccount1PublicKey; - final accountAddress = Contract.computeAddress( - classHash: classHash, - calldata: [publicKey], - salt: salt, - ); - expect( - accountAddress, - equals(devnetAccount1Address), - ); - }); - }, tags: ['unit'], skip: true); + test('Compute account address', () async { + // devnet values + final salt = devnetAccountSalt; + final classHash = devnetAccountClassHash; + // devnet account#1 public key + final publicKey = devnetAccount1PublicKey; + final accountAddress = Contract.computeAddress( + classHash: classHash, + calldata: [publicKey], + salt: salt, + ); + expect( + accountAddress, + equals(devnetAccount1Address), + ); + }); + }, + tags: ['unit'], + skip: true, + ); } diff --git a/packages/starknet/test/crypto/signature_test.dart b/packages/starknet/test/crypto/signature_test.dart index f7b0088d..4c4a2ca4 100644 --- a/packages/starknet/test/crypto/signature_test.dart +++ b/packages/starknet/test/crypto/signature_test.dart @@ -3,61 +3,97 @@ import 'package:test/test.dart'; import 'package:crypto/crypto.dart' as crypto; void main() { - group('generateK', () { - test('computes the right k value', () { - final privateKey = hexStringToBigInt( - '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79'); - final messageHash = hexStringToBigInt( - '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76'); - final k = generateK( + group( + 'generateK', + () { + test('computes the right k value', () { + final privateKey = hexStringToBigInt( + '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79', + ); + final messageHash = hexStringToBigInt( + '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76', + ); + final k = generateK( order: pedersenParams.ecOrder, privateKey: privateKey, hashFunction: crypto.sha256, - data: bigIntToBytes(messageHash)); - expect( + data: bigIntToBytes(messageHash), + ); + expect( k, - equals(hexStringToBigInt( - '0x326715c35f69882c04af9f70d37db977a57bf74252c0ecde0a8d01006bccb9f'))); - }); - }, tags: ['unit']); + equals( + hexStringToBigInt( + '0x326715c35f69882c04af9f70d37db977a57bf74252c0ecde0a8d01006bccb9f', + ), + ), + ); + }); + }, + tags: ['unit'], + ); group('starknet_generateK', () { - test('computes the right k value', () { - final k = starknet_generateK( + test( + 'computes the right k value', + () { + final k = starknetGenerateK( privateKey: hexStringToBigInt( - '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79'), + '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79', + ), messageHash: hexStringToBigInt( - '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76')); - expect( + '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76', + ), + ); + expect( k, - equals(hexStringToBigInt( - '0x738245b914bff42937b4cb377be9920abd5e8476e8998bfc74cb6cca4b9167f'))); - }, tags: ['unit']); + equals( + hexStringToBigInt( + '0x738245b914bff42937b4cb377be9920abd5e8476e8998bfc74cb6cca4b9167f', + ), + ), + ); + }, + tags: ['unit'], + ); test('computes the right k value with seed', () { - final k = starknet_generateK( - privateKey: BigInt.from(1234), - messageHash: BigInt.parse( - "2356066842316221201497701892898101048997905787746711569653082123202087193229"), - seed: BigInt.from(32)); + final k = starknetGenerateK( + privateKey: BigInt.from(1234), + messageHash: BigInt.parse( + '2356066842316221201497701892898101048997905787746711569653082123202087193229', + ), + seed: BigInt.from(32), + ); expect( - k, - equals(BigInt.parse( - "587135542530060539212175581789321092458737758169789380555529615008663266745"))); + k, + equals( + BigInt.parse( + '587135542530060539212175581789321092458737758169789380555529615008663266745', + ), + ), + ); }); }); - group('starknet_sign', () { - test('computes the right signature', () { - final privateKey = hexStringToBigInt( - '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79'); - final messageHash = hexStringToBigInt( - '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76'); - final expectedSignatureR = hexStringToBigInt( - '0x061ec782f76a66f6984efc3a1b6d152a124c701c00abdd2bf76641b4135c770f'); - final expectedSignatureS = hexStringToBigInt( - '0x4e44e759cea02c23568bb4d8a09929bbca8768ab68270d50c18d214166ccd9a'); - final signature = - starknet_sign(privateKey: privateKey, messageHash: messageHash); - expect(signature.r, equals(expectedSignatureR)); - expect(signature.s, equals(expectedSignatureS)); - }); - }, tags: ['unit']); + group( + 'starknet_sign', + () { + test('computes the right signature', () { + final privateKey = hexStringToBigInt( + '0x0139fe4d6f02e666e86a6f58e65060f115cd3c185bd9e98bd829636931458f79', + ); + final messageHash = hexStringToBigInt( + '0x06fea80189363a786037ed3e7ba546dad0ef7de49fccae0e31eb658b7dd4ea76', + ); + final expectedSignatureR = hexStringToBigInt( + '0x061ec782f76a66f6984efc3a1b6d152a124c701c00abdd2bf76641b4135c770f', + ); + final expectedSignatureS = hexStringToBigInt( + '0x4e44e759cea02c23568bb4d8a09929bbca8768ab68270d50c18d214166ccd9a', + ); + final signature = + starknetSign(privateKey: privateKey, messageHash: messageHash); + expect(signature.r, equals(expectedSignatureR)); + expect(signature.s, equals(expectedSignatureS)); + }); + }, + tags: ['unit'], + ); } diff --git a/packages/starknet/test/signer_test.dart b/packages/starknet/test/signer_test.dart index 83eab7a8..e2374ce5 100644 --- a/packages/starknet/test/signer_test.dart +++ b/packages/starknet/test/signer_test.dart @@ -7,11 +7,9 @@ class TestKeyPair { final Felt private; final Felt public; - TestKeyPair(this.private, this.public); - TestKeyPair.fromJson(Map json) - : private = Felt.fromHexString(json['private']), - public = Felt.fromHexString(json['public']); + : private = Felt.fromHexString(json['private'] as String), + public = Felt.fromHexString(json['public'] as String); } void main() { @@ -26,14 +24,14 @@ void main() { transactions: [ FunctionCall( contractAddress: Felt.fromHexString( - "0x033233531959c1da39c28daf337e25e2deadda80ce988290306ffabcd735ccbd", + '0x033233531959c1da39c28daf337e25e2deadda80ce988290306ffabcd735ccbd', ), - entryPointSelector: getSelectorByName("mint"), + entryPointSelector: getSelectorByName('mint'), calldata: [], - ) + ), ], contractAddress: Felt.fromIntString( - "219128243976675829890319084714200810078954121337483207856443222019910998953", + '219128243976675829890319084714200810078954121337483207856443222019910998953', ), version: 0, nonce: defaultNonce, @@ -44,11 +42,11 @@ void main() { signature, equals([ Felt.fromIntString( - "107701415394463892922670165541267022802175117514579709928775579816864470554", + '107701415394463892922670165541267022802175117514579709928775579816864470554', ), Felt.fromIntString( - "1904177602932261497361499193520322287574011759183225218778227195148991255212", - ) + '1904177602932261497361499193520322287574011759183225218778227195148991255212', + ), ]), ); }); @@ -56,7 +54,7 @@ void main() { group('Public key', () { test('returns the correct public key for given a private key', () { - final keyPairsJson = ''' + const keyPairsJson = ''' [ { "public": "0x7e52885445756b313ea16849145363ccb73fb4ab0440dbac333cf9d13de82b9", @@ -96,9 +94,9 @@ void main() { '''; final keyPairs = List.from( (json.decode(keyPairsJson) as List) - .map((e) => TestKeyPair.fromJson(e)), + .map((e) => TestKeyPair.fromJson(e as Map)), ); - for (var e in keyPairs) { + for (final e in keyPairs) { final signer = Signer(privateKey: e.private); expect(signer.publicKey, equals(e.public)); } diff --git a/packages/starknet_builder/.gitignore b/packages/starknet_builder/.gitignore deleted file mode 100644 index 2c02dba4..00000000 --- a/packages/starknet_builder/.gitignore +++ /dev/null @@ -1 +0,0 @@ -test/integration/*.g.dart diff --git a/packages/starknet_builder/LICENSE b/packages/starknet_builder/LICENSE deleted file mode 100644 index aa23ab26..00000000 --- a/packages/starknet_builder/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -MIT License - -Copyright (c) 2022 Gabin Marignier - -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. diff --git a/packages/starknet_builder/README.md b/packages/starknet_builder/README.md deleted file mode 100644 index 4cd2ecc7..00000000 --- a/packages/starknet_builder/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# starknet_builder - -A package to ease interact with a [starknet](http://starknet.io) contract in your application. - -This package provide several builders to generate Dart code from a starknet contract ABI. - -## Supported features - -| Feature | Cairo 0 (legacy) | Cairo 1 | Cairo 2 | -|--------------|--------------------|--------------------|--------------------| -| call | :white_check_mark: | :white_check_mark: | :x: | -| invoke | :white_check_mark: | :white_check_mark: | :x: | -| core types | :white_check_mark: | :construction: | :x: | -| custom types | :white_check_mark: | :construction: | :x: | -| event | :x: | :x: | :x: | - diff --git a/packages/starknet_builder/build.yaml b/packages/starknet_builder/build.yaml deleted file mode 100644 index f4180189..00000000 --- a/packages/starknet_builder/build.yaml +++ /dev/null @@ -1,8 +0,0 @@ -builders: - contract_generator: - import: "package:starknet_builder/src/builder.dart" - builder_factories: ["contractGenerator", "legacyContractGenerator"] - build_extensions: {".abi.json": [".g.dart"], ".sierra.json": [".sierra.g.dart"]} - auto_apply: root_package - build_to: source - diff --git a/packages/starknet_builder/dart_test.yaml b/packages/starknet_builder/dart_test.yaml deleted file mode 100644 index 0f89fd7c..00000000 --- a/packages/starknet_builder/dart_test.yaml +++ /dev/null @@ -1,2 +0,0 @@ -tags: - unit: diff --git a/packages/starknet_builder/lib/src/builder.dart b/packages/starknet_builder/lib/src/builder.dart deleted file mode 100644 index 81fb1c85..00000000 --- a/packages/starknet_builder/lib/src/builder.dart +++ /dev/null @@ -1,7 +0,0 @@ -import 'package:build/build.dart'; -import 'generator.dart'; -import 'legacy_generator.dart'; - -Builder contractGenerator(BuilderOptions options) => const ContractGenerator(); -Builder legacyContractGenerator(BuilderOptions options) => - const LegacyContractGenerator(); diff --git a/packages/starknet_builder/lib/src/examples/balance.abi.json b/packages/starknet_builder/lib/src/examples/balance.abi.json deleted file mode 100644 index 4d65fcee..00000000 --- a/packages/starknet_builder/lib/src/examples/balance.abi.json +++ /dev/null @@ -1,190 +0,0 @@ -[ - { - "members": [ - { - "name": "amount", - "offset": 0, - "type": "Uint256" - }, - { - "name": "id", - "offset": 2, - "type": "felt" - } - ], - "name": "MyAccount", - "size": 3, - "type": "struct" - }, - { - "members": [ - { - "name": "low", - "offset": 0, - "type": "felt" - }, - { - "name": "high", - "offset": 1, - "type": "felt" - } - ], - "name": "Uint256", - "size": 2, - "type": "struct" - }, - { - "inputs": [ - { - "name": "answer_", - "type": "felt" - } - ], - "name": "constructor", - "outputs": [], - "type": "constructor" - }, - { - "inputs": [ - { - "name": "amount", - "type": "felt" - } - ], - "name": "increase_balance", - "outputs": [], - "type": "function" - }, - { - "inputs": [], - "name": "get_balance", - "outputs": [ - { - "name": "balance", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "get_answer", - "outputs": [ - { - "name": "answer", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "a", - "type": "felt" - }, - { - "name": "b", - "type": "felt" - } - ], - "name": "sum", - "outputs": [ - { - "name": "sum", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "a_len", - "type": "felt" - }, - { - "name": "a", - "type": "felt*" - } - ], - "name": "copy_array", - "outputs": [ - { - "name": "b_len", - "type": "felt" - }, - { - "name": "b", - "type": "felt*" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "id", - "type": "felt" - } - ], - "name": "multiple_outputs", - "outputs": [ - { - "name": "account", - "type": "MyAccount" - }, - { - "name": "total", - "type": "Uint256" - }, - { - "name": "ref", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "a_len", - "type": "felt" - }, - { - "name": "a", - "type": "felt*" - }, - { - "name": "id", - "type": "felt" - } - ], - "name": "multiple_outputs_with_array", - "outputs": [ - { - "name": "id", - "type": "felt" - }, - { - "name": "b_len", - "type": "felt" - }, - { - "name": "b", - "type": "felt*" - }, - { - "name": "answer", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/packages/starknet_builder/lib/src/examples/balance.g.dart b/packages/starknet_builder/lib/src/examples/balance.g.dart deleted file mode 100644 index 3027e230..00000000 --- a/packages/starknet_builder/lib/src/examples/balance.g.dart +++ /dev/null @@ -1,247 +0,0 @@ -// Generated code, do not modify. Run `build_runner build` to re-generate! - -import 'package:starknet/starknet.dart'; - -class MyAccount { - MyAccount({ - required Uint256 this.amount, - required Felt this.id, - }); - - factory MyAccount.fromCallData(List callData) { - final amount = Uint256.fromCallData(callData.sublist(0)); - final id = callData[2]; - return MyAccount( - amount: amount, - id: id, - ); - } - - Uint256 amount; - - Felt id; - - List toCallData() { - List ret = List.filled( - 2, - Felt.fromInt(0), - ); - ret[2] = id; - return ret; - } - - String toString() { - return 'MyAccount(amount: $amount, id: $id, )'; - } -} - -class Uint256 { - Uint256({ - required Felt this.low, - required Felt this.high, - }); - - factory Uint256.fromCallData(List callData) { - final low = callData[0]; - final high = callData[1]; - return Uint256( - low: low, - high: high, - ); - } - - Felt low; - - Felt high; - - List toCallData() { - List ret = List.filled( - 2, - Felt.fromInt(0), - ); - ret[0] = low; - ret[1] = high; - return ret; - } - - String toString() { - return 'Uint256(low: $low, high: $high, )'; - } -} - -class MultipleOutputsResult { - MultipleOutputsResult({ - required MyAccount this.account, - required Uint256 this.total, - required Felt this.ref, - }); - - factory MultipleOutputsResult.fromCallData(List callData) { - int offset = 0; - final account = MyAccount.fromCallData(callData.sublist(offset)); - offset = offset + 3; - final total = Uint256.fromCallData(callData.sublist(offset)); - offset = offset + 2; - final ref = callData[offset]; - offset = offset + 1; - return MultipleOutputsResult( - account: account, - total: total, - ref: ref, - ); - } - - MyAccount account; - - Uint256 total; - - Felt ref; - - String toString() { - return 'MultipleOutputsResult(account: $account, total: $total, ref: $ref, )'; - } -} - -class MultipleOutputsWithArrayResult { - MultipleOutputsWithArrayResult({ - required Felt this.id, - required List this.b, - required Felt this.answer, - }); - - factory MultipleOutputsWithArrayResult.fromCallData(List callData) { - int offset = 0; - int _tmpSize = 0; - final id = callData[offset]; - offset = offset + 1; - _tmpSize = callData[offset].toInt(); - final b = callData - .sublist( - offset, - offset + _tmpSize + 1, - ) - .fromCallData(); - offset = offset + _tmpSize + 1; - final answer = callData[offset]; - offset = offset + 1; - return MultipleOutputsWithArrayResult( - id: id, - b: b, - answer: answer, - ); - } - - Felt id; - - List b; - - Felt answer; - - String toString() { - return 'MultipleOutputsWithArrayResult(id: $id, b: $b, answer: $answer, )'; - } -} - -class Balance { - Balance({ - required account, - required address, - }) : _contract = Contract( - account: account, - address: address, - ); - - final Contract _contract; - - Future get_balance() async { - final List params = []; - final res = await _contract.call( - 'get_balance', - params, - ); - return res[0]; - } - - Future get_answer() async { - final List params = []; - final res = await _contract.call( - 'get_answer', - params, - ); - return res[0]; - } - - Future sum( - Felt a, - Felt b, - ) async { - final List params = [ - a, - b, - ]; - final res = await _contract.call( - 'sum', - params, - ); - return res[0]; - } - - Future> copy_array(List a) async { - final List params = [...a.toCallData()]; - final res = await _contract.call( - 'copy_array', - params, - ); - return res.fromCallData(); - } - - Future multiple_outputs(Felt id) async { - final List params = [id]; - final res = await _contract.call( - 'multiple_outputs', - params, - ); - return MultipleOutputsResult.fromCallData(res); - } - - Future multiple_outputs_with_array( - List a, - Felt id, - ) async { - final List params = [ - ...a.toCallData(), - id, - ]; - final res = await _contract.call( - 'multiple_outputs_with_array', - params, - ); - return MultipleOutputsWithArrayResult.fromCallData(res); - } - - Future increase_balance(Felt amount) async { - final List params = [amount]; - final trx = await _contract.execute( - 'increase_balance', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } -} - -extension on List { - List toCallData() { - return [ - Felt.fromInt(this.length), - ...this, - ]; - } - - List fromCallData() { - return this.sublist(1); - } -} diff --git a/packages/starknet_builder/lib/src/examples/check_balance.dart b/packages/starknet_builder/lib/src/examples/check_balance.dart deleted file mode 100644 index 64ddd751..00000000 --- a/packages/starknet_builder/lib/src/examples/check_balance.dart +++ /dev/null @@ -1,71 +0,0 @@ -import 'package:starknet/starknet.dart'; -import 'package:starknet_provider/starknet_provider.dart'; -import './balance.g.dart'; - -class AccountSetup { - final Felt privateKey; - final String accountAddress; - final AccountSupportedTxVersion supportedTxVersion; - - AccountSetup({ - required this.privateKey, - required this.accountAddress, - required this.supportedTxVersion, - }); -} - -final accountDevnet = AccountSetup( - privateKey: Felt(BigInt.parse("302934307671667531413257853548643485645")), - accountAddress: - "0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a", - supportedTxVersion: AccountSupportedTxVersion.v1, -); - -void main() async { - final accountSetup = accountDevnet; - final privateKey = accountSetup.privateKey; - final accountAddress = Felt.fromHexString(accountSetup.accountAddress); - final balanceAddress = Felt.fromHexString( - "0x795595609782473a2836b4bf554431c84593935fddd9d15b4ba552063d82f21"); - final nodeUri = devnetUri; - - final provider = JsonRpcProvider(nodeUri: nodeUri); - final signer = Signer(privateKey: privateKey); - - final account = Account( - accountAddress: accountAddress, - provider: provider, - signer: signer, - chainId: StarknetChainId.testNet, - supportedTxVersion: accountSetup.supportedTxVersion, - ); - - final contract = Balance(account: account, address: balanceAddress); - final balance = await contract.get_balance(); - print('Balance: $balance'); - final answer = await contract.get_answer(); - print('Answer: $answer'); - final sum = await contract.sum(Felt.fromInt(2), Felt.fromInt(4)); - print('Answer sum: $sum'); - final trxHash = await contract.increase_balance(Felt.fromInt(5)); - var accepted = await waitForAcceptance( - transactionHash: trxHash, - provider: provider, - ); - print(accepted ? '$trxHash accepted' : '$trxHash not accepted'); - final new_balance = await contract.get_balance(); - print('Balance: $new_balance'); - - List my_array = List.generate(5, (index) => Felt.fromInt(index)); - final check_array = await contract.copy_array(my_array); - print(check_array); - - final check_multi = await contract.multiple_outputs(Felt.fromInt(4)); - print(check_multi); - - final check_multi_with_output = await contract.multiple_outputs_with_array( - [1, 2, 3, 4].map((e) => Felt.fromInt(e)).toList(), - Felt.fromInt(66), - ); - print(check_multi_with_output); -} diff --git a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.abi.json b/packages/starknet_builder/lib/src/examples/erc20_upgradeable.abi.json deleted file mode 100644 index f7cfdb01..00000000 --- a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.abi.json +++ /dev/null @@ -1,315 +0,0 @@ -[ - { - "members": [ - { - "name": "low", - "offset": 0, - "type": "felt" - }, - { - "name": "high", - "offset": 1, - "type": "felt" - } - ], - "name": "Uint256", - "size": 2, - "type": "struct" - }, - { - "data": [ - { - "name": "from_", - "type": "felt" - }, - { - "name": "to", - "type": "felt" - }, - { - "name": "value", - "type": "Uint256" - } - ], - "keys": [], - "name": "Transfer", - "type": "event" - }, - { - "data": [ - { - "name": "owner", - "type": "felt" - }, - { - "name": "spender", - "type": "felt" - }, - { - "name": "value", - "type": "Uint256" - } - ], - "keys": [], - "name": "Approval", - "type": "event" - }, - { - "data": [ - { - "name": "implementation", - "type": "felt" - } - ], - "keys": [], - "name": "Upgraded", - "type": "event" - }, - { - "data": [ - { - "name": "previousAdmin", - "type": "felt" - }, - { - "name": "newAdmin", - "type": "felt" - } - ], - "keys": [], - "name": "AdminChanged", - "type": "event" - }, - { - "inputs": [ - { - "name": "name", - "type": "felt" - }, - { - "name": "symbol", - "type": "felt" - }, - { - "name": "decimals", - "type": "felt" - }, - { - "name": "initial_supply", - "type": "Uint256" - }, - { - "name": "recipient", - "type": "felt" - }, - { - "name": "proxy_admin", - "type": "felt" - } - ], - "name": "initializer", - "outputs": [], - "type": "function" - }, - { - "inputs": [ - { - "name": "new_implementation", - "type": "felt" - } - ], - "name": "upgrade", - "outputs": [], - "type": "function" - }, - { - "inputs": [], - "name": "name", - "outputs": [ - { - "name": "name", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "symbol", - "outputs": [ - { - "name": "symbol", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "totalSupply", - "outputs": [ - { - "name": "totalSupply", - "type": "Uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [], - "name": "decimals", - "outputs": [ - { - "name": "decimals", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "account", - "type": "felt" - } - ], - "name": "balanceOf", - "outputs": [ - { - "name": "balance", - "type": "Uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "owner", - "type": "felt" - }, - { - "name": "spender", - "type": "felt" - } - ], - "name": "allowance", - "outputs": [ - { - "name": "remaining", - "type": "Uint256" - } - ], - "stateMutability": "view", - "type": "function" - }, - { - "inputs": [ - { - "name": "recipient", - "type": "felt" - }, - { - "name": "amount", - "type": "Uint256" - } - ], - "name": "transfer", - "outputs": [ - { - "name": "success", - "type": "felt" - } - ], - "type": "function" - }, - { - "inputs": [ - { - "name": "sender", - "type": "felt" - }, - { - "name": "recipient", - "type": "felt" - }, - { - "name": "amount", - "type": "Uint256" - } - ], - "name": "transferFrom", - "outputs": [ - { - "name": "success", - "type": "felt" - } - ], - "type": "function" - }, - { - "inputs": [ - { - "name": "spender", - "type": "felt" - }, - { - "name": "amount", - "type": "Uint256" - } - ], - "name": "approve", - "outputs": [ - { - "name": "success", - "type": "felt" - } - ], - "type": "function" - }, - { - "inputs": [ - { - "name": "spender", - "type": "felt" - }, - { - "name": "added_value", - "type": "Uint256" - } - ], - "name": "increaseAllowance", - "outputs": [ - { - "name": "success", - "type": "felt" - } - ], - "type": "function" - }, - { - "inputs": [ - { - "name": "spender", - "type": "felt" - }, - { - "name": "subtracted_value", - "type": "Uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "name": "success", - "type": "felt" - } - ], - "type": "function" - } -] diff --git a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.dart b/packages/starknet_builder/lib/src/examples/erc20_upgradeable.dart deleted file mode 100644 index 7a7bfed1..00000000 --- a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.dart +++ /dev/null @@ -1,135 +0,0 @@ -import 'package:starknet/starknet.dart' hide Uint256, ERC20; -import 'package:starknet_provider/starknet_provider.dart'; -import './erc20_upgradeable.g.dart'; - -class AccountSetup { - final Felt privateKey; - final String accountAddress; - final AccountSupportedTxVersion supportedTxVersion; - - AccountSetup({ - required this.privateKey, - required this.accountAddress, - required this.supportedTxVersion, - }); -} - -class TestSetup { - final String erc20Address; - final String walletAddress; - final Uri nodeUri; - - TestSetup({ - required this.erc20Address, - required this.walletAddress, - required this.nodeUri, - }); -} - -final accountV0Testnet = AccountSetup( - privateKey: Felt.fromInt(1234), - accountAddress: - "0x32d5c7a7953996056caf92ff4dd83f01ad72a3c418c05f15eb2f472d1e9c9f2", - // ignore: deprecated_member_use - supportedTxVersion: AccountSupportedTxVersion.v0, -); - -final accountV1Testnet = AccountSetup( - privateKey: Felt(BigInt.parse( - "888585928659514599423272828715188693704171690573707019357972128231005959671")), - accountAddress: - "0x04FF446995457B7Cd0E0A54De94426E27CB253F556fE3a2025304Ba4FD5D60D0", - supportedTxVersion: AccountSupportedTxVersion.v1, -); -final accountDevnet = AccountSetup( - privateKey: Felt(BigInt.parse("302934307671667531413257853548643485645")), - accountAddress: - "0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a", - supportedTxVersion: AccountSupportedTxVersion.v1, -); - -final testnetSetup = TestSetup( - erc20Address: - "0x4e76f8708774c8162fb4da7abefb3cae94cc51cf3f9b40e0d44f24aabf8a521", - walletAddress: - "0x04FF446995457B7Cd0E0A54De94426E27CB253F556fE3a2025304Ba4FD5D60D0", - nodeUri: infuraGoerliTestnetUri, -); - -final devnetSetup = TestSetup( - erc20Address: - "0x682aee6f493bbb100b255710d4e7a307022decb216092709ee495bc7b65bab0", - walletAddress: - "0x7e00d496e324876bbc8531f2d9a82bf154d1a04a50218ee74cdd372f75a551a", - nodeUri: devnetUri, -); -void main() async { - final accountSetup = accountDevnet; - final networkSetup = devnetSetup; - final privateKey = accountSetup.privateKey; - final accountAddress = Felt.fromHexString(accountSetup.accountAddress); - final erc20Address = Felt.fromHexString(networkSetup.erc20Address); - final walletAddress = Felt.fromHexString(networkSetup.walletAddress); - final nodeUri = networkSetup.nodeUri; - - final provider = JsonRpcProvider(nodeUri: nodeUri); - - final signer = Signer(privateKey: privateKey); - - final account = Account( - provider: provider, - signer: signer, - accountAddress: accountAddress, - chainId: StarknetChainId.testNet, - supportedTxVersion: accountSetup.supportedTxVersion, - ); - - final erc20 = Erc20_upgradeable(account: account, address: erc20Address); - - Future account_balance(Felt account) async { - final balance = await erc20.balanceOf(account); - print('Balance of ${account.toHexString()}: $balance'); - return balance; - } - - final name = await erc20.name(); - print('Name: $name'); - - final symbol = await erc20.symbol(); - print('Symbol: $symbol'); - - final supply = await erc20.totalSupply(); - print('Supply: $supply'); - - await account_balance(walletAddress); - await account_balance(accountAddress); - - var allowance = await erc20.allowance(accountAddress, walletAddress); - print('Allowance: $allowance'); - - var trx = await erc20.transfer( - walletAddress, - Uint256(low: Felt.fromInt(2), high: Felt.fromInt(0)), - ); - print('Transfer Transaction: $trx'); - var accepted = await waitForAcceptance( - transactionHash: trx, - provider: provider, - ); - print(accepted ? '$trx accepted' : '$trx not accepted'); - await account_balance(walletAddress); - - final new_allowance = Felt(allowance.low.toBigInt() + BigInt.from(1)); - trx = await erc20.approve( - walletAddress, - Uint256(low: new_allowance, high: Felt.fromInt(0)), - ); - print('Approve transaction: $trx'); - accepted = await waitForAcceptance( - transactionHash: trx, - provider: provider, - ); - print(accepted ? '$trx accepted' : '$trx not accepted'); - allowance = await erc20.allowance(accountAddress, walletAddress); - print('Allowance: $allowance'); -} diff --git a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.g.dart b/packages/starknet_builder/lib/src/examples/erc20_upgradeable.g.dart deleted file mode 100644 index 72fc3a27..00000000 --- a/packages/starknet_builder/lib/src/examples/erc20_upgradeable.g.dart +++ /dev/null @@ -1,247 +0,0 @@ -// Generated code, do not modify. Run `build_runner build` to re-generate! -// ignore_for_file: unused_element - -import 'package:starknet/starknet.dart'; - -class Uint256 { - Uint256({ - required Felt this.low, - required Felt this.high, - }); - - factory Uint256.fromCallData(List callData) { - final low = callData[0]; - final high = callData[1]; - return Uint256( - low: low, - high: high, - ); - } - - Felt low; - - Felt high; - - List toCallData() { - List ret = List.filled( - 2, - Felt.fromInt(0), - ); - ret[0] = low; - ret[1] = high; - return ret; - } - - String toString() { - return 'Uint256(low: $low, high: $high, )'; - } -} - -class Erc20_upgradeable { - Erc20_upgradeable({ - required account, - required address, - }) : _contract = Contract( - account: account, - address: address, - ); - - final Contract _contract; - - Future name() async { - final List params = []; - final res = await _contract.call( - 'name', - params, - ); - return res[0]; - } - - Future symbol() async { - final List params = []; - final res = await _contract.call( - 'symbol', - params, - ); - return res[0]; - } - - Future totalSupply() async { - final List params = []; - final res = await _contract.call( - 'totalSupply', - params, - ); - return Uint256.fromCallData(res); - } - - Future decimals() async { - final List params = []; - final res = await _contract.call( - 'decimals', - params, - ); - return res[0]; - } - - Future balanceOf(Felt account) async { - final List params = [account]; - final res = await _contract.call( - 'balanceOf', - params, - ); - return Uint256.fromCallData(res); - } - - Future allowance( - Felt owner, - Felt spender, - ) async { - final List params = [ - owner, - spender, - ]; - final res = await _contract.call( - 'allowance', - params, - ); - return Uint256.fromCallData(res); - } - - Future initializer( - Felt name, - Felt symbol, - Felt decimals, - Uint256 initial_supply, - Felt recipient, - Felt proxy_admin, - ) async { - final List params = [ - name, - symbol, - decimals, - ...initial_supply.toCallData(), - recipient, - proxy_admin, - ]; - final trx = await _contract.execute( - 'initializer', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future upgrade(Felt new_implementation) async { - final List params = [new_implementation]; - final trx = await _contract.execute( - 'upgrade', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future transfer( - Felt recipient, - Uint256 amount, - ) async { - final List params = [ - recipient, - ...amount.toCallData(), - ]; - final trx = await _contract.execute( - 'transfer', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future transferFrom( - Felt sender, - Felt recipient, - Uint256 amount, - ) async { - final List params = [ - sender, - recipient, - ...amount.toCallData(), - ]; - final trx = await _contract.execute( - 'transferFrom', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future approve( - Felt spender, - Uint256 amount, - ) async { - final List params = [ - spender, - ...amount.toCallData(), - ]; - final trx = await _contract.execute( - 'approve', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future increaseAllowance( - Felt spender, - Uint256 added_value, - ) async { - final List params = [ - spender, - ...added_value.toCallData(), - ]; - final trx = await _contract.execute( - 'increaseAllowance', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } - - Future decreaseAllowance( - Felt spender, - Uint256 subtracted_value, - ) async { - final List params = [ - spender, - ...subtracted_value.toCallData(), - ]; - final trx = await _contract.execute( - 'decreaseAllowance', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } -} diff --git a/packages/starknet_builder/lib/src/examples/udc.abi.json b/packages/starknet_builder/lib/src/examples/udc.abi.json deleted file mode 100644 index 31c96323..00000000 --- a/packages/starknet_builder/lib/src/examples/udc.abi.json +++ /dev/null @@ -1,69 +0,0 @@ -[ - { - "data": [ - { - "name": "address", - "type": "felt" - }, - { - "name": "deployer", - "type": "felt" - }, - { - "name": "unique", - "type": "felt" - }, - { - "name": "classHash", - "type": "felt" - }, - { - "name": "calldata_len", - "type": "felt" - }, - { - "name": "calldata", - "type": "felt*" - }, - { - "name": "salt", - "type": "felt" - } - ], - "keys": [], - "name": "ContractDeployed", - "type": "event" - }, - { - "inputs": [ - { - "name": "classHash", - "type": "felt" - }, - { - "name": "salt", - "type": "felt" - }, - { - "name": "unique", - "type": "felt" - }, - { - "name": "calldata_len", - "type": "felt" - }, - { - "name": "calldata", - "type": "felt*" - } - ], - "name": "deployContract", - "outputs": [ - { - "name": "address", - "type": "felt" - } - ], - "type": "function" - } -] diff --git a/packages/starknet_builder/lib/src/examples/udc.g.dart b/packages/starknet_builder/lib/src/examples/udc.g.dart deleted file mode 100644 index fd42267d..00000000 --- a/packages/starknet_builder/lib/src/examples/udc.g.dart +++ /dev/null @@ -1,47 +0,0 @@ -// Generated code, do not modify. Run `build_runner build` to re-generate! -// ignore_for_file: unused_element - -import 'package:starknet/starknet.dart'; - -class Udc extends Contract { - Udc({ - required super.account, - required super.address, - }); - - Future deployContract( - Felt classHash, - Felt salt, - Felt unique, - List calldata, - ) async { - final List params = [ - classHash, - salt, - unique, - ...calldata.toCallData(), - ]; - final trx = await super.execute( - 'deployContract', - params, - ); - final trxHash = trx.when( - result: (result) => result.transaction_hash, - error: (error) => throw Exception, - ); - return trxHash; - } -} - -extension on List { - List toCallData() { - return [ - Felt.fromInt(this.length), - ...this, - ]; - } - - List fromCallData() { - return this.sublist(1); - } -} diff --git a/packages/starknet_builder/lib/src/generator.dart b/packages/starknet_builder/lib/src/generator.dart deleted file mode 100644 index caad4dde..00000000 --- a/packages/starknet_builder/lib/src/generator.dart +++ /dev/null @@ -1,426 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:build/build.dart'; -import 'package:code_builder/code_builder.dart'; -import 'package:dart_style/dart_style.dart'; -import 'package:path/path.dart'; - -import 'package:starknet/starknet.dart'; - -final CALL_DATA_VAR = "callData"; -final CALL_DATA_TYPE = refer('List'); -final TO_CALL_DATA = "toCallData"; -final FROM_CALL_DATA = "fromCallData"; - -final CONTRACT_FIELD_VAR = "_contract"; -final CONTRACT_FIELD = refer(CONTRACT_FIELD_VAR); -final CONTRACT_FIELD_TYPE = refer("Contract"); -final CONTRACT_METHOD_CALL = "call"; -final CONTRACT_METHOD_EXECUTE = "execute"; - -class ContractGenerator implements Builder { - const ContractGenerator(); - @override - FutureOr build(BuildStep buildStep) async { - // Each [buildStep] has a single input. - final inputId = buildStep.inputId; - final withoutExtension = - inputId.path.substring(0, inputId.path.length - '.sierra.json'.length); - - final source = await buildStep.readAsString(inputId); - - // ABI is provided as a JSON - final List abi = jsonDecode(source); - - final outputId = AssetId(inputId.package, - inputId.path.replaceFirst(".sierra.json", ".sierra.g.dart")); - final library = - _ContractAbiGenerator(abi, _suggestName(withoutExtension)).generate(); - final emitter = DartEmitter( - allocator: Allocator.simplePrefixing(), useNullSafetySyntax: true); - final output = ''' -// Generated code, do not modify. Run `build_runner build` to re-generate! - -${library.accept(emitter)} -'''; - // Write out the new asset. - await buildStep.writeAsString( - outputId, - DartFormatter().format(output), - ); - } - - // Suggest a name from ABI json file - String _suggestName(String pathWithoutExtension) { - final base = basename(pathWithoutExtension); - return base[0].toUpperCase() + base.substring(1); - } - - @override - final buildExtensions = const { - ".sierra.json": [".sierra.g.dart"] - }; -} - -class _ContractAbiGenerator { - final List abi; - final String name; - - List calls = []; - List executes = []; - Map structs = {}; - - _ContractAbiGenerator(this.abi, this.name) { - for (var element in abi) { - final entry = SierraContractAbiEntry.fromJson(element); - switch (entry.type) { - case "function": - final functionAbi = entry as SierraFunctionAbiEntry; - if (functionAbi.stateMutability == null) { - executes.add(functionAbi); - } else { - calls.add(functionAbi); - } - break; - case "struct": - structs[entry.name] = entry as SierraStructAbiEntry; - break; - } - } - } - - Library generate() { - return Library((b) { - b.directives.addAll([ - Directive.import('package:starknet/starknet.dart'), - ]); - for (var s in structs.values) { - b.body..add(Class(_createCustomClass(s))); - } - // no multiple output in Cairo 1? - /* - for (var fun in calls) { - if (fun.outputsFiltered.length > 1) { - b.body..add(Class(_createOutputClass(fun))); - } - } - */ - b.body..add(Class(_createContractClass)); - }); - } - - void Function(ClassBuilder) _createCustomClass(SierraStructAbiEntry custom) { - void innerFunction(ClassBuilder b) { - b.name = custom.name; - b.fields.addAll(custom.members.map( - (e) => Field((f) => f - ..name = e.name - ..type = _convertType(e.type)), - )); - b - ..constructors.add(Constructor((c) => c - ..optionalParameters.addAll(custom.members.map( - (e) => Parameter((p) => p - ..name = e.name - ..type = _convertType(e.type) - ..required = true - ..named = true - ..toThis = true), - )))) - ..constructors.add(Constructor((c) => c - ..factory = true - ..name = FROM_CALL_DATA - ..requiredParameters.add(Parameter((p) => p - ..name = CALL_DATA_VAR - ..type = CALL_DATA_TYPE)) - ..body = Block((b) { - for (var member in custom.members) { - if (member.type == "felt") { - b - ..addExpression(declareFinal(member.name).assign( - refer('$CALL_DATA_VAR[${member.name}]'))); // FIXME - } else { - b - ..addExpression(declareFinal(member.name) - .assign(refer(member.type).property(FROM_CALL_DATA).call([ - refer(CALL_DATA_VAR) - .property('sublist') - .call([literalNum(0)]) // FIXME - ]))); - } - } - b.addExpression(refer(custom.name).call( - [], - Map.fromIterable(custom.members, - key: (e) => e.name, value: (e) => refer(e.name))).returned); - }))) - ..methods.add(Method((m) => m - ..name = TO_CALL_DATA - ..returns = CALL_DATA_TYPE - ..body = Block((b) { - b - ..addExpression(declareVar('ret', type: CALL_DATA_TYPE) - .assign(CALL_DATA_TYPE.property('filled').call([ - refer('${custom.members.length}'), - refer('Felt').property('fromInt').call([literalNum(0)]) - ]))); - for (var member in custom.members) { - if (member.type == "felt") { - b.addExpression( - refer('ret[${member.name}]').assign(refer(member.name))); - } - } - b.addExpression(refer('ret').returned); - }))) - ..methods.add(Method((m) => m - ..name = 'toString' - ..returns = refer('String') - ..body = Block((b) { - String display = '${custom.name}('; - for (var member in custom.members) { - display += '${member.name}: \$${member.name}, '; - } - display += ")"; - b..addExpression(literalString(display).returned); - }))); - } - - return innerFunction; - } - - void _createContractClass(ClassBuilder b) { - b - ..name = name - ..fields.add(Field((f) => f - ..name = CONTRACT_FIELD_VAR - ..type = CONTRACT_FIELD_TYPE - ..modifier = FieldModifier.final$)) - ..constructors.add(Constructor(_createContractConstructor)); - - for (var fun in calls) { - b.methods.add(Method((b) => _methodFor(fun, b))); - } - - for (var fun in executes) { - b.methods.add(Method((b) => _methodFor(fun, b))); - } - } - - // Generated contract constructor - void _createContractConstructor(ConstructorBuilder b) { - String _accountVar = "account"; - String _addressVar = "address"; - b - ..optionalParameters.addAll([ - Parameter((b) => b - ..name = _accountVar - ..required = true - ..named = true), - Parameter((b) => b - ..name = _addressVar - ..required = true - ..named = true), - ]) - ..initializers.add(CONTRACT_FIELD - .assign(CONTRACT_FIELD_TYPE.call([], { - _accountVar: refer(_accountVar), - _addressVar: refer(_addressVar) - })) - .code); - } - - void _methodFor(SierraFunctionAbiEntry fun, MethodBuilder b) { - b - ..modifier = MethodModifier.async - ..returns = _returnType(fun) - ..name = fun.name - ..body = _bodyForMethod(fun) - ..requiredParameters.addAll(_parametersFor(fun)); - } - - // An 'invoke' will alwas return transaction hash as a String - Reference _returnType(SierraFunctionAbiEntry fun) { - if (fun.stateMutability == 'view') { - return _returnTypeForCall(fun); - } else { - return _futurize(refer("String")); - } - } - - List _parametersFor(SierraFunctionAbiEntry fun) { - final parameters = []; - for (final param in fun.inputsFiltered) { - parameters.add(Parameter((b) => b - ..name = param.name - ..type = _convertType(param.type))); - } - - return parameters; - } - - Reference _convertCoreType(String paramType) { - switch (paramType) { - case 'core::integer::u8': - case 'core::felt252': - case 'core::starknet::contract_address::ContractAddress': - return refer('Felt'); - case 'core::integer::u256': - return refer('Uint256'); - default: - throw Exception("Unsupported core type: $paramType"); - } - } - - Reference _convertType(String paramType) { - switch (paramType) { - case 'Felt': - case 'felt': - return refer('Felt'); - case 'felt*': - return CALL_DATA_TYPE; - default: - if (paramType.startsWith("core::")) { - return _convertCoreType(paramType); - } - if (structs.containsKey(paramType)) { - return refer(paramType); - } else { - throw Exception("Unsupported type for conversion: $paramType"); - } - } - } - - Expression _assignParams(SierraFunctionAbiEntry fun) { - final params = fun.inputsFiltered - .map((e) => e.type == 'felt' - ? refer(e.name) - : refer('...${e.name}.$TO_CALL_DATA()')) - .toList(); - return declareFinal('params', type: CALL_DATA_TYPE) - .assign(literalList(params)); - } - - // Generate method body for a 'call' method - Code _bodyForCall(SierraFunctionAbiEntry fun) { - return Block((b) { - b - ..addExpression(_assignParams(fun)) - ..addExpression(declareFinal('res').assign(CONTRACT_FIELD - .property(CONTRACT_METHOD_CALL) - .call([literalString(fun.name), refer('params')]).awaited)); - _returnBodyForCall(fun, b); - }); - } - - // Generate method body for an 'execute' method - Code _bodyForExecute(SierraFunctionAbiEntry fun) { - final String trxVar = "trx"; - final String trxHashVar = "trxHash"; - final Reference trx = refer(trxVar); - final Reference trxHash = refer(trxHashVar); - - return Block((b) { - b - ..addExpression(_assignParams(fun)) - ..addExpression(declareFinal(trxVar).assign(CONTRACT_FIELD - .property(CONTRACT_METHOD_EXECUTE) - .call([literalString(fun.name), refer('params')]).awaited)) - // caller of the 'invoke' method only need a transaction hash - // and not the InvokeTransactionResult object - ..addExpression( - declareFinal(trxHashVar).assign(trx.property('when').call( - [], - { - 'result': Method((b) => b - ..lambda = true - ..requiredParameters.add(Parameter((p) => p.name = "result")) - ..body = refer('result').property('transaction_hash').code) - .closure, - 'error': Method((b) => b - ..lambda = true - ..requiredParameters.add(Parameter((p) => p.name = "error")) - ..body = Code("throw Exception")).closure - }, - ))) - ..addExpression(trxHash.returned); - }); - } - - Code _bodyForMethod(SierraFunctionAbiEntry fun) { - if (fun.stateMutability == 'view') { - return _bodyForCall(fun); - } else { - return _bodyForExecute(fun); - } - } - - void _returnBodyForCall(SierraFunctionAbiEntry fun, BlockBuilder b) { - if (fun.outputsFiltered.isNotEmpty) { - if (fun.outputsFiltered.length == 1) { - final output = fun.outputsFiltered[0]; - switch (output.type) { - case 'felt': - b.addExpression(refer('res[0]').returned); - break; - case 'felt*': - b.addExpression( - refer('res').property(FROM_CALL_DATA).call([]).returned); - break; - default: - b.addExpression(_convertType(output.type) - .property(FROM_CALL_DATA) - .call([refer('res')]).returned); - break; - } - } else { - b.addExpression(refer(_getOutputClassName(fun)) - .property(FROM_CALL_DATA) - .call([refer('res')]).returned); - } - } - } - - Reference _returnTypeForCall(SierraFunctionAbiEntry fun) { - if (fun.outputsFiltered.isEmpty) { - return _futurize(refer('void')); - } - switch (fun.outputsFiltered.length) { - case 1: - final output = fun.outputsFiltered[0]; - return _futurize(_convertType(output.type)); - - default: - return _futurize(refer(_getOutputClassName(fun))); - } - } - - Reference _futurize(Reference r) { - return TypeReference((b) => b - ..symbol = 'Future' - ..types.add(r)); - } - - String _getOutputClassName(SierraFunctionAbiEntry fun) { - return '${fun.name.snakeCasetoCamelCase()}Result'; - } -} - -extension on SierraFunctionAbiEntry { - List get inputsFiltered { - return this.inputs; - } - - List get outputsFiltered { - return this.outputs; - } -} - -extension on String { - String snakeCasetoCamelCase() { - String ret = this[0].toUpperCase(); - ret += this.substring(1).split('_').reduce((value, element) => - value + element[0].toUpperCase() + element.substring(1)); - return ret; - } -} diff --git a/packages/starknet_builder/lib/src/legacy_generator.dart b/packages/starknet_builder/lib/src/legacy_generator.dart deleted file mode 100644 index a26b9f99..00000000 --- a/packages/starknet_builder/lib/src/legacy_generator.dart +++ /dev/null @@ -1,583 +0,0 @@ -import 'dart:async'; -import 'dart:convert'; - -import 'package:build/build.dart'; -import 'package:code_builder/code_builder.dart'; -import 'package:dart_style/dart_style.dart'; -import 'package:path/path.dart'; - -import 'package:starknet/starknet.dart'; - -final CALL_DATA_VAR = "callData"; -final CALL_DATA_TYPE = refer('List'); -final TO_CALL_DATA = "toCallData"; -final FROM_CALL_DATA = "fromCallData"; - -final CONTRACT_FIELD_VAR = "_contract"; -final CONTRACT_FIELD = refer(CONTRACT_FIELD_VAR); -final CONTRACT_FIELD_TYPE = refer("Contract"); -final CONTRACT_METHOD_CALL = "call"; -final CONTRACT_METHOD_EXECUTE = "execute"; - -class LegacyContractGenerator implements Builder { - const LegacyContractGenerator(); - @override - FutureOr build(BuildStep buildStep) async { - // Each [buildStep] has a single input. - final inputId = buildStep.inputId; - final withoutExtension = - inputId.path.substring(0, inputId.path.length - '.abi.json'.length); - - final source = await buildStep.readAsString(inputId); - - // ABI is provided as a JSON - final List abi = jsonDecode(source); - - final outputId = AssetId( - inputId.package, inputId.path.replaceFirst(".abi.json", ".g.dart")); - final library = - _LegacyContractAbiGenerator(abi, _suggestName(withoutExtension)) - .generate(); - final emitter = DartEmitter( - allocator: Allocator.simplePrefixing(), useNullSafetySyntax: true); - final output = ''' -// Generated code, do not modify. Run `build_runner build` to re-generate! - -${library.accept(emitter)} -'''; - // Write out the new asset. - await buildStep.writeAsString( - outputId, - DartFormatter().format(output), - ); - } - - // Suggest a name from ABI json file - String _suggestName(String pathWithoutExtension) { - final base = basename(pathWithoutExtension); - return base[0].toUpperCase() + base.substring(1); - } - - @override - final buildExtensions = const { - ".abi.json": [".g.dart"] - }; -} - -class _LegacyContractAbiGenerator { - final List abi; - final String name; - - List calls = []; - List executes = []; - Map structs = {}; - - // #98: only add List extension if needed - // The following bool are used to check if we have a - // - felt* parameter in input parameters - // - felt* parameter in output parameters - bool needListFeltToCallData = false; - bool needListFeltFromCallData = false; - - _LegacyContractAbiGenerator(this.abi, this.name) { - for (var element in abi) { - final entry = DeprecatedContractAbiEntry.fromJson(element); - switch (entry.type) { - case "function": - final functionAbi = entry as DeprecatedFunctionAbiEntry; - if (functionAbi.stateMutability == null) { - executes.add(functionAbi); - } else { - calls.add(functionAbi); - } - if (false == needListFeltToCallData) { - if (functionAbi.inputsHas("felt*")) { - needListFeltToCallData = true; - break; - } - } - if (false == needListFeltFromCallData) { - if (functionAbi.outputsHas("felt*")) { - needListFeltFromCallData = true; - break; - } - } - break; - case "struct": - structs[entry.name] = entry as DeprecatedStructAbiEntry; - break; - } - } - } - - Library generate() { - return Library((b) { - b.directives.addAll([ - Directive.import('package:starknet/starknet.dart'), - ]); - for (var s in structs.values) { - b.body..add(Class(_createCustomClass(s))); - } - for (var fun in calls) { - if (fun.outputsFiltered.length > 1) { - b.body..add(Class(_createOutputClass(fun))); - } - } - b.body..add(Class(_createContractClass)); - if (needListFeltFromCallData || needListFeltToCallData) { - b.body.add(Extension((e) { - e.on = CALL_DATA_TYPE; - if (needListFeltToCallData) { - e.methods.add(Method((m) => m - ..name = TO_CALL_DATA - ..returns = CALL_DATA_TYPE - ..body = Block((b) { - b.addExpression(literalList([ - refer('Felt') - .property('fromInt') - .call([refer('this').property('length')]), - refer('this').spread, - ]).returned); - }))); - } - if (needListFeltFromCallData) { - e.methods.add(Method((m) => m - ..name = FROM_CALL_DATA - ..returns = CALL_DATA_TYPE - ..body = Block((b) { - b.addExpression(refer('this') - .property('sublist') - .call([literalNum(1)]).returned); - }))); - } - })); - } - }); - } - - void Function(ClassBuilder) _createCustomClass( - DeprecatedStructAbiEntry custom) { - void innerFunction(ClassBuilder b) { - b.name = custom.name; - b.fields.addAll(custom.members.map( - (e) => Field((f) => f - ..name = e.name - ..type = _convertType(e.type)), - )); - b - ..constructors.add(Constructor((c) => c - ..optionalParameters.addAll(custom.members.map( - (e) => Parameter((p) => p - ..name = e.name - ..type = _convertType(e.type) - ..required = true - ..named = true - ..toThis = true), - )))) - ..constructors.add(Constructor((c) => c - ..factory = true - ..name = FROM_CALL_DATA - ..requiredParameters.add(Parameter((p) => p - ..name = CALL_DATA_VAR - ..type = CALL_DATA_TYPE)) - ..body = Block((b) { - for (var member in custom.members) { - if (member.type == "felt") { - b - ..addExpression(declareFinal(member.name) - .assign(refer('$CALL_DATA_VAR[${member.offset}]'))); - } else { - b - ..addExpression(declareFinal(member.name) - .assign(refer(member.type).property(FROM_CALL_DATA).call([ - refer(CALL_DATA_VAR) - .property('sublist') - .call([literalNum(member.offset)]) - ]))); - } - } - b.addExpression(refer(custom.name).call( - [], - Map.fromIterable(custom.members, - key: (e) => e.name, value: (e) => refer(e.name))).returned); - }))) - ..methods.add(Method((m) => m - ..name = TO_CALL_DATA - ..returns = CALL_DATA_TYPE - ..body = Block((b) { - b - ..addExpression(declareVar('ret', type: CALL_DATA_TYPE) - .assign(CALL_DATA_TYPE.property('filled').call([ - refer('${custom.members.length}'), - refer('Felt').property('fromInt').call([literalNum(0)]) - ]))); - for (var member in custom.members) { - if (member.type == "felt") { - b.addExpression( - refer('ret[${member.offset}]').assign(refer(member.name))); - } - } - b.addExpression(refer('ret').returned); - }))) - ..methods.add(Method((m) => m - ..name = 'toString' - ..returns = refer('String') - ..body = Block((b) { - String display = '${custom.name}('; - for (var member in custom.members) { - display += '${member.name}: \$${member.name}, '; - } - display += ")"; - b..addExpression(literalString(display).returned); - }))); - } - - return innerFunction; - } - - void Function(ClassBuilder) _createOutputClass( - DeprecatedFunctionAbiEntry fun) { - void innerFunction(ClassBuilder b) { - final name = _getOutputClassName(fun); - b - ..name = name - ..fields.addAll(fun.outputsFiltered.map( - (e) => Field((f) => f - ..name = e.name - ..type = _convertType(e.type)), - )) - ..constructors.add(Constructor((c) => c - ..optionalParameters.addAll(fun.outputsFiltered.map( - (e) => Parameter((p) => p - ..name = e.name - ..type = _convertType(e.type) - ..required = true - ..named = true - ..toThis = true), - )))) - ..constructors.add(Constructor((c) => c - ..factory = true - ..name = FROM_CALL_DATA - ..requiredParameters.add(Parameter((p) => p - ..name = CALL_DATA_VAR - ..type = CALL_DATA_TYPE)) - ..body = Block((b) { - String offsetVar = "offset"; - Reference offset = refer(offsetVar); - b.addExpression(declareVar(offsetVar, type: refer('int')) - .assign(literalNum(0))); - String tmpSizeVar = "_tmpSize"; - Reference tmpSize = refer(tmpSizeVar); - - if (fun.outputsHas("felt*")) { - b.addExpression(declareVar(tmpSizeVar, type: refer('int')) - .assign(literalNum(0))); - } - for (var output in fun.outputsFiltered) { - switch (output.type) { - case "felt": - b - ..addExpression(declareFinal(output.name) - .assign(refer(CALL_DATA_VAR).index(offset))) - ..addExpression( - offset.assign(offset.operatorAdd(literalNum(1)))); - break; - case "felt*": - b - ..addExpression(tmpSize.assign(refer(CALL_DATA_VAR) - .index(offset) - .property('toInt') - .call([]))) - ..addExpression(declareFinal(output.name).assign( - refer(CALL_DATA_VAR) - .property('sublist') - .call([ - offset, - offset - .operatorAdd(tmpSize) - .operatorAdd(literalNum(1)) - ]) - .property(FROM_CALL_DATA) - .call([]))) - ..addExpression(offset.assign(offset - .operatorAdd(tmpSize) - .operatorAdd(literalNum(1)))); - - break; - default: - b - ..addExpression(declareFinal(output.name).assign( - _convertType(output.type) - .property(FROM_CALL_DATA) - .call([ - refer(CALL_DATA_VAR).property('sublist').call([offset]) - ]))) - ..addExpression(offset.assign(offset - .operatorAdd(literalNum(structs[output.type]!.size)))); - break; - } - } - b.addExpression(refer(name).call( - [], - Map.fromIterable(fun.outputsFiltered, - key: (e) => e.name, value: (e) => refer(e.name))).returned); - }))); - - b.methods.add(Method((m) => m - ..name = 'toString' - ..returns = refer('String') - ..body = Block((b) { - String display = '${name}('; - for (var output in fun.outputsFiltered) { - display += '${output.name}: \$${output.name}, '; - } - display += ")"; - b..addExpression(literalString(display).returned); - }))); - } - - return innerFunction; - } - - void _createContractClass(ClassBuilder b) { - b - ..name = name - ..fields.add(Field((f) => f - ..name = CONTRACT_FIELD_VAR - ..type = CONTRACT_FIELD_TYPE - ..modifier = FieldModifier.final$)) - ..constructors.add(Constructor(_createContractConstructor)); - - for (var fun in calls) { - b.methods.add(Method((b) => _methodFor(fun, b))); - } - - for (var fun in executes) { - b.methods.add(Method((b) => _methodFor(fun, b))); - } - } - - // Generated contract constructor - void _createContractConstructor(ConstructorBuilder b) { - String _accountVar = "account"; - String _addressVar = "address"; - b - ..optionalParameters.addAll([ - Parameter((b) => b - ..name = _accountVar - ..required = true - ..named = true), - Parameter((b) => b - ..name = _addressVar - ..required = true - ..named = true), - ]) - ..initializers.add(CONTRACT_FIELD - .assign(CONTRACT_FIELD_TYPE.call([], { - _accountVar: refer(_accountVar), - _addressVar: refer(_addressVar) - })) - .code); - } - - void _methodFor(DeprecatedFunctionAbiEntry fun, MethodBuilder b) { - b - ..modifier = MethodModifier.async - ..returns = _returnType(fun) - ..name = fun.name - ..body = _bodyForMethod(fun) - ..requiredParameters.addAll(_parametersFor(fun)); - } - - // An 'invoke' will alwas return transaction hash as a String - Reference _returnType(DeprecatedFunctionAbiEntry fun) { - if (fun.stateMutability == 'view') { - return _returnTypeForCall(fun); - } else { - return _futurize(refer("String")); - } - } - - List _parametersFor(DeprecatedFunctionAbiEntry fun) { - final parameters = []; - for (final param in fun.inputsFiltered) { - parameters.add(Parameter((b) => b - ..name = param.name - ..type = _convertType(param.type))); - } - - return parameters; - } - - Reference _convertType(String paramType) { - switch (paramType) { - case 'Felt': - case 'felt': - return refer('Felt'); - case 'felt*': - return CALL_DATA_TYPE; - default: - if (structs.containsKey(paramType)) { - return refer(paramType); - } else { - throw Exception("Unsupported type for conversion: $paramType"); - } - } - } - - Expression _assignParams(DeprecatedFunctionAbiEntry fun) { - final params = fun.inputsFiltered - .map((e) => e.type == 'felt' - ? refer(e.name) - : refer('...${e.name}.$TO_CALL_DATA()')) - .toList(); - return declareFinal('params', type: CALL_DATA_TYPE) - .assign(literalList(params)); - } - - // Generate method body for a 'call' method - Code _bodyForCall(DeprecatedFunctionAbiEntry fun) { - return Block((b) { - b - ..addExpression(_assignParams(fun)) - ..addExpression(declareFinal('res').assign(CONTRACT_FIELD - .property(CONTRACT_METHOD_CALL) - .call([literalString(fun.name), refer('params')]).awaited)); - _returnBodyForCall(fun, b); - }); - } - - // Generate method body for an 'execute' method - Code _bodyForExecute(DeprecatedFunctionAbiEntry fun) { - final String trxVar = "trx"; - final String trxHashVar = "trxHash"; - final Reference trx = refer(trxVar); - final Reference trxHash = refer(trxHashVar); - - return Block((b) { - b - ..addExpression(_assignParams(fun)) - ..addExpression(declareFinal(trxVar).assign(CONTRACT_FIELD - .property(CONTRACT_METHOD_EXECUTE) - .call([literalString(fun.name), refer('params')]).awaited)) - // caller of the 'invoke' method only need a transaction hash - // and not the InvokeTransactionResult object - ..addExpression( - declareFinal(trxHashVar).assign(trx.property('when').call( - [], - { - 'result': Method((b) => b - ..lambda = true - ..requiredParameters.add(Parameter((p) => p.name = "result")) - ..body = refer('result').property('transaction_hash').code) - .closure, - 'error': Method((b) => b - ..lambda = true - ..requiredParameters.add(Parameter((p) => p.name = "error")) - ..body = Code("throw Exception")).closure - }, - ))) - ..addExpression(trxHash.returned); - }); - } - - Code _bodyForMethod(DeprecatedFunctionAbiEntry fun) { - if (fun.stateMutability == 'view') { - return _bodyForCall(fun); - } else { - return _bodyForExecute(fun); - } - } - - void _returnBodyForCall(DeprecatedFunctionAbiEntry fun, BlockBuilder b) { - if (fun.outputsFiltered.isNotEmpty) { - if (fun.outputsFiltered.length == 1) { - final output = fun.outputsFiltered[0]; - switch (output.type) { - case 'felt': - b.addExpression(refer('res[0]').returned); - break; - case 'felt*': - b.addExpression( - refer('res').property(FROM_CALL_DATA).call([]).returned); - break; - default: - b.addExpression(_convertType(output.type) - .property(FROM_CALL_DATA) - .call([refer('res')]).returned); - break; - } - } else { - b.addExpression(refer(_getOutputClassName(fun)) - .property(FROM_CALL_DATA) - .call([refer('res')]).returned); - } - } - } - - Reference _returnTypeForCall(DeprecatedFunctionAbiEntry fun) { - if (fun.outputsFiltered.isEmpty) { - return _futurize(refer('void')); - } - switch (fun.outputsFiltered.length) { - case 1: - final output = fun.outputsFiltered[0]; - return _futurize(_convertType(output.type)); - - default: - return _futurize(refer(_getOutputClassName(fun))); - } - } - - Reference _futurize(Reference r) { - return TypeReference((b) => b - ..symbol = 'Future' - ..types.add(r)); - } - - String _getOutputClassName(DeprecatedFunctionAbiEntry fun) { - return '${fun.name.snakeCasetoCamelCase()}Result'; - } -} - -extension on List { - List filterArray() { - List ret = []; - for (var i = 0; i < this.length - 1; i++) { - if ('${this[i].name}' != '${this[i + 1].name}_len') { - ret.add(this[i]); - } - } - if (this.isNotEmpty) { - ret.add(this.last); - } - return ret; - } -} - -extension on DeprecatedFunctionAbiEntry { - List get inputsFiltered { - return this.inputs.filterArray(); - } - - List get outputsFiltered { - return this.outputs.filterArray(); - } - - bool inputsHas(String type_) { - return this.inputsFiltered.where((e) => e.type == type_).isNotEmpty; - } - - bool outputsHas(String type_) { - return this.outputsFiltered.where((e) => e.type == type_).isNotEmpty; - } -} - -extension on String { - String snakeCasetoCamelCase() { - String ret = this[0].toUpperCase(); - ret += this.substring(1).split('_').reduce((value, element) => - value + element[0].toUpperCase() + element.substring(1)); - return ret; - } -} diff --git a/packages/starknet_builder/melos_starknet_builder.iml b/packages/starknet_builder/melos_starknet_builder.iml deleted file mode 100644 index 389d07a1..00000000 --- a/packages/starknet_builder/melos_starknet_builder.iml +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/packages/starknet_builder/pubspec.yaml b/packages/starknet_builder/pubspec.yaml deleted file mode 100644 index 5e1981b1..00000000 --- a/packages/starknet_builder/pubspec.yaml +++ /dev/null @@ -1,23 +0,0 @@ -name: starknet_builder -description: The Dart SDK builder for contracts on starknet -version: 0.1.0 -repository: https://github.com/gabsn/starknet.dart - -environment: - sdk: ">=2.17.3 <4.0.0" - -dependencies: - starknet: - starknet_provider: - build: ^2.3.1 - code_builder: ^4.4.0 - dart_style: ^2.2.4 - path: ^1.8.3 - -dev_dependencies: - analyzer: ^5.4.0 - args: ^2.4.2 - build_runner: ^2.1.11 - build_test: ^2.1.6 - lints: ^2.0.0 - test: ^1.16.0 diff --git a/packages/starknet_builder/test/execute_test.dart b/packages/starknet_builder/test/execute_test.dart deleted file mode 100644 index 3e2e68f0..00000000 --- a/packages/starknet_builder/test/execute_test.dart +++ /dev/null @@ -1,39 +0,0 @@ -import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/diagnostic/diagnostic.dart'; - -import 'package:build_test/build_test.dart'; -import 'package:test/test.dart'; - -void main() { - test("Generator should support ABI containing 'execute'", () async { - final expectedClassName = "Execute"; - final expectedFileName = "execute.g.dart"; - - final main = await resolveSources( - { - 'starknet_builder|test/integration/$expectedFileName': useAssetReader, - }, - (resolver) => resolver.libraries.firstWhere( - (element) => element.source.toString().contains('execute')), - ); - final errorResult = await main.session - .getErrors('/starknet_builder/test/integration/$expectedFileName') - as ErrorsResult; - final criticalErrors = errorResult.errors - .where((element) => element.severity == Severity.error) - .toList(); - expect(criticalErrors, isEmpty, - reason: "Generated source code should compile without critical error"); - - final generatedClass = main.getClass(expectedClassName); - expect(generatedClass, isNotNull, - reason: - "Generated source code should contains a class named '$expectedClassName'"); - for (var methodName in ['execute']) { - expect(generatedClass!.methods.where((e) => e.name == methodName).length, - equals(1), - reason: - "Generated class should contains a method named '$methodName'"); - } - }); -} diff --git a/packages/starknet_builder/test/integration/execute.abi.json b/packages/starknet_builder/test/integration/execute.abi.json deleted file mode 100644 index ac224af6..00000000 --- a/packages/starknet_builder/test/integration/execute.abi.json +++ /dev/null @@ -1,29 +0,0 @@ -[ - { - "inputs": [ - { - "name": "a", - "type": "felt" - }, - { - "name": "b", - "type": "felt" - } - ], - "name": "execute", - "outputs": [], - "type": "function" - }, - { - "inputs": [], - "name": "get", - "outputs": [ - { - "name": "sum", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/packages/starknet_builder/test/integration/execute.cairo b/packages/starknet_builder/test/integration/execute.cairo deleted file mode 100644 index 1ffe4260..00000000 --- a/packages/starknet_builder/test/integration/execute.cairo +++ /dev/null @@ -1,26 +0,0 @@ -%lang starknet - -from starkware.cairo.common.cairo_builtins import HashBuiltin - - -@storage_var -func sum() -> (res: felt) { -} - - - -@external -func execute{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}( - a: felt, b: felt -) { - sum.write(a + b); - return (); -} - -@view -func get{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}() -> ( - sum: felt -) { - let (sum_) = sum.read(); - return (sum=sum_); -} \ No newline at end of file diff --git a/packages/starknet_builder/test/integration/issue_101_multiple_output.abi.json b/packages/starknet_builder/test/integration/issue_101_multiple_output.abi.json deleted file mode 100644 index 6e61a15b..00000000 --- a/packages/starknet_builder/test/integration/issue_101_multiple_output.abi.json +++ /dev/null @@ -1,61 +0,0 @@ -[ - { - "members": [ - { - "name": "amount", - "offset": 0, - "type": "Uint256" - }, - { - "name": "id", - "offset": 2, - "type": "felt" - } - ], - "name": "MyAccount", - "size": 3, - "type": "struct" - }, - { - "members": [ - { - "name": "low", - "offset": 0, - "type": "felt" - }, - { - "name": "high", - "offset": 1, - "type": "felt" - } - ], - "name": "Uint256", - "size": 2, - "type": "struct" - }, - { - "inputs": [ - { - "name": "id", - "type": "felt" - } - ], - "name": "multiple_outputs", - "outputs": [ - { - "name": "account", - "type": "MyAccount" - }, - { - "name": "total", - "type": "Uint256" - }, - { - "name": "ref", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/packages/starknet_builder/test/integration/issue_101_multiple_output.cairo b/packages/starknet_builder/test/integration/issue_101_multiple_output.cairo deleted file mode 100644 index a7df7e79..00000000 --- a/packages/starknet_builder/test/integration/issue_101_multiple_output.cairo +++ /dev/null @@ -1,21 +0,0 @@ -%lang starknet - -from starkware.cairo.common.cairo_builtins import HashBuiltin -from starkware.cairo.common.uint256 import Uint256 - -struct MyAccount { - amount: Uint256, - id: felt, -} - -@view -func multiple_outputs{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}(id: felt) -> ( - account: MyAccount, total: Uint256, ref: felt -) { - let amount = Uint256(low=1, high=0); - let account = MyAccount(amount=amount, id=id); - let total = Uint256(low=1000, high=0); - let ref = id + 1; - return(account=account, total=total, ref=ref); -} - diff --git a/packages/starknet_builder/test/integration/simple.abi.json b/packages/starknet_builder/test/integration/simple.abi.json deleted file mode 100644 index e5466969..00000000 --- a/packages/starknet_builder/test/integration/simple.abi.json +++ /dev/null @@ -1,14 +0,0 @@ -[ - { - "inputs": [], - "name": "answer", - "outputs": [ - { - "name": "answer", - "type": "felt" - } - ], - "stateMutability": "view", - "type": "function" - } -] diff --git a/packages/starknet_builder/test/integration/simple.cairo b/packages/starknet_builder/test/integration/simple.cairo deleted file mode 100644 index 931bc7a7..00000000 --- a/packages/starknet_builder/test/integration/simple.cairo +++ /dev/null @@ -1,11 +0,0 @@ -%lang starknet - -from starkware.cairo.common.cairo_builtins import HashBuiltin - - -@view -func answer{syscall_ptr: felt*, pedersen_ptr: HashBuiltin*, range_check_ptr}() -> ( - answer: felt -) { - return (answer=42); -} \ No newline at end of file diff --git a/packages/starknet_builder/test/issues_test.dart b/packages/starknet_builder/test/issues_test.dart deleted file mode 100644 index 2056be0e..00000000 --- a/packages/starknet_builder/test/issues_test.dart +++ /dev/null @@ -1,34 +0,0 @@ -import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/diagnostic/diagnostic.dart'; -import 'package:build_test/build_test.dart'; -import 'package:test/test.dart'; - -void main() { - test( - "Issue #101: Generated source code for 'MultipleOutputResult' fromCallData should not contains unused variable", - () async { - final expectedFileName = "issue_101_multiple_output.g.dart"; - - final main = await resolveSources( - { - 'starknet_builder|test/integration/$expectedFileName': useAssetReader, - }, - (resolver) => resolver.libraries - .firstWhere((element) => element.source.toString().contains('issue')), - ); - final errorResult = await main.session - .getErrors('/starknet_builder/test/integration/$expectedFileName') - as ErrorsResult; - final criticalErrors = errorResult.errors - .where((element) => element.severity == Severity.error) - .toList(); - expect(criticalErrors, isEmpty, - reason: "Generated source code should compile without critical error"); - final unusedLocalVariableErrors = errorResult.errors - .where((element) => - element.errorCode.uniqueName == "HintCode.UNUSED_LOCAL_VARIABLE") - .toList(); - expect(unusedLocalVariableErrors, isEmpty, - reason: "Generated source code shouldn't contains unused variable"); - }); -} diff --git a/packages/starknet_builder/test/melos_test.dart b/packages/starknet_builder/test/melos_test.dart deleted file mode 100644 index aa51d018..00000000 --- a/packages/starknet_builder/test/melos_test.dart +++ /dev/null @@ -1,6 +0,0 @@ -import 'package:test/test.dart'; - -void main() { - test('Prevent melos from failing when no test tagged unit', () {}, - tags: ['unit', 'integration']); -} diff --git a/packages/starknet_builder/test/simple_contract_test.dart b/packages/starknet_builder/test/simple_contract_test.dart deleted file mode 100644 index 68a24b3a..00000000 --- a/packages/starknet_builder/test/simple_contract_test.dart +++ /dev/null @@ -1,57 +0,0 @@ -import 'package:analyzer/dart/analysis/results.dart'; -import 'package:analyzer/diagnostic/diagnostic.dart'; -import 'package:analyzer/dart/element/element.dart'; -import 'package:build_test/build_test.dart'; -import 'package:test/test.dart'; - -void main() { - final expectedClassName = "Simple"; - final expectedFileName = "simple.g.dart"; - late LibraryElement main; - late ClassElement? generatedClass; - late ErrorsResult errorResult; - - setUp(() async { - main = await resolveSources( - { - 'starknet_builder|test/integration/$expectedFileName': useAssetReader, - }, - (resolver) => resolver.libraries.firstWhere( - (element) => element.source.toString().contains('simple')), - ); - errorResult = await main.session - .getErrors('/starknet_builder/test/integration/$expectedFileName') - as ErrorsResult; - generatedClass = main.getClass(expectedClassName); - }); - test("Generated source code should compile without critical error", () { - final criticalErrors = errorResult.errors - .where((element) => element.severity == Severity.error) - .toList(); - expect(criticalErrors, isEmpty, - reason: "Generated source code should compile without critical error"); - }); - test( - "Generated class from simple contract should have only 1 method named 'answer'", - () { - expect(generatedClass, isNotNull, - reason: - "Generated source code should contains a class named '$expectedClassName'"); - expect(generatedClass!.methods.length, equals(1), - reason: "Generated class should have only 1 method"); - expect(generatedClass!.methods[0].name, equals("answer"), - reason: "Generated class shoud have 1 method named 'answer'"); - }); - test( - "#98: Generated source code from ABI should not add extension on List if not needed", - () async { - if (!main.accessibleExtensions.isEmpty) { - for (var ee in main.accessibleExtensions) { - expect(ee.getDisplayString(withNullability: false), - isNot(endsWith("on List")), - reason: - "Generated source code should not add extension on List if not needed"); - } - } - }); -} diff --git a/packages/starknet_builder/tool/extract_sierra_abi.dart b/packages/starknet_builder/tool/extract_sierra_abi.dart deleted file mode 100644 index 9830da12..00000000 --- a/packages/starknet_builder/tool/extract_sierra_abi.dart +++ /dev/null @@ -1,42 +0,0 @@ -import 'dart:convert'; -import 'dart:io'; - -import 'package:args/args.dart'; - -void main(List args) async { - final parser = ArgParser() - ..addFlag('help', - abbr: 'h', negatable: false, help: 'Show usage information') - ..addOption('input', abbr: 'i', help: 'Input path to sierra file') - ..addOption('output', abbr: 'o', help: 'Output path for JSON'); - - final results = parser.parse(args); - if (results['help']) { - print('Usage: dart ${Platform.script.path} ${_generateOptions(parser)}'); - print(parser.usage); - return; - } - final inputPath = - results.wasParsed('input') ? results['input'] : results.rest.first; - final outputPath = - results.wasParsed('output') ? results['output'] : results.rest.last; - - final json = jsonDecode( - await File(inputPath).readAsString(), - ); - - final String abi = jsonEncode(json["abi"]); - await File(outputPath).writeAsString(abi); -} - -String _generateOptions(ArgParser parser) { - final buffer = StringBuffer(); - for (var option in parser.options.keys) { - if (parser.options[option]!.isSingle) { - buffer.write('[--$option value] '); - } else { - buffer.write('[--$option] '); - } - } - return buffer.toString().trim(); -} diff --git a/packages/starknet_provider/analysis_options.yaml b/packages/starknet_provider/analysis_options.yaml index 62a8984e..a8d4734a 100644 --- a/packages/starknet_provider/analysis_options.yaml +++ b/packages/starknet_provider/analysis_options.yaml @@ -3,3 +3,4 @@ include: package:lints/recommended.yaml analyzer: errors: invalid_annotation_target: ignore + non_constant_identifier_names: ignore diff --git a/packages/starknet_provider/lib/src/model/actual_fee.freezed.dart b/packages/starknet_provider/lib/src/model/actual_fee.freezed.dart index ee6effb0..ebfc3a1f 100644 --- a/packages/starknet_provider/lib/src/model/actual_fee.freezed.dart +++ b/packages/starknet_provider/lib/src/model/actual_fee.freezed.dart @@ -23,8 +23,12 @@ mixin _$ActualFee { Felt get amount => throw _privateConstructorUsedError; String get unit => throw _privateConstructorUsedError; + /// Serializes this ActualFee to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ActualFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ActualFeeCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -47,6 +51,8 @@ class _$ActualFeeCopyWithImpl<$Res, $Val extends ActualFee> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of ActualFee + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -85,6 +91,8 @@ class __$$ActualFeeImplCopyWithImpl<$Res> _$ActualFeeImpl _value, $Res Function(_$ActualFeeImpl) _then) : super(_value, _then); + /// Create a copy of ActualFee + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -131,11 +139,13 @@ class _$ActualFeeImpl implements _ActualFee { (identical(other.unit, unit) || other.unit == unit)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, amount, unit); - @JsonKey(ignore: true) + /// Create a copy of ActualFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ActualFeeImplCopyWith<_$ActualFeeImpl> get copyWith => @@ -161,8 +171,11 @@ abstract class _ActualFee implements ActualFee { Felt get amount; @override String get unit; + + /// Create a copy of ActualFee + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ActualFeeImplCopyWith<_$ActualFeeImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/analysis_options.yaml b/packages/starknet_provider/lib/src/model/analysis_options.yaml deleted file mode 100644 index 82a81b3b..00000000 --- a/packages/starknet_provider/lib/src/model/analysis_options.yaml +++ /dev/null @@ -1,3 +0,0 @@ -analyzer: - errors: - non_constant_identifier_names: ignore diff --git a/packages/starknet_provider/lib/src/model/block_hash_and_number.freezed.dart b/packages/starknet_provider/lib/src/model/block_hash_and_number.freezed.dart index 9ead182f..fff1a8d1 100644 --- a/packages/starknet_provider/lib/src/model/block_hash_and_number.freezed.dart +++ b/packages/starknet_provider/lib/src/model/block_hash_and_number.freezed.dart @@ -70,6 +70,8 @@ mixin _$BlockHashAndNumber { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this BlockHashAndNumber to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$BlockHashAndNumberCopyWithImpl<$Res, $Val extends BlockHashAndNumber> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -113,6 +118,8 @@ class __$$BlockHashAndNumberResultImplCopyWithImpl<$Res> $Res Function(_$BlockHashAndNumberResultImpl) _then) : super(_value, _then); + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -126,6 +133,8 @@ class __$$BlockHashAndNumberResultImplCopyWithImpl<$Res> )); } + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $BlockHashAndNumberResponseResultCopyWith<$Res> get result { @@ -165,11 +174,13 @@ class _$BlockHashAndNumberResultImpl implements BlockHashAndNumberResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockHashAndNumberResultImplCopyWith<_$BlockHashAndNumberResultImpl> @@ -255,7 +266,10 @@ abstract class BlockHashAndNumberResult implements BlockHashAndNumber { _$BlockHashAndNumberResultImpl.fromJson; BlockHashAndNumberResponseResult get result; - @JsonKey(ignore: true) + + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockHashAndNumberResultImplCopyWith<_$BlockHashAndNumberResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -282,6 +296,8 @@ class __$$BlockHashAndNumberErrorImplCopyWithImpl<$Res> $Res Function(_$BlockHashAndNumberErrorImpl) _then) : super(_value, _then); + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -295,6 +311,8 @@ class __$$BlockHashAndNumberErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -333,11 +351,13 @@ class _$BlockHashAndNumberErrorImpl implements BlockHashAndNumberError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockHashAndNumberErrorImplCopyWith<_$BlockHashAndNumberErrorImpl> @@ -422,7 +442,10 @@ abstract class BlockHashAndNumberError implements BlockHashAndNumber { _$BlockHashAndNumberErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of BlockHashAndNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockHashAndNumberErrorImplCopyWith<_$BlockHashAndNumberErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -437,8 +460,12 @@ mixin _$BlockHashAndNumberResponseResult { Felt get blockHash => throw _privateConstructorUsedError; int get blockNumber => throw _privateConstructorUsedError; + /// Serializes this BlockHashAndNumberResponseResult to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of BlockHashAndNumberResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $BlockHashAndNumberResponseResultCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -465,6 +492,8 @@ class _$BlockHashAndNumberResponseResultCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of BlockHashAndNumberResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -506,6 +535,8 @@ class __$$BlockHashAndNumberResponseResultImplCopyWithImpl<$Res> $Res Function(_$BlockHashAndNumberResponseResultImpl) _then) : super(_value, _then); + /// Create a copy of BlockHashAndNumberResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -557,11 +588,13 @@ class _$BlockHashAndNumberResponseResultImpl other.blockNumber == blockNumber)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, blockHash, blockNumber); - @JsonKey(ignore: true) + /// Create a copy of BlockHashAndNumberResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockHashAndNumberResponseResultImplCopyWith< @@ -591,8 +624,11 @@ abstract class _BlockHashAndNumberResponseResult Felt get blockHash; @override int get blockNumber; + + /// Create a copy of BlockHashAndNumberResponseResult + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockHashAndNumberResponseResultImplCopyWith< _$BlockHashAndNumberResponseResultImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/starknet_provider/lib/src/model/block_id.freezed.dart b/packages/starknet_provider/lib/src/model/block_id.freezed.dart index fff8febd..32b74fde 100644 --- a/packages/starknet_provider/lib/src/model/block_id.freezed.dart +++ b/packages/starknet_provider/lib/src/model/block_id.freezed.dart @@ -95,6 +95,9 @@ class _$BlockIdCopyWithImpl<$Res, $Val extends BlockId> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -114,6 +117,8 @@ class __$$BlockIdHashImplCopyWithImpl<$Res> _$BlockIdHashImpl _value, $Res Function(_$BlockIdHashImpl) _then) : super(_value, _then); + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -158,11 +163,13 @@ class _$BlockIdHashImpl extends BlockIdHash { other.blockHash == blockHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, blockHash); - @JsonKey(ignore: true) + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockIdHashImplCopyWith<_$BlockIdHashImpl> get copyWith => @@ -245,7 +252,10 @@ abstract class BlockIdHash extends BlockId { _$BlockIdHashImpl.fromJson; Felt get blockHash; - @JsonKey(ignore: true) + + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockIdHashImplCopyWith<_$BlockIdHashImpl> get copyWith => throw _privateConstructorUsedError; } @@ -267,6 +277,8 @@ class __$$BlockIdNumberImplCopyWithImpl<$Res> _$BlockIdNumberImpl _value, $Res Function(_$BlockIdNumberImpl) _then) : super(_value, _then); + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -311,11 +323,13 @@ class _$BlockIdNumberImpl extends BlockIdNumber { other.blockNumber == blockNumber)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, blockNumber); - @JsonKey(ignore: true) + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockIdNumberImplCopyWith<_$BlockIdNumberImpl> get copyWith => @@ -398,7 +412,10 @@ abstract class BlockIdNumber extends BlockId { _$BlockIdNumberImpl.fromJson; int get blockNumber; - @JsonKey(ignore: true) + + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockIdNumberImplCopyWith<_$BlockIdNumberImpl> get copyWith => throw _privateConstructorUsedError; } @@ -420,6 +437,8 @@ class __$$BlockIdTagImplCopyWithImpl<$Res> _$BlockIdTagImpl _value, $Res Function(_$BlockIdTagImpl) _then) : super(_value, _then); + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -464,11 +483,13 @@ class _$BlockIdTagImpl extends BlockIdTag { other.blockTag == blockTag)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, blockTag); - @JsonKey(ignore: true) + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockIdTagImplCopyWith<_$BlockIdTagImpl> get copyWith => @@ -551,7 +572,10 @@ abstract class BlockIdTag extends BlockId { _$BlockIdTagImpl.fromJson; String get blockTag; - @JsonKey(ignore: true) + + /// Create a copy of BlockId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockIdTagImplCopyWith<_$BlockIdTagImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/block_number.freezed.dart b/packages/starknet_provider/lib/src/model/block_number.freezed.dart index 900f553f..e85d1d64 100644 --- a/packages/starknet_provider/lib/src/model/block_number.freezed.dart +++ b/packages/starknet_provider/lib/src/model/block_number.freezed.dart @@ -70,6 +70,8 @@ mixin _$BlockNumber { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this BlockNumber to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$BlockNumberCopyWithImpl<$Res, $Val extends BlockNumber> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -108,6 +113,8 @@ class __$$BlockNumberResultImplCopyWithImpl<$Res> $Res Function(_$BlockNumberResultImpl) _then) : super(_value, _then); + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -150,11 +157,13 @@ class _$BlockNumberResultImpl implements BlockNumberResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockNumberResultImplCopyWith<_$BlockNumberResultImpl> get copyWith => @@ -239,7 +248,10 @@ abstract class BlockNumberResult implements BlockNumber { _$BlockNumberResultImpl.fromJson; int get result; - @JsonKey(ignore: true) + + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockNumberResultImplCopyWith<_$BlockNumberResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -263,6 +275,8 @@ class __$$BlockNumberErrorImplCopyWithImpl<$Res> $Res Function(_$BlockNumberErrorImpl) _then) : super(_value, _then); + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -276,6 +290,8 @@ class __$$BlockNumberErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -313,11 +329,13 @@ class _$BlockNumberErrorImpl implements BlockNumberError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockNumberErrorImplCopyWith<_$BlockNumberErrorImpl> get copyWith => @@ -402,7 +420,10 @@ abstract class BlockNumberError implements BlockNumber { _$BlockNumberErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of BlockNumber + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockNumberErrorImplCopyWith<_$BlockNumberErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/call.freezed.dart b/packages/starknet_provider/lib/src/model/call.freezed.dart index b2ae7364..043fe96c 100644 --- a/packages/starknet_provider/lib/src/model/call.freezed.dart +++ b/packages/starknet_provider/lib/src/model/call.freezed.dart @@ -70,6 +70,8 @@ mixin _$Call { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this Call to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -88,6 +90,9 @@ class _$CallCopyWithImpl<$Res, $Val extends Call> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -107,6 +112,8 @@ class __$$CallResultImplCopyWithImpl<$Res> _$CallResultImpl _value, $Res Function(_$CallResultImpl) _then) : super(_value, _then); + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -156,12 +163,14 @@ class _$CallResultImpl implements CallResult { const DeepCollectionEquality().equals(other._result, _result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_result)); - @JsonKey(ignore: true) + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CallResultImplCopyWith<_$CallResultImpl> get copyWith => @@ -245,7 +254,10 @@ abstract class CallResult implements Call { _$CallResultImpl.fromJson; List get result; - @JsonKey(ignore: true) + + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$CallResultImplCopyWith<_$CallResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -269,6 +281,8 @@ class __$$CallErrorImplCopyWithImpl<$Res> _$CallErrorImpl _value, $Res Function(_$CallErrorImpl) _then) : super(_value, _then); + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -282,6 +296,8 @@ class __$$CallErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -319,11 +335,13 @@ class _$CallErrorImpl implements CallError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$CallErrorImplCopyWith<_$CallErrorImpl> get copyWith => @@ -407,7 +425,10 @@ abstract class CallError implements Call { _$CallErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of Call + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$CallErrorImplCopyWith<_$CallErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/chain_id.freezed.dart b/packages/starknet_provider/lib/src/model/chain_id.freezed.dart index f847a5b5..21d0bae0 100644 --- a/packages/starknet_provider/lib/src/model/chain_id.freezed.dart +++ b/packages/starknet_provider/lib/src/model/chain_id.freezed.dart @@ -70,6 +70,8 @@ mixin _$ChainId { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this ChainId to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -88,6 +90,9 @@ class _$ChainIdCopyWithImpl<$Res, $Val extends ChainId> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -107,6 +112,8 @@ class __$$ChainIdResultImplCopyWithImpl<$Res> _$ChainIdResultImpl _value, $Res Function(_$ChainIdResultImpl) _then) : super(_value, _then); + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -149,11 +156,13 @@ class _$ChainIdResultImpl implements ChainIdResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChainIdResultImplCopyWith<_$ChainIdResultImpl> get copyWith => @@ -237,7 +246,10 @@ abstract class ChainIdResult implements ChainId { _$ChainIdResultImpl.fromJson; String get result; - @JsonKey(ignore: true) + + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChainIdResultImplCopyWith<_$ChainIdResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -261,6 +273,8 @@ class __$$ChainIdErrorImplCopyWithImpl<$Res> _$ChainIdErrorImpl _value, $Res Function(_$ChainIdErrorImpl) _then) : super(_value, _then); + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -274,6 +288,8 @@ class __$$ChainIdErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -311,11 +327,13 @@ class _$ChainIdErrorImpl implements ChainIdError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ChainIdErrorImplCopyWith<_$ChainIdErrorImpl> get copyWith => @@ -399,7 +417,10 @@ abstract class ChainIdError implements ChainId { _$ChainIdErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of ChainId + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$ChainIdErrorImplCopyWith<_$ChainIdErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/contract_class.freezed.dart b/packages/starknet_provider/lib/src/model/contract_class.freezed.dart index 6f58b076..f43bcadf 100644 --- a/packages/starknet_provider/lib/src/model/contract_class.freezed.dart +++ b/packages/starknet_provider/lib/src/model/contract_class.freezed.dart @@ -25,8 +25,12 @@ mixin _$SierraContractClass { EntryPointsByType get entryPointsByType => throw _privateConstructorUsedError; String? get abi => throw _privateConstructorUsedError; + /// Serializes this SierraContractClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $SierraContractClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -56,6 +60,8 @@ class _$SierraContractClassCopyWithImpl<$Res, $Val extends SierraContractClass> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -84,6 +90,8 @@ class _$SierraContractClassCopyWithImpl<$Res, $Val extends SierraContractClass> ) as $Val); } + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $EntryPointsByTypeCopyWith<$Res> get entryPointsByType { @@ -119,6 +127,8 @@ class __$$SierraContractClassImplCopyWithImpl<$Res> $Res Function(_$SierraContractClassImpl) _then) : super(_value, _then); + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -195,7 +205,7 @@ class _$SierraContractClassImpl implements _SierraContractClass { (identical(other.abi, abi) || other.abi == abi)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -204,7 +214,9 @@ class _$SierraContractClassImpl implements _SierraContractClass { entryPointsByType, abi); - @JsonKey(ignore: true) + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SierraContractClassImplCopyWith<_$SierraContractClassImpl> get copyWith => @@ -237,8 +249,11 @@ abstract class _SierraContractClass implements SierraContractClass { EntryPointsByType get entryPointsByType; @override String? get abi; + + /// Create a copy of SierraContractClass + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$SierraContractClassImplCopyWith<_$SierraContractClassImpl> get copyWith => throw _privateConstructorUsedError; } @@ -256,8 +271,12 @@ mixin _$DeprecatedContractClass { List? get abi => throw _privateConstructorUsedError; + /// Serializes this DeprecatedContractClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeprecatedContractClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -287,6 +306,8 @@ class _$DeprecatedContractClassCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -310,6 +331,8 @@ class _$DeprecatedContractClassCopyWithImpl<$Res, ) as $Val); } + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeprecatedCairoEntryPointsByTypeCopyWith<$Res> get entryPointsByType { @@ -348,6 +371,8 @@ class __$$DeprecatedContractClassImplCopyWithImpl<$Res> $Res Function(_$DeprecatedContractClassImpl) _then) : super(_value, _then); + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -414,12 +439,14 @@ class _$DeprecatedContractClassImpl implements _DeprecatedContractClass { const DeepCollectionEquality().equals(other._abi, _abi)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, program, entryPointsByType, const DeepCollectionEquality().hash(_abi)); - @JsonKey(ignore: true) + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeprecatedContractClassImplCopyWith<_$DeprecatedContractClassImpl> @@ -450,8 +477,11 @@ abstract class _DeprecatedContractClass implements DeprecatedContractClass { DeprecatedCairoEntryPointsByType get entryPointsByType; @override List? get abi; + + /// Create a copy of DeprecatedContractClass + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeprecatedContractClassImplCopyWith<_$DeprecatedContractClassImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/contract_storage_diff_item.freezed.dart b/packages/starknet_provider/lib/src/model/contract_storage_diff_item.freezed.dart index a1cfaf71..0228f95a 100644 --- a/packages/starknet_provider/lib/src/model/contract_storage_diff_item.freezed.dart +++ b/packages/starknet_provider/lib/src/model/contract_storage_diff_item.freezed.dart @@ -24,8 +24,12 @@ mixin _$ContractStorageDiffItem { Felt get address => throw _privateConstructorUsedError; List get storageEntries => throw _privateConstructorUsedError; + /// Serializes this ContractStorageDiffItem to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ContractStorageDiffItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ContractStorageDiffItemCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,6 +54,8 @@ class _$ContractStorageDiffItemCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of ContractStorageDiffItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -91,6 +97,8 @@ class __$$ContractStorageDiffItemImplCopyWithImpl<$Res> $Res Function(_$ContractStorageDiffItemImpl) _then) : super(_value, _then); + /// Create a copy of ContractStorageDiffItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -145,12 +153,14 @@ class _$ContractStorageDiffItemImpl implements _ContractStorageDiffItem { .equals(other._storageEntries, _storageEntries)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, address, const DeepCollectionEquality().hash(_storageEntries)); - @JsonKey(ignore: true) + /// Create a copy of ContractStorageDiffItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ContractStorageDiffItemImplCopyWith<_$ContractStorageDiffItemImpl> @@ -178,8 +188,11 @@ abstract class _ContractStorageDiffItem implements ContractStorageDiffItem { Felt get address; @override List get storageEntries; + + /// Create a copy of ContractStorageDiffItem + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ContractStorageDiffItemImplCopyWith<_$ContractStorageDiffItemImpl> get copyWith => throw _privateConstructorUsedError; } @@ -193,8 +206,12 @@ mixin _$StorageItem { Felt get key => throw _privateConstructorUsedError; Felt get value => throw _privateConstructorUsedError; + /// Serializes this StorageItem to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of StorageItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StorageItemCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -218,6 +235,8 @@ class _$StorageItemCopyWithImpl<$Res, $Val extends StorageItem> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of StorageItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -256,6 +275,8 @@ class __$$StorageItemImplCopyWithImpl<$Res> _$StorageItemImpl _value, $Res Function(_$StorageItemImpl) _then) : super(_value, _then); + /// Create a copy of StorageItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -302,11 +323,13 @@ class _$StorageItemImpl implements _StorageItem { (identical(other.value, value) || other.value == value)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, key, value); - @JsonKey(ignore: true) + /// Create a copy of StorageItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StorageItemImplCopyWith<_$StorageItemImpl> get copyWith => @@ -331,8 +354,11 @@ abstract class _StorageItem implements StorageItem { Felt get key; @override Felt get value; + + /// Create a copy of StorageItem + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StorageItemImplCopyWith<_$StorageItemImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/declare_transaction.dart b/packages/starknet_provider/lib/src/model/declare_transaction.dart index 9572245c..00472193 100644 --- a/packages/starknet_provider/lib/src/model/declare_transaction.dart +++ b/packages/starknet_provider/lib/src/model/declare_transaction.dart @@ -1,3 +1,5 @@ +// ignore_for_file: non_constant_identifier_names + import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; import 'package:starknet_provider/starknet_provider.dart'; diff --git a/packages/starknet_provider/lib/src/model/declare_transaction.freezed.dart b/packages/starknet_provider/lib/src/model/declare_transaction.freezed.dart index 64595808..7e65581d 100644 --- a/packages/starknet_provider/lib/src/model/declare_transaction.freezed.dart +++ b/packages/starknet_provider/lib/src/model/declare_transaction.freezed.dart @@ -24,8 +24,12 @@ mixin _$DeclareTransactionRequest { DeclareTransaction get declareTransaction => throw _privateConstructorUsedError; + /// Serializes this DeclareTransactionRequest to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclareTransactionRequestCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,6 +54,8 @@ class _$DeclareTransactionRequestCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclareTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -86,6 +92,8 @@ class __$$DeclareTransactionRequestImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionRequestImpl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -125,11 +133,13 @@ class _$DeclareTransactionRequestImpl implements _DeclareTransactionRequest { other.declareTransaction == declareTransaction)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, declareTransaction); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionRequestImplCopyWith<_$DeclareTransactionRequestImpl> @@ -154,8 +164,11 @@ abstract class _DeclareTransactionRequest implements DeclareTransactionRequest { @override DeclareTransaction get declareTransaction; + + /// Create a copy of DeclareTransactionRequest + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionRequestImplCopyWith<_$DeclareTransactionRequestImpl> get copyWith => throw _privateConstructorUsedError; } @@ -175,8 +188,12 @@ mixin _$DeclareTransactionV1 { DeprecatedContractClass get contractClass => throw _privateConstructorUsedError; + /// Serializes this DeclareTransactionV1 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclareTransactionV1CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -210,6 +227,8 @@ class _$DeclareTransactionV1CopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -253,6 +272,8 @@ class _$DeclareTransactionV1CopyWithImpl<$Res, ) as $Val); } + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeprecatedContractClassCopyWith<$Res> get contractClass { @@ -292,6 +313,8 @@ class __$$DeclareTransactionV1ImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionV1Impl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -397,7 +420,7 @@ class _$DeclareTransactionV1Impl implements _DeclareTransactionV1 { other.contractClass == contractClass)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -409,7 +432,9 @@ class _$DeclareTransactionV1Impl implements _DeclareTransactionV1 { senderAddress, contractClass); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionV1ImplCopyWith<_$DeclareTransactionV1Impl> @@ -453,8 +478,11 @@ abstract class _DeclareTransactionV1 implements DeclareTransactionV1 { Felt get senderAddress; @override DeprecatedContractClass get contractClass; + + /// Create a copy of DeclareTransactionV1 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionV1ImplCopyWith<_$DeclareTransactionV1Impl> get copyWith => throw _privateConstructorUsedError; } @@ -475,8 +503,12 @@ mixin _$DeclareTransactionV2 { throw _privateConstructorUsedError; Felt get compiledClassHash => throw _privateConstructorUsedError; + /// Serializes this DeclareTransactionV2 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclareTransactionV2CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -511,6 +543,8 @@ class _$DeclareTransactionV2CopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -559,6 +593,8 @@ class _$DeclareTransactionV2CopyWithImpl<$Res, ) as $Val); } + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $FlattenSierraContractClassCopyWith<$Res> get contractClass { @@ -599,6 +635,8 @@ class __$$DeclareTransactionV2ImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionV2Impl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -714,7 +752,7 @@ class _$DeclareTransactionV2Impl implements _DeclareTransactionV2 { other.compiledClassHash == compiledClassHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -727,7 +765,9 @@ class _$DeclareTransactionV2Impl implements _DeclareTransactionV2 { contractClass, compiledClassHash); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionV2ImplCopyWith<_$DeclareTransactionV2Impl> @@ -773,8 +813,11 @@ abstract class _DeclareTransactionV2 implements DeclareTransactionV2 { FlattenSierraContractClass get contractClass; @override Felt get compiledClassHash; + + /// Create a copy of DeclareTransactionV2 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionV2ImplCopyWith<_$DeclareTransactionV2Impl> get copyWith => throw _privateConstructorUsedError; } @@ -836,6 +879,8 @@ mixin _$DeclareTransactionResponse { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this DeclareTransactionResponse to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -857,6 +902,9 @@ class _$DeclareTransactionResponseCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -881,6 +929,8 @@ class __$$DeclareTransactionResultImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionResultImpl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -894,6 +944,8 @@ class __$$DeclareTransactionResultImplCopyWithImpl<$Res> )); } + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeclareTransactionResponseResultCopyWith<$Res> get result { @@ -933,11 +985,13 @@ class _$DeclareTransactionResultImpl implements DeclareTransactionResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionResultImplCopyWith<_$DeclareTransactionResultImpl> @@ -1023,7 +1077,10 @@ abstract class DeclareTransactionResult implements DeclareTransactionResponse { _$DeclareTransactionResultImpl.fromJson; DeclareTransactionResponseResult get result; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionResultImplCopyWith<_$DeclareTransactionResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1050,6 +1107,8 @@ class __$$DeclareTransactionErrorImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionErrorImpl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1063,6 +1122,8 @@ class __$$DeclareTransactionErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -1101,11 +1162,13 @@ class _$DeclareTransactionErrorImpl implements DeclareTransactionError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionErrorImplCopyWith<_$DeclareTransactionErrorImpl> @@ -1190,7 +1253,10 @@ abstract class DeclareTransactionError implements DeclareTransactionResponse { _$DeclareTransactionErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionErrorImplCopyWith<_$DeclareTransactionErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1205,8 +1271,12 @@ mixin _$DeclareTransactionResponseResult { Felt get classHash => throw _privateConstructorUsedError; Felt get transactionHash => throw _privateConstructorUsedError; + /// Serializes this DeclareTransactionResponseResult to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclareTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclareTransactionResponseResultCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1233,6 +1303,8 @@ class _$DeclareTransactionResponseResultCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclareTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1274,6 +1346,8 @@ class __$$DeclareTransactionResponseResultImplCopyWithImpl<$Res> $Res Function(_$DeclareTransactionResponseResultImpl) _then) : super(_value, _then); + /// Create a copy of DeclareTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1325,11 +1399,13 @@ class _$DeclareTransactionResponseResultImpl other.transactionHash == transactionHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, classHash, transactionHash); - @JsonKey(ignore: true) + /// Create a copy of DeclareTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTransactionResponseResultImplCopyWith< @@ -1360,8 +1436,11 @@ abstract class _DeclareTransactionResponseResult Felt get classHash; @override Felt get transactionHash; + + /// Create a copy of DeclareTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTransactionResponseResultImplCopyWith< _$DeclareTransactionResponseResultImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/starknet_provider/lib/src/model/declared_contract_item.freezed.dart b/packages/starknet_provider/lib/src/model/declared_contract_item.freezed.dart index 591536f1..36b28640 100644 --- a/packages/starknet_provider/lib/src/model/declared_contract_item.freezed.dart +++ b/packages/starknet_provider/lib/src/model/declared_contract_item.freezed.dart @@ -22,8 +22,12 @@ DeclaredContractItem _$DeclaredContractItemFromJson(Map json) { mixin _$DeclaredContractItem { Felt get classHash => throw _privateConstructorUsedError; + /// Serializes this DeclaredContractItem to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclaredContractItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclaredContractItemCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ class _$DeclaredContractItemCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclaredContractItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -81,6 +87,8 @@ class __$$DeclaredContractItemImplCopyWithImpl<$Res> $Res Function(_$DeclaredContractItemImpl) _then) : super(_value, _then); + /// Create a copy of DeclaredContractItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -120,11 +128,13 @@ class _$DeclaredContractItemImpl implements _DeclaredContractItem { other.classHash == classHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, classHash); - @JsonKey(ignore: true) + /// Create a copy of DeclaredContractItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclaredContractItemImplCopyWith<_$DeclaredContractItemImpl> @@ -149,8 +159,11 @@ abstract class _DeclaredContractItem implements DeclaredContractItem { @override Felt get classHash; + + /// Create a copy of DeclaredContractItem + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclaredContractItemImplCopyWith<_$DeclaredContractItemImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/deploy_account_transaction.freezed.dart b/packages/starknet_provider/lib/src/model/deploy_account_transaction.freezed.dart index c9d4adeb..85da4bd1 100644 --- a/packages/starknet_provider/lib/src/model/deploy_account_transaction.freezed.dart +++ b/packages/starknet_provider/lib/src/model/deploy_account_transaction.freezed.dart @@ -31,8 +31,12 @@ mixin _$DeployAccountTransactionV1 { String get version => throw _privateConstructorUsedError; String get type => throw _privateConstructorUsedError; + /// Serializes this DeployAccountTransactionV1 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeployAccountTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeployAccountTransactionV1CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -66,6 +70,8 @@ class _$DeployAccountTransactionV1CopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeployAccountTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -145,6 +151,8 @@ class __$$DeployAccountTransactionV1ImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTransactionV1Impl) _then) : super(_value, _then); + /// Create a copy of DeployAccountTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -270,7 +278,7 @@ class _$DeployAccountTransactionV1Impl implements _DeployAccountTransactionV1 { (identical(other.type, type) || other.type == type)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -283,7 +291,9 @@ class _$DeployAccountTransactionV1Impl implements _DeployAccountTransactionV1 { version, type); - @JsonKey(ignore: true) + /// Create a copy of DeployAccountTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTransactionV1ImplCopyWith<_$DeployAccountTransactionV1Impl> @@ -330,8 +340,11 @@ abstract class _DeployAccountTransactionV1 String get version; @override String get type; + + /// Create a copy of DeployAccountTransactionV1 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTransactionV1ImplCopyWith<_$DeployAccountTransactionV1Impl> get copyWith => throw _privateConstructorUsedError; } @@ -346,8 +359,12 @@ mixin _$DeployAccountTransactionRequest { DeployAccountTransaction get deployAccountTransaction => throw _privateConstructorUsedError; + /// Serializes this DeployAccountTransactionRequest to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeployAccountTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeployAccountTransactionRequestCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -374,6 +391,8 @@ class _$DeployAccountTransactionRequestCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeployAccountTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -410,6 +429,8 @@ class __$$DeployAccountTransactionRequestImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTransactionRequestImpl) _then) : super(_value, _then); + /// Create a copy of DeployAccountTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -453,11 +474,13 @@ class _$DeployAccountTransactionRequestImpl other.deployAccountTransaction == deployAccountTransaction)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, deployAccountTransaction); - @JsonKey(ignore: true) + /// Create a copy of DeployAccountTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTransactionRequestImplCopyWith< @@ -484,8 +507,11 @@ abstract class _DeployAccountTransactionRequest @override DeployAccountTransaction get deployAccountTransaction; + + /// Create a copy of DeployAccountTransactionRequest + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTransactionRequestImplCopyWith< _$DeployAccountTransactionRequestImpl> get copyWith => throw _privateConstructorUsedError; @@ -549,6 +575,8 @@ mixin _$DeployAccountTransactionResponse { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this DeployAccountTransactionResponse to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -571,6 +599,9 @@ class _$DeployAccountTransactionResponseCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -595,6 +626,8 @@ class __$$DeployAccountTransactionResultImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTransactionResultImpl) _then) : super(_value, _then); + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -608,6 +641,8 @@ class __$$DeployAccountTransactionResultImplCopyWithImpl<$Res> )); } + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeployAccountTransactionResponseResultCopyWith<$Res> get result { @@ -649,11 +684,13 @@ class _$DeployAccountTransactionResultImpl (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTransactionResultImplCopyWith< @@ -742,7 +779,10 @@ abstract class DeployAccountTransactionResult _$DeployAccountTransactionResultImpl.fromJson; DeployAccountTransactionResponseResult get result; - @JsonKey(ignore: true) + + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTransactionResultImplCopyWith< _$DeployAccountTransactionResultImpl> get copyWith => throw _privateConstructorUsedError; @@ -770,6 +810,8 @@ class __$$DeployAccountTransactionErrorImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTransactionErrorImpl) _then) : super(_value, _then); + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -783,6 +825,8 @@ class __$$DeployAccountTransactionErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -823,11 +867,13 @@ class _$DeployAccountTransactionErrorImpl (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTransactionErrorImplCopyWith< @@ -916,7 +962,10 @@ abstract class DeployAccountTransactionError _$DeployAccountTransactionErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of DeployAccountTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTransactionErrorImplCopyWith< _$DeployAccountTransactionErrorImpl> get copyWith => throw _privateConstructorUsedError; @@ -933,8 +982,12 @@ mixin _$DeployAccountTransactionResponseResult { Felt get transactionHash => throw _privateConstructorUsedError; Felt get contractAddress => throw _privateConstructorUsedError; + /// Serializes this DeployAccountTransactionResponseResult to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeployAccountTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeployAccountTransactionResponseResultCopyWith< DeployAccountTransactionResponseResult> get copyWith => throw _privateConstructorUsedError; @@ -962,6 +1015,8 @@ class _$DeployAccountTransactionResponseResultCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeployAccountTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1003,6 +1058,8 @@ class __$$DeployAccountTransactionResponseResultImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTransactionResponseResultImpl) _then) : super(_value, _then); + /// Create a copy of DeployAccountTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1054,12 +1111,14 @@ class _$DeployAccountTransactionResponseResultImpl other.contractAddress == contractAddress)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, transactionHash, contractAddress); - @JsonKey(ignore: true) + /// Create a copy of DeployAccountTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTransactionResponseResultImplCopyWith< @@ -1091,8 +1150,11 @@ abstract class _DeployAccountTransactionResponseResult Felt get transactionHash; @override Felt get contractAddress; + + /// Create a copy of DeployAccountTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTransactionResponseResultImplCopyWith< _$DeployAccountTransactionResponseResultImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/starknet_provider/lib/src/model/deployed_contract_item.freezed.dart b/packages/starknet_provider/lib/src/model/deployed_contract_item.freezed.dart index 589a6987..3ee9e5b4 100644 --- a/packages/starknet_provider/lib/src/model/deployed_contract_item.freezed.dart +++ b/packages/starknet_provider/lib/src/model/deployed_contract_item.freezed.dart @@ -23,8 +23,12 @@ mixin _$DeployedContractItem { Felt get address => throw _privateConstructorUsedError; Felt get classHash => throw _privateConstructorUsedError; + /// Serializes this DeployedContractItem to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeployedContractItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeployedContractItemCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$DeployedContractItemCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeployedContractItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -87,6 +93,8 @@ class __$$DeployedContractItemImplCopyWithImpl<$Res> $Res Function(_$DeployedContractItemImpl) _then) : super(_value, _then); + /// Create a copy of DeployedContractItem + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -135,11 +143,13 @@ class _$DeployedContractItemImpl implements _DeployedContractItem { other.classHash == classHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, address, classHash); - @JsonKey(ignore: true) + /// Create a copy of DeployedContractItem + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployedContractItemImplCopyWith<_$DeployedContractItemImpl> @@ -167,8 +177,11 @@ abstract class _DeployedContractItem implements DeployedContractItem { Felt get address; @override Felt get classHash; + + /// Create a copy of DeployedContractItem + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployedContractItemImplCopyWith<_$DeployedContractItemImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/estimate_fee.dart b/packages/starknet_provider/lib/src/model/estimate_fee.dart index 92ffe60b..f9246a8f 100644 --- a/packages/starknet_provider/lib/src/model/estimate_fee.dart +++ b/packages/starknet_provider/lib/src/model/estimate_fee.dart @@ -1,4 +1,4 @@ -// ignore_for_file: invalid_annotation_target +// ignore_for_file: invalid_annotation_target, non_constant_identifier_names import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; @@ -37,8 +37,9 @@ class SimulationFlag with _$SimulationFlag { factory SimulationFlag.fromJson(Map json) => _$SimulationFlagFromJson(json); + @override Map toJson() => { - 'type': this.when( + 'type': when( skipValidate: () => "SKIP_VALIDATE", skipFeeCharge: () => "SKIP_FEE_CHARGE", ), diff --git a/packages/starknet_provider/lib/src/model/estimate_fee.freezed.dart b/packages/starknet_provider/lib/src/model/estimate_fee.freezed.dart index 200e84bb..5e6d664d 100644 --- a/packages/starknet_provider/lib/src/model/estimate_fee.freezed.dart +++ b/packages/starknet_provider/lib/src/model/estimate_fee.freezed.dart @@ -70,6 +70,8 @@ mixin _$EstimateFee { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this EstimateFee to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$EstimateFeeCopyWithImpl<$Res, $Val extends EstimateFee> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -108,6 +113,8 @@ class __$$EstimateFeeResultImplCopyWithImpl<$Res> $Res Function(_$EstimateFeeResultImpl) _then) : super(_value, _then); + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -157,12 +164,14 @@ class _$EstimateFeeResultImpl implements EstimateFeeResult { const DeepCollectionEquality().equals(other._result, _result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_result)); - @JsonKey(ignore: true) + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EstimateFeeResultImplCopyWith<_$EstimateFeeResultImpl> get copyWith => @@ -247,7 +256,10 @@ abstract class EstimateFeeResult implements EstimateFee { _$EstimateFeeResultImpl.fromJson; List get result; - @JsonKey(ignore: true) + + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$EstimateFeeResultImplCopyWith<_$EstimateFeeResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -271,6 +283,8 @@ class __$$EstimateFeeErrorImplCopyWithImpl<$Res> $Res Function(_$EstimateFeeErrorImpl) _then) : super(_value, _then); + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -284,6 +298,8 @@ class __$$EstimateFeeErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -321,11 +337,13 @@ class _$EstimateFeeErrorImpl implements EstimateFeeError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EstimateFeeErrorImplCopyWith<_$EstimateFeeErrorImpl> get copyWith => @@ -410,7 +428,10 @@ abstract class EstimateFeeError implements EstimateFee { _$EstimateFeeErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of EstimateFee + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$EstimateFeeErrorImplCopyWith<_$EstimateFeeErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -471,6 +492,8 @@ mixin _$SimulationFlag { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this SimulationFlag to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -490,6 +513,9 @@ class _$SimulationFlagCopyWithImpl<$Res, $Val extends SimulationFlag> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of SimulationFlag + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -506,6 +532,9 @@ class __$$SkipValidateImplCopyWithImpl<$Res> __$$SkipValidateImplCopyWithImpl( _$SkipValidateImpl _value, $Res Function(_$SkipValidateImpl) _then) : super(_value, _then); + + /// Create a copy of SimulationFlag + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -532,7 +561,7 @@ class _$SkipValidateImpl implements SkipValidate { (other.runtimeType == runtimeType && other is _$SkipValidateImpl); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => runtimeType.hashCode; @@ -627,6 +656,9 @@ class __$$SkipFeeChargeImplCopyWithImpl<$Res> __$$SkipFeeChargeImplCopyWithImpl( _$SkipFeeChargeImpl _value, $Res Function(_$SkipFeeChargeImpl) _then) : super(_value, _then); + + /// Create a copy of SimulationFlag + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -653,7 +685,7 @@ class _$SkipFeeChargeImpl implements SkipFeeCharge { (other.runtimeType == runtimeType && other is _$SkipFeeChargeImpl); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => runtimeType.hashCode; @@ -943,8 +975,13 @@ mixin _$BroadcastedTxn { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this BroadcastedTxn to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $BroadcastedTxnCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -968,6 +1005,8 @@ class _$BroadcastedTxnCopyWithImpl<$Res, $Val extends BroadcastedTxn> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1016,6 +1055,8 @@ class __$$BroadcastedInvokeTxnV0ImplCopyWithImpl<$Res> $Res Function(_$BroadcastedInvokeTxnV0Impl) _then) : super(_value, _then); + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1144,7 +1185,7 @@ class _$BroadcastedInvokeTxnV0Impl implements BroadcastedInvokeTxnV0 { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1157,7 +1198,9 @@ class _$BroadcastedInvokeTxnV0Impl implements BroadcastedInvokeTxnV0 { entryPointSelector, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BroadcastedInvokeTxnV0ImplCopyWith<_$BroadcastedInvokeTxnV0Impl> @@ -1395,7 +1438,8 @@ abstract class BroadcastedInvokeTxnV0 implements BroadcastedTxn { factory BroadcastedInvokeTxnV0.fromJson(Map json) = _$BroadcastedInvokeTxnV0Impl.fromJson; - @override // start of BROADCASTED_TXN_COMMON_PROPERTIES +// start of BROADCASTED_TXN_COMMON_PROPERTIES + @override String get type; @JsonKey(toJson: maxFeeToJson) Felt get maxFee; @@ -1407,8 +1451,11 @@ abstract class BroadcastedInvokeTxnV0 implements BroadcastedTxn { Felt get contractAddress; Felt get entryPointSelector; List get calldata; + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BroadcastedInvokeTxnV0ImplCopyWith<_$BroadcastedInvokeTxnV0Impl> get copyWith => throw _privateConstructorUsedError; } @@ -1441,6 +1488,8 @@ class __$$BroadcastedInvokeTxnV1ImplCopyWithImpl<$Res> $Res Function(_$BroadcastedInvokeTxnV1Impl) _then) : super(_value, _then); + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1559,7 +1608,7 @@ class _$BroadcastedInvokeTxnV1Impl implements BroadcastedInvokeTxnV1 { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1571,7 +1620,9 @@ class _$BroadcastedInvokeTxnV1Impl implements BroadcastedInvokeTxnV1 { senderAddress, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BroadcastedInvokeTxnV1ImplCopyWith<_$BroadcastedInvokeTxnV1Impl> @@ -1808,7 +1859,8 @@ abstract class BroadcastedInvokeTxnV1 implements BroadcastedTxn { factory BroadcastedInvokeTxnV1.fromJson(Map json) = _$BroadcastedInvokeTxnV1Impl.fromJson; - @override // start of BROADCASTED_TXN_COMMON_PROPERTIES +// start of BROADCASTED_TXN_COMMON_PROPERTIES + @override String get type; @JsonKey(toJson: maxFeeToJson) Felt get maxFee; @@ -1819,8 +1871,11 @@ abstract class BroadcastedInvokeTxnV1 implements BroadcastedTxn { // start of INVOKE_TXN_V1 Felt get senderAddress; List get calldata; + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BroadcastedInvokeTxnV1ImplCopyWith<_$BroadcastedInvokeTxnV1Impl> get copyWith => throw _privateConstructorUsedError; } @@ -1854,6 +1909,8 @@ class __$$BroadcastedDeclareTxnImplCopyWithImpl<$Res> $Res Function(_$BroadcastedDeclareTxnImpl) _then) : super(_value, _then); + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1897,6 +1954,8 @@ class __$$BroadcastedDeclareTxnImplCopyWithImpl<$Res> )); } + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeprecatedContractClassCopyWith<$Res> get contractClass { @@ -1975,7 +2034,7 @@ class _$BroadcastedDeclareTxnImpl implements BroadcastedDeclareTxn { other.senderAddress == senderAddress)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1987,7 +2046,9 @@ class _$BroadcastedDeclareTxnImpl implements BroadcastedDeclareTxn { contractClass, senderAddress); - @JsonKey(ignore: true) + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BroadcastedDeclareTxnImplCopyWith<_$BroadcastedDeclareTxnImpl> @@ -2224,7 +2285,8 @@ abstract class BroadcastedDeclareTxn implements BroadcastedTxn { factory BroadcastedDeclareTxn.fromJson(Map json) = _$BroadcastedDeclareTxnImpl.fromJson; - @override // start of BROADCASTED_TXN_COMMON_PROPERTIES +// start of BROADCASTED_TXN_COMMON_PROPERTIES + @override String get type; @JsonKey(toJson: maxFeeToJson) Felt get maxFee; @@ -2234,8 +2296,11 @@ abstract class BroadcastedDeclareTxn implements BroadcastedTxn { Felt get nonce; // end of BROADCASTED_TXN_COMMON_PROPERTIES DeprecatedContractClass get contractClass; Felt get senderAddress; + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BroadcastedDeclareTxnImplCopyWith<_$BroadcastedDeclareTxnImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2266,6 +2331,8 @@ class __$$BroadcastedDeployTxnImplCopyWithImpl<$Res> $Res Function(_$BroadcastedDeployTxnImpl) _then) : super(_value, _then); + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2299,6 +2366,8 @@ class __$$BroadcastedDeployTxnImplCopyWithImpl<$Res> )); } + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $DeprecatedContractClassCopyWith<$Res> get contractClass { @@ -2367,7 +2436,7 @@ class _$BroadcastedDeployTxnImpl implements BroadcastedDeployTxn { .equals(other._constructorCalldata, _constructorCalldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2377,7 +2446,9 @@ class _$BroadcastedDeployTxnImpl implements BroadcastedDeployTxn { contractAddressSalt, const DeepCollectionEquality().hash(_constructorCalldata)); - @JsonKey(ignore: true) + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BroadcastedDeployTxnImplCopyWith<_$BroadcastedDeployTxnImpl> @@ -2614,15 +2685,18 @@ abstract class BroadcastedDeployTxn implements BroadcastedTxn { factory BroadcastedDeployTxn.fromJson(Map json) = _$BroadcastedDeployTxnImpl.fromJson; - DeprecatedContractClass get contractClass; - @override // start of DEPLOY_TXN_PROPERTIES + DeprecatedContractClass get contractClass; // start of DEPLOY_TXN_PROPERTIES + @override String get version; @override String get type; Felt get contractAddressSalt; List get constructorCalldata; + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BroadcastedDeployTxnImplCopyWith<_$BroadcastedDeployTxnImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2657,6 +2731,8 @@ class __$$BroadcastedDeployAccountTxnImplCopyWithImpl<$Res> $Res Function(_$BroadcastedDeployAccountTxnImpl) _then) : super(_value, _then); + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2787,7 +2863,7 @@ class _$BroadcastedDeployAccountTxnImpl implements BroadcastedDeployAccountTxn { (identical(other.nonce, nonce) || other.nonce == nonce)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2800,7 +2876,9 @@ class _$BroadcastedDeployAccountTxnImpl implements BroadcastedDeployAccountTxn { const DeepCollectionEquality().hash(_signature), nonce); - @JsonKey(ignore: true) + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BroadcastedDeployAccountTxnImplCopyWith<_$BroadcastedDeployAccountTxnImpl> @@ -3040,8 +3118,9 @@ abstract class BroadcastedDeployAccountTxn implements BroadcastedTxn { Felt get contractAddressSalt; Felt get classHash; - List get constructorCalldata; - @override // start of BROADCASTED_TXN_COMMON_PROPERTIES + List + get constructorCalldata; // start of BROADCASTED_TXN_COMMON_PROPERTIES + @override String get type; @JsonKey(toJson: maxFeeToJson) Felt get maxFee; @@ -3049,8 +3128,11 @@ abstract class BroadcastedDeployAccountTxn implements BroadcastedTxn { String get version; List get signature; Felt get nonce; + + /// Create a copy of BroadcastedTxn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BroadcastedDeployAccountTxnImplCopyWith<_$BroadcastedDeployAccountTxnImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/event.freezed.dart b/packages/starknet_provider/lib/src/model/event.freezed.dart index e5d94dbd..19b7aef1 100644 --- a/packages/starknet_provider/lib/src/model/event.freezed.dart +++ b/packages/starknet_provider/lib/src/model/event.freezed.dart @@ -25,8 +25,12 @@ mixin _$Event { List? get keys => throw _privateConstructorUsedError; List? get data => throw _privateConstructorUsedError; + /// Serializes this Event to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Event + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $EventCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ class _$EventCopyWithImpl<$Res, $Val extends Event> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Event + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -90,6 +96,8 @@ class __$$EventImplCopyWithImpl<$Res> _$EventImpl _value, $Res Function(_$EventImpl) _then) : super(_value, _then); + /// Create a copy of Event + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -167,7 +175,7 @@ class _$EventImpl implements _Event { const DeepCollectionEquality().equals(other._data, _data)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -175,7 +183,9 @@ class _$EventImpl implements _Event { const DeepCollectionEquality().hash(_keys), const DeepCollectionEquality().hash(_data)); - @JsonKey(ignore: true) + /// Create a copy of Event + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EventImplCopyWith<_$EventImpl> get copyWith => @@ -198,13 +208,16 @@ abstract class _Event implements Event { factory _Event.fromJson(Map json) = _$EventImpl.fromJson; @override - Felt? get fromAddress; - @override // start of EVENT_CONTENT + Felt? get fromAddress; // start of EVENT_CONTENT + @override List? get keys; @override List? get data; + + /// Create a copy of Event + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$EventImplCopyWith<_$EventImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/fee_estimate.freezed.dart b/packages/starknet_provider/lib/src/model/fee_estimate.freezed.dart index 6cf84c37..f70232ab 100644 --- a/packages/starknet_provider/lib/src/model/fee_estimate.freezed.dart +++ b/packages/starknet_provider/lib/src/model/fee_estimate.freezed.dart @@ -24,8 +24,12 @@ mixin _$FeeEstimate { String get gasPrice => throw _privateConstructorUsedError; String get overallFee => throw _privateConstructorUsedError; + /// Serializes this FeeEstimate to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of FeeEstimate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $FeeEstimateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$FeeEstimateCopyWithImpl<$Res, $Val extends FeeEstimate> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of FeeEstimate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -92,6 +98,8 @@ class __$$FeeEstimateImplCopyWithImpl<$Res> _$FeeEstimateImpl _value, $Res Function(_$FeeEstimateImpl) _then) : super(_value, _then); + /// Create a copy of FeeEstimate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -152,12 +160,14 @@ class _$FeeEstimateImpl implements _FeeEstimate { other.overallFee == overallFee)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, gasConsumed, gasPrice, overallFee); - @JsonKey(ignore: true) + /// Create a copy of FeeEstimate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FeeEstimateImplCopyWith<_$FeeEstimateImpl> get copyWith => @@ -186,8 +196,11 @@ abstract class _FeeEstimate implements FeeEstimate { String get gasPrice; @override String get overallFee; + + /// Create a copy of FeeEstimate + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$FeeEstimateImplCopyWith<_$FeeEstimateImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/function_call.freezed.dart b/packages/starknet_provider/lib/src/model/function_call.freezed.dart index 5206de33..5eb646bb 100644 --- a/packages/starknet_provider/lib/src/model/function_call.freezed.dart +++ b/packages/starknet_provider/lib/src/model/function_call.freezed.dart @@ -24,8 +24,12 @@ mixin _$FunctionCall { Felt get entryPointSelector => throw _privateConstructorUsedError; List get calldata => throw _privateConstructorUsedError; + /// Serializes this FunctionCall to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of FunctionCall + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $FunctionCallCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -50,6 +54,8 @@ class _$FunctionCallCopyWithImpl<$Res, $Val extends FunctionCall> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of FunctionCall + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -94,6 +100,8 @@ class __$$FunctionCallImplCopyWithImpl<$Res> _$FunctionCallImpl _value, $Res Function(_$FunctionCallImpl) _then) : super(_value, _then); + /// Create a copy of FunctionCall + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -159,12 +167,14 @@ class _$FunctionCallImpl implements _FunctionCall { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, contractAddress, entryPointSelector, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of FunctionCall + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$FunctionCallImplCopyWith<_$FunctionCallImpl> get copyWith => @@ -193,8 +203,11 @@ abstract class _FunctionCall implements FunctionCall { Felt get entryPointSelector; @override List get calldata; + + /// Create a copy of FunctionCall + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$FunctionCallImplCopyWith<_$FunctionCallImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_block_txn_count.freezed.dart b/packages/starknet_provider/lib/src/model/get_block_txn_count.freezed.dart index e1f83a23..a3b69e2a 100644 --- a/packages/starknet_provider/lib/src/model/get_block_txn_count.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_block_txn_count.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetBlockTxnCount { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetBlockTxnCount to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetBlockTxnCountCopyWithImpl<$Res, $Val extends GetBlockTxnCount> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -108,6 +113,8 @@ class __$$BlockTxnCountResultImplCopyWithImpl<$Res> $Res Function(_$BlockTxnCountResultImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -150,11 +157,13 @@ class _$BlockTxnCountResultImpl implements BlockTxnCountResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockTxnCountResultImplCopyWith<_$BlockTxnCountResultImpl> get copyWith => @@ -239,7 +248,10 @@ abstract class BlockTxnCountResult implements GetBlockTxnCount { _$BlockTxnCountResultImpl.fromJson; int get result; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockTxnCountResultImplCopyWith<_$BlockTxnCountResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -264,6 +276,8 @@ class __$$GetBlockTxnCountErrorImplCopyWithImpl<$Res> $Res Function(_$GetBlockTxnCountErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -277,6 +291,8 @@ class __$$GetBlockTxnCountErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -314,11 +330,13 @@ class _$GetBlockTxnCountErrorImpl implements GetBlockTxnCountError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetBlockTxnCountErrorImplCopyWith<_$GetBlockTxnCountErrorImpl> @@ -403,7 +421,10 @@ abstract class GetBlockTxnCountError implements GetBlockTxnCount { _$GetBlockTxnCountErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockTxnCount + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetBlockTxnCountErrorImplCopyWith<_$GetBlockTxnCountErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_block_with_tx_hashes.freezed.dart b/packages/starknet_provider/lib/src/model/get_block_with_tx_hashes.freezed.dart index 5c88a76f..4ce176d9 100644 --- a/packages/starknet_provider/lib/src/model/get_block_with_tx_hashes.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_block_with_tx_hashes.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetBlockWithTxHashes { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetBlockWithTxHashes to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -90,6 +92,9 @@ class _$GetBlockWithTxHashesCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -114,6 +119,8 @@ class __$$GetBlockWithTxHashesResultImplCopyWithImpl<$Res> $Res Function(_$GetBlockWithTxHashesResultImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -127,6 +134,8 @@ class __$$GetBlockWithTxHashesResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $BlockWithTxnHashesCopyWith<$Res> get result { @@ -165,11 +174,13 @@ class _$GetBlockWithTxHashesResultImpl implements GetBlockWithTxHashesResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetBlockWithTxHashesResultImplCopyWith<_$GetBlockWithTxHashesResultImpl> @@ -254,7 +265,10 @@ abstract class GetBlockWithTxHashesResult implements GetBlockWithTxHashes { _$GetBlockWithTxHashesResultImpl.fromJson; BlockWithTxnHashes get result; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetBlockWithTxHashesResultImplCopyWith<_$GetBlockWithTxHashesResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -281,6 +295,8 @@ class __$$GetBlockWithTxHashesErrorImplCopyWithImpl<$Res> $Res Function(_$GetBlockWithTxHashesErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -294,6 +310,8 @@ class __$$GetBlockWithTxHashesErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -332,11 +350,13 @@ class _$GetBlockWithTxHashesErrorImpl implements GetBlockWithTxHashesError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetBlockWithTxHashesErrorImplCopyWith<_$GetBlockWithTxHashesErrorImpl> @@ -421,7 +441,10 @@ abstract class GetBlockWithTxHashesError implements GetBlockWithTxHashes { _$GetBlockWithTxHashesErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockWithTxHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetBlockWithTxHashesErrorImplCopyWith<_$GetBlockWithTxHashesErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -519,8 +542,13 @@ mixin _$BlockWithTxnHashes { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this BlockWithTxnHashes to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $BlockWithTxnHashesCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -548,6 +576,8 @@ class _$BlockWithTxnHashesCopyWithImpl<$Res, $Val extends BlockWithTxnHashes> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -604,6 +634,8 @@ class __$$ResultingBlockImplCopyWithImpl<$Res> _$ResultingBlockImpl _value, $Res Function(_$ResultingBlockImpl) _then) : super(_value, _then); + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -723,7 +755,7 @@ class _$ResultingBlockImpl implements ResultingBlock { .equals(other._transactions, _transactions)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -736,7 +768,9 @@ class _$ResultingBlockImpl implements ResultingBlock { sequencerAddress, const DeepCollectionEquality().hash(_transactions)); - @JsonKey(ignore: true) + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ResultingBlockImplCopyWith<_$ResultingBlockImpl> get copyWith => @@ -875,8 +909,11 @@ abstract class ResultingBlock implements BlockWithTxnHashes { Felt get sequencerAddress; @override List get transactions; + + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ResultingBlockImplCopyWith<_$ResultingBlockImpl> get copyWith => throw _privateConstructorUsedError; } @@ -904,6 +941,8 @@ class __$$PendingBlockImplCopyWithImpl<$Res> _$PendingBlockImpl _value, $Res Function(_$PendingBlockImpl) _then) : super(_value, _then); + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -986,7 +1025,7 @@ class _$PendingBlockImpl implements PendingBlock { other.parentHash == parentHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -995,7 +1034,9 @@ class _$PendingBlockImpl implements PendingBlock { sequencerAddress, parentHash); - @JsonKey(ignore: true) + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingBlockImplCopyWith<_$PendingBlockImpl> get copyWith => @@ -1124,8 +1165,11 @@ abstract class PendingBlock implements BlockWithTxnHashes { Felt get sequencerAddress; @override Felt get parentHash; + + /// Create a copy of BlockWithTxnHashes + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingBlockImplCopyWith<_$PendingBlockImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_block_with_txs.freezed.dart b/packages/starknet_provider/lib/src/model/get_block_with_txs.freezed.dart index 5f1dc616..60189aef 100644 --- a/packages/starknet_provider/lib/src/model/get_block_with_txs.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_block_with_txs.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetBlockWithTxs { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetBlockWithTxs to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetBlockWithTxsCopyWithImpl<$Res, $Val extends GetBlockWithTxs> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -111,6 +116,8 @@ class __$$GetBlockWithTxsResultImplCopyWithImpl<$Res> $Res Function(_$GetBlockWithTxsResultImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -124,6 +131,8 @@ class __$$GetBlockWithTxsResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $BlockWithTxsCopyWith<$Res> get result { @@ -161,11 +170,13 @@ class _$GetBlockWithTxsResultImpl implements GetBlockWithTxsResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetBlockWithTxsResultImplCopyWith<_$GetBlockWithTxsResultImpl> @@ -250,7 +261,10 @@ abstract class GetBlockWithTxsResult implements GetBlockWithTxs { _$GetBlockWithTxsResultImpl.fromJson; BlockWithTxs get result; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetBlockWithTxsResultImplCopyWith<_$GetBlockWithTxsResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -274,6 +288,8 @@ class __$$GetBlockWithTxsErrorImplCopyWithImpl<$Res> $Res Function(_$GetBlockWithTxsErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -287,6 +303,8 @@ class __$$GetBlockWithTxsErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -324,11 +342,13 @@ class _$GetBlockWithTxsErrorImpl implements GetBlockWithTxsError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetBlockWithTxsErrorImplCopyWith<_$GetBlockWithTxsErrorImpl> @@ -414,7 +434,10 @@ abstract class GetBlockWithTxsError implements GetBlockWithTxs { _$GetBlockWithTxsErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetBlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetBlockWithTxsErrorImplCopyWith<_$GetBlockWithTxsErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -515,8 +538,13 @@ mixin _$BlockWithTxs { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this BlockWithTxs to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $BlockWithTxsCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -544,6 +572,8 @@ class _$BlockWithTxsCopyWithImpl<$Res, $Val extends BlockWithTxs> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -600,6 +630,8 @@ class __$$BlockWithTxsResponseImplCopyWithImpl<$Res> $Res Function(_$BlockWithTxsResponseImpl) _then) : super(_value, _then); + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -724,7 +756,7 @@ class _$BlockWithTxsResponseImpl implements BlockWithTxsResponse { other.sequencerAddress == sequencerAddress)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -737,7 +769,9 @@ class _$BlockWithTxsResponseImpl implements BlockWithTxsResponse { timestamp, sequencerAddress); - @JsonKey(ignore: true) + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$BlockWithTxsResponseImplCopyWith<_$BlockWithTxsResponseImpl> @@ -865,11 +899,11 @@ abstract class BlockWithTxsResponse implements BlockWithTxs { factory BlockWithTxsResponse.fromJson(Map json) = _$BlockWithTxsResponseImpl.fromJson; - String get status; - @override //Start of BLOCK_BODY_WITH_TXS - List get transactions; - @override //End of BLOCK_BODY_WITH_TXS + String get status; //Start of BLOCK_BODY_WITH_TXS + @override + List get transactions; //End of BLOCK_BODY_WITH_TXS //Start of BLOCK_HEADER + @override Felt get blockHash; Felt get parentHash; int get blockNumber; @@ -878,8 +912,11 @@ abstract class BlockWithTxsResponse implements BlockWithTxs { int get timestamp; @override Felt get sequencerAddress; + + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$BlockWithTxsResponseImplCopyWith<_$BlockWithTxsResponseImpl> get copyWith => throw _privateConstructorUsedError; } @@ -909,6 +946,8 @@ class __$$PendingBlockWithTxsResultImplCopyWithImpl<$Res> $Res Function(_$PendingBlockWithTxsResultImpl) _then) : super(_value, _then); + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -994,7 +1033,7 @@ class _$PendingBlockWithTxsResultImpl implements PendingBlockWithTxsResult { other.blockHash == blockHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1003,7 +1042,9 @@ class _$PendingBlockWithTxsResultImpl implements PendingBlockWithTxsResult { sequencerAddress, blockHash); - @JsonKey(ignore: true) + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingBlockWithTxsResultImplCopyWith<_$PendingBlockWithTxsResultImpl> @@ -1124,16 +1165,20 @@ abstract class PendingBlockWithTxsResult implements BlockWithTxs { factory PendingBlockWithTxsResult.fromJson(Map json) = _$PendingBlockWithTxsResultImpl.fromJson; - @override // Start of BLOCK_BODY_WITH_TXS - List get transactions; - @override // End of BLOCK_BODY_WITH_TXS +// Start of BLOCK_BODY_WITH_TXS + @override + List get transactions; // End of BLOCK_BODY_WITH_TXS + @override int get timestamp; @override Felt get sequencerAddress; @override Felt get blockHash; + + /// Create a copy of BlockWithTxs + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingBlockWithTxsResultImplCopyWith<_$PendingBlockWithTxsResultImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_class.freezed.dart b/packages/starknet_provider/lib/src/model/get_class.freezed.dart index e8c7910d..1cef43cc 100644 --- a/packages/starknet_provider/lib/src/model/get_class.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_class.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetClass { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -88,6 +90,9 @@ class _$GetClassCopyWithImpl<$Res, $Val extends GetClass> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -107,6 +112,8 @@ class __$$GetClassResultImplCopyWithImpl<$Res> _$GetClassResultImpl _value, $Res Function(_$GetClassResultImpl) _then) : super(_value, _then); + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -149,11 +156,13 @@ class _$GetClassResultImpl implements _GetClassResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetClassResultImplCopyWith<_$GetClassResultImpl> get copyWith => @@ -238,7 +247,10 @@ abstract class _GetClassResult implements GetClass { _$GetClassResultImpl.fromJson; IContractClass get result; - @JsonKey(ignore: true) + + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetClassResultImplCopyWith<_$GetClassResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -262,6 +274,8 @@ class __$$GetClassErrorImplCopyWithImpl<$Res> _$GetClassErrorImpl _value, $Res Function(_$GetClassErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -275,6 +289,8 @@ class __$$GetClassErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -312,11 +328,13 @@ class _$GetClassErrorImpl implements _GetClassError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetClassErrorImplCopyWith<_$GetClassErrorImpl> get copyWith => @@ -400,7 +418,10 @@ abstract class _GetClassError implements GetClass { _$GetClassErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetClassErrorImplCopyWith<_$GetClassErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_class_hash_at.freezed.dart b/packages/starknet_provider/lib/src/model/get_class_hash_at.freezed.dart index 74de3980..822a6ff2 100644 --- a/packages/starknet_provider/lib/src/model/get_class_hash_at.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_class_hash_at.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetClassHashAt { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetClassHashAt to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetClassHashAtCopyWithImpl<$Res, $Val extends GetClassHashAt> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -108,6 +113,8 @@ class __$$GetClassHashAtResultImplCopyWithImpl<$Res> $Res Function(_$GetClassHashAtResultImpl) _then) : super(_value, _then); + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -150,11 +157,13 @@ class _$GetClassHashAtResultImpl implements GetClassHashAtResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetClassHashAtResultImplCopyWith<_$GetClassHashAtResultImpl> @@ -240,7 +249,10 @@ abstract class GetClassHashAtResult implements GetClassHashAt { _$GetClassHashAtResultImpl.fromJson; Felt get result; - @JsonKey(ignore: true) + + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetClassHashAtResultImplCopyWith<_$GetClassHashAtResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -264,6 +276,8 @@ class __$$GetClassHashAtErrorImplCopyWithImpl<$Res> $Res Function(_$GetClassHashAtErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -277,6 +291,8 @@ class __$$GetClassHashAtErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -314,11 +330,13 @@ class _$GetClassHashAtErrorImpl implements GetClassHashAtError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetClassHashAtErrorImplCopyWith<_$GetClassHashAtErrorImpl> get copyWith => @@ -403,7 +421,10 @@ abstract class GetClassHashAtError implements GetClassHashAt { _$GetClassHashAtErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetClassHashAt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetClassHashAtErrorImplCopyWith<_$GetClassHashAtErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_events.dart b/packages/starknet_provider/lib/src/model/get_events.dart index 6a625614..0286eb22 100644 --- a/packages/starknet_provider/lib/src/model/get_events.dart +++ b/packages/starknet_provider/lib/src/model/get_events.dart @@ -1,4 +1,4 @@ -// ignore_for_file: invalid_annotation_target +// ignore_for_file: invalid_annotation_target, non_constant_identifier_names import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; diff --git a/packages/starknet_provider/lib/src/model/get_events.freezed.dart b/packages/starknet_provider/lib/src/model/get_events.freezed.dart index b919acf1..3eed5ae1 100644 --- a/packages/starknet_provider/lib/src/model/get_events.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_events.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetEvents { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetEvents to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -88,6 +90,9 @@ class _$GetEventsCopyWithImpl<$Res, $Val extends GetEvents> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -109,6 +114,8 @@ class __$$GetEventsResultImplCopyWithImpl<$Res> _$GetEventsResultImpl _value, $Res Function(_$GetEventsResultImpl) _then) : super(_value, _then); + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -122,6 +129,8 @@ class __$$GetEventsResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $GetEventsResponseCopyWith<$Res> get result { @@ -159,11 +168,13 @@ class _$GetEventsResultImpl implements GetEventsResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetEventsResultImplCopyWith<_$GetEventsResultImpl> get copyWith => @@ -248,7 +259,10 @@ abstract class GetEventsResult implements GetEvents { _$GetEventsResultImpl.fromJson; GetEventsResponse get result; - @JsonKey(ignore: true) + + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetEventsResultImplCopyWith<_$GetEventsResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -272,6 +286,8 @@ class __$$GetEventsErrorImplCopyWithImpl<$Res> _$GetEventsErrorImpl _value, $Res Function(_$GetEventsErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -285,6 +301,8 @@ class __$$GetEventsErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -322,11 +340,13 @@ class _$GetEventsErrorImpl implements GetEventsError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetEventsErrorImplCopyWith<_$GetEventsErrorImpl> get copyWith => @@ -411,7 +431,10 @@ abstract class GetEventsError implements GetEvents { _$GetEventsErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetEvents + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetEventsErrorImplCopyWith<_$GetEventsErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -432,8 +455,12 @@ mixin _$GetEventsRequest { int get chunkSize => throw _privateConstructorUsedError; String? get continuationToken => throw _privateConstructorUsedError; + /// Serializes this GetEventsRequest to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $GetEventsRequestCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -466,6 +493,8 @@ class _$GetEventsRequestCopyWithImpl<$Res, $Val extends GetEventsRequest> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -504,6 +533,8 @@ class _$GetEventsRequestCopyWithImpl<$Res, $Val extends GetEventsRequest> ) as $Val); } + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $BlockIdCopyWith<$Res>? get fromBlock { @@ -516,6 +547,8 @@ class _$GetEventsRequestCopyWithImpl<$Res, $Val extends GetEventsRequest> }); } + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $BlockIdCopyWith<$Res>? get toBlock { @@ -559,6 +592,8 @@ class __$$GetEventsRequestImplCopyWithImpl<$Res> $Res Function(_$GetEventsRequestImpl) _then) : super(_value, _then); + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -659,12 +694,14 @@ class _$GetEventsRequestImpl implements _GetEventsRequest { other.continuationToken == continuationToken)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, fromBlock, toBlock, address, const DeepCollectionEquality().hash(_keys), chunkSize, continuationToken); - @JsonKey(ignore: true) + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetEventsRequestImplCopyWith<_$GetEventsRequestImpl> get copyWith => @@ -691,21 +728,25 @@ abstract class _GetEventsRequest implements GetEventsRequest { factory _GetEventsRequest.fromJson(Map json) = _$GetEventsRequestImpl.fromJson; - @override // start of EVENT_FILTER +// start of EVENT_FILTER + @override BlockId? get fromBlock; @override BlockId? get toBlock; @override Felt? get address; @override - List>? get keys; - @override // end of EVENT_FILTER + List>? get keys; // end of EVENT_FILTER // start of RESULT_PAGE_REQUEST + @override int get chunkSize; @override String? get continuationToken; + + /// Create a copy of GetEventsRequest + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetEventsRequestImplCopyWith<_$GetEventsRequestImpl> get copyWith => throw _privateConstructorUsedError; } @@ -719,8 +760,12 @@ mixin _$GetEventsResponse { List get events => throw _privateConstructorUsedError; String? get continuation_token => throw _privateConstructorUsedError; + /// Serializes this GetEventsResponse to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of GetEventsResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $GetEventsResponseCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -744,6 +789,8 @@ class _$GetEventsResponseCopyWithImpl<$Res, $Val extends GetEventsResponse> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of GetEventsResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -782,6 +829,8 @@ class __$$GetEventsResponseImplCopyWithImpl<$Res> $Res Function(_$GetEventsResponseImpl) _then) : super(_value, _then); + /// Create a copy of GetEventsResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -838,12 +887,14 @@ class _$GetEventsResponseImpl implements _GetEventsResponse { other.continuation_token == continuation_token)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_events), continuation_token); - @JsonKey(ignore: true) + /// Create a copy of GetEventsResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetEventsResponseImplCopyWith<_$GetEventsResponseImpl> get copyWith => @@ -870,8 +921,11 @@ abstract class _GetEventsResponse implements GetEventsResponse { List get events; @override String? get continuation_token; + + /// Create a copy of GetEventsResponse + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetEventsResponseImplCopyWith<_$GetEventsResponseImpl> get copyWith => throw _privateConstructorUsedError; } @@ -889,8 +943,12 @@ mixin _$EmittedEvent { Felt? get blockHash => throw _privateConstructorUsedError; int? get blockNumber => throw _privateConstructorUsedError; + /// Serializes this EmittedEvent to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of EmittedEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $EmittedEventCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -920,6 +978,8 @@ class _$EmittedEventCopyWithImpl<$Res, $Val extends EmittedEvent> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of EmittedEvent + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -984,6 +1044,8 @@ class __$$EmittedEventImplCopyWithImpl<$Res> _$EmittedEventImpl _value, $Res Function(_$EmittedEventImpl) _then) : super(_value, _then); + /// Create a copy of EmittedEvent + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1091,7 +1153,7 @@ class _$EmittedEventImpl implements _EmittedEvent { other.blockNumber == blockNumber)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1102,7 +1164,9 @@ class _$EmittedEventImpl implements _EmittedEvent { blockHash, blockNumber); - @JsonKey(ignore: true) + /// Create a copy of EmittedEvent + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$EmittedEventImplCopyWith<_$EmittedEventImpl> get copyWith => @@ -1140,8 +1204,11 @@ abstract class _EmittedEvent implements EmittedEvent { Felt? get blockHash; @override int? get blockNumber; + + /// Create a copy of EmittedEvent + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$EmittedEventImplCopyWith<_$EmittedEventImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_nonce.freezed.dart b/packages/starknet_provider/lib/src/model/get_nonce.freezed.dart index b5eb06fd..0c611071 100644 --- a/packages/starknet_provider/lib/src/model/get_nonce.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_nonce.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetNonce { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetNonce to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -88,6 +90,9 @@ class _$GetNonceCopyWithImpl<$Res, $Val extends GetNonce> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -107,6 +112,8 @@ class __$$GetNonceResultImplCopyWithImpl<$Res> _$GetNonceResultImpl _value, $Res Function(_$GetNonceResultImpl) _then) : super(_value, _then); + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -149,11 +156,13 @@ class _$GetNonceResultImpl implements GetNonceResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetNonceResultImplCopyWith<_$GetNonceResultImpl> get copyWith => @@ -238,7 +247,10 @@ abstract class GetNonceResult implements GetNonce { _$GetNonceResultImpl.fromJson; Felt get result; - @JsonKey(ignore: true) + + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetNonceResultImplCopyWith<_$GetNonceResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -262,6 +274,8 @@ class __$$GetNonceErrorImplCopyWithImpl<$Res> _$GetNonceErrorImpl _value, $Res Function(_$GetNonceErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -275,6 +289,8 @@ class __$$GetNonceErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -312,11 +328,13 @@ class _$GetNonceErrorImpl implements GetNonceError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetNonceErrorImplCopyWith<_$GetNonceErrorImpl> get copyWith => @@ -400,7 +418,10 @@ abstract class GetNonceError implements GetNonce { _$GetNonceErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetNonce + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetNonceErrorImplCopyWith<_$GetNonceErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_state_update.freezed.dart b/packages/starknet_provider/lib/src/model/get_state_update.freezed.dart index 56a81acf..fdc051b1 100644 --- a/packages/starknet_provider/lib/src/model/get_state_update.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_state_update.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetStateUpdate { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetStateUpdate to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetStateUpdateCopyWithImpl<$Res, $Val extends GetStateUpdate> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -110,6 +115,8 @@ class __$$GetStateUpdateResultImplCopyWithImpl<$Res> $Res Function(_$GetStateUpdateResultImpl) _then) : super(_value, _then); + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -123,6 +130,8 @@ class __$$GetStateUpdateResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $StateUpdateCopyWith<$Res> get result { @@ -160,11 +169,13 @@ class _$GetStateUpdateResultImpl implements GetStateUpdateResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetStateUpdateResultImplCopyWith<_$GetStateUpdateResultImpl> @@ -250,7 +261,10 @@ abstract class GetStateUpdateResult implements GetStateUpdate { _$GetStateUpdateResultImpl.fromJson; StateUpdate get result; - @JsonKey(ignore: true) + + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetStateUpdateResultImplCopyWith<_$GetStateUpdateResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -274,6 +288,8 @@ class __$$GetStateUpdateErrorImplCopyWithImpl<$Res> $Res Function(_$GetStateUpdateErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -287,6 +303,8 @@ class __$$GetStateUpdateErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -324,11 +342,13 @@ class _$GetStateUpdateErrorImpl implements GetStateUpdateError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetStateUpdateErrorImplCopyWith<_$GetStateUpdateErrorImpl> get copyWith => @@ -413,7 +433,10 @@ abstract class GetStateUpdateError implements GetStateUpdate { _$GetStateUpdateErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetStateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetStateUpdateErrorImplCopyWith<_$GetStateUpdateErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_storage.freezed.dart b/packages/starknet_provider/lib/src/model/get_storage.freezed.dart index cdaaf762..1886f396 100644 --- a/packages/starknet_provider/lib/src/model/get_storage.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_storage.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetStorage { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetStorage to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetStorageCopyWithImpl<$Res, $Val extends GetStorage> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -108,6 +113,8 @@ class __$$GetStorageResultImplCopyWithImpl<$Res> $Res Function(_$GetStorageResultImpl) _then) : super(_value, _then); + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -150,11 +157,13 @@ class _$GetStorageResultImpl implements GetStorageResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetStorageResultImplCopyWith<_$GetStorageResultImpl> get copyWith => @@ -239,7 +248,10 @@ abstract class GetStorageResult implements GetStorage { _$GetStorageResultImpl.fromJson; Felt get result; - @JsonKey(ignore: true) + + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetStorageResultImplCopyWith<_$GetStorageResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -263,6 +275,8 @@ class __$$GetStorageErrorImplCopyWithImpl<$Res> _$GetStorageErrorImpl _value, $Res Function(_$GetStorageErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -276,6 +290,8 @@ class __$$GetStorageErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -313,11 +329,13 @@ class _$GetStorageErrorImpl implements GetStorageError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetStorageErrorImplCopyWith<_$GetStorageErrorImpl> get copyWith => @@ -402,7 +420,10 @@ abstract class GetStorageError implements GetStorage { _$GetStorageErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetStorage + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetStorageErrorImplCopyWith<_$GetStorageErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_transaction.dart b/packages/starknet_provider/lib/src/model/get_transaction.dart index 8b507552..7c1cd11f 100644 --- a/packages/starknet_provider/lib/src/model/get_transaction.dart +++ b/packages/starknet_provider/lib/src/model/get_transaction.dart @@ -1,4 +1,4 @@ -// ignore_for_file: invalid_annotation_target +// ignore_for_file: invalid_annotation_target, non_constant_identifier_names import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; diff --git a/packages/starknet_provider/lib/src/model/get_transaction.freezed.dart b/packages/starknet_provider/lib/src/model/get_transaction.freezed.dart index fb0f4a3b..8c46a926 100644 --- a/packages/starknet_provider/lib/src/model/get_transaction.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_transaction.freezed.dart @@ -70,6 +70,8 @@ mixin _$GetTransaction { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetTransaction to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$GetTransactionCopyWithImpl<$Res, $Val extends GetTransaction> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -110,6 +115,8 @@ class __$$GetTransactionResultImplCopyWithImpl<$Res> $Res Function(_$GetTransactionResultImpl) _then) : super(_value, _then); + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -123,6 +130,8 @@ class __$$GetTransactionResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $TxnCopyWith<$Res> get result { @@ -160,11 +169,13 @@ class _$GetTransactionResultImpl implements GetTransactionResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetTransactionResultImplCopyWith<_$GetTransactionResultImpl> @@ -250,7 +261,10 @@ abstract class GetTransactionResult implements GetTransaction { _$GetTransactionResultImpl.fromJson; Txn get result; - @JsonKey(ignore: true) + + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetTransactionResultImplCopyWith<_$GetTransactionResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -274,6 +288,8 @@ class __$$GetTransactionErrorImplCopyWithImpl<$Res> $Res Function(_$GetTransactionErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -287,6 +303,8 @@ class __$$GetTransactionErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -324,11 +342,13 @@ class _$GetTransactionErrorImpl implements GetTransactionError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetTransactionErrorImplCopyWith<_$GetTransactionErrorImpl> get copyWith => @@ -413,7 +433,10 @@ abstract class GetTransactionError implements GetTransaction { _$GetTransactionErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetTransaction + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetTransactionErrorImplCopyWith<_$GetTransactionErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -666,8 +689,13 @@ mixin _$Txn { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this Txn to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $TxnCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -688,6 +716,8 @@ class _$TxnCopyWithImpl<$Res, $Val extends Txn> implements $TxnCopyWith<$Res> { // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -739,6 +769,8 @@ class __$$InvokeTxnV0ImplCopyWithImpl<$Res> _$InvokeTxnV0Impl _value, $Res Function(_$InvokeTxnV0Impl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -882,7 +914,7 @@ class _$InvokeTxnV0Impl implements InvokeTxnV0 { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -896,7 +928,9 @@ class _$InvokeTxnV0Impl implements InvokeTxnV0 { entryPointSelector, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTxnV0ImplCopyWith<_$InvokeTxnV0Impl> get copyWith => @@ -1173,7 +1207,8 @@ abstract class InvokeTxnV0 implements Txn { factory InvokeTxnV0.fromJson(Map json) = _$InvokeTxnV0Impl.fromJson; - @override // start of COMMON_TXN_PROPERTIES +// start of COMMON_TXN_PROPERTIES + @override Felt? get transactionHash; // start of BROADCASTED_TXN_COMMON_PROPERTIES @JsonKey(toJson: maxFeeToJson) Felt? get maxFee; @@ -1188,8 +1223,11 @@ abstract class InvokeTxnV0 implements Txn { Felt? get contractAddress; Felt? get entryPointSelector; List? get calldata; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTxnV0ImplCopyWith<_$InvokeTxnV0Impl> get copyWith => throw _privateConstructorUsedError; } @@ -1220,6 +1258,8 @@ class __$$InvokeTxnV1ImplCopyWithImpl<$Res> _$InvokeTxnV1Impl _value, $Res Function(_$InvokeTxnV1Impl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1353,7 +1393,7 @@ class _$InvokeTxnV1Impl implements InvokeTxnV1 { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1366,7 +1406,9 @@ class _$InvokeTxnV1Impl implements InvokeTxnV1 { sender_address, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTxnV1ImplCopyWith<_$InvokeTxnV1Impl> get copyWith => @@ -1642,7 +1684,8 @@ abstract class InvokeTxnV1 implements Txn { factory InvokeTxnV1.fromJson(Map json) = _$InvokeTxnV1Impl.fromJson; - @override // start of COMMON_TXN_PROPERTIES +// start of COMMON_TXN_PROPERTIES + @override Felt? get transactionHash; // start of BROADCASTED_TXN_COMMON_PROPERTIES @JsonKey(toJson: maxFeeToJson) Felt? get maxFee; @@ -1656,8 +1699,11 @@ abstract class InvokeTxnV1 implements Txn { // start of INVOKE_TXN_V1 Felt? get sender_address; List? get calldata; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTxnV1ImplCopyWith<_$InvokeTxnV1Impl> get copyWith => throw _privateConstructorUsedError; } @@ -1688,6 +1734,8 @@ class __$$DeclareTxnImplCopyWithImpl<$Res> _$DeclareTxnImpl _value, $Res Function(_$DeclareTxnImpl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1813,7 +1861,7 @@ class _$DeclareTxnImpl implements DeclareTxn { other.senderAddress == senderAddress)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1826,7 +1874,9 @@ class _$DeclareTxnImpl implements DeclareTxn { classHash, senderAddress); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTxnImplCopyWith<_$DeclareTxnImpl> get copyWith => @@ -2102,7 +2152,8 @@ abstract class DeclareTxn implements Txn { factory DeclareTxn.fromJson(Map json) = _$DeclareTxnImpl.fromJson; - @override // start of COMMON_TXN_PROPERTIES +// start of COMMON_TXN_PROPERTIES + @override Felt? get transactionHash; // start of BROADCASTED_TXN_COMMON_PROPERTIES @JsonKey(toJson: maxFeeToJson) Felt? get maxFee; @@ -2115,8 +2166,11 @@ abstract class DeclareTxn implements Txn { // end of COMMON_TXN_PROPERTIES Felt? get classHash; Felt? get senderAddress; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTxnImplCopyWith<_$DeclareTxnImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2145,6 +2199,8 @@ class __$$DeployTxnImplCopyWithImpl<$Res> _$DeployTxnImpl _value, $Res Function(_$DeployTxnImpl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2248,7 +2304,7 @@ class _$DeployTxnImpl implements DeployTxn { .equals(other._constructorCalldata, _constructorCalldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2259,7 +2315,9 @@ class _$DeployTxnImpl implements DeployTxn { contractAddressSalt, const DeepCollectionEquality().hash(_constructorCalldata)); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployTxnImplCopyWith<_$DeployTxnImpl> get copyWith => @@ -2535,15 +2593,18 @@ abstract class DeployTxn implements Txn { @override Felt? get transactionHash; - Felt? get classHash; - @override // start of DEPLOY_TXN_PROPERTIES + Felt? get classHash; // start of DEPLOY_TXN_PROPERTIES + @override String? get version; @override String? get type; Felt? get contractAddressSalt; List? get constructorCalldata; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployTxnImplCopyWith<_$DeployTxnImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2576,6 +2637,8 @@ class __$$DeployAccountTxnImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTxnImpl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2721,7 +2784,7 @@ class _$DeployAccountTxnImpl implements DeployAccountTxn { .equals(other._constructorCalldata, _constructorCalldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2735,7 +2798,9 @@ class _$DeployAccountTxnImpl implements DeployAccountTxn { classHash, const DeepCollectionEquality().hash(_constructorCalldata)); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTxnImplCopyWith<_$DeployAccountTxnImpl> get copyWith => @@ -3013,7 +3078,8 @@ abstract class DeployAccountTxn implements Txn { factory DeployAccountTxn.fromJson(Map json) = _$DeployAccountTxnImpl.fromJson; - @override // start of COMMON_TXN_PROPERTIES +// start of COMMON_TXN_PROPERTIES + @override Felt? get transactionHash; // start of BROADCASTED_TXN_COMMON_PROPERTIES @JsonKey(toJson: maxFeeToJson) Felt? get maxFee; @@ -3028,8 +3094,11 @@ abstract class DeployAccountTxn implements Txn { Felt? get contractAddressSalt; Felt? get classHash; List? get constructorCalldata; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTxnImplCopyWith<_$DeployAccountTxnImpl> get copyWith => throw _privateConstructorUsedError; } @@ -3059,6 +3128,8 @@ class __$$L1HandlerTxnImplCopyWithImpl<$Res> _$L1HandlerTxnImpl _value, $Res Function(_$L1HandlerTxnImpl) _then) : super(_value, _then); + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -3169,7 +3240,7 @@ class _$L1HandlerTxnImpl implements L1HandlerTxn { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -3181,7 +3252,9 @@ class _$L1HandlerTxnImpl implements L1HandlerTxn { entryPointSelector, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$L1HandlerTxnImplCopyWith<_$L1HandlerTxnImpl> get copyWith => @@ -3466,8 +3539,11 @@ abstract class L1HandlerTxn implements Txn { Felt? get contractAddress; Felt? get entryPointSelector; List? get calldata; + + /// Create a copy of Txn + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$L1HandlerTxnImplCopyWith<_$L1HandlerTxnImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/get_transaction_receipt.dart b/packages/starknet_provider/lib/src/model/get_transaction_receipt.dart index 17a9c431..b59ad75e 100644 --- a/packages/starknet_provider/lib/src/model/get_transaction_receipt.dart +++ b/packages/starknet_provider/lib/src/model/get_transaction_receipt.dart @@ -1,3 +1,5 @@ +// ignore_for_file: non_constant_identifier_names + import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; import 'package:starknet_provider/src/model/actual_fee.dart'; diff --git a/packages/starknet_provider/lib/src/model/get_transaction_receipt.freezed.dart b/packages/starknet_provider/lib/src/model/get_transaction_receipt.freezed.dart index d671506a..b11e4e8d 100644 --- a/packages/starknet_provider/lib/src/model/get_transaction_receipt.freezed.dart +++ b/packages/starknet_provider/lib/src/model/get_transaction_receipt.freezed.dart @@ -71,6 +71,8 @@ mixin _$GetTransactionReceipt { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this GetTransactionReceipt to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -91,6 +93,9 @@ class _$GetTransactionReceiptCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -115,6 +120,8 @@ class __$$GetTransactionReceiptResultImplCopyWithImpl<$Res> $Res Function(_$GetTransactionReceiptResultImpl) _then) : super(_value, _then); + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -128,6 +135,8 @@ class __$$GetTransactionReceiptResultImplCopyWithImpl<$Res> )); } + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $TxnReceiptCopyWith<$Res> get result { @@ -167,11 +176,13 @@ class _$GetTransactionReceiptResultImpl implements GetTransactionReceiptResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetTransactionReceiptResultImplCopyWith<_$GetTransactionReceiptResultImpl> @@ -256,7 +267,10 @@ abstract class GetTransactionReceiptResult implements GetTransactionReceipt { _$GetTransactionReceiptResultImpl.fromJson; TxnReceipt get result; - @JsonKey(ignore: true) + + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetTransactionReceiptResultImplCopyWith<_$GetTransactionReceiptResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -283,6 +297,8 @@ class __$$GetTransactionReceiptErrorImplCopyWithImpl<$Res> $Res Function(_$GetTransactionReceiptErrorImpl) _then) : super(_value, _then); + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -296,6 +312,8 @@ class __$$GetTransactionReceiptErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -335,11 +353,13 @@ class _$GetTransactionReceiptErrorImpl implements GetTransactionReceiptError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$GetTransactionReceiptErrorImplCopyWith<_$GetTransactionReceiptErrorImpl> @@ -425,7 +445,10 @@ abstract class GetTransactionReceiptError implements GetTransactionReceipt { _$GetTransactionReceiptErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of GetTransactionReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$GetTransactionReceiptErrorImplCopyWith<_$GetTransactionReceiptErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -688,8 +711,13 @@ mixin _$TxnReceipt { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this TxnReceipt to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $TxnReceiptCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -715,6 +743,8 @@ class _$TxnReceiptCopyWithImpl<$Res, $Val extends TxnReceipt> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -738,6 +768,8 @@ class _$TxnReceiptCopyWithImpl<$Res, $Val extends TxnReceipt> ) as $Val); } + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $ActualFeeCopyWith<$Res> get actualFee { @@ -778,6 +810,8 @@ class __$$InvokeTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$InvokeTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -915,7 +949,7 @@ class _$InvokeTxnReceiptImpl implements InvokeTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -929,7 +963,9 @@ class _$InvokeTxnReceiptImpl implements InvokeTxnReceipt { const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTxnReceiptImplCopyWith<_$InvokeTxnReceiptImpl> get copyWith => @@ -1212,7 +1248,8 @@ abstract class InvokeTxnReceipt implements TxnReceipt { factory InvokeTxnReceipt.fromJson(Map json) = _$InvokeTxnReceiptImpl.fromJson; - @override // start of COMMON_RECEIPT_PROPERTIES +// start of COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -1224,8 +1261,11 @@ abstract class InvokeTxnReceipt implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTxnReceiptImplCopyWith<_$InvokeTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1261,6 +1301,8 @@ class __$$DeclareTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$DeclareTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1398,7 +1440,7 @@ class _$DeclareTxnReceiptImpl implements DeclareTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1412,7 +1454,9 @@ class _$DeclareTxnReceiptImpl implements DeclareTxnReceipt { const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclareTxnReceiptImplCopyWith<_$DeclareTxnReceiptImpl> get copyWith => @@ -1695,7 +1739,8 @@ abstract class DeclareTxnReceipt implements TxnReceipt { factory DeclareTxnReceipt.fromJson(Map json) = _$DeclareTxnReceiptImpl.fromJson; - @override // start of COMMON_RECEIPT_PROPERTIES +// start of COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -1707,8 +1752,11 @@ abstract class DeclareTxnReceipt implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclareTxnReceiptImplCopyWith<_$DeclareTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1741,6 +1789,8 @@ class __$$L1HandlerTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$L1HandlerTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1842,7 +1892,7 @@ class _$L1HandlerTxnReceiptImpl implements L1HandlerTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -1853,7 +1903,9 @@ class _$L1HandlerTxnReceiptImpl implements L1HandlerTxnReceipt { blockHash, const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$L1HandlerTxnReceiptImplCopyWith<_$L1HandlerTxnReceiptImpl> get copyWith => @@ -2133,7 +2185,8 @@ abstract class L1HandlerTxnReceipt implements TxnReceipt { factory L1HandlerTxnReceipt.fromJson(Map json) = _$L1HandlerTxnReceiptImpl.fromJson; - @override // start of COMMON_RECEIPT_PROPERTIES +// start of COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -2142,8 +2195,11 @@ abstract class L1HandlerTxnReceipt implements TxnReceipt { Felt? get blockHash; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$L1HandlerTxnReceiptImplCopyWith<_$L1HandlerTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2179,6 +2235,8 @@ class __$$DeployTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$DeployTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2316,7 +2374,7 @@ class _$DeployTxnReceiptImpl implements DeployTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2330,7 +2388,9 @@ class _$DeployTxnReceiptImpl implements DeployTxnReceipt { const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployTxnReceiptImplCopyWith<_$DeployTxnReceiptImpl> get copyWith => @@ -2613,7 +2673,8 @@ abstract class DeployTxnReceipt implements TxnReceipt { factory DeployTxnReceipt.fromJson(Map json) = _$DeployTxnReceiptImpl.fromJson; - @override // start of COMMON_RECEIPT_PROPERTIES +// start of COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -2625,8 +2686,11 @@ abstract class DeployTxnReceipt implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployTxnReceiptImplCopyWith<_$DeployTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -2664,6 +2728,8 @@ class __$$DeployAccountTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$DeployAccountTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -2801,7 +2867,7 @@ class _$DeployAccountTxnReceiptImpl implements DeployAccountTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -2815,7 +2881,9 @@ class _$DeployAccountTxnReceiptImpl implements DeployAccountTxnReceipt { const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeployAccountTxnReceiptImplCopyWith<_$DeployAccountTxnReceiptImpl> @@ -3114,7 +3182,8 @@ abstract class DeployAccountTxnReceipt implements TxnReceipt { factory DeployAccountTxnReceipt.fromJson(Map json) = _$DeployAccountTxnReceiptImpl.fromJson; - @override // start of COMMON_RECEIPT_PROPERTIES +// start of COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -3126,8 +3195,11 @@ abstract class DeployAccountTxnReceipt implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeployAccountTxnReceiptImplCopyWith<_$DeployAccountTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -3161,6 +3233,8 @@ class __$$PendingDeployTxnReceiptImplCopyWithImpl<$Res> $Res Function(_$PendingDeployTxnReceiptImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -3258,7 +3332,7 @@ class _$PendingDeployTxnReceiptImpl implements PendingDeployTxnReceipt { const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -3268,7 +3342,9 @@ class _$PendingDeployTxnReceiptImpl implements PendingDeployTxnReceipt { const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingDeployTxnReceiptImplCopyWith<_$PendingDeployTxnReceiptImpl> @@ -3547,7 +3623,8 @@ abstract class PendingDeployTxnReceipt implements TxnReceipt { factory PendingDeployTxnReceipt.fromJson(Map json) = _$PendingDeployTxnReceiptImpl.fromJson; - @override // start of PENDING_COMMON_RECEIPT_PROPERTIES +// start of PENDING_COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -3555,8 +3632,11 @@ abstract class PendingDeployTxnReceipt implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingDeployTxnReceiptImplCopyWith<_$PendingDeployTxnReceiptImpl> get copyWith => throw _privateConstructorUsedError; } @@ -3590,6 +3670,8 @@ class __$$PendingCommonReceiptPropertiesImplCopyWithImpl<$Res> $Res Function(_$PendingCommonReceiptPropertiesImpl) _then) : super(_value, _then); + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -3689,7 +3771,7 @@ class _$PendingCommonReceiptPropertiesImpl const DeepCollectionEquality().equals(other._events, _events)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -3699,7 +3781,9 @@ class _$PendingCommonReceiptPropertiesImpl const DeepCollectionEquality().hash(_messagesSent), const DeepCollectionEquality().hash(_events)); - @JsonKey(ignore: true) + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingCommonReceiptPropertiesImplCopyWith< @@ -3980,7 +4064,8 @@ abstract class PendingCommonReceiptProperties implements TxnReceipt { factory PendingCommonReceiptProperties.fromJson(Map json) = _$PendingCommonReceiptPropertiesImpl.fromJson; - @override // start of PENDING_COMMON_RECEIPT_PROPERTIES +// start of PENDING_COMMON_RECEIPT_PROPERTIES + @override Felt get transactionHash; @override ActualFee get actualFee; @@ -3988,8 +4073,11 @@ abstract class PendingCommonReceiptProperties implements TxnReceipt { List get messagesSent; @override List get events; + + /// Create a copy of TxnReceipt + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingCommonReceiptPropertiesImplCopyWith< _$PendingCommonReceiptPropertiesImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/starknet_provider/lib/src/model/invoke_transaction.dart b/packages/starknet_provider/lib/src/model/invoke_transaction.dart index 32ff6281..a67ea48b 100644 --- a/packages/starknet_provider/lib/src/model/invoke_transaction.dart +++ b/packages/starknet_provider/lib/src/model/invoke_transaction.dart @@ -1,4 +1,4 @@ -// ignore_for_file: invalid_annotation_target +// ignore_for_file: invalid_annotation_target, non_constant_identifier_names import 'package:freezed_annotation/freezed_annotation.dart'; import 'package:starknet/starknet.dart'; diff --git a/packages/starknet_provider/lib/src/model/invoke_transaction.freezed.dart b/packages/starknet_provider/lib/src/model/invoke_transaction.freezed.dart index b28b5707..2fe386b7 100644 --- a/packages/starknet_provider/lib/src/model/invoke_transaction.freezed.dart +++ b/packages/starknet_provider/lib/src/model/invoke_transaction.freezed.dart @@ -23,8 +23,12 @@ InvokeTransactionRequest _$InvokeTransactionRequestFromJson( mixin _$InvokeTransactionRequest { InvokeTransaction get invokeTransaction => throw _privateConstructorUsedError; + /// Serializes this InvokeTransactionRequest to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $InvokeTransactionRequestCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -49,6 +53,8 @@ class _$InvokeTransactionRequestCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of InvokeTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -85,6 +91,8 @@ class __$$InvokeTransactionRequestImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionRequestImpl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionRequest + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -124,11 +132,13 @@ class _$InvokeTransactionRequestImpl implements _InvokeTransactionRequest { other.invokeTransaction == invokeTransaction)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, invokeTransaction); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionRequest + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionRequestImplCopyWith<_$InvokeTransactionRequestImpl> @@ -153,8 +163,11 @@ abstract class _InvokeTransactionRequest implements InvokeTransactionRequest { @override InvokeTransaction get invokeTransaction; + + /// Create a copy of InvokeTransactionRequest + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionRequestImplCopyWith<_$InvokeTransactionRequestImpl> get copyWith => throw _privateConstructorUsedError; } @@ -174,8 +187,12 @@ mixin _$InvokeTransactionV0 { Felt get entryPointSelector => throw _privateConstructorUsedError; List get calldata => throw _privateConstructorUsedError; + /// Serializes this InvokeTransactionV0 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionV0 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $InvokeTransactionV0CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -206,6 +223,8 @@ class _$InvokeTransactionV0CopyWithImpl<$Res, $Val extends InvokeTransactionV0> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of InvokeTransactionV0 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -276,6 +295,8 @@ class __$$InvokeTransactionV0ImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionV0Impl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionV0 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -388,7 +409,7 @@ class _$InvokeTransactionV0Impl implements _InvokeTransactionV0 { const DeepCollectionEquality().equals(other._calldata, _calldata)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -400,7 +421,9 @@ class _$InvokeTransactionV0Impl implements _InvokeTransactionV0 { entryPointSelector, const DeepCollectionEquality().hash(_calldata)); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionV0 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionV0ImplCopyWith<_$InvokeTransactionV0Impl> get copyWith => @@ -443,8 +466,11 @@ abstract class _InvokeTransactionV0 implements InvokeTransactionV0 { Felt get entryPointSelector; @override List get calldata; + + /// Create a copy of InvokeTransactionV0 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionV0ImplCopyWith<_$InvokeTransactionV0Impl> get copyWith => throw _privateConstructorUsedError; } @@ -464,8 +490,12 @@ mixin _$InvokeTransactionV1 { String get version => throw _privateConstructorUsedError; String get type => throw _privateConstructorUsedError; + /// Serializes this InvokeTransactionV1 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $InvokeTransactionV1CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -496,6 +526,8 @@ class _$InvokeTransactionV1CopyWithImpl<$Res, $Val extends InvokeTransactionV1> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of InvokeTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -566,6 +598,8 @@ class __$$InvokeTransactionV1ImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionV1Impl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionV1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -678,7 +712,7 @@ class _$InvokeTransactionV1Impl implements _InvokeTransactionV1 { (identical(other.type, type) || other.type == type)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -690,7 +724,9 @@ class _$InvokeTransactionV1Impl implements _InvokeTransactionV1 { version, type); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionV1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionV1ImplCopyWith<_$InvokeTransactionV1Impl> get copyWith => @@ -733,8 +769,11 @@ abstract class _InvokeTransactionV1 implements InvokeTransactionV1 { String get version; @override String get type; + + /// Create a copy of InvokeTransactionV1 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionV1ImplCopyWith<_$InvokeTransactionV1Impl> get copyWith => throw _privateConstructorUsedError; } @@ -796,6 +835,8 @@ mixin _$InvokeTransactionResponse { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this InvokeTransactionResponse to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -816,6 +857,9 @@ class _$InvokeTransactionResponseCopyWithImpl<$Res, final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -840,6 +884,8 @@ class __$$InvokeTransactionResultImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionResultImpl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -853,6 +899,8 @@ class __$$InvokeTransactionResultImplCopyWithImpl<$Res> )); } + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $InvokeTransactionResponseResultCopyWith<$Res> get result { @@ -892,11 +940,13 @@ class _$InvokeTransactionResultImpl implements InvokeTransactionResult { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionResultImplCopyWith<_$InvokeTransactionResultImpl> @@ -982,7 +1032,10 @@ abstract class InvokeTransactionResult implements InvokeTransactionResponse { _$InvokeTransactionResultImpl.fromJson; InvokeTransactionResponseResult get result; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionResultImplCopyWith<_$InvokeTransactionResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1009,6 +1062,8 @@ class __$$InvokeTransactionErrorImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionErrorImpl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1022,6 +1077,8 @@ class __$$InvokeTransactionErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -1059,11 +1116,13 @@ class _$InvokeTransactionErrorImpl implements InvokeTransactionError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionErrorImplCopyWith<_$InvokeTransactionErrorImpl> @@ -1148,7 +1207,10 @@ abstract class InvokeTransactionError implements InvokeTransactionResponse { _$InvokeTransactionErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionResponse + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionErrorImplCopyWith<_$InvokeTransactionErrorImpl> get copyWith => throw _privateConstructorUsedError; } @@ -1162,8 +1224,12 @@ InvokeTransactionResponseResult _$InvokeTransactionResponseResultFromJson( mixin _$InvokeTransactionResponseResult { String get transaction_hash => throw _privateConstructorUsedError; + /// Serializes this InvokeTransactionResponseResult to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of InvokeTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $InvokeTransactionResponseResultCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -1190,6 +1256,8 @@ class _$InvokeTransactionResponseResultCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of InvokeTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1226,6 +1294,8 @@ class __$$InvokeTransactionResponseResultImplCopyWithImpl<$Res> $Res Function(_$InvokeTransactionResponseResultImpl) _then) : super(_value, _then); + /// Create a copy of InvokeTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -1267,11 +1337,13 @@ class _$InvokeTransactionResponseResultImpl other.transaction_hash == transaction_hash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, transaction_hash); - @JsonKey(ignore: true) + /// Create a copy of InvokeTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$InvokeTransactionResponseResultImplCopyWith< @@ -1298,8 +1370,11 @@ abstract class _InvokeTransactionResponseResult @override String get transaction_hash; + + /// Create a copy of InvokeTransactionResponseResult + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$InvokeTransactionResponseResultImplCopyWith< _$InvokeTransactionResponseResultImpl> get copyWith => throw _privateConstructorUsedError; diff --git a/packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart b/packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart index bfc5c0b0..de5ced4d 100644 --- a/packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart +++ b/packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart @@ -23,8 +23,12 @@ mixin _$JsonRpcApiError { JsonRpcApiErrorCode get code => throw _privateConstructorUsedError; String get message => throw _privateConstructorUsedError; + /// Serializes this JsonRpcApiError to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of JsonRpcApiError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $JsonRpcApiErrorCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -48,6 +52,8 @@ class _$JsonRpcApiErrorCopyWithImpl<$Res, $Val extends JsonRpcApiError> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of JsonRpcApiError + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -86,6 +92,8 @@ class __$$JsonRpcApiErrorImplCopyWithImpl<$Res> _$JsonRpcApiErrorImpl _value, $Res Function(_$JsonRpcApiErrorImpl) _then) : super(_value, _then); + /// Create a copy of JsonRpcApiError + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -132,11 +140,13 @@ class _$JsonRpcApiErrorImpl implements _JsonRpcApiError { (identical(other.message, message) || other.message == message)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, code, message); - @JsonKey(ignore: true) + /// Create a copy of JsonRpcApiError + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$JsonRpcApiErrorImplCopyWith<_$JsonRpcApiErrorImpl> get copyWith => @@ -163,8 +173,11 @@ abstract class _JsonRpcApiError implements JsonRpcApiError { JsonRpcApiErrorCode get code; @override String get message; + + /// Create a copy of JsonRpcApiError + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$JsonRpcApiErrorImplCopyWith<_$JsonRpcApiErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/msg_to_l1.freezed.dart b/packages/starknet_provider/lib/src/model/msg_to_l1.freezed.dart index a927e913..167efc05 100644 --- a/packages/starknet_provider/lib/src/model/msg_to_l1.freezed.dart +++ b/packages/starknet_provider/lib/src/model/msg_to_l1.freezed.dart @@ -23,8 +23,12 @@ mixin _$MsgToL1 { Felt? get toAddress => throw _privateConstructorUsedError; List? get payload => throw _privateConstructorUsedError; + /// Serializes this MsgToL1 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of MsgToL1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $MsgToL1CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ class _$MsgToL1CopyWithImpl<$Res, $Val extends MsgToL1> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of MsgToL1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -83,6 +89,8 @@ class __$$MsgToL1ImplCopyWithImpl<$Res> _$MsgToL1Impl _value, $Res Function(_$MsgToL1Impl) _then) : super(_value, _then); + /// Create a copy of MsgToL1 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -139,12 +147,14 @@ class _$MsgToL1Impl implements _MsgToL1 { const DeepCollectionEquality().equals(other._payload, _payload)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, toAddress, const DeepCollectionEquality().hash(_payload)); - @JsonKey(ignore: true) + /// Create a copy of MsgToL1 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$MsgToL1ImplCopyWith<_$MsgToL1Impl> get copyWith => @@ -169,8 +179,11 @@ abstract class _MsgToL1 implements MsgToL1 { Felt? get toAddress; @override List? get payload; + + /// Create a copy of MsgToL1 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$MsgToL1ImplCopyWith<_$MsgToL1Impl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/msg_to_l2.freezed.dart b/packages/starknet_provider/lib/src/model/msg_to_l2.freezed.dart index fb336d99..896c5525 100644 --- a/packages/starknet_provider/lib/src/model/msg_to_l2.freezed.dart +++ b/packages/starknet_provider/lib/src/model/msg_to_l2.freezed.dart @@ -23,8 +23,12 @@ mixin _$MsgToL2 { String? get fromAddress => throw _privateConstructorUsedError; List? get payload => throw _privateConstructorUsedError; + /// Serializes this MsgToL2 to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of MsgToL2 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $MsgToL2CopyWith get copyWith => throw _privateConstructorUsedError; } @@ -46,6 +50,8 @@ class _$MsgToL2CopyWithImpl<$Res, $Val extends MsgToL2> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of MsgToL2 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -83,6 +89,8 @@ class __$$MsgToL2ImplCopyWithImpl<$Res> _$MsgToL2Impl _value, $Res Function(_$MsgToL2Impl) _then) : super(_value, _then); + /// Create a copy of MsgToL2 + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -139,12 +147,14 @@ class _$MsgToL2Impl implements _MsgToL2 { const DeepCollectionEquality().equals(other._payload, _payload)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, fromAddress, const DeepCollectionEquality().hash(_payload)); - @JsonKey(ignore: true) + /// Create a copy of MsgToL2 + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$MsgToL2ImplCopyWith<_$MsgToL2Impl> get copyWith => @@ -169,8 +179,11 @@ abstract class _MsgToL2 implements MsgToL2 { String? get fromAddress; @override List? get payload; + + /// Create a copy of MsgToL2 + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$MsgToL2ImplCopyWith<_$MsgToL2Impl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/pending_transactions.freezed.dart b/packages/starknet_provider/lib/src/model/pending_transactions.freezed.dart index 1788f8fa..49a95795 100644 --- a/packages/starknet_provider/lib/src/model/pending_transactions.freezed.dart +++ b/packages/starknet_provider/lib/src/model/pending_transactions.freezed.dart @@ -70,6 +70,8 @@ mixin _$PendingTransactions { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this PendingTransactions to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -89,6 +91,9 @@ class _$PendingTransactionsCopyWithImpl<$Res, $Val extends PendingTransactions> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -111,6 +116,8 @@ class __$$PendingTransactionsResultImplCopyWithImpl<$Res> $Res Function(_$PendingTransactionsResultImpl) _then) : super(_value, _then); + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -160,12 +167,14 @@ class _$PendingTransactionsResultImpl implements PendingTransactionsResult { const DeepCollectionEquality().equals(other._result, _result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, const DeepCollectionEquality().hash(_result)); - @JsonKey(ignore: true) + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingTransactionsResultImplCopyWith<_$PendingTransactionsResultImpl> @@ -250,7 +259,10 @@ abstract class PendingTransactionsResult implements PendingTransactions { _$PendingTransactionsResultImpl.fromJson; List get result; - @JsonKey(ignore: true) + + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingTransactionsResultImplCopyWith<_$PendingTransactionsResultImpl> get copyWith => throw _privateConstructorUsedError; } @@ -277,6 +289,8 @@ class __$$PendingTransactionsErrorImplCopyWithImpl<$Res> $Res Function(_$PendingTransactionsErrorImpl) _then) : super(_value, _then); + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -290,6 +304,8 @@ class __$$PendingTransactionsErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -328,11 +344,13 @@ class _$PendingTransactionsErrorImpl implements PendingTransactionsError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$PendingTransactionsErrorImplCopyWith<_$PendingTransactionsErrorImpl> @@ -417,7 +435,10 @@ abstract class PendingTransactionsError implements PendingTransactions { _$PendingTransactionsErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of PendingTransactions + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$PendingTransactionsErrorImplCopyWith<_$PendingTransactionsErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/state_update.freezed.dart b/packages/starknet_provider/lib/src/model/state_update.freezed.dart index 26290c77..af4c3e2b 100644 --- a/packages/starknet_provider/lib/src/model/state_update.freezed.dart +++ b/packages/starknet_provider/lib/src/model/state_update.freezed.dart @@ -25,8 +25,12 @@ mixin _$StateUpdate { Felt get oldRoot => throw _privateConstructorUsedError; StateDiff get stateDiff => throw _privateConstructorUsedError; + /// Serializes this StateUpdate to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StateUpdateCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -52,6 +56,8 @@ class _$StateUpdateCopyWithImpl<$Res, $Val extends StateUpdate> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -80,6 +86,8 @@ class _$StateUpdateCopyWithImpl<$Res, $Val extends StateUpdate> ) as $Val); } + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $StateDiffCopyWith<$Res> get stateDiff { @@ -111,6 +119,8 @@ class __$$StateUpdateImplCopyWithImpl<$Res> _$StateUpdateImpl _value, $Res Function(_$StateUpdateImpl) _then) : super(_value, _then); + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -179,12 +189,14 @@ class _$StateUpdateImpl implements _StateUpdate { other.stateDiff == stateDiff)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, blockHash, newRoot, oldRoot, stateDiff); - @JsonKey(ignore: true) + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StateUpdateImplCopyWith<_$StateUpdateImpl> get copyWith => @@ -216,8 +228,11 @@ abstract class _StateUpdate implements StateUpdate { Felt get oldRoot; @override StateDiff get stateDiff; + + /// Create a copy of StateUpdate + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StateUpdateImplCopyWith<_$StateUpdateImpl> get copyWith => throw _privateConstructorUsedError; } @@ -239,8 +254,12 @@ mixin _$StateDiff { List get nonces => throw _privateConstructorUsedError; + /// Serializes this StateDiff to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of StateDiff + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $StateDiffCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -269,6 +288,8 @@ class _$StateDiffCopyWithImpl<$Res, $Val extends StateDiff> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of StateDiff + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -333,6 +354,8 @@ class __$$StateDiffImplCopyWithImpl<$Res> _$StateDiffImpl _value, $Res Function(_$StateDiffImpl) _then) : super(_value, _then); + /// Create a copy of StateDiff + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -465,7 +488,7 @@ class _$StateDiffImpl implements _StateDiff { const DeepCollectionEquality().equals(other._nonces, _nonces)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -476,7 +499,9 @@ class _$StateDiffImpl implements _StateDiff { const DeepCollectionEquality().hash(_replacedClasses), const DeepCollectionEquality().hash(_nonces)); - @JsonKey(ignore: true) + /// Create a copy of StateDiff + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$StateDiffImplCopyWith<_$StateDiffImpl> get copyWith => @@ -514,8 +539,11 @@ abstract class _StateDiff implements StateDiff { List get replacedClasses; @override List get nonces; + + /// Create a copy of StateDiff + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$StateDiffImplCopyWith<_$StateDiffImpl> get copyWith => throw _privateConstructorUsedError; } @@ -530,8 +558,12 @@ mixin _$NonceAndContractAddress { Felt get nonce => throw _privateConstructorUsedError; Felt get contractAddress => throw _privateConstructorUsedError; + /// Serializes this NonceAndContractAddress to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of NonceAndContractAddress + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $NonceAndContractAddressCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -556,6 +588,8 @@ class _$NonceAndContractAddressCopyWithImpl<$Res, // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of NonceAndContractAddress + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -597,6 +631,8 @@ class __$$NonceAndContractAddressImplCopyWithImpl<$Res> $Res Function(_$NonceAndContractAddressImpl) _then) : super(_value, _then); + /// Create a copy of NonceAndContractAddress + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -645,11 +681,13 @@ class _$NonceAndContractAddressImpl implements _NonceAndContractAddress { other.contractAddress == contractAddress)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, nonce, contractAddress); - @JsonKey(ignore: true) + /// Create a copy of NonceAndContractAddress + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NonceAndContractAddressImplCopyWith<_$NonceAndContractAddressImpl> @@ -676,8 +714,11 @@ abstract class _NonceAndContractAddress implements NonceAndContractAddress { Felt get nonce; @override Felt get contractAddress; + + /// Create a copy of NonceAndContractAddress + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$NonceAndContractAddressImplCopyWith<_$NonceAndContractAddressImpl> get copyWith => throw _privateConstructorUsedError; } @@ -691,8 +732,12 @@ mixin _$DeclaredClass { Felt get classHash => throw _privateConstructorUsedError; Felt get compiledClassHash => throw _privateConstructorUsedError; + /// Serializes this DeclaredClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of DeclaredClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $DeclaredClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -716,6 +761,8 @@ class _$DeclaredClassCopyWithImpl<$Res, $Val extends DeclaredClass> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of DeclaredClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -754,6 +801,8 @@ class __$$DeclaredClassImplCopyWithImpl<$Res> _$DeclaredClassImpl _value, $Res Function(_$DeclaredClassImpl) _then) : super(_value, _then); + /// Create a copy of DeclaredClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -803,11 +852,13 @@ class _$DeclaredClassImpl implements _DeclaredClass { other.compiledClassHash == compiledClassHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, classHash, compiledClassHash); - @JsonKey(ignore: true) + /// Create a copy of DeclaredClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$DeclaredClassImplCopyWith<_$DeclaredClassImpl> get copyWith => @@ -833,8 +884,11 @@ abstract class _DeclaredClass implements DeclaredClass { Felt get classHash; @override Felt get compiledClassHash; + + /// Create a copy of DeclaredClass + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$DeclaredClassImplCopyWith<_$DeclaredClassImpl> get copyWith => throw _privateConstructorUsedError; } @@ -848,8 +902,12 @@ mixin _$ReplacedClass { Felt get contractAddress => throw _privateConstructorUsedError; Felt get classHash => throw _privateConstructorUsedError; + /// Serializes this ReplacedClass to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of ReplacedClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $ReplacedClassCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -873,6 +931,8 @@ class _$ReplacedClassCopyWithImpl<$Res, $Val extends ReplacedClass> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of ReplacedClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -911,6 +971,8 @@ class __$$ReplacedClassImplCopyWithImpl<$Res> _$ReplacedClassImpl _value, $Res Function(_$ReplacedClassImpl) _then) : super(_value, _then); + /// Create a copy of ReplacedClass + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -960,11 +1022,13 @@ class _$ReplacedClassImpl implements _ReplacedClass { other.classHash == classHash)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, contractAddress, classHash); - @JsonKey(ignore: true) + /// Create a copy of ReplacedClass + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$ReplacedClassImplCopyWith<_$ReplacedClassImpl> get copyWith => @@ -990,8 +1054,11 @@ abstract class _ReplacedClass implements ReplacedClass { Felt get contractAddress; @override Felt get classHash; + + /// Create a copy of ReplacedClass + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$ReplacedClassImplCopyWith<_$ReplacedClassImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/sync_status.freezed.dart b/packages/starknet_provider/lib/src/model/sync_status.freezed.dart index a1d2491d..fca9ff35 100644 --- a/packages/starknet_provider/lib/src/model/sync_status.freezed.dart +++ b/packages/starknet_provider/lib/src/model/sync_status.freezed.dart @@ -27,8 +27,12 @@ mixin _$SyncStatus { Felt get highestBlockHash => throw _privateConstructorUsedError; String get highestBlockNum => throw _privateConstructorUsedError; + /// Serializes this SyncStatus to a JSON map. Map toJson() => throw _privateConstructorUsedError; - @JsonKey(ignore: true) + + /// Create a copy of SyncStatus + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) $SyncStatusCopyWith get copyWith => throw _privateConstructorUsedError; } @@ -58,6 +62,8 @@ class _$SyncStatusCopyWithImpl<$Res, $Val extends SyncStatus> // ignore: unused_field final $Res Function($Val) _then; + /// Create a copy of SyncStatus + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -122,6 +128,8 @@ class __$$SyncStatusImplCopyWithImpl<$Res> _$SyncStatusImpl _value, $Res Function(_$SyncStatusImpl) _then) : super(_value, _then); + /// Create a copy of SyncStatus + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -212,7 +220,7 @@ class _$SyncStatusImpl implements _SyncStatus { other.highestBlockNum == highestBlockNum)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash( runtimeType, @@ -223,7 +231,9 @@ class _$SyncStatusImpl implements _SyncStatus { highestBlockHash, highestBlockNum); - @JsonKey(ignore: true) + /// Create a copy of SyncStatus + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SyncStatusImplCopyWith<_$SyncStatusImpl> get copyWith => @@ -261,8 +271,11 @@ abstract class _SyncStatus implements SyncStatus { Felt get highestBlockHash; @override String get highestBlockNum; + + /// Create a copy of SyncStatus + /// with the given fields replaced by the non-null parameter values. @override - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) _$$SyncStatusImplCopyWith<_$SyncStatusImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/lib/src/model/syncing.freezed.dart b/packages/starknet_provider/lib/src/model/syncing.freezed.dart index a036866e..3f11eaca 100644 --- a/packages/starknet_provider/lib/src/model/syncing.freezed.dart +++ b/packages/starknet_provider/lib/src/model/syncing.freezed.dart @@ -78,6 +78,8 @@ mixin _$Syncing { required TResult orElse(), }) => throw _privateConstructorUsedError; + + /// Serializes this Syncing to a JSON map. Map toJson() => throw _privateConstructorUsedError; } @@ -96,6 +98,9 @@ class _$SyncingCopyWithImpl<$Res, $Val extends Syncing> final $Val _value; // ignore: unused_field final $Res Function($Val) _then; + + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. } /// @nodoc @@ -117,6 +122,8 @@ class __$$SynchronizedImplCopyWithImpl<$Res> _$SynchronizedImpl _value, $Res Function(_$SynchronizedImpl) _then) : super(_value, _then); + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -130,6 +137,8 @@ class __$$SynchronizedImplCopyWithImpl<$Res> )); } + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $SyncStatusCopyWith<$Res> get result { @@ -167,11 +176,13 @@ class _$SynchronizedImpl implements Synchronized { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SynchronizedImplCopyWith<_$SynchronizedImpl> get copyWith => @@ -261,7 +272,10 @@ abstract class Synchronized implements Syncing { _$SynchronizedImpl.fromJson; SyncStatus get result; - @JsonKey(ignore: true) + + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$SynchronizedImplCopyWith<_$SynchronizedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -283,6 +297,8 @@ class __$$NotSynchronizedImplCopyWithImpl<$Res> _$NotSynchronizedImpl _value, $Res Function(_$NotSynchronizedImpl) _then) : super(_value, _then); + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -325,11 +341,13 @@ class _$NotSynchronizedImpl implements NotSynchronized { (identical(other.result, result) || other.result == result)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, result); - @JsonKey(ignore: true) + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$NotSynchronizedImplCopyWith<_$NotSynchronizedImpl> get copyWith => @@ -420,7 +438,10 @@ abstract class NotSynchronized implements Syncing { _$NotSynchronizedImpl.fromJson; bool get result; - @JsonKey(ignore: true) + + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$NotSynchronizedImplCopyWith<_$NotSynchronizedImpl> get copyWith => throw _privateConstructorUsedError; } @@ -444,6 +465,8 @@ class __$$SyncingErrorImplCopyWithImpl<$Res> _$SyncingErrorImpl _value, $Res Function(_$SyncingErrorImpl) _then) : super(_value, _then); + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. @pragma('vm:prefer-inline') @override $Res call({ @@ -457,6 +480,8 @@ class __$$SyncingErrorImplCopyWithImpl<$Res> )); } + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. @override @pragma('vm:prefer-inline') $JsonRpcApiErrorCopyWith<$Res> get error { @@ -494,11 +519,13 @@ class _$SyncingErrorImpl implements SyncingError { (identical(other.error, error) || other.error == error)); } - @JsonKey(ignore: true) + @JsonKey(includeFromJson: false, includeToJson: false) @override int get hashCode => Object.hash(runtimeType, error); - @JsonKey(ignore: true) + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) @override @pragma('vm:prefer-inline') _$$SyncingErrorImplCopyWith<_$SyncingErrorImpl> get copyWith => @@ -588,7 +615,10 @@ abstract class SyncingError implements Syncing { _$SyncingErrorImpl.fromJson; JsonRpcApiError get error; - @JsonKey(ignore: true) + + /// Create a copy of Syncing + /// with the given fields replaced by the non-null parameter values. + @JsonKey(includeFromJson: false, includeToJson: false) _$$SyncingErrorImplCopyWith<_$SyncingErrorImpl> get copyWith => throw _privateConstructorUsedError; } diff --git a/packages/starknet_provider/pubspec.yaml b/packages/starknet_provider/pubspec.yaml index 459f4e76..5ac29ecb 100644 --- a/packages/starknet_provider/pubspec.yaml +++ b/packages/starknet_provider/pubspec.yaml @@ -1,20 +1,20 @@ name: starknet_provider description: A starting point for Dart libraries or applications. -version: 1.0.0 -# repository: https://github.com/my_org/my_repo +version: 0.1.0 +repository: https://github.com/focustree/starknet.dart environment: sdk: ^3.0.5 dependencies: - starknet: - freezed_annotation: ^2.4.1 - http: ^1.2.1 - json_annotation: ^4.8.1 + starknet: ^0.1.0 + freezed_annotation: ^2.4.4 + http: ^1.2.2 + json_annotation: ^4.9.0 dev_dependencies: - build_runner: ^2.4.9 - freezed: ^2.5.2 + build_runner: ^2.4.13 + freezed: ^2.5.7 json_serializable: ^6.8.0 - lints: ^3.0.0 - test: ^1.24.0 \ No newline at end of file + lints: ^5.0.0 + test: ^1.25.8 diff --git a/packages/wallet_kit/analysis_options.yaml b/packages/wallet_kit/analysis_options.yaml index a5744c1c..2e3c70e5 100644 --- a/packages/wallet_kit/analysis_options.yaml +++ b/packages/wallet_kit/analysis_options.yaml @@ -1,4 +1,6 @@ include: package:flutter_lints/flutter.yaml -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +analyzer: + exclude: + - "**/*.g.dart" + - "**/*.freezed.dart" diff --git a/packages/wallet_kit/android/local.properties b/packages/wallet_kit/android/local.properties index 4eb73482..67d3ac90 100644 --- a/packages/wallet_kit/android/local.properties +++ b/packages/wallet_kit/android/local.properties @@ -1,2 +1,2 @@ -sdk.dir=/Users/paulreboullet/Library/Android/sdk -flutter.sdk=/usr/local/Caskroom/flutter/3.7.7/flutter \ No newline at end of file +sdk.dir=/Users/lesnitsky/Library/Android/sdk +flutter.sdk=/Users/lesnitsky/flutter-sdk diff --git a/packages/wallet_kit/ios/Flutter/Generated.xcconfig b/packages/wallet_kit/ios/Flutter/Generated.xcconfig index 60b60916..391fd69f 100644 --- a/packages/wallet_kit/ios/Flutter/Generated.xcconfig +++ b/packages/wallet_kit/ios/Flutter/Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/usr/local/Caskroom/flutter/3.7.7/flutter -FLUTTER_APPLICATION_PATH=/Users/paulreboullet/Desktop/Starknet/starknet.dart/packages/wallet_kit +FLUTTER_ROOT=/Users/lesnitsky/flutter-sdk +FLUTTER_APPLICATION_PATH=/Users/lesnitsky/w/focustree/starknet.dart/packages/wallet_kit COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_TARGET=lib/main.dart FLUTTER_BUILD_DIR=build diff --git a/packages/wallet_kit/ios/Flutter/flutter_export_environment.sh b/packages/wallet_kit/ios/Flutter/flutter_export_environment.sh index f7fe2d57..e5027076 100755 --- a/packages/wallet_kit/ios/Flutter/flutter_export_environment.sh +++ b/packages/wallet_kit/ios/Flutter/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/usr/local/Caskroom/flutter/3.7.7/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/paulreboullet/Desktop/Starknet/starknet.dart/packages/wallet_kit" +export "FLUTTER_ROOT=/Users/lesnitsky/flutter-sdk" +export "FLUTTER_APPLICATION_PATH=/Users/lesnitsky/w/focustree/starknet.dart/packages/wallet_kit" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_TARGET=lib/main.dart" export "FLUTTER_BUILD_DIR=build" diff --git a/packages/wallet_kit/macos/Flutter/GeneratedPluginRegistrant.swift b/packages/wallet_kit/macos/Flutter/GeneratedPluginRegistrant.swift index c4ac0d43..c9ab4607 100644 --- a/packages/wallet_kit/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/packages/wallet_kit/macos/Flutter/GeneratedPluginRegistrant.swift @@ -7,8 +7,10 @@ import Foundation import path_provider_foundation import secure_store +import webview_flutter_wkwebview func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) SecureStorePlugin.register(with: registry.registrar(forPlugin: "SecureStorePlugin")) + FLTWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "FLTWebViewFlutterPlugin")) } diff --git a/packages/wallet_kit/macos/Flutter/ephemeral/Flutter-Generated.xcconfig b/packages/wallet_kit/macos/Flutter/ephemeral/Flutter-Generated.xcconfig index 09a92b73..95745250 100644 --- a/packages/wallet_kit/macos/Flutter/ephemeral/Flutter-Generated.xcconfig +++ b/packages/wallet_kit/macos/Flutter/ephemeral/Flutter-Generated.xcconfig @@ -1,6 +1,6 @@ // This is a generated file; do not edit or check into version control. -FLUTTER_ROOT=/usr/local/Caskroom/flutter/3.7.7/flutter -FLUTTER_APPLICATION_PATH=/Users/paulreboullet/Desktop/Starknet/starknet.dart/packages/wallet_kit +FLUTTER_ROOT=/Users/lesnitsky/flutter-sdk +FLUTTER_APPLICATION_PATH=/Users/lesnitsky/w/focustree/starknet.dart/packages/wallet_kit COCOAPODS_PARALLEL_CODE_SIGN=true FLUTTER_BUILD_DIR=build FLUTTER_BUILD_NAME=0.0.1 diff --git a/packages/wallet_kit/macos/Flutter/ephemeral/flutter_export_environment.sh b/packages/wallet_kit/macos/Flutter/ephemeral/flutter_export_environment.sh index f3d17e5a..32c8d483 100755 --- a/packages/wallet_kit/macos/Flutter/ephemeral/flutter_export_environment.sh +++ b/packages/wallet_kit/macos/Flutter/ephemeral/flutter_export_environment.sh @@ -1,7 +1,7 @@ #!/bin/sh # This is a generated file; do not edit or check into version control. -export "FLUTTER_ROOT=/usr/local/Caskroom/flutter/3.7.7/flutter" -export "FLUTTER_APPLICATION_PATH=/Users/paulreboullet/Desktop/Starknet/starknet.dart/packages/wallet_kit" +export "FLUTTER_ROOT=/Users/lesnitsky/flutter-sdk" +export "FLUTTER_APPLICATION_PATH=/Users/lesnitsky/w/focustree/starknet.dart/packages/wallet_kit" export "COCOAPODS_PARALLEL_CODE_SIGN=true" export "FLUTTER_BUILD_DIR=build" export "FLUTTER_BUILD_NAME=0.0.1" diff --git a/pubspec.yaml b/pubspec.yaml index 351f4e15..4b1cd069 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,4 +5,6 @@ environment: dev_dependencies: build_runner: ^2.4.9 freezed: ^2.5.2 - melos: ^6.0.0 + melos: ^6.2.0 + starklints: + path: packages/starklints diff --git a/renovate.json b/renovate.json deleted file mode 100644 index 311840d2..00000000 --- a/renovate.json +++ /dev/null @@ -1,30 +0,0 @@ -{ - "$schema": "https://docs.renovatebot.com/renovate-schema.json", - "extends": ["config:base"], - "python": { - "enabled": false - }, - "ignorePaths": ["**/examples/**", "**/test/**", "**/docs/**"], - "packageRules": [ - { - "paths": ["packages/secure_store"], - "groupName": "secure_store updates" - }, - { - "paths": ["packages/starknet"], - "groupName": "starknet updates" - }, - { - "paths": ["packages/starknet_provider"], - "groupName": "starknet_provider updates" - }, - { - "paths": ["packages/starknet_builder"], - "groupName": "starknet_builder updates" - }, - { - "paths": ["packages/wallet_kit"], - "groupName": "wallet_kit updates" - } - ] -}