Skip to content

Commit

Permalink
Merge pull request #4700 from leather-wallet/release/thursday
Browse files Browse the repository at this point in the history
Release/thursday
  • Loading branch information
kyranjamie authored Dec 14, 2023
2 parents d42aeea + 8d160b0 commit 42682f2
Show file tree
Hide file tree
Showing 49 changed files with 1,787 additions and 1,179 deletions.
27 changes: 18 additions & 9 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ jobs:
- name: Build extension in test mode
run: yarn build:test

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

# Playwright can only test extensions in headed mode, see
# https://playwright.dev/docs/chrome-extensions. To run a browser in
# headed mode, a display server is necessary. However, this job runs on
Expand All @@ -72,7 +77,7 @@ jobs:
- name: Run Playwright tests
run: xvfb-run yarn playwright test tests/specs --shard=${{ matrix.shardIndex }}/${{ matrix.shardTotal }} --workers=1
env:
GITHUB_HEAD_REF: ${{ github.head_ref }}
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
TEST_ACCOUNT_SECRET_KEY: ${{ secrets.TEST_ACCOUNT_SECRET_KEY }}

- name: Upload blob report to GitHub Actions Artifacts
Expand Down Expand Up @@ -105,23 +110,27 @@ jobs:
- name: Merge into HTML Report
run: npx playwright merge-reports --reporter html ./all-blob-reports

- name: Upload HTML report
uses: actions/upload-artifact@v3
with:
name: html-report--attempt-${{ github.run_attempt }}
path: playwright-report
retention-days: 14

- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Deploy
- name: Deploy PR
uses: peaceiris/actions-gh-pages@v3
if: github.event_name == 'pull_request'
with:
personal_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
external_repository: leather-wallet/playwright-reports
publish_branch: main
publish_dir: ./playwright-report
destination_dir: ${{ steps.extract_branch.outputs.branch }}

- name: Deploy specs.leather.io
uses: peaceiris/actions-gh-pages@v3
if: steps.extract_branch.outputs.branch == 'dev'
with:
personal_token: ${{ secrets.SEMANTIC_RELEASE_TOKEN }}
external_repository: leather-wallet/specs.leather.io
publish_branch: main
publish_dir: ./playwright-report
cname: specs.leather.io
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@
"dependencies": {
"@bitcoinerlab/secp256k1": "1.0.2",
"@coinbase/cbpay-js": "1.0.2",
"@dlc-link/dlc-tools": "1.0.7",
"@dlc-link/dlc-tools": "1.0.9",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.1.0",
"@ledgerhq/hw-transport-webusb": "6.27.19",
Expand All @@ -140,7 +140,7 @@
"@scure/bip39": "1.2.1",
"@scure/btc-signer": "1.1.0",
"@segment/analytics-next": "1.56.0",
"@sentry/react": "7.72.0",
"@sentry/react": "7.86.0",
"@sentry/tracing": "7.72.0",
"@stacks/auth": "6.9.0",
"@stacks/blockchain-api-client": "6.3.4",
Expand All @@ -165,7 +165,7 @@
"@typescript-eslint/eslint-plugin": "6.7.4",
"@vkontakte/vk-qr": "2.0.13",
"@zondax/ledger-stacks": "1.0.4",
"alex-sdk": "0.1.22",
"alex-sdk": "0.1.23",
"are-passive-events-supported": "1.1.1",
"argon2-browser": "1.18.0",
"assert": "2.0.0",
Expand Down Expand Up @@ -212,7 +212,7 @@
"react-intersection-observer": "9.5.2",
"react-lottie": "1.2.3",
"react-redux": "8.1.3",
"react-router-dom": "6.16.0",
"react-router-dom": "6.20.1",
"react-virtuoso": "4.6.0",
"redux-persist": "6.0.0",
"rxjs": "7.8.1",
Expand Down
2 changes: 1 addition & 1 deletion panda.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { defineConfig } from '@pandacss/dev';
import { breakpoints } from './theme/breakpoints';
import { globalCss } from './theme/global/global';
import { keyframes } from './theme/keyframes';
import { buttonRecipe } from './theme/recipes/button';
import { buttonRecipe } from './theme/recipes/button-recipe';
import { semanticTokens } from './theme/semantic-tokens';
import { tokens } from './theme/tokens';
import { textStyles } from './theme/typography';
Expand Down
4 changes: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { defineConfig, devices } from '@playwright/test';

console.log('Branch: ', process.env.GITHUB_HEAD_REF);
console.log('Branch: ', process.env.BRANCH_NAME);

/**
* See https://playwright.dev/docs/test-configuration
Expand All @@ -21,7 +21,7 @@ export default defineConfig({
use: {
// Traces are heavy so we want to use them sparingly, but having full trace
// to reference of the latest dev build is useful to inspect.
trace: process.env.GITHUB_HEAD_REF === 'dev' ? 'on' : 'on-first-retry',
trace: process.env.BRANCH_NAME === 'dev' ? 'on' : 'on-first-retry',
},
projects: [
{
Expand Down
7 changes: 5 additions & 2 deletions src/app/common/hooks/use-bitcoin-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export function useBitcoinContracts() {
const defaultParams = useDefaultRequestParams();
const bitcoinMarketData = useCryptoCurrencyMarketData('BTC');
const calculateFiatValue = useCalculateBitcoinFiatValue();

const bitcoinAccountDetails = useCurrentAccountNativeSegwitIndexZeroSigner();
const currentIndex = useCurrentAccountIndex();
const nativeSegwitPrivateKeychain = useNativeSegwitAccountBuilder()?.(currentIndex);
Expand Down Expand Up @@ -236,17 +237,19 @@ export function useBitcoinContracts() {
};
}

async function sumBitcoinContractCollateralAmounts(): Promise<Money | undefined> {
async function sumBitcoinContractCollateralAmounts(): Promise<Money> {
let bitcoinContractsCollateralSum = 0;
const bitcoinContracts = await getAllSignedBitcoinContracts();
if (!bitcoinContracts) return;
if (!bitcoinContracts) return createMoneyFromDecimal(0, 'BTC');

bitcoinContracts.forEach((bitcoinContract: BitcoinContractListItem) => {
bitcoinContractsCollateralSum += parseInt(bitcoinContract.acceptorCollateral);
});
const bitcoinContractCollateralSumMoney = createMoneyFromDecimal(
satToBtc(bitcoinContractsCollateralSum),
'BTC'
);

return bitcoinContractCollateralSumMoney;
}

Expand Down
3 changes: 2 additions & 1 deletion src/app/components/app-version.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const AppVersionLabel = forwardRef<HTMLSpanElement, AppVersionLabelProps>(
ml="space.02"
opacity={0.5}
textDecoration={isLatestVersion ? 'none' : 'line-through'}
textWrap="nowrap"
{...props}
>
{children}
Expand All @@ -36,7 +37,7 @@ export function AppVersion() {
const version = useMemo(() => {
switch (process.env.WALLET_ENVIRONMENT) {
case 'development':
return `dev@${BRANCH_NAME}`;
return BRANCH_NAME;
case 'feature':
return `${BRANCH_NAME}#${COMMIT_SHA?.slice(0, 8)}`;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export function BitcoinContractEntryPointLayout(props: BitcoinContractEntryPoint
: balance.amount.toString();
const formattedBalance = formatBalance(amount);

if (Number(balance.amount) === 0) return null;

return (
<Flex cursor={cursor} onClick={onClick} outline={0}>
<Flag align="middle" img={icon} spacing="space.04" width="100%">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,51 +1,30 @@
import { useState } from 'react';
import { useAsync } from 'react-async-hook';
import { useNavigate } from 'react-router-dom';

import { Money, createMoneyFromDecimal } from '@shared/models/money.model';
import { RouteUrls } from '@shared/route-urls';

import { useBitcoinContracts } from '@app/common/hooks/use-bitcoin-contracts';
import { i18nFormatCurrency } from '@app/common/money/format-money';
import { useCalculateBitcoinFiatValue } from '@app/query/common/market-data/market-data.hooks';
import { useGetBitcoinContractsBalance } from '@app/query/bitcoin/balance/bitcoin-contracts-balance.hooks';
import { BitcoinContractIcon } from '@app/ui/components/icons/bitcoin-contract-icon';

import { BitcoinContractEntryPointLayout } from './bitcoin-contract-entry-point-layout';

interface BitcoinContractEntryPointProps {
btcAddress: string;
}
export function BitcoinContractEntryPoint({ btcAddress }: BitcoinContractEntryPointProps) {
export function BitcoinContractEntryPoint() {
const navigate = useNavigate();
const { sumBitcoinContractCollateralAmounts } = useBitcoinContracts();
const [isLoading, setIsLoading] = useState(true);
const calculateFiatValue = useCalculateBitcoinFiatValue();
const [bitcoinContractSum, setBitcoinContractSum] = useState<Money>(
createMoneyFromDecimal(0, 'BTC')
);

useAsync(async () => {
setIsLoading(true);
const currentBitcoinContractSum = await sumBitcoinContractCollateralAmounts();
if (!currentBitcoinContractSum) return;
setBitcoinContractSum(currentBitcoinContractSum);
setIsLoading(false);
}, [btcAddress]);
const { bitcoinContractsBalance, bitcoinContractsBalanceInUSD, isLoading } =
useGetBitcoinContractsBalance();

function onClick() {
navigate(RouteUrls.BitcoinContractList);
}

return (
!bitcoinContractSum.amount.isZero() && (
<BitcoinContractEntryPointLayout
isLoading={isLoading}
balance={bitcoinContractSum}
caption={bitcoinContractSum.symbol}
icon={<BitcoinContractIcon />}
usdBalance={i18nFormatCurrency(calculateFiatValue(bitcoinContractSum))}
onClick={onClick}
/>
)
<BitcoinContractEntryPointLayout
isLoading={isLoading}
balance={bitcoinContractsBalance}
caption={bitcoinContractsBalance.symbol}
icon={<BitcoinContractIcon />}
usdBalance={bitcoinContractsBalanceInUSD}
onClick={onClick}
/>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { Flex } from 'leather-styles/jsx';

import { HasChildren } from '@app/common/has-children';
import { whenPageMode } from '@app/common/utils';

export function ChooseAssetContainer({ children }: HasChildren) {
return whenPageMode({
full: (
<Flex
borderRadius={['unset', '16px']}
height="fit-content"
maxWidth={['100%', 'centeredPageFullWidth']}
minWidth={['100%', 'centeredPageFullWidth']}
background="accent.background-primary"
>
{children}
</Flex>
),
popup: (
<Flex background="accent.background-primary" width="100%">
{children}
</Flex>
),
});
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box, Flex, StackProps, styled } from 'leather-styles/jsx';

export function ChooseCryptoAssetLayout({ children }: StackProps) {
export function ChooseCryptoAssetLayout({ children, title }: StackProps & { title: string }) {
return (
<Flex
alignItems="left"
Expand All @@ -12,10 +12,8 @@ export function ChooseCryptoAssetLayout({ children }: StackProps) {
pb="space.05"
>
<Box pb="space.05" pt={['unset', 'space.05']} px="space.05">
<styled.h1 textStyle="heading.03">
CHOOSE ASSET
<br />
TO SEND
<styled.h1 width="250px" textStyle="heading.03">
{title}
</styled.h1>
</Box>
{children}
Expand Down
2 changes: 1 addition & 1 deletion src/app/features/asset-list/asset-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export function AssetsList() {
{/* Temporary duplication during Ledger Bitcoin feature dev */}
{['testnet', 'regtest'].includes(network.chain.bitcoin.bitcoinNetwork) &&
whenWallet({
software: <BitcoinContractEntryPoint btcAddress={btcAddress} />,
software: <BitcoinContractEntryPoint />,
ledger: null,
})}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export function ConnectLedgerAssetBtn({ chain }: ConnectLedgerAssetBtnProps) {
display="flex"
alignItems="center"
variant="outline"
height="36px"
size="sm"
gap="space.02"
onClick={onClick}
>
Expand Down
50 changes: 50 additions & 0 deletions src/app/features/feedback-button/feedback-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { BrowserClient, Feedback, getCurrentHub } from '@sentry/react';
import { Flex } from 'leather-styles/jsx';

import { analytics } from '@shared/utils/analytics';

import { useThemeSwitcher } from '@app/common/theme-provider';
import { LeatherButton } from '@app/ui/components/button';
import { MegaphoneIcon } from '@app/ui/components/icons/megaphone-icon';

export function openFeedbackDialog() {
void analytics.track('user_clicked_feedback_button');
const client = getCurrentHub().getClient<BrowserClient>();
const feedback = client?.getIntegration(Feedback);
if (!feedback) return;
feedback.openDialog();
}

export function FeedbackButton() {
const { theme } = useThemeSwitcher();
return (
<LeatherButton
background="brown.1"
_hover={{ background: 'brown.2' }}
variant="ghost"
size="sm"
pos="fixed"
bottom="space.04"
right="space.04"
left="auto"
top="auto"
boxShadow={
theme === 'light'
? '0px 12px 24px 0px rgba(18, 16, 15, 0.08), 0px 4px 8px 0px rgba(18, 16, 15, 0.08), 0px 0px 2px 0px rgba(18, 16, 15, 0.08);'
: undefined
}
filter={
theme === 'dark'
? 'drop-shadow(0px 12px 24px rgba(247, 245, 243, 0.08)) drop-shadow(0px 4px 8px rgba(247, 245, 243, 0.08)) drop-shadow(0px 0px 2px rgba(247, 245, 243, 0.50));'
: undefined
}
zIndex={9}
onClick={openFeedbackDialog}
>
<Flex>
<MegaphoneIcon mr="space.01" mt="2px" />
Give feedback
</Flex>
</LeatherButton>
);
}
Loading

0 comments on commit 42682f2

Please sign in to comment.