Skip to content

Commit

Permalink
fix payment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Megha-Dev-19 committed Jan 6, 2025
1 parent ff8b2be commit e8ceee8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 28 deletions.
30 changes: 4 additions & 26 deletions instances/treasury-devdao.near/widget/components/BalanceBanner.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const { getNearBalances, hasPermission } = VM.require(
const { getNearBalances } = VM.require(
"${REPL_BASE_DEPLOYMENT_ACCOUNT}/widget/lib.common"
);

Expand Down Expand Up @@ -39,36 +39,14 @@ function formatNearAmount(amount) {
}

function BalanceBanner({ accountId, treasuryDaoID }) {
if (
!treasuryDaoID ||
typeof getNearBalances !== "function" ||
!accountId ||
typeof hasPermission !== "function"
) {
if (!treasuryDaoID || typeof getNearBalances !== "function" || !accountId) {
return <></>;
}

const nearBalances = getNearBalances(accountId);
const hasCreatePermission = hasPermission(
treasuryDaoID,
accountId,
"transfer",
"AddProposal"
);

const daoPolicy = useCache(
() => Near.asyncView(treasuryDaoID, "get_policy"),
"get_policy",
{ subscribe: false }
);

// if they have create permission they need deposit amount for add proposal
const ADDITIONAL_AMOUNT = hasCreatePermission
? formatNearAmount(daoPolicy?.proposal_bond)
: 0;

const LOW_BALANCE_LIMIT = ADDITIONAL_AMOUNT + 0.7; // 0.7N
const INSUFFICIENT_BALANCE_LIMIT = ADDITIONAL_AMOUNT + 0.3; // 0.3N
const LOW_BALANCE_LIMIT = 0.7; // 0.7N
const INSUFFICIENT_BALANCE_LIMIT = 0.3; // 0.3N

const profile = Social.getr(`${accountId}/profile`);
const name = profile.name ?? accountId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,10 @@ const WarningModal = () => (
</ModalHeader>
<ModalContent>
Hey {name}, you don't have enough NEAR to complete actions on your
treasury. You need at least {INSUFFICIENT_BALANCE_LIMIT}. Please add more
funds to your account and try again.
treasury. You need at least {INSUFFICIENT_BALANCE_LIMIT}N{" "}
{checkForDeposit &&
", which includes the proposal bond needed to create a proposal"}
. Please add more funds to your account and try again.
</ModalContent>
</Modal>
);
Expand Down

0 comments on commit e8ceee8

Please sign in to comment.