-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: re-type
walletCapabilities
object (#1238)
- Loading branch information
Showing
15 changed files
with
115 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@coinbase/onchainkit': patch | ||
--- | ||
|
||
**feat**: re-typed walletCapabilities object in `OnchainKitConfig`. by @0xAlec #1238 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
// Capabilities | ||
export enum Capabilities { | ||
AtomicBatch = 'atomicBatch', | ||
AuxiliaryFunds = 'auxiliaryFunds', | ||
PaymasterService = 'paymasterService', | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useMemo } from 'react'; | ||
import type { WalletCapabilities } from 'viem'; | ||
import { useAccount } from 'wagmi'; | ||
import { useCapabilities } from 'wagmi/experimental'; | ||
import type { UseCapabilitiesSafeParams } from '../../types'; | ||
|
||
export function useCapabilitiesSafe({ | ||
chainId, | ||
}: UseCapabilitiesSafeParams): WalletCapabilities { | ||
const { isConnected } = useAccount(); | ||
|
||
const { data: capabilities, error } = useCapabilities({ | ||
query: { enabled: isConnected }, | ||
}); | ||
|
||
return useMemo(() => { | ||
if (error || !capabilities || !capabilities[chainId]) { | ||
return {}; | ||
} | ||
|
||
return capabilities[chainId]; | ||
}, [capabilities, chainId, error]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.