Skip to content

Commit

Permalink
remove provider type from companion app
Browse files Browse the repository at this point in the history
  • Loading branch information
frontendphil committed Jan 30, 2025
1 parent f13b76c commit af11179
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 416 deletions.
9 changes: 2 additions & 7 deletions deployables/app/app/components/wallet/Connect.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { ProviderType, type HexAddress } from '@zodiac/schema'
import { type HexAddress } from '@zodiac/schema'
import { Labeled, PrimaryButton } from '@zodiac/ui'
import { ConnectKitButton, ConnectKitProvider } from 'connectkit'
import { useAccountEffect } from 'wagmi'

export type OnConnectArgs = {
providerType: ProviderType
address: HexAddress
}

Expand All @@ -14,7 +13,7 @@ type ConnectProps = {

export const Connect = ({ onConnect }: ConnectProps) => {
useAccountEffect({
onConnect({ address, connector, isReconnected }) {
onConnect({ address, isReconnected }) {
if (isReconnected) {
return
}
Expand All @@ -25,10 +24,6 @@ export const Connect = ({ onConnect }: ConnectProps) => {

onConnect({
address,
providerType:
connector.type === 'injected'
? ProviderType.InjectedWallet
: ProviderType.WalletConnect,
})
},
})
Expand Down
12 changes: 4 additions & 8 deletions deployables/app/app/components/wallet/ConnectWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ZERO_ADDRESS } from '@zodiac/chains'
import { type HexAddress, ProviderType } from '@zodiac/schema'
import { type HexAddress } from '@zodiac/schema'
import { useEffect, useRef } from 'react'
import { type ChainId } from 'ser-kit'
import { useAccount, useAccountEffect, useDisconnect } from 'wagmi'
Expand Down Expand Up @@ -79,7 +79,7 @@ const useAutoReconnect = ({
currentConnectedAddress,
onConnect,
}: UseAutoReconnectOptions) => {
const { address, connector } = useAccount()
const { address } = useAccount()

const accountConnected =
currentConnectedAddress != null && currentConnectedAddress !== ZERO_ADDRESS
Expand All @@ -91,7 +91,7 @@ const useAutoReconnect = ({
}, [onConnect])

useEffect(() => {
if (address == null || connector == null) {
if (address == null) {
return
}

Expand All @@ -105,10 +105,6 @@ const useAutoReconnect = ({

onConnectRef.current({
address,
providerType:
connector.type === 'injected'
? ProviderType.InjectedWallet
: ProviderType.WalletConnect,
})
}, [accountConnected, address, connector])
}, [accountConnected, address])
}
5 changes: 1 addition & 4 deletions deployables/app/app/routes/edit-route.$data.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
updateRoleId,
} from '@zodiac/modules'
import type { initSafeApiKit } from '@zodiac/safe'
import { encode, ProviderType } from '@zodiac/schema'
import { encode } from '@zodiac/schema'
import {
createMockEndWaypoint,
createMockEoaAccount,
Expand Down Expand Up @@ -172,7 +172,6 @@ describe('Edit route', () => {
createMockEoaAccount({ address: randomAddress() }),
),
],
providerType: ProviderType.InjectedWallet,
})

await render(`/edit-route/${encode(route)}`)
Expand All @@ -196,7 +195,6 @@ describe('Edit route', () => {
createMockEoaAccount({ address: randomAddress() }),
),
}),
providerType: ProviderType.InjectedWallet,
})

await render(`/edit-route/${encode(route)}`)
Expand Down Expand Up @@ -352,7 +350,6 @@ describe('Edit route', () => {
waypoints: createMockWaypoints({
waypoints: [createMockRoleWaypoint({ moduleAddress, version: 1 })],
}),
providerType: ProviderType.InjectedWallet,
})

await render(`/edit-route/${encode(route)}`)
Expand Down
15 changes: 2 additions & 13 deletions deployables/app/app/routes/edit-route.$data.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import {
updateAvatar,
updateChainId,
updateLabel,
updateProviderType,
updateRoleId,
updateRolesWaypoint,
updateStartingPoint,
Expand All @@ -37,8 +36,6 @@ import {
} from '@zodiac/modules'
import {
jsonStringify,
ProviderType,
providerTypeSchema,
type ExecutionRoute,
type Waypoints,
} from '@zodiac/schema'
Expand Down Expand Up @@ -73,7 +70,6 @@ export const loader = ({ params }: Route.LoaderArgs) => {
label: route.label,
chainId,
avatar: route.avatar,
providerType: route.providerType,
waypoints: route.waypoints,
isDev: process.env.NODE_ENV === 'development',
}
Expand Down Expand Up @@ -157,15 +153,12 @@ export const clientAction = async ({
const route = parseRouteData(params.data)

const address = getHexString(data, 'address')
const providerType = verifyProviderType(getInt(data, 'providerType'))
const account = await createAccount(
jsonRpcProvider(getChainId(route.avatar)),
address,
)

return editRoute(
updateStartingPoint(updateProviderType(route, providerType), account),
)
return editRoute(updateStartingPoint(route, account))
}
case Intent.DisconnectWallet: {
const route = parseRouteData(params.data)
Expand Down Expand Up @@ -202,12 +195,11 @@ const EditRoute = ({
<ConnectWallet
chainId={chainId}
pilotAddress={optimisticRoute.pilotAddress}
onConnect={({ address, providerType }) => {
onConnect={({ address }) => {
submit(
formData({
intent: Intent.ConnectWallet,
address,
providerType,
}),
{ method: 'POST' },
)
Expand Down Expand Up @@ -383,6 +375,3 @@ const getMultisend = (route: ExecutionRoute, module: ZodiacModule) => {

invariant(false, `Cannot get multisend for module type "${module.type}"`)
}

const verifyProviderType = (value: number): ProviderType =>
providerTypeSchema.parse(value)
1 change: 0 additions & 1 deletion packages/modules/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export { decodeRoleKey, encodeRoleKey } from './roleKey'
export { updateAvatar } from './updateAvatar'
export { updateChainId } from './updateChainId'
export { updateLabel } from './updateLabel'
export { updateProviderType } from './updateProviderType'
export { updateRoleId } from './updateRoleId'
export { updateRolesWaypoint } from './updateRolesWaypoint'
export { updateStartingPoint } from './updateStartingPoint'
Expand Down
Loading

0 comments on commit af11179

Please sign in to comment.