Skip to content

Commit

Permalink
Merge pull request #888 from 0xsend/dev
Browse files Browse the repository at this point in the history
deploy
  • Loading branch information
youngkidwarrior authored Nov 23, 2024
2 parents f29b2e3 + 8b9f6c3 commit 1e970b7
Show file tree
Hide file tree
Showing 41 changed files with 2,087 additions and 2,999 deletions.
36 changes: 2 additions & 34 deletions apps/next/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '../public/reset.css'
import '../styles/globals.css'

import 'raf/polyfill'
import '@my/ui/src/config/fonts.css'

Expand All @@ -10,38 +9,12 @@ import type { AuthProviderProps } from 'app/provider/auth'
import { api } from 'app/utils/api'
import type { NextPage } from 'next'
import Head from 'next/head'
import { useEffect, type ReactElement, type ReactNode } from 'react'
import type { ReactElement, ReactNode } from 'react'
import type { SolitoAppProps } from 'solito'
import { Provider } from 'app/provider'
import { projectId, config as wagmiConfig } from 'app/provider/wagmi/config'
import { createWeb3Modal, useWeb3ModalTheme } from '@web3modal/wagmi/react'
import { baseMainnetClient } from '@my/wagmi'
import { YStack, H1, H2 } from '@my/ui'
import { IconSendLogo } from 'app/components/icons'

createWeb3Modal({
wagmiConfig,
projectId,
defaultChain: baseMainnetClient.chain,
themeVariables: {
'--w3m-accent': '#86AE80',
},
tokens: {
8453: {
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
},
845337: {
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
},
1: {
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
},
1337: {
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
},
},
})

if (process.env.NODE_ENV === 'production') {
require('../public/tamagui.css')
}
Expand All @@ -57,12 +30,7 @@ function MyApp({
// reference: https://nextjs.org/docs/pages/building-your-application/routing/pages-and-layouts
const getLayout = Component.getLayout || ((page) => page)

const [theme, setTheme] = useRootTheme()
const { setThemeMode } = useWeb3ModalTheme()

useEffect(() => {
setThemeMode(theme)
}, [theme, setThemeMode])
const [, setTheme] = useRootTheme()

return (
<>
Expand Down
32 changes: 32 additions & 0 deletions apps/next/pages/account/affiliate.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Head from 'next/head'
import { userProtectedGetSSP } from 'utils/userProtected'
import type { NextPageWithLayout } from '../_app'
import { AffiliateScreen } from 'app/features/affiliate/screen'
import { HomeLayout } from 'app/features/home/layout.web'
import { TopNav } from 'app/components/TopNav'

export const Page: NextPageWithLayout = () => {
return (
<>
<Head>
<title>Send | Affiliates</title>
<meta
name="description"
content="View your network and track referral activity."
key="desc"
/>
</Head>
<AffiliateScreen />
</>
)
}

const subheader = 'View your network and track referral activity.'

export const getServerSideProps = userProtectedGetSSP()

Page.getLayout = (children) => (
<HomeLayout TopNav={<TopNav header="Affiliate" subheader={subheader} />}>{children}</HomeLayout>
)

export default Page
26 changes: 0 additions & 26 deletions apps/next/pages/referrals.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/api/src/routers/_app.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'
import { createTRPCRouter } from '../trpc'
import { authRouter } from './auth'
import { authRouter } from './auth/router'
import { chainAddressRouter } from './chainAddress'
import { distributionRouter } from './distribution'
import { tagRouter } from './tag'
Expand Down
57 changes: 0 additions & 57 deletions packages/api/src/routers/auth.ts

This file was deleted.

88 changes: 88 additions & 0 deletions packages/api/src/routers/auth/router.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { TRPCError } from '@trpc/server'
import { supabaseAdmin } from 'app/utils/supabase/admin'
import debug from 'debug'
import { z } from 'zod'
import { createTRPCRouter, publicProcedure } from '../../trpc'
import { AuthStatus } from './types'

const log = debug('api:auth')

export const authRouter = createTRPCRouter({
signInWithOtp: publicProcedure
.input(
z.object({
phone: z.string().trim(),
countrycode: z.string(),
captchaToken: z.string().optional(),
bypassOnboardedCheck: z.boolean().optional().default(false),
})
)
.mutation(async ({ input }) => {
const { phone, countrycode, captchaToken, bypassOnboardedCheck } = input

if (!phone) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Phone number is required',
})
}

if (!countrycode) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Country Code is required',
})
}

if (!!process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY && !captchaToken) {
throw new TRPCError({
code: 'BAD_REQUEST',
message: 'Captcha token is required',
})
}

if (!bypassOnboardedCheck) {
log('checking if phone is already used', { phone })

const { data } = await supabaseAdmin
.rpc('profile_lookup', { lookup_type: 'phone', identifier: `${countrycode}${phone}` })
.maybeSingle()

if (data) {
log('phone is already used', { phone })

return {
status: AuthStatus.PhoneAlreadyUsed,
}
}
}

const { error } = await supabaseAdmin.auth
.signInWithOtp({ phone: `${countrycode}${phone}`, options: { captchaToken } })
.then(async (r) => {
// TODO: potentially add a fake numbers list for app store reviewers
if (__DEV__ || process.env.CI) {
log('fake_otp_credentials', { phone: `${countrycode}${phone}` })
return await supabaseAdmin.rpc('fake_otp_credentials', {
phone: `${countrycode}${phone}`,
})
}
const errMessage = r.error?.message.toLowerCase()
log('signInWithOtp', { errMessage, phone })
return r
})

if (error) {
throw new TRPCError({
code: 'INTERNAL_SERVER_ERROR',
message: error.message,
})
}

log('successfully signed up with otp', { phone })

return {
status: AuthStatus.SignedIn,
}
}),
})
4 changes: 4 additions & 0 deletions packages/api/src/routers/auth/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export enum AuthStatus {
SignedIn = 'SignedIn',
PhoneAlreadyUsed = 'PhoneAlreadyUsed',
}
31 changes: 31 additions & 0 deletions packages/app/components/icons/IconRocket.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type { ColorTokens } from '@my/ui/types'
import { type IconProps, themed } from '@tamagui/helpers-icon'
import { memo } from 'react'
import { Mask, Path, Svg, Rect, G } from 'react-native-svg'

