Skip to content

Commit

Permalink
Merge pull request #4676 from leather-wallet/release/tuesday-morning
Browse files Browse the repository at this point in the history
Release/tuesday morning
  • Loading branch information
kyranjamie authored Dec 12, 2023
2 parents 568e498 + 3d5ca6d commit 08e659f
Show file tree
Hide file tree
Showing 74 changed files with 1,675 additions and 458 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ jobs:
- pre-run
strategy:
matrix:
target: [chromium, firefox]
# Firefox removed while off store
target: [chromium]
steps:
- uses: actions/checkout@v4
with:
Expand Down Expand Up @@ -65,7 +66,12 @@ jobs:
- pre-run
- build
steps:
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- uses: kyranjamie/[email protected]
with:
header: '> Try out this version of Leather — [download extension builds](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}).'
header: '> Try out this version of Leather — [Extension build](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}), [Test report](https://leather-wallet.github.io/playwright-reports/${{ steps.extract_branch.outputs.branch }})'
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: GH pages
name: Publish unit test coverage

on:
push:
Expand Down
56 changes: 51 additions & 5 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Playwright Tests
name: Integration Tests

env:
CI: true
Expand Down Expand Up @@ -72,10 +72,56 @@ 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 }}
TEST_ACCOUNT_SECRET_KEY: ${{ secrets.TEST_ACCOUNT_SECRET_KEY }}
- uses: actions/upload-artifact@v3

- name: Upload blob report to GitHub Actions Artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: all-blob-reports
path: blob-report
retention-days: 1
if-no-files-found: error

merge-reports:
name: Merge reports
if: always()
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3

- name: Install dependencies
run: yarn --frozen-lockfile

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
name: all-blob-reports
path: all-blob-reports

- 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
uses: peaceiris/actions-gh-pages@v3
with:
name: playwright-report
path: playwright-report/
retention-days: 10
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 }}
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"prettier.documentSelectors": ["src/**/*.{ts,tsx}", "*.{js,json}"],
"vitest.include": ["src/**/*.spec.ts"],
"githubPullRequests.ignoredPullRequestBranches": ["dev"]
"githubPullRequests.ignoredPullRequestBranches": ["dev"],
"typescript.preferences.preferTypeOnlyAutoImports": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@
"@leather-wallet/tokens": "0.0.2",
"@ls-lint/ls-lint": "2.1.0",
"@pandacss/dev": "0.18.3",
"@playwright/test": "1.38.1",
"@playwright/test": "1.40.1",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@redux-devtools/cli": "3.0.2",
"@redux-devtools/remote": "0.8.1",
Expand Down
11 changes: 9 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { defineConfig, devices } from '@playwright/test';

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

