# Multisig

## Initialization

#### Init

```typescript
init(provider: SigningCosmWasmClient, multisig: string): Promise<void>
```

This method receives the provider used, and the multisig the user wants to connect to.

#### Create proposal

```typescript
createProposal(args: {
    messages: unknown[];
    description: string;
    manualExecution?: boolean;
    from: string;
}): Promise<{
    proposal: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This method creates a new proposal on the multisig. It receives as arguments an object containing the following fields:

* messages: an array of json serializable objects that contain messages to execute by the multisig.
* description: a description for the proposal
* manualExecution: an optional field that when set to true it doesnt execute the proposal once its reached minimum approval.
* from: the provider account that executes the transaction

This method return object contains a field called "proposal" which contains the proposal ID in the multisig.

#### Vote Proposal

```typescript
voteProposal(args: {
    proposal: string;
    vote: VoteOption;
    from: string;
}): Promise<{
    status: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This method creates a vote on a proposal. The vote must be made by a member of the multisig. It receives an object with the following parameters:

* proposal: the proposal ID in the multisig
* vote: VoteOption that could be YES or NO, "1" or "0" respectively.
* from: the provider address to send the transaction from

It returns an object with a field called "status" which returns the proposal status.

#### Execute Proposal

```typescript
executeProposal(args: {
    proposal: string;
    from: string;
}): Promise<{
    status: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This method is used to execute proposal that were created with the "manualExecution" field set to true. Otherwise, this function will fail. It receives as parameter an object with these fields:

* proposal: Proposal ID to execute
* from: the account used by the provider

#### Propose IBC Transfer

```typescript
proposeIBCTransfer(args: {
    from: string;
    channel: string;
    to: string;
    amount: string;
    description?: string;
    manualExecution?: boolean;
    timestamp?: string;
}): Promise<{
    proposal: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This method creates an IBC transfer proposal. Its just like a normal proposal but it abstracts the complexities of the IBC message. The fields it receives are:

* from: account to use by provider
* channel: channel used by the ibc transfer
* to: the account to transfer the funds to
* amount: the amount of funds to transfer (native tokens)
* description: the description of the proposal. If not provided it creates a default description of the action
* manualExecution: see create proposal.
* timestamp: TODO.

#### Propose Add member

```typescript
proposeAddMembers(args: {
    new_members: string[];
    from: string;
    description?: string;
    manualExecution?: boolean;
}): Promise<{
    proposal: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This function creates a simple proposal to reconfigure the multisig. It fetches current configuration (members and approval) and adds the new members to the array. If the new members are already on the multisig it throws an error.

* new\_members: array of addresses of members to add.
* from: user account to send the transaction from.
* description: if not set it adds a default description
* manualExecution: see create proposal

#### Propose Remove member

```typescript
proposeRemoveMembers(args: {
    removed: string[];
    from: string;
    description?: string;
    manualExecution?: boolean;
}): Promise<{
    proposal: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This function creates a simple proposal to reconfigure the multisig. It fetches current configuration (members and approval) and removes the ones from the previous configuration. If the removed members are not present on the multisig it throws an error.

* removed: array of addresses of members to remove.
* from: user account to send the transaction from.
* description: if not set it adds a default description
* manualExecution: see create proposal

#### Propose Minimum approval

```typescript
proposeMinimumApproval(args: {
    newApproval: number;
    from: string;
    description?: string;
    manualExecution?: boolean;
}): Promise<{
    proposal: string | undefined;
    transactionHash: string;
    events: readonly Event[];
}>
```

This function creates a simple proposal to reconfigure the multisig. It fetches current configuration (members and approval) and adds a new minimum approval. If its larger than the current amount of members it throws an error.

* newApproval: new minimum approval.
* from: user account to send the transaction from.
* description: if not set it adds a default description
* manualExecution: see create proposal

#### Get configuration

```typescript
getConfiguration(): Promise<{
    approval: number;
    members: string[];
}>
```

This function returns the current multisig configuration. It doesn receive parametres. Its return values are:

* members: Current members of the multisig.
* approval: Current minimum approval
