Skip to content

Commit 06a0c34

Browse files
Merge pull request #1555 from Web3Auth/feat/mobile-adapters
adds wc metamask, rainbow
2 parents 453cd5c + 751914c commit 06a0c34

File tree

3 files changed

+46
-11
lines changed
  • packages

3 files changed

+46
-11
lines changed

packages/adapters/wallet-connect-v2-adapter/src/config.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,32 @@ import { CHAIN_NAMESPACES, ChainNamespaceType, IWalletConnectExtensionAdapter }
44
import { IAdapterSettings } from "./interface";
55

66
export const WALLET_CONNECT_EXTENSION_ADAPTERS: IWalletConnectExtensionAdapter[] = [
7+
{
8+
name: "Rainbow",
9+
chains: [CHAIN_NAMESPACES.EIP155],
10+
logo: "https://images.web3auth.io/login-rainbow.svg",
11+
mobile: {
12+
native: "rainbow:",
13+
universal: "https://rnbwapp.com",
14+
},
15+
desktop: {
16+
native: "",
17+
universal: "",
18+
},
19+
},
20+
{
21+
name: "MetaMask",
22+
chains: [CHAIN_NAMESPACES.EIP155],
23+
logo: "https://images.web3auth.io/login-metamask.svg",
24+
mobile: {
25+
native: "metamask:",
26+
universal: "https://metamask.app.link",
27+
},
28+
desktop: {
29+
native: "",
30+
universal: "",
31+
},
32+
},
733
{
834
name: "Argent",
935
chains: [CHAIN_NAMESPACES.EIP155],

packages/providers/ethereum-provider/src/providers/privateKeyProviders/TransactionFormatter/index.ts

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,22 @@ export class TransactionFormatter {
5959
if (!this.isEIP1559Compatible && clonedTxParams.gasPrice) {
6060
if (clonedTxParams.maxFeePerGas) delete clonedTxParams.maxFeePerGas;
6161
if (clonedTxParams.maxPriorityFeePerGas) delete clonedTxParams.maxPriorityFeePerGas;
62+
// if user provides gas Limit, we should use it instead
6263
// if gas is not provided explicitly, estimate it.
64+
if (!clonedTxParams.gasLimit) {
65+
if (!clonedTxParams.gas) {
66+
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
67+
if (defaultGasLimit) {
68+
clonedTxParams.gasLimit = defaultGasLimit;
69+
}
70+
} else {
71+
clonedTxParams.gasLimit = clonedTxParams.gas;
72+
}
73+
}
74+
return clonedTxParams;
75+
}
76+
77+
if (!clonedTxParams.gasLimit) {
6378
if (!clonedTxParams.gas) {
6479
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
6580
if (defaultGasLimit) {
@@ -68,16 +83,6 @@ export class TransactionFormatter {
6883
} else {
6984
clonedTxParams.gasLimit = clonedTxParams.gas;
7085
}
71-
return clonedTxParams;
72-
}
73-
74-
if (!clonedTxParams.gas) {
75-
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
76-
if (defaultGasLimit) {
77-
clonedTxParams.gasLimit = defaultGasLimit;
78-
}
79-
} else {
80-
clonedTxParams.gasLimit = clonedTxParams.gas;
8186
}
8287

8388
const {

packages/ui/src/components/ExternalWallets.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,12 @@ export default function ExternalWallet(props: ExternalWalletsProps) {
133133
const buttons: ExternalButton[] = [];
134134
// add wallet connect links
135135
if (deviceDetails.platform === bowser.PLATFORMS_MAP.mobile) {
136-
const mobileLinks = formatMobileRegistry(wcAdapters, walletConnectUri, deviceDetails.os, deviceDetails.platform);
136+
let mobileLinks = formatMobileRegistry(wcAdapters, walletConnectUri, deviceDetails.os, deviceDetails.platform);
137137
if (deviceDetails.os === bowser.OS_MAP.iOS) {
138+
if ((window as any).ethereum?.isMetaMask) {
139+
// if metamask, use the metamask adapter directly
140+
mobileLinks = mobileLinks.filter((x) => x.name !== "MetaMask");
141+
}
138142
buttons.push(
139143
...mobileLinks.map((link) => ({
140144
name: link.name,

0 commit comments

Comments
 (0)