CommRustModule bindings and rust client method implementation
Depends on D11084
Paths
| Differential D11098 Authored by varun on Feb 15 2024, 1:30 PM.
Details Summary CommRustModule bindings and rust client method implementation Depends on D11084 Test Plan called the JSI function from JS and successfully retrieved the user ID associated with a wallet address in my local DDB diff --git a/native/account/siwe-panel.react.js b/native/account/siwe-panel.react.js index 02dd3fbed..2b49412d4 100644 --- a/native/account/siwe-panel.react.js +++ b/native/account/siwe-panel.react.js @@ -28,6 +28,7 @@ import { UnknownErrorAlertDetails } from '../utils/alert-messages.js'; import Alert from '../utils/alert.js'; import { getContentSigningKey } from '../utils/crypto-utils.js'; import { defaultLandingURLPrefix } from '../utils/url-utils.js'; +import { commRustModule } from '../native-modules.js'; const commSIWE = `${defaultLandingURLPrefix}/siwe`; @@ -110,6 +111,12 @@ function SIWEPanel(props: Props): React.Node { ); } + const identityUserID = await commRustModule.findUserIDForWalletAddress( + '0xF8b57E5eD505bC6fAfFC765c1AC8569063664c28', + ); + console.log(identityUserID); + const parsedIdentityResponse = JSON.parse(identityUserID); + console.log(parsedIdentityResponse.userID); const ed25519 = await getContentSigningKey(); setPrimaryIdentityPublicKey(ed25519); })(); LOG {"userID":"C81FF954-6216-4489-B23C-0EA145EA2003","isReserved":false} LOG C81FF954-6216-4489-B23C-0EA145EA2003
Diff Detail
Event TimelineHerald added subscribers: tomek, ashoat. · View Herald TranscriptFeb 15 2024, 1:30 PM2024-02-15 13:30:10 (UTC-8) varun edited the test plan for this revision. (Show Details)Feb 15 2024, 1:30 PM2024-02-15 13:30:57 (UTC-8) Harbormaster completed remote builds in B26940: Diff 37281.Feb 15 2024, 1:46 PM2024-02-15 13:46:39 (UTC-8) Comment Actions
Comment Actions
I just updated D11005 to use this, but the gist is, we need to check if a user already exists for a given wallet address so that we can decide whether to call identityWalletLogIn, identityWalletRegister, or onAccountDoesNotExist Initially I wanted to just try login and check for a "does not exist" error, but we remove the nonce from DDB on the login call (i think this is the right thing to do to prevent replay attacks), so the client would have to get a new nonce and sign a new message to subsequently register, which would be a bad user experience.
I initially tried making it more general but because the RPC expects an Identifier enum (with variants WalletAddress and Username), we'd need to pass an enum from C++ to rust, which seemed like more trouble than it was worth.
yes Comment Actions We also need findUserIDForWalletAddress to determine whether to navigate to ExistingEthereumAccount from ConnectEthereum Comment Actions Thanks for explaining!
I'm not so sure about the replay attack stuff. But looking at your code, it seems like FullscreenSIWEPanel is the only place that will need an extra round trip here, and that component should go away after we launch secondary device auth via primary device.
We'll need this one long-term.
Comment Actions Makes sense to me. We can easily refactor this in the future when we find a better way of passing enums JS -> C++ -> Rust
I think @varun just mentioned the same problem we have in the "restore" whitepaper protocol - we want to avoid running the SIWE login procedure twice and it's a bad UX This revision is now accepted and ready to land.Feb 15 2024, 10:23 PM2024-02-15 22:23:09 (UTC-8) Closed by commit rCOMM46366c847b3a: [native] add findUserIDForWalletAddress to CommRustModule (authored by varun). · Explain WhyFeb 16 2024, 7:20 AM2024-02-16 07:20:34 (UTC-8) This revision was automatically updated to reflect the committed changes.
Revision Contents
Diff 37281 native/cpp/CommonCpp/NativeModules/CommRustModule.h
native/cpp/CommonCpp/NativeModules/CommRustModule.cpp
native/cpp/CommonCpp/_generated/rustJSI-generated.cpp
native/cpp/CommonCpp/_generated/rustJSI.h
|