Skip to content

Commit 2bca8fa

Browse files
committed
feat(tx): Add missing actions
1 parent 7f2353b commit 2bca8fa

File tree

4 files changed

+59
-5
lines changed

4 files changed

+59
-5
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@sqds/cli",
3-
"version": "2.3.16",
3+
"version": "2.3.17",
44
"description": "",
55
"main": "bin/index.js",
66
"scripts": {

src/lib/api.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,14 @@ class API{
192192
approveTransaction = async (tx: PublicKey) => {
193193
return this.squads.approveTransaction(tx);
194194
}
195+
196+
rejectTransaction = async (tx: PublicKey) => {
197+
return this.squads.rejectTransaction(tx);
198+
}
199+
200+
cancelTransaction = async (tx: PublicKey) => {
201+
return this.squads.cancelTransaction(tx);
202+
}
195203

196204
addKeyTransaction = async (msPDA: PublicKey, key: PublicKey) => {
197205
const txBuilder = await this.squads.getTransactionBuilder(msPDA, 0);

src/lib/inq/transactions.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import inquirer from "inquirer";
22

33
export default (txs, userKey) => {
44
// console.log(txs);
5-
5+
66
const choices = txs.filter((tx) => {
7-
return ((tx.creator.toBase58() === userKey.toBase58() && tx.status.draft ) || tx.status.active || tx.status.executeReady || tx.status.executed);
7+
return ((tx.creator.toBase58() === userKey.toBase58() && tx.status.draft ) || tx.status.active || tx.status.executeReady || tx.status.executed || tx.status.rejected || tx.status.cancelled);
88
}).map(tx => {
99
return `${tx.publicKey.toBase58()} (${Object.keys(tx.status)[0]})`;
1010
});
@@ -18,7 +18,7 @@ export default (txs, userKey) => {
1818
name: 'action',
1919
message: 'Choose a transaction',
2020
choices,
21-
}
21+
}
2222
];
2323
return inquirer.prompt(txList);
24-
};
24+
};

src/lib/menu.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,52 @@ class Menu{
479479
this.transaction(tx, ms, txs);
480480
}
481481
}
482+
else if (action === "Reject") {
483+
const {yes} = await basicConfirm(`Reject this transaction?`,false);
484+
if (yes) {
485+
const status = new Spinner("Rejecting transaction...");
486+
status.start();
487+
try {
488+
const updatedTx = await this.api.rejectTransaction(tx.publicKey);
489+
status.stop();
490+
const newInd = txs.findIndex(t => t.publicKey.toBase58() === updatedTx.publicKey.toBase58());
491+
txs.splice(newInd, 1, updatedTx);
492+
console.log("Transaction rejected");
493+
await continueInq();
494+
this.transaction(updatedTx, ms, txs);
495+
}catch(e){
496+
status.stop();
497+
console.log("Error!", e);
498+
await continueInq();
499+
this.transaction(tx, ms, txs);
500+
}
501+
}else{
502+
this.transaction(tx, ms, txs);
503+
}
504+
}
505+
else if (action === "Submit to cancel") {
506+
const {yes} = await basicConfirm(`Cancel this transaction?`,false);
507+
if (yes) {
508+
const status = new Spinner("Cancelling transaction...");
509+
status.start();
510+
try {
511+
const updatedTx = await this.api.cancelTransaction(tx.publicKey);
512+
status.stop();
513+
const newInd = txs.findIndex(t => t.publicKey.toBase58() === updatedTx.publicKey.toBase58());
514+
txs.splice(newInd, 1, updatedTx);
515+
console.log("Transaction cancel submitted");
516+
await continueInq();
517+
this.transaction(updatedTx, ms, txs);
518+
}catch(e){
519+
status.stop();
520+
console.log("Error!", e);
521+
await continueInq();
522+
this.transaction(tx, ms, txs);
523+
}
524+
}else{
525+
this.transaction(tx, ms, txs);
526+
}
527+
}
482528
else{
483529
this.transaction(tx, ms, txs);
484530
}

0 commit comments

Comments
 (0)