-
Notifications
You must be signed in to change notification settings - Fork 170
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
CAIP-341 - Extension ID Target Type Specification #341
Open
ffmcgee725
wants to merge
7
commits into
ChainAgnostic:main
Choose a base branch
from
ffmcgee725:feat/define-extension-id-as-a-valid-target-type
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+134
−0
Open
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
294a3c0
feat: draft extension id target type specification CAIP
ffmcgee725 656551f
refactor: update x placeholder to 341
ffmcgee725 5b0b6f4
refactor: improvement suggestions by adonesky1
ffmcgee725 79df192
refactor: improvement suggestions by jiexi
ffmcgee725 833baae
Merge branch 'ChainAgnostic:main' into feat/define-extension-id-as-a-…
ffmcgee725 916e37e
feat: update specification
ffmcgee725 bc11116
refactor: minor adjustment
ffmcgee725 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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,125 @@ | ||
--- | ||
caip: 341 | ||
title: Extension ID Target Type Specification | ||
author: [Joao Tavares] (@ffmcgee725) | ||
discussions-to: https://github.com/ChainAgnostic/CAIPs/issues/341 | ||
status: Draft | ||
type: Standard | ||
created: 2024-12-12 | ||
requires: 294 | ||
--- | ||
|
||
## Simple Summary | ||
|
||
CAIP-341 defines the Extension ID type as a valid target type for establishing connections with browser extension wallets via the [CAIP-294] `wallet_announce` wallet discovery event. | ||
|
||
## Abstract | ||
|
||
This proposal introduces a new target type Extension ID for the `target` field of the `WalletData` interface dispatched in [CAIP-294]'s `wallet_announce` event. This target type is used to specify the extension ID of a browser extension wallet, allowing callers to establish connections with the wallet using the [`externally_connectable`][externally_connectable API documentation] API. | ||
|
||
## Motivation | ||
|
||
CAIP-294 proposes a solution to fragmentation across blockchain ecosystems wallet discovery mechanisms (e.g Ethereum's [EIP-6963], Solana's [Wallet Standard]). By defining a standardized target type for browser extension wallets that use the `externally_connectable` browser API, we aim to extend CAIP-294's unified solution to cross ecosystem wallet discoverability, enhancing interoperability across these different blockchain ecosystems. | ||
|
||
## Specification | ||
|
||
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this document are to be interpreted as described in [RFC-2119](https://www.rfc-editor.org/rfc/rfc2119). | ||
|
||
### Definitions | ||
|
||
Wallet Provider: A user agent that manages accounts and facilitates transactions with a blockchain. | ||
|
||
Decentralized Application (dapp): A web page that relies upon one or many Web3 platform APIs which are exposed to the web page via the Wallet. | ||
|
||
Blockchain Library: A library or piece of software that assists a dapp to interact with a blockchain and interface with the Wallet. | ||
|
||
### Target Type | ||
|
||
The `target` field in the `WalletData` interface is used to specify the connection method for the wallet. This CAIP introduces the Extension ID type as a valid target type. | ||
|
||
This field MAY be included in the `WalletData`, and if included, SHOULD be an object containing Extension ID type used to connect to wallets using `externally_connectable`. | ||
|
||
```typescript | ||
interface WalletData { | ||
// Required properties | ||
uuid: string; | ||
name: string; | ||
icon: string; | ||
rdns: string; | ||
// Optional properties | ||
target?: { | ||
type: "caip341", | ||
value: <extension_id> | ||
} | ||
scopes?: Caip217AuthorizationScopes; | ||
} | ||
``` | ||
|
||
### Usage | ||
|
||
The Extension ID target type is used to specify the extension ID of a browser extension wallet. This allows the dapp to establish a connection with the wallet using the `externally_connectable` API. The `externally_connectable` API documentation can be found [here](https://developer.chrome.com/docs/extensions/reference/manifest/externally-connectable). | ||
|
||
```ts | ||
const walletData = { | ||
uuid: "350670db-19fa-4704-a166-e52e178b59d2", | ||
name: "Example Wallet", | ||
icon: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==", | ||
rdns: "com.example.wallet", | ||
target: { | ||
type: "caip341", | ||
value: "abcdefghijklmnopqrstuvwxyz" | ||
}, | ||
scopes: { | ||
"eip155:1": { | ||
methods: ["eth_signTransaction", "eth_sendTransaction"], | ||
notifications: ["accountsChanged", "chainChanged"] | ||
} | ||
} | ||
} | ||
``` | ||
|
||
### Establishing Connection | ||
|
||
When the target type is Extension ID, the dapp MUST use the Extension ID to establish a connection with the wallet using the `externally_connectable` browser API. All subsequent communication with the wallet SHOULD be conducted over the `externally_connectable` API using `runtime.connect()` and `runtime.sendMessage()`. | ||
|
||
Example of establishing a connection and sending a message: | ||
|
||
```ts | ||
const port = chrome.runtime.connect(walletData.target.value); | ||
|
||
port.onMessage.addListener((message) => { | ||
// Handle incoming messages | ||
}); | ||
|
||
port.postMessage({ | ||
id: 1, | ||
jsonrpc: "2.0", | ||
method: "wallet_createSession", | ||
params: { | ||
// ... session parameters ... | ||
} | ||
}); | ||
``` | ||
|
||
## Rationale | ||
|
||
By defining the Extension ID target type, we provide a standardized way for dapps to connect with browser extension wallets. This reduces complexity and enhances interoperability across different blockchain ecosystems. The use of the `externally_connectable` API ensures secure and efficient communication between the dapp and the wallet. | ||
|
||
## Backwards Compatibility | ||
|
||
This CAIP is fully compatible with existing standards and does not introduce any breaking changes. It extends the `WalletData` interface to include the `target` field, which is optional and does not affect existing implementations. | ||
|
||
## Links | ||
|
||
- [EIP-6963][eip-6963] - Ethereum's Multi Injected Provider Discovery | ||
- [CAIP-294][caip-294] - Browser Wallet Messaging for Extensions | ||
- [externally_connectable API documentation][externally_connectable API documentation] - Chrome's `externally_connectable` browser API documentation | ||
- [Wallet Standard][wallet standard] - Solana's Wallet Standard for discoverability | ||
|
||
[eip-6963]: https://eips.ethereum.org/EIPS/eip-6963 | ||
[caip-294]: https://chainagnostic.org/CAIPs/caip-294 | ||
[externally_connectable API documentation]: https://developer.chrome.com/docs/extensions/reference/manifest/externally-connectable | ||
[wallet standard]: https://github.com/anza-xyz/wallet-standard | ||
|
||
## Copyright | ||
Copyright and related rights waived via [CC0](../LICENSE). |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm hoping it's this line, and not something else, that is tripping up the github internal YAML parser
![image](https://private-user-images.githubusercontent.com/37127325/401603841-55d19a40-aaeb-4721-b95a-b8577b29db9d.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk5MjQwNDcsIm5iZiI6MTczOTkyMzc0NywicGF0aCI6Ii8zNzEyNzMyNS80MDE2MDM4NDEtNTVkMTlhNDAtYWFlYi00NzIxLWI5NWEtYjg1NzdiMjlkYjlkLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTklMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE5VDAwMDkwN1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWQ3YjZlYzdhMWNiODA4ODQxY2ExMDNiMWZkNjFlYjYyMDNiNGU1OTczMTkzOWU1NjkzNWI4OGQyNDY0MWMyNjYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.8W9Tqux8EkEOAs-RnC3j-I0Jit7SVGAb5y7ix5Qy9xg)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolved in 916e37e