/**
* See https://playwright.dev/docs/test-configuration
*/
Expand All @@ -12,9 +14,14 @@ export default defineConfig({
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [[process.env.CI ? 'github' : 'list'], ['html', { open: 'never' }]],
reporter: [
[process.env.CI ? 'github' : 'list'],
[process.env.CI ? 'blob' : 'html', { open: 'never' }],
],
use: {
trace: 'on-first-retry',
// 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',
},
projects: [
{
Expand Down
8 changes: 7 additions & 1 deletion src/app/features/collectibles/collectibles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ export function Collectibles() {
subHeader={whenWallet({
software: (
<TaprootBalanceDisplayer
onSelectRetrieveBalance={() => navigate(RouteUrls.RetriveTaprootFunds)}
onSelectRetrieveBalance={() =>
navigate(RouteUrls.RetrieveTaprootFunds, {
state: {
backgroundLocation: { pathname: RouteUrls.Home },
},
})
}
/>
),
ledger: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import * as btc from '@scure/btc-signer';
import { hexToBytes } from '@stacks/common';
import get from 'lodash.get';

import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { logger } from '@shared/logger';
import { RouteUrls } from '@shared/route-urls';

Expand Down Expand Up @@ -45,7 +46,7 @@ function LedgerSignBitcoinTxContainer() {
const [unsignedTransaction, setUnsignedTransaction] = useState<null | btc.Transaction>(null);
const signLedger = useSignLedgerBitcoinTx();

const inputsToSign = useLocationStateWithCache<number[]>('inputsToSign');
const inputsToSign = useLocationStateWithCache<BitcoinInputSigningConfig[]>('inputsToSign');
const allowUserToGoBack = useLocationState<boolean>('goBack');

useEffect(() => {
Expand All @@ -68,12 +69,12 @@ function LedgerSignBitcoinTxContainer() {

try {
const versionInfo = await getBitcoinAppVersion(bitcoinApp);

ledgerAnalytics.trackDeviceVersionInfo(versionInfo);
setAwaitingDeviceConnection(false);

setLatestDeviceResponse(versionInfo as any);
} catch (e) {}
} catch (e) {
logger.error('Unable to get Ledger app version info', e);
}

ledgerNavigate.toDeviceBusyStep('Verifying public key on Ledger…');

Expand All @@ -84,7 +85,11 @@ function LedgerSignBitcoinTxContainer() {
ledgerNavigate.toAwaitingDeviceOperation({ hasApprovedOperation: false });

try {
const btcTx = await signLedger(bitcoinApp, unsignedTransaction.toPSBT(), inputsToSign);
const btcTx = await signLedger(
bitcoinApp,
unsignedTransaction.toPSBT(),
inputsToSign?.map(x => x.index)
);

if (!btcTx || !unsignedTransactionRaw) throw new Error('No tx returned');
ledgerNavigate.toAwaitingDeviceOperation({ hasApprovedOperation: true });
Expand Down
6 changes: 5 additions & 1 deletion src/app/features/ledger/hooks/use-ledger-navigate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { bytesToHex } from '@stacks/common';
import { ClarityValue, StacksTransaction } from '@stacks/transactions';

import { SupportedBlockchains } from '@shared/constants';
import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { RouteUrls } from '@shared/route-urls';

import { immediatelyAttemptLedgerConnection } from './use-when-reattempt-ledger-connection';
Expand All @@ -30,7 +31,10 @@ export function useLedgerNavigate() {
});
},

toConnectAndSignBitcoinTransactionStep(psbt: Uint8Array, inputsToSign?: number[]) {
toConnectAndSignBitcoinTransactionStep(
psbt: Uint8Array,
inputsToSign?: BitcoinInputSigningConfig[]
) {
return navigate(RouteUrls.ConnectLedger, {
replace: true,
relative: 'route',
Expand Down
6 changes: 3 additions & 3 deletions src/app/features/ledger/utils/stacks-ledger-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,11 @@ export function signLedgerStacksStructuredMessage(app: StacksApp) {
}

export function signStacksTransactionWithSignature(transaction: string, signatureVRS: Buffer) {
const deserialzedTx = deserializeTransaction(transaction);
const deserializedTx = deserializeTransaction(transaction);
const spendingCondition = createMessageSignature(signatureVRS.toString('hex'));
(deserialzedTx.auth.spendingCondition as SingleSigSpendingCondition).signature =
(deserializedTx.auth.spendingCondition as SingleSigSpendingCondition).signature =
spendingCondition;
return deserialzedTx;
return deserializedTx;
}

export function useActionCancellableByUser() {
Expand Down
9 changes: 5 additions & 4 deletions src/app/features/psbt-signer/hooks/use-psbt-signer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { useMemo } from 'react';
import { hexToBytes } from '@noble/hashes/utils';
import * as btc from '@scure/btc-signer';

import { BitcoinInputSigningConfig } from '@shared/crypto/bitcoin/signer-config';
import { logger } from '@shared/logger';
import { isString } from '@shared/utils';

Expand All @@ -14,7 +15,7 @@ import {
export type RawPsbt = ReturnType<typeof btc.RawPSBTV0.decode>;

interface SignPsbtArgs {
indexesToSign?: number[];
signingConfig: BitcoinInputSigningConfig[];
tx: btc.Transaction;
}
export function usePsbtSigner() {
Expand All @@ -23,9 +24,9 @@ export function usePsbtSigner() {

return useMemo(
() => ({
async signPsbt({ indexesToSign, tx }: SignPsbtArgs) {
addMissingTapInteralKeys(tx, indexesToSign);
return signBitcoinTx(tx.toPSBT(), indexesToSign);
async signPsbt({ signingConfig, tx }: SignPsbtArgs) {
addMissingTapInteralKeys(tx, signingConfig);
return signBitcoinTx(tx.toPSBT(), signingConfig);
},
getPsbtAsTransaction(psbt: string | Uint8Array) {
const bytes = isString(psbt) ? hexToBytes(psbt) : psbt;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Disclaimer } from '@app/components/disclaimer';

interface DisclaimerProps {
appName?: string;
appName?: string | null;
}
export function StacksMessageSigningDisclaimer({ appName }: DisclaimerProps) {
return (
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { ChainID, bytesToHex } from '@stacks/common';
import { hashMessage } from '@stacks/encryption';

import { UnsignedMessage } from '@shared/signature/signature-types';

import { NoFeesWarningRow } from '@app/components/no-fees-warning-row';

import { MessagePreviewBox } from '../../../features/message-signer/message-preview-box';
import { SignMessageActions } from '../../../features/message-signer/stacks-sign-message-action';
import { Utf8Payload } from '../stacks-message-signing';
import { StacksMessageSigningDisclaimer } from './message-signing-disclaimer';

interface SignatureRequestMessageContentProps {
isLoading: boolean;
onSignMessage(unsignedMessage: UnsignedMessage): Promise<void>;
onCancelMessageSigning(): void;
payload: Utf8Payload;
}
export function StacksSignatureRequestMessageContent({
isLoading,
onSignMessage,
onCancelMessageSigning,
payload,
}: SignatureRequestMessageContentProps) {
return (
<>
<MessagePreviewBox
message={payload.message}
hash={bytesToHex(hashMessage(payload.message))}
/>
<NoFeesWarningRow chainId={payload.network?.chainId ?? ChainID.Testnet} />
<SignMessageActions
isLoading={isLoading}
onSignMessageCancel={onCancelMessageSigning}
onSignMessage={() => onSignMessage({ messageType: 'utf8', message: payload.message })}
/>
<hr />
<StacksMessageSigningDisclaimer appName={payload.appName} />
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { ChainID } from '@stacks/common';

import { UnsignedMessage } from '@shared/signature/signature-types';

import { NoFeesWarningRow } from '@app/components/no-fees-warning-row';
import { SignMessageActions } from '@app/features/message-signer/stacks-sign-message-action';

import { StructuredPayload } from '../stacks-message-signing';
import { StacksMessageSigningDisclaimer } from './message-signing-disclaimer';
import { StructuredDataBox } from './structured-data-box';

interface SignatureRequestStructuredDataContentProps {
isLoading: boolean;
onSignMessage(unsignedMessage: UnsignedMessage): Promise<void>;
onCancelMessageSigning(): void;
payload: StructuredPayload;
}
export function SignatureRequestStructuredDataContent({
isLoading,
onSignMessage,
onCancelMessageSigning,
payload,
}: SignatureRequestStructuredDataContentProps) {
return (
<>
<StructuredDataBox message={payload.message} domain={payload.domain} />
<NoFeesWarningRow chainId={payload.network?.chainId ?? ChainID.Testnet} />
<SignMessageActions
isLoading={isLoading}
onSignMessageCancel={onCancelMessageSigning}
onSignMessage={() =>
onSignMessage({
messageType: 'structured',
message: payload.message,
domain: payload.domain,
})
}
/>
<hr />
<StacksMessageSigningDisclaimer appName={payload.appName} />
</>
);
}
Loading

0 comments on commit 08e659f

Please sign in to comment.