const Rocket = (props) => {
const { size, color, ...rest } = props
return (
<Svg
width={size ?? 48}
height={size ?? 48}
color={color as ColorTokens | undefined}
viewBox="0 0 48 48"
fill="none"
{...rest}
>
<Mask id="mask0_1_1346" maskUnits="userSpaceOnUse" x="0" y="0" width="48" height="48">
<Rect width="48" height="48" fill="#D9D9D9" />
</Mask>
<G mask="url(#mask0_1_1346)">
<Path
d="M9.35 20.4499L14.65 22.6999C15.25 21.4999 15.8917 20.3166 16.575 19.1499C17.2583 17.9832 17.9833 16.8666 18.75 15.7999L14.8 14.9999L9.35 20.4499ZM17.05 24.4999L23.7 31.1499C25.6 30.2832 27.3833 29.2999 29.05 28.1999C30.7167 27.0999 32.0667 26.0332 33.1 24.9999C35.8 22.2999 37.7833 19.5332 39.05 16.6999C40.3167 13.8666 41 10.6666 41.1 7.0999C37.5333 7.1999 34.3333 7.88323 31.5 9.1499C28.6667 10.4166 25.9 12.3999 23.2 15.0999C22.1667 16.1332 21.1 17.4832 20 19.1499C18.9 20.8166 17.9167 22.5999 17.05 24.4999ZM28.5 19.6999C27.8333 19.0332 27.5 18.2082 27.5 17.2249C27.5 16.2416 27.8333 15.4166 28.5 14.7499C29.1667 14.0832 29.9917 13.7499 30.975 13.7499C31.9583 13.7499 32.7833 14.0832 33.45 14.7499C34.1167 15.4166 34.45 16.2416 34.45 17.2249C34.45 18.2082 34.1167 19.0332 33.45 19.6999C32.7833 20.3666 31.9583 20.6999 30.975 20.6999C29.9917 20.6999 29.1667 20.3666 28.5 19.6999ZM27.75 38.8499L33.2 33.3999L32.4 29.4499C31.3333 30.2166 30.2167 30.9416 29.05 31.6249C27.8833 32.3082 26.7 32.9499 25.5 33.5499L27.75 38.8499ZM44.05 4.1499C44.35 8.68323 43.7833 12.8166 42.35 16.5499C40.9167 20.2832 38.55 23.7999 35.25 27.0999L35.05 27.2999L36.15 32.7999C36.25 33.2999 36.225 33.7832 36.075 34.2499C35.925 34.7166 35.6667 35.1332 35.3 35.4999L26.75 44.0999L22.5 34.1999L14 25.6999L4.1 21.4499L12.7 12.8999C13.0667 12.5332 13.4833 12.2749 13.95 12.1249C14.4167 11.9749 14.9 11.9499 15.4 12.0499L20.9 13.1499C20.9333 13.1166 20.9667 13.0916 21 13.0749C21.0333 13.0582 21.0667 13.0332 21.1 12.9999C24.4 9.6999 27.9167 7.3249 31.65 5.8749C35.3833 4.4249 39.5167 3.8499 44.05 4.1499ZM7.45 31.7499C8.61667 30.5832 10.0417 29.9916 11.725 29.9749C13.4083 29.9582 14.8333 30.5332 16 31.6999C17.1667 32.8666 17.7417 34.2916 17.725 35.9749C17.7083 37.6582 17.1167 39.0832 15.95 40.2499C15.0833 41.1166 13.7417 41.8332 11.925 42.3999C10.1083 42.9666 7.38333 43.4999 3.75 43.9999C4.25 40.3666 4.775 37.6332 5.325 35.7999C5.875 33.9666 6.58333 32.6166 7.45 31.7499ZM9.55 33.8999C9.08333 34.3999 8.66667 35.1832 8.3 36.2499C7.93333 37.3166 7.61667 38.6832 7.35 40.3499C9.01667 40.0832 10.3833 39.7666 11.45 39.3999C12.5167 39.0332 13.3 38.6166 13.8 38.1499C14.4333 37.5832 14.7583 36.8749 14.775 36.0249C14.7917 35.1749 14.5 34.4332 13.9 33.7999C13.2667 33.1999 12.525 32.9082 11.675 32.9249C10.825 32.9416 10.1167 33.2666 9.55 33.8999Z"
fill={'currentColor'}
/>
</G>
</Svg>
)
}

const IconRocket = memo<IconProps>(themed(Rocket))
export { IconRocket }
Loading

0 comments on commit 1e970b7

Please sign in to comment.