-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
gauntlet: multisig: Allow batch approving transactions
- Loading branch information
Showing
1 changed file
with
44 additions
and
0 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
gauntlet/packages/gauntlet-serum-multisig/src/commands/approve.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { SolanaCommand, TransactionResponse } from '@chainlink/gauntlet-solana' | ||
import { PublicKey } from '@solana/web3.js' | ||
import { Result } from '@chainlink/gauntlet-core' | ||
import { logger } from '@chainlink/gauntlet-core/dist/utils' | ||
import { CONTRACT_LIST, getContract } from '../lib/contracts' | ||
|
||
export default class SetOwners extends SolanaCommand { | ||
static id = 'serum_multisig:approve' | ||
static category = CONTRACT_LIST.MULTISIG | ||
|
||
static examples = ['yarn gauntlet serum_multisig:approve --network=local [IDS...]'] | ||
|
||
constructor(flags, args) { | ||
super(flags, args) | ||
} | ||
makeRawTransaction = async (signer: PublicKey) => { | ||
const multisigAddress = new PublicKey(process.env.MULTISIG_ADDRESS || '') | ||
const multisig = getContract(CONTRACT_LIST.MULTISIG) | ||
const address = multisig.programId.toString() | ||
const program = this.loadProgram(multisig.idl, address) | ||
|
||
|
||
logger.info(`Approving transactions: ${this.args}`) | ||
|
||
// map ids over this | ||
const ixs = await Promise.all(this.args.map((tx) => | ||
program.methods | ||
.approve() | ||
.accounts({ | ||
multisig: multisigAddress, | ||
transaction: new PublicKey(tx), | ||
owner: signer, | ||
}) | ||
.instruction() | ||
)) | ||
|
||
return ixs | ||
} | ||
|
||
//execute not needed, this command cannot be ran outside of multisig | ||
execute = async () => { | ||
return {} as Result<TransactionResponse> | ||
} | ||
} |