Skip to content

Conversation

@marchuk-vlad
Copy link
Contributor

@marchuk-vlad marchuk-vlad commented Mar 24, 2025

Summary by CodeRabbit

  • New Features

    • Switched token support from Polygon MATIC to opBNB tokens for balance queries and transfers.
    • Introduced enhanced offer versioning, allowing for improved offer creation and management.
    • Updated backend and blockchain endpoints to production-ready URLs.
  • Bug Fixes

    • Corrected naming inconsistencies in offer handling to ensure smoother functionality.
  • Refactor

    • Standardized version and naming parameters across workflows.
    • Upgraded dependency versions and refined error messaging for a more robust user experience.

fixcik and others added 30 commits February 7, 2025 15:08
…-version

chore: update @super-protocol/sp-files-addon to version 0.9.4
* feat(offers): add support for value offer versioning (SP-5780)

* build(deps): use @super-protocol/sdk-js (SP-5780)

* feat(offersGetInfoCommand): remove "version" param from command (SP-5789)

- because we don't have to make filter in graphql query yet (it will be added later)

* fix(addValueOfferVersionService): handle contract error and invalid version param (SP-5780)

* chore(deps): update @super-protocol/sdk-js  to 3.4.0-beta.7 (SP-5780)

---------

Co-authored-by: Dmitry Somov <smv.dmitry@gmail.com>
Merge branch staging into develop
…on-file-upload

chore: improve output path validation for files upload
* feat: move to opBNB tokens and names

* fix: spaUrl and default backend url
Merge branch staging into develop
@marchuk-vlad marchuk-vlad requested a review from Idris0v March 24, 2025 14:40
@marchuk-vlad marchuk-vlad self-assigned this Mar 24, 2025
@coderabbitai
Copy link

coderabbitai bot commented Mar 24, 2025

Walkthrough

This pull request implements extensive updates across configuration, dependency management, command logic, and service functions. Major changes include modifying RPC endpoints and backend URLs, updating package versions and dependencies, and transitioning token handling from MATIC to BNB. The pull request also introduces comprehensive offer versioning support by enforcing stricter type requirements and renaming version-related properties to "offerVersion" across multiple modules. Additionally, GraphQL schema definitions have been enhanced, new helper functions for version management added, and minor typo corrections applied.

Changes

File(s) Change Summary
config.example.json, src/config.ts, src/constants.ts Updated RPC endpoints, backend URLs, and smart contract addresses; introduced constant BACKEND_URL_DEFAULT.
package.json Bumped package version (0.10.11 → 0.10.12) and updated dependency versions for @super-protocol/sdk-js and @super-protocol/sp-files-addon.
src/commands/filesUpload.addon.ts Added a check for existing output path using preparePath and fs.stat to prevent overwrites; removed duplicate declaration.
src/commands/offersCreate.ts, src/commands/offersGetInfo.ts, src/commands/offersUpdateSlot.ts, src/commands/ordersCreate.ts, src/commands/workflowsCreate.ts Introduced offer versioning: added new optional property enabled, destructured and passed version info, and corrected typos (e.g., FethchedOffer to FetchedOffer) with updated property access.
src/commands/secrets/storage/* (command-builders.ts, register/action.ts, register/command.ts, service.ts, status/action.ts, status/command.ts, status/service.ts, update/action.ts) Renamed property from version to offerVersion and updated method signatures; enforced non-optional offerVersion in storage registration and status checks.
src/commands/secrets/utils.ts Renamed key types (e.g., LoaderSecretPublicKeyLoaderSecretAccessPublicKey), updated parameters in order id functions to require offerVersion, and added the findLastOfferVersion function.
src/commands/tokensBalance.ts, src/commands/tokensRequest.ts, src/index.ts Migrated from handling Polygon MATIC tokens to opBNB tokens: updated service names, command options, variable names, and error/analytics messages.
src/gql/index.ts, src/gql/schemas/offers.graphql Enhanced GraphQL schema: added optional versions array to the Offer type, removed redundant fields from offerInfo, added new types for offer versioning, and improved query definitions.
src/services/* (addValueOfferVersion.ts, calcWorkflowDeposit.ts, createValueOffer.ts, createWorkflow.ts, getBnbBalance.ts, offerValueVersionHelper.ts, readValueOfferInfo.ts, readValueOfferSlot.ts, requestBnb.ts, requestCustomBnb.ts, workflowHelpers.ts) Added new functions (addValueOfferVersion, selectLastValueOfferVersion), renamed functions (e.g., getMaticBalancegetBnbBalance), corrected type names (e.g., FethchedOfferFetchedOffer), updated validation schemas, and removed hardcoded parameters (such as gas limits) to better handle offer versioning and token functionalities.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant OfferService
    participant BlockchainConnector
    participant VersionHelper

    Client->>OfferService: createValueOffer(params)
    Note over OfferService: Validate offer info and determine version
    OfferService->>VersionHelper: selectLastValueOfferVersion(versions)
    VersionHelper-->>OfferService: Latest version (if any)
    OfferService->>OfferService: Call addValueOfferVersion (with new version info)
    OfferService->>BlockchainConnector: setNewVersion(offerId, versionInfo)
    alt Offer is not enabled
        OfferService->>BlockchainConnector: enable(offer)
    end
    OfferService-->>Client: Return created offer with version
Loading
sequenceDiagram
    participant CLI
    participant TokenService
    participant BlockchainConnector

    CLI->>TokenService: Initiate tokensCommand (--bnb flag)
    TokenService->>BlockchainConnector: getBnbBalance(address)
    BlockchainConnector-->>TokenService: Return BNB balance
    TokenService-->>CLI: Display BNB token balance and status
Loading

Poem

I'm a hopped-up rabbit in a coding dell,
Skipping through endpoints where new URLs dwell.
Bin the old MATIC, now BNB leads the way,
Offers versioned neatly, as clear as day.
Commands refined and schemas redefined,
With every change, my ears twitch and unwind!
Carrots and code—oh, what a joyous display!

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
  • @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.

@marchuk-vlad marchuk-vlad merged commit 18e931f into main Mar 24, 2025
4 of 5 checks passed
Copy link

@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

🔭 Outside diff range comments (2)
src/index.ts (2)

781-785: ⚠️ Potential issue

Inconsistent analytics event naming

While the conditional check has been updated to options.bnb, the analytics event name is still AnalyticEvent.MATIC_TOKENS_REPLENISHED, which creates an inconsistency between the token being requested and the event being tracked.

Update the analytics event name to reflect the BNB token:

-            eventName: AnalyticEvent.MATIC_TOKENS_REPLENISHED,
+            eventName: AnalyticEvent.BNB_TOKENS_REPLENISHED,

Verify that this constant is defined in the analytics service.


795-802: ⚠️ Potential issue

Inconsistent analytics error event naming

Similarly to the success event, the error tracking event name needs to be updated to reflect the transition from MATIC to BNB tokens.

Update the analytics error event name:

-              eventName: AnalyticEvent.MATIC_TOKENS_REPLENISHED,
+              eventName: AnalyticEvent.BNB_TOKENS_REPLENISHED,
🧹 Nitpick comments (6)
src/services/offerValueVersionHelper.ts (1)

3-17: Improve the return type clarity and edge case handling.

The function correctly selects the last offer version with "New" status, but I see a few areas for improvement:

  1. The conditional return could be more explicit about returning undefined for empty arrays or when no "New" status versions are found.
  2. The function lacks a return type annotation, which would improve code readability.
export const selectLastValueOfferVersion = (
  versions?: OfferVersion[],
-): OfferVersion | undefined => {
+): OfferVersion | undefined => {
+  if (!versions?.length) {
+    return undefined;
+  }
+
  const version = versions
    ?.filter((v) => v.status === OfferVersionStatus.New)
    .reduce((max, current) => (current.version > max.version ? current : max), {
      version: Number.MIN_SAFE_INTEGER,
      info: {},
      status: OfferVersionStatus.New,
    });

  if (version?.version !== Number.MIN_SAFE_INTEGER) {
    return version;
  }
+  return undefined;
};
src/services/getBnbBalance.ts (2)

8-8: Renamed function from getMaticBalance to getBnbBalance.

The function has been renamed to reflect the token change from MATIC to BNB. However, the function is missing a return type annotation.

-const getBnbBalance = async (params: GetMumbaiBalanceParams) => {
+const getBnbBalance = async (params: GetMumbaiBalanceParams): Promise<BigNumber> => {
🧰 Tools
🪛 ESLint

[error] 8-8: Missing return type on function.

(@typescript-eslint/explicit-function-return-type)


4-6: Consider updating parameter type name for consistency.

The function has been renamed from getMaticBalance to getBnbBalance, but the parameter type GetMumbaiBalanceParams still references Mumbai (Polygon testnet). For consistency, you might want to rename this type as well.

-export type GetMumbaiBalanceParams = {
+export type GetBnbBalanceParams = {
  address: string;
};
src/services/createValueOffer.ts (1)

65-70: Consider dynamic version assignment.

Hardcoding the version to 1 might be restrictive if version 1 already exists. Consider fetching the latest version and incrementing it automatically.

src/services/workflowHelpers.ts (1)

104-110: Populating version with selectLastValueOfferVersion.

Casting the fetched list to FetchedOffer[] is convenient but consider validating item shapes or handling potential mismatches. Overall logic is sound for returning version data.

src/gql/index.ts (1)

8653-8693: Consider using a GraphQL enum for status.

Here, status is set as a string but the JSDoc suggests discrete values ("0", "1"). A GraphQL enum would enforce stricter typing and clarity. Also, confirm whether version should be an integer instead of float.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between e5b450d and 1a63377.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (35)
  • config.example.json (1 hunks)
  • package.json (2 hunks)
  • src/commands/filesUpload.addon.ts (1 hunks)
  • src/commands/offersCreate.ts (3 hunks)
  • src/commands/offersGetInfo.ts (2 hunks)
  • src/commands/offersUpdateSlot.ts (1 hunks)
  • src/commands/ordersCreate.ts (5 hunks)
  • src/commands/secrets/storage/command-builders.ts (3 hunks)
  • src/commands/secrets/storage/register/action.ts (4 hunks)
  • src/commands/secrets/storage/register/command.ts (1 hunks)
  • src/commands/secrets/storage/service.ts (5 hunks)
  • src/commands/secrets/storage/status/action.ts (2 hunks)
  • src/commands/secrets/storage/status/command.ts (1 hunks)
  • src/commands/secrets/storage/status/service.ts (1 hunks)
  • src/commands/secrets/storage/update/action.ts (3 hunks)
  • src/commands/secrets/utils.ts (6 hunks)
  • src/commands/tokensBalance.ts (2 hunks)
  • src/commands/tokensRequest.ts (2 hunks)
  • src/commands/workflowsCreate.ts (3 hunks)
  • src/config.ts (2 hunks)
  • src/constants.ts (1 hunks)
  • src/gql/index.ts (11 hunks)
  • src/gql/schemas/offers.graphql (1 hunks)
  • src/index.ts (4 hunks)
  • src/services/addValueOfferVersion.ts (1 hunks)
  • src/services/calcWorkflowDeposit.ts (2 hunks)
  • src/services/createValueOffer.ts (3 hunks)
  • src/services/createWorkflow.ts (0 hunks)
  • src/services/getBnbBalance.ts (1 hunks)
  • src/services/offerValueVersionHelper.ts (1 hunks)
  • src/services/readValueOfferInfo.ts (2 hunks)
  • src/services/readValueOfferSlot.ts (1 hunks)
  • src/services/requestBnb.ts (1 hunks)
  • src/services/requestCustomBnb.ts (1 hunks)
  • src/services/workflowHelpers.ts (4 hunks)
💤 Files with no reviewable changes (1)
  • src/services/createWorkflow.ts
🧰 Additional context used
🧬 Code Definitions (16)
src/commands/offersCreate.ts (4)
src/services/readValueOfferInfo.ts (1)
  • readValueOfferInfo (66-100)
src/services/createValueOffer.ts (1)
  • params (25-81)
src/services/createTeeOffer.ts (1)
  • params (15-58)
src/services/addValueOfferVersion.ts (1)
  • params (18-52)
src/commands/tokensBalance.ts (1)
src/utils.ts (1)
  • weiToEther (130-138)
src/commands/secrets/storage/status/action.ts (1)
src/commands/secrets/utils.ts (1)
  • findLastOfferVersion (91-101)
src/config.ts (1)
src/constants.ts (1)
  • BACKEND_URL_DEFAULT (10-10)
src/services/offerValueVersionHelper.ts (1)
src/gql/index.ts (1)
  • OfferVersion (8653-8666)
src/commands/secrets/storage/command-builders.ts (1)
src/commands/secrets/constants.ts (4)
  • SPCTL_COMMAND (1-1)
  • SECRETS_COMMAND (2-2)
  • STORAGE_COMMAND (3-3)
  • STATUS_COMMAND (6-6)
src/commands/filesUpload.addon.ts (1)
src/commands/filesUpload.ts (1)
  • params (21-182)
src/commands/workflowsCreate.ts (1)
src/services/workflowHelpers.ts (1)
  • FetchedOffer (21-26)
src/services/calcWorkflowDeposit.ts (1)
src/services/workflowHelpers.ts (1)
  • FetchedOffer (21-26)
src/commands/secrets/storage/update/action.ts (3)
src/commands/secrets/utils.ts (1)
  • findLastOfferVersion (91-101)
src/commands/secrets/storage/status/command.ts (1)
  • statusCommand (5-9)
src/commands/secrets/storage/command-builders.ts (1)
  • buildStatusCommand (54-69)
src/services/addValueOfferVersion.ts (3)
src/gql/index.ts (3)
  • OfferVersionInfo (8668-8673)
  • Offer (8407-8424)
  • OfferVersion (8653-8666)
src/services/createValueOffer.ts (1)
  • params (25-81)
src/commands/offersCreate.ts (1)
  • params (30-107)
src/commands/offersGetInfo.ts (2)
src/gql/index.ts (3)
  • OfferInfo (8491-8526)
  • OfferVersion (8653-8666)
  • TeeOfferInfo (9773-9782)
src/services/offerValueVersionHelper.ts (1)
  • selectLastValueOfferVersion (3-17)
src/commands/secrets/storage/register/action.ts (3)
src/commands/secrets/storage/service.ts (1)
  • RegisterStorageParams (21-28)
src/commands/secrets/utils.ts (1)
  • findLastOfferVersion (91-101)
src/commands/secrets/storage/command-builders.ts (1)
  • buildStatusCommand (54-69)
src/services/createValueOffer.ts (2)
src/gql/index.ts (3)
  • OfferInfo (8491-8526)
  • OfferVersionInfo (8668-8673)
  • Offer (8407-8424)
src/services/addValueOfferVersion.ts (1)
  • params (18-52)
src/commands/ordersCreate.ts (1)
src/services/workflowHelpers.ts (2)
  • FetchedOffer (21-26)
  • getFetchedOffers (96-112)
src/services/workflowHelpers.ts (2)
src/gql/index.ts (1)
  • OfferVersion (8653-8666)
src/services/offerValueVersionHelper.ts (1)
  • selectLastValueOfferVersion (3-17)
🪛 ESLint
src/services/getBnbBalance.ts

[error] 8-8: Missing return type on function.

(@typescript-eslint/explicit-function-return-type)

🔇 Additional comments (100)
config.example.json (1)

7-7: Updated blockchain RPC URL from Polygon to opBNB

The configuration has been updated to use opBNB network instead of Polygon. This change is part of the transition from MATIC to BNB tokens mentioned in the PR summary.

Please verify that the smart contract address (line 8) is still valid for the opBNB network, as it remained unchanged during this transition.

src/services/readValueOfferSlot.ts (1)

15-15: Added metadata support to ValueOfferSlotFileValidator

The addition of the metadata field with a default empty string value provides backward compatibility while enabling the new offer versioning functionality mentioned in the PR summary.

src/services/requestCustomBnb.ts (1)

25-25: Updated error message to reflect BNB token usage

The error message has been changed from 'MATIC tokens request error' to 'BNB tokens request error', aligning with the broader transition from MATIC to BNB tokens across the codebase.

src/services/requestBnb.ts (1)

25-25: Updated error message to reflect BNB token usage

The error message has been changed from 'MATIC tokens request error' to 'BNB tokens request error', aligning with the broader transition from MATIC to BNB tokens across the codebase.

src/commands/secrets/storage/register/command.ts (1)

8-8: Command option renamed for clarity

The option --version <number> has been renamed to --offer-version <number> to clearly indicate that this version relates to the solution offer. This change improves clarity and is consistent with the standardization of naming conventions for versioning across the codebase.

src/commands/secrets/storage/status/command.ts (1)

8-8: Command option renamed for consistency

The option --version <number> has been renamed to --offer-version <number> to maintain consistency with other commands in the codebase. This is part of the broader effort to standardize versioning terminology across the application.

src/commands/tokensBalance.ts (2)

2-2: Service import updated from MATIC to BNB

The import has been updated from getMaticBalanceService to getBnbBalanceService as part of the transition from MATIC to BNB tokens throughout the application.


29-31: Token reference updated from MATIC/POL to BNB

The code has been updated to fetch and display BNB token balances instead of MATIC/POL tokens. Variable names and output messages have been modified accordingly to reference BNB.

src/commands/offersUpdateSlot.ts (1)

47-47:

Details

❓ Verification inconclusive

Added metadata parameter to updateSlot method

The metadata parameter has been added to the updateSlot method call for value offers, extending the functionality to include metadata in the update process. This enhancement aligns with the broader improvements in offer versioning support.

Ensure that the Offer.updateSlot method signature in the SDK has been updated to accept this additional parameter, and that valueOfferSlot.metadata is properly initialized in the readValueOfferSlot function.


🏁 Script executed:

#!/bin/bash
# Check if the updateSlot method in the SDK expects this new parameter
rg -A 2 "updateSlot.*metadata" --type typescript

Length of output: 85


Below is a revised review comment. I’ve also generated a new shell script using the correct file type (using --type ts instead of --type typescript) to verify that the SDK’s Offer.updateSlot method signature includes the new metadata parameter. Please run this script and check its output to confirm that the SDK has been updated accordingly.


Verify SDK Update for Metadata Parameter

The commit now includes the metadata parameter in the updateSlot call for value offers, which extends support for offer versioning improvements. Please verify the following:

  • The SDK’s Offer.updateSlot signature accepts the new metadata parameter.
  • The valueOfferSlot.metadata is properly initialized in the readValueOfferSlot function.

Below is the updated shell script for verification:

If the script output confirms the updated method signature, you can consider this change approved. If not, please investigate further.


🏁 Script executed:

#!/bin/bash
# Re-run the verification for the SDK's updateSlot method using the recognized file type for TypeScript files.
rg -A 2 "updateSlot.*metadata" --type ts

Length of output: 164


Verify SDK Update for Metadata Parameter

The commit now includes the metadata parameter in the updateSlot call for value offers, extending support for enhanced offer versioning. However, our automated search using the correct file type yielded no output. Please manually verify that:

  • The Offer.updateSlot method signature in the SDK has been updated to accept the metadata parameter.
  • The valueOfferSlot.metadata is properly initialized in the readValueOfferSlot function.
src/services/calcWorkflowDeposit.ts (2)

10-10: Typo correction - fixing imported type name.

The import has been corrected from FethchedOffer to FetchedOffer, fixing a typo in the type name.


21-21: Typo correction - fixing type reference.

The type reference has been corrected from FethchedOffer to FetchedOffer, maintaining consistency with the type defined in the workflowHelpers.ts file.

src/commands/secrets/storage/status/service.ts (1)

15-15: Made offerVersion a required parameter.

The offerVersion parameter is now required rather than optional, which strengthens the type safety and aligns with how it's being used in the function implementation. This change is consistent with the broader pattern in the codebase to standardize version handling.

src/services/getBnbBalance.ts (1)

13-13: Updated export to use the new function name.

The export statement correctly reflects the renamed function.

src/commands/offersCreate.ts (3)

27-27: Good addition of optional enabled flag.

Adding this optional property enhances flexibility by allowing clients to create offers in a disabled state if needed.


60-60: Improved destructuring of version information.

Extracting the version data from the offer info properly separates concerns and allows for better version management.


97-98: Enhanced offer creation with version info and enablement control.

The changes correctly pass version information to the offer creation process and provide a sensible default for the enabled flag (true if not specified).

src/config.ts (2)

5-5: Added import for backend URL constant.

The import of BACKEND_URL_DEFAULT from the constants file is necessary for the new mainnet URL handling.


197-200: Added specific handling for mainnet URLs.

The changes improve URL resolution by adding explicit handling for the mainnet environment, returning the appropriate SPA URL when the backend URL matches the default (mainnet) URL.

src/commands/secrets/storage/status/action.ts (3)

5-5: Added import for version utility function.

This import supports the enhancement to find the last offer version when none is explicitly provided.


8-8: Standardized naming convention for offer version.

Renaming from version to offerVersion improves consistency with the rest of the codebase and makes the API more intuitive.


28-30: Enhanced version handling with fallback mechanism.

This improvement adds automatic retrieval of the latest offer version when none is specified, making the API more user-friendly while maintaining backward compatibility.

src/commands/filesUpload.addon.ts (1)

179-188: Added safeguard against overwriting existing files.

This change adds an important validation check to prevent accidentally overwriting existing files. The error handling properly distinguishes between the expected "file not found" case and other potential errors.

package.json (2)

3-3: Package version bump looks good.

The version has been updated from 0.10.11 to 0.10.12, which aligns with the PR title "Release 0.10.12".


39-40:

Details

✅ Verification successful

Dependency updates are appropriate.

The SDK dependency is updated to a newer beta version with more flexible versioning (^3.5.0-beta.2), and the files addon is updated to a newer patch version (^0.9.6). These changes support the new offer versioning functionality introduced in this PR.


🏁 Script executed:

#!/bin/bash
# Verify that the updated SDK dependencies are compatible with the current code

# Check imports from @super-protocol/sdk-js
echo "Checking for imports of new SDK classes (particularly versioning related):"
rg -A 1 "import.*@super-protocol/sdk-js" --glob "*.ts"

# Check for usages of any version-related functionality
echo "Checking for usages of versioning functionality:"
rg "offerVersion|OfferVersion" --glob "*.ts"

Length of output: 22329


SDK Dependency and Files Addon Updates Verified

The dependency updates in package.json (lines 39-40) have been confirmed as appropriate. The updated SDK dependency (@super-protocol/sdk-js at ^3.5.0-beta.2) and the files addon (@super-protocol/sp-files-addon at ^0.9.6) are correctly integrated across the codebase. The verification script confirms that versioning functionality (e.g., usage of offerVersion) is present and properly utilized in numerous modules. No additional changes are required.

src/gql/schemas/offers.graphql (1)

73-81: New versions field properly structures the offer versioning support.

The addition of the versions field to the query provides a well-structured way to handle multiple offer versions, each with its own metadata, hash, and signature information. This change supports the architectural shift mentioned in the PR description regarding offer versioning.

The nested structure with version, status, and info fields provides a clear organization of version-specific data that was previously at the offer level.

src/commands/workflowsCreate.ts (2)

43-43: Fixed type name typo.

The type name has been corrected from FethchedOffer to FetchedOffer, enhancing code consistency.


484-485:

Details

✅ Verification successful

Updated property access paths to match new versioning structure.

The property paths have been updated to access version-specific fields through the new version property, which aligns with the architectural changes for offer versioning.


🏁 Script executed:

#!/bin/bash
# Verify that null/undefined handling is appropriate for these optional fields

# Check if there are any null checks for version before accessing its properties
echo "Checking for null checks on version property:"
rg "version\s*(\?\.|&&|\?)" src/commands/

# Check how optional chaining is used with version properties
echo "Checking usage of optional chaining with version properties:"
rg "version\?\.info" src/

Length of output: 1040


Final Approval: Updated Property Access Paths Verified

The updated property access paths in src/commands/workflowsCreate.ts correctly use optional chaining to safely access new version-specific fields. The shell script output confirms that both offer.version?.info.hash?.hash and similar patterns (e.g., offer.version?.info.signatureKeyHash?.hash) are properly guarded via optional chaining. This aligns with the architectural changes for offer versioning and ensures appropriate null/undefined handling.

  • Verified Location: src/commands/workflowsCreate.ts (Lines 484-485)
  • Consistency Check: Similar usage in src/commands/offersGetInfo.ts confirms uniform handling across related files.

No further modifications are necessary.

src/commands/secrets/storage/command-builders.ts (4)

22-22: Updated version parameter name for clarity.

The property name has been changed from version to offerVersion in the register command, which improves clarity by explicitly tying it to the offer context.


43-43: Updated version parameter name for consistency.

The property name has been updated from version to offerVersion in the update command, maintaining consistent naming across the codebase.


56-56: Made offerVersion parameter required and renamed for clarity.

The type definition has been updated to make offerVersion a required property (instead of an optional version), which enforces proper usage of the status command.


64-64:

Details

❓ Verification inconclusive

Updated command-line flag for consistency.

The command-line flag has been changed from --version to --offer-version, which aligns with the naming convention used throughout the codebase and clarifies its purpose.


🏁 Script executed:

#!/bin/bash
# Verify that the command-line flag change is consistent across the codebase

# Check for any remaining --version flags in commands related to offers
echo "Checking for any remaining --version flags that should be updated:"
rg " --version " --glob "*.ts" src/commands/

# Check for usage of --offer-version flag to ensure consistency
echo "Checking usage of --offer-version flag:"
rg " --offer-version " --glob "*.ts" src/commands/

Length of output: 331


Consistency Check for Updated Command-line Flag

  • The flag has been updated from --version to --offer-version to align with the naming convention.
  • A search for residual --version occurrences in the commands did not return any results.
  • The change appears consistent; however, the absence of output from the search warrants manual verification to ensure the update is fully propagated.
src/commands/secrets/storage/update/action.ts (3)

7-7: Improved modularity through utility function import

The addition of the findLastOfferVersion utility function enhances the code's modularity by centralizing version retrieval logic, which can be reused across multiple commands.


37-39: Good enhancement to version handling

The implementation of conditional version assignment is a positive improvement that:

  1. Uses the explicitly provided version when available
  2. Falls back to retrieving the latest version automatically when not specified

This makes the function more flexible and user-friendly.


67-70: Improved parameter passing specificity

This change improves the code by explicitly passing only the required parameters (offerVersion and config) to the buildStatusCommand function instead of passing the entire options object. This makes the dependencies clearer and aligns with the updated signature of buildStatusCommand shown in the relevant code snippets.

src/commands/tokensRequest.ts (4)

3-5: Transitioning from MATIC to BNB token services

The imports have been updated to reflect the transition from MATIC to BNB token handling services, which is consistent with the changes throughout the file. This suggests a platform migration from Polygon to BNB Chain.


13-13: Updated token request parameter type

The TokensRequestParams type has been updated to replace requestMatic with requestBnb, reflecting the transition to BNB tokens in the system.


19-22: Updated token type checking and user guidance

The conditional check and help message have been modified to reflect the new token type (BNB instead of MATIC), maintaining consistent user guidance throughout the interface.


44-52: Token service integration updated for BNB

The token request implementation has been updated to work with BNB instead of MATIC tokens, including:

  1. Updated console messaging to inform users about opBNB tokens
  2. Service calls changed to use BNB-specific services
  3. Success confirmation messages updated for consistency

This completes the token handling transition in this module.

src/index.ts (2)

752-752: Updated token request CLI option

The CLI option has been updated from --matic to --bnb with an appropriate description change to reflect the platform transition from Polygon to opBNB.


769-769: Updated token request parameter name

The parameter name in the request object has been changed from requestMatic to requestBnb to maintain consistency with the type definition changes in src/commands/tokensRequest.ts.

src/commands/ordersCreate.ts (5)

21-21: Fixed type name typo

The type name has been corrected from FethchedOffer to FetchedOffer, improving code consistency and preventing potential confusion.


71-72: Updated return type and variable declaration

The function's return type and variable declaration have been updated to use the corrected type name FetchedOffer, ensuring type consistency.


83-83: Consistent type usage for offer variable

Variable type annotation updated to use the corrected FetchedOffer type, maintaining consistency throughout the file.


101-101: Updated Map type parameter

The Map type parameter in the checkFetchedOffers function call has been updated to use the corrected FetchedOffer type, ensuring proper type checking.


244-244: Consistent type usage in function call

The variable type annotation in the function call has been updated to use the corrected FetchedOffer type, completing the typo correction throughout the file.

src/constants.ts (1)

10-12:

Details

✅ Verification successful

Significant URL and address changes detected

The changes involve migrating from test environment to production, moving from Polygon testnet to BNB Chain:

  1. Backend URL changed from testnet to production
  2. Blockchain RPC URL changed from Polygon Amoy testnet to opBNB
  3. Smart contract address updated to match the new blockchain

This represents a major environment shift. Ensure all dependent systems are aware of these changes and update their configurations accordingly.


🏁 Script executed:

#!/bin/bash
# Check if these constants are referenced elsewhere in the codebase
echo "Checking for references to these constants:"
rg -A 2 -B 2 "BACKEND_URL_DEFAULT|BLOCKCHAIN_RPC_URL_DEFAULT|SMART_CONTRACT_ADDRESS_DEFAULT" --type ts

echo "Checking if config.example.json has been updated with the new URLs:"
find . -name "config.example.json" -type f -exec cat {} \; | grep -E "opbnb.superprotocol.com|0x3C69ea105Fc716C1Dcb41859281Aa817D0A0B279"

Length of output: 3055


Environment Transition Update Verified

The updated defaults in src/constants.ts have been correctly changed to point to the production backend and blockchain configuration (BNB Chain via opBNB). Our verification confirms that:

  • References in src/config.ts and src/commands/setup.ts are correctly using the updated constants.
  • The config.example.json file has been updated to include the new URLs and smart contract address.

Please ensure that any external systems or environments relying on these settings are notified accordingly.

src/commands/offersGetInfo.ts (4)

1-7: Added support for offer versioning

New imports enhance the offers module with versioning capabilities, enabling better version management.


18-18: Type enhancement for offer variable

The type definition has been improved to accommodate versioning by allowing an optional version property on OfferInfo objects.


20-28: Code style improvement with braces

Added braces to the 'tee' case for consistent code style and to prevent potential bugs if more code is added in the future.


29-49: New utility function to handle offer versions

The added convert function enhances the code by:

  1. Extracting version information from offer data
  2. Selecting the latest version with appropriate status
  3. Combining this with offer info to create a comprehensive response

This implementation correctly handles undefined offers and intelligently merges version data when available.

src/services/addValueOfferVersion.ts (4)

1-16: Well-structured type definition and imports

The imports and type definition for AddOfferVersionParams are clearly organized, with appropriate types from the SDK and necessary parameters for the function.


18-24: Proper validation of input parameters

The function correctly initializes the blockchain connector and validates the version number, ensuring it's non-negative. This prevents invalid version numbers from being processed.


28-43: Improved error handling for version collisions

The implementation properly:

  1. Retrieves the current version count
  2. Handles the case where a specific version is requested
  3. Catches NotFoundError appropriately when checking if a version exists
  4. Throws a clear error message when trying to create a version that already exists

This prevents duplicate versions and provides clear feedback to users.


44-52: Clean version assignment and operation

The function:

  1. Assigns a version number based on user input or auto-increments
  2. Sets the new version with proper parameters
  3. Provides informative output to the user
  4. Returns the new version number for use by calling functions

This implementation is concise and functional.

src/commands/secrets/storage/register/action.ts (6)

7-7: Added utility import for version management

The import of findLastOfferVersion enhances the module's capability to retrieve the latest version when a specific version isn't provided.


10-10: Property renamed from 'version' to 'offerVersion'

This change improves naming consistency across the codebase by aligning with other occurrences of "offerVersion".


40-40: Updated parameter name for consistency

The parameter passed to checkParamsToRegisterStorage now uses offerVersion for better clarity and consistency.


47-49: Enhanced version handling with fallback mechanism

The code now intelligently:

  1. Uses the explicitly provided version when available
  2. Automatically retrieves the latest version as fallback
  3. Ensures that a valid version is always assigned

This makes the API more robust and user-friendly while maintaining version consistency.


77-80: Updated status command building with version information

The status command builder now receives the correct version parameter, ensuring that status commands generated will reference the correct offer version.


94-94: Strengthened type safety for findStorageOrderId function

The parameter type has been enhanced from Pick<OfferStorageRequest, 'offerId' | 'offerVersion'> to Pick<Required<OfferStorageRequest>, 'offerId' | 'offerVersion'>, ensuring that both properties are required and preventing potential null/undefined errors.

src/services/createValueOffer.ts (5)

1-8: Imports look consistent and necessary.

No concerns about these imported modules. They align well with the usage in this module.


13-13: New import for addValueOfferVersion.

This inclusion appears appropriate. Ensure error handling for addValueOfferVersion exceptions is handled upstream or in the caller if needed.


45-49: Refined arguments for Offers.create.

Calling Offers.create with clearer named parameters is more expressive and maintains readability. Looks good.


72-78: Conditional enabling of the offer.

This logic is straightforward and ensures that the offer is only enabled when required. The approach is sound.


22-22:

Details

❓ Verification inconclusive

Check usage of the new enabled property.

You added a new property enabled. Confirm that every caller of createValueOffer sets this correctly or has a default, to avoid unexpected behavior.


🏁 Script executed:

#!/bin/bash
rg -A 3 'createValueOffer\('

Length of output: 336


Let's see if the function signature or body sets a default value for the new enabled property.


🏁 Script executed:

#!/bin/bash
rg -A 10 "function createValueOffer" src/services/createValueOffer.ts

Length of output: 71


Action: Verify “enabled” Property Handling in createValueOffer

It appears that the only observed call (in src/commands/offersCreate.ts) does not pass an explicit value for the new enabled property. Please ensure one of the following:

  • The implementation in src/services/createValueOffer.ts provides a default value for enabled when it’s not supplied.
  • Alternatively, update all call sites (currently, src/commands/offersCreate.ts) to explicitly set enabled as required.

This verification is necessary to avoid any unintended behavior due to an undefined or unexpected value for enabled.

src/commands/secrets/storage/service.ts (5)

32-32: Optional parameter in internal check function.

offerVersion remains optional here for fallback logic, which can be acceptable. Ensure this partial signature does not cause confusion when offerVersion is mandatory at higher levels.


41-52: Robust validation for offer versions.

Good checks for undefined, non-existent, or invalid version numbers. This prevents registering storage against invalid or non-existing versions.


72-72: Passing offerVersion to setOfferStorageRequest.

This ensures consistency with the newly enforced version usage. No issues found.


137-137: Replication factor properly set.

Assigning replicationFactor here is correct. Just confirm that the upstream logic ensures valid replicationFactor values.


23-23:

Details

✅ Verification successful

Confirm backward compatibility for mandatory offerVersion.

Previously, offerVersion might have been optional. Now it is mandatory in RegisterStorageParams. Verify that no existing calls are missing this property.


🏁 Script executed:

#!/bin/bash
rg -A 3 'RegisterStorageParams'

Length of output: 2264


Backward Compatibility Confirmed: Mandatory offerVersion is consistently provided

The grep output confirms that all instances creating a RegisterStorageParams object include the offerVersion property. In both the registration and update actions (as seen in src/commands/secrets/storage/register/action.ts and src/commands/secrets/storage/update/action.ts), the property is explicitly provided. There are no calls missing this field.

src/services/workflowHelpers.ts (6)

2-2: Expanded imports with OfferVersion.

The additional import for OfferVersion is appropriate, matching the usage in this code.


16-16: Importing selectLastValueOfferVersion.

This is coherent with the approach of attaching the latest version data to offers.


21-25: Type FetchedOffer gains version property.

Adding version?: OfferVersion; provides a structured way to store offer version details. This maintains flexibility if some offers lack version info.


29-29: Map<string, FetchedOffer> type usage.

Changing the collection type to store FetchedOffer objects improves clarity.


70-70: Ensuring correct type for offers parameter.

Using Map<string, FetchedOffer> is consistent, confirming that each entry is the new typed structure.


101-101: Function returns array of FetchedOffer.

Refactoring the return type to Promise<FetchedOffer[]> matches the updated internal representation.

src/services/readValueOfferInfo.ts (8)

2-7: Updated imports to include OfferVersion type

The import statement now includes OfferVersion from the SDK, which will be used for the newly introduced versioning support in this file.


18-22: Schema naming standardization

The validator has been appropriately renamed from OfferInfoRestrictionsValidator to OfferInfoRestrictionsSchema to maintain consistency with other schema definitions in the file.


24-32: New version schema definition

The newly introduced schema definitions properly structure offer versioning information, with appropriate fields for metadata, hashes, and version numbers.


33-48: Updated OfferInfoSchema with version support

The OfferInfoSchema has been extended to include version information while making the version number optional, which allows backward compatibility with existing offer information.


50-55: Validator restructuring

The validators have been restructured to accommodate the new versioning system. The optional validator now properly omits the version field and extends with a partial restrictions schema.


57-58: Type definitions for versioned offer info

New type definitions have been added to properly represent offer information with versioning support.


60-69: Updated function signatures with new return types

The function signatures have been updated to return the new types, providing better type safety and representing the new structure of the offer information.


72-72: Updated validator usage

The validator used in the readJsonFile call has been updated to use the new schema definitions, maintaining consistency with the type changes.

src/commands/secrets/utils.ts (6)

8-13: Updated imports for more specific access control

The imports have been updated to use more specific types (LoaderSecretAccessPublicKey and LoaderSecretsAccessPublicKeys) and added the Offer class which is needed for the new findLastOfferVersion function.


22-22: Updated type for secret parameter

The type for the secret parameter has been updated to use the more specific LoaderSecretAccessPublicKey type.


49-49: Updated method call for accessing secrets

The method call has been updated to use LoaderSecretsAccessPublicKeys.get() instead of the previous implementation, aligning with the type changes introduced.


80-80:

Details

✅ Verification successful

Updated function parameter type to enforce required fields

Similar to the previous function, the parameter type for findRequestOrderId now uses Required<OfferStorageRequest> to enforce that both offerId and offerVersion must be provided.

Check that all calls to this function provide both parameters.


🏁 Script executed:

#!/bin/bash
# Search for calls to findRequestOrderId to ensure both parameters are provided
rg "findRequestOrderId\(" -A 5 -B 5

Length of output: 536


Parameter enforcement verified: All calls supply required fields.

The update to the function parameter type in src/commands/secrets/utils.ts now mandates that both offerId and offerVersion are provided. Our search results confirm that the sole call to findRequestOrderId in src/commands/secrets/storage/register/action.ts passes the params variable—which is expected to contain both fields based on its enforced type. No additional calls were found that could potentially violate the new requirement.


61-61:

Details

✅ Verification successful

Updated function parameter type to enforce required fields

The parameter type for findAllocatedOrderId now uses Required<OfferStorageRequest> to enforce that both offerId and offerVersion must be provided.

This change might break existing code if these properties were previously treated as optional. Verify that all calls to this function provide both parameters.


🏁 Script executed:

#!/bin/bash
# Search for calls to findAllocatedOrderId to ensure both parameters are provided
rg "findAllocatedOrderId\(" -A 5 -B 5

Length of output: 1857


Verified: All call sites pass the required parameters

The updated parameter type now enforces that both offerId and offerVersion are present. A search across the codebase confirmed that all calls—specifically in:

  • src/commands/secrets/storage/update/action.ts
  • src/commands/secrets/storage/register/action.ts

…pass a params object that already includes both required fields.

No breaking changes appear to be introduced by this update.


91-101:

Details

✅ Verification successful

Added function to find the last offer version

A new utility function findLastOfferVersion has been added to retrieve the last version number for a given offer ID. The function properly handles the case when no version is found by throwing an appropriate error.

Run the following script to see where this new function is being used in the codebase:


🏁 Script executed:

#!/bin/bash
# Search for usages of the new findLastOfferVersion function
rg "findLastOfferVersion\(" -A 3

Length of output: 1068


Function Integration Confirmed: The new utility is correctly implemented and utilized.

The addition of the findLastOfferVersion function in src/commands/secrets/utils.ts (lines 91-101) is verified and working as expected. This function retrieves the last version number for an offer and appropriately throws an error when no version is found. Furthermore, the results from the usage search confirm that this function is consistently invoked in:

  • src/commands/secrets/storage/update/action.ts
  • src/commands/secrets/storage/register/action.ts
  • src/commands/secrets/storage/status/action.ts

No further changes are needed.

src/gql/index.ts (10)

8423-8423: Add tests for new optional field.

This new versions?: Maybe<Array<OfferVersion>> field allows for multiple offer versions. Consider adding tests to ensure this field is being populated and handled correctly in queries and mutations.


8483-8484: Document the new search field usage.

The search?: InputMaybe<Scalars['String']> filter is a great addition. Ensure it is documented and tested so that both backend and frontend teams understand how to filter by ID or name.


8573-8573: Keep consistency between Offer and OfferInput.

Adding versions?: InputMaybe<Array<OfferVersionInput>> maintains consistency with the Offer type. This looks good; be sure any downstream logic for handling versions is well-tested.


9191-9192: _id naming consistency.

The property _id?: InputMaybe<Scalars['String']> is common in MongoDB-based schemas. This is fine, but confirm that other filters also use _id for consistency. Otherwise, this looks good.


9268-9269: Validate resolver for newly introduced query.

getUsedPipelineTypesByEngines is a useful addition. Ensure the corresponding resolver logic is in place and aligns with the pipeline retrieval process.

Would you like a script to confirm the existence of the resolver implementation?


9350-9353: Match argument usage with resolvers.

The new arguments for QueryGetUsedPipelineTypesByEnginesArgs appear correct. Double-check that your resolvers and services handle the filter and pipelineTypeSource fields as intended.


9408-9408: Confirm backward compatibility for query arguments.

Replacing _id with filter in QueryProviderArgs might affect existing calls. Verify that all references to QueryProviderArgs and its _id parameter have been updated accordingly.


9761-9762: Consistent search behavior.

Adding search?: InputMaybe<Scalars['String']> mirrors the pattern from the earlier filter addition. This ensures a uniform approach for searching TEE offers by ID or name.


10039-10039: Check usage of extended fields in queries.

OffersQuery now retrieves versions data. Confirm that services and consumers can handle these newly introduced fields in the response without errors.


10269-10277: Ensure frontend integration for versions field.

The versions subfield in the query results is now exposed. Make sure any consuming clients are updated to handle and display multiple offer versions properly.

authority: string;
action: string;
offerInfo: OfferInfo;
versionInfo: OfferVersionInfo;
Copy link

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

Confirm all calls pass versionInfo.

The new required property versionInfo ensures versioning data is available. If there are other callers of createValueOffer, verify they also provide this parameter.

Run the following script to locate all createValueOffer calls and confirm they pass versionInfo:


🏁 Script executed:

#!/bin/bash
rg -A 3 'createValueOffer\('

Length of output: 336


Action Required: Ensure all calls to createValueOffer include the new versionInfo parameter.

  • In src/commands/offersCreate.ts, the current call to createValueOffer only passes authority, action, and contractAddress. It must be updated to pass a versionInfo value as well.
  • Please verify that any other invocations of createValueOffer (if present) also provide a valid versionInfo.

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.

6 participants