Skip to content

Commit 9617fc7

Browse files
authored
Merge pull request #23 from hyperweb-io/fix-inj-signing
Fix inj signing
2 parents 4f2ae9f + a5b3330 commit 9617fc7

File tree

6 files changed

+119
-2056
lines changed

6 files changed

+119
-2056
lines changed

examples/authz/hooks/useTx.ts

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export enum TxStatus {
1010
Broadcasting = 'Transaction Broadcasting',
1111
}
1212

13+
/**
14+
* Get the signing client for the chain
15+
* This is a hook that returns the signing client for the chain
16+
* @param chainName - The name of the chain
17+
* @param options - The options for the signing client
18+
* @param options.walletStatus - The current status of the wallet, only connected wallets are enabled
19+
* @returns The signing client for the chain
20+
*/
1321
export const useSigningClient = (
1422
chainName: string,
1523
options: {

examples/injective/components/SendMsg.tsx

+5-2
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,11 @@ export default function SendMsg() {
2121
const chain = defaultChain;
2222
const txPage = chain?.explorers?.[0].txPage;
2323

24-
const { address } = useChain(defaultChainName);
24+
const { address, status } = useChain(defaultChainName);
2525
const { data: signingClient, isLoading } = useSigningClient(
2626
defaultChainName,
2727
{
28-
walletStatus: WalletState.Connected,
28+
walletStatus: status,
2929
}
3030
);
3131

@@ -68,6 +68,8 @@ export default function SendMsg() {
6868
amount: [{ denom, amount: '1' }],
6969
});
7070

71+
console.log(signingClient);
72+
7173
send(
7274
{
7375
signerAddress: address,
@@ -82,6 +84,7 @@ export default function SendMsg() {
8284
setSending(false);
8385
},
8486
onError: (error) => {
87+
console.log(error);
8588
setError(error?.message || 'Unknown error');
8689
setSending(false);
8790
},

examples/injective/hooks/useTx.ts

+8
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ export enum TxStatus {
1010
Broadcasting = 'Transaction Broadcasting',
1111
}
1212

13+
/**
14+
* Get the signing client for the chain
15+
* This is a hook that returns the signing client for the chain
16+
* @param chainName - The name of the chain
17+
* @param options - The options for the signing client
18+
* @param options.walletStatus - The current status of the wallet, only connected wallets are enabled
19+
* @returns The signing client for the chain
20+
*/
1321
export const useSigningClient = (
1422
chainName: string,
1523
options: {

examples/injective/package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@
2424
"@cosmology/telescope": "^1.10.3",
2525
"@emotion/react": "11.10.6",
2626
"@emotion/styled": "11.10.6",
27-
"@interchain-kit/core": "0.2.202",
28-
"@interchain-kit/keplr-extension": "0.2.202",
29-
"@interchain-kit/leap-extension": "0.2.202",
30-
"@interchain-kit/react": "0.2.202",
27+
"@interchain-kit/core": "0.2.204",
28+
"@interchain-kit/keplr-extension": "0.2.204",
29+
"@interchain-kit/leap-extension": "0.2.204",
30+
"@interchain-kit/react": "0.2.204",
3131
"@interchain-ui/react": "^1.23.29",
3232
"@interchain-ui/react-no-ssr": "^0.1.6",
3333
"@interchainjs/cosmos": "1.9.12",
@@ -37,12 +37,12 @@
3737
"bignumber.js": "9.1.1",
3838
"chain-registry": "^1.69.32",
3939
"decimal.js": "^10.4.3",
40+
"immer": "^10.0.2",
4041
"injective-react": "1.9.12",
4142
"mobx": "^6.13.5",
4243
"next": "^13",
4344
"react": "18.2.0",
4445
"react-dom": "18.2.0",
45-
"immer": "^10.0.2",
4646
"react-icons": "4.6.0"
4747
},
4848
"devDependencies": {

examples/injective/pages/_app.tsx

+24-20
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
1-
import "../styles/globals.css";
2-
import "@interchain-ui/react/styles";
1+
import '../styles/globals.css';
2+
import '@interchain-ui/react/styles';
33

4-
import type { AppProps } from "next/app";
5-
import { QueryClientProvider, QueryClient } from "@tanstack/react-query";
6-
import { ChainProvider } from "@interchain-kit/react";
7-
import { defaultAssetList, defaultChain } from "../config/defaults";
8-
import { keplrWallet } from "@interchain-kit/keplr-extension";
9-
import { leapWallet } from "@interchain-kit/leap-extension";
4+
import type { AppProps } from 'next/app';
5+
import { QueryClientProvider, QueryClient } from '@tanstack/react-query';
6+
import { ChainProvider } from '@interchain-kit/react';
7+
import { defaultAssetList, defaultChain } from '../config/defaults';
8+
import { keplrWallet } from '@interchain-kit/keplr-extension';
9+
import { leapWallet } from '@interchain-kit/leap-extension';
10+
import { defaultSignerOptions } from '@interchainjs/injective/defaults';
1011
import {
1112
Box,
1213
ThemeProvider,
1314
Toaster,
1415
useTheme,
1516
useColorModeValue,
16-
} from "@interchain-ui/react";
17-
import { defaultRpcEndpoint } from "@/config";
17+
} from '@interchain-ui/react';
18+
import { defaultRpcEndpoint } from '@/config';
1819
const queryClient = new QueryClient({
1920
defaultOptions: {
2021
queries: {
@@ -36,18 +37,21 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
3637
assetLists={[defaultAssetList!]}
3738
wallets={[keplrWallet, leapWallet]}
3839
signerOptions={{
39-
signing: () => {
40-
return {
41-
broadcast: {
42-
checkTx: true,
43-
deliverTx: true,
44-
},
45-
};
40+
signing: (chain) => {
41+
if (chain === 'injective') {
42+
return {
43+
signerOptions: defaultSignerOptions.Cosmos,
44+
broadcast: {
45+
checkTx: true,
46+
deliverTx: true,
47+
},
48+
};
49+
}
4650
},
4751
}}
4852
endpointOptions={{
4953
endpoints: {
50-
"injective": {
54+
injective: {
5155
rpc: [defaultRpcEndpoint],
5256
},
5357
},
@@ -57,7 +61,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
5761
<Box
5862
className={themeClass}
5963
minHeight="100dvh"
60-
backgroundColor={useColorModeValue("$white", "$background")}
64+
backgroundColor={useColorModeValue('$white', '$background')}
6165
>
6266
{/* TODO fix type error */}
6367
{/* @ts-ignore */}
@@ -66,7 +70,7 @@ function CreateCosmosApp({ Component, pageProps }: AppProps) {
6670
</QueryClientProvider>
6771
</ChainProvider>
6872

69-
<Toaster position={"top-right"} closeButton={true} />
73+
<Toaster position={'top-right'} closeButton={true} />
7074
</ThemeProvider>
7175
);
7276
}

0 commit comments

Comments
 (0)