Skip to content

Commit

Permalink
Merge pull request #759 from telosnetwork/755-telos-cloud-login--zero…
Browse files Browse the repository at this point in the history
…-name-account-choice

Telos Cloud Login | Zero name input
  • Loading branch information
Viterbo authored Feb 9, 2024
2 parents fed9e7d + e378554 commit 4362270
Show file tree
Hide file tree
Showing 12 changed files with 1,310 additions and 50 deletions.
1 change: 0 additions & 1 deletion env.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const TESTNET = {
NETWORK_CHAIN_ID:
'1eaa0824707c8c16bd25145493bf062aecddfeb56c736f6ba6397f3195f33c9f',
TELOS_API_ENDPOINT: 'https://api-dev.telos.net/v1',
// TELOS_API_ENDPOINT: 'http://localhost:9999/v1',
HYPERION_ENDPOINT: 'https://testnet.telos.net',
NETWORK_EXPLORER: 'https://explorer-test.telos.net',
CHAIN_NAME: 'telos-testnet',
Expand Down
10 changes: 10 additions & 0 deletions src/antelope/chains/NativeChainSettings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,16 @@ export default abstract class NativeChainSettings implements ChainSettings {
return this.eosioCore.v1.chain.get_account(address);
}

async isAccountNameAvailable(accountName: string): Promise<boolean> {
return new Promise((resolve) => {
this.eosioCore.v1.chain.get_account(accountName).then(() => {
resolve(false);
}).catch(() => {
resolve(true);
});
});
}

async getKeyAccounts(key: string): Promise<KeyAccounts> {
return (await this.eosioCore.v1.history.get_key_accounts(key)) as unknown as KeyAccounts;
}
Expand Down
15 changes: 14 additions & 1 deletion src/antelope/wallets/ual/MetakeepUAL.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,18 @@ const metakeepDefaultAccountSelector: MetakeepAccountSelector = {
selectAccount: (accounts: string[]) => Promise.resolve(accounts[0]),
};

const metakeepDefaultAccountNameSelector: MetakeepNameAccountSelector = {
selectAccountName: () => Promise.resolve(''),
};

export interface MetakeepAccountSelector {
selectAccount: (accounts: string[]) => Promise<string>;
}

export interface MetakeepNameAccountSelector {
selectAccountName: () => Promise<string>;
}

export class MetakeepAuthenticator extends Authenticator {
private chainId: string;
private rpc: JsonRpc;
Expand All @@ -60,6 +67,7 @@ export class MetakeepAuthenticator extends Authenticator {
private userCredentials: UserCredentials = { email: '', jwt: '' };

private accountSelector: MetakeepAccountSelector = metakeepDefaultAccountSelector;
private accountNameSelector: MetakeepNameAccountSelector = metakeepDefaultAccountNameSelector;

constructor(chains: Chain[], options: MetakeepUALOptions) {
super(chains, options);
Expand Down Expand Up @@ -92,6 +100,10 @@ export class MetakeepAuthenticator extends Authenticator {
this.accountSelector = accountSelector;
}

setAccountNameSelector(accountNameSelector: MetakeepNameAccountSelector) {
this.accountNameSelector = accountNameSelector;
}

saveCache() {
metakeepCache.saveCache();
}
Expand Down Expand Up @@ -187,11 +199,12 @@ export class MetakeepAuthenticator extends Authenticator {
}

async createAccount(publicKey: string): Promise<string> {
const suggestedName = await this.accountNameSelector.selectAccountName();
return axios.post(this.accountCreateAPI, {
ownerKey: publicKey,
activeKey: publicKey,
jwt: this.userCredentials.jwt,
// suggestedName: 'somevalidname', // we are not using this optional parameter for now
suggestedName: suggestedName,
}).then(response => response.data.accountName);
}

Expand Down
2 changes: 1 addition & 1 deletion src/css/quasar.variables.sass
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// Tip: Use the "Theme Builder" on Quasar's documentation website.
$primary : #571aff
$secondary : #dfdfed
$secondary : #1a85ff
$accent : #ffd75e

$dark : #130C3F
Expand Down
9 changes: 9 additions & 0 deletions src/i18n/en-us/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,11 @@ export default {
oauth_facebook: 'Facebook',
oauth_twitter: 'Twitter',
oauth_email: 'Email',
random: 'Random',
continue: 'Continue',
account_name: 'Account Name',
name_selection_text: 'A new account will be created for you. Choose a name with twelve characters long using only lowercase letters or numbers from 1 to 5.',
account_selection_text: 'Choose one of your accounts to log in',
},
nav: {
copy_address: 'Copy address to clipboard',
Expand Down Expand Up @@ -366,6 +371,10 @@ export default {
resources_low: 'Your resources are low',
recommend_bying: 'We recommend you buy more for 1 TLOS',
proceed_q: 'Proceed?',
account_name_feedback_no_dots: 'Account name cannot contain dots',
account_name_feedback_invalid_character: 'invalid character \'{char}\'',
account_name_feedback_invalid_length: '{length} of 12 characters',
account_name_feedback_taken: 'Account name is taken',
},
streaming: {
title: 'Live Streaming Example',
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/EVMLoginButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export default defineComponent({
const supportsMetamask = computed(() => {
const e = window.ethereum as unknown as { [key:string]: boolean };
return e && e.isMetaMask && !supportsSafePal.value && !unsupportedExtensions.value; //
return e && e.isMetaMask && !supportsSafePal.value && !unsupportedExtensions.value;
});
const supportsSafePal = computed(() => {
Expand Down
2 changes: 1 addition & 1 deletion src/pages/home/GoogleOneTap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ class GoogleOneTapController {
btn, this.buttonConfig,
);
}
}, 1000);
}, 100);
}

handleOneTapMoment(type: string, status: string, reason: string) {
Expand Down
Loading

0 comments on commit 4362270

Please sign in to comment.