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

feat: more send utilities #1892

Merged
merged 8 commits into from
Jan 28, 2025
Merged

feat: more send utilities #1892

merged 8 commits into from
Jan 28, 2025

Conversation

brendan-defi
Copy link
Contributor

What changed? Why?

  • added buildSendTransaction API endpoint
  • added useSendTransaction hook
  • added validateAddressInput wallet util

Notes to reviewers

How has it been tested?

Copy link

vercel bot commented Jan 28, 2025

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

Name Status Preview Comments Updated (UTC)
onchainkit-coverage ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 6:34pm
onchainkit-playground ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 6:34pm
onchainkit-routes ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 28, 2025 6:34pm

to: tokenAddress,
data: transferCallData,
},
];
Copy link
Contributor

Choose a reason for hiding this comment

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

why does this return an array?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it doesn't need to, I'll just return the object

}
const parsedAmount = parseUnits(amount, token.decimals);
return {
calls: buildSendTransaction({
Copy link
Contributor

Choose a reason for hiding this comment

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

this will be a weird response format if there's an error

}
} else if (isAddress(input, { strict: false })) {
return input;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: if isAddress then no need to check if its isBasename or isEns? moving this first could remove the else if and short circuit faster

Copy link
Contributor Author

Choose a reason for hiding this comment

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

makes sense, updated

} catch (error) {
return {
code: 'AmBSeTa01', // Api Module Build Send Transaction Error 01
error: `Something went wrong: ${error}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

could probably just return error here, i think its implicit that something went wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack, will update to Error: ${error}

return sendTransaction;
}

const parsedAmount = parseUnits(amount.toString(), token.decimals);
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: amount should already be a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yep, you're right, removing the method

@brendan-defi brendan-defi merged commit 8607454 into main Jan 28, 2025
16 checks passed
@brendan-defi brendan-defi deleted the feat/send-helpers branch January 28, 2025 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants