Skip to content

Commit

Permalink
Merge pull request #5412 from leather-wallet/release/stamp-schema-fix
Browse files Browse the repository at this point in the history
Release/stamp schema fix
  • Loading branch information
alter-eggo authored May 22, 2024
2 parents d9894a4 + 5903a7b commit 6a598c8
Show file tree
Hide file tree
Showing 119 changed files with 1,217 additions and 1,297 deletions.
10 changes: 2 additions & 8 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ jobs:
strategy:
fail-fast: false
matrix:
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8]
shardTotal: [8]
shardIndex: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
shardTotal: [10]

steps:
- uses: actions/checkout@v4
Expand Down Expand Up @@ -91,12 +91,6 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up pnpm
uses: pnpm/action-setup@v4

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Download blob reports from GitHub Actions Artifacts
uses: actions/download-artifact@v3
with:
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"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=icons --ignoreFiles=leather-styles --ignoreFiles=tests --excludePathsFromReport=.*stories",
"lint:unused-exports": "ts-unused-exports tsconfig.json --ignoreFiles=icons --ignoreFiles=leather-styles --ignoreFiles=mocks --ignoreFiles=tests --excludePathsFromReport=.*stories",
"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": "pnpm build",
Expand Down Expand Up @@ -135,8 +135,8 @@
"@dlc-link/dlc-tools": "1.1.1",
"@fungible-systems/zone-file": "2.0.0",
"@hirosystems/token-metadata-api-client": "1.2.0",
"@leather-wallet/models": "0.4.4",
"@leather-wallet/tokens": "0.0.14",
"@leather-wallet/models": "0.6.3",
"@leather-wallet/tokens": "0.0.15",
"@ledgerhq/hw-transport-webusb": "6.27.19",
"@noble/hashes": "1.3.2",
"@noble/secp256k1": "2.0.0",
Expand Down Expand Up @@ -257,7 +257,7 @@
"@ls-lint/ls-lint": "2.2.3",
"@mdx-js/loader": "3.0.0",
"@pandacss/dev": "0.32.0",
"@playwright/test": "1.42.1",
"@playwright/test": "1.44.0",
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
"@redux-devtools/cli": "4.0.0",
"@redux-devtools/remote": "0.9.3",
Expand Down
5 changes: 4 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ export default defineConfig({
testDir: './tests',
timeout: 30 * 1000,
expect: { timeout: 5000 },
fullyParallel: true,
// Extensions live cross-worker meaning `chrome.storage` is shared. Disabling
// `fullyParallel` means fewer tests run at the same time, but ensures a
// truely new context is used each time
fullyParallel: false,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
Expand Down
36 changes: 18 additions & 18 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 3 additions & 6 deletions src/app/common/hooks/balance/use-total-balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function useTotalBalance({ btcAddress, stxAddress }: UseTotalBalanceArgs)

// get btc balance
const {
btcCryptoAssetBalance,
balance: btcBalance,
isLoading: isLoadingBtcBalance,
isFetching: isFetchingBtcBalance,
isInitialLoading: isInititalLoadingBtcBalance,
Expand All @@ -37,10 +37,7 @@ export function useTotalBalance({ btcAddress, stxAddress }: UseTotalBalanceArgs)
return useMemo(() => {
// calculate total balance
const stxUsdAmount = baseCurrencyAmountInQuote(stxBalance, stxMarketData);
const btcUsdAmount = baseCurrencyAmountInQuote(
btcCryptoAssetBalance.availableBalance,
btcMarketData
);
const btcUsdAmount = baseCurrencyAmountInQuote(btcBalance.availableBalance, btcMarketData);

const totalBalance = { ...stxUsdAmount, amount: stxUsdAmount.amount.plus(btcUsdAmount.amount) };
return {
Expand All @@ -56,7 +53,7 @@ export function useTotalBalance({ btcAddress, stxAddress }: UseTotalBalanceArgs)
}, [
stxBalance,
stxMarketData,
btcCryptoAssetBalance.availableBalance,
btcBalance.availableBalance,
btcMarketData,
isLoading,
isLoadingBtcBalance,
Expand Down
3 changes: 1 addition & 2 deletions src/app/common/hooks/use-submit-stx-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ export function useSubmitTransactionCallback({ loadingKey }: UseSubmitTransactio
rawTx: bytesToHex(transaction.serialize()),
txId: safelyFormatHexTxid(response.txid),
});
await delay(500);
toast.success('Transaction submitted!');

await delay(500);

void analytics.track('broadcast_transaction', { symbol: 'stx' });
Expand Down
17 changes: 14 additions & 3 deletions src/app/common/validation/forms/amount-validators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import * as yup from 'yup';

import { Money } from '@shared/models/money.model';
import { isNumber } from '@shared/utils';
import { analytics } from '@shared/utils/analytics';

import { countDecimals } from '@app/common/math/helpers';
import { convertAmountToBaseUnit } from '@app/common/money/calculate-money';
import {
btcToSat,
microStxToStx,
Expand Down Expand Up @@ -90,8 +92,16 @@ export function stxAvailableBalanceValidator(availableBalance: Money) {
microStxToStx(sum.amount).toString()
),
test(value: unknown) {
const fee = stxToMicroStx(this.parent.fee);
if (!availableBalance || !isNumber(value)) return false;
const fee = new BigNumber(stxToMicroStx(this.parent.fee));
if (!fee.isFinite()) {
void analytics.track('unable_to_read_fee_in_stx_validator');
return this.createError({ message: 'Unable to read current fee' });
}
if (!isNumber(value)) return false;
if (!availableBalance) {
void analytics.track('unable_to_read_available_balance_in_stx_validator');
return this.createError({ message: 'Available balance unknown' });
}
const availableBalanceLessFee = availableBalance.amount.minus(fee);
return availableBalanceLessFee.isGreaterThanOrEqualTo(stxToMicroStx(value));
},
Expand All @@ -100,6 +110,7 @@ export function stxAvailableBalanceValidator(availableBalance: Money) {

export function stacksFungibleTokenAmountValidator(balance: Money) {
const { amount, decimals } = balance;

return amountValidator()
.test((value, context) => {
if (!isNumber(value)) return false;
Expand All @@ -116,7 +127,7 @@ export function stacksFungibleTokenAmountValidator(balance: Money) {
message: formatInsufficientBalanceError(balance, sum => microStxToStx(sum.amount).toString()),
test(value) {
if (!isNumber(value) || !amount) return false;
return new BigNumber(value).isLessThanOrEqualTo(amount);
return new BigNumber(value).isLessThanOrEqualTo(convertAmountToBaseUnit(amount, decimals));
},
});
}
Expand Down
8 changes: 4 additions & 4 deletions src/app/components/balance/btc-balance.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { formatMoney } from '@app/common/money/format-money';
import { Caption } from '@app/ui/components/typography/caption';

import { BitcoinNativeSegwitAccountLoader } from '../loaders/bitcoin-account-loader';
import { BtcCryptoAssetLoader } from '../loaders/btc-crypto-asset-loader';
import { BtcBalanceLoader } from '../loaders/btc-balance-loader';

export function BtcBalance() {
return (
<BitcoinNativeSegwitAccountLoader current>
{signer => (
<BtcCryptoAssetLoader address={signer.address}>
{asset => <Caption>{formatMoney(asset.balance.availableBalance)}</Caption>}
</BtcCryptoAssetLoader>
<BtcBalanceLoader address={signer.address}>
{balance => <Caption>{formatMoney(balance.availableBalance)}</Caption>}
</BtcBalanceLoader>
)}
</BitcoinNativeSegwitAccountLoader>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
determineUtxosForSpendAll,
} from '@app/common/transactions/bitcoin/coinselect/local-coin-selection';
import { useCurrentNativeSegwitUtxos } from '@app/query/bitcoin/address/utxos-by-address.hooks';
import { useCurrentBtcAvailableBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { useCurrentBtcCryptoAssetBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { useCryptoCurrencyMarketDataMeanAverage } from '@app/query/common/market-data/market-data.hooks';

export const MAX_FEE_RATE_MULTIPLIER = 50;
Expand All @@ -22,15 +22,17 @@ interface UseBitcoinCustomFeeArgs {
}

export function useBitcoinCustomFee({ amount, isSendingMax, recipients }: UseBitcoinCustomFeeArgs) {
const { balance } = useCurrentBtcAvailableBalanceNativeSegwit();
const { balance } = useCurrentBtcCryptoAssetBalanceNativeSegwit();
const { data: utxos = [] } = useCurrentNativeSegwitUtxos();
const btcMarketData = useCryptoCurrencyMarketDataMeanAverage('BTC');

return useCallback(
(feeRate: number) => {
if (!feeRate || !utxos.length) return { fee: 0, fiatFeeValue: '' };

const satAmount = isSendingMax ? balance.amount.toNumber() : amount.amount.toNumber();
const satAmount = isSendingMax
? balance.availableBalance.amount.toNumber()
: amount.amount.toNumber();

const determineUtxosArgs = {
amount: satAmount,
Expand All @@ -49,6 +51,6 @@ export function useBitcoinCustomFee({ amount, isSendingMax, recipients }: UseBit
)}`,
};
},
[utxos, isSendingMax, balance.amount, amount.amount, recipients, btcMarketData]
[utxos, isSendingMax, balance.availableBalance.amount, amount.amount, recipients, btcMarketData]
);
}
10 changes: 6 additions & 4 deletions src/app/components/bitcoin-fees-list/use-bitcoin-fees-list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
determineUtxosForSpend,
determineUtxosForSpendAll,
} from '@app/common/transactions/bitcoin/coinselect/local-coin-selection';
import { useCurrentBtcAvailableBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { useCurrentBtcCryptoAssetBalanceNativeSegwit } from '@app/query/bitcoin/balance/btc-balance-native-segwit.hooks';
import { UtxoResponseItem } from '@app/query/bitcoin/bitcoin-client';
import { useAverageBitcoinFeeRates } from '@app/query/bitcoin/fees/fee-estimates.hooks';
import { useCryptoCurrencyMarketDataMeanAverage } from '@app/query/common/market-data/market-data.hooks';
Expand Down Expand Up @@ -43,7 +43,7 @@ export function useBitcoinFeesList({
recipient,
utxos,
}: UseBitcoinFeesListArgs) {
const { balance } = useCurrentBtcAvailableBalanceNativeSegwit();
const { balance } = useCurrentBtcCryptoAssetBalanceNativeSegwit();
const btcMarketData = useCryptoCurrencyMarketDataMeanAverage('BTC');
const { data: feeRates, isLoading } = useAverageBitcoinFeeRates();

Expand All @@ -57,7 +57,9 @@ export function useBitcoinFeesList({
if (!feeRates || !utxos.length) return [];

const determineUtxosDefaultArgs = {
recipients: [{ address: recipient, amount: isSendingMax ? balance : amount }],
recipients: [
{ address: recipient, amount: isSendingMax ? balance.availableBalance : amount },
],
utxos,
};

Expand Down Expand Up @@ -116,7 +118,7 @@ export function useBitcoinFeesList({
}

return feesArr;
}, [feeRates, utxos, isSendingMax, balance, amount, recipient, btcMarketData]);
}, [feeRates, utxos, recipient, isSendingMax, balance.availableBalance, amount, btcMarketData]);

return {
feesList,
Expand Down
Loading

0 comments on commit 6a598c8

Please sign in to comment.