mirror of
https://github.com/logos-messaging/js-waku.git
synced 2026-01-07 16:23:09 +00:00
Remove dead code
This commit is contained in:
parent
a8b29a2fac
commit
16b79306d5
@ -3,7 +3,6 @@ import '@ethersproject/shims';
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import './App.css';
|
import './App.css';
|
||||||
import { Waku } from 'js-waku';
|
import { Waku } from 'js-waku';
|
||||||
import { Signer } from '@ethersproject/abstract-signer';
|
|
||||||
import { Message } from './messaging/Messages';
|
import { Message } from './messaging/Messages';
|
||||||
import 'fontsource-roboto';
|
import 'fontsource-roboto';
|
||||||
import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core';
|
import { AppBar, IconButton, Toolbar, Typography } from '@material-ui/core';
|
||||||
@ -67,7 +66,6 @@ const useStyles = makeStyles({
|
|||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [waku, setWaku] = useState<Waku>();
|
const [waku, setWaku] = useState<Waku>();
|
||||||
const [signer, setSigner] = useState<Signer>();
|
|
||||||
const [provider, setProvider] = useState<Web3Provider>();
|
const [provider, setProvider] = useState<Web3Provider>();
|
||||||
const [encPublicKey, setEncPublicKey] = useState<Uint8Array>();
|
const [encPublicKey, setEncPublicKey] = useState<Uint8Array>();
|
||||||
const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>(
|
const [publicKeys, setPublicKeys] = useState<Map<string, Uint8Array>>(
|
||||||
@ -193,7 +191,6 @@ function App() {
|
|||||||
<ConnectWallet
|
<ConnectWallet
|
||||||
setProvider={setProvider}
|
setProvider={setProvider}
|
||||||
setAddress={setAddress}
|
setAddress={setAddress}
|
||||||
setSigner={setSigner}
|
|
||||||
/>
|
/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
@ -204,7 +201,6 @@ function App() {
|
|||||||
address={address}
|
address={address}
|
||||||
/>
|
/>
|
||||||
<BroadcastPublicKey
|
<BroadcastPublicKey
|
||||||
signer={signer}
|
|
||||||
address={address}
|
address={address}
|
||||||
encryptionPublicKey={encPublicKey}
|
encryptionPublicKey={encPublicKey}
|
||||||
waku={waku}
|
waku={waku}
|
||||||
|
|||||||
@ -3,13 +3,11 @@ import React from 'react';
|
|||||||
import { createPublicKeyMessage } from './crypto';
|
import { createPublicKeyMessage } from './crypto';
|
||||||
import { PublicKeyMessage } from './messaging/wire';
|
import { PublicKeyMessage } from './messaging/wire';
|
||||||
import { WakuMessage, Waku } from 'js-waku';
|
import { WakuMessage, Waku } from 'js-waku';
|
||||||
import { Signer } from '@ethersproject/abstract-signer';
|
|
||||||
import { PublicKeyContentTopic } from './waku';
|
import { PublicKeyContentTopic } from './waku';
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
encryptionPublicKey: Uint8Array | undefined;
|
encryptionPublicKey: Uint8Array | undefined;
|
||||||
waku: Waku | undefined;
|
waku: Waku | undefined;
|
||||||
signer: Signer | undefined;
|
|
||||||
address: string | undefined;
|
address: string | undefined;
|
||||||
providerRequest:
|
providerRequest:
|
||||||
| ((request: { method: string; params?: Array<any> }) => Promise<any>)
|
| ((request: { method: string; params?: Array<any> }) => Promise<any>)
|
||||||
@ -17,7 +15,6 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export default function BroadcastPublicKey({
|
export default function BroadcastPublicKey({
|
||||||
signer,
|
|
||||||
encryptionPublicKey,
|
encryptionPublicKey,
|
||||||
address,
|
address,
|
||||||
waku,
|
waku,
|
||||||
@ -25,18 +22,12 @@ export default function BroadcastPublicKey({
|
|||||||
}: Props) {
|
}: Props) {
|
||||||
const broadcastPublicKey = () => {
|
const broadcastPublicKey = () => {
|
||||||
if (!encryptionPublicKey) return;
|
if (!encryptionPublicKey) return;
|
||||||
if (!signer) return;
|
|
||||||
if (!address) return;
|
if (!address) return;
|
||||||
if (!waku) return;
|
if (!waku) return;
|
||||||
if (!providerRequest) return;
|
if (!providerRequest) return;
|
||||||
|
|
||||||
console.log('Creating Public Key Message');
|
console.log('Creating Public Key Message');
|
||||||
createPublicKeyMessage(
|
createPublicKeyMessage(address, encryptionPublicKey, providerRequest)
|
||||||
signer,
|
|
||||||
address,
|
|
||||||
encryptionPublicKey,
|
|
||||||
providerRequest
|
|
||||||
)
|
|
||||||
.then((msg) => {
|
.then((msg) => {
|
||||||
console.log('Public Key Message created');
|
console.log('Public Key Message created');
|
||||||
encodePublicKeyWakuMessage(msg)
|
encodePublicKeyWakuMessage(msg)
|
||||||
@ -63,7 +54,7 @@ export default function BroadcastPublicKey({
|
|||||||
variant="contained"
|
variant="contained"
|
||||||
color="primary"
|
color="primary"
|
||||||
onClick={broadcastPublicKey}
|
onClick={broadcastPublicKey}
|
||||||
disabled={!encryptionPublicKey || !waku || !signer}
|
disabled={!encryptionPublicKey || !waku || !address || !providerRequest}
|
||||||
>
|
>
|
||||||
Broadcast Encryption Public Key
|
Broadcast Encryption Public Key
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import { Button } from '@material-ui/core';
|
import { Button } from '@material-ui/core';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Signer } from '@ethersproject/abstract-signer';
|
|
||||||
import { ethers } from 'ethers';
|
import { ethers } from 'ethers';
|
||||||
import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider';
|
import { Web3Provider } from '@ethersproject/providers/src.ts/web3-provider';
|
||||||
|
|
||||||
@ -8,15 +7,10 @@ declare let window: any;
|
|||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
setAddress: (address: string) => void;
|
setAddress: (address: string) => void;
|
||||||
setSigner: (signer: Signer) => void;
|
|
||||||
setProvider: (provider: Web3Provider) => void;
|
setProvider: (provider: Web3Provider) => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ConnectWallet({
|
export default function ConnectWallet({ setAddress, setProvider }: Props) {
|
||||||
setAddress,
|
|
||||||
setSigner,
|
|
||||||
setProvider,
|
|
||||||
}: Props) {
|
|
||||||
const connectWallet = () => {
|
const connectWallet = () => {
|
||||||
try {
|
try {
|
||||||
window.ethereum
|
window.ethereum
|
||||||
@ -25,7 +19,6 @@ export default function ConnectWallet({
|
|||||||
const _provider = new ethers.providers.Web3Provider(window.ethereum);
|
const _provider = new ethers.providers.Web3Provider(window.ethereum);
|
||||||
setAddress(accounts[0]);
|
setAddress(accounts[0]);
|
||||||
setProvider(_provider);
|
setProvider(_provider);
|
||||||
setSigner(_provider.getSigner());
|
|
||||||
});
|
});
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error('No web3 provider available');
|
console.error('No web3 provider available');
|
||||||
|
|||||||
@ -1,6 +1,5 @@
|
|||||||
import '@ethersproject/shims';
|
import '@ethersproject/shims';
|
||||||
|
|
||||||
import { Signer } from '@ethersproject/abstract-signer';
|
|
||||||
import { PublicKeyMessage } from './messaging/wire';
|
import { PublicKeyMessage } from './messaging/wire';
|
||||||
import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils';
|
import { hexToBuf, equalByteArrays, bufToHex } from 'js-waku/lib/utils';
|
||||||
import * as sigUtil from 'eth-sig-util';
|
import * as sigUtil from 'eth-sig-util';
|
||||||
@ -11,7 +10,6 @@ import * as sigUtil from 'eth-sig-util';
|
|||||||
* Ethereum Address holder.
|
* Ethereum Address holder.
|
||||||
*/
|
*/
|
||||||
export async function createPublicKeyMessage(
|
export async function createPublicKeyMessage(
|
||||||
web3Signer: Signer,
|
|
||||||
address: string,
|
address: string,
|
||||||
encryptionPublicKey: Uint8Array,
|
encryptionPublicKey: Uint8Array,
|
||||||
providerRequest: (request: {
|
providerRequest: (request: {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user