Skip to content

Commit 23e0254

Browse files
committed
fix: use aa
1 parent 2c79fe1 commit 23e0254

1 file changed

Lines changed: 24 additions & 4 deletions

File tree

modules/web3/hooks/use-aa.ts

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
11
import { useCapabilities } from 'wagmi';
22
import { useDappStatus } from './use-dapp-status';
33

4+
const isCapabilitySupported = (capability?: {
5+
supported?: boolean;
6+
status?: 'supported' | 'ready' | 'unsupported';
7+
}) => {
8+
if (!capability) return false;
9+
10+
if (typeof capability.status === 'string') {
11+
return capability.status != 'unsupported';
12+
}
13+
14+
return !!capability.supported;
15+
};
16+
417
export const useAA = () => {
518
const { chainId, isAccountActive } = useDappStatus();
619
const capabilitiesQuery = useCapabilities({
@@ -17,11 +30,18 @@ export const useAA = () => {
1730
}
1831
: undefined;
1932

20-
// per EIP-5792 ANY successful call to getCapabilities is a sign of EIP support
21-
const isAA = capabilitiesQuery.isFetched && !!capabilitiesQuery.data;
33+
const isAtomicBatchSupported =
34+
isCapabilitySupported(capabilities?.atomic) ||
35+
// legacy
36+
isCapabilitySupported(capabilities?.atomicBatch);
37+
38+
const areAuxiliaryFundsSupported = isCapabilitySupported(
39+
capabilities?.auxiliaryFunds,
40+
);
2241

23-
const isAtomicBatchSupported = !!capabilities?.atomicBatch?.supported;
24-
const areAuxiliaryFundsSupported = !!capabilities?.auxiliaryFunds?.supported;
42+
// per EIP-5792 ANY successful call to getCapabilities is a sign of EIP support
43+
// but MM is not following the spec properly
44+
const isAA = capabilitiesQuery.isFetched && isAtomicBatchSupported;
2545

2646
return {
2747
...capabilitiesQuery,

0 commit comments

Comments
 (0)