Skip to content

Commit

Permalink
PR Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mario-christopher committed Apr 2, 2024
1 parent c6adcdf commit c0dba9e
Show file tree
Hide file tree
Showing 9 changed files with 31 additions and 23 deletions.
2 changes: 0 additions & 2 deletions packages/site/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import {
ReconnectButton,
SetLxpAddressButton,
} from '../components';
import { LxpAddressInput } from '../components/Other/Input';
import { defaultSnapOrigin } from '../config';
import { MetamaskActions, MetaMaskContext } from '../hooks';
import {
Expand Down Expand Up @@ -81,7 +80,6 @@ const ErrorMessage = styled.div`

const Index = () => {
const { state, dispatch, provider } = useContext(MetaMaskContext);
const [lxpAddressValue, setLxpAddressValue] = useState<string>();
const [claimMessage, setClaimMessage] = useState<string>();
const [snapLxpAddress, setSnapLxpAddress] = useState<string>();
const [connectedAccount, setConnectedAccount] = useState<string>();
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"heading": "Linea XP wallet address",
"prompt": "Please enter the wallet address linked to your LXP"
},
"nextSteps": {
"nextSteps": {
"heading": "Thank you for installing the LXP Snap",
"body": "Next, set your address with the [companion site](https://lxp-snap.linea.build/) to track your Linea XP balance. At any time you can open the Snaps menu and click on LXP to view your balance, Proof of Humanity status, and current activations."
},
Expand All @@ -30,7 +30,7 @@
"viewBalance": "View balance on Lineascan",
"completePOH": "Complete Proof of Humanity",
"exploreAll": "Explore All Linea Activations",
"errors": {
"errors": {
"heading": "Error",
"invalidLxpAddress": "{address} is not a valid address. Please try again."
}
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/locales/es.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"heading": "Cuenta que usas para Linea XP",
"prompt": "Ingresa tu cuenta para ver tu balance"
},
"nextSteps": {
"nextSteps": {
"heading": "Gracias por instalar LXP Snap",
"body": "Para ver tu balance de LXP y estado de POH, [ingresa tu cuenta por el sitio web](https://lxp-snap.linea.build/). A cualquier tiempo puedes abrir el menu y seleccionar el Snap para ver tu balance, estado de POH, y activaciones de LXP activas."
},
Expand All @@ -30,7 +30,7 @@
"viewBalance": "Ve tu balance de LXP en Lineascan",
"completePOH": "Verfica tu estado de POH",
"exploreAll": "Explora todas las activaciones",
"errors": {
"errors": {
"heading": "Error",
"invalidLxpAddress": "{address} no es una cuenta valido. Por favor, inténtelo de nuevo más tarde."
}
Expand Down
4 changes: 2 additions & 2 deletions packages/snap/locales/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"heading": "fr-Linea XP wallet address",
"prompt": "fr-Please enter the wallet address linked to your LXP"
},
"nextSteps": {
"nextSteps": {
"heading": "fr-Thank you for installing the LXP Snap",
"body": "fr-Next, set your address with the [companion site](https://lxp-snap.linea.build/) to track your Linea XP balance. At any time you can open the Snaps menu and click on LXP to view your balance, Proof of Humanity status, and current activations."
},
Expand All @@ -30,7 +30,7 @@
"viewBalance": "fr-View balance on Lineascan",
"completePOH": "fr-Complete Proof of Humanity",
"exploreAll": "fr-Explore All Linea Activations",
"errors": {
"errors": {
"heading": "fr-Error",
"invalidLxpAddress": "fr-{address} is not a valid address. Please try again."
}
Expand Down
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": "J7CKoYhgYm7nmRgfcnLRzWRRcavzXQvpyUlJ+oA/AlI=",
"shasum": "5p0LwnblfoZD85wuMK7Iq0QxplgShS2yfApvzPmgzLA=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
Expand Down
20 changes: 13 additions & 7 deletions packages/snap/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ import {
getPohStatus,
registerAddress,
} from './service';
import { renderMainUi, renderPromptLxpAddress, renderPromptLxpAddressError, renderPromptNextSteps } from './ui';
import {
renderMainUi,
renderPromptLxpAddress,
renderPromptLxpAddressError,
renderPromptNextSteps,
} from './ui';
import { getChainId, getState, loadCaptions, setState } from './utils';

export const onInstall: OnInstallHandler = async () => {
Expand All @@ -29,18 +34,18 @@ export const onUpdate: OnUpdateHandler = async () => {

export const onHomePage: OnHomePageHandler = async () => {
await loadCaptions();
/* make calls in parallel */
const [chainId, snapState] = await Promise.all([getChainId(), getState()]);

/* make calls in parallel */
const [chainId, snapState] = await Promise.all([getChainId(), getState()]);

const myAccount = snapState.lxpAddress as string;

/* make calls in parallel */
const [myLxpBalance, myPohStatus, activations] = await Promise.all([
getLxpBalanceForAddress(myAccount, chainId),
getPohStatus(myAccount),
getCurrentActivations(),
]);
]);

await setState({
myLxpBalance,
Expand Down Expand Up @@ -83,7 +88,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
return registerAddress(signature, payload);
}

case 'watchLxpAddress': {
case 'watchLxpAddress': {
await loadCaptions();
const lxpAddress = await snap.request({
method: 'snap_dialog',
Expand All @@ -103,6 +108,7 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ request }) => {
});
}
}
return null;
}

default:
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ export type Captions = {
viewBalance: string;
completePOH: string;
exploreAll: string;
errors: {
heading: string,
invalidLxpAddress: string;
errors: {
heading: string;
invalidLxpAddress: string;
};
};

Expand Down
10 changes: 7 additions & 3 deletions packages/snap/src/ui.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ export async function renderPromptLxpAddress() {

/**
* Render the UI in the onInstall hook.
* @returns DialogParams UI for onInstall.
* @returns DialogParams UI for onInstall.
*/
export async function renderPromptNextSteps() {
const snapState = await getState();
Expand All @@ -130,13 +130,17 @@ export async function renderPromptNextSteps() {

/**
* Render the UI in the onRpcRequest for setting a watch address when an invalid address is provided.
* @param lxpAddressStr - The LXP Address.
* @returns DialogParams UI for onRpcRequest error dialog.
*/
export async function renderPromptLxpAddressError(lxpAddressStr:string) {
export async function renderPromptLxpAddressError(lxpAddressStr: string) {
const snapState = await getState();
const captions = snapState?.captions;

const errorMsg = captions?.errors.invalidLxpAddress.replace('{address}', lxpAddressStr);
const errorMsg = captions?.errors.invalidLxpAddress.replace(
'{address}',
lxpAddressStr,
);

return {
type: 'alert',
Expand Down
2 changes: 1 addition & 1 deletion packages/snap/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export async function getChainId() {

if (!chainId) {
console.error('Something went wrong while getting the chain ID.');
chainId = '1';
chainId = '1';
}

return chainId;
Expand Down

0 comments on commit c0dba9e

Please sign in to comment.