Skip to content

Commit

Permalink
fixing libp2p bugs, upgrading libp2p
Browse files Browse the repository at this point in the history
  • Loading branch information
brossetti1 committed Apr 11, 2023
1 parent 323a486 commit e12cf46
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ const SwitchAndPayAcknowledgement: React.FC<SwitchAndPayAcknowledgementProps> =
const { chain } = useNetwork();
const [localState, setLocalState] = useLocalStorage();
const [isMounted, setIsMounted] = useState(false);
console.log(signer);

const registryContract = StolenWalletRegistryFactory.connect(
CONTRACT_ADDRESSES?.[chain?.name!].StolenWalletRegistry as string,
Expand All @@ -38,7 +37,6 @@ const SwitchAndPayAcknowledgement: React.FC<SwitchAndPayAcknowledgementProps> =
});

const { v, r, s } = ethers.utils.splitSignature(storedSignature.value);

const tx = await registryContract.acknowledgementOfRegistry(
storedSignature.deadline,
storedSignature.nonce,
Expand All @@ -49,7 +47,6 @@ const SwitchAndPayAcknowledgement: React.FC<SwitchAndPayAcknowledgementProps> =
);

const receipt = await tx.wait();

setLocalState({ acknowledgementReceipt: JSON.stringify(receipt) });
console.log(receipt);
setLoading(false);
Expand Down
3 changes: 3 additions & 0 deletions components/WebRtcRegistration/Registeree/RegisterAndSign.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ const RegisterAndSign: React.FC<RegisterAndSignProps> = ({
}

const streamData = {
keyRef: REGISTRATION_KEY,
chainId: chain?.id!,
address: address!,
value: typedSignature?.data!,
deadline,
nonce,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const AcknowledgementPayment: React.FC<AcknowledgementPaymentProps> = ({ libp2p,
const deadline = ethers.BigNumber.from(storedSignature.deadline);
const nonce = ethers.BigNumber.from(storedSignature.nonce);
const { v, r, s } = ethers.utils.splitSignature(storedSignature.value);

const tx = await registryContract.acknowledgementOfRegistry(
deadline,
nonce,
Expand Down
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,18 @@
"test:unit": "jest"
},
"dependencies": {
"@chainsafe/libp2p-noise": "^10.0.1",
"@chainsafe/libp2p-noise": "^11.0.4",
"@chakra-ui/icons": "^2.0.18",
"@chakra-ui/react": "^2.5.5",
"@chakra-ui/system": "^2.5.5",
"@chakra-ui/theme-tools": "^2.0.16",
"@emotion/react": "^11.10.6",
"@emotion/styled": "^11.10.6",
"@libp2p/bootstrap": "^5.0.0",
"@libp2p/mplex": "^7.0.0",
"@libp2p/peer-id-factory": "^1.0.19",
"@libp2p/webrtc-star": "^5.0.3",
"@libp2p/webrtc-star-signalling-server": "^2.0.5",
"@libp2p/bootstrap": "^6.0.3",
"@libp2p/mplex": "^7.1.3",
"@libp2p/peer-id-factory": "^2.0.3",
"@libp2p/webrtc-star": "^6.0.0",
"@libp2p/webrtc-star-signalling-server": "^3.0.0",
"@libp2p/websockets": "^5.0.0",
"@rainbow-me/rainbowkit": "^0.8.1",
"@svgr/webpack": "^6.5.0",
Expand Down
2 changes: 1 addition & 1 deletion pages/dapp/p2pRelay/connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ export const Connection = () => {
break;
case PROTOCOLS.REG_SIG:
setSignatureLocalStorage(parsedData as setLocalStorageProps);

const data = accessLocalStorage();
// TODO - resolve window.libp2p for libp2p instance
await passStreamData({
libp2p: window.libp2p,
Expand Down
1 change: 0 additions & 1 deletion utils/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ export const setSignatureWithExpiry = ({
const time = ttl; // .toNumber() + oneHour;
const item = {
value: value,

deadline: time,
startTime: new Date(Date.now() + 1 * 60 * 1000), // TODO come back to this and insert startTime.
deadlineDate: new Date(Date.now() + 6 * 60 * 1000), // TODO come back to this and insert deadline.
Expand Down

0 comments on commit e12cf46

Please sign in to comment.