Refactor duplicated code into shared utilities - #14
Open
devin-ai-integration[bot] wants to merge 1 commit into
Open
Refactor duplicated code into shared utilities#14devin-ai-integration[bot] wants to merge 1 commit into
devin-ai-integration[bot] wants to merge 1 commit into
Conversation
Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Visit the preview URL for this PR (updated for commit d73ae03): https://decentralized-dall-e--pr14-devin-1784700602-ded-4i0asf72.web.app (expires Wed, 29 Jul 2026 06:13:07 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 Sign: 9f3ca659ce42113c1a9d85a3ba19a54f05478557 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Extracts repeated boilerplate in the frontend web3 helpers and the Hardhat scripts into shared utilities. No behavior change — public function signatures are preserved and the frontend build + both TS typechecks pass.
frontend/src/helpers/web3.tsEvery
callXfunction repeated the same wrappers. Collapsed into two private helpers:callNumTasks,callGetTasks,callNumSubmissions,callGetSubmissions) were eachnew Promise(async (res,rej)=>{ try{ res(await contract.methods.X().call()) }catch(e){rej(e)} })→ nowcallContractMethod(contract, "X", [args]).callMakeTask,callSubmit,callAssignWinner) each duplicated the Klaytn gas/gasPrice estimation +.send(..., callback)dance → nowsendContractMethod(contract, method, args, chainId, { from, value? }):frontend/src/helpers/utilities.tsconvertStringToHexandconvertNumberToStringwere defined identically in bothutilities.tsandbignumber.ts. Removed the copies inutilities.tsand re-export them from./bignumber(keeps existinghelpers/utilitiesimporters working).blockchain/scripts/Added
scripts/utils.tsand routed the scripts through it, removing copy-pasted boilerplate:loadDeployment/saveDeployment(deployment.json),loadArtifactAbi,attachDDALLE(getContractFactory("DDALLE").attach),findEvent(receipt, name)(replaces inlinereceipt.events?.filter(e=>e.event===name)[0]), andrunMain(main)(replaces the repeatedmain().catch(...)footer). Applied acrossdeploy,makeTask,makeSubmission,listTasks,assignWinner,giveETH.Link to Devin session: https://app.devin.ai/sessions/98a1211fd774434aa2714c7532d5766a
Requested by: @walnutwaldo
Devin Review