Skip to content

Commit

Permalink
Merge branch 'main' into fix/toast-type-bug
Browse files Browse the repository at this point in the history
 Conflicts:
	apps/namada-interface/src/slices/transfers.ts
  • Loading branch information
emccorson committed Jul 21, 2023
2 parents d7888c0 + 6d82708 commit 004f96e
Show file tree
Hide file tree
Showing 228 changed files with 5,747 additions and 1,145 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ for solving possible issue see [Troubleshooting](#troubleshooting)

## Introduction

This is the main app of the project and it is the user interface of the application. It is based on create-react-app and uses TypeScript. Some of its' functionality is split to external project living in this repository, under the directory `packages`. They are: [anoma-lib](#anoma-lib), [key-management](#key-management), [masp-web](#masp-web). All of those dependencies use Rust code that is compiled to WASM with [bindgen](https://rustwasm.github.io/wasm-bindgen). Anoma-wallet and its developers do not have to care about this fact, except when compiling the dependencies in the beginning. All of the libraries using WASM exposes a usual TypeScript interface.

This is the `namada-interface` monorepo. Within it, you will find the code for the web wallet implementation. it contains the following packages:

```bash
Expand All @@ -49,14 +47,14 @@ namada-interface/
├── namada-interface/ # Main wallet React App
├── extension/ # Browser Extension React App
└── packages/
├── crypto/ # Crypto functions related to anoma extension and interface
├── crypto/ # Crypto functions related to namada extension and interface
├── integrations/ # Third-party wallet integrations
├── masp-web/ # utilities for performing MASP actions
├── rpc/ # Library for handling HTTP and WebSocket RPC calls
├── seed-management/ # Seed management library
├── session/ # Session management library
├── shared/ # Package for interfacing with `namada/shared`
├── tx/ # Library for interfacing with Anoma transactions
├── tx/ # Library for interfacing with Namada transactions
├── utils/ # Shared utilities
├── wallet/ # Library for deriving keys
└── wasm/ # Legacy wasm library
Expand Down
8 changes: 4 additions & 4 deletions apps/extension/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Anoma Browser Extension
# Namada Browser Extension

This is the Anoma Browser Extension project.
This is the Namada Browser Extension project.

## Usage

Expand Down Expand Up @@ -52,10 +52,10 @@ Once you have run `yarn build`, you can use the files in `./dist` to install the

1. In Firefox, navigate to `about:debugging#/runtime/this-firefox`
2. Select `Load Temporary Add-On...`
3. Navigate to either the `build/browser/manifest.json` or the `build/firefox/anoma_extension-0.1.0.zip` file to install
3. Navigate to either the `build/browser/manifest.json` or the `build/firefox/namada_extension-0.1.0.zip` file to install

The extension should be installed. Currently, this is enabled for `namada.me`, so navigating to that page will call the `content` scripts,
hopefully instantiating an instance of the `Anoma()` class API for handling communication between client and key store.
hopefully instantiating an instance of the `Namada()` class API for handling communication between client and key store.

## Notes

Expand Down
20 changes: 10 additions & 10 deletions apps/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@anoma/extension",
"name": "@namada/extension",
"version": "0.1.0",
"description": "Anoma Browser Extension",
"description": "Namada Browser Extension",
"repository": "https://github.com/anoma/namada-interface/",
"author": "Heliax Dev <[email protected]>",
"license": "MIT",
Expand All @@ -26,18 +26,18 @@
"wasm:build:dev": "./scripts/build.sh"
},
"dependencies": {
"@anoma/chains": "0.1.0",
"@anoma/components": "0.1.0",
"@anoma/crypto": "0.1.0",
"@anoma/shared": "0.1.0",
"@anoma/storage": "0.1.0",
"@anoma/types": "0.1.0",
"@anoma/utils": "0.1.0",
"@namada/chains": "0.1.0",
"@namada/components": "0.1.0",
"@namada/crypto": "0.1.0",
"@namada/shared": "0.1.0",
"@namada/storage": "0.1.0",
"@namada/types": "0.1.0",
"@namada/utils": "0.1.0",
"@namada/ledger-namada": "0.0.1",
"@cosmjs/encoding": "^0.29.0",
"@ledgerhq/hw-transport": "^6.28.3",
"@ledgerhq/hw-transport-webhid": "^6.27.14",
"@ledgerhq/hw-transport-webusb": "^6.27.14",
"@zondax/ledger-namada": "^0.0.2",
"bignumber.js": "^9.1.1",
"@dao-xyz/borsh": "^5.1.5",
"buffer": "^6.0.3",
Expand Down
28 changes: 23 additions & 5 deletions apps/extension/src/App/Accounts/AccountListing.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useNavigate } from "react-router-dom";

