Skip to content

Commit

Permalink
fix: Snap crashing when no address is set on installation (#31)
Browse files Browse the repository at this point in the history
Co-authored-by: Christian Montoya <[email protected]>
  • Loading branch information
alainncls and Montoya authored Mar 28, 2024
1 parent 807326f commit 704fcb6
Show file tree
Hide file tree
Showing 7 changed files with 66 additions and 17 deletions.
10 changes: 9 additions & 1 deletion packages/snap/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
10 changes: 9 additions & 1 deletion packages/snap/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
10 changes: 9 additions & 1 deletion packages/snap/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 4 additions & 2 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
8 changes: 8 additions & 0 deletions packages/snap/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
37 changes: 26 additions & 11 deletions packages/snap/src/ui.ts

Large diffs are not rendered by default.

0 comments on commit 704fcb6

Please sign in to comment.