Skip to content
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

EPIC | Telos Cloud Login #756

Open
wants to merge 56 commits into
base: develop
Choose a base branch
from
Open

Conversation

Viterbo
Copy link
Collaborator

@Viterbo Viterbo commented Jan 18, 2024

Fixes #752

Mainnet deployment

Description

This epic branch implements the new flow for the Telos Cloud Login functionality split into four incremental steps, each one with its own branch and PR:

1 - Change the flow

In the last prototype, we had two steps to perform a successful login using GoogleOneTap. With this first branch, we changed the flow to just one step. The Google One Tap button is rendered when you arrive at the site.

2 - Zero Account Selector

To cover those rare cases when one user already has more than two accounts associated with the corresponding meta keep public key, this second branch incorporates an account selector interactive step in between the process of logging in with Could Login on Telos Zero.

3 - Zero Account Creation (Name Choise)

in this third branch, we incorporate another interactive step to the login process only for new users who have no account associated with their public key from Metakeep. In this case, we present the user with a simple form with just a field to input the desired name for the account, along with a button to generate a random name.

4 - Greymass Fuel service

In this last branch, we fixed the old implementation of the service to work again, especially for new accounts created with Telos Cloud Login. In this case, we made a few minor changes like removing the confirmation modal to use the service and changing the verification functions because the service now does not charge users for RAM (that is a new policy from Greymass and we needed to adapt the checks to allow that).

Screen captures

Account Selection + Greymass Fuel

telos-cloud-login.webm

Account Creation Form

Telos-cloud-login--acccount-name-input.webm

Confirmation of fee payment

telos-cloud-login--confirm-pay-fee.webm

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have cleaned up the code in the areas my change touches
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings
  • I have removed any unnecessary console messages
  • I have included all English text in the translation file and/or created a new issue with the required translations for the currently supported languages
  • I have tested for mobile functionality and responsiveness
  • I have added appropriate test coverage

@Viterbo Viterbo linked an issue Jan 18, 2024 that may be closed by this pull request
4 tasks
Copy link

netlify bot commented Jan 18, 2024

Deploy Preview for wallet-develop-mainnet ready!

Name Link
🔨 Latest commit 32b4518
🔍 Latest deploy log https://app.netlify.com/sites/wallet-develop-mainnet/deploys/666c23a61c19dd000855f410
😎 Deploy Preview https://deploy-preview-756--wallet-develop-mainnet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 18, 2024

Deploy Preview for wallet-staging ready!

Name Link
🔨 Latest commit 32b4518
🔍 Latest deploy log https://app.netlify.com/sites/wallet-staging/deploys/666c23a61c19dd000855f40c
😎 Deploy Preview https://deploy-preview-756--wallet-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@Viterbo Viterbo self-assigned this Jan 18, 2024
Copy link

netlify bot commented Feb 9, 2024

Deploy Preview for telos-cloud-wallet ready!

Name Link
🔨 Latest commit 32b4518
🔍 Latest deploy log https://app.netlify.com/sites/telos-cloud-wallet/deploys/666c23a6b3782300087e1d1c
😎 Deploy Preview https://deploy-preview-756--telos-cloud-wallet.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Viterbo and others added 4 commits February 9, 2024 20:54
Comment on lines +225 to +226
// if we have more than one account, we ask the user to select one using this callback
const selectedAccount = await this.accountSelector.selectAccount(accountNames);
Copy link
Collaborator Author

@Viterbo Viterbo Feb 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const selectedAccount = await this.accountSelector.selectAccount(accountNames);

That line is a callback to the external website to halt the process, allowing the user to select from the discovered accounts for login. This is optional, and if not overridden, a default, straightforward selection without interaction will be performed instead.

In this case, the accounts are taken from the cache.

Comment on lines +253 to +254
// if we have more than one account, we ask the user to select one using this callback
accountName = await this.accountSelector.selectAccount(names);
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

accountName = await this.accountSelector.selectAccount(names);

Again, this line allows the user to select one account to log in with. In this case, the accounts are taken from the blockchain.

}

async createAccount(publicKey: string): Promise<string> {
const suggestedName = await this.accountNameSelector.selectAccountName();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const suggestedName = await this.accountNameSelector.selectAccountName();

That line is a callback to the external website to stop the process, allowing the user to select an unused account name for the new account creation. This is optional, and if not overridden, a default empty string will be returned without interaction, leading to the endpoint being called with no suggested account name, resulting in the creation of a completely random account.

Comment on lines +424 to +431
const transaction_extensions = originalTransaction.transaction_extensions ?? [] as string[];
const context_free_actions = originalTransaction.context_free_actions ?? [] as string[];
const delay_sec = originalTransaction.delay_sec ?? 0;
const max_cpu_usage_ms = originalTransaction.max_cpu_usage_ms ?? 0;
const max_net_usage_words = originalTransaction.max_net_usage_words ?? 0;
const expiration = originalTransaction.expiration ?? transaction.expiration.toString();
const ref_block_num = originalTransaction.ref_block_num ?? transaction.ref_block_num.toNumber();
const ref_block_prefix = originalTransaction.ref_block_prefix ?? transaction.ref_block_prefix.toNumber();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The original transaction may or may not have all the transaction details, containing only the actions. If we are coming from a Greymass Fuel intersection, the original transaction will be complete so we need to use it as it comes in order to sign the same transaction as Fuel did. If not, it's ok to create a brand-new transaction.

Comment on lines +320 to +347
Dialog.create({
title: GreymassFuelService.globals.$t('api.greymass_dialog_title'),
message,
html: true,
cancel,
ok,
persistent: true,
class: 'text-black',
options: {
type: 'checkbox',
model: mymodel,
isValid: (model/*: string | string[]*/) => {
GreymassFuelService.setPreferences(username, {
remember: model.length === 1,
});
return true;
},
items: [
{
label: GreymassFuelService.globals.$t('api.remember_my_decision'),
value: 'remember',
color: 'primary' },
],
},
})
// all answers should save the preferences
.onOk(() => handler(true))
.onCancel(() => handler(false));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We only present this Dialog in the case of having any extra fees that the user should approve to pay. If there are no fees, then no Dialog is shown to the user.

Comment on lines +23 to +29
const chainNetworkNames: Record<string, string> = (tab === 'zero') ? {
'telos': 'telos',
'telos-testnet': 'telos-testnet',
} : {
'telos': 'telos-evm',
'telos-testnet': 'telos-evm-testnet',
};
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ezra-sg, you made a comment about this code that I did not answer back then.

I can't put this code into the network configuration because it responds to a non-generic logic specific to our website.

@Viterbo Viterbo marked this pull request as ready for review February 13, 2024 00:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EPIC | Telos Cloud Login
2 participants