diff --git a/packages/snap/locales/en.json b/packages/snap/locales/en.json index 23b12c5..7ad4df5 100644 --- a/packages/snap/locales/en.json +++ b/packages/snap/locales/en.json @@ -17,5 +17,13 @@ "lxpAddress": { "heading": "LXP wallet address", "prompt": "Please enter the wallet address linked to your LXP" - } + }, + "noAddress": { + "toSetText": "To view your LXP balance and POH status,", + "toSetLink": "first set your address" + }, + "help": "LXP earned in activations may not arrive in your wallet until the activation is complete.", + "viewBalance": "View balance on Lineascan", + "completePOH": "Complete Proof of Humanity", + "exploreAll": "Explore All Linea Activations" } diff --git a/packages/snap/locales/es.json b/packages/snap/locales/es.json index c99d3ae..5690cbe 100644 --- a/packages/snap/locales/es.json +++ b/packages/snap/locales/es.json @@ -17,5 +17,13 @@ "lxpAddress": { "heading": "Cuenta que usas para LXP", "prompt": "Ingresa tu cuenta para ver tu balance" - } + }, + "noAddress": { + "toSetText": "Para ver tu balance de LXP y estado de POH,", + "toSetLink": "primero ingresa tu cuenta" + }, + "help": "Es posible que LXP obtenido en activaciones no llegue a su cuenta hasta que se complete la activaciĆ³n.", + "viewBalance": "Ve tu balance de LXP en Lineascan", + "completePOH": "Verfica tu estado de POH", + "exploreAll": "Explora todas las activaciones" } diff --git a/packages/snap/locales/fr.json b/packages/snap/locales/fr.json index 1a0d808..ce177a6 100644 --- a/packages/snap/locales/fr.json +++ b/packages/snap/locales/fr.json @@ -17,5 +17,13 @@ "lxpAddress": { "heading": "fr-LXP wallet address", "prompt": "fr-Please enter the wallet address linked to your LXP" - } + }, + "noAddress": { + "toSetText": "fr-To view your LXP balance and POH status,", + "toSetLink": "fr-first set your address" + }, + "help": "fr-LXP earned in activations may not arrive in your wallet until the activation is complete.", + "viewBalance": "fr-View balance on Lineascan", + "completePOH": "fr-Complete Proof of Humanity", + "exploreAll": "fr-Explore All Linea Activations" } diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 7200769..0335c67 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/Consensys/lxp-snap" }, "source": { - "shasum": "yXWTJ1K5yj636sebpR+mZxeFeegggEBjeFnfr4FfDHU=", + "shasum": "wlgQrcTjUra39G2Y2d4+Y1O7jqyjYhBnIBc+2bH9fTI=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index 37a173a..f9ca9e9 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -43,8 +43,10 @@ export const onHomePage: OnHomePageHandler = async () => { const chainId = await getChainId(); const snapState = await getState(); const myAccount = snapState.lxpAddress as string; - const myLxpBalance = await getLxpBalanceForAddress(myAccount, chainId); - const myPohStatus = await getPohStatus(myAccount); + const myLxpBalance = myAccount + ? await getLxpBalanceForAddress(myAccount, chainId) + : 0; + const myPohStatus = myAccount ? await getPohStatus(myAccount) : false; const activations = await getCurrentActivations(); await setState({ diff --git a/packages/snap/src/types/index.ts b/packages/snap/src/types/index.ts index 186da40..2c70963 100644 --- a/packages/snap/src/types/index.ts +++ b/packages/snap/src/types/index.ts @@ -20,6 +20,14 @@ export type Captions = { heading: string; prompt: string; }; + noAddress: { + toSetText: string; + toSetLink: string; + }; + help: string; + viewBalance: string; + completePOH: string; + exploreAll: string; }; export type Tag = { diff --git a/packages/snap/src/ui.ts b/packages/snap/src/ui.ts index 1c7753c..ee277a7 100644 --- a/packages/snap/src/ui.ts +++ b/packages/snap/src/ui.ts @@ -55,26 +55,41 @@ export async function renderMainUi(myAccount: string) { } } + const myData = []; + + if (myAccount) { + myData.push(row(labelAddress, address(myAccount))); + myData.push(row(labelBalance, text(`${lxpBalance}`))); + myData.push(row(labelPohStatus, text(`${pohStatus}`))); + } else { + const addressToSetText = captions?.noAddress?.toSetText as string; + const addressToSetLink = captions?.noAddress?.toSetLink as string; + myData.push( + text( + `${addressToSetText} [${addressToSetLink}](https://lxp-snap.linea.build).`, + ), + ); + } + + const help = captions?.help as string; + const viewBalance = captions?.viewBalance as string; + const completePOH = captions?.completePOH as string; + const exploreAll = captions?.exploreAll as string; + return { content: panel([ image( '', ), - row(labelAddress, address(myAccount)), - row(labelBalance, text(`${lxpBalance}`)), - row(labelPohStatus, text(`${pohStatus}`)), + ...myData, ...activationsList, divider(), + text(`_${help}_`), text( - '_LXP earned in activations may not arrive in your wallet until the activation is complete._', - ), - text( - `• [View balance on Lineascan](https://lineascan.build/token/0xd83af4fbd77f3ab65c3b1dc4b38d7e67aecf599a?a=${myAccount})`, - ), - text('• [Complete Proof of Humanity](https://poh.linea.build)'), - text( - '• [Explore All Linea Activations](https://linea.build/activations)', + `• [${viewBalance}](https://lineascan.build/token/0xd83af4fbd77f3ab65c3b1dc4b38d7e67aecf599a?a=${myAccount})`, ), + text(`• [${completePOH}](https://poh.linea.build)`), + text(`• [${exploreAll}](https://linea.build/activations)'`), ]), }; }