import { Keypair, PublicKey, TransactionInstruction, TransactionSignature } from '@solana/web3.js'; import SafeFinder from './safe-finder'; import { AnchorProvider, Program } from '@project-serum/anchor'; import { InstructionBuilder } from '../builders/instruction-builder'; import { ISnowflakeSafe } from '../interfaces/safe-interface'; import { TransactionSender } from './transaction-sender'; import { MultisigJob, SafeType, SerializableAction } from '../models'; export declare class SnowflakeSafe implements ISnowflakeSafe { program: Program; instructionBuilder: InstructionBuilder; transactionSender: TransactionSender; wallet: PublicKey; finder: SafeFinder; constructor(provider: AnchorProvider); /** ## Create a new safe * * Note: Approvals required must be lower than or equal to the total number of safe owners. * ### Example * ``` * const safeKeypair = Keypair.generate(); * * const input = { approvalsRequired: 1, owners: [owner], }; * const txId = await snowflakeSafe.createSafe( safeKeypair, input.owners, input.approvalsRequired ); * ``` * ### Parameters * @param owners An array of public keys for owners of the safe * @param approvalsRequired The number of owners required to approve a proposal * @returns Safe address and a transaction signature */ createSafe(owners: PublicKey[], approvalsRequired: number): Promise<[PublicKey, TransactionSignature]>; private buildProposal; /** ## Create a multi-signature proposal * * ### Description * Proposal requires approvals (minimum as a declared approvals_required of the safe). It can be `approve` or `reject` by using `approveProposal` or `rejectProposal`. * Note: * - Only the owner of the safe can create a proposal. * - Only the proposal creator can delete the proposal. * - Only safe owners can approve or reject a proposal. * - Only safe owners can execute a proposal. * * ### Parameters * @param safeAddress Publickey of the safe * @param proposalName Name of proposal * @param proposalInstructions List of executed instructions * @param setupInstructions List of instructions to setup the proposal (createAssociatedTokenAccount...) * @param accountSize The size of the account (default: 1800) * @returns Proposal address and a transaction signature */ createProposal(safeAddress: PublicKey, proposalName: string, proposalInstructions: TransactionInstruction[], setupInstructions?: TransactionInstruction[], accountSize?: number, isApproved?: boolean, separatedActions?: boolean): Promise<[PublicKey, TransactionSignature]>; /** ## Create recurring proposal instructions * * @param safeAddress Public key of the safe * @param proposalKeypair New keypair generated of a proposal * @param proposal Multisig proposal class object * @param setupInstructions Setup instructions * @param accountSize Proposal account size * @param isDraft Check if proposal is draft (for separated actions proposal only) * @param isApproved Auto approved by creator when proposal created * @param separatedActions Check if proposal has separated actions added * @returns */ createRecurringProposalInstructions(safeAddress: PublicKey, proposalKeypair: Keypair, proposal: MultisigJob, setupInstructions?: TransactionInstruction[], accountSize?: number, isDraft?: boolean, isApproved?: boolean, separatedActions?: boolean): Promise; /** ## Create a recurring proposal * ### Description * A recurring proposal is a proposal that will be executed by Snowflake node operators. * * ### Parameters * @param safeAddress Public key of the safe * @param proposal Proposal * @param setupInstructions List of instructions to setup the proposal (createAssociatedTokenAccount...) * @param accountSize The size of the account (default: 1800) * @param isDraft Set the proposal as draft to allow adding more actions (default: false) * @param isApproved Allow auto approved by creator when proposal created (default: true) * @returns Proposal address and a transaction signature */ createRecurringProposal(safeAddress: PublicKey, proposal: MultisigJob, setupInstructions?: TransactionInstruction[], accountSize?: number, isDraft?: boolean, isApproved?: boolean, separatedActions?: boolean): Promise<[PublicKey, TransactionSignature]>; /** ## Delete a proposal * * ### Description * Only a proposal creator can delete a proposal. * * ### Parameters * @param proposalAddress Public key of the proposal * @returns A transaction signature */ deleteProposal(proposalAddress: PublicKey): Promise; /** ## Approve a proposal * * ### Description * Note: Only safe owners can approve a proposal. * * ### Parameters * @param flowAddress Public key of the flow * @returns A transaction signature */ approveProposal(proposalAddress: PublicKey): Promise; /** ## Reject a proposal * * ### Description * Note: Only safe owners can reject a proposal. * * ### Parameters * @param proposalAddress Public key of the proposal * @returns A transaction signature */ rejectProposal(proposalAddress: PublicKey): Promise; /** ## Abort a proposal * * ### Description * - Only works if the proposal is a recurring. * - Only safe owners can abort a proposal. * * ### Parameters * @param proposalAddress Public key of the proposal * @returns A transaction signature */ abortRecurringProposal(proposalAddress: PublicKey): Promise; /** ## Execute a proposal * * ### Description * - Only safe owners can execute a proposal. * * ### Parameters * @param proposalAddress Public key of the proposal * @returns A transaction signature */ executeProposal(proposalAddress: PublicKey): Promise; /** ## Create add owner instruction * * Note: The method will create a new instruction to add new owner to the safe * ### Parameters * @param safeAddress Public key of the safe * @param safeOwner Public key of added owner * @returns A transaction signature */ createAddOwnerProposalInstruction(safeAddress: PublicKey, safeOwner: PublicKey): Promise; /** ## Create remove owner instruction * * Note: The method will create a new instruction to remove new owner to the safe * ### Parameters * @param safeAddress Public key of the safe * @param safeOwner Public key of added owner * @returns A transaction signature */ createRemoveOwnerProposalInstruction(safeAddress: PublicKey, safeOwner: PublicKey): Promise; /** ## Create change threshold instruction * * Note: The method will create a new instruction to change threshold of the safe * ### Parameters * @param safeAddress Public key of the safe * @param safeOwner Public key of added owner * @returns A transaction signature */ createChangeThresholdProposalInstruction(safeAddress: PublicKey, threshold: number): Promise; /** ## Create add proposal action instructions * Note: Add new actions to the proposal * @param proposalAddress Public key of the proposal * @param proposalActions List of proposal action * @returns */ createAddProposalActionInstructions(proposalAddress: PublicKey, proposalActions: SerializableAction[]): Promise; fetchSafe(safeAddress: PublicKey): Promise; fetchProposal(proposalAddress: PublicKey): Promise; fetchDerivedSafeAddress(proposalAddress: PublicKey): Promise; fetchOwnedSafes(ownerAddress: PublicKey): Promise; fetchAllProposals(safeAddress: PublicKey): Promise; findSafeSignerAddress(safeAddress: PublicKey, safeProgramId: PublicKey): Promise<[PublicKey, number]>; private validateCreateSafe; }