Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: conditions for contract writes #662

Merged
merged 1 commit into from
Sep 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/components/Comment/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,15 +157,15 @@ const NewComment: FC<Props> = ({ hideCard = false, publication }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Crowdfund/New.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -164,15 +164,15 @@ const NewCrowdfund: NextPage = () => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Publication/Actions/Collect/CollectModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -216,15 +216,15 @@ const CollectModule: FC<Props> = ({ count, setCount, publication }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
18 changes: 9 additions & 9 deletions src/components/Publication/Actions/Mirror.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,15 @@ const Mirror: FC<Props> = ({ publication, isFullPublication }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Publication/Crowdfund/Fund.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,15 @@ const Fund: FC<Props> = ({ fund, collectModule, setRevenue, revenue }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Publication/New/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,15 +149,15 @@ const NewPost: FC<Props> = ({ hideCard = false }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Account/SetProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,15 @@ const SetProfile: FC = () => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Account/SuperFollow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,15 @@ const SuperFollow: FC = () => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Dispatcher/ToggleDispatcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,15 @@ const ToggleDispatcher: FC<Props> = ({ buttonSize = 'md' }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Profile/NFTPicture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,15 +104,15 @@ const NFTPicture: FC<Props> = ({ profile }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Profile/Picture.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,15 +92,15 @@ const Picture: FC<Props> = ({ profile }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Settings/Profile/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,15 @@ const Profile: FC<Props> = ({ profile }) => {
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Shared/Follow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,15 @@ const Follow: FC<Props> = ({ profile, showText = false, setFollowing }) => {
datas: followData,
sig
};
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down
16 changes: 8 additions & 8 deletions src/components/Shared/SuperFollow/FollowModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ const FollowModule: FC<Props> = ({ profile, setFollowing, setShowFollowModal, ag
};

setUserSigNonce(userSigNonce + 1);
if (RELAY_ON) {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });
if (!RELAY_ON) {
return write?.({ recklesslySetUnpreparedArgs: inputStruct });
}

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} else {
const {
data: { broadcast: result }
} = await broadcast({ request: { id, signature } });

if ('reason' in result) {
write?.({ recklesslySetUnpreparedArgs: inputStruct });
}
} catch {}
Expand Down