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/ warn if collateral return is being directed to another owner #946

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nami-wallet",
"version": "3.8.2",
"version": "3.8.3",
"description": "Maintained by IOG",
"license": "Apache-2.0",
"repository": {
Expand Down
2 changes: 1 addition & 1 deletion src/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"manifest_version": 3,
"name": "Nami",
"version": "3.8.2",
"version": "3.8.3",
"description": "Maintained by IOG",
"background": { "service_worker": "background.bundle.js" },
"action": {
Expand Down
23 changes: 22 additions & 1 deletion src/ui/app/pages/signTx.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ const SignTx = ({ request, controller }) => {
const [isLoading, setIsLoading] = React.useState({
loading: true,
error: null,
warning: null
});

const assetsModalRef = React.useRef();
Expand Down Expand Up @@ -480,7 +481,17 @@ const SignTx = ({ request, controller }) => {
}
const collateralReturn = tx.body().collateral_return();
// presence of collateral return means "account" collateral can be ignored
if (collateralReturn) return;
if (collateralReturn) {
// collateral return usually is paid to account's payment address, however, the DApp
// could be providing collateral so blocking the tx is not appropriate.
if (collateralReturn.address().to_bech32() !== account.paymentAddr) {
setIsLoading((l) => ({
...l,
warning: 'Collateral return is being directed to another owner. Ensure you are not providing the collateral input'
}));
}
return;
}
if (!account.collateral) {
setIsLoading((l) => ({ ...l, error: 'Collateral not set' }));
return;
Expand Down Expand Up @@ -740,6 +751,16 @@ const SignTx = ({ request, controller }) => {
justifyContent="center"
flexDirection={'column'}
>
{isLoading.warning && (
<>
<Box py={2} px={4} rounded={'full'} background={background}>
<Text fontSize="xs" color={'orange.500'}>
Warning! {isLoading.warning}
</Text>
</Box>
<Box h={6} />
</>
)}
{isLoading.error && (
<>
<Box py={2} px={4} rounded={'full'} background={background}>
Expand Down