Skip to content

Commit

Permalink
Merge branch 'main' into fork-demo
Browse files Browse the repository at this point in the history
  • Loading branch information
Gergő Nagy authored Mar 8, 2022
2 parents 966b5ac + e8947e6 commit c595525
Show file tree
Hide file tree
Showing 26 changed files with 95 additions and 53 deletions.
23 changes: 23 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
// This is a non-ESM JS file, so this rule can't be followed.
/* eslint-disable @typescript-eslint/no-var-requires */
const {
rules: {
"@typescript-eslint/naming-convention":
airbnbTypeScriptNamingConventionRules,
},
} = require("eslint-config-airbnb-typescript/lib/shared")

const {
rules: { "no-param-reassign": airbnbNoParamReassignRules },
} = require("eslint-config-airbnb-base/rules/best-practices")
Expand Down Expand Up @@ -28,6 +35,22 @@ module.exports = {
// The rule is also mostly irrelevant to this codebase due to TypeScript
// usage (where .tsx is required).
"react/jsx-filename-extension": [0],
"@typescript-eslint/naming-convention": [
...airbnbTypeScriptNamingConventionRules,
// Allow underscore-only identifiers to indicate ignored positional variables.
{
selector: "variable",
format: null,
filter: {
regex: "^_+$",
match: true,
},
custom: {
regex: "^_+$",
match: true,
},
},
],
// TypeScript allows us to declare props that are non-optional internally
// but are interpreted as optional externally if they have defaultProps
// defined; the following two adjustments disable eslint-plugin-react
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/accounts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const enum AccountType {
ReadOnly = "read-only",
Imported = "imported",
Ledger = "ledger",
NewSeed = "newSeed",
Internal = "internal",
}

const availableDefaultNames = [
Expand Down
4 changes: 2 additions & 2 deletions background/redux-slices/keyrings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Keyring, KeyringMetadata } from "../services/keyring/index"

type KeyringsState = {
keyrings: Keyring[]
keyringMetadata: { [keyringId: string]: { source: "import" | "newSeed" } }
keyringMetadata: { [keyringId: string]: { source: "import" | "internal" } }
importing: false | "pending" | "done"
status: "locked" | "unlocked" | "uninitialized"
keyringToVerify: {
Expand Down Expand Up @@ -36,7 +36,7 @@ export const emitter = new Emittery<Events>()

interface ImportKeyring {
mnemonic: string
source: "newSeed" | "import"
source: "internal" | "import"
path?: string
}

Expand Down
4 changes: 2 additions & 2 deletions background/redux-slices/selectors/accountsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const getAccountType = (
address: string,
signingMethod: SigningMethod,
addressSources: {
[address: string]: "import" | "newSeed"
[address: string]: "import" | "internal"
}
): AccountType => {
if (signingMethod == null) {
Expand All @@ -208,7 +208,7 @@ const getAccountType = (
if (addressSources[address] === "import") {
return AccountType.Imported
}
return AccountType.NewSeed
return AccountType.Internal
}

export const selectAccountTotalsByCategory = createSelector(
Expand Down
2 changes: 1 addition & 1 deletion background/redux-slices/selectors/keyringsSelectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const selectSourcesByAddress = createSelector(
keyrings,
keyringMetadata
): {
[keyringId: string]: "import" | "newSeed"
[keyringId: string]: "import" | "internal"
} =>
Object.fromEntries(
keyrings
Expand Down
4 changes: 2 additions & 2 deletions background/services/keyring/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export type Keyring = {
}

export interface KeyringMetadata {
source: "import" | "newSeed"
source: "import" | "internal"
}

interface SerializedKeyringData {
Expand Down Expand Up @@ -311,7 +311,7 @@ export default class KeyringService extends BaseService<Events> {
*/
async importKeyring(
mnemonic: string,
source: "import" | "newSeed",
source: "import" | "internal",
path?: string
): Promise<string> {
this.requireUnlocked()
Expand Down
8 changes: 4 additions & 4 deletions provider-bridge-shared/runtime-typechecks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ export function isPortResponseEvent(arg: unknown): arg is PortResponseEvent {
}

export const AllowedQueryParamPage = {
signTransaction: "/signTransaction",
dappPermission: "/dappPermission",
signData: "/signData",
personalSignData: "/personalSign",
signTransaction: "/sign-transaction",
dappPermission: "/dapp-permission",
signData: "/sign-data",
personalSignData: "/personal-sign",
} as const

export type AllowedQueryParamPageType =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const walletTypeDetails: { [key in AccountType]: WalletTypeInfo } = {
title: "Import",
icon: "./images/[email protected]",
},
[AccountType.NewSeed]: {
[AccountType.Internal]: {
title: "Tally",
icon: "./images/[email protected]", // FIXME: Icon is cut off - we should get a better one
},
Expand Down Expand Up @@ -171,7 +171,7 @@ export default function AccountsNotificationPanelAccounts({
}, [onCurrentAddressChange, pendingSelectedAddress, selectedAccountAddress])

const accountTypes = [
AccountType.NewSeed,
AccountType.Internal,
AccountType.Imported,
AccountType.ReadOnly,
]
Expand Down Expand Up @@ -211,7 +211,7 @@ export default function AccountsNotificationPanelAccounts({
accountType={accountType}
walletNumber={idx + 1}
onClickAddAddress={
accountType === "imported" || accountType === "newSeed"
accountType === "imported" || accountType === "internal"
? () => {
if (accountTotalsByKeyringId[0].keyringId) {
dispatch(
Expand Down Expand Up @@ -261,7 +261,7 @@ export default function AccountsNotificationPanelAccounts({
icon="plus"
iconSize="medium"
iconPosition="left"
linkTo="/onboarding/addWallet"
linkTo="/onboarding/add-wallet"
>
Add Wallet
</SharedButton>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/HiddenDevPanel/HiddenDevPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function HiddenDevPanel(): ReactElement {
icon="arrow_right"
iconSize="large"
onClick={() => {
history.push("/onboarding/infoIntro")
history.push("/onboarding/info-intro")
}}
>
Enter Onboarding
Expand Down
9 changes: 8 additions & 1 deletion ui/components/Onboarding/OnboardingDerivationPathSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,14 @@ import SharedModal from "../Shared/SharedModal"
import SharedSelect from "../Shared/SharedSelect"

// TODO make this network specific
const initialDerivationPaths: { value: string; label: string }[] = [
const initialDerivationPaths: {
value: string
label: string
}[] = [
{
value: "m/44'/60'/x'/0/0",
label: "Ledger Live",
},
{
value: "m/44'/60'/0'/0",
label: "Ethereum",
Expand Down
9 changes: 7 additions & 2 deletions ui/components/Shared/SharedAssetInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function SelectAssetMenuContent<T extends AnyAsset>(
</div>
</div>
<div className="divider" />
<ul>
<ul className="assets_list">
{sortedFilteredAssets.map((assetWithOptionalAmount) => {
const { asset } = assetWithOptionalAmount
return (
Expand Down Expand Up @@ -180,7 +180,12 @@ function SelectAssetMenuContent<T extends AnyAsset>(
width: 384px;
border-bottom: 1px solid var(--hunter-green);
margin-top: 15px;
margin-bottom: 8.5px;
}
.assets_list {
display: block;
overflow: scroll;
height: calc(100% - 98px);
width: 100%;
}
`}
</style>
Expand Down
2 changes: 1 addition & 1 deletion ui/components/Swap/SwapQuote.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export default function SwapQuote({
gasPrice,
})
)
history.push("/signTransaction")
history.push("/sign-transaction")
}, [
finalQuote,
dispatch,
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/EarnDeposit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export default function EarnDeposit(): ReactElement {
type="primary"
size="large"
isDisabled={hasError}
linkTo={!isApproved ? "/signTransaction" : "/signData"}
linkTo={!isApproved ? "/sign-transaction" : "/sign-data"}
onClick={!isApproved ? approve : enable}
>
{!isApproved ? "Approve" : "Enable"}
Expand Down
7 changes: 6 additions & 1 deletion ui/pages/Ledger/LedgerImportAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ function usePageData({
const firstIndex = pageIndex * addressesPerPage
const lastIndex = (pageIndex + 1) * addressesPerPage - 1
for (let i = firstIndex; i <= lastIndex; i += 1) {
paths.push(`${parentPath}/${i}`)
if (parentPath.includes("x")) {
const formattedString = parentPath.slice().replace("x", `${i}`)
paths.push(formattedString)
} else {
paths.push(`${parentPath}/${i}`)
}
}

const items = paths.map((path) => {
Expand Down
6 changes: 3 additions & 3 deletions ui/pages/Onboarding/OnboardingAddWallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default function OnboardingStartTheHunt(): ReactElement {
<SharedButton
type="tertiary"
size="medium"
linkTo="/onboarding/viewOnlyWallet"
linkTo="/onboarding/view-only-wallet"
>
Preview an address
</SharedButton>
Expand All @@ -39,7 +39,7 @@ export default function OnboardingStartTheHunt(): ReactElement {
<SharedButton
type="tertiary"
size="medium"
linkTo="/onboarding/importMetamask"
linkTo="/onboarding/import-metamask"
>
Import recovery phrase
</SharedButton>
Expand Down Expand Up @@ -70,7 +70,7 @@ export default function OnboardingStartTheHunt(): ReactElement {
<SharedButton
type="secondary"
size="medium"
linkTo="/onboarding/onboardingInterstitialCreatePhrase"
linkTo="/onboarding/onboarding-interstitial-create-phrase"
>
Create new wallet
</SharedButton>
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Onboarding/OnboardingInfoIntro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export default function OnboardingInfoIntro(): ReactElement {
const [redirectToAddWallet, setRedirectToAddWallet] = useState(false)

if (redirectToAddWallet) {
return <Redirect push to="/onboarding/addWallet" />
return <Redirect push to="/onboarding/add-wallet" />
}

return (
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Onboarding/OnboardingInterstitialCreatePhrase.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function OnboardingInterstitialCreatePhrase(): ReactElement {
async function generateThenContinue() {
if (areKeyringsUnlocked) {
await dispatch(generateNewKeyring())
history.push("/onboarding/saveSeed")
history.push("/onboarding/save-seed")
}
},
[areKeyringsUnlocked, dispatch, history]
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Onboarding/OnboardingSaveSeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export default function OnboardingSaveSeed(): ReactElement {
size="medium"
icon="arrow_right"
iconSize="large"
linkTo="/onboarding/verifySeed"
linkTo="/onboarding/verify-seed"
>
I wrote it down
</SharedButton>
Expand Down
5 changes: 4 additions & 1 deletion ui/pages/Onboarding/OnboardingVerifySeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ function SuccessMessage({ mnemonic }: { mnemonic: string[] }) {
type="primary"
onClick={async () => {
await dispatch(
importKeyring({ mnemonic: mnemonic.join(" "), source: "newSeed" })
importKeyring({
mnemonic: mnemonic.join(" "),
source: "internal",
})
)
history.push("/")
}}
Expand Down
8 changes: 1 addition & 7 deletions ui/pages/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function Main(): ReactElement {
function saveHistoryEntries(routeHistoryEntities: Location[]) {
const isNotOnKeyringRelatedPage =
routeHistoryEntities[routeHistoryEntities.length - 1].pathname !==
"/signTransaction" &&
"/sign-transaction" &&
!routeHistoryEntities[routeHistoryEntities.length - 1].pathname.includes(
"/keyring/"
)
Expand Down Expand Up @@ -187,12 +187,6 @@ export function Main(): ReactElement {
<>
<style jsx global>
{`
body {
width: 384px;
height: 594px;
scrollbar-width: none;
}
::-webkit-scrollbar {
width: 0px;
background: transparent;
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Send.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export default function Send(): ReactElement {
hasError
}
linkTo={{
pathname: "/signTransaction",
pathname: "/sign-transaction",
state: {
redirectTo: {
path: "/singleAsset",
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ export default function Swap(): ReactElement {
})
)

history.push("/signTransaction")
history.push("/sign-transaction")
}

const updateSwapData = useCallback(
Expand Down
2 changes: 1 addition & 1 deletion ui/pages/Wallet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export default function Wallet(): ReactElement {

// If an account doesn't exist, display onboarding
if (!hasAccounts) {
return <Redirect to="/onboarding/infoIntro" />
return <Redirect to="/onboarding/info-intro" />
}

return (
Expand Down
7 changes: 6 additions & 1 deletion ui/public/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ body {
background-color: var(--hunter-green);
}

body.popup {
width: 384px;
height: 594px;
scrollbar-width: none;
}

a {
text-decoration: none;
}
Expand Down Expand Up @@ -132,4 +138,3 @@ label {
opacity: 60%;
background-color: var(--green-120);
}

2 changes: 1 addition & 1 deletion ui/public/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<link rel="stylesheet" href="./fonts.css" />
<link rel="stylesheet" href="./index.css" />
</head>
<body>
<body class="popup">
<div id="tally-root" />
<script src="../ui.js" type="text/javascript"></script>
</body>
Expand Down
Loading

0 comments on commit c595525

Please sign in to comment.