Skip to content

Commit

Permalink
fixing multiple bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
brossetti1 committed Apr 11, 2023
1 parent a704863 commit 323a486
Show file tree
Hide file tree
Showing 11 changed files with 28 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const SwitchAndPayAcknowledgement: React.FC<SwitchAndPayAcknowledgementProps> =
return (
<RegistrationSection title="Pay for Acknowledgement">
<Flex flexDirection="column">
<Text>Sign and Pay for Acknowledgement from {localState.trustedRelayer}</Text>
{/* <Text>Sign and Pay for Acknowledgement from {localState.trustedRelayer}</Text> */}
<Text mb={5}>Sign and Pay for Acknowledgement from {localState.address}</Text>
</Flex>
<Flex justifyContent="flex-end" gap={5}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const SwitchAndPayRegistration: React.FC<SwitchAndPayRegistrationProps> = ({
{expiryBlock && <Timer expiryBlock={expiryBlock} setExpiryStep={setExpiryStep} />}
<Flex flexDirection="column">
<Text>Sign and Pay for Registration from {localState.trustedRelayer}</Text>
<Text mb={5}>Sign and Pay for Registration from {localState.address}</Text>
{/* <Text mb={5}>Sign and Pay for Registration from {localState.address}</Text> */}
</Flex>
<Flex justifyContent="flex-end" gap={5}>
<Button isLoading={loading} onClick={signAndPay}>
Expand Down
10 changes: 8 additions & 2 deletions components/SharedRegistration/Requirements.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,13 @@ import { useNetwork } from 'wagmi';

import capitalize from 'lodash/capitalize';
import useLocalStorage from '@hooks/useLocalStorage';
import { RegistrationValues, StandardSteps, SelfRelaySteps, RegistrationTypes } from '@utils/types';
import {
RegistrationValues,
StandardSteps,
SelfRelaySteps,
RegistrationTypes,
registrationTitles,
} from '@utils/types';
import router from 'next/router';
import WebRTCStarInstructions from '@components/WebRtcRegistration/WebRTCStarInstructions';
import Loader from '@components/Loader';
Expand Down Expand Up @@ -125,7 +131,7 @@ const Requirements: React.FC<RequirementProps> = ({ address, isConnected, regist
};

return (
<RegistrationSection title={`${capitalize(registrationType)} Registration`}>
<RegistrationSection title={`${registrationTitles[registrationType]} Registration`}>
<Box pb={10}>Requirements:</Box>
{registrationType === 'standardRelay' && <StandardRequirements />}
{registrationType === 'selfRelay' && <SelfRelayRequirements />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const AcknowledgeAndSign: React.FC<AcknowledgeAndSignProps> = ({
}

const signatureData = {
signature: typedSignature?.data!,
value: typedSignature?.data!,
deadline,
nonce,
address: localState.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const RegisterAndSign: React.FC<RegisterAndSignProps> = ({
}

const streamData = {
signature: typedSignature?.data!,
value: typedSignature?.data!,
deadline,
nonce,
};
Expand Down
5 changes: 2 additions & 3 deletions hooks/useRegBlocksLeft.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ const useRegBlocksLeft = (address: string, signer: Signer) => {

const fetchDeadlineBlocks = async () => {
try {
const [currentBlock, expiry, start, graceBlcoks, deadlineBlcoks, isExpired] =
const [currentBlock, expiry, start, graceBlocks, deadlineBlcoks, isExpired] =
await registryContract.getDeadlines(address);

setExpiryBlock(expiry);
setStartBlock(start);
setExpired(isExpired);

const nums = [currentBlock, expiry, start, graceBlcoks, deadlineBlcoks].map((n) =>
const nums = [currentBlock, expiry, start, graceBlocks, deadlineBlcoks].map((n) =>
n.toNumber()
);

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@rainbow-me/rainbowkit": "^0.8.1",
"@svgr/webpack": "^6.5.0",
"@wagmi/core": "^0.9.5",
"@wallet-hygiene/swr-contracts": "^0.0.84",
"@wallet-hygiene/swr-contracts": "^0.0.85",
"axios": "^0.26.1",
"date-fns": "^2.29.3",
"ethers": "^5.7.2",
Expand Down
2 changes: 2 additions & 0 deletions pages/dapp/p2pRelay/connection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export const Connection = () => {
}

const parsedData: RelayerMessageProps = JSON.parse(data);
console.log(parsedData);
switch (stream.stat.protocol) {
case PROTOCOLS.CONNECT:
handleRelayerCallback({ ...parsedData, step: P2PRegistereeSteps.AcknowledgeAndSign });
Expand Down Expand Up @@ -164,6 +165,7 @@ export const Connection = () => {

break;
case PROTOCOLS.ACK_SIG:
console.log(parsedData);
setSignatureLocalStorage(parsedData as setLocalStorageProps);

setLocalStorage({
Expand Down
1 change: 1 addition & 0 deletions pages/dapp/selfRelay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const SelfRelayRegistration: React.FC<SelfRelayRegistrationInterface> = () => {

const setNextStep = () => {
setLocalState({
address: address!,
trustedRelayer: tempRelayer,
step: SelfRelaySteps.SwitchAndPayOne,
});
Expand Down
7 changes: 4 additions & 3 deletions utils/signature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const setSignatureLocalStorage = ({
deadline,
nonce,
}: setLocalStorageProps) => {
console.log(keyRef, chainId, address, value, deadline, nonce);
const item = {
value,
deadline,
Expand Down Expand Up @@ -147,7 +148,7 @@ interface Domain712 {
version: string;
chainId: number;
verifyingContract: string;
salt: String0x;
salt: String0x;
}
export interface signTypedDataProps {
domain: TypedDataDomain;
Expand Down Expand Up @@ -202,7 +203,7 @@ export const buildAcknowledgementStruct = async ({
version: '4',
chainId: chain?.id!,
verifyingContract: CONTRACT_ADDRESSES[chain?.name!].StolenWalletRegistry,
salt: "0xe7e338c8a96606d405ae49875289174c38181bda641043e953b12964ad115f49"
salt: '0xe7e338c8a96606d405ae49875289174c38181bda641043e953b12964ad115f49',
},
value: {
owner: address,
Expand Down Expand Up @@ -250,7 +251,7 @@ export const buildRegistrationStruct = async ({
version: '4',
chainId: chain?.id!,
verifyingContract: CONTRACT_ADDRESSES[chain?.name!].StolenWalletRegistry,
salt: "0x86fdecd3151a18dd477feb379432be4107d347c2ee6bc63ca6212c6d674c17f9"
salt: '0x86fdecd3151a18dd477feb379432be4107d347c2ee6bc63ca6212c6d674c17f9',
},
value: {
owner: address,
Expand Down
6 changes: 6 additions & 0 deletions utils/types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
export type String0x = `0x${string}` | undefined;
export type RegistrationTypes = 'standardRelay' | 'selfRelay' | 'p2pRelay';

export const registrationTitles = {
standardRelay: 'Standard Relay',
selfRelay: 'Self Relay',
p2pRelay: 'P2P Relay',
};

// TODO do these need requirements?
// TODO convert enums to interger values
export enum StandardSteps {
Expand Down

0 comments on commit 323a486

Please sign in to comment.