Add Emit Function (#113)
Co-authored-by: Ben Kremer <ben@walletconnect.com> Co-authored-by: Vanessa Mercado <finessevanes@Vanessas-MacBook-Pro.local>
This commit is contained in:
parent
4f8d26dda4
commit
8927cddaf9
@ -55,12 +55,13 @@ const SActiveSession = styled(SActiveAccount as any)`
|
||||
|
||||
interface HeaderProps {
|
||||
ping: () => Promise<void>;
|
||||
emit: () => Promise<void>;
|
||||
disconnect: () => Promise<void>;
|
||||
session: SessionTypes.Struct | undefined;
|
||||
}
|
||||
|
||||
const Header = (props: HeaderProps) => {
|
||||
const { ping, disconnect, session } = props;
|
||||
const { ping, disconnect, session, emit } = props;
|
||||
return (
|
||||
<SHeader {...props}>
|
||||
{session ? (
|
||||
@ -82,6 +83,9 @@ const Header = (props: HeaderProps) => {
|
||||
<Button outline color="black" onClick={ping}>
|
||||
{"Ping"}
|
||||
</Button>
|
||||
<Button outline color="black" onClick={emit}>
|
||||
{"Emit"}
|
||||
</Button>
|
||||
<Button outline color="red" onClick={disconnect}>
|
||||
{"Disconnect"}
|
||||
</Button>
|
||||
|
@ -108,6 +108,18 @@ const Home: NextPage = () => {
|
||||
await ping();
|
||||
};
|
||||
|
||||
async function emit() {
|
||||
if (typeof client === "undefined") {
|
||||
throw new Error("WalletConnect is not initialized");
|
||||
}
|
||||
|
||||
await client.emit({
|
||||
topic: session?.topic || '',
|
||||
event: { name: 'chainChanged', data: {} },
|
||||
chainId: 'eip155:5'
|
||||
})
|
||||
}
|
||||
|
||||
const getEthereumActions = (): AccountAction[] => {
|
||||
const onSendTransaction = async (chainId: string, address: string) => {
|
||||
openRequestModal();
|
||||
@ -408,7 +420,7 @@ const Home: NextPage = () => {
|
||||
return (
|
||||
<SLayout>
|
||||
<Column maxWidth={1000} spanHeight>
|
||||
<Header ping={onPing} disconnect={disconnect} session={session} />
|
||||
<Header ping={onPing} disconnect={disconnect} session={session} emit={emit}/>
|
||||
<SContent>{isInitializing ? "Loading..." : renderContent()}</SContent>
|
||||
</Column>
|
||||
<Modal show={!!modal} closeModal={closeModal}>
|
||||
|
Loading…
Reference in New Issue
Block a user