Skip to content

Commit

Permalink
Merge pull request #1555 from Web3Auth/feat/mobile-adapters
Browse files Browse the repository at this point in the history
adds wc metamask, rainbow
  • Loading branch information
chaitanyapotti authored Jul 21, 2023
2 parents 453cd5c + 751914c commit 06a0c34
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 11 deletions.
26 changes: 26 additions & 0 deletions packages/adapters/wallet-connect-v2-adapter/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,32 @@ import { CHAIN_NAMESPACES, ChainNamespaceType, IWalletConnectExtensionAdapter }
import { IAdapterSettings } from "./interface";

export const WALLET_CONNECT_EXTENSION_ADAPTERS: IWalletConnectExtensionAdapter[] = [
{
name: "Rainbow",
chains: [CHAIN_NAMESPACES.EIP155],
logo: "https://images.web3auth.io/login-rainbow.svg",
mobile: {
native: "rainbow:",
universal: "https://rnbwapp.com",
},
desktop: {
native: "",
universal: "",
},
},
{
name: "MetaMask",
chains: [CHAIN_NAMESPACES.EIP155],
logo: "https://images.web3auth.io/login-metamask.svg",
mobile: {
native: "metamask:",
universal: "https://metamask.app.link",
},
desktop: {
native: "",
universal: "",
},
},
{
name: "Argent",
chains: [CHAIN_NAMESPACES.EIP155],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,22 @@ export class TransactionFormatter {
if (!this.isEIP1559Compatible && clonedTxParams.gasPrice) {
if (clonedTxParams.maxFeePerGas) delete clonedTxParams.maxFeePerGas;
if (clonedTxParams.maxPriorityFeePerGas) delete clonedTxParams.maxPriorityFeePerGas;
// if user provides gas Limit, we should use it instead
// if gas is not provided explicitly, estimate it.
if (!clonedTxParams.gasLimit) {
if (!clonedTxParams.gas) {
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
if (defaultGasLimit) {
clonedTxParams.gasLimit = defaultGasLimit;
}
} else {
clonedTxParams.gasLimit = clonedTxParams.gas;
}
}
return clonedTxParams;
}

if (!clonedTxParams.gasLimit) {
if (!clonedTxParams.gas) {
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
if (defaultGasLimit) {
Expand All @@ -68,16 +83,6 @@ export class TransactionFormatter {
} else {
clonedTxParams.gasLimit = clonedTxParams.gas;
}
return clonedTxParams;
}

if (!clonedTxParams.gas) {
const defaultGasLimit = await this.getDefaultGasLimit(clonedTxParams);
if (defaultGasLimit) {
clonedTxParams.gasLimit = defaultGasLimit;
}
} else {
clonedTxParams.gasLimit = clonedTxParams.gas;
}

const {
Expand Down
6 changes: 5 additions & 1 deletion packages/ui/src/components/ExternalWallets.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ export default function ExternalWallet(props: ExternalWalletsProps) {
const buttons: ExternalButton[] = [];
// add wallet connect links
if (deviceDetails.platform === bowser.PLATFORMS_MAP.mobile) {
const mobileLinks = formatMobileRegistry(wcAdapters, walletConnectUri, deviceDetails.os, deviceDetails.platform);
let mobileLinks = formatMobileRegistry(wcAdapters, walletConnectUri, deviceDetails.os, deviceDetails.platform);
if (deviceDetails.os === bowser.OS_MAP.iOS) {
if ((window as any).ethereum?.isMetaMask) {
// if metamask, use the metamask adapter directly
mobileLinks = mobileLinks.filter((x) => x.name !== "MetaMask");
}
buttons.push(
...mobileLinks.map((link) => ({
name: link.name,
Expand Down

0 comments on commit 06a0c34

Please sign in to comment.