-
Notifications
You must be signed in to change notification settings - Fork 8
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
Telos Cloud Wallet (powered by Metakeep) #728
Conversation
…into new-telos-cloud
✅ Deploy Preview for wallet-staging ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for wallet-develop-mainnet ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
const script = document.createElement('script'); | ||
script.src = 'https://cdn.usefathom.com/script.js'; | ||
script.dataset.site = 'ISPYEAKT'; | ||
script.dataset.spa = 'auto'; | ||
script.defer = true; | ||
document.body.appendChild(script); |
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.
@ezra-sg, this code was inside an if and the condition was that the chain used is EVM.
I had a lot of problems related to the chain being set (especially on auto-login situations where telos-evm is set because of the UI and then the telos-zero is set because the user was previously logged in telos zero).
What I need to know is if it is safe to remove that condition and have this code executed always.
if (chainSettings.isNative()) { | ||
this.trace('fetchAllowancesForAccount', 'Native chain does not have allowances'); | ||
return; | ||
} | ||
|
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 avoids trying to fetch allowances data from a native chain
if (!chain.settings.isNative()) { | ||
const chain_settings = chain.settings as EVMChainSettings; | ||
const sysToken = chain_settings.getSystemToken(); | ||
const stkToken = chain_settings.getStakedSystemToken(); |
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.
Again, this avoids fetching the staking ratio data from a non-evm chain
if (!chain.settings.isNative()) { | ||
const decimals = (this.getChain(label).settings as EVMChainSettings).getStakedSystemToken().decimals; | ||
const ratioNumber = parseFloat(ethers.utils.formatUnits(ratio, decimals)); | ||
this.trace('setStakedRatio', label, ratio.toString(), ratioNumber); | ||
(this.__chains[label] as EvmChainModel).stakeRatio = ratio; | ||
} else { | ||
this.trace('setStakedRatio', label, 'Native chain has no staked ratio'); | ||
} |
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.
Ensuring the correct chain
if (!chain.settings.isNative()) { | ||
const decimals = (this.getChain(label).settings as EVMChainSettings).getStakedSystemToken().decimals; | ||
const ratioNumber = parseFloat(ethers.utils.formatUnits(ratio, decimals)); | ||
this.trace('setUnstakedRatio', label, ratio.toString(), ratioNumber); | ||
(this.__chains[label] as EvmChainModel).unstakeRatio = ratio; | ||
} else { | ||
this.trace('setUnstakedRatio', label, 'Native chain has no unstaked ratio'); | ||
} |
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.
Ensuring the correct chain
if (chainSettings.isNative()) { | ||
this.trace('fetchEvmNftTransfersForAccount', 'Native networks not supported yet'); | ||
return; | ||
} |
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.
fetching history only for EVM (for now)
if (this.isNetworkEVM(label)) { | ||
const contract = await this.getStakedSystemContractInstance(label); | ||
const totalStaking = await contract.totalAssets(); | ||
this.setTotalStaking(label, totalStaking); | ||
} else { | ||
this.trace('updateTotalStaking', label, 'not supported for native chains yet'); | ||
} |
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.
only for EVM chains
if (this.isNetworkEVM(label)) { | ||
const contract = await this.getEscrowContractInstance(label); | ||
const period = await contract.lockDuration(); | ||
this.setUnstakingPeriod(label, period.toNumber()); | ||
} else { | ||
this.trace('updateUnstakingPeriod', label, 'not supported for native chains yet'); | ||
} |
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.
only for EVM chains
if (this.isNetworkEVM(label)) { | ||
const contract = await this.getEscrowContractInstance(label); | ||
const address = useAccountStore().getAccount(label).account; | ||
const withdrawable = await contract.maxWithdraw(address); | ||
this.setWithdrawable(label, withdrawable); | ||
} else { | ||
this.trace('updateWithdrawable', label, 'not supported for native chains yet'); | ||
} |
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.
only for EVM chains
if (this.isNetworkEVM(label)) { | ||
const contract = await this.getEscrowContractInstance(label); | ||
const address = useAccountStore().getAccount(label).account; | ||
const deposits = await contract.depositsOf(address); | ||
this.setDeposits(label, deposits); | ||
} else { | ||
console.error('updateDeposits', label, 'not supported for native chains yet'); | ||
} |
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.
only for EVM chains
if (this.isNetworkEVM(label)) { | ||
const contract = await this.getEscrowContractInstance(label); | ||
const address = useAccountStore().getAccount(label).account; | ||
const balance = await contract.balanceOf(address); | ||
this.setBalance(label, balance); | ||
} else { | ||
console.error('updateBalance', label, 'not supported for native chains yet'); | ||
} |
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.
only for EVM chains
@@ -42,28 +42,19 @@ export class AntelopeWallets { | |||
// we try first the best solution which is taking the provider from the current authenticator | |||
const authenticator = account.authenticator as EVMAuthenticator; | |||
const provider = authenticator.web3Provider(); | |||
this.trace('getWeb3Provider authenticator.web3Provider() Success! (account.authenticator)', provider); | |||
return provider; | |||
} catch(e1) { | |||
this.trace('getWeb3Provider authenticator.web3Provider() Failed!', e1); | |||
} | |||
|
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.
The second option was window.ethereum
but now is removed. The problem with that option is that the window.ethereum
may be present but the wallet may be not even opened, so the user is not logged and the chain is not set. In that case, the provider does not work so the option is discarded.
// utils/metakeep-cache.ts | ||
|
||
export interface MetakeepCacheData { |
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 is an auxiliary file with useful functions to keep cached all data coming from metakeep, so we don't need to query the same data over and over again each time the user logs in. That makes the process of auto-log much faster.
next: async (account: AccountModel) => { | ||
if (account.isNative) { | ||
if (!window.location.pathname.startsWith('/zero')) { | ||
const router = await getRouter(app); | ||
router.push({ path: '/zero/balance' }); | ||
} | ||
} else { | ||
if (!window.location.pathname.startsWith('/evm')) { | ||
const router = await getRouter(app); | ||
router.push({ path: '/evm/wallet?tab=balance' }); | ||
} |
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.
Now the redirection takes into account which type of chain you are logging in to. It only redirects you if you are on the wrong path.
import { AntelopeError } from 'src/antelope/types'; | ||
|
||
import * as Buffer from 'buffer'; | ||
import { BehaviorSubject, Subject } from 'rxjs'; | ||
|
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 is an auxiliary file with useful functions to handle everything related to the GoogleOneTap service.
Fixes #727, #713
BLOCKED: The Telos Cloud for Telos Zero is not working yet because the account-creation endpoint is not ready to go yet. We need to set up a new Table in the database to remember the account created for each Google user so we don't create more than one per user.
Description
This PR includes the implementation of the new Telos Cloud Wallet, powered by Metakeep, for both Telos EVM and Telos Zero. It entirely removes any references to the old OreId service.
Additionally, the auto-login feature has been stabilized to ensure reliable functionality in all cases (EVM or Zero): for example, if the user is logged into Telos Zero and opens the website on any page, he or she will be redirected to the Telos Zero balances page (and similarly with EVM).
Checks have been added to ensure the correct network is being used before performing tasks such as obtaining the conversion ratio (STLOS) or the APY of the staking.
Test scenarios
EVM
EVM auto-login
T-Zero (This still does not work because the endpoint is not ready)
T-Zero auto-login
Checklist: