diff --git a/packages/graz/package.json b/packages/graz/package.json index 859d5ef..a3d7807 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", diff --git a/packages/graz/src/actions/wallet/wallet-connect/clot.ts b/packages/graz/src/actions/wallet/wallet-connect/clot.ts index 33db8f6..9b2503d 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 862b173..3b54568 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 31dd052..95c6717 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 ddb5b97..1eaed4f 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 1b3d811..5577148 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 5211468..ae98207 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; }