From b0ac3abdcce7d74a90ca71606c8733e915945c82 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Tue, 14 May 2024 16:11:09 +0800 Subject: [PATCH 1/4] fix(core): connectTo throw error directly --- packages/core/src/services/connect.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/core/src/services/connect.ts b/packages/core/src/services/connect.ts index c8908a2..e25eb04 100644 --- a/packages/core/src/services/connect.ts +++ b/packages/core/src/services/connect.ts @@ -1,7 +1,7 @@ -import { computed, readonly } from 'vue' +import { computed, markRaw, readonly } from 'vue' import { useStore } from '../store' import { ConnectOptions, ConnectorName } from '../types' -import { ConnectError, ConnectorNotFoundError } from '../errors' +import { ConnectorNotFoundError } from '../errors' import { isWindowEthereumAvailable, normalizeChainId } from '../utils' import { removeLastConnectedBrowserWallet, setLastConnectedBrowserWallet } from './localStorage' @@ -46,8 +46,8 @@ export function useConnect(pinia?: any) { if (info?.rdns) setLastConnectedBrowserWallet(info.rdns) } catch (err: any) { await disconnect() // will resetWallet() - walletStore.wallet.error = err.message - throw new ConnectError(err) + walletStore.wallet.error = markRaw(err) + throw err } // ============================= listen EIP-1193 events ============================= From 7894235d176ecb08955c4673c73859e8b97398c7 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Tue, 14 May 2024 16:12:46 +0800 Subject: [PATCH 2/4] docs: update eips with provider errors --- app/content/eips.md | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/content/eips.md b/app/content/eips.md index 099bcf5..ee4dc22 100644 --- a/app/content/eips.md +++ b/app/content/eips.md @@ -15,6 +15,19 @@ Collect the EIPs related to DApp development, especially in frontend. - [EIP-1193: Ethereum Provider JavaScript API](https://eips.ethereum.org/EIPS/eip-1193){:target="_blank"} - [Eip1193Provider - ethers v6](https://docs.ethers.org/v6/api/providers/#Eip1193Provider){:target="_blank"} +### Provider Errors + +- [EIP-1193 Provider Errors](https://eips.ethereum.org/EIPS/eip-1193#provider-errors){:target="_blank"} + +| Status code | Name | Description | +| ----------- | --------------------- | ------------------------------------------------------------------------ | +| 4001 | User Rejected Request | The user rejected the request. | +| 4100 | Unauthorized | The requested method and/or account has not been authorized by the user. | +| 4200 | Unsupported Method | The Provider does not support the requested method. | +| 4900 | Disconnected | The Provider is disconnected from all chains. | +| 4901 | Chain Disconnected | The Provider is not connected to the requested chain. | + + ## EIP-6963 - [EIP-6963: Multi Injected Provider Discovery](https://eips.ethereum.org/EIPS/eip-6963){:target="_blank"} - [eip6963.org](https://eip6963.org/){:target="_blank"} @@ -24,4 +37,3 @@ Collect the EIPs related to DApp development, especially in frontend. - [EIP-3326: Wallet Switch Ethereum Chain RPC Method](https://eips.ethereum.org/EIPS/eip-3326){:target="_blank"} - [EIP-1474: Remote procedure call specification](https://eips.ethereum.org/EIPS/eip-1474){:target="_blank"} - From c009d6889fd0311bd9f9fde74593b7ea051df4e2 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Tue, 14 May 2024 16:18:52 +0800 Subject: [PATCH 3/4] docs: replace common-errors with errors, and update --- app/content/common-errors.md | 15 --------------- app/content/eips.md | 13 +------------ app/content/errors.md | 27 +++++++++++++++++++++++++++ app/core/sidebar.ts | 6 +++--- 4 files changed, 31 insertions(+), 30 deletions(-) delete mode 100644 app/content/common-errors.md create mode 100644 app/content/errors.md diff --git a/app/content/common-errors.md b/app/content/common-errors.md deleted file mode 100644 index 6a6b5d8..0000000 --- a/app/content/common-errors.md +++ /dev/null @@ -1,15 +0,0 @@ ---- -description: '' -head: - meta: - - name: 'keywords' - content: '' ---- - -# Common Errors - -Common errors, common solutions. - - -- ["getActivePinia()" was called but there was no active Pinia.](https://github.com/vu3th/vue-dapp/issues/160){:target="_blank"} - diff --git a/app/content/eips.md b/app/content/eips.md index ee4dc22..9eba6cf 100644 --- a/app/content/eips.md +++ b/app/content/eips.md @@ -13,20 +13,9 @@ Collect the EIPs related to DApp development, especially in frontend. ## EIP-1193 - [EIP-1193: Ethereum Provider JavaScript API](https://eips.ethereum.org/EIPS/eip-1193){:target="_blank"} + - [Provider Errors](https://eips.ethereum.org/EIPS/eip-1193#provider-errors){:target="_blank"} - [Eip1193Provider - ethers v6](https://docs.ethers.org/v6/api/providers/#Eip1193Provider){:target="_blank"} -### Provider Errors - -- [EIP-1193 Provider Errors](https://eips.ethereum.org/EIPS/eip-1193#provider-errors){:target="_blank"} - -| Status code | Name | Description | -| ----------- | --------------------- | ------------------------------------------------------------------------ | -| 4001 | User Rejected Request | The user rejected the request. | -| 4100 | Unauthorized | The requested method and/or account has not been authorized by the user. | -| 4200 | Unsupported Method | The Provider does not support the requested method. | -| 4900 | Disconnected | The Provider is disconnected from all chains. | -| 4901 | Chain Disconnected | The Provider is not connected to the requested chain. | - ## EIP-6963 - [EIP-6963: Multi Injected Provider Discovery](https://eips.ethereum.org/EIPS/eip-6963){:target="_blank"} diff --git a/app/content/errors.md b/app/content/errors.md new file mode 100644 index 0000000..084fea7 --- /dev/null +++ b/app/content/errors.md @@ -0,0 +1,27 @@ +--- +description: '' +head: + meta: + - name: 'keywords' + content: '' +--- + +# Errors + +## Provider Errors + +- [EIP-1193 Provider Errors](https://eips.ethereum.org/EIPS/eip-1193#provider-errors){:target="_blank"} + +| Status code | Name | Description | +| ----------- | --------------------- | ------------------------------------------------------------------------ | +| 4001 | User Rejected Request | The user rejected the request. | +| 4100 | Unauthorized | The requested method and/or account has not been authorized by the user. | +| 4200 | Unsupported Method | The Provider does not support the requested method. | +| 4900 | Disconnected | The Provider is disconnected from all chains. | +| 4901 | Chain Disconnected | The Provider is not connected to the requested chain. | + + +## Developing Common Errors + +- ["getActivePinia()" was called but there was no active Pinia.](https://github.com/vu3th/vue-dapp/issues/160){:target="_blank"} + diff --git a/app/core/sidebar.ts b/app/core/sidebar.ts index 1c807f9..b44c06f 100644 --- a/app/core/sidebar.ts +++ b/app/core/sidebar.ts @@ -100,11 +100,11 @@ export const sidebarMenu = [ h( NuxtLink, { - to: '/common-errors', + to: '/errors', }, - { default: () => 'Common Errors' }, + { default: () => 'Errors' }, ), - key: '/common-errors', + key: '/errors', }, { label: () => From 6e784429de78c766710c4ba6d5fb47327933a399 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Tue, 14 May 2024 17:13:33 +0800 Subject: [PATCH 4/4] fix(core,walletconnect): add ProviderRpcError type to wallet.error, and add 4001 error to WalletConnectConnector --- app/pages/index.vue | 13 ++++++-- packages/core/src/types/wallet.ts | 3 +- .../src/walletConnectConnector.ts | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 18 deletions(-) diff --git a/app/pages/index.vue b/app/pages/index.vue index 0aa5bf7..51e3a2c 100644 --- a/app/pages/index.vue +++ b/app/pages/index.vue @@ -1,7 +1,6 @@