Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3352245
D6326.id21156.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D6326.id21156.diff
View Options
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
Details
Attached
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)
Attached To
Mode
D6326: [web] Have user sign SIWEMessage with wallet and hit `siwe_auth` endpoint
Attached
Detach File
Event Timeline
Log In to Comment