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

/send checks UI mvp #643

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from
Open

/send checks UI mvp #643

wants to merge 7 commits into from

Conversation

nicky-LV
Copy link
Contributor

No description provided.

@nicky-LV nicky-LV requested a review from 0xBigBoss as a code owner July 30, 2024 18:39
Copy link

Vercel Unique URL: https://sendapp-azqkjv8px-0xsend.vercel.app
Vercel Preview URL: sendapp-feat-send-checks-ui-mvp-0xsend.vercel.app
Last Commit: 63458d8

labels=labels,
resource_deps = [
"yarn:install",
"anvil:mainnet",
Copy link
Contributor

Choose a reason for hiding this comment

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

should remove this.

Suggested change
"anvil:mainnet",

Copy link
Contributor

@0xBigBoss 0xBigBoss left a comment

Choose a reason for hiding this comment

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

I'd add a salt to the DeploySendCheck.s.sol so that it uses CREATE2 and the wagmi cli will pick it up automatically.

SendCheck sendCheck = new SendCheck();

SendCheck sendCheck = new SendCheck{salt: keccak256("SendCheck")}();

Copy link
Contributor

Choose a reason for hiding this comment

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

I couldn't get my address filled in here due to not using CREATE2 but CREATE instead.

I needed this patch to get my address filled in. If we patch the deploy script to use CREATE2, then we don't need this patch.

diff --git a/packages/wagmi/wagmi.config.ts b/packages/wagmi/wagmi.config.ts
index 539cbef2..d1dd47d2 100644
--- a/packages/wagmi/wagmi.config.ts
+++ b/packages/wagmi/wagmi.config.ts
@@ -6,6 +6,9 @@ import { erc20Abi } from 'viem'
 import { base, baseSepolia, mainnet, sepolia } from 'viem/chains'
 import { localhost, baseLocal } from './src/chains'
 import { iEntryPointAbi } from './src'
+import debug from 'debug'
+
+const log = debug('wagmi:config')
 
 const broadcasts = (
   await globby([`${process.cwd()}/../contracts/broadcast/**/run-latest.json`])
@@ -14,6 +17,8 @@ const broadcasts = (
 if (!broadcasts.length) throw new Error('No broadcasts found.')
 
 const deployments = await broadcasts.reduce(async (accP, file) => {
+  log('processing', file)
+
   const acc = await accP
   const data = await import(file, {
     assert: { type: 'json' },
@@ -27,7 +32,7 @@ const deployments = await broadcasts.reduce(async (accP, file) => {
   transactions
     .filter((tx) => {
       if (!tx.transactionType) throw new Error(`No transactionType found in ${file}`)
-      return tx.transactionType === 'CREATE2'
+      return tx.transactionType === 'CREATE2' || tx.transactionType === 'CREATE'
     })
     .map((tx) => {
       const { contractAddress, contractName } = tx

}

const userOp = getClaimSendCheckUserOp(claimSendCheckUserOpProps as ClaimSendCheckUserOpProps)
const receipt = await claimSendCheck(userOp)
Copy link
Contributor

Choose a reason for hiding this comment

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

we need to submit this user op to a new API endpoint that is connected to an EOA account that will submit it on behalf of the user (if they don't have any USDC balance). To start, we can just do it for all user ops.

@@ -56,4 +56,8 @@ contract SendCheck {
delete checks[ephemeralAddress];
check.token.safeTransfer(msg.sender, check.amount);
}

function getCheck(address ephemeralAddress) external view returns (Check memory) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nice. I like how this types the return address in viem.

I looked at trying sendCheck.read.checks(ephemeralAddress) but it does not return it as the struct.

queryProps?
): UseQueryResult<SendCheckData> => {
return useQuery({
queryKey: ['sendCheckData'],
Copy link
Contributor

Choose a reason for hiding this comment

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

you want it to update if the ephemeralAddress changes

Suggested change
queryKey: ['sendCheckData'],
queryKey: ['sendCheckData', ephemeralAddress],

* Get a token's goin gecko id from its contract address
* @param {Hex} contractAddress - token contract address
*/
export const useCoinGeckoTokenId = (contractAddress: Hex, queryParams?): UseQueryResult<string> => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting, did not know about this. Did useTokenMarketData not work for you?

}

return (
<Button onPress={onPress} theme="green" px="$15" br={12} disabledStyle={{ opacity: 0.5 }}>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<Button onPress={onPress} theme="green" px="$15" br={12} disabledStyle={{ opacity: 0.5 }}>
import { useLink } from 'solito/link'
// ...
<Button {...useLink({ href: '/checks' })} theme="green" px="$15" br={12} disabledStyle={{ opacity: 0.5 }}>

Copy link
Collaborator

Choose a reason for hiding this comment

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

We also have a <LinkableButton/> Component that does the same thing
https://github.com/0xsend/sendapp/blob/dev/packages/ui/src/components/LinkableButton.tsx

return sendToken as Hex
}, [sendToken])

const parsedAmount: bigint = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

don't forget to multiply by the token decimals.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants