Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix inj signing #23

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/authz/hooks/useTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export enum TxStatus {
Broadcasting = 'Transaction Broadcasting',
}

/**
* Get the signing client for the chain
* This is a hook that returns the signing client for the chain
* @param chainName - The name of the chain
* @param options - The options for the signing client
* @param options.walletStatus - The current status of the wallet, only connected wallets are enabled
* @returns The signing client for the chain
*/
export const useSigningClient = (
chainName: string,
options: {
Expand Down
7 changes: 5 additions & 2 deletions examples/injective/components/SendMsg.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ export default function SendMsg() {
const chain = defaultChain;
const txPage = chain?.explorers?.[0].txPage;

const { address } = useChain(defaultChainName);
const { address, status } = useChain(defaultChainName);
const { data: signingClient, isLoading } = useSigningClient(
defaultChainName,
{
walletStatus: WalletState.Connected,
walletStatus: status,
}
);

Expand Down Expand Up @@ -68,6 +68,8 @@ export default function SendMsg() {
amount: [{ denom, amount: '1' }],
});

console.log(signingClient);

send(
{
signerAddress: address,
Expand All @@ -82,6 +84,7 @@ export default function SendMsg() {
setSending(false);
},
onError: (error) => {
console.log(error);
setError(error?.message || 'Unknown error');
setSending(false);
},
Expand Down
8 changes: 8 additions & 0 deletions examples/injective/hooks/useTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ export enum TxStatus {
Broadcasting = 'Transaction Broadcasting',
}

/**
* Get the signing client for the chain
* This is a hook that returns the signing client for the chain
* @param chainName - The name of the chain
* @param options - The options for the signing client
* @param options.walletStatus - The current status of the wallet, only connected wallets are enabled
* @returns The signing client for the chain
*/
export const useSigningClient = (
chainName: string,
options: {
Expand Down
10 changes: 5 additions & 5 deletions examples/injective/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
"@cosmology/telescope": "^1.10.3",
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@interchain-kit/core": "0.2.202",
"@interchain-kit/keplr-extension": "0.2.202",
"@interchain-kit/leap-extension": "0.2.202",
"@interchain-kit/react": "0.2.202",
"@interchain-kit/core": "0.2.204",
"@interchain-kit/keplr-extension": "0.2.204",
"@interchain-kit/leap-extension": "0.2.204",
"@interchain-kit/react": "0.2.204",
"@interchain-ui/react": "^1.23.29",
"@interchain-ui/react-no-ssr": "^0.1.6",
"@interchainjs/cosmos": "1.9.12",
Expand All @@ -37,12 +37,12 @@
"bignumber.js": "9.1.1",
"chain-registry": "^1.69.32",
"decimal.js": "^10.4.3",
"immer": "^10.0.2",
"injective-react": "1.9.12",
"mobx": "^6.13.5",
"next": "^13",
"react": "18.2.0",
"react-dom": "18.2.0",
"immer": "^10.0.2",
"react-icons": "4.6.0"
},
"devDependencies": {
Expand Down
44 changes: 24 additions & 20 deletions examples/injective/pages/_app.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
import "../styles/globals.css";
import "@interchain-ui/react/styles";
import '../styles/globals.css';
import '@interchain-ui/react/styles';

import type { AppProps } from "next/app";
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
import { ChainProvider } from "@interchain-kit/react";
import { defaultAssetList, defaultChain } from "../config/defaults";
import { keplrWallet } from "@interchain-kit/keplr-extension";
import { leapWallet } from "@interchain-kit/leap-extension";
import type { AppProps } from 'next/app';
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
import { ChainProvider } from '@interchain-kit/react';
import { defaultAssetList, defaultChain } from '../config/defaults';
import { keplrWallet } from '@interchain-kit/keplr-extension';
import { leapWallet } from '@interchain-kit/leap-extension';
import { defaultSignerOptions } from '@interchainjs/injective/defaults';
import {
Box,
ThemeProvider,
Toaster,
useTheme,
useColorModeValue,
} from "@interchain-ui/react";
import { defaultRpcEndpoint } from "@/config";
} from '@interchain-ui/react';
import { defaultRpcEndpoint } from '@/config';
const queryClient = new QueryClient({
defaultOptions: {
queries: {
Expand All @@ -36,18 +37,21 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
assetLists={[defaultAssetList!]}
wallets={[keplrWallet, leapWallet]}
signerOptions={{
signing: () => {
return {
broadcast: {
checkTx: true,
deliverTx: true,
},
};
signing: (chain) => {
if (chain === 'injective') {
return {
signerOptions: defaultSignerOptions.Cosmos,
broadcast: {
checkTx: true,
deliverTx: true,
},
};
}
},
}}
endpointOptions={{
endpoints: {
"injective": {
injective: {
rpc: [defaultRpcEndpoint],
},
},
Expand All @@ -57,7 +61,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
<Box
className={themeClass}
minHeight="100dvh"
backgroundColor={useColorModeValue("$white", "$background")}
backgroundColor={useColorModeValue('$white', '$background')}
>
{/* TODO fix type error */}
{/* @ts-ignore */}
Expand All @@ -66,7 +70,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
</QueryClientProvider>
</ChainProvider>

<Toaster position={"top-right"} closeButton={true} />
<Toaster position={'top-right'} closeButton={true} />
</ThemeProvider>
);
}
Expand Down
Loading
Loading