Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIP-0106? | Web-Wallet Bridge - Multisig wallets #617

Merged
merged 30 commits into from
Jun 26, 2024
Merged
Changes from 23 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
0db056f
Initial draft completed
leo42 Nov 11, 2023
81780e1
Merge branch 'cardano-foundation:master' into master
leo42 Nov 11, 2023
2f80311
Update CIP-130/README.md
leo42 Nov 11, 2023
2a8ca30
Update CIP-130/README.md
leo42 Nov 11, 2023
48ff4c2
renaming CPI folder
leo42 Nov 11, 2023
7ecb1bc
Update CIP-XXXX/README.md
leo42 Nov 11, 2023
92732d3
remove exes whitespaces
leo42 Nov 11, 2023
1b7c753
Rework as a CIP-30 Extension
leo42 Nov 14, 2023
f934813
small improvment
leo42 Nov 27, 2023
d014274
standardising title with wallet extension CIPs
rphair Dec 6, 2023
2561e4e
applying official CIP number 106
rphair Dec 12, 2023
ec1bdfc
Merge branch 'master' of https://github.com/leo42/CIPs
leo42 Dec 13, 2023
7d9cb6d
Rename and mark reference implementation as complete
leo42 Dec 13, 2023
aaa736a
rename
leo42 Dec 13, 2023
cfc5318
Merge branch 'cardano-foundation:master' into master
leo42 Apr 15, 2024
adb8da1
Update CIP-0106/README.md
leo42 May 15, 2024
ab9e1ef
Update CIP-0106/README.md
leo42 May 15, 2024
9d6a57f
Update CIP-0106/README.md
leo42 Jun 5, 2024
e2ab1fc
remove duplicate sections
leo42 Jun 6, 2024
dc00f1b
Update README.md
leo42 Jun 6, 2024
7292e1c
Update README.md
leo42 Jun 6, 2024
f0e298b
add namespacing
leo42 Jun 6, 2024
1e70fa9
Update README.md
leo42 Jun 6, 2024
9a8db7f
needs seminal pull request as Discussion
rphair Jun 11, 2024
ce033b7
Add implementors , remove rational for required data
leo42 Jun 12, 2024
483b8c8
Update CIP-0106/README.md
leo42 Jun 12, 2024
1d13e70
Update README.md
leo42 Jun 12, 2024
fd6e5cb
Changed Removed Endpoints to Disabled Endpoints
leo42 Jun 13, 2024
a9f2670
very minor formatting: white space justification
rphair Jun 22, 2024
bb015c5
fix spelling mistake in CIP title
rphair Jun 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
151 changes: 151 additions & 0 deletions CIP-0106/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
---
CIP: 106
Title: Web-Wallet Bridge - Mutlisig wallets
Status: Proposed
Category: Wallets
Authors:
- Leo
Implementors: NA
rphair marked this conversation as resolved.
Show resolved Hide resolved
Discussions:
rphair marked this conversation as resolved.
Show resolved Hide resolved
Created: 2023-10-12
License: CC-BY-4.0
---

## Abstract

This document describes a CIP-30 extension allowing webpages (i.e. dApps) to interface with Cardano Multisig-wallets. This document is a work in progress and is not yet finalized. It is expected to be updated as the ecosystem evolves.

## Motivation: why is this CIP necessary?

In order to facilitate future dApp development, we will need a way for dApps to communicate with multisig wallets, given the unique complexities of native script based addresses. Special provisions need to be made to make the connector compatible with them.

Specifically, apps building transactions need to be able to get the following information from the wallet:
- Script descriptor
- Script Requirements list
- Collateral donator (since native script based addresses cannot provide collateral for transactions)

Additionally, apps need to be able to submit a transaction to the wallet for signing in an asynchronous manner, as gathering of signatures can take a long time and each wallet provider will have its own way of handling this process.

Finally, the signTx() and signData() endpoints will have to be disabled when using this extension since they are not compatible with native script based addresses.

### Rationale for the required data

- Script descriptor:
- Any transaction consuming a UTxO from a native script based address must attach the corresponding script.
- Script Requirements list:
- dApps need to know the number of signers to calculate the fees correctly.
- Including the correct "required signers" brings UX improvements.
- dApps need to know if the script has any before-after requirements to set the correct validBefore and TTL values.
- Collateral donator:
- Native script based addresses cannot provide collateral for Plutus transactions

