-
Notifications
You must be signed in to change notification settings - Fork 25
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
Sign Auth Entry API & modal flow #949
Conversation
…and related API hooks
subInvocations: RootOutput[]; | ||
} | ||
|
||
export function buildInvocationTree(root: xdr.SorobanAuthorizedInvocation) { |
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.
This can be deleted once the sdk version is out.
@@ -10,6 +10,6 @@ interface BlobProps { | |||
export const Blob = (props: BlobProps) => ( | |||
<Card variant={Card.variant.highlight}> | |||
<Heading4>Signing data:</Heading4> | |||
<div className="Blob">{props.blob}</div> | |||
<div className="Blob">{atob(props.blob)}</div> |
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.
not sure why we didn't decode the b64 blob before, just oversight.
}; | ||
}[]; | ||
}) => { | ||
// TODO: use getters in signTx to get these correctly |
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.
Once we clean up SignTx
to better use the xdr class methods, we should be able to clean this code up a bit and use this component in SignAuthEntry
as well.
@@ -783,15 +816,9 @@ export const Operations = ({ | |||
/> | |||
))} | |||
|
|||
{scFunc ? ( |
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.
This applied the feedback to focus more on the post sim auth then the op.func
values. They hold similar info but the auth invocation better represents the sim results.
There is one more refactor here that I haven't made because this PR is already large but I could be convinced to do it here also. We should split I plan to do this as a separate PR to keep things comprehensible but let me know if you feel strongly that this should happen in this one. |
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.
small set of comments, otherwise lgtm from my perspective but my ✔️ is not so much on the actual Freighter side
type: EXTERNAL_SERVICE_TYPES.SUBMIT_AUTH_ENTRY, | ||
}); | ||
} catch (e) { | ||
console.error(e); |
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.
should this also do response.error = e;
?
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 it's more appropriate to throw here because that would be an implementation error when the other is a type or API error. Added in 63a77ea but let me know if you disagree.
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.
def up to y'all cuz I'm unfamiliar w/ your error-handling conventions, I just more wanted to call out the distinction between exceptions and the response.error field
extension/src/popup/components/signAuthEntry/AuthEntry/index.tsx
Outdated
Show resolved
Hide resolved
@shared/api/external.ts
Outdated
|
||
if (error) { | ||
throw error; | ||
throw error; |
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.
repeated line
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.
whops, thanks for the catch. Fixed in 4b0d05a
@@ -88,18 +89,20 @@ export const AccountHistory = () => { | |||
const stellarExpertUrl = getStellarExpertUrl(networkDetails); | |||
|
|||
// differentiate between if data is still loading and if no account history results came back from Horizon | |||
const shouldLoadToken = | |||
isExperimentalModeEnabled || networkDetails.network === NETWORKS.FUTURENET; |
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.
isn't this more dependent on isExperimentalModeEnabled
? If that flag is true, soroban-client
will be used, but it will use stellar-sdk
if it's false.
Also, since we're going live on Testnet in a few weeks, maybe we should just key this off of isExperimentalModeEnabled
. I'm guessing the Futurenet check is to make sure the data exists (or something like that). Maybe we should gracefully fail if the data isn't found on network
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'm not sure that I understand, how does this toggle the sdk? AFAIk this toggles wether we fetch and add soroban tokens to the account history. The network check is needed because you can be in experimental mode while not being on Futurenet, so as currently implemented it incorrectly shows tokens that are not for the network when on Testnet.
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.
Oh actually - you're right. We're just grabbing the Horizon entry, so we can just use stellar-sdk
here. I was thinking of other places in the app where we do: const SDK = isExperimentalModeEnabled ? SorobanSdk : StellarSdk;
. You can ignore that first part 😛
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.
but still I think also the second part we cannot do right now because the tokens as we store them today have no relation to any network(we should address this before testnet) so when on Testnet but with experimental mode toggled on, you incorrectly see tokens that are on Futurenet without the network check.
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 guess for the second part: I think instead of checking for Futurenet explicitly here, we should adjust the network url that SorobanContext
is using. On closer inspection, looks like SorobanContext
is hardcoded to use Futurenet. So, in getTokenBalances
on ln 162, it's always checking Fututenet.
We should fix that in SorobanContext (but maybe we just do that in a later PR)
This is mostly so when Soroban is running on both Futurenet and Testnet, we have fewer places in the code where we have explicit checks for Futurenet that we have to manually remove
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 must have been writing this at the same time. Yeah we should def be able to configure the SorobanContext for other networks before Testnet support is live. We still can't set the network in the SorobanContext to whatever the current network is here to fix this bug because a) the saved tokens have no relation to a network today, b) There is still only futurenet support so this is incorrect today.
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.
There's def a bigger refactor here to support future networks but this is just meant to address the live bug where we show users the wrong tokens when in experimental mode and not on Futurenet. In order to fix this to work for other networks, we also need to refactor how we store tokens to include network details, then change all token related checks to instead map to tokens that are saved for that network.
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.
Cool - yeah, let's just leave this is as-is then, and we can tackle the network stuff later on
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.
but good call out as I hadn't really considered before this that there will be significant work to support tokens on other networks, and it will include the always hairy work of migrating storage schemas.
} | ||
}, [startedHwSign, hwStatus]); | ||
|
||
useEffect(() => { |
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 something you did a good job of in the PR to add sign-blob was put this "auto-select account/set current account" logic in one place and pass it to different views. I think you should do the same here so we're not repeating this logic in all the 3 sign-X
views
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.
Hmm yeah I chose the repetition because they no longer share a common ancestor where it would make sense to hold common logic. I think the solution now would have to be a wrapper component that does the shared stuff and passes it to a generic child prop. Let me give that a shot then.
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.
Might also work as a custom hook?
Really want to avoid the repetition bc the logic is a little hairy
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.
made a new hook that worked pretty nicely for this in 47ea4f9
} from "popup/ducks/transactionSubmission"; | ||
|
||
export function useSetupSigningFlow( | ||
dispatch: AppDispatch, |
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.
do you need to pass dispatch? or can you just instantiate a new one with useDispatch
? Might make the API a little nicer to have one fewer param
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.
yeah 100%, moved in 06295ca
Ticket: https://stellarorg.atlassian.net/jira/software/c/projects/WAL/boards/36?modal=detail&selectedIssue=WAL-1016&assignee=63bc81730a1b5442166a2f79
This adds a new API
signAuthEntry
and a matching popup flow for signing auth entries.Splits
signTx
andsignBlob
, so now we havesign-transaction
andsign-blob
paths instead of a shared one.Adds
buildInvocationTree
(can be deleted once the sdk version lands) for crawling and unpacking xdr structures from a root invocation. Adds this to theTransaction
component used to render transaction details during signing. Applied feedback to focus more on post simauth
thanop.func
in order to surface the invocation.