import { Icon, IconName } from "@anoma/components";
import { AccountType, Bip44Path, DerivedAccount } from "@anoma/types";
import { shortenAddress } from "@anoma/utils";
import { Icon, IconName } from "@namada/components";
import { AccountType, Bip44Path, DerivedAccount } from "@namada/types";
import { shortenAddress } from "@namada/utils";

import { TopLevelRoute } from "App/types";
import {
Expand All @@ -29,21 +29,39 @@ const textToClipboard = (content: string): void => {
navigator.clipboard.writeText(content);
};

const isChild = (type: AccountType, path: Bip44Path): boolean => {
// All PrivateKey accounts are child accounts
if (type === AccountType.PrivateKey) {
return true;
}

if (type === AccountType.Ledger) {
// If this is a Ledger account, a child account is any account
// with a path that isn't the default path (/0'/0/0). This is for display
// purposes only. If the sum of the path components is greater than
// zero, it is a child.
const { account, change, index = 0 } = path;
return account + change + index > 0;
}

return false;
};

const formatDerivationPath = (
isChildAccount: boolean,
{ account, change, index = 0 }: Bip44Path,
type: AccountType
): string =>
isChildAccount
? `/${account}'/${
type === AccountType.PrivateKey ? `${change}/` : ""
type !== AccountType.Mnemonic ? `${change}/` : ""
}${index}`
: "";

const AccountListing = ({ account, parentAlias }: Props): JSX.Element => {
const { address, alias, path, type } = account;
const navigate = useNavigate();
const isChildAccount = type !== AccountType.Mnemonic;
const isChildAccount = isChild(type, path);

return (
<AccountListingContainer>
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/App/Accounts/Accounts.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { DerivedAccount } from "@anoma/types";
import { DerivedAccount } from "@namada/types";
import {
AccountsContainer,
AccountsList,
Expand Down
6 changes: 3 additions & 3 deletions apps/extension/src/App/Accounts/AddAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import {
Input,
InputVariants,
Toggle,
} from "@anoma/components";
import { AccountType, DerivedAccount } from "@anoma/types";
import { chains, defaultChainId } from "@anoma/chains";
} from "@namada/components";
import { AccountType, DerivedAccount } from "@namada/types";
import { chains, defaultChainId } from "@namada/chains";

import { ExtensionRequester } from "extension";
import { Ports } from "router";
Expand Down
18 changes: 10 additions & 8 deletions apps/extension/src/App/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React, { useEffect, useState } from "react";
import { ThemeProvider } from "styled-components";
import { Routes, Route, useNavigate } from "react-router-dom";

import { DerivedAccount } from "@anoma/types";
import { getTheme } from "@anoma/utils";
import { Icon, IconName } from "@anoma/components";
import { useUntil } from "@anoma/hooks";
import { DerivedAccount } from "@namada/types";
import { getTheme } from "@namada/utils";
import { Icon, IconName } from "@namada/components";
import { useUntil } from "@namada/hooks";

import { Ports } from "router";
import {
Expand Down Expand Up @@ -78,11 +78,13 @@ export const App: React.FC = () => {
setStatus(Status.Pending);

try {
const parentId = await requester.sendMessage(
const parent = await requester.sendMessage(
Ports.Background,
new GetActiveAccountMsg()
);
const parentAccount = accounts.find((account) => account.id === parentId);
const parentAccount = accounts.find(
(account) => account.id === parent?.id
);
setParentAccount(parentAccount);
} catch (e) {
console.error(e);
Expand Down Expand Up @@ -115,7 +117,7 @@ export const App: React.FC = () => {
},
onFail: () => {
setError("An error occurred connecting to extension");
setStatus(Status.Failed);
setStatus(Status.Completed);
},
},
{ tries: 10, ms: 100 },
Expand Down Expand Up @@ -188,7 +190,7 @@ export const App: React.FC = () => {
<GlobalStyles />
<ContentContainer>
<TopSection>
<Heading>Anoma Browser Extension</Heading>
<Heading>Namada Browser Extension</Heading>
<HeadingLoader
className={
maspStatus.status === Status.Pending ? "is-loading" : ""
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/App/LockWrapper/LockWrapper.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from "react";
import { useNavigate } from "react-router-dom";

import { Icon, IconName } from "@anoma/components";
import { Icon, IconName } from "@namada/components";
import { ButtonContainer, LockExtensionButton } from "./LockWrapper.components";
import { LockKeyRingMsg } from "background/keyring";
import { Ports } from "router";
Expand Down
2 changes: 1 addition & 1 deletion apps/extension/src/App/Login/Login.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState } from "react";
import { useNavigate } from "react-router-dom";

import { Button, ButtonVariant, Input, InputVariants } from "@anoma/components";
import { Button, ButtonVariant, Input, InputVariants } from "@namada/components";

import { TopLevelRoute } from "App/types";
import { ExtensionRequester } from "extension";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useState } from "react";
import {
Button,
ButtonVariant
} from "@anoma/components";
} from "@namada/components";
import zxcvbn, { ZXCVBNFeedback } from "zxcvbn";

import {
Expand All @@ -17,7 +17,7 @@ import { DeleteAccountMsg } from "background/keyring";
import { ExtensionRequester } from "extension";
import { Ports } from "router";
import { DeleteAccountError } from "background/keyring/types";
import { assertNever } from "@anoma/utils";
import { assertNever } from "@namada/utils";

enum Status {
Unsubmitted,
Expand Down
51 changes: 19 additions & 32 deletions apps/extension/src/App/Settings/ExtraSettings/ExtraSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import { assertNever } from "@anoma/utils";
import { assertNever } from "@namada/utils";
import { ExtensionRequester } from "extension";

import { Mode, ExtraSetting } from "./types";
import { ResetPassword } from "./ResetPassword";
import { DeleteAccount } from "./DeleteAccount";
import {
ExtraSettingsContainer,
CloseLink
} from "./ExtraSettings.components";
import { ExtraSettingsContainer, CloseLink } from "./ExtraSettings.components";

/**
* Container for additional settings forms such as the reset password form.
Expand All @@ -17,37 +14,27 @@ const ExtraSettings: React.FC<{
requester: ExtensionRequester;
onClose: () => void;
onDeleteAccount: (id: string) => void;
}> = ({
extraSetting,
requester,
onClose,
onDeleteAccount,
}) => {
}> = ({ extraSetting, requester, onClose, onDeleteAccount }) => {
return (
<ExtraSettingsContainer>
{extraSetting &&
<CloseLink onClick={onClose}>
Close
</CloseLink>}

{
extraSetting === null ? "" :

extraSetting.mode === Mode.ResetPassword ?
<ResetPassword
accountId={extraSetting.accountId}
requester={requester}
/> :

extraSetting.mode === Mode.DeleteAccount ?
<DeleteAccount
accountId={extraSetting.accountId}
requester={requester}
onDeleteAccount={onDeleteAccount}
/> :
{extraSetting && <CloseLink onClick={onClose}>Close</CloseLink>}

{extraSetting === null ? (
""
) : extraSetting.mode === Mode.ResetPassword ? (
<ResetPassword
accountId={extraSetting.accountId}
requester={requester}
/>
) : extraSetting.mode === Mode.DeleteAccount ? (
<DeleteAccount
accountId={extraSetting.accountId}
requester={requester}
onDeleteAccount={onDeleteAccount}
/>
) : (
assertNever(extraSetting.mode)
}
)}
</ExtraSettingsContainer>
);
};
Expand Down
Loading

0 comments on commit 004f96e

Please sign in to comment.