Skip to content

Commit

Permalink
Merge pull request #87 from hyperweb-io/fix-cache-logic
Browse files Browse the repository at this point in the history
fix tx data array
  • Loading branch information
Zetazzz authored Feb 7, 2025
2 parents 3cdbfe3 + 8ab7f18 commit 28dc9d1
Show file tree
Hide file tree
Showing 61 changed files with 222 additions and 174 deletions.
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/extern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
17 changes: 10 additions & 7 deletions libs/cosmos-types/src/helper-func-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down Expand Up @@ -95,12 +95,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
client.addEncoders(opts.encoders ?? []);
client.addConverters(opts.converters ?? []);

const data = [
{
typeUrl: opts.typeUrl,
value: message,
},
];
const data = Array.isArray(message)
? message.map(msg => ({
typeUrl: opts.typeUrl,
value: msg,
}))
: [{
typeUrl: opts.typeUrl,
value: message,
}];
return client.signAndBroadcast!(signerAddress, data, fee, memo);
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/cosmos-types/src/varint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/extern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
18 changes: 10 additions & 8 deletions libs/injective-react/src/helper-func-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand All @@ -10,7 +10,6 @@ import { BinaryReader, BinaryWriter } from "./binary";
import { getRpcClient } from "./extern";
import { isRpc, Rpc } from "./helpers";
import { TelescopeGeneratedCodec } from "./types";
import { GlobalDecoderRegistry } from "./registry";

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

const data = [
{
typeUrl: opts.typeUrl,
value: message,
},
];
const data = Array.isArray(message)
? message.map(msg => ({
typeUrl: opts.typeUrl,
value: msg,
}))
: [{
typeUrl: opts.typeUrl,
value: message,
}];
return client.signAndBroadcast!(signerAddress, data, fee, memo);
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
15 changes: 8 additions & 7 deletions libs/injective-react/src/react-query.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/


import { getRpcClient } from './extern'
import { getRpcClient } from './extern'
import {
isRpc,
Rpc,
Expand Down Expand Up @@ -94,11 +94,6 @@ export const useRpcClient = <TData = ProtobufRpcClient>({
}, options);
};

export interface UseQueryBuilderOptions<TReq, TRes> {
builderQueryFn: (clientResolver?: RpcResolver) => (request: TReq) => Promise<TRes>,
queryKeyPrefix: string,
}

const getRpcClientFromCache = (
queryClient: ReturnType<typeof useQueryClient>,
key: string,
Expand All @@ -108,6 +103,12 @@ const getRpcClientFromCache = (
return queryClient.getQueryData<Rpc>(queryKey);
};

export interface UseQueryBuilderOptions<TReq, TRes> {
builderQueryFn: (clientResolver?: RpcResolver) => (request: TReq) => Promise<TRes>,
queryKeyPrefix: string,
}


export function buildUseQuery<TReq, TRes>(opts: UseQueryBuilderOptions<TReq, TRes>) {
return <TData = TRes>({
request,
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-react/src/varint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/extern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
17 changes: 10 additions & 7 deletions libs/injective-vue/src/helper-func-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down Expand Up @@ -95,12 +95,15 @@ export function buildTx<TMsg>(opts: TxBuilderOptions) {
client.addEncoders(opts.encoders ?? []);
client.addConverters(opts.converters ?? []);

const data = [
{
typeUrl: opts.typeUrl,
value: message,
},
];
const data = Array.isArray(message)
? message.map(msg => ({
typeUrl: opts.typeUrl,
value: msg,
}))
: [{
typeUrl: opts.typeUrl,
value: message,
}];
return client.signAndBroadcast!(signerAddress, data, fee, memo);
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/utf8.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injective-vue/src/varint.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
29 changes: 28 additions & 1 deletion libs/injective-vue/src/vue-query.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down Expand Up @@ -31,6 +31,7 @@ import {
} from '@tanstack/vue-query';

import { HttpEndpoint, ProtobufRpcClient } from '@cosmjs/stargate';
import { Tendermint34Client } from '@cosmjs/tendermint-rpc';
import {Ref} from 'vue'

export const DEFAULT_RPC_CLIENT_QUERY_KEY = 'rpcClient';
Expand Down Expand Up @@ -110,6 +111,32 @@ export function useRpcClient<TData = ProtobufRpcClient>({
);
}

interface UseTendermintClient extends VueQueryParams<Tendermint34Client> {
rpcEndpoint: string | HttpEndpoint;
}

/**
* Function that uses vue-query to cache a connected tendermint client.
*/
export const useTendermintClient = ({
rpcEndpoint,
options,
}: UseTendermintClient) => {
const { data: client } = useQuery<Tendermint34Client, Error, Tendermint34Client>({
queryKey: ['client', 'tendermint', rpcEndpoint],
queryFn: () => Tendermint34Client.connect(rpcEndpoint),
...{
// allow overriding
onError: (e: any) => {
throw new Error(`Failed to connect to ${rpcEndpoint}` + '\n' + e)
},
...options,
}
}
);
return { client };
};

export interface UseQueryBuilderOptions<TReq, TRes> {
builderQueryFn: (
clientResolver?: RpcResolver
Expand Down
2 changes: 1 addition & 1 deletion libs/injectivejs/src/binary.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injectivejs/src/extern.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
18 changes: 10 additions & 8 deletions libs/injectivejs/src/helper-func-types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand All @@ -10,7 +10,6 @@ import { BinaryReader, BinaryWriter } from "./binary";
import { getRpcClient } from "./extern";
import { isRpc, Rpc } from "./helpers";
import { TelescopeGeneratedCodec } from "./types";
import { GlobalDecoderRegistry } from "./registry";

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

const data = [
{
typeUrl: opts.typeUrl,
value: message,
},
];
const data = Array.isArray(message)
? message.map(msg => ({
typeUrl: opts.typeUrl,
value: msg,
}))
: [{
typeUrl: opts.typeUrl,
value: message,
}];
return client.signAndBroadcast!(signerAddress, data, fee, memo);
};
}
Expand Down
2 changes: 1 addition & 1 deletion libs/injectivejs/src/helpers.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injectivejs/src/registry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
2 changes: 1 addition & 1 deletion libs/injectivejs/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* This file and any referenced files were automatically generated by @cosmology/[email protected].16
* This file and any referenced files were automatically generated by @cosmology/[email protected].19
* DO NOT MODIFY BY HAND. Instead, download the latest proto files for your chain
* and run the transpile command or npm scripts command that is used to regenerate this bundle.
*/
Expand Down
Loading

0 comments on commit 28dc9d1

Please sign in to comment.