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

fix: unwire perp module for main branch #1830

Merged
merged 4 commits into from
Apr 2, 2024
Merged

fix: unwire perp module for main branch #1830

merged 4 commits into from
Apr 2, 2024

Conversation

matthiasmatt
Copy link
Contributor

@matthiasmatt matthiasmatt commented Mar 28, 2024

Purpose / Abstract

  • Closes #AAA

Summary by CodeRabbit

  • Documentation

    • Updated INSTALL.md with more detailed installation instructions, including troubleshooting subsections.
    • Revised README.md with updated links, component descriptions, and formatting improvements.
  • New Features

    • Enhanced Docker container configuration for running Nibiru Chain nodes with updated CORS settings and port configurations.
  • Refactor

    • Removed references and functionalities related to the perp module across various files, indicating a shift in module strategy.
    • Simplified the AfterEpochEnd function in the x/oracle/keeper package, changing how rewards and allocations are managed.
  • Chores

    • Improved code readability in the Justfile by adjusting indentation and removing unnecessary comments.
    • Updated the deploy-wasm.sh script for better transaction processing control.
  • Bug Fixes

    • Fixed flag handling in contrib/scripts/localnet.sh to enable only FLAG_SPOT and display its status correctly.

@matthiasmatt matthiasmatt requested a review from a team as a code owner March 28, 2024 10:14
Copy link
Contributor

coderabbitai bot commented Mar 28, 2024

Walkthrough

The updates encompass a range of modifications aimed at refining the installation and operational aspects of the nibid binaries and its associated components. Key changes include the removal of the perp module across various files, enhancements to the documentation for clarity, and adjustments in scripts and configurations to streamline the setup process. This overhaul simplifies the installation, enriches the documentation, and removes outdated functionalities, indicating a strategic pivot in the project's direction.

Changes

Files Summary
INSTALL.md Reorganized sections, added "Troubleshooting" subsections, updated repository references, clarified installation instructions.
README.md Updated links, revised component descriptions, adjusted table formatting, minor formatting changes in build commands.
app/keepers.go, cmd/nibid/cmd/root.go, contrib/.../chaosnet.Dockerfile, contrib/scripts/chaosnet.sh, contrib/scripts/localnet.sh, simapp/sim_test.go, x/common/testutil/cli/network.go, x/common/testutil/cli/query.go, x/common/testutil/testapp/testapp.go, x/oracle/client/cli/gen_pricefeeder_delegation_test.go, x/oracle/keeper/hooks.go Removed references and functionalities related to the perp module, adjusted Docker and script configurations, updated test utilities and oracle keeper logic.
justfile Reformatted for better readability and consistency without changing functionality.

"In the realm of code where the bits do hop,
A rabbit worked hard, never willing to stop.
🌟 With changes anew, the project did glow,
Outdated the old, in the new we bestow.
Through scripts and docs, the path we refine,
A toast to the devs, with 🍷 so fine!"

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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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/coderabbit-overrides.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.

Review Status

