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

Fix premature close of onramp #1163

Draft
wants to merge 8 commits into
base: dev
Choose a base branch
from
Draft

Fix premature close of onramp #1163

wants to merge 8 commits into from

Conversation

erick-kolwaii
Copy link
Collaborator

No description provided.

Copy link

github-actions bot commented Mar 8, 2025

Vercel Unique URL: https://sendapp-bf8ys3s40-0xsend.vercel.app
Vercel Preview URL: sendapp-fix-pending-0xsend.vercel.app
Last Commit: 5fd541a

Copy link

github-actions bot commented Mar 8, 2025

Playwright Report

Summary

Expected Skipped Unexpected Flaky Duration
84 6 0 0 214.01s

Suites

account-rewards.onboarded.spec.ts

can visit rewards page

  • chromium: ✅
  • firefox: ✅

account-sendtag-add.onboarded.spec.ts

can visit add sendtags page

  • chromium: ✅
  • firefox: ✅

can add a pending tag

  • chromium: ✅
  • firefox: ✅

cannot add an invalid tag name

  • chromium: ✅
  • firefox: ✅

cannot add more than 5 tags

  • chromium: ✅
  • firefox: ✅

cannot confirm a tag without paying

  • chromium: ✅
  • firefox: ✅

account-sendtag-checkout.onboarded.spec.ts

can confirm a tag

  • chromium: ✅
  • firefox: ✅

can refer a tag

  • chromium: ✅
  • firefox: ✅

can refer multiple tags in separate transactions

  • chromium: ✅
  • firefox: ✅

account-settings-backup.onboarded.spec.ts

can backup account

  • chromium: ✅
  • firefox: ✅

can remove a signer

  • chromium: ✅
  • firefox: ✅

account.logged-in.spec.ts

can visit account page

  • chromium: ✅
  • firefox: ✅

can update profile

  • chromium: ✅
  • firefox: ✅

activity.onboarded.spec.ts

can visit activity page and see correct activity feed

  • chromium: ✅
  • firefox: ✅

can search on activity page

  • chromium: ✅
  • firefox: ✅

home.onboarded.spec.ts

can visit token detail page

  • chromium: ✅
  • firefox: ✅

leaderboard.logged-in.spec.ts

can visit leaderboard page

  • chromium: ✅
  • firefox: ✅

onboarding.logged-in.spec.ts

can visit onboarding page

  • chromium: ✅
  • firefox: ✅

profile.anon.spec.ts

anon user can visit public profile

  • chromium: ✅
  • firefox: ✅

anon user cannot visit private profile

  • chromium: ✅
  • firefox: ✅

profile.logged-in.spec.ts

logged in user needs onboarding before visiting profile

  • chromium: ✅
  • firefox: ✅

profile.onboarded.spec.ts

can visit other user profile and send by tag

  • chromium: ✅
  • firefox: ✅

can visit my own profile

  • chromium: ✅
  • firefox: ✅

can visit private profile

  • chromium: ✅
  • firefox: ✅

can view activities between another profile

  • chromium: ✅
  • firefox: ✅

send-token-upgrade.onboarded.spec.ts

can upgrade their Send Token V0 to Send Token V1

  • chromium: ✅
  • firefox: ✅

send.onboarded.spec.ts

can send USDC starting from profile page

  • chromium: ✅
  • firefox: ✅

can send USDC using tag starting from home page

  • chromium: ✅
  • firefox: ✅

can send USDC using sendid starting from home page

  • chromium: ✅
  • firefox: ✅

can send USDC using address starting from home page

  • chromium: ✅
  • firefox: ✅

can send ETH starting from profile page

  • chromium: ✅
  • firefox: ✅

can send ETH using tag starting from home page

  • chromium: ✅
  • firefox: ✅

can send ETH using sendid starting from home page

  • chromium: ✅
  • firefox: ✅

can send ETH using address starting from home page

  • chromium: ✅
  • firefox: ✅

