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: Migrate to app_id architecture, remove external phone support & more #61

Merged
merged 11 commits into from
Feb 22, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions LENS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ _These instructions assume you're integrating into a React/Next.js app. If you'r

1. Install IDKit JS
```bash
yarn add @worldcoin/idkit
yarn add @worldcoin/idkit@0.3.3
# or
npm install @worldcoin/idkit
npm install @worldcoin/idkit@0.3.3
```
2. Load IDKit JS. Note the action ID below, the Action ID is the **same for all Lens-powered apps.**

Expand Down
158 changes: 0 additions & 158 deletions idkit/src/components/CountryCodeSelect.tsx

This file was deleted.

45 changes: 29 additions & 16 deletions idkit/src/components/IDKitWidget/BaseWidget.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@ import { classNames, getCopy } from '@/lib/utils'
import type { WidgetProps } from '@/types/config'
import { Fragment, useEffect, useMemo } from 'react'
import WorldIDWordmark from '../Icons/WorldIDWordmark'
import EnterPhoneState from './States/EnterPhoneState'
import VerifyCodeState from './States/VerifyCodeState'
import { AnimatePresence, motion } from 'framer-motion'
import ArrowLongLeftIcon from '../Icons/ArrowLongLeftIcon'
import SelectMethodState from './States/SelectMethodState'
import HostAppVerificationState from './States/HostAppVerificationState'

const getParams = ({
Expand All @@ -46,14 +43,14 @@ const getParams = ({
isOpen: open,
onOpenChange,
canGoBack: computed.canGoBack(stage),
defaultStage: computed.getDefaultStage(),
})

const IDKitWidget: FC<WidgetProps> = ({
children,
actionId,
app_id,
action,
action_description,
theme,
methods,
signal,
walletConnectProjectId,
handleVerify,
Expand All @@ -68,7 +65,6 @@ const IDKitWidget: FC<WidgetProps> = ({
stage,
setStage,
canGoBack,
defaultStage,
setOptions,
copy: _copy,
theme: _theme,
Expand All @@ -77,21 +73,38 @@ const IDKitWidget: FC<WidgetProps> = ({

useEffect(() => {
setOptions(
{ actionId, signal, walletConnectProjectId, methods, onSuccess, handleVerify, autoClose, copy, theme },
{
app_id,
action,
action_description,
signal,
walletConnectProjectId,
onSuccess,
handleVerify,
autoClose,
copy,
theme,
},
ConfigSource.PROPS
)
}, [actionId, signal, walletConnectProjectId, methods, onSuccess, theme, handleVerify, autoClose, copy, setOptions])
}, [
copy,
app_id,
action,
theme,
signal,
autoClose,
onSuccess,
setOptions,
handleVerify,
action_description,
walletConnectProjectId,
])

const StageContent = useMemo(() => {
switch (stage) {
case IDKITStage.SELECT_METHOD:
return SelectMethodState
case IDKITStage.ENTER_PHONE:
return EnterPhoneState
case IDKITStage.WORLD_ID:
return WorldIDState
case IDKITStage.ENTER_CODE:
return VerifyCodeState
case IDKITStage.SUCCESS:
return SuccessState
case IDKITStage.ERROR:
Expand Down Expand Up @@ -151,7 +164,7 @@ const IDKitWidget: FC<WidgetProps> = ({
<Toast.Viewport className="flex justify-center" />
<div className="mx-6 mb-12 flex items-center justify-between">
<button
onClick={() => setStage(defaultStage)}
onClick={() => setStage(IDKITStage.WORLD_ID)}
disabled={!canGoBack}
className={classNames(
!canGoBack && 'invisible pointer-events-none',
Expand Down
Loading