Actionable comments generated: 8

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 18fcef1 and 6cc5357.
Files ignored due to path filters (6)
  • x/perp/v2/types/event.pb.go is excluded by !**/*.pb.go
  • x/perp/v2/types/genesis.pb.go is excluded by !**/*.pb.go
  • x/perp/v2/types/query.pb.go is excluded by !**/*.pb.go
  • x/perp/v2/types/query.pb.gw.go is excluded by !**/*.pb.gw.go
  • x/perp/v2/types/state.pb.go is excluded by !**/*.pb.go
  • x/perp/v2/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (14)
  • INSTALL.md (7 hunks)
  • README.md (5 hunks)
  • app/keepers.go (10 hunks)
  • cmd/nibid/cmd/root.go (2 hunks)
  • contrib/docker/chaosnet.Dockerfile (1 hunks)
  • contrib/scripts/chaosnet.sh (3 hunks)
  • contrib/scripts/localnet.sh (4 hunks)
  • justfile (1 hunks)
  • simapp/sim_test.go (2 hunks)
  • x/common/testutil/cli/network.go (2 hunks)
  • x/common/testutil/cli/query.go (3 hunks)
  • x/common/testutil/testapp/testapp.go (2 hunks)
  • x/oracle/client/cli/gen_pricefeeder_delegation_test.go (1 hunks)
  • x/oracle/keeper/hooks.go (2 hunks)
Files skipped from review due to trivial changes (3)
  • contrib/docker/chaosnet.Dockerfile
  • justfile
  • x/oracle/client/cli/gen_pricefeeder_delegation_test.go
Additional comments (9)
x/oracle/keeper/hooks.go (1)
  • 7-12: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-96]

The changes in AfterEpochEnd function remove all internal logic, leaving only a conditional check. This simplification could impact how rewards and allocations are managed after each epoch. Ensure that this change aligns with the intended behavior and that any necessary logic is handled elsewhere or is no longer needed.

x/common/testutil/cli/query.go (1)
  • 16-21: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-93]

The removal of functions related to querying markets and positions in the perp/v2 module suggests a significant change in functionality. Ensure that all references to these removed functions are also updated or removed throughout the codebase to prevent broken dependencies or functionality.

Verification successful

The script execution did not find any references to "QueryMarketsV2", "QueryMarketV2", or "QueryPositionV2" in the codebase. This indicates that the necessary cleanup of references to these removed functions has already been performed, aligning with the objectives of ensuring no broken dependencies or functionality. Therefore, the concern raised in the review comment appears to have been addressed.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for references to the removed functions in the codebase
rg "QueryMarketsV2|QueryMarketV2|QueryPositionV2"

Length of output: 51

x/common/testutil/testapp/testapp.go (1)
  • 19-24: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-93]

The removal of the perp/v2 module import and related functionality in the test app setup indicates alignment with the PR's objective to unwire the perp module. Ensure that any tests or functionalities depending on the perp module are either updated or removed to reflect this change.

Verification successful

The search results indicate that references to PerpKeeperV2 and TestingCollateralDenomNUSD are only found within the CHANGELOG.md, which documents historical changes and does not reflect current dependencies in the codebase. This suggests that the removal of the perp/v2 module import and related functionality from the test app setup has been handled appropriately, with no unresolved dependencies remaining. Therefore, the changes align with the PR's objective to unwire the perp module.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for tests or functionalities that might depend on the `perp` module
rg "PerpKeeperV2|TestingCollateralDenomNUSD"

Length of output: 869

cmd/nibid/cmd/root.go (1)
  • 29-34: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-93]

The removal of the perpv2cli.AddMarketGenesisCmd function call from the initRootCmd function aligns with the PR's objective to unwire the perp module. Ensure that any dependencies or functionalities relying on this command are either updated or removed to reflect this change.

Verification successful

The search for references to the AddMarketGenesisCmd function in the codebase did not yield any results, indicating that the removal of this function call from initRootCmd does not leave behind any unresolved references or dependencies. This supports the initial assessment that the change aligns with the PR's objective to unwire the perp module.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for references to the removed `AddMarketGenesisCmd` function in the codebase
rg "AddMarketGenesisCmd"

Length of output: 24

README.md (4)
  • 25-27: The updates to the documentation links are clear and enhance the accessibility of resources for users.
  • 47-49: The revised descriptions for the components provide more detailed and accurate information, which is beneficial for readers.
  • 51-59: The adjustments to the table formatting for module descriptions improve readability and consistency.
  • 91-102: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [70-115]

The minor formatting changes in the Building: make commands section contribute to a clearer and more consistent presentation.

app/keepers.go (1)
  • 366-378: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-428]

Given the extensive changes and the removal of the perp module, it's crucial to ensure that all references to the perp module have been correctly removed. Additionally, related adjustments in keeper initializations, module manager configurations, and app module routing should be carefully reviewed to prevent runtime errors or misconfigurations. Finally, it's important to check for any potential side effects of the perp module removal, such as broken dependencies or inconsistencies in the application's logic.

Verification successful

The verification process did not find any remaining references to the perp module in app/keepers.go, suggesting that the removal of the perp module and related adjustments have been correctly implemented in the codebase. No issues were found regarding the module manager configurations or any comments/documentation that might still reference the perp module. Based on this, the changes mentioned in the review comment appear to have been successfully verified.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for any remaining references to the perp module in the app/keepers.go file.
rg --type go 'perp' app/keepers.go

# Verify that module manager configurations and app module routing do not include the perp module.
rg --type go 'ModuleManager' app/keepers.go
rg --type go 'initAppModules' app/keepers.go
rg --type go 'initModuleManager' app/keepers.go

# Check for any comments or documentation that might still reference the perp module.
rg --type go -C3 '//.*perp' app/keepers.go

Length of output: 1043

Comment on lines 22 to 38

## ⚙️ — Documentation

- [Docs | Nibiru Chain](https://nibiru.fi/docs/): Conceptual and technical documentation can be found here.
- [Docs | Nibiru Chain](https://nibiru.fi/docs/): Conceptual and technical documentation can be found here.
- [Complete Golang reference docs](https://pkg.go.dev/github.com/NibiruChain/nibiru): (`pkg.go.dev`) For the blockchain implementation .
- ["X Module"](https://nibiru.fi/docs/dev/x/)-specific documentation

## 💬 — Community

If you have questions or concerns, feel free to connect with a developer or community member in the [Nibiru Discord][social-discord]. We also have active communities on [Twitter][social-twitter] and [Telegram][social-telegram].

<!-- Markdown versions of the social badges
[![description][discord-badge]][social-discord]
[![description][twitter-badge]][social-twitter]
<!-- Markdown versions of the social badges
[![description][discord-badge]][social-discord]
[![description][twitter-badge]][social-twitter]
[![description][telegram-badge]][social-telegram]
-->

Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [79-79]

The operating system name should adhere to the standard naming convention. Here's the correction:

- MacOS
+ macOS

- [Troubleshooting](#troubleshooting)
- [Contributing](#contributing)
- [Troubleshooting](#troubleshooting-1)
- [Error when running `make install` on MacOS](#error-when-running-make-install-on-macos)
Copy link
Contributor

Choose a reason for hiding this comment

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

The "Troubleshooting" section appears twice in the Table of Contents. Consider removing the duplicate entry to avoid confusion.

make install
make localnet
```
and open another terminal.

Copy link
Contributor

Choose a reason for hiding this comment

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

This sentence does not start with an uppercase letter. Consider revising for consistency and readability.

- and open another terminal.
+ And open another terminal.

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.

Suggested change

INSTALL.md Outdated
Comment on lines 124 to 127

```
brew install wget
```
```
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [115-127]

The operating system from Apple is written as “macOS” rather than “MacOS”. Consider updating for accuracy.

- ### Error when running `make install` on MacOS
+ ### Error when running `make install` on macOS

curr_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
source "$curr_dir/feat-perp.sh"
add_genesis_perp_markets_offline
curr_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)"
Copy link
Contributor

Choose a reason for hiding this comment

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

The variable curr_dir appears unused in this script. If it's not needed, consider removing it to clean up the code.

Comment on lines 27 to 32
sed -i "s/localhost:1317/0.0.0.0:$LCD_PORT/" $HOME/.nibid/config/app.toml
sed -i "s/localhost:9090/0.0.0.0:$GRPC_PORT/" $HOME/.nibid/config/app.toml


# ------------------------------------------------------------------------
# Configure genesis params
# ------------------------------------------------------------------------
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [16-28]

Consider quoting variables to prevent globbing and word splitting. This is a good practice to ensure that the script behaves as expected when dealing with values that may contain spaces or special characters.

- nibid init $CHAIN_ID --chain-id $CHAIN_ID --home $HOME/.nibid --overwrite
+ nibid init "$CHAIN_ID" --chain-id "$CHAIN_ID" --home "$HOME/.nibid" --overwrite

Comment on lines 58 to 63
# behavior of the script is to run make install if the flag --no-build is not present.
FLAG_NO_BUILD=false

# $FLAG_PERP: Feature flag for x/perp. Enabled with `--features perp`.
FLAG_PERP=false

# $FLAG_SPOT: Feature flag for x/spot. Enabled with `--features spot`.
FLAG_SPOT=false

Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [26-26]

The expression if [ console_log_text_color ]; then is constant and might not behave as expected. If you intended to check the success of the console_log_text_color function, consider using if console_log_text_color; then instead.


📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [152-160]

Consider quoting variables to prevent globbing and word splitting. This is a good practice to ensure that the script behaves as expected when dealing with values that may contain spaces or special characters.

- if $BINARY init nibiru-localnet-0 --chain-id $CHAIN_ID --overwrite; then
+ if "$BINARY" init nibiru-localnet-0 --chain-id "$CHAIN_ID" --overwrite; then

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.

Review Status

Actionable comments generated: 9

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6cc5357 and c7d06d6.
Files selected for processing (1)
  • contrib/scripts/e2e/deploy-wasm.sh (3 hunks)
Additional comments (1)
contrib/scripts/e2e/deploy-wasm.sh (1)
  • 7-7: The update to use -b block for the transaction flag is a good improvement for better control flow during transaction processing. This ensures that the script waits for the transaction to be included in a block before proceeding, which is crucial for scripts that depend on the outcome of previous transactions.


# validator addr
VALIDATOR_ADDR=$($BINARY keys show validator --address)
echo "Validator address:"
echo "$VALIDATOR_ADDR"

BALANCE_1=$($BINARY q bank balances "$VALIDATOR_ADDR")
BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR)
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent globbing and word splitting, it's recommended to double-quote variables when they are used. This applies to the usage of $VALIDATOR_ADDR in the command to query bank balances.

- BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR)
+ BALANCE_1=$($BINARY q bank balances "$VALIDATOR_ADDR")

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.

Suggested change
BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR)
BALANCE_1=$($BINARY q bank balances "$VALIDATOR_ADDR")

sleep 3

CONTRACT_CODE=$($BINARY q tx $TX_HASH --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to the previous comment, to prevent globbing and word splitting, it's recommended to double-quote variables when they are used. This applies to the usage of $TXFLAG in the command to store the contract code.

- CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
+ CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator "$TXFLAG" --output json | jq -r '.logs[0].events[-1].attributes[-1].value')

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.

Suggested change
CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator "$TXFLAG" --output json | jq -r '.logs[0].events[-1].attributes[-1].value')

sleep 3

CONTRACT_CODE=$($BINARY q tx $TX_HASH --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
echo "Stored: $CONTRACT_CODE"

BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR)
Copy link
Contributor

Choose a reason for hiding this comment

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

To ensure the script's robustness and prevent potential issues, it's advisable to double-quote variables when they are used. This applies to the usage of $VALIDATOR_ADDR in the command to query bank balances after storing the contract.

- BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR)
+ BALANCE_2=$($BINARY q bank balances "$VALIDATOR_ADDR")

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.

Suggested change
BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR)
BALANCE_2=$($BINARY q bank balances "$VALIDATOR_ADDR")

@@ -28,7 +25,6 @@

INIT='{"purchase_price":{"amount":"100","denom":"unibi"},"transfer_price":{"amount":"999","denom":"unibi"}}'
$BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin
Copy link
Contributor

Choose a reason for hiding this comment

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

When using variables in bash scripts, especially in commands that might be affected by globbing or word splitting, it's best practice to double-quote them. This applies to the usage of $CONTRACT_CODE and $INIT in the command to instantiate the wasm contract.

- $BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin
+ $BINARY tx wasm instantiate "$CONTRACT_CODE" "$INIT" --from validator "$TXFLAG" --label "awesome name service" --no-admin

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.

Suggested change
$BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin
$BINARY tx wasm instantiate "$CONTRACT_CODE" "$INIT" --from validator "$TXFLAG" --label "awesome name service" --no-admin

@@ -28,7 +25,6 @@

INIT='{"purchase_price":{"amount":"100","denom":"unibi"},"transfer_price":{"amount":"999","denom":"unibi"}}'
$BINARY tx wasm instantiate $CONTRACT_CODE "$INIT" --from validator $TXFLAG --label "awesome name service" --no-admin
sleep 3

CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CONTRACT_CODE --output json | jq -r '.contracts[-1]')
Copy link
Contributor

Choose a reason for hiding this comment

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

To prevent potential issues with globbing and word splitting, it's recommended to double-quote variables in bash scripts. This applies to the usage of $CONTRACT_CODE in the command to list contracts by code.

- CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CONTRACT_CODE --output json | jq -r '.contracts[-1]')
+ CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code "$CONTRACT_CODE" --output json | jq -r '.contracts[-1]')

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.

Suggested change
CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code $CONTRACT_CODE --output json | jq -r '.contracts[-1]')
CONTRACT_ADDRESS=$($BINARY query wasm list-contract-by-code "$CONTRACT_CODE" --output json | jq -r '.contracts[-1]')

Comment on lines 4 to 22
BINARY="nibid"
DENOM="unibi"
CHAIN_ID="nibiru-localnet-0"
TXFLAG="--gas-prices 0.1$DENOM --gas auto --gas-adjustment 1.3 -y -b async --chain-id $CHAIN_ID"
TXFLAG="--gas-prices 0.1$DENOM --gas auto --gas-adjustment 1.3 -y -b block --chain-id $CHAIN_ID"

# validator addr
VALIDATOR_ADDR=$($BINARY keys show validator --address)
echo "Validator address:"
echo "$VALIDATOR_ADDR"

BALANCE_1=$($BINARY q bank balances "$VALIDATOR_ADDR")
BALANCE_1=$($BINARY q bank balances $VALIDATOR_ADDR)
echo "Pre-store balance:"
echo "$BALANCE_1"
echo "TX Flags: $TXFLAG"

TX_HASH=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.txhash' )
sleep 3

CONTRACT_CODE=$($BINARY q tx $TX_HASH --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
CONTRACT_CODE=$($BINARY tx wasm store "./contrib/scripts/e2e/contracts/cw_nameservice.wasm" --from validator $TXFLAG --output json | jq -r '.logs[0].events[-1].attributes[-1].value')
echo "Stored: $CONTRACT_CODE"

BALANCE_2=$($BINARY q bank balances $VALIDATOR_ADDR)
Copy link
Contributor

Choose a reason for hiding this comment

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

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [32-32]

For better script safety and to avoid issues related to globbing and word splitting, ensure variables are double-quoted. This applies to the usage of $CONTRACT_ADDRESS in the command to query the wasm contract.

- $BINARY query wasm contract $CONTRACT_ADDRESS
+ $BINARY query wasm contract "$CONTRACT_ADDRESS"

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [39-39]

To ensure the script's reliability, it's recommended to double-quote variables when they are used. This applies to the usage of $CONTRACT_ADDRESS and $NAME_QUERY in the command to query the registered domain name.

- DOMAIN_OWNER=$($BINARY query wasm contract-state smart $CONTRACT_ADDRESS "$NAME_QUERY" --output json | jq -r '.data.address')
+ DOMAIN_OWNER=$($BINARY query wasm contract-state smart "$CONTRACT_ADDRESS" "$NAME_QUERY" --output json | jq -r '.data.address')

📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [42-42]

Finally, to prevent issues with globbing and word splitting, it's advisable to double-quote variables in bash scripts. This applies to the comparison of $DOMAIN_OWNER and $VALIDATOR_ADDR in the conditional statement.

- if [ $DOMAIN_OWNER != $VALIDATOR_ADDR ]; then
+ if [ "$DOMAIN_OWNER" != "$VALIDATOR_ADDR" ]; then

@@ -37,7 +33,6 @@

# purchase a domain name
$BINARY tx wasm execute $CONTRACT_ADDRESS '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator $TXFLAG -y
Copy link
Contributor

Choose a reason for hiding this comment

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

To enhance the script's robustness, it's advisable to double-quote variables in bash scripts. This applies to the usage of $CONTRACT_ADDRESS and $TXFLAG in the command to execute the wasm contract.

- $BINARY tx wasm execute $CONTRACT_ADDRESS '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator $TXFLAG -y
+ $BINARY tx wasm execute "$CONTRACT_ADDRESS" '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator "$TXFLAG" -y

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.

Suggested change
$BINARY tx wasm execute $CONTRACT_ADDRESS '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator $TXFLAG -y
$BINARY tx wasm execute "$CONTRACT_ADDRESS" '{"register":{"name":"uniques-domain"}}' --amount 100$DENOM --from validator "$TXFLAG" -y

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

Review Status

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c7d06d6 and c7e901b.
Files selected for processing (1)
  • justfile (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • justfile
Additional Context Used

@Unique-Divine Unique-Divine merged commit 68f8f5b into main Apr 2, 2024
12 of 13 checks passed
@Unique-Divine Unique-Divine deleted the mat/rip-perp branch April 2, 2024 08:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants