Page MenuHomePhabricator

D6326.id21156.diff
No OneTemporary

D6326.id21156.diff

diff --git a/web/account/siwe.react.js b/web/account/siwe.react.js
--- a/web/account/siwe.react.js
+++ b/web/account/siwe.react.js
@@ -9,6 +9,7 @@
RainbowKitProvider,
useConnectModal,
} from '@rainbow-me/rainbowkit';
+import invariant from 'invariant';
import _merge from 'lodash/fp/merge';
import * as React from 'react';
import { FaEthereum } from 'react-icons/fa';
@@ -16,6 +17,7 @@
chain,
configureChains,
createClient,
+ useAccount,
useSigner,
WagmiConfig,
} from 'wagmi';
@@ -31,7 +33,11 @@
useDispatchActionPromise,
useServerCall,
} from 'lib/utils/action-utils';
-import { siweMessageSigningExplanationStatements } from 'lib/utils/siwe-utils.js';
+import {
+ createSIWEMessage,
+ siweMessageSigningExplanationStatements,
+ siweStatementWithoutPublicKey,
+} from 'lib/utils/siwe-utils.js';
import Button from '../components/button.react';
import LoadingIndicator from '../loading-indicator.react';
@@ -63,6 +69,7 @@
);
function SIWE(): React.Node {
const { openConnectModal } = useConnectModal();
+ const { address } = useAccount();
const { data: signer } = useSigner();
const dispatchActionPromise = useDispatchActionPromise();
const getSIWENonceCall = useServerCall(getSIWENonce);
@@ -91,6 +98,16 @@
[],
);
+ const onSignInButtonClick = React.useCallback(async () => {
+ invariant(siweNonce, 'nonce must be present during SIWE attempt');
+ const message = createSIWEMessage(
+ address,
+ siweStatementWithoutPublicKey,
+ siweNonce,
+ );
+ await signer.signMessage(message);
+ }, [address, signer, siweNonce]);
+
let siweLoginForm;
if (signer && !siweNonce) {
siweLoginForm = (
@@ -109,7 +126,7 @@
</div>
<p>{siweMessageSigningExplanationStatements[0]}</p>
<p>{siweMessageSigningExplanationStatements[1]}</p>
- <Button variant="filled" type="submit" onClick={undefined}>
+ <Button variant="filled" onClick={onSignInButtonClick}>
Sign in
</Button>
</div>

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 24, 5:15 AM (20 h, 39 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2574062
Default Alt Text
D6326.id21156.diff (1 KB)

Event Timeline