Skip to content

Commit

Permalink
Merge pull request #4324 from leather-wallet/release/remove-ordapi
Browse files Browse the repository at this point in the history
Release/remove ordapi
  • Loading branch information
fbwoolf authored Oct 4, 2023
2 parents 5749baa + 55019df commit 71862b8
Show file tree
Hide file tree
Showing 122 changed files with 1,820 additions and 1,471 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/code-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ jobs:
- uses: actions/checkout@v4
- uses: ./.github/actions/provision

- name: Build
run: yarn build

- name: Test
run: yarn test:unit

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:

- uses: ./.github/actions/provision

- name: Build prod
run: yarn build
- name: Build
run: yarn test:coverage

- name: Make badge maker
run: npx make-coverage-badge
Expand Down
37 changes: 30 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# Leather

[![Chrome Web Store](https://img.shields.io/chrome-web-store/stars/ldinpeekobnhjjdofggfgjlcehhmanlj?label=Chrome%20Web%20Store)](https://chrome.google.com/webstore/detail/stacks-wallet/ldinpeekobnhjjdofggfgjlcehhmanlj)
[![Mozilla Add-on](https://img.shields.io/amo/stars/hiro-wallet?label=Firefox%20Add-on)](https://addons.mozilla.org/en-US/firefox/addon/hiro-wallet/)
[![coverage](https://raw.githubusercontent.com/hirosystems/wallet/gh-pages/badge.svg)](https://hirosystems.github.io/wallet/)
[![Mozilla Add-on](https://img.shields.io/amo/stars/leather-wallet?label=Firefox%20Add-on)](https://addons.mozilla.org/en-US/firefox/addon/leather-wallet/)
[![coverage](https://raw.githubusercontent.com/leather-wallet/extension/gh-pages/badge.svg)](https://leather-wallet.github.io/extension/)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Leather is the most popular and trusted wallet for apps built on Bitcoin. Connect to apps and manage assets secured by Bitcoin and Bitcoin L2s with battle-tested wallet for the Stacks blockchain.
Expand Down Expand Up @@ -66,9 +66,32 @@ yarn playwright install --with-deps

Note that the installed browsers are tied to the version of Playwright being used, and it may be necessary to run the above command again in some situations, such as when upgrading Playwright or switching branches. [Read the documentation for more information](https://playwright.dev/docs/cli#install-system-dependencies).

### Integration tests

All integration tests can be run using:

```bash
yarn test:integration
```

To run a suite of tests you can use:

```bash
yarn playwright test specs/TEST.spec.ts
yarn playwright test tests/specs --shard=3/8
```

### Unit tests

Unit tests can be run with vitest using:

```bash
yarn test:unit
```

## Production

[See instructions on Hiro.so for installing from source for production usage.](https://www.hiro.so/wallet/install-web-source)
[See instructions on Leather.io to install from source](https://leather.io/install-extension)

Alternatively, the following steps can be taken by _technical_ users with the latest version of node installed on their machines.

Expand Down Expand Up @@ -98,13 +121,13 @@ We consider the security of our systems a top priority. But no matter how much e

If you discover a security vulnerability, please use one of the following means of communications to report it to us:

- Report the security issue to our [HackerOne program](https://hackerone.com/hiro)
- Report the security issue directly at [security@hiro.so](mailto:security@hiro.so)
- Report the security issue to our [HackerOne program](https://hackerone.com/leather_wallet)
- Report the security issue directly at [security@leather.io](mailto:security@leather.io)

Please note this email is strictly for reporting security vulnerabilities. For support queries, contact [[email protected]](mailto:[email protected]). Your efforts to responsibly disclose your findings are sincerely appreciated and will be taken into account to acknowledge your contributions.

### Audit Report

In Q1 2021, Hiro partnered with [Least Authority](https://leastauthority.com/), a leading security consultancy with experience in the crypto space, to audit Leather. On April 29th 2021, after addressing the major concerns described in the initial findings, as well as a concluding sign off from the Least Authority team, a final report was delivered.
In Q1 2021, Leather partnered with [Least Authority](https://leastauthority.com/), a leading security consultancy with experience in the crypto space, to audit Leather. On April 29th 2021, after addressing the major concerns described in the initial findings, as well as a concluding sign off from the Least Authority team, a final report was delivered.

[Download and read the full report here](https://github.com/hirosystems/wallet/blob/main/public/docs/least-authority-security-audit-report.pdf)
[Download and read the full report here](https://github.com/leather-wallet/extension/blob/main/public/docs/least-authority-security-audit-report.pdf)
46 changes: 22 additions & 24 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,14 @@
"lint:fix": "eslint \"src/**/*.{ts,tsx}\" --fix",
"lint:prettier": "prettier --check \"{src,tests}/**/*.{ts,tsx}\" \"*.{js,json}\"",
"lint:prettier:fix": "prettier --write \"{src,tests}/**/*.{ts,tsx}\" *.js",
"lint:unused-exports": "ts-unused-exports tsconfig.json --ignoreFiles=leather-styles",
"lint:unused-exports": "ts-unused-exports tsconfig.json --ignoreFiles=leather-styles --ignoreFiles=tests",
"lint:remote-wallet-config": "npx ajv-cli validate -s config/wallet-config.schema.json -d config/wallet-config.json",
"lint:deps": "dependency-cruise --config .dependency-cruiser.js \"src/**/*.{ts,tsx}\"",
"prod:ext": "yarn build",
"prod:analyze": "cross-env WALLET_ENVIRONMENT=production ANALYZE=true webpack -p",
"test:integration": "playwright test",
"test:unit": "vitest run",
"test:coverage": "WALLET_ENVIRONMENT=testing jest --collect-coverage",
"test:watch": "WALLET_ENVIRONMENT=testing jest --watch",
"test:coverage": "vitest run --coverage",
"typecheck": "tsc --noEmit",
"prepare": "panda codegen"
},
Expand Down Expand Up @@ -160,13 +159,13 @@
"@stacks/wallet-sdk": "6.9.0",
"@stitches/react": "1.2.8",
"@styled-system/theme-get": "5.1.2",
"@tanstack/query-sync-storage-persister": "4.35.3",
"@tanstack/react-query": "4.35.3",
"@tanstack/react-query-devtools": "4.35.3",
"@tanstack/react-query-persist-client": "4.35.5",
"@tanstack/query-sync-storage-persister": "4.35.7",
"@tanstack/react-query": "4.35.7",
"@tanstack/react-query-devtools": "4.35.7",
"@tanstack/react-query-persist-client": "4.35.7",
"@tippyjs/react": "4.2.6",
"@types/lodash.uniqby": "4.7.7",
"@typescript-eslint/eslint-plugin": "6.7.3",
"@typescript-eslint/eslint-plugin": "6.7.4",
"@vkontakte/vk-qr": "2.0.13",
"@zondax/ledger-stacks": "1.0.4",
"are-passive-events-supported": "1.1.1",
Expand All @@ -188,7 +187,7 @@
"dotenv": "16.3.1",
"ecdsa-sig-formatter": "1.0.11",
"ecpair": "2.1.0",
"formik": "2.4.3",
"formik": "2.4.5",
"jotai": "2.2.1",
"jotai-redux": "0.2.1",
"jsontokens": "4.0.1",
Expand All @@ -199,8 +198,8 @@
"mdi-react": "9.2.0",
"micro-packed": "0.3.2",
"object-hash": "3.0.0",
"observable-hooks": "4.2.2",
"pino": "8.15.1",
"observable-hooks": "4.2.3",
"pino": "8.15.4",
"postcss-preset-env": "9.1.4",
"prismjs": "1.29.0",
"promise-memoize": "1.2.1",
Expand All @@ -215,7 +214,7 @@
"react-icons": "4.10.1",
"react-intersection-observer": "9.5.2",
"react-lottie": "1.2.3",
"react-redux": "8.1.2",
"react-redux": "8.1.3",
"react-router-dom": "6.16.0",
"react-virtuoso": "4.6.0",
"redux-persist": "6.0.0",
Expand All @@ -229,7 +228,7 @@
"valid-url": "1.0.9",
"varuint-bitcoin": "1.1.2",
"webextension-polyfill": "0.10.0",
"yup": "1.3.1",
"yup": "1.3.2",
"zxcvbn": "4.4.2"
},
"devDependencies": {
Expand All @@ -239,7 +238,7 @@
"@babel/preset-typescript": "7.23.0",
"@btckit/types": "0.0.19",
"@ls-lint/ls-lint": "2.1.0",
"@pandacss/dev": "0.15.3",
"@pandacss/dev": "0.15.4",
"@playwright/test": "1.38.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@redux-devtools/cli": "3.0.2",
Expand All @@ -258,13 +257,13 @@
"@types/html-webpack-plugin": "3.2.7",
"@types/jsdom": "21.1.3",
"@types/lodash.get": "4.4.7",
"@types/node": "20.7.1",
"@types/node": "20.8.2",
"@types/object-hash": "3.0.4",
"@types/prismjs": "1.26.1",
"@types/promise-memoize": "1.2.2",
"@types/punycode": "2.1.0",
"@types/qrcode.react": "1.0.2",
"@types/react": "18.2.23",
"@types/qrcode.react": "1.0.3",
"@types/react": "18.2.24",
"@types/react-dom": "18.2.8",
"@types/react-lottie": "1.2.7",
"@types/react-router-dom": "5.3.3",
Expand All @@ -274,24 +273,23 @@
"@types/webextension-polyfill": "0.10.4",
"@types/webpack": "5.28.3",
"@types/zxcvbn": "4.4.2",
"@typescript-eslint/parser": "6.7.3",
"@typescript-eslint/parser": "6.7.4",
"@vitest/coverage-istanbul": "0.34.6",
"audit-ci": "6.6.1",
"babel-loader": "9.1.3",
"base64-loader": "1.0.0",
"bip32": "4.0.0",
"bip39": "3.1.0",
"blns": "2.0.4",
"browserslist": "4.22.0",
"browserslist": "4.22.1",
"chrome-webstore-upload-cli": "2.2.2",
"clean-webpack-plugin": "4.0.0",
"concurrently": "8.0.1",
"conventional-changelog-conventionalcommits": "6.1.0",
"conventional-changelog-conventionalcommits": "7.0.2",
"copy-webpack-plugin": "11.0.0",
"cross-env": "7.0.3",
"crypto-browserify": "3.12.0",
"deepmerge": "4.3.1",
"dependency-cruiser": "14.0.0",
"dependency-cruiser": "14.1.0",
"dotenv-webpack": "8.0.1",
"esbuild": "0.19.4",
"esbuild-loader": "4.0.2",
Expand All @@ -314,13 +312,13 @@
"stream-browserify": "3.0.0",
"svg-url-loader": "8.0.0",
"ts-node": "10.9.1",
"ts-unused-exports": "7.0.3",
"ts-unused-exports": "10.0.1",
"tsconfig-paths-webpack-plugin": "4.1.0",
"typescript": "5.2.2",
"vitest": "0.34.6",
"vm-browserify": "1.1.2",
"web-ext": "7.8.0",
"web-ext-submit": "7.7.0",
"web-ext-submit": "7.8.0",
"webpack": "5.88.2",
"webpack-bundle-analyzer": "4.9.1",
"webpack-cli": "5.1.4",
Expand Down
2 changes: 1 addition & 1 deletion src/app/common/form-utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { useField, useFormikContext } from 'formik';

function useIsFieldDirty(name: string) {
export function useIsFieldDirty(name: string) {
const [field, meta] = useField(name);
return field.value !== meta.initialValue;
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/common/hooks/balance/btc/use-btc-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { baseCurrencyAmountInQuote, subtractMoney } from '@app/common/money/calc
import { i18nFormatCurrency } from '@app/common/money/format-money';
import { createBitcoinCryptoCurrencyAssetTypeWrapper } from '@app/query/bitcoin/address/address.utils';
import { useBitcoinPendingTransactionsBalance } from '@app/query/bitcoin/address/transactions-by-address.hooks';
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';
import { useCryptoCurrencyMarketData } from '@app/query/common/market-data/market-data.hooks';

export function useBtcAssetBalance(btcAddress: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useMemo } from 'react';

import type { AllTransferableCryptoAssetBalances } from '@shared/models/crypto-asset-balance.model';

import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';
import { useTransferableStacksFungibleTokenAssetBalances } from '@app/query/stacks/balance/stacks-ft-balances.hooks';
import { createStacksCryptoCurrencyAssetTypeWrapper } from '@app/query/stacks/balance/stacks-ft-balances.utils';
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';
Expand Down
24 changes: 13 additions & 11 deletions src/app/components/account/account-list-item-layout.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { Flex, Spinner, Stack, StackProps, color, useMediaQuery } from '@stacks/ui';
import { Spinner } from '@stacks/ui';
import { truncateMiddle } from '@stacks/ui-utils';
import { SettingsSelectors } from '@tests/selectors/settings.selectors';
import { HStack, styled } from 'leather-styles/jsx';
import { Flex, HStack, Stack, StackProps, styled } from 'leather-styles/jsx';
import { token } from 'leather-styles/tokens';

import { useViewportMinWidth } from '@app/common/hooks/use-media-query';
import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query';

import { CaptionDotSeparator } from '../caption-dot-separator';
Expand Down Expand Up @@ -41,7 +43,7 @@ export function AccountListItemLayout(props: AccountListItemLayoutProps) {
...rest
} = props;

const [isNarrowViewport] = useMediaQuery('(max-width: 400px)');
const isBreakpointSm = useViewportMinWidth('sm');
const isBitcoinEnabled = useConfigBitcoinEnabled();

return (
Expand All @@ -54,35 +56,35 @@ export function AccountListItemLayout(props: AccountListItemLayoutProps) {
onClick={onSelectAccount}
{...rest}
>
<Flag align="middle" img={avatar} spacing="base" width="100%">
<Stack spacing="extra-tight">
<Flag align="middle" img={avatar} spacing="space.04" width="100%" mr="space.04">
<Stack gap="space.01">
<HStack alignItems="center" justifyContent="space-between">
<Stack alignItems="center" isInline space="tight">
<HStack alignItems="center" gap="space.02">
{accountName}
{isActive && <CheckmarkIcon />}
</Stack>
</HStack>
{isLoading ? (
<Spinner
position="absolute"
right={0}
top="calc(50% - 8px)"
color={color('text-caption')}
color={token('colors.accent.text-subdued')}
size="18px"
/>
) : (
balanceLabel
)}
</HStack>
<Stack alignItems="center" spacing="6px" isInline whiteSpace="nowrap">
<HStack alignItems="center" gap="space.02" whiteSpace="nowrap">
<CaptionDotSeparator>
<styled.span textStyle="caption.02">
{truncateMiddle(stxAddress, isNarrowViewport ? 3 : 4)}
{truncateMiddle(stxAddress, isBreakpointSm ? 4 : 3)}
</styled.span>
{isBitcoinEnabled && (
<styled.span textStyle="caption.02">{truncateMiddle(btcAddress, 5)}</styled.span>
)}
</CaptionDotSeparator>
</Stack>
</HStack>
</Stack>
</Flag>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/app/components/balance-btc.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { formatMoney } from '@app/common/money/format-money';
import { Caption } from '@app/components/typography';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';

export function BtcBalance() {
const balance = useCurrentNativeSegwitAddressBalance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import {
determineUtxosForSpend,
determineUtxosForSpendAll,
} from '@app/common/transactions/bitcoin/coinselect/local-coin-selection';
import { useSpendableCurrentNativeSegwitAccountUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useCurrentNativeSegwitAccountSpendableUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';
import { useCryptoCurrencyMarketData } from '@app/query/common/market-data/market-data.hooks';

export const MAX_FEE_RATE_MULTIPLIER = 50;
Expand All @@ -21,7 +21,7 @@ interface UseBitcoinCustomFeeArgs {
}
export function useBitcoinCustomFee({ amount, isSendingMax, recipient }: UseBitcoinCustomFeeArgs) {
const balance = useCurrentNativeSegwitAddressBalance();
const { data: utxos = [] } = useSpendableCurrentNativeSegwitAccountUtxos();
const { data: utxos = [] } = useCurrentNativeSegwitAccountSpendableUtxos();
const btcMarketData = useCryptoCurrencyMarketData('BTC');

return useCallback(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
determineUtxosForSpend,
determineUtxosForSpendAll,
} from '@app/common/transactions/bitcoin/coinselect/local-coin-selection';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useCurrentNativeSegwitAddressBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';
import { UtxoResponseItem } from '@app/query/bitcoin/bitcoin-client';
import { useAverageBitcoinFeeRates } from '@app/query/bitcoin/fees/fee-estimates.hooks';
import { useCryptoCurrencyMarketData } from '@app/query/common/market-data/market-data.hooks';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import {
convertInscriptionToSupportedInscriptionType,
createInscriptionInfoUrl,
} from '@app/query/bitcoin/ordinals/inscription.hooks';
import { useGetInscriptionsByOutputQuery } from '@app/query/bitcoin/ordinals/use-inscription-by-output.query';
import { useGetInscriptionsByOutputQuery } from '@app/query/bitcoin/ordinals/inscriptions-by-param.query';
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';

import { CaptionDotSeparator } from '../caption-dot-separator';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { noop } from '@shared/utils';

import { Brc20TokenAssetItem } from '@app/components/crypto-assets/bitcoin/brc20-token-asset-list/components/brc20-token-asset-item';
import { Tooltip } from '@app/components/tooltip';
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/bitcoin-balances.query';
import { useNativeSegwitBalance } from '@app/query/bitcoin/balance/btc-native-segwit-balance.hooks';
import { Brc20Token } from '@app/query/bitcoin/ordinals/brc20/brc20-tokens.query';
import { useCurrentAccountNativeSegwitAddressIndexZero } from '@app/store/accounts/blockchain/bitcoin/native-segwit-account.hooks';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import { Box, Spinner, Text } from '@stacks/ui';
import { sanitize } from 'dompurify';

import { figmaTheme } from '@app/common/utils/figma-theme';
import { useTextInscriptionContentQuery } from '@app/query/bitcoin/ordinals/use-text-ordinal-content.query';
import { useInscriptionTextContentQuery } from '@app/query/bitcoin/ordinals/inscription-text-content.query';

interface InscriptionTextProps {
contentSrc: string;
}
export function InscriptionText(props: InscriptionTextProps) {
const query = useTextInscriptionContentQuery(props.contentSrc);
const query = useInscriptionTextContentQuery(props.contentSrc);

if (query.isLoading) return <Spinner color={figmaTheme.icon} size="16px" />;

Expand Down
Loading

0 comments on commit 71862b8

Please sign in to comment.