Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for AVNU paymaster #451

Merged
merged 26 commits into from
Feb 13, 2025
Merged

Conversation

rukafe0x
Copy link
Contributor

@rukafe0x rukafe0x commented Feb 6, 2025

Support AVNU paymaster as a new package provider to close issue #349

Main features:

  • Sponsors could add rewards for users.
  • Users can execute sponsored transactions (user don't pay for gas).
  • Sponsors also could execute signed users transactions on behalf of users.
  • Sponsor could check for their rewards activity
  • User could check their rewards balance
  • Includes snip-12 implementation to obtain hash from type data.
  • Docs with examples.

Not included in this version:

  • Gasless new account deployment

Summary by CodeRabbit

  • New Features

    • Enabled enhanced service interactions by integrating a new provider package for transaction processing, reward management, and typed data handling.
    • Updated environment configurations with public RPC endpoints for improved connectivity.
    • Introduced new methods for managing account rewards, executing transactions, and building typed data.
  • Documentation

    • Introduced comprehensive guides, including a new paymaster documentation page, README, and changelog updates.
    • Updated documentation to reflect new environment variables and service interactions.
  • Tests

    • Added integration and unit tests to validate the new functionalities and ensure reliable service performance.
    • Established a testing framework for both the AvnuProvider and AvnuReadProvider classes.

Copy link

docs-page bot commented Feb 6, 2025

To view this pull requests documentation preview, visit the following URL:

docs.page/focustree/starknet.dart~451

Documentation is deployed and generated using docs.page.

Copy link
Contributor

coderabbitai bot commented Feb 6, 2025

Walkthrough

This pull request introduces extensive changes across multiple areas. Environment files and CI workflows have been updated with new RPC endpoints (AVNU_RPC and changes to STARKNET_RPC). The documentation is expanded with a new entry and detailed instructions for the AVNU Paymaster Provider. A new package, avnu_provider, is added which includes new configuration files, models built with Freezed, provider implementations (for both read and write operations), utility functions for data encoding and typed data manipulation, and corresponding tests. Various files now export and orchestrate these features, establishing a comprehensive framework for interacting with the AVNU service.

Changes

File(s) Change Summary
.env.devnet, .vscode/launch.json, .github/workflows/ci.yaml, pubspec.yaml (root) Added/updated environment variables: new AVNU_RPC value added; STARKNET_RPC updated; added new dependency starknet_provider
docs.yaml, docs/packages/avnu_provider.mdx Documentation updated: new “Avnu Paymaster Provider” entry added and "How to Contribute" link removed; detailed package documentation introduced
packages/avnu_provider/.gitignore, CHANGELOG.md, README.md, analysis_options.yaml, dart_test.yaml, pubspec.yaml (in package) New package configuration files added for the avnu_provider package with changelog, readme, analysis options, and test configurations
packages/avnu_provider/lib/avnu_provider.dart, lib/src/index.dart, provider.dart, read_provider.dart Core library updates: exports consolidated; new abstract and concrete provider classes (AvnuProvider & AvnuReadProvider) implemented
packages/avnu_provider/lib/src/model/... Multiple new model files added (e.g., AvnuConfig, AvnuAccountCompatible, AvnuAccountRewards, AvnuBuildTypedData, AvnuExecute, AvnuGasTokenPrices, AvnuSponsorActivity, AvnuStatus) using Freezed for immutable data structures and JSON serialization
packages/avnu_provider/lib/src/typed_data/... New utility functions for encoding, number manipulation, short string handling, and comprehensive SNIP-12 typed data structures introduced
packages/avnu_provider/test/utils.dart, test/integration/provider_test.dart, test/read_provider_test.dart New test utilities and test suites created for integration and unit testing of provider functionalities

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant Prov as AvnuJsonRpcProvider
  participant RPC as callRpcEndpoint
  participant AVNU as AVNU RPC Service

  Client->>Prov: buildTypedData(userAddress, calls, ...)
  Prov->>RPC: callRpcEndpoint(method: build_typed_data, params)
  RPC->>AVNU: HTTP Request
  AVNU-->>RPC: JSON Response
  RPC-->>Prov: Parsed typed data
  Client->>Prov: execute(typedData, signature, ...)
  Prov->>RPC: callRpcEndpoint(method: execute, params)
  RPC->>AVNU: HTTP Request
  AVNU-->>RPC: JSON Response
  RPC-->>Prov: Execution result
  Prov-->>Client: AvnuExecute result
Loading
sequenceDiagram
  participant Client
  participant Read as AvnuJsonRpcReadProvider
  participant RPC as callRpcEndpoint
  participant AVNU as AVNU RPC Service

  Client->>Read: avnuStatus()
  Read->>RPC: callRpcEndpoint(method: avnu_status)
  RPC->>AVNU: HTTP Request
  AVNU-->>RPC: JSON Response
  RPC-->>Read: Parsed status
  Read-->>Client: AvnuStatus result
Loading

Possibly related PRs

Poem

I'm a clever little rabbit,
Hopping through code with nimble feet,
Added AVNU_RPC to light our path,
Through tests and docs our changes meet.
With Freezed and providers, I cheer with glee—
A carrot-full journey in Dart, woo-hoo!
🥕🐇 Happy coding from my burrow to thee!


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 12

🧹 Nitpick comments (29)
packages/avnu_provider/pubspec.yaml (1)

23-23: Trailing Newline Requirement.
YAMLlint reports that there is no newline character at the end of the file. Adding a trailing newline will resolve this minor issue and improve lint compliance.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

packages/avnu_provider/lib/src/provider.dart (2)

3-6: Use DartDoc comments for method documentation

Currently, the method comments in AvnuProvider are using single-line comments //. To improve documentation generation and IDE support, it's recommended to use DartDoc comments with ///.

Apply this diff to update the comments:

-  // Build the data type for the account
-  //
-  // [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)
+  /// Build the data type for the account
+  ///
+  /// [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)

Repeat similar changes for the other methods to enhance readability and maintain consistency.

Also applies to: 8-11, 13-16, 18-20


44-51: Refactor to use async/await for better readability and error handling

The methods buildTypedData, execute, and setAccountRewards are marked as async but are using .then() with closures to handle Futures. Using the await keyword improves readability and simplifies error handling.

Apply this diff to refactor the methods:

-  return callRpcEndpoint(
-    nodeUri: nodeUri, 
-    method: 'paymaster_build_typed_data', 
-    params: [effectiveApiKey, userAddress, calls, gasTokenAddress, maxGasTokenAmount, accountClassHash]
-  ).then((dynamic json) => AvnuBuildTypedData.fromJson(json));
+  final json = await callRpcEndpoint(
+    nodeUri: nodeUri, 
+    method: 'paymaster_build_typed_data', 
+    params: [effectiveApiKey, userAddress, calls, gasTokenAddress, maxGasTokenAmount, accountClassHash]
+  );
+  return AvnuBuildTypedData.fromJson(json);

Repeat similar changes for the execute and setAccountRewards methods to enhance code clarity.

Also applies to: 54-61, 64-71

packages/avnu_provider/lib/src/read_provider.dart (2)

3-7: Use DartDoc comments for method documentation

In the AvnuReadProvider abstract class, method comments are currently using //. Switching to DartDoc comments with /// will improve documentation generation and IDE support.

Apply this diff to update the comments:

-  // Gets the AVNU service status
-  //
-  // [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)
+  /// Gets the AVNU service status
+  ///
+  /// [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)

Update other methods similarly to maintain consistency.

Also applies to: 9-13, 14-18, 19-23, 24-28


52-55: Refactor to use async/await for better readability and error handling

The methods in AvnuJsonRpcReadProvider use .then() to handle asynchronous calls. Utilizing await enhances readability and simplifies error management.

Example refactor for the avnuStatus method:

-  return callRpcEndpoint(nodeUri: nodeUri, method: 'paymaster_status')
-      .then((dynamic json) => AvnuStatus.fromJson(json as Map<String, dynamic>));
+  final json = await callRpcEndpoint(nodeUri: nodeUri, method: 'paymaster_status');
+  return AvnuStatus.fromJson(json as Map<String, dynamic>);

Refactor the other methods similarly to improve code clarity.

Also applies to: 58-61, 64-67, 70-77, 80-94

packages/avnu_provider/lib/src/call_rpc_endpoint.dart (2)

30-30: Remove unnecessary cast in parameter handling

The cast (params as List<String>) is unnecessary since params is already a List<String>. Removing it will simplify the code.

Apply this diff to remove the unnecessary cast:

-      if ((params as List<String>)[0] != '') headers['api-key'] = (params as List<String>)[0];
+      if (params[0] != '') headers['api-key'] = params[0];

This improves code readability without altering functionality.

🧰 Tools
🪛 GitHub Actions: code_health

[warning] 30-30: Unnecessary cast. Try removing the cast.


135-137: Add null checks when parsing response headers

The code assumes that the signature header is always present and correctly formatted. Adding null checks and validation improves robustness.

Apply this diff to enhance error handling:

-      final signatureParts = response.headers['signature']!.split(',');
+      final signatureHeader = response.headers['signature'];
+      if (signatureHeader == null || signatureHeader.isEmpty) {
+        throw Exception('Missing or empty signature header');
+      }
+      final signatureParts = signatureHeader.split(',');

This ensures that the code handles missing or malformed headers gracefully.

packages/avnu_provider/lib/src/model/avnu_status.dart (1)

8-21: Add documentation to improve code clarity.

The implementation using union types for status and error cases is good. Consider adding documentation to improve clarity.

 @freezed
+/// Represents the status of an AVNU operation.
+///
+/// This class can represent either a successful status with a boolean value,
+/// or an error status with a [JsonRpcApiError].
 class AvnuStatus with _$AvnuStatus {
+  /// Creates a status instance with a boolean value.
   const factory AvnuStatus.status({
     required bool status,
   }) = AvnuStatusStatus;
+
+  /// Creates an error status instance with a [JsonRpcApiError].
   const factory AvnuStatus.error({
     required JsonRpcApiError error,
   }) = AvnuStatusError;

+  /// Creates an [AvnuStatus] instance from a JSON map.
+  ///
+  /// If the JSON contains an 'error' key, creates an [AvnuStatusError],
+  /// otherwise creates an [AvnuStatusStatus].
   factory AvnuStatus.fromJson(Map<String, Object?> json) =>
       json.containsKey('error')
           ? AvnuStatusError.fromJson(json)
           : AvnuStatusStatus.fromJson(json);
 }
packages/avnu_provider/lib/src/model/avnu_account_rewards.dart (1)

17-33: Add documentation for optional fields.

While the AvnuAccountRewards class is well-structured, consider adding documentation to explain:

  • Why all fields are optional
  • Which combinations of fields are valid
  • What default values should be expected when fields are null
packages/avnu_provider/test/utils.dart (1)

23-30: Consider extracting environment check logic.

The environment variable check is duplicated across all three functions. Consider extracting it into a helper function.

+String getEnvVar(String name) {
+  final env = Platform.environment;
+  if (env[name] == null) {
+    throw Exception('$name environment variable is not set');
+  }
+  return env[name]!;
+}

 ReadProvider getProvider() {
-  final env = Platform.environment;
-  if (env['STARKNET_RPC'] == null) {
-    throw Exception('STARKNET_RPC environment variable is not set');
-  }
-  return JsonRpcReadProvider(nodeUri: Uri.parse(env['STARKNET_RPC']!));
+  return JsonRpcReadProvider(nodeUri: Uri.parse(getEnvVar('STARKNET_RPC')));
 }

 AvnuReadProvider getAvnuReadProvider({BigInt? publicKey, String? apiKey}) {
-  final env = Platform.environment;
-  if (env['AVNU_RPC'] == null) {
-    throw Exception('AVNU_RPC environment variable is not set');
-  }
-  return AvnuJsonRpcReadProvider(nodeUri: Uri.parse(env['AVNU_RPC']!), publicKey: publicKey, apiKey: apiKey);
+  return AvnuJsonRpcReadProvider(nodeUri: Uri.parse(getEnvVar('AVNU_RPC')), publicKey: publicKey, apiKey: apiKey);
 }

 AvnuProvider getAvnuProvider({BigInt? publicKey, String? apiKey}) {
-  final env = Platform.environment;
-  if (env['AVNU_RPC'] == null) {
-    throw Exception('AVNU_RPC environment variable is not set');
-  }
-  return AvnuJsonRpcProvider(nodeUri: Uri.parse(env['AVNU_RPC']!), publicKey: publicKey, apiKey: apiKey);
+  return AvnuJsonRpcProvider(nodeUri: Uri.parse(getEnvVar('AVNU_RPC')), publicKey: publicKey, apiKey: apiKey);
 }
packages/avnu_provider/lib/src/model/json_rpc_api_error.dart (1)

19-87: Consider automating error code generation.

The TODO comment suggests these error codes should be generated from JSON-RPC API specs. This would help maintain consistency with the specification and reduce manual maintenance.

Would you like me to help create a script to generate these error codes from the JSON-RPC API specification?

packages/avnu_provider/lib/src/typed_data/encode.dart (3)

19-23: Consider removing deprecated function.

The stringToArrayBuffer function is marked as deprecated in favor of utf8ToArray. Since this is a new file, it's better to remove deprecated functions to maintain a clean codebase.

-// Convert utf8-string to Uint8Array
-@Deprecated('Use utf8ToArray instead')
-Uint8List stringToArrayBuffer(String str) {
-  return utf8ToArray(str);
-}

35-38: Optimize hex string conversion.

The current implementation of buf2hex could be more efficient by pre-allocating the string buffer.

-String buf2hex(Uint8List buffer) {
-  return buffer.map((x) => x.toRadixString(16).padLeft(2, '0')).join();
+String buf2hex(Uint8List buffer) {
+  final result = StringBuffer();
+  for (final byte in buffer) {
+    result.write(byte.toRadixString(16).padLeft(2, '0'));
+  }
+  return result.toString();
+}

98-106: Enhance case conversion robustness.

The pascalToSnake function could be more robust by handling edge cases like consecutive uppercase letters.

-String pascalToSnake(String text) {
-  if (!RegExp(r'[a-z]').hasMatch(text)) return text;
-  
-  return text
-      .split(RegExp(r'(?=[A-Z])'))
-      .join('_')
-      .toUpperCase();
+String pascalToSnake(String text) {
+  if (!RegExp(r'[a-z]').hasMatch(text)) return text;
+  
+  return text
+      .replaceAllMapped(
+        RegExp(r'[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+'),
+        (Match m) => '${m[0]}_',
+      )
+      .toUpperCase()
+      .replaceAll(RegExp(r'_$'), '');
+}
packages/avnu_provider/lib/src/typed_data/shortstring.dart (1)

81-92: Add documentation to ByteArray class.

The ByteArray class lacks documentation explaining its purpose and the meaning of its fields.

+/// Represents a byte array with pending word information.
+///
+/// This class is used to store byte data along with information about a pending word
+/// that hasn't been fully processed yet.
 class ByteArray {
+  /// The processed data as a list of integers
   final List<int> data;
+  /// The current pending word being processed
   final int pendingWord;
+  /// The length of the current pending word
   final int pendingWordLen;

   const ByteArray({
     required this.data,
     required this.pendingWord,
     required this.pendingWordLen,
   });
 }
packages/avnu_provider/lib/src/typed_data/num.dart (1)

60-75: Improve error message in assertInRange.

The error message in assertInRange could be more descriptive by including the actual and allowed ranges.

-    throw Exception('Message not signable, $messageSuffix.');
+    throw Exception(
+      'Message not signable, $messageSuffix. '
+      'Value $inputBigInt is outside allowed range '
+      '[$lowerBoundBigInt, $upperBoundBigInt].'
+    );
packages/avnu_provider/test/integration/read_provider_test.dart (1)

73-100: Add more test cases for account compatibility.

The account compatibility tests could be expanded to cover more edge cases.

Consider adding tests for:

  • Invalid address format
  • Address with invalid checksum
  • Account with unsupported implementation
  • Account with incompatible version
packages/avnu_provider/test/provider_test.dart (2)

9-22: Consider adding documentation for the removeNullFields utility function.

The function recursively removes null fields from a JSON-like map structure. Adding documentation would help explain its purpose and behavior.

Add documentation:

+/// Recursively removes null fields from a JSON-like map structure.
+/// 
+/// This function traverses through the map and:
+/// - Removes key-value pairs where the value is null
+/// - Recursively processes nested maps
+/// - Processes maps within lists
void removeNullFields(Map<String, dynamic> json) {

378-378: Consider adding more test cases for edge cases.

The current test suite covers basic functionality but could benefit from additional test cases for error conditions and edge cases.

Consider adding tests for:

  • Invalid API keys
  • Expired rewards
  • Invalid whitelisted calls
  • Network errors
docs/packages/avnu_provider.mdx (7)

13-13: Grammar Improvement in Introduction.
The sentence beginning with "With these provider you (as sponsor)..." should be revised for grammatical agreement. Consider changing it to: "With this provider, you (as sponsor) will be able to pay your users’ gas fees..."

🧰 Tools
🪛 LanguageTool

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


20-20: Grammar Correction for Transaction Instruction.
In the instruction "User prepare their transaction (using buildTypedData function)," update the verb to match the subject. For example, "User prepares their transaction" (or "Users prepare their transaction" if intended for plural).

🧰 Tools
🪛 LanguageTool

[grammar] ~20-~20: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


22-22: Punctuation Improvement in Fee Description.
Consider inserting a comma after "pay the gas fees" to improve readability in the sentence describing the fee structure.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~22-~22: Possible missing comma found.
Context: ...ll execute the transaction, pay the gas fees and the sponsor will be charged for the...

(AI_HYDRA_LEO_MISSING_COMMA)


45-49: Consistency in Function Argument Documentation.
The bullet points for the arguments (e.g., campaign, protocol, freeTx, etc.) would benefit from standardized punctuation for clarity. Ensuring a consistent list format helps readability.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~45-~45: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~46-~46: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~47-~47: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~48-~48: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


67-67: Rephrase Transaction Setup Instruction.
Instead of "mandatory step previous to execute a transaction," consider rephrasing to "mandatory step prior to executing a transaction" for both clarity and grammatical correctness.

🧰 Tools
🪛 LanguageTool

[style] ~67-~67: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


134-134: Terminology Clarification in Transaction Example.
In the phrase "set an approve transaction to the ERC20 contract," the term "approve" should be replaced with "approval" to clearly denote the type of transaction.

🧰 Tools
🪛 LanguageTool

[grammar] ~134-~134: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


162-162: Verb Form Correction.
Replace "builded typed data" with "built typed data" to correct the irregular verb form.

🧰 Tools
🪛 LanguageTool

[grammar] ~162-~162: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

packages/avnu_provider/dart_test.yaml (1)

1-2: YAML Formatting: Newline at End of File.
A newline at the end of the file is required by YAML linting standards. Please add a newline character at the end to ensure compliance.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 2-2: no new line character at the end of file

(new-line-at-end-of-file)

packages/avnu_provider/README.md (2)

14-14: Enhance Placeholder Description Wording.
In the placeholder "TODO" for the package description, consider using a phrase like "brief description" to clearly signal that users should insert a concise summary of the package’s purpose.

🧰 Tools
🪛 LanguageTool

[style] ~14-~14: Consider using the synonym “brief” (= concise, using a few words, not lasting long) to strengthen your wording.
Context: ...to/develop-packages). --> TODO: Put a short description of the package here that he...

(QUICK_BRIEF)


29-29: Article Usage Suggestion in Examples Section.
The instruction "Add longer examples for package users. Add longer examples to /example folder." could be clearer if revised to "Add longer examples to the /example folder." This minor edit improves the flow of the sentence.

🧰 Tools
🪛 LanguageTool

[uncategorized] ~29-~29: You might be missing the article “the” here.
Context: ...r package users. Add longer examples to /example folder. ```dart const like =...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 13edd1a and d398e06.

📒 Files selected for processing (51)
  • .env.devnet (1 hunks)
  • .vscode/launch.json (1 hunks)
  • docs.yaml (1 hunks)
  • docs/packages/avnu_provider.mdx (1 hunks)
  • packages/avnu_provider/.gitignore (1 hunks)
  • packages/avnu_provider/CHANGELOG.md (1 hunks)
  • packages/avnu_provider/README.md (1 hunks)
  • packages/avnu_provider/analysis_options.yaml (1 hunks)
  • packages/avnu_provider/dart_test.yaml (1 hunks)
  • packages/avnu_provider/lib/avnu_provider.dart (1 hunks)
  • packages/avnu_provider/lib/src/avnu_config.dart (1 hunks)
  • packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1 hunks)
  • packages/avnu_provider/lib/src/index.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_compatible.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_compatible.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_compatible.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_execute.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_execute.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_sponsor_activity.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_sponsor_activity.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_sponsor_activity.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/index.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/json_rpc_api_error.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/json_rpc_api_error.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/json_rpc_api_error.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/provider.dart (1 hunks)
  • packages/avnu_provider/lib/src/read_provider.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/encode.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/hash.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/merkle.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/num.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/shortstring.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart (1 hunks)
  • packages/avnu_provider/pubspec.yaml (1 hunks)
  • packages/avnu_provider/test/integration/read_provider_test.dart (1 hunks)
  • packages/avnu_provider/test/provider_test.dart (1 hunks)
  • packages/avnu_provider/test/utils.dart (1 hunks)
  • pubspec.yaml (1 hunks)
✅ Files skipped from review due to trivial changes (14)
  • packages/avnu_provider/.gitignore
  • packages/avnu_provider/lib/avnu_provider.dart
  • packages/avnu_provider/CHANGELOG.md
  • packages/avnu_provider/analysis_options.yaml
  • packages/avnu_provider/lib/src/model/avnu_execute.g.dart
  • packages/avnu_provider/lib/src/index.dart
  • packages/avnu_provider/lib/src/model/index.dart
  • packages/avnu_provider/lib/src/model/avnu_account_compatible.g.dart
  • packages/avnu_provider/lib/src/model/avnu_status.g.dart
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.g.dart
  • packages/avnu_provider/lib/src/model/json_rpc_api_error.g.dart
  • packages/avnu_provider/lib/src/model/avnu_sponsor_activity.g.dart
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.g.dart
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.g.dart
🧰 Additional context used
📓 Learnings (2)
packages/avnu_provider/lib/src/model/json_rpc_api_error.dart (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#417
File: packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart:26-31
Timestamp: 2024-11-21T18:01:50.217Z
Learning: The file `packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart` is auto-generated and should not be manually modified. Documentation changes should be made in the source file used to generate this code to ensure they persist upon regeneration.
packages/avnu_provider/lib/src/model/json_rpc_api_error.freezed.dart (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#417
File: packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart:26-31
Timestamp: 2024-11-21T18:01:50.217Z
Learning: The file `packages/starknet_provider/lib/src/model/json_rpc_api_error.freezed.dart` is auto-generated and should not be manually modified. Documentation changes should be made in the source file used to generate this code to ensure they persist upon regeneration.
🪛 GitHub Actions: code_health
packages/avnu_provider/lib/src/model/avnu_execute.dart

[warning] 9-9: The annotation 'JsonKey' can only be used on fields or getters.

packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[warning] 30-30: Unnecessary cast. Try removing the cast.


[error] 1-1: You must have a LICENSE file in the root directory.

packages/avnu_provider/lib/src/typed_data/hash.dart

[info] 5-5: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.

packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart

[warning] 36-36: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 46-46: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 47-47: Empty statement. Try removing the empty statement or restructuring the code.

packages/avnu_provider/lib/src/typed_data/typed_data.dart

[info] 314-314: Unnecessary use of 'toList' in a spread. Try removing the invocation of 'toList'.

🪛 Gitleaks (8.21.2)
packages/avnu_provider/test/integration/read_provider_test.dart

42-42: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

packages/avnu_provider/test/provider_test.dart

45-45: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)


69-69: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
docs/packages/avnu_provider.mdx

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


[grammar] ~20-~20: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


[uncategorized] ~22-~22: Possible missing comma found.
Context: ...ll execute the transaction, pay the gas fees and the sponsor will be charged for the...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~45-~45: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~46-~46: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~47-~47: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~48-~48: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~56-~56: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~67-~67: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~71-~71: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~72-~72: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~73-~73: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~81-~81: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~83-~83: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


[formatting] ~90-~90: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~96-~96: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)


[grammar] ~134-~134: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


[grammar] ~162-~162: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

packages/avnu_provider/README.md

[style] ~14-~14: Consider using the synonym “brief” (= concise, using a few words, not lasting long) to strengthen your wording.
Context: ...to/develop-packages). --> TODO: Put a short description of the package here that he...

(QUICK_BRIEF)


[uncategorized] ~29-~29: You might be missing the article “the” here.
Context: ...r package users. Add longer examples to /example folder. ```dart const like =...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

🪛 GitHub Actions: CI
packages/avnu_provider/test/provider_test.dart

[warning] 1-1: A tag was used that wasn't specified in dart_test.yaml. integration was used in the group 'WriteProvider'.

🪛 YAMLlint (1.35.1)
packages/avnu_provider/dart_test.yaml

[error] 2-2: no new line character at the end of file

(new-line-at-end-of-file)

packages/avnu_provider/pubspec.yaml

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (26)
pubspec.yaml (1)

9-14: Dependency Addition for Starknet Provider.
The new dependency starknet_provider: ^0.1.0 is correctly added to the dependencies section. Please ensure that the version remains consistent with the package’s runtime requirements across the monorepo.

packages/avnu_provider/pubspec.yaml (4)

1-5: Metadata and Package Information.
The metadata entries including name, description, version, and repository are comprehensive and correctly outline the package details for avnu_provider.


6-8: SDK Environment Specification.
The environment block with sdk: ^3.5.3 is properly specified for this package. Consider verifying that this constraint aligns with the overall monorepo requirements if inter-package compatibility is desired.


9-16: Regular Dependencies Setup.
Dependencies such as starknet, freezed_annotation, http, json_annotation, and pointycastle are defined with clear version constraints. Please double-check these versions for compatibility with other components in the ecosystem.


17-23: Dev Dependencies and Dependency Placement.
The dev_dependencies are well defined for building and testing. However, note that starknet_provider: ^0.1.0+1 is included here. Confirm whether this dependency is only needed during development or should be promoted to a regular dependency for runtime usage if applicable.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 23-23: no new line character at the end of file

(new-line-at-end-of-file)

packages/avnu_provider/lib/src/model/avnu_sponsor_activity.freezed.dart (1)

1-637: Generated code should not be manually modified

This file appears to be generated code (indicated by // GENERATED CODE - DO NOT MODIFY BY HAND). It is recommended not to manually modify generated files to prevent inconsistencies. Ensure that any changes are made in the source files that generate this code.

packages/avnu_provider/lib/src/model/avnu_gas_token_prices.freezed.dart (1)

1-662: Generated code should not be manually modified

This file appears to be generated code (indicated by // GENERATED CODE - DO NOT MODIFY BY HAND). It is recommended not to manually modify generated files to prevent inconsistencies. Ensure that any changes are made in the source files that generate this code.

packages/avnu_provider/lib/src/typed_data/merkle.dart (1)

1-11: Consider removing or documenting the unimplemented class.

Since the TODO comment indicates that Merkle tree construction is not required for AVNU paymaster support, consider either:

  1. Removing this class if it's not needed for the current implementation.
  2. Adding documentation explaining why this placeholder is needed and when it will be implemented.

Additionally, if you decide to keep the class:

  • Consider making the hashFunction parameter type-safe by specifying its signature.
  • Add documentation for the class and its methods.
+/// A Merkle tree implementation for future use.
+/// This class is currently a placeholder and will be implemented in the future.
 class MerkleTree {
   final String root;
   
-  MerkleTree(List<String> leaves, Function hashFunction) : root = _buildRoot(leaves, hashFunction);
+  /// Creates a new Merkle tree from the given leaves using the specified hash function.
+  ///
+  /// The [leaves] parameter is a list of strings representing the leaf nodes.
+  /// The [hashFunction] parameter is a function that takes a string and returns a string hash.
+  MerkleTree(List<String> leaves, String Function(String) hashFunction)
+      : root = _buildRoot(leaves, hashFunction);
   
-  static String _buildRoot(List<String> leaves, Function hashFunction) {
+  static String _buildRoot(List<String> leaves, String Function(String) hashFunction) {
     // Implement merkle tree construction
     throw UnimplementedError();
   }
packages/avnu_provider/lib/src/model/avnu_account_compatible.dart (1)

1-21: LGTM! Well-structured data model implementation.

The AvnuAccountCompatible class is well-designed with:

  • Proper use of Freezed for immutable data classes
  • Clear separation between success and error cases
  • Type-safe JSON serialization
packages/avnu_provider/lib/src/model/avnu_sponsor_activity.dart (1)

1-26: LGTM! Comprehensive data model for sponsor activity.

The AvnuSponsorActivity class is well-implemented with:

  • Complete set of fields for tracking sponsor activity metrics
  • Proper use of Freezed for immutable data classes
  • Clear separation between success and error cases
  • Type-safe JSON serialization
packages/avnu_provider/test/utils.dart (2)

5-12: LGTM! Well-structured error handling.

The function properly validates the environment variable before creating the provider.


14-21: LGTM! Consistent implementation with getProvider.

The function follows the same pattern and includes optional parameters needed for AVNU paymaster support.

packages/avnu_provider/lib/src/model/avnu_gas_token_prices.dart (1)

8-34: LGTM! Well-structured data models with proper error handling.

The implementation uses freezed effectively and handles both success and error cases appropriately.

packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart (1)

1-171: LGTM! The implementation follows Freezed package conventions.

The AvnuExecute class is well-structured for representing transaction execution results with proper JSON serialization/deserialization support.

packages/avnu_provider/lib/src/model/json_rpc_api_error.freezed.dart (1)

1-183: LGTM! The implementation follows Freezed package conventions.

The JsonRpcApiError class is well-structured for representing JSON-RPC API errors with proper JSON serialization/deserialization support.

packages/avnu_provider/lib/src/model/avnu_status.freezed.dart (1)

1-426: LGTM! The implementation follows Freezed package conventions.

The AvnuStatus union type is well-structured for representing success/error states with proper JSON serialization/deserialization and pattern matching support.

packages/avnu_provider/lib/src/model/avnu_account_compatible.freezed.dart (1)

1-495: LGTM! The implementation follows Freezed package conventions.

The AvnuAccountCompatible union type is well-structured for representing account compatibility states with proper JSON serialization/deserialization and pattern matching support.

packages/avnu_provider/test/provider_test.dart (1)

257-257: Address the TODO comment for account deployment test.

The TODO comment indicates missing test coverage for account deployment functionality.

Would you like me to help implement the test case for account deployment? This would help ensure comprehensive test coverage.

packages/avnu_provider/lib/src/model/avnu_account_rewards.freezed.dart (1)

1-4: LGTM! Generated code with proper ignore directives.

The file correctly includes necessary ignore directives for generated code.

packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1)

1-4: LGTM! Generated code with proper ignore directives.

The file correctly includes necessary ignore directives for generated code.

.vscode/launch.json (1)

9-11: Verify the RPC endpoints are production-ready.

The configuration includes public RPC endpoints. Ensure these are:

  1. Production-ready and stable
  2. Have sufficient rate limits for your needs
  3. Support all required RPC methods
✅ Verification successful

🌐 Web query:

What are the rate limits and supported methods for the Blast API Starknet RPC endpoint?

💡 Result:

The Blast API Starknet RPC endpoint provides tiered rate limits and supports both standard JSON-RPC methods and specialized Builder API endpoints. Here's a detailed breakdown:

### Rate Limits
1. **Requests Per Second (RPS):**
   - **Free Plan:** Up to **100 RPS** per project (shared across all endpoints)[3][7]
   - **Paid Plans (Developer/Startup):** Up to **10,000 RPS**[3]
   - Implemented via sliding window algorithm tracking last-second activity[1]

2. **WebSocket Connections:**
   - **1,000 concurrent connections** per project (shared across endpoints)[1]

3. **Data Limits:**
   | Type                     | Limit    |
   |--------------------------|----------|
   | HTTP Request Header      | 8 KB     |
   | HTTP Request Body        | 1 MB     |
   | WebSocket Client Message | 1 MB     |
   | WebSocket Server Message | 128 MB   | [1]

4. **Method-Specific Restrictions:**
   - `eth_getLogs` block range:
     - Free: 500 blocks
     - Paid: 2,000 blocks[1]

### Supported Methods
**Standard JSON-RPC Methods:**
- `starknet_blockNumber`
- `starknet_syncing`
- `starknet_getBlockWithTxs`
- `starknet_getTransactionReceipt`[7][8]

**Builder API Endpoints:**
*Transaction Methods*
- `getTransaction` - Fetch transaction details by hash
- `getTransactions` - List transactions in block range[5]

*Token Management*
- `getTokenAllowance` - Check ERC20 spending approvals
- `getTokenHolders` - List token ownership distribution[5]

*Starknet-Specific Features*
- `getEvents` - Filter chain events
- `getMessages` - Retrieve L1<>L2 messages
- `getBlockReceipts` - Access full block confirmation data[5]

### Usage Considerations
Public endpoints require no authentication but have stricter limits[7]. Paid plans offer dedicated endpoints with higher throughput and priority support[3]. For intensive applications like NFT platforms or analytics tools, the Builder API provides optimized endpoints for common Starknet operations[3][5].

Citations:

- 1: https://docs.blastapi.io/blast-documentation/things-you-need-to-know/limits
- 2: https://www.starknet-react.com/docs/providers
- 3: https://blastapi.io/chains/starknet
- 4: https://chainstack.com/build-better-with-starknet/
- 5: https://docs.blastapi.io/blast-documentation/apis-documentation/builder-api/starknet/
- 6: https://www.quicknode.com/pricing
- 7: https://blastapi.io/public-api/starknet
- 8: https://docs.blastapi.io/running-a-node/supported-chains/starknet/mainnet
- 9: https://docs.alchemy.com/reference/blast-chain-api-faq
- 10: https://github.com/arddluma/awesome-list-rpc-nodes-providers/blob/main/README.md

Review of RPC Endpoint Production Readiness

The Blast API Starknet RPC endpoint (i.e., "https://starknet-sepolia.public.blastapi.io/rpc/v0_7") is production-ready when used under an appropriate plan. According to the Blast API documentation:

  • Production usage requires a paid plan (up to 10,000 RPS) whereas the free plan offers only up to 100 RPS.
  • It supports the full suite of standard JSON-RPC methods as well as specialized Builder API endpoints, providing the necessary functionality for production environments.

For completeness, please also verify that:

  • The selected plan (free versus paid) meets your application's throughput and reliability needs.
  • The AVNU endpoint ("https://sepolia.api.avnu.fi") is confirmed as production-grade via its own documentation.

Overall, these environment configurations in .vscode/launch.json appear acceptable provided the usage plan aligns with your operational requirements.

docs.yaml (2)

31-32: New Documentation Entry Added for AVNU Paymaster Provider.
The addition of the "Avnu Paymaster Provider" entry with its corresponding link ("/packages/avnu_provider") properly expands the sidebar to include the new package documentation. Ensure that the content in the referenced documentation file remains consistent with the entry details.


33-34: Review of "How to Contribute" Link Removal.
The link to "/how-to-contribute" has been removed from the sidebar. Verify that this removal is intentional and that alternative guidance for contributors is provided elsewhere in the documentation.

.env.devnet (1)

26-26: New Environment Variable AVNU_RPC Added.
The variable is correctly set to https://sepolia.api.avnu.fi for the AVNU service endpoint. Please confirm that all parts of the system that interact with the AVNU paymaster use this variable.

docs/packages/avnu_provider.mdx (1)

1-251: Overall Documentation Feedback.
The new documentation for the AVNU Paymaster Provider is comprehensive and well-organized, covering an introduction, functions, and examples. Once the above grammar and punctuation suggestions are incorporated, the clarity and professionalism of the document will be further enhanced.

🧰 Tools
🪛 LanguageTool

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


[grammar] ~20-~20: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


[uncategorized] ~22-~22: Possible missing comma found.
Context: ...ll execute the transaction, pay the gas fees and the sponsor will be charged for the...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~45-~45: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~46-~46: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~47-~47: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~48-~48: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~56-~56: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~67-~67: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~71-~71: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~72-~72: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~73-~73: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~81-~81: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~82-~82: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~83-~83: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~83-~83: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


[formatting] ~90-~90: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~96-~96: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)


[grammar] ~134-~134: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


[grammar] ~162-~162: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

packages/avnu_provider/README.md (1)

1-40: Overall README Feedback.
The README provides a robust template for the AVNU Provider package. Once the placeholder "TODO" items are replaced with detailed, package-specific information, this document will serve as an excellent resource for users. The suggested wording and style adjustments will further enhance its clarity and usefulness.

🧰 Tools
🪛 LanguageTool

[style] ~14-~14: Consider using the synonym “brief” (= concise, using a few words, not lasting long) to strengthen your wording.
Context: ...to/develop-packages). --> TODO: Put a short description of the package here that he...

(QUICK_BRIEF)


[uncategorized] ~29-~29: You might be missing the article “the” here.
Context: ...r package users. Add longer examples to /example folder. ```dart const like =...

(AI_EN_LECTOR_MISSING_DETERMINER_THE)

@rukafe0x rukafe0x changed the title Add support for AVNU paymaster feat: Add support for AVNU paymaster Feb 6, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5

♻️ Duplicate comments (1)
packages/avnu_provider/lib/src/provider.dart (1)

1-1: ⚠️ Potential issue

Add a LICENSE file to the root directory

The pipeline failure indicates that a LICENSE file is missing in the root directory. Including a LICENSE file is essential for open-source compliance and clarity on usage rights.

🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

🧹 Nitpick comments (18)
packages/avnu_provider/lib/src/typed_data/encode.dart (8)

7-7: Consider a more descriptive constant name.

The constant stringZero could be more descriptive, such as ZERO_PADDING or DEFAULT_PAD_CHAR, to better convey its purpose in padding operations.

-const stringZero = '0';
+const ZERO_PADDING = '0';

19-23: Improve deprecated function documentation.

The documentation comment is identical to the function it redirects to. Consider adding a deprecation reason and migration instructions.

-// Convert utf8-string to Uint8Array
+/// Converts UTF-8 string to Uint8Array.
+/// @deprecated Use [utf8ToArray] instead as it provides a more semantic name
+/// for UTF-8 string conversion operations.

25-33: Enhance documentation for base64 conversion functions.

The functions claim browser and Node.js compatibility in comments, but this is a Dart implementation. Consider updating the documentation to reflect the actual implementation.

-// Convert string to array buffer (browser and node compatible)
+/// Decodes a base64 string into a byte array using Dart's built-in base64 codec.
 Uint8List atobUniversal(String a) {
   return base64.decode(a);
 }

-// Convert array buffer to string (browser and node compatible)
+/// Encodes a byte array into a base64 string using Dart's built-in base64 codec.
 String btoaUniversal(Uint8List b) {
   return base64.encode(b);
 }

35-48: Add input validation for hex string operations.

The hex manipulation functions should validate their inputs to ensure they contain valid hexadecimal characters.

 String buf2hex(Uint8List buffer) {
   return buffer.map((x) => x.toRadixString(16).padLeft(2, '0')).join();
 }

 String removeHexPrefix(String hex) {
+  if (hex.isEmpty) {
+    throw ArgumentError('Hex string cannot be empty');
+  }
   return hex.replaceFirst(RegExp(r'^0x', caseSensitive: false), '');
 }

 String addHexPrefix(String hex) {
+  if (!RegExp(r'^[0-9a-fA-F]*$').hasMatch(removeHexPrefix(hex))) {
+    throw ArgumentError('Invalid hex string');
+  }
   return '0x${removeHexPrefix(hex)}';
 }

50-73: Add input validation for padding operations.

The padding functions should validate their inputs to ensure length is non-negative and padding string is not empty.

 String padString(
   String str,
   int length,
   bool left, {
   String padding = stringZero,
 }) {
+  if (length < 0) {
+    throw ArgumentError('Length cannot be negative');
+  }
+  if (padding.isEmpty) {
+    throw ArgumentError('Padding string cannot be empty');
+  }
   final diff = length - str.length;
   var result = str;
   if (diff > 0) {
     final pad = padding * diff;
     result = left ? pad + str : str + pad;
   }
   return result;
 }

75-98: Add validation and optimize hex sanitization.

The byte length and sanitization functions could benefit from input validation and optimization.

 int calcByteLength(String str, [int byteSize = 8]) {
+  if (byteSize <= 0) {
+    throw ArgumentError('Byte size must be positive');
+  }
   final length = str.length;
   final remainder = length % byteSize;
   return remainder > 0
       ? ((length - remainder) ~/ byteSize) * byteSize + byteSize
       : length;
 }

 String sanitizeHex(String hex) {
+  if (hex.isEmpty) {
+    return hex;
+  }
   final hexWithoutPrefix = removeHexPrefix(hex);
+  if (!RegExp(r'^[0-9a-fA-F]*$').hasMatch(hexWithoutPrefix)) {
+    throw ArgumentError('Invalid hex string');
+  }
   final sanitizedHex = sanitizeBytes(hexWithoutPrefix, byteSize: 2);
-  return sanitizedHex.isNotEmpty ? addHexPrefix(sanitizedHex) : sanitizedHex;
+  return addHexPrefix(sanitizedHex);
 }

100-105: Improve case conversion robustness.

The case conversion function could handle more edge cases and provide better validation.

 String pascalToSnake(String text) {
+  if (text.isEmpty) {
+    return text;
+  }
+
   if (!RegExp(r'[a-z]').hasMatch(text)) return text;
 
-  return text.split(RegExp(r'(?=[A-Z])')).join('_').toUpperCase();
+  // Handle consecutive uppercase letters correctly
+  return text
+      .replaceAllMapped(
+          RegExp(r'([A-Z]+)([A-Z][a-z])|([a-z])([A-Z])'),
+          (Match m) =>
+              '${m[1] ?? m[3] ?? ''}${m[1] != null ? '_' : ''}${m[2] ?? m[4] ?? ''}')
+      .toUpperCase();
 }

107-120: Add input validation for array concatenation.

The array concatenation function should validate its input to ensure the array list is not empty.

 Uint8List concatenateArrayBuffer(List<Uint8List> uint8arrays) {
+  if (uint8arrays.isEmpty) {
+    return Uint8List(0);
+  }
   final totalLength =
       uint8arrays.fold<int>(0, (total, array) => total + array.length);
   final result = Uint8List(totalLength);
   var offset = 0;
 
   for (final array in uint8arrays) {
     result.setRange(offset, offset + array.length, array);
     offset += array.length;
   }
 
   return result;
 }
packages/avnu_provider/lib/src/provider.dart (2)

1-1: Use relative imports for internal files within the same package

Importing your own package using package: syntax can lead to issues with duplicate copies of code and can cause problems with relative paths and library privacy. It's recommended to use relative imports for files within the same package.

Apply this diff to change the import to a relative path:

-import 'package:avnu_provider/avnu_provider.dart';
+import '../avnu_provider.dart';
🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.


4-6: Use Dart documentation comments for public API methods

To improve code documentation and enable tools like dartdoc to generate API documentation, it's recommended to use triple-slash comments (///) before public class and method declarations.

Apply this change to convert the comments:

-  // Build the data type for the account
-  //
-  // [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)
+  /// Build the data type for the account
+  ///
+  /// [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)

Repeat similar changes for the other methods.

Also applies to: 14-17, 20-23, 31-32

packages/avnu_provider/lib/src/read_provider.dart (1)

59-59: Remove unnecessary cast

The cast to Map<String, dynamic> is unnecessary here. The callRpcEndpoint function already returns a dynamic that can be passed directly to AvnuStatus.fromJson.

Apply this diff to remove the unnecessary cast:

-        (dynamic json) => AvnuStatus.fromJson(json as Map<String, dynamic>));
+        (dynamic json) => AvnuStatus.fromJson(json));
packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1)

31-32: Remove unnecessary cast and enclose 'if' statement in a block

The cast (params as List<String>) is unnecessary if params is already of type List<String>. Additionally, it's recommended to enclose the statements within an if block using braces {} for better readability and to avoid potential bugs.

Apply this diff to remove the unnecessary cast and add braces:

-      if ((params as List<String>)[0] != '')
-        headers['api-key'] = (params as List<String>)[0];
+      final paramsList = params as List<String>;
+      if (paramsList[0] != '') {
+        headers['api-key'] = paramsList[0];
+      }
🧰 Tools
🪛 GitHub Actions: CI

[warning] 31-31: Unnecessary cast. Try removing the cast.


[info] 31-31: Statements in an if should be enclosed in a block. Try wrapping the statement in a block.

packages/avnu_provider/lib/src/avnu_config.dart (1)

24-27: Add validation for API key format.

While the API key can be empty (as per comment), consider validating its format when non-empty to catch configuration errors early.

Apply this diff to add basic validation:

   void setApiKey(String apiKey) {
+    if (apiKey.isNotEmpty && !RegExp(r'^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$').hasMatch(apiKey)) {
+      throw ArgumentError('Invalid API key format');
+    }
     _apiKey = apiKey;
   }
packages/avnu_provider/test/provider_test.dart (1)

306-307: Document the missing account deployment test.

The TODO comment about testing with deploymentData should be expanded to explain why it's currently disabled and what conditions need to be met to enable it.

Apply this diff to improve the documentation:

-      // TODO: test execution with deploymentData for account deploy.
+      // TODO: Test execution with deploymentData for account deploy.
+      // This test is currently disabled because:
+      // 1. Account deployment requires specific testnet conditions
+      // 2. Need to implement gasless new account deployment support
+      // Enable this test once the above requirements are met.
packages/avnu_provider/lib/src/typed_data/typed_data.dart (4)

337-355: Document merkletree implementation status.

The TODO comment about merkletree implementation should be more descriptive about its current status and future plans.

Apply this diff:

-    // TODO: Implement merkletree (not required for avnu paymaster)
+    // TODO(#issue): Merkletree implementation is currently not required for AVNU paymaster.
+    // This feature will be implemented in a future update when needed.

376-376: Remove redundant comment.

The comment "... Add other type cases following the same pattern as in the JS code ..." is implementation noise and should be removed.


297-415: Consider using a more maintainable pattern for type handling.

The large switch statement for handling different types could be refactored into a more maintainable pattern using a strategy pattern or type registry.

Consider creating a TypeHandler interface and separate handler classes for each type. This would make the code more modular and easier to maintain.

Example structure:

abstract class TypeHandler {
  List<String> encode(dynamic data, TypedDataRevision revision);
}

class EnumTypeHandler implements TypeHandler {
  @override
  List<String> encode(dynamic data, TypedDataRevision revision) {
    // Implementation for enum type
  }
}

// Register handlers in a map
final typeHandlers = {
  'enum': EnumTypeHandler(),
  // ... other handlers
};

379-383: Consider extracting magic numbers to named constants.

The u128 max value should be extracted to a named constant for better readability and maintainability.

Apply this diff:

+  static const u128MaxValue = BigInt.parse('340282366920938463463374607431768211455');
+
   case 'u128':
   case 'timestamp':
     if (revision == TypedDataRevision.active) {
       assertRange(data, type,
           min: BigInt.zero,
-          max: BigInt.parse('340282366920938463463374607431768211455'));
+          max: u128MaxValue);
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d398e06 and e24a4e4.

📒 Files selected for processing (16)
  • packages/avnu_provider/lib/src/avnu_config.dart (1 hunks)
  • packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1 hunks)
  • packages/avnu_provider/lib/src/index.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (1 hunks)
  • packages/avnu_provider/lib/src/provider.dart (1 hunks)
  • packages/avnu_provider/lib/src/read_provider.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/encode.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/hash.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/merkle.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/num.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/shortstring.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart (1 hunks)
  • packages/avnu_provider/test/integration/read_provider_test.dart (1 hunks)
  • packages/avnu_provider/test/provider_test.dart (1 hunks)
  • packages/avnu_provider/test/utils.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • packages/avnu_provider/lib/src/model/avnu_account_rewards.dart
  • packages/avnu_provider/lib/src/index.dart
  • packages/avnu_provider/test/integration/read_provider_test.dart
  • packages/avnu_provider/lib/src/typed_data/merkle.dart
  • packages/avnu_provider/lib/src/typed_data/hash.dart
  • packages/avnu_provider/test/utils.dart
  • packages/avnu_provider/lib/src/typed_data/shortstring.dart
  • packages/avnu_provider/lib/src/typed_data/num.dart
🧰 Additional context used
📓 Learnings (1)
packages/avnu_provider/test/provider_test.dart (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#451
File: packages/avnu_provider/test/provider_test.dart:45-45
Timestamp: 2025-02-06T15:57:05.663Z
Learning: Hardcoded API keys are acceptable in test files when they are specifically designated for testing purposes.
🪛 GitHub Actions: code_health
packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/avnu_config.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/read_provider.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/test/provider_test.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/typed_data/encode.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/typed_data/typed_data.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/provider.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

🪛 GitHub Actions: CI
packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[warning] 31-31: Unnecessary cast. Try removing the cast.


[info] 31-31: Statements in an if should be enclosed in a block. Try wrapping the statement in a block.


[info] 124-124: Unnecessary empty statement. Try removing the empty statement or restructuring the code.

packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart

[warning] 36-36: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 45-45: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 46-46: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 47-47: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 48-48: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 49-49: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 50-50: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 51-51: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 52-52: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 53-53: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 55-55: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 56-56: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 66-66: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 67-67: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 68-68: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 69-69: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 70-70: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 71-71: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 72-72: The annotation 'JsonKey' can only be used on fields or getters.

packages/avnu_provider/test/provider_test.dart

[warning] 1-1: A tag was used that wasn't specified in dart_test.yaml. Integration was used in the group 'WriteProvider'.

packages/avnu_provider/lib/src/typed_data/typed_data.dart

[warning] 165-165: The operand can't be 'null', so the condition is always 'true'. Remove the condition.


[warning] 166-166: The operand can't be 'null', so the condition is always 'true'. Remove the condition.


[warning] 167-167: The operand can't be 'null', so the condition is always 'true'. Remove the condition.


[warning] 168-168: The operand can't be 'null', so the condition is always 'true'. Remove the condition.


[warning] 177-177: The '!' will have no effect because the receiver can't be null. Try removing the '!' operator.

🔇 Additional comments (3)
packages/avnu_provider/lib/src/read_provider.dart (2)

1-1: Use relative imports for internal files within the same package

Importing your own package using package: syntax can lead to issues with duplicate copies of code and can cause problems with relative paths and library privacy. It's recommended to use relative imports for files within the same package.

Apply this diff to change the import to a relative path:

-import 'package:avnu_provider/avnu_provider.dart';
+import '../avnu_provider.dart';
🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): Unnecessary cast. Try removing the cast.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 1-1: enclosed in a block. Try wrapping the statement in a block.


[info] 1-1: Unnecessary empty statement. Try removing the empty statement or restructuring the code.


[info] 1-1: Import of a library in the 'lib/src' directory of another package. Try importing a public library that exports this library, or removing the import.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.


4-7: Use Dart documentation comments for public API methods

To improve code documentation and enable tools like dartdoc to generate API documentation, it's recommended to use triple-slash comments (///) before public class and method declarations.

Apply this change to convert the comments:

-  // Gets the AVNU service status
-  //
-  // [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)
+  /// Gets the AVNU service status
+  ///
+  /// [Spec](https://doc.avnu.fi/avnu-paymaster/integration/api-references)

Repeat similar changes for the other methods.

Also applies to: 9-12, 14-17, 19-22, 25-28, 31-32

packages/avnu_provider/test/provider_test.dart (1)

431-431: Add test tag to dart_test.yaml.

The pipeline reports a warning about the 'integration' tag not being specified in dart_test.yaml.

Add the tag to your dart_test.yaml file:

tags:
  integration:
    timeout: 1m
✅ Verification successful

Action: Update dart_test.yaml to include the missing integration tag.

The pipeline warning is due to the integration tag used in your test file not being declared in your dart_test.yaml. To resolve this, add the following snippet to your dart_test.yaml:

tags:
  integration:
    timeout: 1m

This ensures that tests tagged with 'integration' have the appropriate timeout setting.

Comment on lines +45 to +57
@JsonKey(name: 'caller') String? callerv1,
@JsonKey(name: 'Caller') String? callerv2,
@JsonKey(name: 'nonce') String? noncev1,
@JsonKey(name: 'Nonce') String? noncev2,
@JsonKey(name: 'execute_after') String? executeAfterv1,
@JsonKey(name: 'Execute After') String? executeAfterv2,
@JsonKey(name: 'execute_before') String? executeBeforev1,
@JsonKey(name: 'Execute Before') String? executeBeforev2,
@JsonKey(name: 'calls_len') int? callsLen,
// process calls or Calls in json response
@JsonKey(name: 'calls') List<Call>? calls,
@JsonKey(name: 'Calls') List<Call>? callsv2,
}) = _Message;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Fix JsonKey annotations and add documentation.

The pipeline reports warnings about JsonKey annotations. Additionally, the code would benefit from documentation explaining the versioning scheme.

Apply this diff to fix the annotations and add documentation:

   const factory Message({
+    /// Caller address (v1 format)
     @JsonKey(name: 'caller')
     String? callerv1,
+    /// Caller address (v2 format)
     @JsonKey(name: 'Caller')
     String? callerv2,
+    /// Transaction nonce (v1 format)
     @JsonKey(name: 'nonce')
     String? noncev1,
+    /// Transaction nonce (v2 format)
     @JsonKey(name: 'Nonce')
     String? noncev2,
     // ... continue for other fields
   }) = _Message;
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
@JsonKey(name: 'caller') String? callerv1,
@JsonKey(name: 'Caller') String? callerv2,
@JsonKey(name: 'nonce') String? noncev1,
@JsonKey(name: 'Nonce') String? noncev2,
@JsonKey(name: 'execute_after') String? executeAfterv1,
@JsonKey(name: 'Execute After') String? executeAfterv2,
@JsonKey(name: 'execute_before') String? executeBeforev1,
@JsonKey(name: 'Execute Before') String? executeBeforev2,
@JsonKey(name: 'calls_len') int? callsLen,
// process calls or Calls in json response
@JsonKey(name: 'calls') List<Call>? calls,
@JsonKey(name: 'Calls') List<Call>? callsv2,
}) = _Message;
const factory Message({
/// Caller address (v1 format)
@JsonKey(name: 'caller') String? callerv1,
/// Caller address (v2 format)
@JsonKey(name: 'Caller') String? callerv2,
/// Transaction nonce (v1 format)
@JsonKey(name: 'nonce') String? noncev1,
/// Transaction nonce (v2 format)
@JsonKey(name: 'Nonce') String? noncev2,
@JsonKey(name: 'execute_after') String? executeAfterv1,
@JsonKey(name: 'Execute After') String? executeAfterv2,
@JsonKey(name: 'execute_before') String? executeBeforev1,
@JsonKey(name: 'Execute Before') String? executeBeforev2,
@JsonKey(name: 'calls_len') int? callsLen,
// process calls or Calls in json response
@JsonKey(name: 'calls') List<Call>? calls,
@JsonKey(name: 'Calls') List<Call>? callsv2,
}) = _Message;
🧰 Tools
🪛 GitHub Actions: CI

[warning] 45-45: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 46-46: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 47-47: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 48-48: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 49-49: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 50-50: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 51-51: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 52-52: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 53-53: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 55-55: The annotation 'JsonKey' can only be used on fields or getters.


[warning] 56-56: The annotation 'JsonKey' can only be used on fields or getters.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🔭 Outside diff range comments (2)
packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1)

1-1385: Address pipeline validation failures.

Several issues were reported by the package validator:

  1. Missing LICENSE file in the root directory
  2. Invalid JsonSerializable and JsonKey annotations in the source file
  3. Missing version notes in CHANGELOG.md

Required actions:

  1. Add a LICENSE file to the root directory
  2. Fix the JsonSerializable and JsonKey annotations in avnu_build_typed_data.dart
  3. Update CHANGELOG.md with notes for version 0.1.0+1

To fix the annotation issues, ensure they are properly placed on class declarations and fields in the source file:

@JsonSerializable()
class AvnuBuildTypedData {
  @JsonKey(name: 'field_name')
  final String field;
  // ...
}
🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart (1)

1-167:

🧩 Analysis chain

Address pipeline failures before merging.

Several issues need to be addressed:

  1. Add a LICENSE file to the root directory
  2. Fix invalid @JsonSerializable and @JsonKey annotations in avnu_build_typed_data.dart
  3. Update CHANGELOG.md with notes for version 0.1.0+1
  4. Review dependency overrides in pubspec_overrides.yaml

Run this script to check the LICENSE file and CHANGELOG:


🏁 Script executed:

#!/bin/bash
# Description: Verify LICENSE and CHANGELOG files

# Check if LICENSE exists
if [ ! -f "LICENSE" ]; then
    echo "ERROR: LICENSE file is missing"
fi

# Check CHANGELOG version
if ! grep -q "## 0.1.0+1" "packages/avnu_provider/CHANGELOG.md"; then
    echo "ERROR: Version 0.1.0+1 not found in CHANGELOG.md"
fi

# List dependency overrides
if [ -f "pubspec_overrides.yaml" ]; then
    echo "WARNING: Found the following dependency overrides:"
    cat pubspec_overrides.yaml
fi

Length of output: 297


Pipeline Failures Detected: Missing LICENSE and CHANGELOG Version Notes

  • The root LICENSE file is missing.
  • The CHANGELOG in packages/avnu_provider/CHANGELOG.md does not contain the version information for 0.1.0+1.
  • Additionally, please address the invalid @JsonSerializable and @jsonkey annotations in avnu_build_typed_data.dart and review the dependency overrides in pubspec_overrides.yaml.
🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

🧹 Nitpick comments (7)
packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (3)

648-673: Consider consolidating version-specific fields.

The Message class contains duplicate fields for different versions (v1 and v2) which could lead to maintenance issues. Consider using a version enum and a single set of fields instead.

Example approach:

enum MessageVersion { v1, v2 }

class Message {
  final MessageVersion version;
  final String? caller;
  final String? nonce;
  final String? executeAfter;
  final String? executeBefore;
  // ...
}

1070-1085: Similar versioning issue in Call class.

The Call class follows the same pattern of duplicate fields for different versions.

Consider applying the same versioning solution as suggested for the Message class.


189-194: Improve immutability handling.

The code uses EqualUnmodifiableListView for collections but checks for it before returning. This pattern is repeated in multiple places.

Consider wrapping collections in EqualUnmodifiableListView at construction time instead of checking each time:

class _$MessageImpl implements _Message {
  final List<Call>? _calls;
  
  _$MessageImpl({List<Call>? calls}) 
    : _calls = calls == null ? null : EqualUnmodifiableListView(calls);
    
  @override
  List<Call>? get calls => _calls;
}

Also applies to: 923-933, 935-944, 1270-1279, 1281-1290

packages/avnu_provider/lib/src/call_rpc_endpoint.dart (4)

6-11: Consider making the ask-signature header configurable.

The ask-signature header is currently hardcoded to 'true' but needs to be removed for certain methods (e.g., paymaster_get_account_rewards). Consider making this configurable based on the method or adding it only when needed.

-  headers['ask-signature'] = 'true';
+  // Only add ask-signature header for methods that support it
+  if (!['paymaster_get_account_rewards'].contains(method)) {
+    headers['ask-signature'] = 'true';
+  }

13-124: Extract method handlers into separate functions.

The switch statement is quite long and handles complex logic for each method. Consider extracting each case into a separate function for better maintainability and testability.

+  Future<(Uri, String, Map<String, String>, Map<String, dynamic>)> _handlePaymasterStatus(
+      Uri nodeUri, Map<String, String> headers) async {
+    return (
+      nodeUri.replace(path: '/paymaster/v1/status'),
+      'get',
+      headers,
+      {},
+    );
+  }
+
   switch (method) {
     case 'paymaster_status':
-      httpMethod = 'get';
-      nodeUri = nodeUri.replace(path: '/paymaster/v1/status');
+      final (newUri, method, newHeaders, body) = await _handlePaymasterStatus(nodeUri, headers);
+      nodeUri = newUri;
+      httpMethod = method;
+      headers = newHeaders;
+      body = body;
       break;

139-160: Extract signature verification into a separate function.

The signature verification logic is complex and would be more maintainable as a separate function. This would also make it easier to test.

+  Future<void> _verifySignature(http.Response response) async {
+    if (AvnuConfig.instance.publicKey == null ||
+        response.headers['ask-signature'] != 'true') {
+      return;
+    }
+
+    final signatureParts = response.headers['signature']!.split(',');
+    final signature = Signature(
+        BigInt.parse(signatureParts[0].substring(2), radix: 16),
+        BigInt.parse(signatureParts[1].substring(2), radix: 16));
+
+    final messageHash = computeHashOnElements(
+        [starknetKeccak(utf8.encode(response.body)).toBigInt()]);
+
+    final publicKey = AvnuConfig.instance.publicKey!;
+    final isValid = starknetVerify(
+        messageHash: messageHash, signature: signature, publicKey: publicKey);
+
+    if (!isValid) {
+      throw Exception('Invalid signature');
+    }
+  }

131-165: Use more specific error types for better error handling.

The current error handling uses generic Exception and FormatException. Consider creating custom error types for better error handling by consumers.

class SignatureVerificationError extends Exception {
  final String message;
  SignatureVerificationError(this.message);
}

class PaymasterResponseError extends Exception {
  final String message;
  final String responseBody;
  PaymasterResponseError(this.message, this.responseBody);
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e24a4e4 and 92ae015.

📒 Files selected for processing (6)
  • packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_execute.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (3)
  • packages/avnu_provider/lib/src/model/avnu_execute.dart
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart
🧰 Additional context used
🪛 GitHub Actions: code_health
packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

🔇 Additional comments (4)
packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1)

1-5: Generated code should not be modified directly.

This is an auto-generated file by the Freezed package. Any changes should be made to the source file avnu_build_typed_data.dart instead.

🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/lib/src/model/avnu_execute.freezed.dart (2)

1-5: LGTM! Generated code with appropriate ignore directives.

The file is correctly marked as generated code with appropriate ignore directives for linting and coverage.

🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.


21-33: LGTM! Well-structured data class definition.

The AvnuExecute class is well-structured with:

  • Required transactionHash field
  • JSON serialization support
  • Immutable data class copying
packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1)

1-1: Add a LICENSE file to the root directory

The pipeline failure indicates that a LICENSE file is missing in the root directory. Including a LICENSE file is essential for open-source compliance and clarity on usage rights.

🧰 Tools
🪛 GitHub Actions: code_health

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[error] 1-1: Package validation found the following potential issues: dart analyze found the following issue(s): warning - lib/src/model/avnu_build_typed_data.dart:44:4 - The annotation 'JsonSerializable' can only be used on classes. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:46:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:47:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:73:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following potential issues: warning - lib/src/model/avnu_build_typed_data.dart:74:6 - The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target.


[error] 1-1: Package validation found the following error: /home/runner/work/starknet.dart/starknet.dart/packages/avnu_provider/CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (5)
packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (5)

6-17: Add class documentation.

Please add documentation to explain the purpose and usage of this class, especially since it's a key component for typed data handling in the AVNU paymaster implementation.

 @freezed
+/// Represents the structure for building typed data in AVNU paymaster transactions.
+/// 
+/// This class is used to create and serialize typed data that follows the AVNU
+/// paymaster's expected format, containing type definitions, domain information,
+/// and message content.
 class AvnuBuildTypedData with _$AvnuBuildTypedData {

19-28: Add class documentation.

Please add documentation to explain the purpose of this class and its fields.

 @freezed
+/// Defines a type in the AVNU paymaster's type system.
+/// 
+/// Each type definition consists of a name and its corresponding type string.
+/// This is used to describe the structure of data in typed data signatures.
 class TypeDefinition with _$TypeDefinition {
   const factory TypeDefinition({
+    /// The name of the type being defined
     required String name,
+    /// The type string that describes this type's structure
     required String type,
   }) = _TypeDefinition;

30-40: Add class documentation.

Please add documentation to explain the purpose of this class and its fields.

 @freezed
+/// Represents the domain information for typed data signing.
+/// 
+/// The domain helps ensure the signature is valid only for a specific application,
+/// chain, and version, preventing signature replay across different contexts.
 class Domain with _$Domain {
   const factory Domain({
+    /// The name of the signing domain (e.g., application name)
     required String name,
+    /// The version of the signing domain
     required String version,
+    /// The chain ID where this signature is valid
     required String chainId,
+    /// Optional revision number for the domain
     String? revision,
   }) = _Domain;

42-61: Add class documentation and explain versioning scheme.

Please add documentation to explain:

  1. The purpose of this class
  2. The versioning scheme (v1/v2)
  3. The relationship between different versions of the same field
 @freezed
+/// Represents the message content for typed data signing in AVNU paymaster transactions.
+/// 
+/// This class supports two versions of field names (v1 and v2) to maintain
+/// compatibility with different versions of the AVNU paymaster API. Each field
+/// has both lowercase (v1) and capitalized (v2) variants.
 class Message with _$Message {
   const factory Message({
+    /// The caller's address in v1 format (lowercase)
     @JsonKey(name: 'caller') String? callerv1,
+    /// The caller's address in v2 format (capitalized)
     @JsonKey(name: 'Caller') String? callerv2,
     // ... continue for other fields
   }) = _Message;

63-76: Add class documentation and explain versioning scheme.

Please add documentation to explain:

  1. The purpose of this class
  2. The versioning scheme (v1/v2)
  3. The relationship between different versions of the same field
 @freezed
+/// Represents a call in the AVNU paymaster transaction.
+/// 
+/// This class describes a single call within a transaction, including the target
+/// address, selector, and calldata. Like the Message class, it supports two
+/// versions of field names (v1 and v2) for API compatibility.
 class Call with _$Call {
   const factory Call({
+    /// The target address in v1 format (lowercase)
     @JsonKey(name: 'to') String? tov1,
+    /// The target address in v2 format (capitalized)
     @JsonKey(name: 'To') String? tov2,
     // ... continue for other fields
   }) = _Call;
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 92ae015 and 3e060f5.

📒 Files selected for processing (2)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/avnu_provider/lib/src/model/avnu_build_typed_data.freezed.dart
⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: lint
  • GitHub Check: analyze
  • GitHub Check: test-integration
🔇 Additional comments (1)
packages/avnu_provider/lib/src/model/avnu_build_typed_data.dart (1)

1-4: LGTM!

The file structure with freezed annotations and part declarations is correctly set up.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1)

126-129: Remove debug print statements.

Remove the debug print statements to keep the code clean and production-ready.

Apply this diff to remove the debug statements:

-  print('****************************************************');
-  print('filteredBody: $filteredBody');
-  print('****************************************************');
-  print('****************************************************');
-  print('response.body: ${response.body}');
-  print('****************************************************');

Also applies to: 133-135

packages/avnu_provider/test/provider_test.dart (3)

9-22: Consider making the function immutable.

The current implementation modifies the input map in place. Consider making it immutable by returning a new map instead.

Apply this diff to make the function immutable:

-void removeNullFields(Map<String, dynamic> json) {
-  json.removeWhere((key, value) => value == null);
-  json.forEach((key, value) {
-    if (value is Map<String, dynamic>) {
-      removeNullFields(value);
-    } else if (value is List) {
-      for (var item in value) {
-        if (item is Map<String, dynamic>) {
-          removeNullFields(item);
-        }
-      }
-    }
-  });
+Map<String, dynamic> removeNullFields(Map<String, dynamic> json) {
+  final result = Map<String, dynamic>.from(json);
+  result.removeWhere((key, value) => value == null);
+  result.forEach((key, value) {
+    if (value is Map<String, dynamic>) {
+      result[key] = removeNullFields(value);
+    } else if (value is List) {
+      result[key] = value.map((item) {
+        if (item is Map<String, dynamic>) {
+          return removeNullFields(item);
+        }
+        return item;
+      }).toList();
+    }
+  });
+  return result;
}

75-75: Remove commented out code.

Remove the commented out code to keep the test file clean and maintainable.

Apply this diff to remove the commented out code:

-        //final accountClassHash = '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003';
-        // {
-        //   // 'class_hash': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'salt': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'unique': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'calldata': ['0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003'],
-        //   // 'sigdata': ['0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003']
-        // };

Also applies to: 121-127


151-151: Remove commented out code.

Remove the commented out code to keep the test file clean and maintainable.

Apply this diff to remove the commented out code:

-        //final accountClassHash = '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003';
-        // {
-        //   // 'class_hash': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'salt': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'unique': '0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003',
-        // 'calldata': ['0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003'],
-        //   // 'sigdata': ['0x01a736d6ed154502257f02b1ccdf4d9d1089f80811cd6acad48e6b6a9d1f2003']
-        // };

Also applies to: 196-202

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3e060f5 and f4ec0e0.

📒 Files selected for processing (3)
  • .github/workflows/ci.yaml (1 hunks)
  • packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1 hunks)
  • packages/avnu_provider/test/provider_test.dart (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .github/workflows/ci.yaml
🧰 Additional context used
📓 Learnings (1)
packages/avnu_provider/test/provider_test.dart (1)
Learnt from: rukafe0x
PR: focustree/starknet.dart#451
File: packages/avnu_provider/test/provider_test.dart:45-45
Timestamp: 2025-02-06T15:57:05.663Z
Learning: Hardcoded API keys are acceptable in test files when they are specifically designated for testing purposes.
🪛 GitHub Actions: code_health
packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target


[warning] 1-1: CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

packages/avnu_provider/test/provider_test.dart

[error] 1-1: Package validation found the following error: You must have a LICENSE file in the root directory. An open-source license helps ensure people can legally use your code.


[warning] 1-1: dart analyze found the following issue(s): The annotation 'JsonKey' can only be used on fields or getters. - invalid_annotation_target


[warning] 1-1: CHANGELOG.md doesn't mention current version (0.1.0+1). Consider updating it with notes on this version prior to publication.


[hint] 1-1: Non-dev dependencies are overridden in pubspec_overrides.yaml. This indicates you are not testing your package against the same versions of its dependencies that users will have when they use it.

🪛 Gitleaks (8.21.2)
packages/avnu_provider/test/provider_test.dart

45-45: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 GitHub Actions: CI
packages/avnu_provider/test/provider_test.dart

[warning] 1-1: A tag was used that wasn't specified in dart_test.yaml. integration was used in the group 'WriteProvider'.

🔇 Additional comments (2)
packages/avnu_provider/test/provider_test.dart (2)

208-306: LGTM!

The test is well-documented and thoroughly tests the functionality of executing sponsored transactions without an API key.


410-430: LGTM!

The test is well-documented and thoroughly tests the functionality of setting account rewards.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
docs/packages/avnu_provider.mdx (3)

13-14: Fix grammatical issues in the introduction.

There are a few grammatical errors that should be corrected:

  • Line 13: "With these provider" should be "With this provider"
  • Line 20: "User prepare" should be "User prepares"
-With these provider you (as sponsor) will be able to pay your users' gas fees and you (as a user) will be able to execute gasless transactions sponsored by the sponsor.
+With this provider you (as sponsor) will be able to pay your users' gas fees and you (as a user) will be able to execute gasless transactions sponsored by the sponsor.

-5.  User prepare their transaction (using `buildTypedData` function).
+5.  User prepares their transaction (using `buildTypedData` function).

Also applies to: 20-20

🧰 Tools
🪛 LanguageTool

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


70-78: Improve clarity of optional parameters in buildTypedData documentation.

The documentation for optional parameters could be clearer. Consider restructuring the parameters list to better indicate which parameters are optional and their relationship with rewards usage.

Arguments:
- `userAddress`: Your user account address.
- `calls`: The list of calls to execute.
-`gasTokenAddress`: The gas token address. (Optional, this must be excluded if you want to use your rewards)
-`maxGasTokenAmount`: The max gas token amount. (Optional, this must be excluded if you want to use your rewards)
- `accountClassHash`: The account class hash.
+`gasTokenAddress`: The gas token address. Set to empty string to use rewards.
+`maxGasTokenAmount`: The max gas token amount. Set to empty string to use rewards.
🧰 Tools
🪛 LanguageTool

[style] ~71-~71: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~77-~77: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


87-87: Add a note about gasless account deployment support.

The documentation mentions that deployment data is "only provided for future compatibility". Consider adding a note referencing the PR objectives which explicitly state that gasless account deployment is not supported in the current version.

-`deploymentData`: The deployment data. At this moment, this field is not used and is only provided for future compatibility with gasless account deployment.
+`deploymentData`: The deployment data. This field is reserved for future compatibility with gasless account deployment, which is not supported in the current version.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~87-~87: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f4ec0e0 and 7f7a1bc.

📒 Files selected for processing (2)
  • docs/packages/avnu_provider.mdx (1 hunks)
  • packages/avnu_provider/LICENSE (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • packages/avnu_provider/LICENSE
🧰 Additional context used
🪛 LanguageTool
docs/packages/avnu_provider.mdx

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


[grammar] ~20-~20: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~60-~60: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~71-~71: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~77-~77: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~87-~87: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


[formatting] ~94-~94: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~100-~100: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)


[grammar] ~138-~138: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


[grammar] ~166-~166: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

⏰ Context from checks skipped due to timeout of 90000ms (3)
  • GitHub Check: test-integration
  • GitHub Check: analyze
  • GitHub Check: lint
🔇 Additional comments (1)
docs/packages/avnu_provider.mdx (1)

1-259: Well-structured and comprehensive documentation!

The documentation effectively covers all aspects of the AVNU Paymaster Provider, including clear explanations of the roles, detailed API documentation, and practical examples. The inclusion of example API responses is particularly helpful for implementation.

🧰 Tools
🪛 LanguageTool

[grammar] ~13-~13: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


[grammar] ~20-~20: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~60-~60: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~71-~71: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~77-~77: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~87-~87: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


[formatting] ~94-~94: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~100-~100: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)


[grammar] ~138-~138: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


[grammar] ~166-~166: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
docs/packages/avnu_provider.mdx (6)

14-15: Fix grammar in the introduction.

The introduction has some grammatical issues that affect readability.

-With these provider you (as sponsor) will be able to pay your users' gas fees and you (as a user) will be able to execute gasless transactions sponsored by the sponsor. So, the user will simply sign a typed data containing the calls he wants to execute. The gas fees in ETH, will be 
-paid by Avnu relayers to execute the transaction. The process is as follows:
+With this provider, you (as a sponsor) will be able to pay your users' gas fees, and you (as a user) will be able to execute gasless transactions sponsored by the sponsor. The user will simply sign typed data containing the calls they want to execute. The gas fees in ETH will be 
+paid by Avnu relayers to execute the transaction. The process is as follows:
🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


21-22: Fix grammar in user steps.

The steps have subject-verb agreement issues.

-5.  User prepare their transaction (using `buildTypedData` function).
-6.  And finally, sign it (using `execute` function) and send it to the Avnu relayer.
+5.  User prepares their transaction (using `buildTypedData` function).
+6.  Finally, signs it (using `execute` function) and sends it to the Avnu relayer.
🧰 Tools
🪛 LanguageTool

[grammar] ~21-~21: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


72-73: Improve clarity in function description.

The description of buildTypedData function is wordy and redundant.

-Prepare and build a typed data to execute a transaction (mandatory step previous to execute a transaction).
+Prepare and build typed data to execute a transaction (mandatory step before execution).
🧰 Tools
🪛 LanguageTool

[style] ~72-~72: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


77-79: Clarify optional parameters in function documentation.

The documentation for optional parameters is repetitive and can be improved.

-`gasTokenAddress`: The gas token address. (Optional, this must be excluded if you want to use your rewards)
-`maxGasTokenAmount`: The max gas token amount. (Optional, this must be excluded if you want to use your rewards)
+`gasTokenAddress`: The gas token address. (Leave empty to use rewards)
+`maxGasTokenAmount`: The max gas token amount. (Leave empty to use rewards)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~78-~78: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


88-89: Update deployment data documentation.

The documentation for deploymentData can be more concise.

-`deploymentData`: The deployment data. At this moment, this field is not used and is only provided for future compatibility with gasless account deployment.
+`deploymentData`: The deployment data. Currently unused, reserved for future gasless account deployment support.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~88-~88: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~88-~88: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


264-269: Add environment variable validation in test instructions.

The test instructions should include validation of environment variables.

 To run the tests, you need to set the environment variables `AVNU_RPC` and `STARKNET_RPC` with the corresponding values.
 
 ```bash
+# Validate environment variables
+if [ -z "$AVNU_RPC" ] || [ -z "$STARKNET_RPC" ]; then
+  echo "Error: AVNU_RPC and STARKNET_RPC must be set"
+  exit 1
+fi
+
 export AVNU_RPC=https://sepolia.api.avnu.fi
 export STARKNET_RPC=https://starknet-sepolia.public.blastapi.io/rpc/v0_7

</blockquote></details>

</blockquote></details>

<details>
<summary>📜 Review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**

<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between 7f7a1bcdf64e59325ec7d64ccf17e2efa57ff98f and a49db4daa7bc4299247562dc5badb02c395fa63b.

</details>

<details>
<summary>📒 Files selected for processing (1)</summary>

* `docs/packages/avnu_provider.mdx` (1 hunks)

</details>

<details>
<summary>🧰 Additional context used</summary>

<details>
<summary>🪛 LanguageTool</summary>

<details>
<summary>docs/packages/avnu_provider.mdx</summary>

[grammar] ~14-~14: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service.  ## I. Introduction  With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)

---

[grammar] ~21-~21: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...`getAccountRewards` function). 5.  User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)

---

[uncategorized] ~23-~23: Possible missing comma found.
Context: ...ll execute the transaction, pay the gas fees and the sponsor will be charged for the...

(AI_HYDRA_LEO_MISSING_COMMA)

---

[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...e account address to check. - `campaign`: The campaign name. - `protocol`: The pr...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...mpaign`: The campaign name. - `protocol`: The protocol name. - `freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...protocol`: The protocol name. - `freeTx`: The number of free transactions. - `exp...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...of free transactions. - `expirationDate`: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~54-~54: Loose punctuation mark.
Context: ...ate of the rewards. - `whitelistedCalls`: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... start date of the activity. - `endDate`: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)

---

[style] ~72-~72: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction).  Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)