## Specification

### Data Types

#### KeyHash

A hex-encoded string of the corresponding bytes. This represents the hash of the public key used to sign transactions.

```ts
type KeyHash = String
```

#### ScriptRequirements

```ts
type ScriptRequirementsCode = {
Signer: 1,
Before: 2,
After: 3,
}
type ScriptRequirement = {
code: ScriptRequirementsCode,
value: KeyHash|number,
}
```

### Aditional Error Types

#### CompletedTxError

```ts
CompletedTxErrorCode = {
NotFound: 1,
NotReady: 2
}
```

* NotFound - The transaction with the given id was not found.
* NotReady - The transaction with the given id is not ready yet.

### Additional API Endpoints

#### api.cip106.getCollateralAddress(): Promise\<Address>

For Plutus V2 and later, partial collateral is supported. This function returns an address that can be used to add collateral to a transaction. The address returned must be owned by one of the signers in the list of signers returned by `api.getScriptRequirements()`.

dApp developers can choose to use this address to add collateral to a transaction, or they can choose to use the `api.getCollateral()` function to get a list of UTXOs that can be used as collateral. If the dApp chooses to use this address, they must ensure that the address is not used for any other purpose, as the wallet may be using it to track collateral, and that the collateral return address is the same one.

#### api.cip106.getScriptRequirements: Promise\<ScriptRequirement[]>

Errors: `APIError`

Returns a list of ScriptRequirements that will be used to validate any transaction sent to the wallet.

#### api.cip106.getScript(): Promise\<cbor\<nativeScript>>

Errors: `APIError`

Returns the CBOR-encoded native script that controls this wallet.

#### api.cip106.submitUnsignedTx(tx: cbor\<unsignedTransaction>): Promise\<hash32>

Errors: `APIError`, `TxError`

Submits a transaction to the wallet for signing. The wallet should check that the transaction is valid, gather the required signatures, compose the finalized transaction, and submit the transaction to the network. If the transaction is valid and the wallet is able to sign it, the wallet should return the transaction hash. If the transaction is invalid or the wallet is unable to sign it, the wallet should throw a `TxError` with the appropriate error code. The wallet should not submit the transaction to the network if it is invalid or the wallet is unable to sign it.

If the transaction contains hidden metadata, the wallet should not submit the transaction when it is ready, but return it to the dApp when the dApp calls the `getCompletedTx` function.

#### api.cip106.getCompletedTx(txId: hash32): Promise\[<cbor\<transaction>,cbor<transaction_witness_set>>]

Errors: `APIError`, `CompletedTxError`

If the transaction is not ready, the wallet should throw a `CompletedTxError` with the appropriate error code. If the transaction is ready, the wallet should return the CBOR-encoded transaction and the signatures.

### Altered API endpoints

#### api.getCollateral(params: { amount: cbor\<Coin> }): Promise\<TransactionUnspentOutput[] | null>

Native script based addresses cannot provide collateral for transactions. Using this function, dApps can request the wallet to provide collateral for a transaction. The collateral must be a pure ADA UTXO, held by one of the signers in the list of signers returned by `api.getScriptRequirements()`.

### Removed API endpoints
leo42 marked this conversation as resolved.
Show resolved Hide resolved

When connecting to a wallet using this extension the following endpoints will be disabled:

#### `api.signTx(tx: cbor<transaction>, partialSign: bool = false): Promise<cbor<transaction_witness_set>>`


#### `api.signData(addr: Address, payload: Bytes): Promise<DataSignature>`


## Rationale: how does this CIP achieve its goals?

See justification and explanations provided with each API endpoint.


## Path to Active

### Acceptance Criteria

- [ ] The interface is implemented and supported by multiple wallet providers.
- [ ] The interface is used by multiple dApps to interact with wallet providers.

### Implementation Plan

- [x] Provide some reference implementation of wallet providers
- [leo42/BroClanWallet](#completed)
leo42 marked this conversation as resolved.
Show resolved Hide resolved

## Copyright

This CIP is licensed under [CC-BY-4.0](https://creativecommons.org/licenses/by/4.0/legalcode).