Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use personal_sign when injected web3provider is TrustWallet #1542

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/providers/src.ts/web3-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { JsonRpcProvider } from "./json-rpc-provider";
export type ExternalProvider = {
isMetaMask?: boolean;
isStatus?: boolean;
isTrust?: boolean;
host?: string;
path?: string;
sendAsync?: (request: { method: string, params?: Array<any> }, callback: (error: any, response: any) => void) => void
Expand All @@ -30,7 +31,7 @@ function buildWeb3LegacyFetcher(provider: ExternalProvider, sendFunc: Web3Legacy
return function(method: string, params: Array<any>): Promise<any> {

// Metamask complains about eth_sign (and on some versions hangs)
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus)) {
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus || provider.isTrust)) {
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
method = "personal_sign";
params = [ params[1], params[0] ];
Expand Down Expand Up @@ -65,7 +66,7 @@ function buildEip1193Fetcher(provider: ExternalProvider): JsonRpcFetchFunc {
if (params == null) { params = [ ]; }

// Metamask complains about eth_sign (and on some versions hangs)
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus)) {
if (method == "eth_sign" && (provider.isMetaMask || provider.isStatus || provider.isTrust)) {
// https://github.com/ethereum/go-ethereum/wiki/Management-APIs#personal_sign
method = "personal_sign";
params = [ params[1], params[0] ];
Expand Down