From b70b84a775f73e2281d57f84fc656cc942e5d07e Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Thu, 30 May 2024 16:21:31 +0700 Subject: [PATCH 1/5] fix: signing client hooks returning undefined --- packages/graz/src/hooks/signingClients.ts | 32 +++++++++++------------ 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/packages/graz/src/hooks/signingClients.ts b/packages/graz/src/hooks/signingClients.ts index 43e84ff..0a5eebc 100644 --- a/packages/graz/src/hooks/signingClients.ts +++ b/packages/graz/src/hooks/signingClients.ts @@ -32,10 +32,10 @@ interface BaseSigningClientArgs extends QueryConfig { } export function useStargateSigningClient( args?: BaseSigningClientArgs & SiginingClientSinglechainArgs, -): UseQueryResult; +): UseQueryResult; export function useStargateSigningClient( args?: BaseSigningClientArgs & SiginingClientMultichainArgs, -): UseQueryResult>; +): UseQueryResult>; /** * graz query hook to retrieve a SigningStargateClient. * @@ -56,7 +56,7 @@ export function useStargateSigningClient( // eslint-disable-next-line prefer-arrow-functions/prefer-arrow-functions export function useStargateSigningClient( args?: BaseSigningClientArgs & Args, -): UseQueryResult> { +): UseQueryResult> { const chains = useChainsFromArgs({ chainId: args?.chainId, multiChain: args?.multiChain }); const wallet = useGrazInternalStore((x) => x.walletType); const activeChainIds = useGrazSessionStore((x) => x.activeChainIds); @@ -70,7 +70,7 @@ export function useStargateSigningClient( if (_chains.length < 1) throw new Error("No chains found"); const res = await createMultiChainAsyncFunction(Boolean(args?.multiChain), _chains, async (_chain) => { // Chain is not connected return undefined - if (!activeChainIds?.includes(_chain.chainId)) return undefined; + if (!activeChainIds?.includes(_chain.chainId)) return null; const isWalletAvailable = checkWallet(_wallet); if (!isWalletAvailable) { throw new Error(`${_wallet} is not available`); @@ -112,10 +112,10 @@ export function useStargateSigningClient( export function useCosmWasmSigningClient( args?: BaseSigningClientArgs & SiginingClientSinglechainArgs, -): UseQueryResult; +): UseQueryResult; export function useCosmWasmSigningClient( args?: BaseSigningClientArgs & SiginingClientMultichainArgs, -): UseQueryResult>; +): UseQueryResult>; /** * graz query hook to retrieve a SigningCosmWasmClient. * @@ -134,7 +134,7 @@ export function useCosmWasmSigningClient( // eslint-disable-next-line prefer-arrow-functions/prefer-arrow-functions export function useCosmWasmSigningClient( args?: BaseSigningClientArgs & Args, -): UseQueryResult> { +): UseQueryResult> { const chains = useChainsFromArgs({ chainId: args?.chainId, multiChain: args?.multiChain }); const wallet = useGrazInternalStore((x) => x.walletType); const activeChainIds = useGrazSessionStore((x) => x.activeChainIds); @@ -149,7 +149,7 @@ export function useCosmWasmSigningClient( if (_chains.length < 1) throw new Error("No chains found"); const res = await createMultiChainAsyncFunction(Boolean(args?.multiChain), _chains, async (_chain) => { // Chain is not connected return undefined - if (!activeChainIds?.includes(_chain.chainId)) return undefined; + if (!activeChainIds?.includes(_chain.chainId)) return null; const isWalletAvailable = checkWallet(_wallet); if (!isWalletAvailable) { throw new Error(`${_wallet} is not available`); @@ -193,13 +193,13 @@ export function useStargateTmSigningClient( type: "tm34" | "tm37"; } & BaseSigningClientArgs & SiginingClientSinglechainArgs, -): UseQueryResult; +): UseQueryResult; export function useStargateTmSigningClient( args: { type: "tm34" | "tm37"; } & BaseSigningClientArgs & SiginingClientMultichainArgs, -): UseQueryResult>; +): UseQueryResult>; /** * graz query hook to retrieve a SigningStargateClient with tendermint client. * @@ -223,7 +223,7 @@ export function useStargateTmSigningClient( type: "tm34" | "tm37"; } & BaseSigningClientArgs & Args, -): UseQueryResult> { +): UseQueryResult> { const chains = useChainsFromArgs({ chainId: args.chainId, multiChain: args.multiChain }); const wallet = useGrazInternalStore((x) => x.walletType); const activeChainIds = useGrazSessionStore((x) => x.activeChainIds); @@ -244,7 +244,7 @@ export function useStargateTmSigningClient( if (_chains.length < 1) throw new Error("No chains found"); const res = await createMultiChainAsyncFunction(Boolean(args.multiChain), _chains, async (_chain) => { // Chain is not connected return undefined - if (!activeChainIds?.includes(_chain.chainId)) return undefined; + if (!activeChainIds?.includes(_chain.chainId)) return null; const isWalletAvailable = checkWallet(_wallet); if (!isWalletAvailable) { throw new Error(`${_wallet} is not available`); @@ -289,13 +289,13 @@ export function useCosmWasmTmSigningClient( type: "tm34" | "tm37"; } & BaseSigningClientArgs & SiginingClientSinglechainArgs, -): UseQueryResult; +): UseQueryResult; export function useCosmWasmTmSigningClient( args: { type: "tm34" | "tm37"; } & BaseSigningClientArgs & SiginingClientMultichainArgs, -): UseQueryResult>; +): UseQueryResult>; /** * graz query hook to retrieve a SigningCosmWasmClient with tendermint client. * @@ -319,7 +319,7 @@ export function useCosmWasmTmSigningClient( type: "tm34" | "tm37"; } & BaseSigningClientArgs & Args, -): UseQueryResult> { +): UseQueryResult> { const chains = useChainsFromArgs({ chainId: args.chainId, multiChain: args.multiChain }); const wallet = useGrazInternalStore((x) => x.walletType); const activeChainIds = useGrazSessionStore((x) => x.activeChainIds); @@ -348,7 +348,7 @@ export function useCosmWasmTmSigningClient( if (_chains.length < 1) throw new Error("No chains found"); const res = await createMultiChainAsyncFunction(Boolean(args.multiChain), _chains, async (_chain) => { // Chain is not connected return undefined - if (!activeChainIds?.includes(_chain.chainId)) return undefined; + if (!activeChainIds?.includes(_chain.chainId)) return null; const isWalletAvailable = checkWallet(_wallet); if (!isWalletAvailable) { throw new Error(`${_wallet} is not available`); From 1bd6a66e108fdf9dc1c731b2099d66d8c8b55a9a Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Thu, 30 May 2024 16:28:49 +0700 Subject: [PATCH 2/5] chore: cleanup --- packages/graz/src/actions/wallet/index.ts | 2 +- .../graz/src/actions/wallet/leap-metamask-snap/index.ts | 1 + packages/graz/src/actions/wallet/wallet-connect/clot.ts | 1 + packages/graz/src/actions/wallet/wallet-connect/types.ts | 6 +++++- 4 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/graz/src/actions/wallet/index.ts b/packages/graz/src/actions/wallet/index.ts index ffb088f..6e2ca72 100644 --- a/packages/graz/src/actions/wallet/index.ts +++ b/packages/graz/src/actions/wallet/index.ts @@ -12,10 +12,10 @@ import { getMetamaskSnapLeap } from "./leap-metamask-snap/leap"; import { getStation } from "./station"; import { getVectis } from "./vectis"; import { getWalletConnect } from "./wallet-connect"; +import { getWCClot } from "./wallet-connect/clot"; import { getWCCosmostation } from "./wallet-connect/cosmostation"; import { getWCKeplr } from "./wallet-connect/keplr"; import { getWCLeap } from "./wallet-connect/leap"; -import { getWCClot } from "./wallet-connect/clot"; import { getXDefi } from "./xdefi"; /** diff --git a/packages/graz/src/actions/wallet/leap-metamask-snap/index.ts b/packages/graz/src/actions/wallet/leap-metamask-snap/index.ts index c3e96bf..10c10d5 100644 --- a/packages/graz/src/actions/wallet/leap-metamask-snap/index.ts +++ b/packages/graz/src/actions/wallet/leap-metamask-snap/index.ts @@ -233,6 +233,7 @@ export const getMetamaskSnap = (params?: GetMetamaskSnap): Wallet => { }; }; + // eslint-disable-next-line @typescript-eslint/require-await const getOfflineSignerAuto = async (chainId: string) => { return getOfflineSignerOnlyAmino(chainId); }; diff --git a/packages/graz/src/actions/wallet/wallet-connect/clot.ts b/packages/graz/src/actions/wallet/wallet-connect/clot.ts index cdce66b..33db8f6 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/clot.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/clot.ts @@ -16,6 +16,7 @@ export const getWCClot = (): Wallet => { encoding: "base64", appUrl: { mobile: { + android: "clot://", ios: "clot://", }, }, diff --git a/packages/graz/src/actions/wallet/wallet-connect/types.ts b/packages/graz/src/actions/wallet/wallet-connect/types.ts index 09cfea9..5211468 100644 --- a/packages/graz/src/actions/wallet/wallet-connect/types.ts +++ b/packages/graz/src/actions/wallet/wallet-connect/types.ts @@ -16,7 +16,11 @@ export interface WalletConnectSignDirectResponse { export interface GetWalletConnectParams { encoding: BufferEncoding; - walletType: WalletType.WC_KEPLR_MOBILE | WalletType.WC_LEAP_MOBILE | WalletType.WC_COSMOSTATION_MOBILE | WalletType.WC_CLOT_MOBILE; + walletType: + | WalletType.WC_KEPLR_MOBILE + | WalletType.WC_LEAP_MOBILE + | WalletType.WC_COSMOSTATION_MOBILE + | WalletType.WC_CLOT_MOBILE; appUrl: { mobile: { ios: string; From 660ed05424aaa87551684edc6263509c06914ec7 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Thu, 30 May 2024 16:29:04 +0700 Subject: [PATCH 3/5] feat(docs): wc clot mobile --- docs/docs/types/walletType.md | 1 + docs/docs/wallet-connect.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/docs/docs/types/walletType.md b/docs/docs/types/walletType.md index cf8398c..2e56d8b 100644 --- a/docs/docs/types/walletType.md +++ b/docs/docs/types/walletType.md @@ -44,6 +44,7 @@ enum WalletType { WC_KEPLR_MOBILE = "wc_keplr_mobile", WC_LEAP_MOBILE = "wc_leap_mobile", WC_COSMOSTATION_MOBILE = "wc_cosmostation_mobile", + WC_CLOT_MOBILE = "wc_clot_mobile", METAMASK_SNAP_LEAP = "metamask_snap_leap", METAMASK_SNAP_COSMOS = "metamask_snap_cosmos", STATION = "station", diff --git a/docs/docs/wallet-connect.md b/docs/docs/wallet-connect.md index a3f205c..d4f865d 100644 --- a/docs/docs/wallet-connect.md +++ b/docs/docs/wallet-connect.md @@ -70,4 +70,4 @@ export const AvailableWallets = () => { `WalletType.WC_COSMOSTATION_MOBILE` - `WalletType.WC_KEPLR_MOBILE` | `WalletType.WC_LEAP_MOBILE`| - `WalletType.WC_COSMOSTATION_MOBILE` only returns true on mobile, `WalletType.WALLETCONNECT` will shows on anywhere + `WalletType.WC_COSMOSTATION_MOBILE` | `WalletType.WC_CLOT_MOBILE` only returns true on mobile, `WalletType.WALLETCONNECT` will shows on anywhere From 95dd63ee76cd226607b3211aaa5f5605255f9cf8 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Thu, 30 May 2024 16:33:39 +0700 Subject: [PATCH 4/5] feat(docs): update changelog and migration guide --- docs/docs/change-log.md | 21 +++++++++++++++++++++ docs/docs/migration-guide.md | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/docs/docs/change-log.md b/docs/docs/change-log.md index 2cd2574..597d529 100644 --- a/docs/docs/change-log.md +++ b/docs/docs/change-log.md @@ -4,6 +4,27 @@ sidebar_position: 8 # Changelog +## Version 0.1.18 + +- Added Wallet connect mobile clot integration +- Fix signing client hooks client side error + +## Version 0.1.16 + +- Bump capsule deps + +## Version 0.1.15 + +- Fetch all keys from wallet instead of transforming bech32 + +## Version 0.1.14 + +- Support iframe autoconnect + +## version 0.1.13 + +- Support iframe connection + ## Version 0.1.9 - graz cli fix null `gasPriceStep` diff --git a/docs/docs/migration-guide.md b/docs/docs/migration-guide.md index aa5bf43..519e750 100644 --- a/docs/docs/migration-guide.md +++ b/docs/docs/migration-guide.md @@ -4,6 +4,12 @@ sidebar_position: 3 # Migration Guide +## 0.1.18 Breaking Changes + +### Signing client hooks + +Now siging client hooks not returning `undefined` when the signing client is not available, it will return `null` instead. + ## 0.1.0 Breaking Changes ### `` From 0f4abad9bd64211bdd758b650d4dd368612f4ee7 Mon Sep 17 00:00:00 2001 From: Nur Fikri Date: Thu, 30 May 2024 16:33:52 +0700 Subject: [PATCH 5/5] feat: v0.1.18 --- 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 10a0139..fb0d68d 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.17", + "version": "0.1.18", "author": "Griko Nibras ", "repository": "https://github.com/graz-sh/graz.git", "homepage": "https://github.com/graz-sh/graz",