---

[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...s`: Your user account address. - `calls`: The list of calls to execute. - `gasTok...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...of calls to execute. - `gasTokenAddress`: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)

---

[style] ~78-~78: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - `accountClassHash`:...

(REP_WANT_TO_VB)

---

[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...Your user account address. - `typedData`: The typed data. - `signature`: The type...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ypedData`: The typed data. - `signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)

---

[uncategorized] ~88-~88: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - `deploymentData`: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)

---

[style] ~88-~88: For conciseness, consider replacing this expression with an adverb.
Context: ... `deploymentData`: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)

---

[formatting] ~95-~95: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status.  Arguments: - `None`.  ### 2) `getGasTokenPrices();` Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)

---

[formatting] ~101-~101: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices.  Arguments: - `None`.  ## III. Examples  You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)

---

[grammar] ~139-~139: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract.  ```...

(PREPOSITION_VERB)

---

[grammar] ~167-~167: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

</details>

</details>

</details>

<details>
<summary>🔇 Additional comments (1)</summary><blockquote>

<details>
<summary>docs/packages/avnu_provider.mdx (1)</summary>

`106-106`: **Fix broken link to test folder.**

The link to the test folder is incorrectly formatted and won't resolve correctly.

```diff
-You could check more examples in the packages [test](https://github.com/focustree/starknet.dart/packages/avnu_provider/test) folder.
+You could check more examples in the packages [test](https://github.com/focustree/starknet.dart/tree/main/packages/avnu_provider/test) folder.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 6

🧹 Nitpick comments (10)
packages/avnu_provider/dart_test.yaml (1)

2-2: Consider documenting integration test requirements.

Since integration tests will interact with the AVNU RPC endpoint, it would be helpful to document any prerequisites or environment setup needed.

Add a comment to clarify the requirements:

 tags:
   integration:
+    # Requires AVNU_RPC environment variable to be set
+    # See .env.devnet for the default configuration
     timeout: 60s
docs/packages/avnu_provider.mdx (3)

14-14: Fix grammatical errors in the introduction.

There are two grammatical issues that need to be corrected:

  1. "With these provider" should be "With this provider"
  2. "User prepare" should be "User prepares"
-With these provider you (as sponsor) will be able to pay your users' gas fees
+With this provider you (as sponsor) will be able to pay your users' gas fees
-5.  User prepare their transaction (using `buildTypedData` function).
+5.  User prepares their transaction (using `buildTypedData` function).

Also applies to: 21-21

🧰 Tools
🪛 LanguageTool

[grammar] ~14-~14: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


42-54: Improve formatting consistency in function arguments.

The arguments lists use inconsistent punctuation. Consider standardizing the format:

Arguments:
-  - `address`: The account address to check.
-  - `campaign`: The campaign name.
+  * `address`: The account address to check.
+  * `campaign`: The campaign name.

Apply this format consistently across all function arguments in the documentation.

Also applies to: 59-61, 74-79, 84-88

🧰 Tools
🪛 LanguageTool

[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~54-~54: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


167-167: Fix grammatical and typographical errors in the examples section.

There are two errors that need to be corrected:

-Now, we set other parameters to get our builded typed data from Avnu API.
+Now, we set other parameters to get our built typed data from Avnu API.
-In the background, this is an example of asuccesful API response:
+In the background, this is an example of a successful API response:

Also applies to: 186-186

🧰 Tools
🪛 LanguageTool

[grammar] ~167-~167: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

packages/avnu_provider/test/utils.dart (1)

15-25: Consider extracting environment variable check to a helper function.

The environment variable check is duplicated across functions. Consider extracting it to reduce code duplication.

+String getRequiredEnvVar(String name) {
+  final env = Platform.environment;
+  if (env[name] == null) {
+    throw Exception('$name environment variable is not set');
+  }
+  return env[name]!;
+}

 AvnuReadProvider getAvnuReadProvider({BigInt? publicKey, String? apiKey}) {
-  final env = Platform.environment;
-  if (env['AVNU_RPC'] == null) {
-    throw Exception('AVNU_RPC environment variable is not set');
-  }
-
   return AvnuJsonRpcReadProvider(
-      nodeUri: Uri.parse(env['AVNU_RPC']!),
+      nodeUri: Uri.parse(getRequiredEnvVar('AVNU_RPC')),
       publicKey: publicKey,
       apiKey: apiKey);
 }
packages/avnu_provider/test/read_provider_test.dart (2)

7-20: Add type checking and handle more edge cases.

The function could be more robust with these improvements:

  1. Check if Map values are actually Map<String, dynamic> before casting
  2. Handle null values in lists
  3. Add null check for the input map itself
 void removeNullFields(Map<String, dynamic> json) {
+  if (json == null) return;
+
   json.removeWhere((key, value) => value == null);
   json.forEach((key, value) {
-    if (value is Map<String, dynamic>) {
+    if (value is Map && value is Map<String, dynamic>) {
       removeNullFields(value);
     } else if (value is List) {
       for (var item in value) {
-        if (item is Map<String, dynamic>) {
+        if (item == null) continue;
+        if (item is Map && item is Map<String, dynamic>) {
           removeNullFields(item);
         }
       }
     }
   });
 }

55-63: Add test for error case.

The test group only covers the success case. Add a test for the error case to ensure proper error handling.

 group('serviceStatus', () {
   test('returns avnu service status', () async {
     final avnuStatus = await avnuReadProvider.avnuStatus();
     avnuStatus.when(
       status: (status) => expect(status, isTrue),
       error: (error) => fail('Should not return an error'),
     );
   });
+  test('handles service unavailable', () async {
+    // Create provider with invalid URI to simulate service unavailability
+    final invalidProvider = getAvnuReadProvider(
+      nodeUri: Uri.parse('https://invalid.url'),
+      publicKey: publicKey,
+      apiKey: apiKey,
+    );
+    final avnuStatus = await invalidProvider.avnuStatus();
+    avnuStatus.when(
+      status: (status) => fail('Should return an error'),
+      error: (error) => expect(error, isNotEmpty),
+    );
+  });
 });
packages/avnu_provider/lib/src/call_rpc_endpoint.dart (2)

6-124: Extract method handlers to improve maintainability.

The switch statement is quite long and handles multiple concerns. Consider extracting each method handler into a separate function while keeping the dynamic parameter types as per previous feedback.

+Future<Uri> handlePaymasterStatus(Uri nodeUri) {
+  return nodeUri.replace(path: '/paymaster/v1/status');
+}
+
+Future<Uri> handlePaymasterGasTokenPrices(Uri nodeUri) {
+  return nodeUri.replace(path: '/paymaster/v1/gas-token-prices');
+}
+
+Future<Uri> handlePaymasterAccountCompatible(Uri nodeUri, List<String> params) {
+  final address = params[0];
+  return nodeUri.replace(path: '/paymaster/v1/accounts/$address/compatible');
+}
+
 Future<dynamic> callRpcEndpoint(
     {required Uri nodeUri, required String method, Object? params}) async {
   Map<String, String> headers = {};
   headers['accept'] = '*/*';
   headers['ask-signature'] = 'true';
   var httpMethod = '';
   var body = {};
   switch (method) {
     case 'paymaster_status':
       httpMethod = 'get';
-      nodeUri = nodeUri.replace(path: '/paymaster/v1/status');
+      nodeUri = await handlePaymasterStatus(nodeUri);
       break;
     // ... extract other cases similarly

131-165: Extract signature verification logic.

The signature verification logic could be extracted into a separate function to improve readability and maintainability.

+Future<void> verifySignature(http.Response response, BigInt publicKey) async {
+  if (response.headers['ask-signature'] != 'true') return;
+
+  final signatureParts = response.headers['signature']!.split(',');
+  final signature = Signature(
+    BigInt.parse(signatureParts[0].substring(2), radix: 16),
+    BigInt.parse(signatureParts[1].substring(2), radix: 16)
+  );
+
+  final messageHash = computeHashOnElements(
+    [starknetKeccak(utf8.encode(response.body)).toBigInt()]
+  );
+
+  if (!starknetVerify(
+    messageHash: messageHash,
+    signature: signature,
+    publicKey: publicKey
+  )) {
+    throw Exception('Invalid signature');
+  }
+}
+
 try {
   final jsonResponse = json.decode(response.body);
   if (jsonResponse == null) {
     throw FormatException('Empty response received from server');
   }
   
   if (AvnuConfig.instance.publicKey != null &&
       response.headers['ask-signature'] == 'true') {
-    // Signature verification logic...
+    await verifySignature(response, AvnuConfig.instance.publicKey!);
   }
   return jsonResponse;
 } on FormatException catch (e) {
   throw FormatException(
       'Failed to parse server response: ${e.message}. Response body: ${response.body}');
 }
packages/avnu_provider/test/integration/provider_test.dart (1)

430-452: Improve test descriptions and add edge cases.

The account rewards test group could benefit from more descriptive test names and additional test cases for edge cases.

 group('setAccountRewards', () {
-  test('set rewards for a user account', () async {
+  test('successfully sets rewards with valid parameters', () async {
     // ... existing test ...
   });
+
+  test('handles invalid campaign name', () async {
+    final address = sepoliaAccount0.accountAddress.toHexString();
+    final invalidCampaign = '';  // Empty campaign name
+    final protocol = 'AVNU';
+    final freeTx = 2;
+    final expirationDate = DateTime.now().add(Duration(hours: 1)).toUtc().toIso8601String();
+    final whitelistedCalls = [{'contractAddress': '*', 'entrypoint': '*'}];
+    
+    expect(
+      () => avnuProvider.setAccountRewards(
+        address, invalidCampaign, protocol, freeTx, expirationDate, whitelistedCalls
+      ),
+      throwsA(isA<Exception>())
+    );
+  });
+
+  test('handles expired date', () async {
+    final address = sepoliaAccount0.accountAddress.toHexString();
+    final campaign = 'Onboarding';
+    final protocol = 'AVNU';
+    final freeTx = 2;
+    final expiredDate = DateTime.now().subtract(Duration(hours: 1)).toUtc().toIso8601String();
+    final whitelistedCalls = [{'contractAddress': '*', 'entrypoint': '*'}];
+    
+    expect(
+      () => avnuProvider.setAccountRewards(
+        address, campaign, protocol, freeTx, expiredDate, whitelistedCalls
+      ),
+      throwsA(isA<Exception>())
+    );
+  });
 });
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a49db4d and eb57138.

📒 Files selected for processing (6)
  • docs/packages/avnu_provider.mdx (1 hunks)
  • packages/avnu_provider/dart_test.yaml (1 hunks)
  • packages/avnu_provider/lib/src/call_rpc_endpoint.dart (1 hunks)
  • packages/avnu_provider/test/integration/provider_test.dart (1 hunks)
  • packages/avnu_provider/test/read_provider_test.dart (1 hunks)
  • packages/avnu_provider/test/utils.dart (1 hunks)
🧰 Additional context used
🪛 GitHub Actions: CI
packages/avnu_provider/lib/src/call_rpc_endpoint.dart

[error] 1-1: The script format:check failed to execute.

docs/packages/avnu_provider.mdx

[error] 1-1: The script format:check failed to execute.

packages/avnu_provider/test/integration/provider_test.dart

[error] 1-1: The script format:check failed to execute.

packages/avnu_provider/test/utils.dart

[error] 1-1: The script format:check failed to execute.

packages/avnu_provider/test/read_provider_test.dart

[error] 1-1: The script format:check failed to execute.

packages/avnu_provider/dart_test.yaml

[error] 1-1: The script format:check failed to execute.

🪛 LanguageTool
docs/packages/avnu_provider.mdx

[grammar] ~14-~14: The plural determiner ‘these’ does not agree with the singular noun ‘provider’.
Context: ...ster service. ## I. Introduction With these provider you (as sponsor) will be able to pay yo...

(THIS_NNS)


[grammar] ~21-~21: There seems to be a noun/verb agreement error. Did you mean “prepares” or “prepared”?
Context: ...getAccountRewards function). 5. User prepare their transaction (using `buildTypedDat...

(SINGULAR_NOUN_VERB_AGREEMENT)


[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~54-~54: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~61-~61: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~72-~72: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~77-~77: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~78-~78: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~88-~88: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. At this moment, th...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~88-~88: For conciseness, consider replacing this expression with an adverb.
Context: ... deploymentData: The deployment data. At this moment, this field is not used and is only pro...

(AT_THE_MOMENT)


[formatting] ~95-~95: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~101-~101: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)


[grammar] ~139-~139: The word ‘approve’ is not a noun. Did you mean “approval”?
Context: ...ed. In the following example, we set an approve transaction to the ERC20 contract. ```...

(PREPOSITION_VERB)


[grammar] ~167-~167: ‘build’ has the past form ‘built’.
Context: ...Now, we set other parameters to get our builded typed data from Avnu API. If we want th...

(EN_IRREGULAR_VERB)

🪛 YAMLlint (1.35.1)
packages/avnu_provider/dart_test.yaml

[error] 3-3: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (3)
docs/packages/avnu_provider.mdx (1)

262-285: LGTM! Clear and comprehensive test instructions.

The test instructions are well-documented with proper environment setup and execution steps.

packages/avnu_provider/test/utils.dart (2)

6-13: LGTM! Good error handling.

The function properly checks for the environment variable and provides a clear error message.


27-37: Consider extracting environment variable check to a helper function.

Same duplication of environment variable check as in getAvnuReadProvider.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (6)
docs/packages/avnu_provider.mdx (4)

14-14: Add missing comma for better readability.

-With this provider you (as sponsor) will be able to pay your users' gas fees
+With this provider, you (as sponsor) will be able to pay your users' gas fees
🧰 Tools
🪛 LanguageTool

[typographical] ~14-~14: It appears that a comma is missing.
Context: ...service. ## I. Introduction With this provider you (as sponsor) will be able to pay yo...

(DURING_THAT_TIME_COMMA)


71-72: Improve clarity with more concise phrasing.

-Prepare and build a typed data to execute a transaction (mandatory step previous to execute a transaction).
+Prepare and build a typed data to execute a transaction (mandatory step before executing a transaction).
🧰 Tools
🪛 LanguageTool

[style] ~71-~71: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


88-88: Use more formal language for future compatibility note.

-The deployment data. At this moment, this field is not used and is only provided for future gasless account deployment compatibility.
+The deployment data. Currently unused, reserved for future gasless account deployment compatibility.

167-167: Fix grammatical error in the text.

-Now, we set other parameters to get our builded typed data from Avnu API.
+Now, we set other parameters to get our built typed data from Avnu API.
packages/avnu_provider/test/integration/provider_test.dart (2)

1-3: Remove or clarify commented imports.

These imports are currently commented out. If they are no longer needed, removing them would declutter the test file. Otherwise, consider adding a clarifying comment about their potential future usage.


45-45: Be mindful of committing test credentials.

A static analysis tool detected a potentially sensitive API key. It's okay if this key is exclusively for testing and does not expose critical resources. Otherwise, consider storing it in an environment variable.

🧰 Tools
🪛 Gitleaks (8.21.2)

45-45: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb57138 and fa88775.

📒 Files selected for processing (4)
  • docs/packages/avnu_provider.mdx (1 hunks)
  • packages/avnu_provider/dart_test.yaml (1 hunks)
  • packages/avnu_provider/test/integration/provider_test.dart (1 hunks)
  • packages/avnu_provider/test/utils.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • packages/avnu_provider/dart_test.yaml
  • packages/avnu_provider/test/utils.dart
🧰 Additional context used
🪛 Gitleaks (8.21.2)
packages/avnu_provider/test/integration/provider_test.dart

45-45: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 LanguageTool
docs/packages/avnu_provider.mdx

[typographical] ~14-~14: It appears that a comma is missing.
Context: ...service. ## I. Introduction With this provider you (as sponsor) will be able to pay yo...

(DURING_THAT_TIME_COMMA)


[uncategorized] ~49-~49: Loose punctuation mark.
Context: ...e account address to check. - campaign: The campaign name. - protocol: The pr...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~50-~50: Loose punctuation mark.
Context: ...mpaign: The campaign name. - protocol: The protocol name. - freeTx`: The numb...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~51-~51: Loose punctuation mark.
Context: ...protocol: The protocol name. - freeTx: The number of free transactions. - exp...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~52-~52: Loose punctuation mark.
Context: ...of free transactions. - expirationDate: The expiration date of the rewards. - `...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~53-~53: Loose punctuation mark.
Context: ...ate of the rewards. - whitelistedCalls: The list of whitelisted contracts adres...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~60-~60: Loose punctuation mark.
Context: ... start date of the activity. - endDate: The end date of the activity (max diff ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~71-~71: ‘previous to’ might be wordy. Consider a shorter alternative.
Context: ...o execute a transaction (mandatory step previous to execute a transaction). Arguments: - `...

(EN_WORDINESS_PREMIUM_PREVIOUS_TO)


[uncategorized] ~75-~75: Loose punctuation mark.
Context: ...s: Your user account address. - calls: The list of calls to execute. - gasTok...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~76-~76: Loose punctuation mark.
Context: ...of calls to execute. - gasTokenAddress: The gas token address. (Optional, this ...

(UNLIKELY_OPENING_PUNCTUATION)


[style] ~77-~77: You have already used this phrasing in nearby sentences. Consider replacing it to add variety to your writing.
Context: ...(Optional, this must be excluded if you want to use your rewards) - accountClassHash:...

(REP_WANT_TO_VB)


[uncategorized] ~85-~85: Loose punctuation mark.
Context: ...Your user account address. - typedData: The typed data. - signature: The type...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~86-~86: Loose punctuation mark.
Context: ...ypedData: The typed data. - signature`: The type data signature (as indicated i...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~87-~87: Loose punctuation mark.
Context: ...ndicated in SNIP-12). - deploymentData: The deployment data. Currently unused, ...

(UNLIKELY_OPENING_PUNCTUATION)


[formatting] ~94-~94: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ... Get the AVNU service status. Arguments: - None. ### 2) getGasTokenPrices(); Get the ...

(DOUBLE_PUNCTUATION_PREMIUM)


[formatting] ~100-~100: These punctuation marks differ from each other. Use only one if you are ending a sentence.
Context: ...et the AVNU gas token prices. Arguments: - None. ## III. Examples You could check more...

(DOUBLE_PUNCTUATION_PREMIUM)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test-integration
🔇 Additional comments (4)
docs/packages/avnu_provider.mdx (2)

1-9: LGTM! Well-structured documentation.

The document is well-organized with a clear index and navigation structure.


261-284: LGTM! Clear and complete test instructions.

The test instructions are well-documented with environment setup and example output.

packages/avnu_provider/test/integration/provider_test.dart (2)

10-23: Implementation of removeNullFields looks good.

This utility function cleanly removes null entries from nested maps. It appears correct and thorough for typical JSON use cases.


292-431: Consider converting the commented-out test into a skipped test or a tracked TODO.

This large block of commented code has been noted before. If you plan to implement account deployment tests in the future, marking it as a skipped test or adding a clear TODO might improve clarity and maintainability.

Copy link
Collaborator

@ptisserand ptisserand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!
It should be good to merge after removing uneeded code.

@rukafe0x
Copy link
Contributor Author

@ptisserand I agree with all your requested changes and found more unused code, so I removed it. Please check again...thanks.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (3)
packages/avnu_provider/test/utils.dart (1)

16-26: Consider reducing code duplication.

The error checking logic is duplicated between getAvnuProvider and getAvnuReadProvider. Consider extracting the common logic into a helper function.

Apply this diff to reduce code duplication:

+String _getAvnuRpc() {
+  final env = Platform.environment;
+  if (env['AVNU_RPC'] == null) {
+    throw Exception('AVNU_RPC environment variable is not set');
+  }
+  return env['AVNU_RPC']!;
+}
+
 AvnuReadProvider getAvnuReadProvider({BigInt? publicKey, String? apiKey}) {
-  final env = Platform.environment;
-  if (env['AVNU_RPC'] == null) {
-    throw Exception('AVNU_RPC environment variable is not set');
-  }
-
   return AvnuJsonRpcReadProvider(
-      nodeUri: Uri.parse(env['AVNU_RPC']!),
+      nodeUri: Uri.parse(_getAvnuRpc()),
       publicKey: publicKey,
       apiKey: apiKey);
 }

 AvnuProvider getAvnuProvider({BigInt? publicKey, String? apiKey}) {
-  final env = Platform.environment;
-  if (env['AVNU_RPC'] == null) {
-    throw Exception('AVNU_RPC environment variable is not set');
-  }
-
   return AvnuJsonRpcProvider(
-      nodeUri: Uri.parse(env['AVNU_RPC']!),
+      nodeUri: Uri.parse(_getAvnuRpc()),
       publicKey: publicKey,
       apiKey: apiKey);
 }
packages/avnu_provider/test/read_provider_test.dart (1)

7-20: Move utility function to a shared location.

The removeNullFields function is duplicated in provider_test.dart. Consider moving it to a shared test utilities file.

Create a new file test/test_utils.dart and move the function there:

// test/test_utils.dart
void removeNullFields(Map<String, dynamic> json) {
  json.removeWhere((key, value) => value == null);
  json.forEach((key, value) {
    if (value is Map<String, dynamic>) {
      removeNullFields(value);
    } else if (value is List) {
      for (var item in value) {
        if (item is Map<String, dynamic>) {
          removeNullFields(item);
        }
      }
    }
  });
}

Then import and use it in both test files:

-void removeNullFields(Map<String, dynamic> json) {
-  // ... implementation ...
-}
+import 'test_utils.dart';
packages/avnu_provider/test/integration/provider_test.dart (1)

23-296: Consider adding error scenario test cases.

The integration tests cover positive scenarios well, but could benefit from additional error scenarios such as:

  • Invalid signatures
  • Expired rewards
  • Invalid contract addresses
  • Network failures

Would you like me to generate test cases for these error scenarios?

🧰 Tools
🪛 Gitleaks (8.21.2)

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fa88775 and bce1943.

📒 Files selected for processing (14)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.freezed.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/avnu_status.g.dart (1 hunks)
  • packages/avnu_provider/lib/src/model/index.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/encode.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/num.dart (1 hunks)
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart (1 hunks)
  • packages/avnu_provider/pubspec.yaml (1 hunks)
  • packages/avnu_provider/test/integration/provider_test.dart (1 hunks)
  • packages/avnu_provider/test/read_provider_test.dart (1 hunks)
  • packages/avnu_provider/test/utils.dart (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (9)
  • packages/avnu_provider/lib/src/model/avnu_status.dart
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.dart
  • packages/avnu_provider/lib/src/typed_data/encode.dart
  • packages/avnu_provider/lib/src/model/index.dart
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.g.dart
  • packages/avnu_provider/lib/src/model/avnu_status.g.dart
  • packages/avnu_provider/lib/src/typed_data/num.dart
  • packages/avnu_provider/lib/src/model/avnu_gas_token_prices.freezed.dart
  • packages/avnu_provider/lib/src/typed_data/typed_data.dart
🧰 Additional context used
🪛 Gitleaks (8.21.2)
packages/avnu_provider/test/integration/provider_test.dart

41-41: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

packages/avnu_provider/test/read_provider_test.dart

40-40: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

🪛 YAMLlint (1.35.1)
packages/avnu_provider/pubspec.yaml

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (6)
packages/avnu_provider/test/utils.dart (1)

4-14: LGTM!

The function correctly checks for the required environment variable and initializes the provider with the necessary parameters.

packages/avnu_provider/test/read_provider_test.dart (1)

22-124: LGTM!

The test cases are well-organized, comprehensive, and cover both positive and negative scenarios. The use of hardcoded test values is acceptable in this context.

🧰 Tools
🪛 Gitleaks (8.21.2)

40-40: Detected a Generic API Key, potentially exposing access to various services and sensitive operations.

(generic-api-key)

packages/avnu_provider/lib/src/model/avnu_status.freezed.dart (1)

1-165: Skip reviewing generated code.

This is an auto-generated file by the Freezed package. No review needed.

packages/avnu_provider/test/integration/provider_test.dart (1)

8-21: Move utility function to a shared location.

The removeNullFields function is duplicated in read_provider_test.dart. Consider moving it to a shared test utilities file.

packages/avnu_provider/pubspec.yaml (2)

1-4: LGTM! Package metadata is well-structured.

The package metadata follows Dart conventions and provides clear information about the package's purpose.


6-7: Verify the SDK version constraint.

The SDK version constraint ^3.5.3 is quite recent. Let's verify if this is the latest stable version and if it aligns with the project's compatibility requirements.

✅ Verification successful

🌐 Web query:

What is the latest stable version of the Dart SDK?

💡 Result:

The latest stable version of the Dart SDK is 3.7.0, as confirmed by the official Dart documentation[4]. This release is intended for production use and follows the standard semantic versioning scheme for stable channel builds (x.y.z format)[2][4].

Key details about recent Dart SDK releases:

  • Version 3.6.x remains widely used with over 11k downloads for v3.6.x releases[1]
  • The current beta channel offers preview builds like 3.8.x-dev versions[1][2]
  • Dev channel provides prereleases updated twice weekly (e.g., 3.8.x-c-000-dev)[2][3]

For most developers, sticking with the stable channel (v3.7.x) is recommended unless needing experimental features from newer beta/dev builds[2][4]. The SDK can be installed/upgraded through package managers or direct downloads from dart.dev[4].

Citations:


SDK version constraint verification

  • The Pubspec currently specifies sdk: ^3.5.3, meaning the project supports Dart versions ≥3.5.3 and <4.0.0.
  • A web query confirmed that the latest stable Dart SDK is 3.7.0.
  • Since the caret constraint automatically accepts any compatible version within the 3.x range, using Dart 3.7.0 (or later 3.x releases) is supported.
  • If you require features from Dart 3.7.0 as a minimum, consider updating the constraint to ^3.7.0; otherwise, the current configuration is acceptable.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bce1943 and e74b071.

📒 Files selected for processing (1)
  • packages/avnu_provider/pubspec.yaml (1 hunks)
🧰 Additional context used
🪛 YAMLlint (1.35.1)
packages/avnu_provider/pubspec.yaml

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)

🔇 Additional comments (4)
packages/avnu_provider/pubspec.yaml (4)

1-4: LGTM! Package metadata is well-defined.

The package metadata follows Dart conventions and clearly indicates its purpose as an AVNU provider package.


9-15: Dependencies are well-defined and up-to-date.

The dependencies are appropriate for an AVNU provider implementation and use recent, stable versions.


17-22: Dev dependencies are well-defined and up-to-date.

The development dependencies include all necessary tools for code generation, linting, and testing.

🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)


22-22: Add a newline at the end of the file.

The file is missing a newline at the end, which is a YAML best practice and will fix the linting error.

   test: ^1.25.15
+
🧰 Tools
🪛 YAMLlint (1.35.1)

[error] 22-22: no new line character at the end of file

(new-line-at-end-of-file)

@ptisserand ptisserand merged commit 124efc7 into focustree:main Feb 13, 2025
7 of 10 checks passed
@ptisserand
Copy link
Collaborator

Close #349

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants