-
Notifications
You must be signed in to change notification settings - Fork 316
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
⚡️ [FEAT] : Integrate Trustchain logic in LedgerSync LLD - V1 #7131
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 5 Skipped Deployments
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some feedbacks
!hasError && stuffHandledByTrustchain(); | ||
}, 3000); | ||
}, [hasError, stuffHandledByTrustchain]); | ||
!hasError && stuffHandledByTrustchain(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
improvements i see:
- we need to handle possible error thrown by stuffHandledByTrustchain and display them to user (using the Generic Error rendering which should tell the user the precise error instead of the UnsecuredError )
- Q: is there a way, as a user, to interrupt the flow? because we don't handle the unsubscribe of these, and it's possible that runWithDevice never ends which can introduce race conditions
const memberCredentials = useSelector(memberCredentialsSelector); | ||
|
||
if (!trustchain || !memberCredentials) { | ||
throw new Error("trustchain or memberCredentials is missing"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dangerous to throw in a hook.
to me, instead we should return a callback that will do nothing if trustchain is falsy, because in that case there will be no more things to delete.
setUrl(url); | ||
}, | ||
onDisplayDigits: digits => { | ||
dispatch(setQrCodePinCode(digits)); // Should we assert that it is a string of 3 digits ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually today it's "3" but it could be something else, this is a config in the protocol of QR Code, it could be changed in future and UI just need to adapt to the number of digits ideally: https://github.com/LedgerHQ/ledger-live/blob/develop/libs/trustchain/src/qrcode/index.ts#L155
const trustchain = useSelector(trustchainSelector); | ||
const memberCredentials = useSelector(memberCredentialsSelector); | ||
|
||
if (!trustchain || !memberCredentials) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think we should be able to useLiveAuthenticate with these falsy, it hsouldn't throw from the hook.
there will be error cases where we will need to reset the trustchain (e.g. when member is ejected)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as auth(trustchain: Trustchain, memberCredentials: MemberCredentials): Promise<JWT>;
We can't :/
7181e83
to
38f3091
Compare
libs/trustchain/src/qrcode/index.ts
Outdated
@@ -34,7 +34,7 @@ export async function createQRCodeHostInstance({ | |||
}): Promise<void> { | |||
const ephemeralKey = await crypto.randomKeypair(); | |||
const publisher = crypto.to_hex(ephemeralKey.publicKey); | |||
const url = `${getEnv("TRUSTCHAIN_API").replace("http", "ws")}/v1/qr?host=${publisher}`; | |||
const url = `${getEnv("TRUSTCHAIN_API")}/v1/qr?host=${publisher}`.replace(/^http/, "ws"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you undo this change? the develop's version is correct
libs/trustchain/src/store.ts
Outdated
}; | ||
|
||
export const getInitialStore = (): TrustchainStore => { | ||
return { | ||
trustchain: null, | ||
memberCredentials: null, | ||
jwt: null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should undo this too, no need to store the jwt anymore
|
apps/ledger-live-desktop/src/newArch/WalletSync/hooks/useTrustchainSdk.ts
Show resolved
Hide resolved
return addMemberMutation.isError ? ( | ||
<ErrorDisplay error={addMemberMutation.error} withExportLogs onRetry={onRetry} /> | ||
) : ( | ||
<FollowStepsOnDevice modelId={device.modelId as DeviceModelId} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<FollowStepsOnDevice modelId={device.modelId as DeviceModelId} /> | |
<FollowStepsOnDevice modelId={device.modelId} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And the import
--------- Co-authored-by: Come Grellard <come.grellard@ledger.fr> Co-authored-by: Gaëtan Renaudeau <renaudeau.gaetan@gmail.com>
--------- Co-authored-by: Come Grellard <come.grellard@ledger.fr> Co-authored-by: Gaëtan Renaudeau <renaudeau.gaetan@gmail.com>
✅ Checklist
npx changeset
was attached.📝 Description
Integrates the trustchain lib and store integration on the actual UI of the trustchain flows
❓ Context
🧐 Checklist for the PR Reviewers