generated from web3/web3.js-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: lightweight plugin dependencies + manual test results (#14)
* feat: lightweight plugin dependencies * feat: manual test results (#15) * chore: update gh actions
- Loading branch information
Showing
24 changed files
with
405 additions
and
118 deletions.
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
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,101 @@ | ||
# Result of manual tests with wallets | ||
|
||
## Browser extension wallets | ||
|
||
| Method | Metamask | Coinbase Wallet | Trust Wallet | Enkrypt | Rainbow | Rabby Wallet | Exodus | Phantom | | ||
| -------------------------- | -------- | --------------- | ------------ | ------- | ------- | ------------ | ------ | ------- | | ||
| wallet_addEthereumChain | ✓ | ✓ (\*) | ✓ | ✓ | ✓ (\*) | ✓ | x (\*) | x (\*) | | ||
| wallet_switchEthereumChain | ✓ | ✓ (\*) | ✓ | ✓ | ✓ | ✓ | ✓ (\*) | ✓ (\*) | | ||
| wallet_watchAsset | ✓ (\*) | ✓ | ✓ (\*) | x | ✓ (\*) | ✓ (\*) | x | ✓ (\*) | | ||
| wallet_requestPermissions | ✓ (\*) | x | ✓ | x (\*) | x | ✓ | ✓ | ✓ | | ||
| wallet_getPermissions | ✓ | x | ✓ | x | x | ✓ | ✓ | ✓ | | ||
| wallet_revokePermissions | ✓ | x | ✓ | x | x | ✓ | ✓ (\*) | x | | ||
|
||
- (✓) Supported | ||
- (x) Not supported | ||
- (\*) See additional remarks below | ||
|
||
### Comments / Remarks | ||
|
||
#### Expected behavior | ||
|
||
- `wallet_addEthereumChain`: Adds a new chain to the wallet if it’s not already recognized, and switches to it. | ||
- `wallet_switchEthereumChain`: Switches to a recognized chain; fails if the chain is not already added to the wallet. | ||
- `wallet_watchAsset`: Adds a new asset to the wallet if it’s not already recognized. | ||
- `wallet_requestPermissions`: Requests specific permissions from the wallet, triggering a modal for user approval. | ||
- `wallet_getPermissions`: Retrieves the list of permissions the dApp currently has from the wallet. | ||
- `wallet_revokePermissions`: Revokes previously granted permissions from the dApp. | ||
|
||
#### Metamask | ||
|
||
- `wallet_requestPermissions` and `wallet_getPermissions`: Returns a full response containing all permission fields according to the specification. | ||
- `wallet_watchAsset`: There’s an issue with Web3RequestManager, causing an error with the wallet's response: | ||
|
||
``` | ||
ResponseError: Returned error: Cannot destructure property 'tokenId' of 'n' as it is undefined. | ||
at Web3RequestManager.<anonymous> (web3_request_manager.ts:178:1) | ||
at Generator.next (<anonymous>) | ||
at fulfilled (web3_request_manager.ts:1:1)` | ||
``` | ||
|
||
#### Coinbase Wallet | ||
|
||
- `wallet_addEthereumChain`: It does not fully adhere to the specification, as it changes the network temporarily but doesn’t save it. As a result, if the wallet does not natively support the network, following up with `wallet_switchEthereumChain` for the same network will fail. | ||
- `wallet_watchAsset`: The wallet responds with a modal with the following message: "Coinbase Wallet automatically tracks token ownerships on the Ethereum network. There is no need to import USDC." | ||
|
||
### Trust Wallet | ||
|
||
- General Behavior is very similarly to MetaMask. | ||
- `wallet_watchAsset`: Produces an error due to an issue with destructuring the wallet’s response: | ||
|
||
``` | ||
WatchAsset.tsx:45 TypeError: Cannot destructure property 'address' of 'A' as it is undefined. | ||
at wi.request (inpage.js:247:201226) | ||
at inpage.js:247:206755 | ||
at yu.handleStaticRequests (inpage.js:247:207086) | ||
at yu.request (inpage.js:247:206709) | ||
at web3_request_manager.ts:271:1 | ||
at new Promise (<anonymous>) | ||
at Web3RequestManager.<anonymous> (web3_request_manager.ts:250:1) | ||
at Generator.next (<anonymous>) | ||
at web3_request_manager.ts:1:1 | ||
at new Promise (<anonymous>) | ||
``` | ||
|
||
### Enkrypt | ||
|
||
- `wallet_requestPermissions`: Returns a limited response object, but no permissions appear to be granted, and no modal is shown to request user approval. | ||
|
||
### Rainbow | ||
|
||
- `wallet_addEthereumChain`: Adds a chain but does not switch to it; fails if the network is already known to the wallet. | ||
- `wallet_watchAsset`: Fails with the error `"Internal error: Cannot read properties of undefined (reading 'address')"`. | ||
|
||
### Rabby Wallet | ||
|
||
- `wallet_requestPermissions` and `wallet_getPermissions`: Returns a response object containing only `parentCapability`, but functions as expected. | ||
- `wallet_watchAsset`: Opens a modal with an “Add Custom Token” header, but it remains stuck and does not complete the action. | ||
|
||
### Exodus | ||
|
||
- `wallet_addEthereumChain` and `wallet_switchEthereumChain`: Only work with chains natively supported by the wallet; new chains cannot be added. | ||
- `wallet_requestPermissions` and `wallet_getPermissions`: Returns a response object containing only `parentCapability`, but functions as expected. | ||
- `wallet_revokePermissions`: Revokes permissions but also triggers an error: `DisconnectedError: The provider is disconnected from all chains`. This appears to be an issue with the wallet itself. | ||
|
||
### Phantom | ||
|
||
- `wallet_addEthereumChain` and `wallet_switchEthereumChain`: Only work with chains natively supported by the wallet; new chains cannot be added. | ||
- `wallet_watchAsset`: Fails with an error: | ||
|
||
``` | ||
WatchAsset.tsx:45 Ir: Missing or invalid parameters. | ||
at r.request (chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/evmAsk.js:7:5094) | ||
at Web3RequestManager.<anonymous> (http://localhost:3000/static/js/bundle.js:80237:25) | ||
at Generator.next (<anonymous>) | ||
at http://localhost:3000/static/js/bundle.js:80100:67 | ||
at new Promise (<anonymous>) | ||
``` | ||
|
||
## Mobile wallets using WalletConnect | ||
|
||
TBD |
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
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
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,52 @@ | ||
import { useContext, useEffect, useState } from 'react'; | ||
import { type ProviderChainId } from 'web3'; | ||
|
||
import { Web3Context } from '../web3/Web3Context'; | ||
|
||
export function ChainId() { | ||
const { currentProvider } = useContext(Web3Context); | ||
const [chainId, setChainId] = useState<bigint | undefined>(undefined); | ||
|
||
useEffect(() => { | ||
currentProvider?.provider | ||
.request({ method: 'eth_chainId' }) | ||
.then((id) => { | ||
setChainId(BigInt(id as string)); | ||
}) | ||
.catch((error) => { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
}); | ||
}, [currentProvider]); | ||
|
||
useEffect(() => { | ||
if (currentProvider === undefined) { | ||
return; | ||
} | ||
|
||
const { provider } = currentProvider; | ||
|
||
function onChainChanged(newId: ProviderChainId) { | ||
setChainId(BigInt(newId)); | ||
} | ||
|
||
provider.on('chainChanged', onChainChanged); | ||
|
||
// eslint-disable-next-line consistent-return | ||
return () => { | ||
// not all wallet providers implement removeListener | ||
try { | ||
provider.removeListener('chainChanged', onChainChanged); | ||
} catch (error) { | ||
// eslint-disable-next-line no-console | ||
console.error(error); | ||
} | ||
}; | ||
}, [currentProvider]); | ||
|
||
if (!chainId) { | ||
return <div>Loading...</div>; | ||
} | ||
|
||
return <div>Chain ID: {`${chainId}`}</div>; | ||
} |
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.