Skip to content

Commit

Permalink
Revert "Don't expose sequenceWaasProvider and sequenceWaas on connect…
Browse files Browse the repository at this point in the history
…or use getProvider instead"

This reverts commit cb1769c.
  • Loading branch information
corbanbrook committed May 1, 2024
1 parent cb1769c commit 157aeef
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
1 change: 0 additions & 1 deletion packages/connectors/src/connectors/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@ export * from './mock'
export * from './sequence'
export * from './twitch'
export * from './walletConnect'
export * from './wagmiConnectors'
export * from './types'
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ sequenceWaasWallet.type = 'sequence-waas' as const
export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
type Provider = SequenceWaasProvider
type Properties = {
sequenceWaas: SequenceWaaS
sequenceWaasProvider: SequenceWaasProvider
params: BaseSequenceWaasConnectorOptions
}
type StorageItem = {
Expand Down Expand Up @@ -65,6 +67,8 @@ export function sequenceWaasWallet(params: BaseSequenceWaasConnectorOptions) {
id: `sequence-waas`,
name: 'Sequence WaaS',
type: sequenceWaasWallet.type,
sequenceWaas,
sequenceWaasProvider,
params,

async setup() {
Expand Down
5 changes: 1 addition & 4 deletions packages/kit/src/hooks/useWaasConfirmationHandler.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { commons } from '@0xsequence/core'
import { useState, useEffect } from 'react'
import { Deferred } from '../utils/deferred'
import { SequenceWaasProvider } from '@0xsequence/kit-connectors'

let _pendingConfirmation: Deferred<{ id: string; confirmed: boolean }> | undefined

Expand Down Expand Up @@ -36,14 +35,13 @@ export function useWaasConfirmationHandler(
return
}

const waasProvider = (await waasConnector.getProvider()) as SequenceWaasProvider
const waasProvider = waasConnector.sequenceWaasProvider

if (!waasProvider) {
return
}

waasProvider.requestConfirmationHandler = {
// @ts-ignore-next-line
confirmSignTransactionRequest(
id: string,
txs: commons.transaction.Transaction[],
Expand All @@ -54,7 +52,6 @@ export function useWaasConfirmationHandler(
_pendingConfirmation = pending
return pending.promise
},

confirmSignMessageRequest(id: string, message: string, chainId: number): Promise<{ id: string; confirmed: boolean }> {
const pending = new Deferred<{ id: string; confirmed: boolean }>()
setPendingRequestConfirmation({ id, type: 'signMessage', message, chainId })
Expand Down
9 changes: 3 additions & 6 deletions packages/kit/src/hooks/useWaasEmailAuth.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState } from 'react'
import { ExtendedConnector } from '../utils'
import { SequenceWaasProvider } from '@0xsequence/kit-connectors'

export function useEmailAuth({ connector, onSuccess }: { connector?: ExtendedConnector; onSuccess: (idToken: string) => void }) {
if (!connector) {
Expand All @@ -23,8 +22,7 @@ export function useEmailAuth({ connector, onSuccess }: { connector?: ExtendedCon

try {
const connectorAny: any = connector
const provider = (await connectorAny.getProvider()) as SequenceWaasProvider
const { instance } = await provider.sequenceWaas?.email.initiateAuth({ email })
const { instance } = await connectorAny.sequenceWaas?.email.initiateAuth({ email })
setInstance(instance)
setEmail(email)
} catch (e: any) {
Expand All @@ -39,9 +37,8 @@ export function useEmailAuth({ connector, onSuccess }: { connector?: ExtendedCon

try {
const connectorAny: any = connector
const provider = (await connectorAny.getProvider()) as SequenceWaasProvider
const sessionHash = await provider.sequenceWaas?.getSessionHash()
const { idToken } = await provider.sequenceWaas?.email.finalizeAuth({ instance, answer, email, sessionHash })
const sessionHash = await connectorAny.sequenceWaas?.getSessionHash()
const { idToken } = await connectorAny.sequenceWaas?.email.finalizeAuth({ instance, answer, email, sessionHash })
onSuccess(idToken)
} catch (e: any) {
setError(e.message || 'Unknown error')
Expand Down
4 changes: 2 additions & 2 deletions packages/kit/src/hooks/useWaasFeeOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { Deferred } from '../utils/deferred'
import { Connector, useConnections } from 'wagmi'
import { FeeOption } from '@0xsequence/waas'
import { ethers } from 'ethers'
import { SequenceWaasProvider } from '@0xsequence/kit-connectors'

// null means it's native token
let _pendingFeeConfirmation: Deferred<{ id: string; feeTokenAddress?: string | null; confirmed: boolean }> | undefined
Expand Down Expand Up @@ -42,7 +41,8 @@ export function useWaasFeeOptions(): [
return
}

const waasProvider = (await waasConnector.getProvider()) as SequenceWaasProvider
// @ts-ignore-next-line
const waasProvider = waasConnector.sequenceWaasProvider

if (!waasProvider) {
return
Expand Down

0 comments on commit 157aeef

Please sign in to comment.