Skip to content

Instantly share code, notes, and snippets.

@pedrouid
Created February 8, 2023 15:51
Show Gist options
  • Save pedrouid/e9578f182f5a360f0085bd01d995fbd7 to your computer and use it in GitHub Desktop.
Save pedrouid/e9578f182f5a360f0085bd01d995fbd7 to your computer and use it in GitHub Desktop.
CAIP-25 splitting a namespace between optional and required
// Currently our proposals require a lot from wallets by including all methods into requiredNamespaces
// This puts a high requirement on the wallets to support a lot of methods and chains
{
requiredNamespaces: {
eip155: {
chains: [1, 2, 3],
methods: [
'eth_sendTransaction',
'eth_sendRawTransaction',
'eth_sign',
'eth_signTransaction',
'eth_signTypedData',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
'personal_sign',
'wallet_switchEthereumChain',
'wallet_addEthereumChain'
],
events: ['accountsChanged', 'chainChanged'],
}
}
}
// However in reality a lot of wallets don't support all of these methods, which is going to lead in too many rejections
// Using the new optional namespaces we could split the methods and events into both required and optional namespaces
{
requiredNamespaces: {
eip155: {
chains: [1, 2, 3],
methods: [
'eth_sendTransaction',
'personal_sign'
],
events: ['accountsChanged', 'chainChanged'],
}
},
optionalNamespaces: {
eip155: {
chains: [1, 2, 3],
methods: [
'eth_sign',
'eth_signTransaction',
'eth_signTypedData',
'eth_signTypedData_v3',
'eth_signTypedData_v4',
],
events: [],
},
wallet: {
chains: [],
methods: [
'wallet_switchEthereumChain',
'wallet_addEthereumChain'
],
events: []
}
}
}
// Note how we cover the same scope for chains 1, 2 and 3 for 'eip155' on both requiredNamespaces and optionalNamespaces
// Additionally we also include a non-blockchain namespace with wallet-specific methods with empty chains array
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment