You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We could make a ReadOnlyWeb3Provider that would implement Provider and could be "upgraded" to a Web3Provider.
Every methods that require an account would throw an error explaining that the class should be upgraded to use it
exportclassReadOnlyProviderimplementsProvider{constructor(publicclient: PublicAPI){}/** * Upgrades the provider to a Web3Provider by connecting an account * @param account - Account to connect to the provider * @returns The created Web3Provider */connectAccount(account: Account): Web3Provider{returnnewWeb3Provider(this.client,account)}privatereadonly_providerName: string='Massa web3 ReadOnlyProvider'privatereadonly_accountRequiredError=`This method is not available in ReadOnlyProvider. Please use the "connectAccount" method to upgrade the class to a "Web3Provider".`getaddress(): string{thrownewError(this._accountRequiredError)}getaccountName(): string{thrownewError(this._accountRequiredError)}getproviderName(): string{returnthis._providerName}
...
And Web3Provider could extends ReadOnlyWeb3Provider so we avoid duplicating code as they will both implement the same function except the ones requiring an account which will be different
to use all json rpc endpoint that does not require signaure
The text was updated successfully, but these errors were encountered: