Hu-Fi / Mr.Market

Mr. Market is the exchange oracle of HuFi, and a CeFi crypto bot on Mixin Messenger
https://mr-market-one.vercel.app
GNU Affero General Public License v3.0
1 stars 6 forks source link

fix bot id constant #142

Closed zed-wong closed 2 months ago

zed-wong commented 2 months ago

Type

bug_fix


Description


Changes walkthrough

Relevant files
Bug_fix
constants.ts
Update Default BOT_ID Constant                                                     

interface/src/lib/helpers/constants.ts - Updated the default value of `BOT_ID` constant.
+1/-1     

PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

vercel[bot] commented 2 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
mr-market ✅ Ready (Inspect) Visit Preview Apr 10, 2024 10:03am
railway-app[bot] commented 2 months ago

This PR is being deployed to Railway 🚅

github-actions[bot] commented 2 months ago

PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/875daec104fd63c4f072b597f0000621e4530c0e)

github-actions[bot] commented 2 months ago

PR Review

(Review updated until commit https://github.com/Hu-Fi/Mr.Market/commit/875daec104fd63c4f072b597f0000621e4530c0e)

⏱️ Estimated effort to review [1-5] 1, because the PR involves a simple change of a constant value in a configuration file. The change is straightforward and does not involve complex logic or modifications to the application's functionality.
🧪 Relevant tests No
🔍 Possible issues Possible Misconfiguration: If the new `BOT_ID` is not properly configured in the environment or if it does not correspond to a valid bot, it could lead to runtime errors or misbehavior in the application.
🔒 Security concerns No
Code feedback:
relevant fileinterface/src/lib/helpers/constants.ts
suggestion       Consider validating the `BOT_ID` format upon application startup to ensure it meets expected criteria (e.g., UUID format). This can help catch configuration errors early. [important]
relevant lineexport const BOT_ID = env.PUBLIC_BOT_ID || '51186d7e-d488-417d-a031-b4e34f4fdf86'


✨ Review tool usage guide:
**Overview:** The `review` tool scans the PR code changes, and generates a PR review which includes several types of feedbacks, such as possible PR issues, security threats and relevant test in the PR. More feedbacks can be [added](https://pr-agent-docs.codium.ai/tools/review/#general-configurations) by configuring the tool. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on any PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L23) related to the review tool (`pr_reviewer` section), use the following template: ``` /review --pr_reviewer.some_config1=... --pr_reviewer.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_reviewer] some_config1=... some_config2=... ``` See the review [usage page](https://pr-agent-docs.codium.ai/tools/review/) for a comprehensive guide on using this tool.
github-actions[bot] commented 2 months ago

PR Description updated to latest commit (https://github.com/Hu-Fi/Mr.Market/commit/875daec104fd63c4f072b597f0000621e4530c0e)

github-actions[bot] commented 2 months ago

PR Code Suggestions

CategorySuggestions                                                                                                                                                       
Best practice
Use strict boolean checks for environment variables expected to be booleans. ___ **Consider using strict boolean checks for environment variables that are expected to be
booleans. The current implementation env.PUBLIC_SHOW_BAR || true will always result in
true, regardless of the environment variable's value, because any non-empty string is
truthy in JavaScript/TypeScript. To correctly handle boolean environment variables, you
can use a more explicit check, such as env.PUBLIC_SHOW_BAR === 'true'.** [interface/src/lib/helpers/constants.ts [7]](https://github.com/Hu-Fi/Mr.Market/pull/142/files#diff-1d9500711f0f58654b9e0e95aa0e7fdc798a0b74f1c2310b09e52123e52d6bf2R7-R7) ```diff -export const SHOW_BAR = env.PUBLIC_SHOW_BAR || true +export const SHOW_BAR = env.PUBLIC_SHOW_BAR === 'true' ```

✨ Improve tool usage guide:
**Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ``` See the improve [usage page](https://pr-agent-docs.codium.ai/tools/improve/) for a comprehensive guide on using this tool.
github-actions[bot] commented 2 months ago

Persistent review updated to latest commit https://github.com/Hu-Fi/Mr.Market/commit/875daec104fd63c4f072b597f0000621e4530c0e

github-actions[bot] commented 2 months ago

PR Code Suggestions

CategorySuggestions                                                                                                                                                       
Best practice
Use strict comparison to ensure env.PUBLIC_BOT_ID is only overridden when not set. ___ **Consider using a strict comparison (===) with typeof to check if env.PUBLIC_BOT_ID is
defined, instead of relying on a falsy value. This ensures that the fallback value is used
only when env.PUBLIC_BOT_ID is truly not set, rather than when it is set to a falsy value
like an empty string.** [interface/src/lib/helpers/constants.ts [8]](https://github.com/Hu-Fi/Mr.Market/pull/142/files#diff-1d9500711f0f58654b9e0e95aa0e7fdc798a0b74f1c2310b09e52123e52d6bf2R8-R8) ```diff -export const BOT_ID = env.PUBLIC_BOT_ID || '51186d7e-d488-417d-a031-b4e34f4fdf86' +export const BOT_ID = typeof env.PUBLIC_BOT_ID === 'string' && env.PUBLIC_BOT_ID.length > 0 ? env.PUBLIC_BOT_ID : '51186d7e-d488-417d-a031-b4e34f4fdf86' ```
Bug
Ensure SHOW_BAR behaves as expected by explicitly comparing with 'true'. ___ **For the SHOW_BAR constant, explicitly check for the string 'true' when dealing with
environment variables to avoid unexpected truthy values. Environment variables are read as
strings, and a non-empty string is truthy in JavaScript, which might not be the intended
behavior.** [interface/src/lib/helpers/constants.ts [7]](https://github.com/Hu-Fi/Mr.Market/pull/142/files#diff-1d9500711f0f58654b9e0e95aa0e7fdc798a0b74f1c2310b09e52123e52d6bf2R7-R7) ```diff -export const SHOW_BAR = env.PUBLIC_SHOW_BAR || true +export const SHOW_BAR = env.PUBLIC_SHOW_BAR === 'true' || true ```

✨ Improve tool usage guide:
**Overview:** The `improve` tool scans the PR code changes, and automatically generates suggestions for improving the PR code. The tool can be triggered [automatically](https://pr-agent-docs.codium.ai/usage-guide/automations_and_usage/#github-app-automatic-tools-when-a-new-pr-is-opened) every time a new PR is opened, or can be invoked manually by commenting on a PR. - When commenting, to edit [configurations](https://github.com/Codium-ai/pr-agent/blob/main/pr_agent/settings/configuration.toml#L78) related to the improve tool (`pr_code_suggestions` section), use the following template: ``` /improve --pr_code_suggestions.some_config1=... --pr_code_suggestions.some_config2=... ``` - With a [configuration file](https://pr-agent-docs.codium.ai/usage-guide/configuration_options/), use the following template: ``` [pr_code_suggestions] some_config1=... some_config2=... ``` See the improve [usage page](https://pr-agent-docs.codium.ai/tools/improve/) for a comprehensive guide on using this tool.