-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add support for eip5792 getCapabilities and sendCalls #2576
Changes from 57 commits
195855f
2d45778
85919a8
34e4a86
fda468e
6ab8122
f77df04
980497c
ee7c48a
a576a24
0c98ebf
b8b9499
36cb863
4c65e0f
06305e1
894715f
6fa8735
285424f
68f1630
47a5422
be601aa
b733eeb
66d99b1
1d75098
e0f5dc7
1e6c8cf
ce8bf2b
c622501
f092de3
9c3a0b6
d5ab204
aab1d7c
c1bc4a7
5ac735f
c92d110
88e759f
65f90d5
e90884f
e5b7819
408f4c1
3d10166
9312712
30b3bd6
eb3ae4c
28bc815
4a7c7f5
d8c1b0c
e791dd4
667b737
119837e
8b32d8b
93ebbdc
22462c1
a2f690e
2e915da
af3df11
2c8d14b
c29098d
030586a
a859400
d9b9d61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { Button, Stack, Text, Input, Tooltip } from '@chakra-ui/react' | ||
import { useState } from 'react' | ||
import { useState, useEffect } from 'react' | ||
import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers/react' | ||
import { EthereumProvider } from '@walletconnect/ethereum-provider' | ||
import { useChakraToast } from '../Toast' | ||
|
@@ -11,6 +11,7 @@ import { | |
WALLET_CAPABILITIES, | ||
getCapabilitySupportedChainInfo | ||
} from '../../utils/EIP5792Utils' | ||
import { W3mFrameProvider } from '@web3modal/wallet' | ||
|
||
export function EthersSendCallsWithPaymasterServiceTest() { | ||
const [paymasterServiceUrl, setPaymasterServiceUrl] = useState<string>('') | ||
|
@@ -20,14 +21,27 @@ export function EthersSendCallsWithPaymasterServiceTest() { | |
const { walletProvider } = useWeb3ModalProvider() | ||
const toast = useChakraToast() | ||
|
||
const paymasterServiceSupportedChains = | ||
address && walletProvider instanceof EthereumProvider | ||
? getCapabilitySupportedChainInfo( | ||
WALLET_CAPABILITIES.PAYMASTER_SERVICE, | ||
walletProvider, | ||
address | ||
) | ||
: [] | ||
const [paymasterServiceSupportedChains, setPaymasterServiceSupportedChains] = useState< | ||
Awaited<ReturnType<typeof getCapabilitySupportedChainInfo>> | ||
>([]) | ||
|
||
useEffect(() => { | ||
if ( | ||
address && | ||
(walletProvider instanceof EthereumProvider || walletProvider instanceof W3mFrameProvider) | ||
) { | ||
getCapabilitySupportedChainInfo( | ||
WALLET_CAPABILITIES.PAYMASTER_SERVICE, | ||
walletProvider, | ||
address | ||
).then(capabilities => { | ||
setPaymasterServiceSupportedChains(capabilities) | ||
}) | ||
} else { | ||
setPaymasterServiceSupportedChains([]) | ||
} | ||
}, [address, walletProvider]) | ||
|
||
const paymasterServiceSupportedChainNames = paymasterServiceSupportedChains | ||
.map(ci => ci.chainName) | ||
.join(', ') | ||
|
@@ -98,7 +112,8 @@ export function EthersSendCallsWithPaymasterServiceTest() { | |
) | ||
} | ||
|
||
return false | ||
// Replace with capability check | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, is it a todo? Should be replaced with something else? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If it requires more polishing or would be handled in another PR etc, would it be better to give more context to devs? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually a todo yes. Ty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually there's a typing issue. I'll change this in a different PR 🙏 |
||
return walletProvider instanceof W3mFrameProvider | ||
} | ||
|
||
if (!isConnected || !walletProvider || !address) { | ||
|
@@ -137,7 +152,7 @@ export function EthersSendCallsWithPaymasterServiceTest() { | |
</Tooltip> | ||
<Button | ||
width={'fit-content'} | ||
data-test-id="send-calls-paymaster-service-button" | ||
data-testid="send-calls-paymaster-service-button" | ||
onClick={onSendCalls} | ||
isDisabled={isLoading || !paymasterServiceUrl} | ||
> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it a todo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
added a proper comment for following prs