-
Notifications
You must be signed in to change notification settings - Fork 9
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
[ABW-4001] Update PreAuthorization models #1400
Conversation
RadixWallet/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Outdated
Show resolved
Hide resolved
var timestamp: Date { | ||
switch self { | ||
case let .afterDelay(afterDelay): | ||
Date().addingTimeInterval(TimeInterval(afterDelay.expireAfterSeconds)) |
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.
Date()
? Shouldn't the timestamp be UTC?
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 dearful dates and timezones.. Let me write down my dummy/cautious reasoning to validate the current logic makes sense.
In this case, the subintent will expire X seconds after signature. Let's use 600
(10 minutes) for this example, which we will set using the test dApp.
It is currently 13:54 PM GMT+1
in Madrid. This means that when I get to this state, the timestamp: Date
will return 14:04 GMT+1
.
Given this timestamp
is used on the PollPreAuthorizationStatus+View
, we can validate that after signing the preAuth, the view says that it expires in 9 minutes
(it shows 10 minutes only for a second) and not in -50 minutes
(as it would be in GMT
timezone)
So far so good, now we need to make sure that the value sent to Sargon and then to the dApp makes sense. The process here is:
- convert
Swift.Date
intoSargon.Timestamp
(happens thanks to magic code inuniffi.toml
) - get amount of second since this timestamp and send it to dApp (done here)
Now, if we check the final result sent to the dApp we can see it is 1732799073
.
Then, using a Playground I can confirm this value corresponds to 14:04
in my timezone:
Or if I use a helper tool such as https://www.unixtimestamp.com/ we can verify it is 14:04 GMT+1
and 13:04 GMT
:
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.
given that the same delay applies, regardless of the base, I think this could be safe, unless user goes and changes the date in the settings while the countdown is ticking 😄.
But as we have discussed, the same timestamp that is calculated when creating the Subintent should be used in all places.
RadixWallet/Features/DappInteractionFeature/Coordinator/DappInteractionFlow.swift
Outdated
Show resolved
Hide resolved
RadixWallet/Clients/PreAuthorizationClient/PreAuthorizationClient+Interface.swift
Show resolved
Hide resolved
44bc768
to
beae529
Compare
Jira ticket: ABW-4001
Description
Updates response to include
SubintentHash
andexpirationTimestamp
, which allows us to remove thePreAuthData
helper struct we moved alongDappInteractor
(and children).How to test
Play with Anthic test app and verify everything works as expected.