Fix three code bugs #5
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses three identified bugs and includes several minor robustness improvements across the codebase.
.envfile writing: Previously, the.env.localfile was written by passing an array of lines directly tofs.writeFile, which implicitly coerced the array into a comma-joined string, corrupting the file format. The fix explicitly joins the array elements with\nbefore writing.applyGasMultiplierfunction intypescript/agentkit/src/utils.tsusedNumber(gas)for calculations, leading to potential precision loss for largeBigIntvalues. The fix implements aBigInt-safe scaling method with fixed precision to prevent overflow and underflow.hashlib.md5was used for checksums in analytics, which is an insecure cryptographic hash function. This has been replaced withhashlib.sha256.requests.getandrequests.postcalls across various Python modules lacked explicittimeoutparameters, risking indefinite hangs. Timeouts have been added to all affected HTTP requests.Minor Robustness Improvements:
typescript/agentkit/src/action-providers/opensea/openseaActionProvider.ts,Number.parseInt(chainId, 10)is now used for clarity and radix safety when creating the ethers provider.typescript/agentkit/src/action-providers/wow/utils.ts,BigInt(amount)is now explicitly passed to on-chain quote functions to avoid implicit coercions and ensure correct unit handling.Tests
All TypeScript packages built and tests ran successfully for the TS workspace. Python tests were not available in this environment, but the changes are additive and safe.
Checklist
A couple of things to include in your PR for completeness:
Note
Adds HTTP timeouts and sha256 checksums in Python, fixes .env file writing, implements BigInt-safe gas scaling, and improves argument types/parsing in TS providers.
timeouttorequests.get/postinpyth_action_provider.py,send_analytics_event.py, andcreate_onchain_agent/cli.py.hashlib.md5withhashlib.sha256for analytics checksum.applyGasMultiplierinagentkit/src/utils.tsto avoidNumber(gas)precision loss with bigint-safe scaling and input guards..env.localas a single joined string increate-onchain-agent/src/utils.ts.Number.parseInt(chainId, 10)when creating ethers provider inopenseaActionProvider.ts.BigInt(...)args to on-chain quote calls inaction-providers/wow/utils.ts.Written by Cursor Bugbot for commit bf017df. This will update automatically on new commits. Configure here.