can send SEND starting from profile page

  • chromium: ✅
  • firefox: ✅

can send SEND using tag starting from home page

  • chromium: ✅
  • firefox: ✅

can send SEND using sendid starting from home page

  • chromium: ✅
  • firefox: ✅

can send SEND using address starting from home page

  • chromium: ✅
  • firefox: ✅

sign-in.anon.spec.ts

redirect on sign-in

  • chromium: ✅
  • firefox: ✅

redirect to send confirm page on sign-in

  • chromium: ✅
  • firefox: ✅

sign-up.anon.spec.ts

can sign up

  • chromium: ✅
  • firefox: ✅

country code is selected based on geoip

  • chromium: ✅
  • firefox: ✅

skip otp for existing user trying to sign up using already used phone number

  • chromium: ⏭
  • firefox: ⏭

user can sign in with passkey from backing up page

  • chromium: ⏭
  • firefox: ⏭

user can sign in as back up using otp from backing up page

  • chromium: ⏭
  • firefox: ⏭

jest.mock('app/features/deposit/components/PendingScreen', () => ({
PendingScreen: () => <Text testID="pending-screen">PendingScreen-Mock</Text>,
}))
jest.mock('@my/ui', () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ask @0xBigBoss if this is necessary. Seems like overkill

Copy link
Contributor

Choose a reason for hiding this comment

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

This is probably mocking too much. We can use the test provider and we shouldn't have to mock the UI package. We can wrap the components in this provider and it should work without the excessive mocking.

jest.clearAllMocks()

// Default mock implementations
;(useSendAccount as unknown as jest.Mock).mockReturnValue(mockSendAccount)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Instead of using as here I'd use a @ts-expect-error comment

* PendingScreen component that displays while waiting for a transaction to be confirmed.
* It polls for new USDC transactions and redirects to success page when a new transaction is detected.
*
* @param props - Component properties
Copy link
Collaborator

Choose a reason for hiding this comment

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

These jsdoc comments not very useful


// If we have new transactions, consider it a success
if (currentCount > initialActivityCount) {
// TODO: redirect to success page
Copy link
Collaborator

Choose a reason for hiding this comment

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

Finish this todo

useEffect(() => {
if (!activityData || initialActivityCount === null) return

const usdcToMe = activityData.pages[0]?.filter(
Copy link
Collaborator

@youngkidwarrior youngkidwarrior Mar 8, 2025

Choose a reason for hiding this comment

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

This logic doesn't make sense to me. Why are we comparing usdcToMe length to activity feed length

Copy link
Contributor

Choose a reason for hiding this comment

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

we're trying to see if any new USDC deposits have been sent to the user.

import { getOnrampBuyUrl } from '@coinbase/onchainkit/fund'
import { useMutation } from '@tanstack/react-query'
import { useRouter } from 'solito/router'

type OnrampStatus = 'idle' | 'pending' | 'success' | 'failed'
type OnrampStatus = 'idle' | 'pending_payment' | 'success' | 'failed' | 'payment_submitted'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Any reason we are changing 'pending' to 'pending_payment'

@@ -127,17 +133,19 @@ export function useCoinbaseOnramp({
const status: OnrampStatus = isSuccess
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you use a switch(true) instead of a nested ternary

@@ -22,25 +22,28 @@ export function useCoinbaseOnramp({
partnerUserId,
defaultPaymentMethod = 'CARD',
}: OnrampConfig) {
const [popup, setPopup] = useState<Window | null>(null)
const popupRef = useRef<Window | null>(null)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nice

const [initialActivityCount, setInitialActivityCount] = useState<number | null>(null)
// Query to check for new USDC transactions
const { data: activityData } = useTokenActivityFeed({
address: usdcAddress[baseMainnet.id] as PgBytea,
Copy link
Contributor

Choose a reason for hiding this comment

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

Need to use hexToBytea. Viem uses 0x prefix. Supabase uses \x prefix

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

damn AI actually had it right and I went back and changed it bc it looked funny, noted

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