flutter_web3_webview 1.0.0
flutter_web3_webview: ^1.0.0 copied to clipboard
A Flutter WebView widget that bridges in-app web pages to a Web3 wallet over EIP-1193 (EVM) and the Solana wallet standard.
1.0.0 #
First stable release. The injected Web3 provider is now built from vendored
TypeScript source (provider/) instead of a lost pre-compiled artifact, and
the EVM / Solana request pipeline has been hardened end-to-end.
Provider #
- NEW:
lib/js/provider.min.jsis generated from the vendoredprovider/source viabun run build:flutter(321 KB, down from the legacy ~1.46 MB bundle). Dropping the unreachableMobileAdapterfromEthereumProvider/SolanaProvidercuts the@metamask/eth-sig-utildependency chain and fixes a latent issue where the adapter renamed EVM methods (eth_sendTransaction → signTransaction, etc.) that the Dart dispatcher doesn't recognise. DApp-facing surface is unchanged (verified against the legacy bundle). - NEW: Serialize Solana
signTransactioninside the provider. Concurrent calls (directly or viasignAllTransactions) run one at a time through an instance-level promise queue, so a DApp can't race the wallet's single approval UI; a rejected signature does not wedge the queue. This replaces the host-app userscript that previously monkey-patched the behaviour onto the provider at runtime.
Fixes #
- SECURITY: Deny WebView permission requests by default unless the caller provides an explicit permission handler.
- Handle
wallet_addEthereumChainseparately fromwallet_switchEthereumChainvia a newwalletAddEthereumChaincallback: per EIP-3085 it registers the chain and resolves withnullwithout switching the active chain or emittingchainChanged. With no add handler it rejects with4200(unsupported method) rather than falling back to a switch, so an add request never silently changes the active network. - Return
nullfrom a successfulwallet_switchEthereumChainper EIP-3326 (it previously resolved with the chain id, which strict DApps treat as a protocol mismatch). - Stop advertising the Solana wallet-standard
signAndSendTransactionandsignInfeatures: the provider has no default broadcast RPC and SIWS isn't bridged, so advertising them led DApps into a guaranteed runtime failure (signAndSendTransactionthrew on an uninitialised connection,signInalways threwMethod not implemented.). DApps now fall back tosignTransaction/connect+signMessage. - Fix the legacy synchronous
_send:net_version/eth_chainIdno longer return the accounts array, andgetNetworkVersion's method name no longer carries a stray trailing space. The pass-through provider doesn't cache the chain id, so these synchronous calls now throw4200pointing callers at the asyncrequestAPI. - Always emit the EIP-6963
announceProviderevent, even whenwindow.ethereumalready exists — the previous early-return suppressed the announcement and broke multi-provider coexistence. The injected script now guards re-initialisation onfxwallet.ethereumand only claimswindow.ethereumwhen it is free. - Default the EIP-6963 announcement metadata to valid values — a built-in
data-URI
iconand a reverse-DNSrdns(both overridable viaWeb3EthSettings) — instead of empty strings that strict DApps reject. - Surface EIP-1193
4001(user rejected) instead of the invalid4092code when a chain switch is declined, and rejectwallet_switchEthereumChainwith4902for any chain id that is missing or is not a0x-prefixed hex string (previously'1','0xzz',' 0x1 'and similar values still reached the wallet callback). - Surface structured EIP-1193 errors to DApps. The Dart side throws
Web3RpcError; the injected provider bridge parses itsWeb3RpcError:sentinel out of the wrapped rejection string and re-throws a realProviderRpcErrorcarryingcode/message/data, so DApps can branch onerror.code(e.g.4902→wallet_addEthereumChain). - Add
Web3EthSettings.overwriteMetamask(defaultfalse). Previouslywindow.ethereum.isMetaMaskwas permanentlyfalsebecause the value was injected under a config field the provider never read — breaking DApps that gate signing on it (e.g. the MetaMask test dapp). - Back
JsTransactionObjectfields with the underlying raw map so setting a typed field tonullactually clears the value (was leaking the original DApp value throughtoJson()), while preserving DApp-provided fields likenonce/maxFeePerGas/ numericgas. - JSON-encode wallet metadata before injecting it into JavaScript.
- Share provider asset loading across concurrent initialization calls.
- Serialize user-confirmed EVM and Solana requests and safely encode chain change events.
- Respect
isWeb3when injecting provider scripts and forward Ajax ready-state callbacks.
0.1.0 #
- NEW: Initial Release.
0.1.1 #
- UPDATE: Inject provider at document start.
0.1.2 #
- UPDATE: Init provider js before use.
- UPDATE: Update README.md for use.
0.1.3 #
- FIX: Return full data for personal sign.
0.1.4 #
- UPDATE: Add event queueing logic.
0.1.5 #
- FIX: Optimized logic for error catching in events.