Skip to content

Conversation

kulikthebird
Copy link
Contributor

@kulikthebird kulikthebird commented Sep 17, 2025

why?

To reduce the code boilerplate and make one more step towards uniform TS-driven script environment. This is a follow-up PR (it's optional from the main task perspective).

how?

By removing redundant mainprocessor methods and use the new TS one instead.

testing

  • To be done: manual tests of the affected commands to make sure that everything works as expected

Greptile Summary

Updated On: 2025-09-17 13:28:44 UTC

This PR refactors CosmWasm scripts to use a new TypeScript-based mainProcessor function instead of individual JavaScript implementations. The changes are part of a broader initiative to create a "uniform TS-driven script environment" and reduce code duplication across the codebase.

The refactoring involves removing local mainProcessor implementations from six CosmWasm JavaScript files and migrating them to use a centralized TypeScript processor located in cosmwasm/processor.ts. This new processor handles common operations like configuration loading, wallet preparation, client setup, and configuration saving through a ConfigManager class, eliminating the need for each script to implement these repetitive tasks.

The migration updates function signatures across the affected scripts to match the new processor's interface, typically changing from (client, config, args, options) to (client, wallet, config, options, args, fee). The changes also remove various utility functions like getProposalConfig, initContractConfig, and hardcoded constants like governanceAddress that have been moved to the new TypeScript configuration management system.

Important Files Changed

Changed Files
Filename Score Overview
cosmwasm/query.js 0/5 Removes local mainProcessor but fails to import the new TS version, causing runtime errors
cosmwasm/submit-proposal.js 0/5 Removes mainProcessor and utilities without proper imports, breaking all command actions
cosmwasm/utils.js 2/5 Removes deprecated utilities but has inconsistent export of removed governanceAddress
common/utils.js 4/5 Cleanly removes getProposalConfig function as part of TS migration
cosmwasm/rotate-signers.js 4/5 Successfully migrates to TS mainProcessor with updated function signatures
cosmwasm/deploy-contract.js 4/5 Properly refactored to use new TS mainProcessor with ConfigManager
cosmwasm/update-code-id.js 5/5 Clean migration that removes boilerplate while maintaining functionality

Confidence score: 1/5

  • This PR contains critical implementation errors that will cause runtime failures in multiple scripts
  • Score reflects incomplete refactoring where import statements and function calls don't match the removed implementations
  • Files cosmwasm/query.js and cosmwasm/submit-proposal.js require immediate attention as they reference undefined functions

Sequence Diagram

sequenceDiagram
    participant User
    participant Commander as "Commander.js CLI"
    participant Action as "Action Function"
    participant TSProcessor as "TS mainProcessor"
    participant CosmWasm as "CosmWasm Client"
    participant Wallet as "Wallet"
    participant Network as "Axelar Network"

    User->>Commander: "Run command (e.g., deploy-contract upload)"
    Commander->>Action: "Parse options and call action"
    Action->>TSProcessor: "mainProcessor(commandFunction, options)"
    
    TSProcessor->>Wallet: "Initialize wallet from mnemonic"
    Wallet-->>TSProcessor: "Wallet instance"
    
    TSProcessor->>CosmWasm: "Create signing client with wallet"
    CosmWasm-->>TSProcessor: "Client instance"
    
    TSProcessor->>TSProcessor: "Load configuration and validate"
    
    TSProcessor->>Action: "Call command function with (client, wallet, config, options)"
    
    alt Upload Contract
        Action->>CosmWasm: "Upload WASM binary"
        CosmWasm->>Network: "Submit upload transaction"
        Network-->>CosmWasm: "Code ID and checksum"
        CosmWasm-->>Action: "Upload result"
    else Submit Proposal
        Action->>Action: "Encode governance proposal"
        Action->>CosmWasm: "Submit governance proposal"
        CosmWasm->>Network: "Submit proposal transaction"
        Network-->>CosmWasm: "Proposal ID"
        CosmWasm-->>Action: "Proposal result"
    else Query Contract
        Action->>CosmWasm: "Query contract state"
        CosmWasm->>Network: "Query request"
        Network-->>CosmWasm: "Contract data"
        CosmWasm-->>Action: "Query result"
    end
    
    Action-->>TSProcessor: "Command execution result"
    TSProcessor->>TSProcessor: "Save updated config if needed"
    TSProcessor->>User: "Display results and completion message"
Loading

@kulikthebird kulikthebird changed the title Chore/use ts main processor chore: use ts main processor Sep 17, 2025
@kulikthebird kulikthebird changed the title chore: use ts main processor chore: use TS main processor in cosmwasm Sep 17, 2025
@kulikthebird kulikthebird changed the base branch from main to feat/main_processor_ts September 17, 2025 11:32
@kulikthebird kulikthebird marked this pull request as ready for review September 17, 2025 13:26
@kulikthebird kulikthebird requested a review from a team as a code owner September 17, 2025 13:26
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

7 files reviewed, 3 comments

Edit Code Review Bot Settings | Greptile

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

@nbayindirli nbayindirli left a comment

Choose a reason for hiding this comment

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

nit: title to chore(cosmwasm): use TS mainProcessor

cursor[bot]

This comment was marked as outdated.

@kulikthebird kulikthebird changed the title chore: use TS main processor in cosmwasm chore(cosmwasm): use TS mainProcessor Sep 23, 2025
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@kulikthebird kulikthebird changed the title chore(cosmwasm): use TS mainProcessor refactor(cosmwasm): use TS mainProcessor Sep 23, 2025
Base automatically changed from feat/main_processor_ts to main September 24, 2025 07:33
@kulikthebird kulikthebird merged commit afc8d92 into main Sep 24, 2025
11 checks passed
@kulikthebird kulikthebird deleted the chore/use_ts_main_processor branch September 24, 2025 07:55
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.

4 participants