UNPKG

@abstract-foundation/agw-client

Version:
32 lines 1.33 kB
import { createClient, createPublicClient, createWalletClient, http, } from 'viem'; import { toAccount } from 'viem/accounts'; import {} from 'viem/zksync'; import { getSmartAccountAddressFromInitialSigner } from './utils.js'; import { globalWalletActions, } from './walletActions.js'; export async function createAbstractClient({ signer, chain, transport, address, isPrivyCrossApp = false, publicTransport = http(undefined, { batch: true, }), customPaymasterHandler, }) { if (!transport) { throw new Error('Transport is required'); } const publicClient = createPublicClient({ chain: chain, transport: publicTransport, }); const smartAccountAddress = address ?? (await getSmartAccountAddressFromInitialSigner(signer.address, publicClient)); const baseClient = createClient({ account: toAccount(smartAccountAddress), chain: chain, transport, }); // Create a signer wallet client to handle actual signing const signerWalletClient = createWalletClient({ account: signer, chain: chain, transport, }); const abstractClient = baseClient.extend(globalWalletActions(signerWalletClient, publicClient, isPrivyCrossApp, customPaymasterHandler)); return abstractClient; } //# sourceMappingURL=abstractClient.js.map