-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: tomiir <rocchitomas@gmail.com> Co-authored-by: Sven <38101365+svenvoskamp@users.noreply.github.com> Co-authored-by: Sven <fr.sven.fr@gmail.com>
- Loading branch information
1 parent
dae7026
commit 543585f
Showing
174 changed files
with
5,267 additions
and
1,999 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
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,18 @@ | ||
import type { Meta } from '@storybook/web-components' | ||
import '@web3modal/ui/src/composites/wui-select' | ||
import type { WuiSelect } from '@web3modal/ui/src/composites/wui-select' | ||
import { html } from 'lit' | ||
import { networkImageSrc } from '../../utils/PresetUtils' | ||
|
||
type Component = Meta<WuiSelect> | ||
|
||
export default { | ||
title: 'Composites/wui-select', | ||
args: { | ||
imageSrc: networkImageSrc | ||
} | ||
} as Component | ||
|
||
export const Default: Component = { | ||
render: args => html`<wui-select imageSrc=${args.imageSrc}></wui-select>` | ||
} |
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
98 changes: 98 additions & 0 deletions
98
apps/laboratory/src/components/Ethers/Ethers5GetCallsStatusTest.tsx
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,98 @@ | ||
import { Button, Stack, Text, Input } from '@chakra-ui/react' | ||
import { useState } from 'react' | ||
import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers5/react' | ||
import { EthereumProvider } from '@walletconnect/ethereum-provider' | ||
import { useChakraToast } from '../Toast' | ||
import { ethers } from 'ethers5' | ||
import { W3mFrameProvider } from '@web3modal/wallet' | ||
import { type GetCallsStatusParams } from '../../types/EIP5792' | ||
import { EIP_5792_RPC_METHODS } from '../../utils/EIP5792Utils' | ||
|
||
export function Ethers5GetCallsStatusTest() { | ||
const [isLoading, setLoading] = useState(false) | ||
const [batchCallId, setBatchCallId] = useState('') | ||
|
||
const { address, chainId, isConnected } = useWeb3ModalAccount() | ||
const { walletProvider } = useWeb3ModalProvider() | ||
const toast = useChakraToast() | ||
|
||
async function onGetCallsStatus() { | ||
try { | ||
setLoading(true) | ||
if (!walletProvider || !address) { | ||
throw Error('user is disconnected') | ||
} | ||
if (!chainId) { | ||
throw Error('chain not selected') | ||
} | ||
if (!batchCallId) { | ||
throw Error('call id not valid') | ||
} | ||
const provider = new ethers.providers.Web3Provider(walletProvider, chainId) | ||
const batchCallsStatus = await provider.send(EIP_5792_RPC_METHODS.WALLET_GET_CALLS_STATUS, [ | ||
batchCallId as GetCallsStatusParams | ||
]) | ||
toast({ | ||
title: 'Success', | ||
description: JSON.stringify(batchCallsStatus), | ||
type: 'success' | ||
}) | ||
} catch { | ||
toast({ | ||
title: 'Error', | ||
description: 'Failed to get call status', | ||
type: 'error' | ||
}) | ||
} finally { | ||
setLoading(false) | ||
} | ||
} | ||
function isGetCallsStatusSupported(): boolean { | ||
// We are currently checking capabilities above. We should use those capabilities instead of this check. | ||
if (walletProvider instanceof W3mFrameProvider) { | ||
return true | ||
} | ||
if (walletProvider instanceof EthereumProvider) { | ||
return Boolean( | ||
walletProvider?.signer?.session?.namespaces?.['eip155']?.methods?.includes( | ||
EIP_5792_RPC_METHODS.WALLET_GET_CALLS_STATUS | ||
) | ||
) | ||
} | ||
|
||
return false | ||
} | ||
|
||
if (!isConnected || !address || !walletProvider) { | ||
return ( | ||
<Text fontSize="md" color="yellow"> | ||
Wallet not connected | ||
</Text> | ||
) | ||
} | ||
if (!isGetCallsStatusSupported()) { | ||
return ( | ||
<Text fontSize="md" color="yellow"> | ||
Wallet does not support wallet_getCallsStatus rpc method | ||
</Text> | ||
) | ||
} | ||
|
||
return ( | ||
<Stack direction={['column', 'column', 'row']}> | ||
<Input | ||
placeholder="0xf34ffa..." | ||
onChange={e => setBatchCallId(e.target.value)} | ||
value={batchCallId} | ||
isDisabled={isLoading} | ||
/> | ||
<Button | ||
data-testid="get-calls-status-button" | ||
onClick={onGetCallsStatus} | ||
isDisabled={isLoading} | ||
> | ||
Get Calls Status | ||
</Button> | ||
</Stack> | ||
) | ||
} |
33 changes: 33 additions & 0 deletions
33
apps/laboratory/src/components/Ethers/Ethers5ModalInfo.tsx
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,33 @@ | ||
import * as React from 'react' | ||
import { useWeb3ModalAccount, useWeb3ModalProvider } from '@web3modal/ethers5/react' | ||
import EthereumProvider from '@walletconnect/ethereum-provider' | ||
|
||
import { AppKitInfo } from '../AppKitInfo' | ||
|
||
export function Ethers5ModalInfo() { | ||
const { isConnected, address, chainId } = useWeb3ModalAccount() | ||
const [ready, setReady] = React.useState(false) | ||
const [clientId, setClientId] = React.useState<string | null>(null) | ||
const { walletProvider, walletProviderType } = useWeb3ModalProvider() | ||
async function getClientId() { | ||
if (walletProviderType === 'walletConnect') { | ||
const ethereumProvider = walletProvider as unknown as EthereumProvider | ||
|
||
return await ethereumProvider?.signer?.client?.core?.crypto?.getClientId() | ||
} | ||
|
||
return null | ||
} | ||
|
||
React.useEffect(() => { | ||
getClientId().then(setClientId) | ||
}, [walletProvider]) | ||
|
||
React.useEffect(() => { | ||
setReady(true) | ||
}, []) | ||
|
||
return ready && isConnected ? ( | ||
<AppKitInfo address={address} chainId={chainId} clientId={clientId} /> | ||
) : null | ||
} |
Oops, something went wrong.