Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Prevent submission of sign-in screen when minimum values not yet entered #4702

Closed
Closed
2 changes: 1 addition & 1 deletion 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.1.1",
"@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 Down
24 changes: 7 additions & 17 deletions src/app/common/hooks/use-bitcoin-contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,27 +207,17 @@ export function useBitcoinContracts() {
close();
}

async function getAllActiveBitcoinContracts(): Promise<BitcoinContractListItem[] | undefined> {
async function getAllSignedBitcoinContracts(): Promise<BitcoinContractListItem[] | undefined> {
const bitcoinContractInterface = await getBitcoinContractInterface();

if (!bitcoinContractInterface) return;

await bitcoinContractInterface.periodic_check();
const bitcoinContracts = await bitcoinContractInterface.get_contracts();
const signedBitcoinContracts = bitcoinContracts.filter(
(bitcoinContract: BitcoinContractListItem) => bitcoinContract.state === 'Signed'
);

const stateOrder = ['Signed', 'Confirmed'];

const activeBitcoinContracts = bitcoinContracts
.filter(
(bitcoinContract: BitcoinContractListItem) =>
bitcoinContract.state === 'Signed' || bitcoinContract.state === 'Confirmed'
)
.sort(
(a: BitcoinContractListItem, b: BitcoinContractListItem) =>
stateOrder.indexOf(a.state) - stateOrder.indexOf(b.state)
);

return activeBitcoinContracts;
return signedBitcoinContracts;
}

function getTransactionDetails(txId: string, bitcoinCollateral: number) {
Expand All @@ -249,7 +239,7 @@ export function useBitcoinContracts() {

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

bitcoinContracts.forEach((bitcoinContract: BitcoinContractListItem) => {
Expand Down Expand Up @@ -323,7 +313,7 @@ export function useBitcoinContracts() {
handleOffer,
handleAccept,
handleReject,
getAllActiveBitcoinContracts,
getAllSignedBitcoinContracts,
sumBitcoinContractCollateralAmounts,
sendRpcResponse,
};
Expand Down
4 changes: 2 additions & 2 deletions src/app/pages/bitcoin-contract-list/bitcoin-contract-list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ import { BitcoinContractListItemLayout } from './components/bitcoin-contract-lis
import { BitcoinContractListLayout } from './components/bitcoin-contract-list-layout';

export function BitcoinContractList() {
const { getAllActiveBitcoinContracts } = useBitcoinContracts();
const { getAllSignedBitcoinContracts } = useBitcoinContracts();
const [bitcoinContracts, setBitcoinContracts] = useState<BitcoinContractListItem[]>([]);
const [isLoading, setLoading] = useState(true);
const [isError, setError] = useState(false);

useOnMount(() => {
const fetchAndFormatBitcoinContracts = async () => {
const fetchedBitcoinContracts = await getAllActiveBitcoinContracts();
const fetchedBitcoinContracts = await getAllSignedBitcoinContracts();
if (!fetchedBitcoinContracts) {
setError(true);
setLoading(false);
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/onboarding/sign-in/mnemonic-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ export function MnemonicForm({ mnemonic, setMnemonic, twentyFourWordMode }: Mnem
<LeatherButton
data-testid={OnboardingSelectors.SignInBtn}
aria-disabled={isLoading || showMnemonicErrors}
disabled={isEmpty(touched) || !isValid}
disabled={isEmpty(touched) || !isValid || !hasFormValues}
aria-busy={isLoading}
width="100%"
type="submit"
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -899,10 +899,10 @@
resolved "https://registry.yarnpkg.com/@discoveryjs/json-ext/-/json-ext-0.5.7.tgz#1d572bfbbe14b7704e0ba0f39b74815b84870d70"
integrity sha512-dBVuXR082gk3jsFp7Rd/JI4kytwGHecnCoTtXFb7DB6CNHp4rg5k1bhg0nWdLGLnOV71lmDzGQaLMy8iPLY0pw==

"@dlc-link/dlc-tools@1.1.1":
version "1.1.1"
resolved "https://registry.yarnpkg.com/@dlc-link/dlc-tools/-/dlc-tools-1.1.1.tgz#01e2351babb70b352247cf8e0e20aac9724c4f35"
integrity sha512-+4RlBjqv3Ws9ndc9dP+SWS/GZ7j18T3TlpzgEblR/WB8pA0FAV2D8Faz+S32m7q6CXFogArZXc/IoyQ+bx3Wtg==
"@dlc-link/dlc-tools@1.0.9":
version "1.0.9"
resolved "https://registry.yarnpkg.com/@dlc-link/dlc-tools/-/dlc-tools-1.0.9.tgz#3dfe1d743e9d5e309732e55c824ffbf77039f2bf"
integrity sha512-+lxe6nrZCbuUWcMR4l9X+axqR1yB7lgtjsrP6Pp23GRqSGL+wvts+L8wSCJxTi6rDhBKfGzvau3SLOPrha/3Rw==

"@dnd-kit/accessibility@^3.1.0":
version "3.1.0"
Expand Down Expand Up @@ -12065,7 +12065,7 @@ is-typedarray@^1.0.0, is-typedarray@~1.0.0:
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==

is-unicode-supported@^1.1.0, is-unicode-supported@^1.2.0:
is-unicode-supported@^1.1.0, is-unicode-supported@^1.2.0, is-unicode-supported@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz#d824984b616c292a2e198207d4a609983842f714"
integrity sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==
Expand Down
Loading