Skip to content

Commit

Permalink
fix init issue in relay-kit
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniSomoza authored and dasanra committed May 16, 2024
1 parent 55e24a6 commit 6702b3d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
5 changes: 4 additions & 1 deletion packages/account-abstraction-kit/src/AccountAbstraction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,10 @@ class AccountAbstraction {
}

#initializeProtocolKit = async () => {
const safeProvider = new SafeProvider({ provider: this.#provider, signer: this.#signer })
const safeProvider = new SafeProvider({
provider: this.#provider,
signer: this.#signer as string
})
const signer = await safeProvider.getSignerAddress()

if (!signer) {
Expand Down
13 changes: 10 additions & 3 deletions packages/protocol-kit/src/SafeProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,23 @@ import {
SafeProviderConfig,
Eip1193Provider,
HttpTransport,
SocketTransport
SocketTransport,
SafeSigner
} from '@safe-global/protocol-kit/types'
import PasskeySigner from './utils/passkeys/PasskeySigner'

class SafeProvider {
#externalProvider: BrowserProvider | JsonRpcProvider
signer?: string | PasskeySigner
signer?: SafeSigner
provider: Eip1193Provider | HttpTransport | SocketTransport

constructor({ provider, signer }: SafeProviderConfig) {
constructor({
provider,
signer
}: {
provider: SafeProviderConfig['provider']
signer?: SafeSigner
}) {
if (typeof provider === 'string') {
this.#externalProvider = new JsonRpcProvider(provider)
} else {
Expand Down
3 changes: 2 additions & 1 deletion packages/protocol-kit/src/types/safeProvider.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import PasskeySigner from '../utils/passkeys/PasskeySigner'
import { passkeyArgType } from './passkeys'

export type RequestArguments = {
readonly method: string
Expand All @@ -18,7 +19,7 @@ export type SafeSigner = HexAddress | PrivateKey | PasskeySigner
export type SafeProviderConfig = {
/** signerOrProvider - Ethers signer or provider */
provider: Eip1193Provider | HttpTransport | SocketTransport
signer?: SafeSigner
signer?: HexAddress | PrivateKey | passkeyArgType
}

export type SafeProviderTransaction = {
Expand Down
1 change: 1 addition & 0 deletions packages/protocol-kit/src/utils/passkeys/PasskeySigner.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { ethers, AbstractSigner, Provider } from 'ethers'
import { Buffer } from 'buffer'

import { PasskeyCoordinates, passkeyArgType } from '../../types/passkeys'
import { SafeWebAuthnSignerFactoryContractImplementationType } from '../../types/contracts'

Expand Down
2 changes: 1 addition & 1 deletion packages/relay-kit/src/packs/safe-4337/Safe4337Pack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export class Safe4337Pack extends RelayKitBasePack<{
])

const multiSendContract = await getMultiSendContract({
safeProvider: new SafeProvider({ provider, signer }),
safeProvider: new SafeProvider({ provider, signer: signer as string }),
safeVersion: options.safeVersion || DEFAULT_SAFE_VERSION
})

Expand Down

0 comments on commit 6702b3d

Please sign in to comment.