Skip to content

Commit

Permalink
docs(cleint): add signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
javadkh2 committed Apr 2, 2024
1 parent d55dc48 commit 02d4965
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 6 deletions.
33 changes: 28 additions & 5 deletions packages/libs/client/NEW_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -993,17 +993,40 @@ const signedTx = signWithKeypair(tx);

### Add Signatures Manually

if you already have the signature you can add it in the right order to the tx by
If you already have the signature you can add it in the right order to the tx by
using `addSignatures`

```TS
addSignatures(transaction, ...signatures): IUnsignedCommand | ICommand
```

| Parameter | Type | Description |
| ------------- | --------------------------------------- | ----------------------------------------------------------- |
| transaction | IUnsignedCommand | the partially signed or unsigned transaction |
| ...signatures | Array<{ sig: string; pubKey?: string }> | list of signatures that need to be added to the transaction |
| Parameter | Type | Description |
| ------------- | ---------------------------------------------------------------- | ----------------------------------------------------------- |
| transaction | IUnsignedCommand | the partially signed or unsigned transaction |
| ...signatures | Array<{ sig: string; pubKey: string }> \| Array<{ sig: string }> | list of signatures that need to be added to the transaction |

**Note** All signatures should either include a `pubKey`, or none of them
should. If signatures do not include `pubKey`, then the number of signatures
should match the number of signers; thus, signatures are matched based on their
order.

#### Examples

Add Signature with pubKey

```TS

const signedTx = addSignatures(partiallySignedTx, { sig: "signature-str", pubKey: "publicKey"})

```

Add Signature based on orger

```TS

const signedTx = addSignatures(twoSignersTx, { sigOne: "signature-str" }, { sigTwo: "signature-str" })

```

## TODO: ADD OTHER PARTS

Expand Down
2 changes: 1 addition & 1 deletion packages/libs/client/src/signing/utils/addSignatures.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const debug: Debugger = _debug('@kadena/client:signing:addSignature');
*/
export const addSignatures: (
transaction: IUnsignedCommand,
...signatures: { sig: string; pubKey?: string }[]
...signatures: { sig: string; pubKey: string }[] | { sig: string }[]
) => IUnsignedCommand | ICommand = (transaction, ...signatures) => {
debug(
() =>
Expand Down

0 comments on commit 02d4965

Please sign in to comment.