Skip to content

Commit

Permalink
Added prompt for notarization fee
Browse files Browse the repository at this point in the history
  • Loading branch information
macterra committed Dec 11, 2023
1 parent 25aff56 commit ff575de
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
10 changes: 5 additions & 5 deletions frontend/src/AdminView.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ const AdminView = () => {

const handleNotarize = async () => {

if (admin.pending) {
if (!window.confirm(`Spend USD ${walletInfo.fee_usd} for RBF?`)) {
return;
}
const txnFee = prompt("Enter txn fee in USD", "0.0");

if (txnFee === null || txnFee === "") {
return;
}

setDisableButton(true);
try {
const getAdmin = await axios.get('/api/v1/admin/notarize');
const getAdmin = await axios.post('/api/v1/admin/notarize', { txnFee: txnFee });
const admin = getAdmin.data;

if (admin.pending) {
Expand Down
11 changes: 9 additions & 2 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,9 @@ app.get('/api/v1/admin/register', ensureAuthenticated, async (req, res) => {
}
});

app.get('/api/v1/admin/notarize', ensureAuthenticated, async (req, res) => {
app.post('/api/v1/admin/notarize', ensureAuthenticated, async (req, res) => {
try {
const { txnFee } = req.body;
const adminData = admin.getAdmin();

if (!adminData.owner || adminData.owner !== req.user.xid) {
Expand All @@ -380,7 +381,13 @@ app.get('/api/v1/admin/notarize', ensureAuthenticated, async (req, res) => {
return res.status(500).json({ message: 'Not registered' });
}

const savedAdmin = await admin.notarizeState(adminData, 0);
const maxFee = parseInt(txnFee, 10);

if (!maxFee) {
return res.status(401).json({ message: 'No txn fee specified' });
}

const savedAdmin = await admin.notarizeState(adminData, maxFee);

if (savedAdmin.pending !== adminData.pending) {
savedAdmin.githash = await archiver.commitChanges({
Expand Down

0 comments on commit ff575de

Please sign in to comment.