[英]Metamask sends RPC Error although it is caught in Javascript
[英]MetaMask - RPC Error: Permissions request already pending, in Angular 10
我已將 MetaMask 與 Angular 集成在一起,從代碼中打開 MetaMask 擴展時出現此錯誤。
以下是我打開擴展程序的代碼。 我在點擊打開 MetaMask 時調用這個 function,它給出了那個錯誤
MetaMask - RPC 錯誤:權限請求已掛起; 請稍等。 {代碼:-32002,消息:“權限請求已經掛起;請稍候。”}
ethEnabled(template?): any
{
if ((window as any).web3)
{
(window as any).web3 = new Web3((window as any).web3.currentProvider);
(window as any).ethereum.enable();
console.log((window as any).ethereum.enable());
}
else
{
this.modalRef = this.modalService.show(template);
}
}
這個錯誤實際上是預期的; 當您已經提交了權限請求,但用戶尚未登錄 MetaMask 或未授予您的應用程序權限時,就會發生這種情況。
如果用戶登錄 MetaMask 並接受權限請求,則不會再出現此錯誤。
這在文檔中進行了解釋,其中說You should always disable the "connect" button while the connection request is pending
(否則會發生此錯誤)。
這是處理此問題的一種方法:
他們的文檔中有更多信息和一個很好的例子。
清除您的互聯網緩存、臨時文件等。
描述錯誤
當我在請求 eth 帳戶時關閉解鎖錢包彈出窗口時,我沒有得到任何結果。 當我再次請求 eth 帳戶時,我收到以下錯誤 MetaMask - RPC Error: Already processing eth_requestAccounts。 請稍等。
重現步驟(必需)
window.web3 = new Web3(window.ethereum)
const account = await window.ethereum.request({
method: 'eth_requestAccounts',
})
鎖定錢包 觸發請求 關閉解鎖彈窗 再次觸發請求 預期行為
收到帶有特定代碼的錯誤,以了解解鎖錢包已關閉以及要從處理中解除的交易 pipe。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.