Skip to content

Commit

Permalink
pass undefined aaConfig if it's not enabled on sdk config
Browse files Browse the repository at this point in the history
  • Loading branch information
lionellbriones committed Nov 29, 2024
1 parent a260b04 commit 8a981e5
Showing 1 changed file with 17 additions and 13 deletions.
30 changes: 17 additions & 13 deletions packages/plugins/wallet-services-plugin/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,19 +103,23 @@ export class WalletServicesPlugin extends SafeEventEmitter implements IPlugin {
web3auth.coreOptions.useAAWithExternalWallet &&
(web3auth.connectedAdapterName === WALLET_ADAPTERS.AUTH ||
(web3auth.connectedAdapterName !== WALLET_ADAPTERS.AUTH && web3auth.coreOptions.useAAWithExternalWallet));
const smartAccountAddress = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.smartAccount.address;
const smartAccountType = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.name;
const paymasterConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.paymasterConfig;
const bundlerConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.bundlerConfig;

// TODO: fix this type casting when we start using accountAbstractionController
const accountAbstractionConfig = {
enabled: enableAccountAbstraction,
smartAccountAddress: smartAccountAddress || undefined,
smartAccountType: smartAccountType || undefined,
paymasterConfig: paymasterConfig || undefined,
bundlerConfig: bundlerConfig || undefined,
} as AccountAbstractionConfig;

let accountAbstractionConfig: AccountAbstractionConfig;

if (enableAccountAbstraction) {
const smartAccountAddress = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.smartAccount.address;
const smartAccountType = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config.smartAccountInit.name;
const paymasterConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.paymasterConfig;
const bundlerConfig = (web3auth.coreOptions.accountAbstractionProvider as AccountAbstractionProvider)?.config?.bundlerConfig;

// TODO: fix this type casting when we start using accountAbstractionController
accountAbstractionConfig = {
smartAccountAddress: smartAccountAddress || undefined,
smartAccountType: smartAccountType || undefined,
paymasterConfig: paymasterConfig || undefined,
bundlerConfig: bundlerConfig || undefined,
} as AccountAbstractionConfig;
}

const finalInitOptions = {
...this.walletInitOptions,
Expand Down

0 comments on commit 8a981e5

Please sign in to comment.