File tree Expand file tree Collapse file tree 7 files changed +91
-14
lines changed
__fixtures__/issues/98/out
packages/ts-codegen/src/helpers Expand file tree Collapse file tree 7 files changed +91
-14
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -103,7 +103,7 @@ export interface ICosmWasmClient {
103103 queryContractSmart ( contractAddr : string , query : any ) : Promise < any > ;
104104}
105105
106- export interface ISigningCosmWasmClient {
106+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
107107 execute (
108108 sender : string ,
109109 contractAddress : string ,
@@ -143,8 +143,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
143143 } ;
144144}
145145
146- export function getSigningCosmWasmClient ( signingClient : DirectSigner ) : ISigningCosmWasmClient {
146+ export function getSigningCosmWasmClient ( signingClient : DirectSigner , rpcEndpoint ?: string ) : ISigningCosmWasmClient {
147147 return {
148+ queryContractSmart : async ( contractAddr : string , query : any ) => {
149+ if ( ! rpcEndpoint ) {
150+ throw new Error ( 'rpcEndpoint is required for queryContractSmart in signing client' ) ;
151+ }
152+ const request : QuerySmartContractStateRequest = {
153+ address : contractAddr ,
154+ queryData : toUint8Array ( query )
155+ } ;
156+ const response : QuerySmartContractStateResponse = await getSmartContractState ( rpcEndpoint , request ) ;
157+ return fromUint8Array ( response . data ) ;
158+ } ,
148159 execute : async (
149160 sender : string ,
150161 contractAddress : string ,
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ export interface ICosmWasmClient {
9797 queryContractSmart(contractAddr: string, query: any): Promise<any>;
9898}
9999
100- export interface ISigningCosmWasmClient {
100+ export interface ISigningCosmWasmClient extends ICosmWasmClient {
101101 execute(
102102 sender: string,
103103 contractAddress: string,
@@ -137,8 +137,19 @@ export function getCosmWasmClient(rpcEndpoint: string): ICosmWasmClient {
137137 };
138138}
139139
140- export function getSigningCosmWasmClient(signingClient: DirectSigner): ISigningCosmWasmClient {
140+ export function getSigningCosmWasmClient(signingClient: DirectSigner, rpcEndpoint?: string ): ISigningCosmWasmClient {
141141 return {
142+ queryContractSmart: async (contractAddr: string, query: any) => {
143+ if (!rpcEndpoint) {
144+ throw new Error('rpcEndpoint is required for queryContractSmart in signing client');
145+ }
146+ const request: QuerySmartContractStateRequest = {
147+ address: contractAddr,
148+ queryData: toUint8Array(query)
149+ };
150+ const response: QuerySmartContractStateResponse = await getSmartContractState(rpcEndpoint, request);
151+ return fromUint8Array(response.data);
152+ },
142153 execute: async (
143154 sender: string,
144155 contractAddress: string,
You can’t perform that action at this time.
0 commit comments