Skip to content

Commit 28dc9d1

Browse files
authored
Merge pull request #87 from hyperweb-io/fix-cache-logic
fix tx data array
2 parents 3cdbfe3 + 8ab7f18 commit 28dc9d1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+222
-174
lines changed

libs/cosmos-types/src/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/cosmos-types/src/extern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/cosmos-types/src/helper-func-types.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
@@ -95,12 +95,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
9595
client.addEncoders(opts.encoders ?? []);
9696
client.addConverters(opts.converters ?? []);
9797

98-
const data = [
99-
{
100-
typeUrl: opts.typeUrl,
101-
value: message,
102-
},
103-
];
98+
const data = Array.isArray(message)
99+
? message.map(msg => ({
100+
typeUrl: opts.typeUrl,
101+
value: msg,
102+
}))
103+
: [{
104+
typeUrl: opts.typeUrl,
105+
value: message,
106+
}];
104107
return client.signAndBroadcast!(signerAddress, data, fee, memo);
105108
};
106109
}

libs/cosmos-types/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/cosmos-types/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/cosmos-types/src/utf8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/cosmos-types/src/varint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/extern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/helper-func-types.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
@@ -10,7 +10,6 @@ import { BinaryReader, BinaryWriter } from "./binary";
1010
import { getRpcClient } from "./extern";
1111
import { isRpc, Rpc } from "./helpers";
1212
import { TelescopeGeneratedCodec } from "./types";
13-
import { GlobalDecoderRegistry } from "./registry";
1413

1514
export interface QueryBuilderOptions<TReq, TRes> {
1615
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -103,12 +102,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
103102
client.addEncoders(opts.encoders ?? []);
104103
client.addConverters(opts.converters ?? []);
105104

106-
const data = [
107-
{
108-
typeUrl: opts.typeUrl,
109-
value: message,
110-
},
111-
];
105+
const data = Array.isArray(message)
106+
? message.map(msg => ({
107+
typeUrl: opts.typeUrl,
108+
value: msg,
109+
}))
110+
: [{
111+
typeUrl: opts.typeUrl,
112+
value: message,
113+
}];
112114
return client.signAndBroadcast!(signerAddress, data, fee, memo);
113115
};
114116
}

libs/injective-react/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/react-query.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
66

77

8-
import { getRpcClient } from './extern'
8+
import { getRpcClient } from './extern'
99
import {
1010
isRpc,
1111
Rpc,
@@ -94,11 +94,6 @@ export const useRpcClient = <TData = ProtobufRpcClient>({
9494
}, options);
9595
};
9696

97-
export interface UseQueryBuilderOptions<TReq, TRes> {
98-
builderQueryFn: (clientResolver?: RpcResolver) => (request: TReq) => Promise<TRes>,
99-
queryKeyPrefix: string,
100-
}
101-
10297
const getRpcClientFromCache = (
10398
queryClient: ReturnType<typeof useQueryClient>,
10499
key: string,
@@ -108,6 +103,12 @@ const getRpcClientFromCache = (
108103
return queryClient.getQueryData<Rpc>(queryKey);
109104
};
110105

106+
export interface UseQueryBuilderOptions<TReq, TRes> {
107+
builderQueryFn: (clientResolver?: RpcResolver) => (request: TReq) => Promise<TRes>,
108+
queryKeyPrefix: string,
109+
}
110+
111+
111112
export function buildUseQuery<TReq, TRes>(opts: UseQueryBuilderOptions<TReq, TRes>) {
112113
return <TData = TRes>({
113114
request,

libs/injective-react/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/utf8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-react/src/varint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/extern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/helper-func-types.ts

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
@@ -95,12 +95,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
9595
client.addEncoders(opts.encoders ?? []);
9696
client.addConverters(opts.converters ?? []);
9797

98-
const data = [
99-
{
100-
typeUrl: opts.typeUrl,
101-
value: message,
102-
},
103-
];
98+
const data = Array.isArray(message)
99+
? message.map(msg => ({
100+
typeUrl: opts.typeUrl,
101+
value: msg,
102+
}))
103+
: [{
104+
typeUrl: opts.typeUrl,
105+
value: message,
106+
}];
104107
return client.signAndBroadcast!(signerAddress, data, fee, memo);
105108
};
106109
}

libs/injective-vue/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/utf8.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/varint.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injective-vue/src/vue-query.ts

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
@@ -31,6 +31,7 @@ import {
3131
} from '@tanstack/vue-query';
3232

3333
import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate';
34+
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
3435
import {Ref} from 'vue'
3536

3637
export const DEFAULT_RPC_CLIENT_QUERY_KEY = 'rpcClient';
@@ -110,6 +111,32 @@ export function useRpcClient<TData = ProtobufRpcClient>({
110111
);
111112
}
112113

114+
interface UseTendermintClient extends VueQueryParams<Tendermint34Client> {
115+
rpcEndpoint: string | HttpEndpoint;
116+
}
117+
118+
/**
119+
* Function that uses vue-query to cache a connected tendermint client.
120+
*/
121+
export const useTendermintClient = ({
122+
rpcEndpoint,
123+
options,
124+
}: UseTendermintClient) => {
125+
const { data: client } = useQuery<Tendermint34Client, Error, Tendermint34Client>({
126+
queryKey: ['client', 'tendermint', rpcEndpoint],
127+
queryFn: () => Tendermint34Client.connect(rpcEndpoint),
128+
...{
129+
// allow overriding
130+
onError: (e: any) => {
131+
throw new Error(`Failed to connect to ${rpcEndpoint}` + '\n' + e)
132+
},
133+
...options,
134+
}
135+
}
136+
);
137+
return { client };
138+
};
139+
113140
export interface UseQueryBuilderOptions<TReq, TRes> {
114141
builderQueryFn: (
115142
clientResolver?: RpcResolver

libs/injectivejs/src/binary.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injectivejs/src/extern.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injectivejs/src/helper-func-types.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/
@@ -10,7 +10,6 @@ import { BinaryReader, BinaryWriter } from "./binary";
1010
import { getRpcClient } from "./extern";
1111
import { isRpc, Rpc } from "./helpers";
1212
import { TelescopeGeneratedCodec } from "./types";
13-
import { GlobalDecoderRegistry } from "./registry";
1413

1514
export interface QueryBuilderOptions<TReq, TRes> {
1615
encode: (request: TReq, writer?: BinaryWriter) => BinaryWriter
@@ -103,12 +102,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
103102
client.addEncoders(opts.encoders ?? []);
104103
client.addConverters(opts.converters ?? []);
105104

106-
const data = [
107-
{
108-
typeUrl: opts.typeUrl,
109-
value: message,
110-
},
111-
];
105+
const data = Array.isArray(message)
106+
? message.map(msg => ({
107+
typeUrl: opts.typeUrl,
108+
value: msg,
109+
}))
110+
: [{
111+
typeUrl: opts.typeUrl,
112+
value: message,
113+
}];
112114
return client.signAndBroadcast!(signerAddress, data, fee, memo);
113115
};
114116
}

libs/injectivejs/src/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injectivejs/src/registry.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

libs/injectivejs/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
2+
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
33
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
44
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
55
*/

0 commit comments

Comments
 (0)