Skip to content

Commit 1e970b7

Browse files
Merge pull request #888 from 0xsend/dev
deploy
2 parents f29b2e3 + 8b9f6c3 commit 1e970b7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2087
-2999
lines changed

apps/next/pages/_app.tsx

+2-34
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import '../public/reset.css'
22
import '../styles/globals.css'
3-
43
import 'raf/polyfill'
54
import '@my/ui/src/config/fonts.css'
65

@@ -10,38 +9,12 @@ import type { AuthProviderProps } from 'app/provider/auth'
109
import { api } from 'app/utils/api'
1110
import type { NextPage } from 'next'
1211
import Head from 'next/head'
13-
import { useEffect, type ReactElement, type ReactNode } from 'react'
12+
import type { ReactElement, ReactNode } from 'react'
1413
import type { SolitoAppProps } from 'solito'
1514
import { Provider } from 'app/provider'
16-
import { projectId, config as wagmiConfig } from 'app/provider/wagmi/config'
17-
import { createWeb3Modal, useWeb3ModalTheme } from '@web3modal/wagmi/react'
18-
import { baseMainnetClient } from '@my/wagmi'
1915
import { YStack, H1, H2 } from '@my/ui'
2016
import { IconSendLogo } from 'app/components/icons'
2117

22-
createWeb3Modal({
23-
wagmiConfig,
24-
projectId,
25-
defaultChain: baseMainnetClient.chain,
26-
themeVariables: {
27-
'--w3m-accent': '#86AE80',
28-
},
29-
tokens: {
30-
8453: {
31-
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
32-
},
33-
845337: {
34-
address: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
35-
},
36-
1: {
37-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
38-
},
39-
1337: {
40-
address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
41-
},
42-
},
43-
})
44-
4518
if (process.env.NODE_ENV === 'production') {
4619
require('../public/tamagui.css')
4720
}
@@ -57,12 +30,7 @@ function MyApp({
5730
// reference: https://nextjs.org/docs/pages/building-your-application/routing/pages-and-layouts
5831
const getLayout = Component.getLayout || ((page) => page)
5932

60-
const [theme, setTheme] = useRootTheme()
61-
const { setThemeMode } = useWeb3ModalTheme()
62-
63-
useEffect(() => {
64-
setThemeMode(theme)
65-
}, [theme, setThemeMode])
33+
const [, setTheme] = useRootTheme()
6634

6735
return (
6836
<>

apps/next/pages/account/affiliate.tsx

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import Head from 'next/head'
2+
import { userProtectedGetSSP } from 'utils/userProtected'
3+
import type { NextPageWithLayout } from '../_app'
4+
import { AffiliateScreen } from 'app/features/affiliate/screen'
5+
import { HomeLayout } from 'app/features/home/layout.web'
6+
import { TopNav } from 'app/components/TopNav'
7+
8+
export const Page: NextPageWithLayout = () => {
9+
return (
10+
<>
11+
<Head>
12+
<title>Send | Affiliates</title>
13+
<meta
14+
name="description"
15+
content="View your network and track referral activity."
16+
key="desc"
17+
/>
18+
</Head>
19+
<AffiliateScreen />
20+
</>
21+
)
22+
}
23+
24+
const subheader = 'View your network and track referral activity.'
25+
26+
export const getServerSideProps = userProtectedGetSSP()
27+
28+
Page.getLayout = (children) => (
29+
<HomeLayout TopNav={<TopNav header="Affiliate" subheader={subheader} />}>{children}</HomeLayout>
30+
)
31+
32+
export default Page

apps/next/pages/referrals.tsx

-26
This file was deleted.

packages/api/src/routers/_app.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { inferRouterInputs, inferRouterOutputs } from '@trpc/server'
22
import { createTRPCRouter } from '../trpc'
3-
import { authRouter } from './auth'
3+
import { authRouter } from './auth/router'
44
import { chainAddressRouter } from './chainAddress'
55
import { distributionRouter } from './distribution'
66
import { tagRouter } from './tag'

packages/api/src/routers/auth.ts

-57
This file was deleted.
+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
import { TRPCError } from '@trpc/server'
2+
import { supabaseAdmin } from 'app/utils/supabase/admin'
3+
import debug from 'debug'
4+
import { z } from 'zod'
5+
import { createTRPCRouter, publicProcedure } from '../../trpc'
6+
import { AuthStatus } from './types'
7+
8+
const log = debug('api:auth')
9+
10+
export const authRouter = createTRPCRouter({
11+
signInWithOtp: publicProcedure
12+
.input(
13+
z.object({
14+
phone: z.string().trim(),
15+
countrycode: z.string(),
16+
captchaToken: z.string().optional(),
17+
bypassOnboardedCheck: z.boolean().optional().default(false),
18+
})
19+
)
20+
.mutation(async ({ input }) => {
21+
const { phone, countrycode, captchaToken, bypassOnboardedCheck } = input
22+
23+
if (!phone) {
24+
throw new TRPCError({
25+
code: 'BAD_REQUEST',
26+
message: 'Phone number is required',
27+
})
28+
}
29+
30+
if (!countrycode) {
31+
throw new TRPCError({
32+
code: 'BAD_REQUEST',
33+
message: 'Country Code is required',
34+
})
35+
}
36+
37+
if (!!process.env.NEXT_PUBLIC_TURNSTILE_SITE_KEY && !captchaToken) {
38+
throw new TRPCError({
39+
code: 'BAD_REQUEST',
40+
message: 'Captcha token is required',
41+
})
42+
}
43+
44+
if (!bypassOnboardedCheck) {
45+
log('checking if phone is already used', { phone })
46+
47+
const { data } = await supabaseAdmin
48+
.rpc('profile_lookup', { lookup_type: 'phone', identifier: `${countrycode}${phone}` })
49+
.maybeSingle()
50+
51+
if (data) {
52+
log('phone is already used', { phone })
53+
54+
return {
55+
status: AuthStatus.PhoneAlreadyUsed,
56+
}
57+
}
58+
}
59+
60+
const { error } = await supabaseAdmin.auth
61+
.signInWithOtp({ phone: `${countrycode}${phone}`, options: { captchaToken } })
62+
.then(async (r) => {
63+
// TODO: potentially add a fake numbers list for app store reviewers
64+
if (__DEV__ || process.env.CI) {
65+
log('fake_otp_credentials', { phone: `${countrycode}${phone}` })
66+
return await supabaseAdmin.rpc('fake_otp_credentials', {
67+
phone: `${countrycode}${phone}`,
68+
})
69+
}
70+
const errMessage = r.error?.message.toLowerCase()
71+
log('signInWithOtp', { errMessage, phone })
72+
return r
73+
})
74+
75+
if (error) {
76+
throw new TRPCError({
77+
code: 'INTERNAL_SERVER_ERROR',
78+
message: error.message,
79+
})
80+
}
81+
82+
log('successfully signed up with otp', { phone })
83+
84+
return {
85+
status: AuthStatus.SignedIn,
86+
}
87+
}),
88+
})
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export enum AuthStatus {
2+
SignedIn = 'SignedIn',
3+
PhoneAlreadyUsed = 'PhoneAlreadyUsed',
4+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import type { ColorTokens } from '@my/ui/types'
2+
import { type IconProps, themed } from '@tamagui/helpers-icon'
3+
import { memo } from 'react'
4+
import { Mask, Path, Svg, Rect, G } from 'react-native-svg'
5+
6+
const Rocket = (props) => {
7+
const { size, color, ...rest } = props
8+
return (
9+
<Svg
10+
width={size ?? 48}
11+
height={size ?? 48}
12+
color={color as ColorTokens | undefined}
13+
viewBox="0 0 48 48"
14+
fill="none"
15+
{...rest}
16+
>
17+
<Mask id="mask0_1_1346" maskUnits="userSpaceOnUse" x="0" y="0" width="48" height="48">
18+
<Rect width="48" height="48" fill="#D9D9D9" />
19+
</Mask>
20+
<G mask="url(#mask0_1_1346)">
21+
<Path
22+
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"
23+
fill={'currentColor'}
24+
/>
25+
</G>
26+
</Svg>
27+
)
28+
}
29+
30+
const IconRocket = memo<IconProps>(themed(Rocket))
31+
export { IconRocket }

0 commit comments

Comments
 (0)