From 89e3f6700da75bde608a655ea1bc08da8d9fdf28 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 4 Dec 2024 00:52:26 +0700 Subject: [PATCH 1/2] fix: walletconnect not opening when signing --- .../src/actions/wallet/wallet-connect/clot.ts | 10 +++++++--- .../wallet/wallet-connect/cosmostation.ts | 1 + .../src/actions/wallet/wallet-connect/index.ts | 16 ++++------------ .../src/actions/wallet/wallet-connect/keplr.ts | 14 ++++++++++---- .../src/actions/wallet/wallet-connect/leap.ts | 14 ++++++++++---- .../src/actions/wallet/wallet-connect/types.ts | 2 +- 6 files changed, 33 insertions(+), 24 deletions(-) diff --git a/packages/graz/src/actions/wallet/wallet-connect/clot.ts b/packages/graz/src/actions/wallet/wallet-connect/clot.ts index 33db8f63..9b2503de 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/clot.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/clot.ts @@ -23,12 +23,16 @@ export const getWCClot = (): Wallet => { walletType: WalletType.WC_CLOT_MOBILE, formatNativeUrl: (appUrl, wcUri, os) => { const plainAppUrl = appUrl.replaceAll("/", "").replaceAll(":", ""); - const encoded = encodeURIComponent(wcUri); + const encoded = wcUri && encodeURIComponent(wcUri); switch (os) { - case "ios": + case "ios": { + if (!encoded) return `${plainAppUrl}://wcV2`; return `${plainAppUrl}://wcV2?${encoded}`; - default: + } + default: { + if (!encoded) return `${plainAppUrl}://wc`; return `${plainAppUrl}://wc?uri=${encoded}`; + } } }, }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/cosmostation.ts b/packages/graz/src/actions/wallet/wallet-connect/cosmostation.ts index 862b1739..3b545683 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/cosmostation.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/cosmostation.ts @@ -23,6 +23,7 @@ export const getWCCosmostation = (): Wallet => { walletType: WalletType.WC_COSMOSTATION_MOBILE, formatNativeUrl: (appUrl, wcUri, _os) => { const plainAppUrl = appUrl.replaceAll("/", "").replaceAll(":", ""); + if (!wcUri) return `${plainAppUrl}://wc`; return `${plainAppUrl}://wc?${wcUri}`; }, }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/index.ts b/packages/graz/src/actions/wallet/wallet-connect/index.ts index 31dd0527..95c6717f 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/index.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/index.ts @@ -26,20 +26,12 @@ export const getWalletConnect = (params?: GetWalletConnectParams): Wallet => { const { appUrl, formatNativeUrl } = params; if (!isMobile()) return; if (isAndroid()) { - if (!wcUri) { - window.open(appUrl.mobile.android, "_self", "noreferrer noopener"); - } else { - const href = formatNativeUrl(appUrl.mobile.android, wcUri, "android"); - window.open(href, "_self", "noreferrer noopener"); - } + const href = formatNativeUrl(appUrl.mobile.android, wcUri, "android"); + window.open(href, "_self", "noreferrer noopener"); } if (isIos()) { - if (!wcUri) { - window.open(appUrl.mobile.ios, "_self", "noreferrer noopener"); - } else { - const href = formatNativeUrl(appUrl.mobile.ios, wcUri, "ios"); - window.open(href, "_self", "noreferrer noopener"); - } + const href = formatNativeUrl(appUrl.mobile.ios, wcUri, "ios"); + window.open(href, "_self", "noreferrer noopener"); } }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/keplr.ts b/packages/graz/src/actions/wallet/wallet-connect/keplr.ts index ddb5b975..1eaed4f7 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/keplr.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/keplr.ts @@ -23,14 +23,20 @@ export const getWCKeplr = (): Wallet => { walletType: WalletType.WC_KEPLR_MOBILE, formatNativeUrl: (appUrl, wcUri, os) => { const plainAppUrl = appUrl.replaceAll("/", "").replaceAll(":", ""); - const encoded = encodeURIComponent(wcUri); + const encoded = wcUri && encodeURIComponent(wcUri); switch (os) { - case "ios": + case "ios": { + if (!encoded) return `${plainAppUrl}://wcV2`; return `${plainAppUrl}://wcV2?${encoded}`; - case "android": + } + case "android": { + if (!encoded) return `${plainAppUrl}://wcV2#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`; return `${plainAppUrl}://wcV2?${encoded}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`; - default: + } + default: { + if (!encoded) return `${plainAppUrl}://wc`; return `${plainAppUrl}://wc?uri=${encoded}`; + } } }, }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/leap.ts b/packages/graz/src/actions/wallet/wallet-connect/leap.ts index 1b3d8115..55771480 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/leap.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/leap.ts @@ -23,14 +23,20 @@ export const getWCLeap = (): Wallet => { walletType: WalletType.WC_LEAP_MOBILE, formatNativeUrl: (appUrl, wcUri, os) => { const plainAppUrl = appUrl.replaceAll("/", "").replaceAll(":", ""); - const encoded = encodeURIComponent(wcUri); + const encoded = wcUri && encodeURIComponent(wcUri); switch (os) { - case "ios": + case "ios": { + if (!encoded) return `${plainAppUrl}://wcV2`; return `${plainAppUrl}://wcV2?${encoded}`; - case "android": + } + case "android": { + if (!encoded) return `${plainAppUrl}://wcV2#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`; return `${plainAppUrl}://wcV2?${encoded}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`; - default: + } + default: { + if (!encoded) return `${plainAppUrl}://wc`; return `${plainAppUrl}://wc?uri=${encoded}`; + } } }, }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/types.ts b/packages/graz/src/actions/wallet/wallet-connect/types.ts index 52114687..ae982073 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/types.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/types.ts @@ -27,5 +27,5 @@ export interface GetWalletConnectParams { android: string; }; }; - formatNativeUrl: (appUrl: string, wcUri: string, os?: "android" | "ios") => string; + formatNativeUrl: (appUrl: string, wcUri?: string, os?: "android" | "ios") => string; } From c6013e3f9ad482ab47b3388b3276f364c7bffa79 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Wed, 4 Dec 2024 00:52:50 +0700 Subject: [PATCH 2/2] bump version --- packages/graz/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/graz/package.json b/packages/graz/package.json index 859d5ef6..a3d7807f 100644 --- a/packages/graz/package.json +++ b/packages/graz/package.json @@ -1,7 +1,7 @@ { "name": "graz", "description": "React hooks for Cosmos", - "version": "0.1.29", + "version": "0.1.30", "author": "Griko Nibras ", "repository": "https://github.com/graz-sh/graz.git", "homepage": "https://github.com/graz-sh/graz",