From 26362263505b9371a0d91fcd2ebe8f57a4efede0 Mon Sep 17 00:00:00 2001 From: poocart <7067483+poocart@users.noreply.github.com> Date: Wed, 25 Oct 2023 14:21:32 +0300 Subject: [PATCH] fixed accountTemplate type --- src/components/EtherspotTransactionKit.tsx | 7 +++++-- src/providers/EtherspotContextProvider.tsx | 7 +++++-- src/types/EtherspotTransactionKit.ts | 2 ++ 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/components/EtherspotTransactionKit.tsx b/src/components/EtherspotTransactionKit.tsx index d110bc9..2170d24 100644 --- a/src/components/EtherspotTransactionKit.tsx +++ b/src/components/EtherspotTransactionKit.tsx @@ -1,15 +1,18 @@ import React from 'react'; import { WalletProviderLike, Factory } from '@etherspot/prime-sdk'; -import EtherspotContextProvider from '../providers/EtherspotContextProvider'; + +// types +import { AccountTemplate } from '../types/EtherspotTransactionKit'; // providers import EtherspotTransactionKitContextProvider from '../providers/EtherspotTransactionKitContextProvider'; import ProviderWalletContextProvider from '../providers/ProviderWalletContextProvider'; +import EtherspotContextProvider from '../providers/EtherspotContextProvider'; interface EtherspotTransactionKitProps extends React.PropsWithChildren { provider: WalletProviderLike; chainId?: number; - accountTemplate?: Factory; + accountTemplate?: AccountTemplate; } const EtherspotTransactionKit = ({ diff --git a/src/providers/EtherspotContextProvider.tsx b/src/providers/EtherspotContextProvider.tsx index 36098a0..8701753 100644 --- a/src/providers/EtherspotContextProvider.tsx +++ b/src/providers/EtherspotContextProvider.tsx @@ -15,6 +15,9 @@ import React, { // contexts import EtherspotContext from '../contexts/EtherspotContext'; +// types +import { AccountTemplate } from '../types/EtherspotTransactionKit'; + let sdkPerChain: { [chainId: number]: PrimeSdk } = {}; const EtherspotContextProvider = ({ @@ -26,7 +29,7 @@ const EtherspotContextProvider = ({ children: ReactNode; provider: WalletProviderLike; chainId: number; - accountTemplate: Factory; + accountTemplate: AccountTemplate; }) => { const context = useContext(EtherspotContext); @@ -49,7 +52,7 @@ const EtherspotContextProvider = ({ const sdkForChain = new PrimeSdk(provider, { chainId: sdkChainId, projectKey: '__ETHERSPOT_PROJECT_KEY__' || undefined, - factoryWallet: accountTemplate, + factoryWallet: accountTemplate as Factory, }); sdkPerChain = { diff --git a/src/types/EtherspotTransactionKit.ts b/src/types/EtherspotTransactionKit.ts index e0d0b99..fa7be89 100644 --- a/src/types/EtherspotTransactionKit.ts +++ b/src/types/EtherspotTransactionKit.ts @@ -121,3 +121,5 @@ interface UserOp { paymasterAndData: EtherspotPromiseOrValue; signature: EtherspotPromiseOrValue; } + +export type AccountTemplate = 'etherspot' | 'zeroDev' | 'simpleAccount';