-
Notifications
You must be signed in to change notification settings - Fork 481
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(mobile): add integration with gateway backend for notifications feature #4878
base: dev
Are you sure you want to change the base?
Conversation
} | ||
|
||
// Step 1: Generate delegate key | ||
const delegateMnemonic = ethers.Wallet.createRandom().mnemonic?.phrase |
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.
Why do we need mnemonic here? Why don#t we go for creating a random private key?
const wallet = Wallet.createRandom(provider);
console.log(wallet.privatekey)
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.
Good catch. I'll avoid the Mnemonic.
const encryptedDelegateKey = await DeviceCrypto.encrypt(asymmetricKey, delegatedAccount.privateKey, { | ||
biometryTitle: 'Authenticate', | ||
biometrySubTitle: 'Saving delegated key', | ||
biometryDescription: 'Please authenticate yourself', | ||
}) |
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 don't need this kind of protection for the delegate key. It is not going to sign transactions and can be exchanged at any point.
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.
aren't we showing and allowing users to revoke these keys? we can store it on redux only then. wdyt?
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.
No, I meant that we don't need biometry protection. Users should be able to remove the keys as in the old app.
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.
Removed already.
Branch preview✅ Deploy successful! Storybook: |
@@ -90,6 +90,7 @@ | |||
"react-native-device-info": "^14.0.1", | |||
"react-native-draggable-flatlist": "^4.0.1", | |||
"react-native-gesture-handler": "~2.20.2", | |||
"react-native-get-random-values": "^1.11.0", |
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.
before we add this package I would actually want to know why is quick-crypto not doing this. Maybe we are calling the polyfills from it too late?
const signerAccount = ownerPrivateKey ? new Wallet(ownerPrivateKey) : Wallet.createRandom() | ||
|
||
if (!signerAccount) { | ||
throw Logger.error(ERROR_MSG, 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.
this could be moved to a getSignerAccount function
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.
Done.
const ownerPrivateKey = await getPrivateKey() | ||
|
||
try { | ||
if (!ownerAddress || !activeSafe || !nonce || !fcmToken) { |
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.
could be moved to a validate function.
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 that if the try block is structured as:
validateParameters(...)
const ownerPrivateKey = await getPrivateKey(...)
const signerAccount = await createSignerAccount(ownerPrivateKey)
if (!signerAccount) throw new Error(ERROR_MSG)
const siweMessage = generateSiweMessage(...)
// Verify the delegate on the backend and subscribe for notifications.
await verifyAndSubscribeDelegate(...)
it would make it way easier to read and follow
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.
Also what you get is separation of conserns. We abstract everything in small, testable functions. It not only improves readibility, but also makes it easier to unit test.
} | ||
}, []) | ||
|
||
const createOnBackEnd = useCallback( |
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.
maybe something like authenticateAndSubscribeDelate would be more on point?
What it solves
Resolves #
How this PR fixes it
How to test it
Screenshots
Checklist