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: keystone approvals, bridge amount too low, spend approval dollar value #85

Merged
merged 4 commits into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/background/vmModules/ApprovalController.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ describe('src/background/vmModules/ApprovalController', () => {
inputs: btcTx.inputs,
outputs: btcTx.outputs,
}),
btcNetwork
btcNetwork,
action.tabId
);

expect(await promise).toEqual({
Expand Down Expand Up @@ -270,7 +271,8 @@ describe('src/background/vmModules/ApprovalController', () => {
inputs: btcTx.inputs,
outputs: btcTx.outputs,
}),
btcNetwork
btcNetwork,
action.tabId
);

expect(await promise).toEqual({ signedData: signedTx });
Expand Down
6 changes: 5 additions & 1 deletion src/background/vmModules/ApprovalController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,11 @@ export class ApprovalController implements IApprovalController {
case RpcMethod.BITCOIN_SEND_TRANSACTION:
case RpcMethod.BITCOIN_SIGN_TRANSACTION:
case RpcMethod.ETH_SEND_TRANSACTION:
return await this.#walletService.sign(signingData.data, network);
return await this.#walletService.sign(
signingData.data,
network,
action.tabId
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pass tabId, so the signature request can later be paired with the window that initiated the request

);

default:
throw new Error('Unrecognized method: ' + params.request.method);
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Bridge/components/BridgeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ export const BridgeForm = ({
const [neededGas, setNeededGas] = useState(0n);

useEffect(() => {
if (minimum && amount.lt(minimum)) {
if (minimum && amount.gt(0) && amount.lt(minimum)) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't show the "Amount is too low" error if amount is 0

setIsAmountTooLow(true);
} else {
setIsAmountTooLow(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,13 +133,7 @@ export function TokenSpendLimit({
displayValue: isInfinite
? t('Unlimited')
: (diffItemValue as TokenUnit).toDisplay(),
usdPrice:
isInfinite || !approval.usdPrice
? undefined
: String(
(diffItemValue as TokenUnit).toDisplay({ asNumber: true }) *
Number(approval.usdPrice)
),
usdPrice: isInfinite ? undefined : approval.usdPrice,
}}
/>
</Stack>
Expand Down
Loading