Skip to content

Commit

Permalink
fix: check broadcast param as string
Browse files Browse the repository at this point in the history
  • Loading branch information
fbwoolf committed Aug 30, 2023
1 parent 1e69362 commit 4f9ba97
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 9 deletions.
8 changes: 7 additions & 1 deletion src/app/components/generic-error/generic-error.layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,13 @@ export function GenericErrorLayout(props: GenericErrorProps) {
<styled.h1 mt="space.05" textStyle="heading.04">
{title}
</styled.h1>
<styled.h2 mt="space.04" textAlign="center" textStyle="label.02" wordWrap="break-word">
<styled.h2
mt="space.04"
textAlign="center"
textStyle="label.02"
width="100%"
wordWrap="break-word"
>
{body}
</styled.h2>
<Box
Expand Down
4 changes: 2 additions & 2 deletions src/app/features/current-account/current-account-name.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/s
function AccountNameTitle({ children, ...props }: HasChildren & BoxProps) {
return (
<Box {...props}>
<styled.h1 data-testid={SettingsSelectors.CurrentAccountDisplayName} textStyle="label.01">
<styled.span data-testid={SettingsSelectors.CurrentAccountDisplayName} textStyle="label.01">
{children}
</styled.h1>
</styled.span>
</Box>
);
}
Expand Down
16 changes: 11 additions & 5 deletions src/app/pages/rpc-sign-psbt/use-rpc-sign-psbt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ interface BroadcastSignedPsbtTxArgs {
export function useRpcSignPsbt() {
const analytics = useAnalytics();
const navigate = useNavigate();
// const { addressNativeSegwitTotal, addressTaprootTotal, fee } = usePsbtSignerContext();
const { allowedSighash, broadcast, origin, psbtHex, requestId, signAtIndex, tabId } =
useRpcSignPsbtParams();
const { signPsbt, getPsbtAsTransaction } = usePsbtSigner();
Expand Down Expand Up @@ -107,10 +106,17 @@ export function useRpcSignPsbt() {
makeRpcSuccessResponse('signPsbt', { id: requestId, result: { hex: bytesToHex(psbt) } })
);

// Optional args are handle bc we support two request apis,
// but only support broadcasting using the rpc request method
if (broadcast && addressNativeSegwitTotal && addressTaprootTotal && fee) {
tx.finalize();
// Optional args are handled here bc we support two request apis,
// but we only support broadcasting using the rpc request method
if (broadcast === 'true' && addressNativeSegwitTotal && addressTaprootTotal && fee) {
try {
tx.finalize();
} catch (e) {
return navigate(RouteUrls.RequestError, {
state: { message: e instanceof Error ? e.message : '', title: 'Failed to finalize tx' },
});
}

await broadcastSignedPsbtTx({
addressNativeSegwitTotal,
addressTaprootTotal,
Expand Down
5 changes: 4 additions & 1 deletion src/background/messaging/rpc-methods/sign-psbt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export async function rpcSignPsbt(message: SignPsbtRequest, port: chrome.runtime

const requestParams: RequestParams = [
['hex', message.params.hex],
['network', message.params.network ?? 'mainnet'],
['requestId', message.id],
];

Expand All @@ -84,6 +83,10 @@ export async function rpcSignPsbt(message: SignPsbtRequest, port: chrome.runtime
requestParams.push(['broadcast', message.params.broadcast.toString()]);
}

if (isDefined(message.params.network)) {
requestParams.push(['network', message.params.network.toString()]);
}

if (isDefined(message.params.signAtIndex))
ensureArray(message.params.signAtIndex).forEach(index =>
requestParams.push(['signAtIndex', index.toString()])
Expand Down

0 comments on commit 4f9ba97

Please sign in to comment.