Skip to content

Update/interchainjs migration #175

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import { ICosmWasmClient, ISigningCosmWasmClient } from "./contractContextBase";
import { ExecuteResult } from "@interchainjs/cosmos/signing-client";
import { Coin, StdFee } from "@interchainjs/amino";
import { ExecuteMsg, Binary, InstantiateMsg, QueryMsg } from "./CwAdminFactory.types";
export interface CwAdminFactoryReadOnlyInterface {
contractAddress: string;
}
export class CwAdminFactoryQueryClient implements CwAdminFactoryReadOnlyInterface {
client: CosmWasmClient;
client: ICosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string) {
constructor(client: ICosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
}
Expand All @@ -32,10 +33,10 @@ export interface CwAdminFactoryInterface {
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class CwAdminFactoryClient implements CwAdminFactoryInterface {
client: SigningCosmWasmClient;
client: ISigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
constructor(client: ISigningCosmWasmClient, sender: string, contractAddress: string) {
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { Coin } from "@cosmjs/amino";
import { MsgExecuteContractEncodeObject } from "@cosmjs/cosmwasm-stargate";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { Coin } from "@interchainjs/amino";
import { MsgExecuteContractEncodeObject } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { MsgExecuteContract } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@interchainjs/encoding";
import { ExecuteMsg, Binary, InstantiateMsg, QueryMsg } from "./CwAdminFactory.types";
export interface CwAdminFactoryMsg {
contractAddress: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import { ICosmWasmClient, ISigningCosmWasmClient } from "./contractContextBase";
import { ExecuteResult } from "@interchainjs/cosmos/signing-client";
import { Coin, StdFee } from "@interchainjs/amino";
import { Addr, PaymentInfo, Uint128, ConfigResponse, ExecuteMsg, Binary, Cw20ReceiveMsg, GetRegistrationResponse, Registration, InfoForCodeIdResponse, InstantiateMsg, ListRegistrationsResponse, QueryMsg, ReceiveMsg } from "./CwCodeIdRegistry.types";
export interface CwCodeIdRegistryReadOnlyInterface {
contractAddress: string;
Expand Down Expand Up @@ -35,9 +36,9 @@ export interface CwCodeIdRegistryReadOnlyInterface {
}) => Promise<ListRegistrationsResponse>;
}
export class CwCodeIdRegistryQueryClient implements CwCodeIdRegistryReadOnlyInterface {
client: CosmWasmClient;
client: ICosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string) {
constructor(client: ICosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
this.config = this.config.bind(this);
Expand Down Expand Up @@ -146,10 +147,10 @@ export interface CwCodeIdRegistryInterface {
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class CwCodeIdRegistryClient implements CwCodeIdRegistryInterface {
client: SigningCosmWasmClient;
client: ISigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
constructor(client: ISigningCosmWasmClient, sender: string, contractAddress: string) {
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { Coin } from "@cosmjs/amino";
import { MsgExecuteContractEncodeObject } from "@cosmjs/cosmwasm-stargate";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { Coin } from "@interchainjs/amino";
import { MsgExecuteContractEncodeObject } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { MsgExecuteContract } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@interchainjs/encoding";
import { Addr, PaymentInfo, Uint128, ConfigResponse, ExecuteMsg, Binary, Cw20ReceiveMsg, GetRegistrationResponse, Registration, InfoForCodeIdResponse, InstantiateMsg, ListRegistrationsResponse, QueryMsg, ReceiveMsg } from "./CwCodeIdRegistry.types";
export interface CwCodeIdRegistryMsg {
contractAddress: string;
Expand Down
13 changes: 7 additions & 6 deletions __output__/builder/bundler_test/contracts/CwSingle.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { ICosmWasmClient, ISigningCosmWasmClient } from "./contractContextBase";
import { ExecuteResult } from "@interchainjs/cosmos/signing-client";
import { StdFee } from "@interchainjs/amino";
import { Addr, Uint128, Duration, Threshold, PercentageThreshold, Decimal, ConfigResponse, CheckedDepositInfo, ExecuteMsg, CosmosMsgForEmpty, BankMsg, StakingMsg, DistributionMsg, Binary, IbcMsg, Timestamp, Uint64, WasmMsg, GovMsg, VoteOption, Vote, DepositToken, Coin, Empty, IbcTimeout, IbcTimeoutBlock, DepositInfo, GovernanceModulesResponse, InfoResponse, ContractVersion, InstantiateMsg, Expiration, Status, ListProposalsResponse, ProposalResponse, Proposal, Votes, ListVotesResponse, VoteInfo, MigrateMsg, ProposalCountResponse, ProposalHooksResponse, QueryMsg, ReverseProposalsResponse, VoteHooksResponse, VoteResponse } from "./CwSingle.types";
export interface CwSingleReadOnlyInterface {
contractAddress: string;
Expand Down Expand Up @@ -51,9 +52,9 @@ export interface CwSingleReadOnlyInterface {
info: () => Promise<InfoResponse>;
}
export class CwSingleQueryClient implements CwSingleReadOnlyInterface {
client: CosmWasmClient;
client: ICosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string) {
constructor(client: ICosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
this.config = this.config.bind(this);
Expand Down Expand Up @@ -231,10 +232,10 @@ export interface CwSingleInterface {
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class CwSingleClient implements CwSingleInterface {
client: SigningCosmWasmClient;
client: ISigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
constructor(client: ISigningCosmWasmClient, sender: string, contractAddress: string) {
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { MsgExecuteContractEncodeObject } from "@cosmjs/cosmwasm-stargate";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { MsgExecuteContractEncodeObject } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { MsgExecuteContract } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@interchainjs/encoding";
import { Addr, Uint128, Duration, Threshold, PercentageThreshold, Decimal, ConfigResponse, CheckedDepositInfo, ExecuteMsg, CosmosMsgForEmpty, BankMsg, StakingMsg, DistributionMsg, Binary, IbcMsg, Timestamp, Uint64, WasmMsg, GovMsg, VoteOption, Vote, DepositToken, Coin, Empty, IbcTimeout, IbcTimeoutBlock, DepositInfo, GovernanceModulesResponse, InfoResponse, ContractVersion, InstantiateMsg, Expiration, Status, ListProposalsResponse, ProposalResponse, Proposal, Votes, ListVotesResponse, VoteInfo, MigrateMsg, ProposalCountResponse, ProposalHooksResponse, QueryMsg, ReverseProposalsResponse, VoteHooksResponse, VoteResponse } from "./CwSingle.types";
export interface CwSingleMsg {
contractAddress: string;
Expand Down
13 changes: 7 additions & 6 deletions __output__/builder/bundler_test/contracts/Factory.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { ICosmWasmClient, ISigningCosmWasmClient } from "./contractContextBase";
import { ExecuteResult } from "@interchainjs/cosmos/signing-client";
import { StdFee } from "@interchainjs/amino";
import { AdminAddrResponse, CodeIdResponse, CodeIdType, Uint128, Binary, CreateWalletMsg, Guardians, MultiSig, Coin, Cw20Coin, ExecuteMsg, Addr, ProxyMigrationTxMsg, WalletAddr, CanonicalAddr, RelayTransaction, FeeResponse, GovecAddrResponse, InstantiateMsg, QueryMsg, WalletQueryPrefix, Duration, StakingOptions, WalletInfo, ContractVersion, WalletsOfResponse, WalletsResponse } from "./Factory.types";
export interface FactoryReadOnlyInterface {
contractAddress: string;
Expand Down Expand Up @@ -35,9 +36,9 @@ export interface FactoryReadOnlyInterface {
adminAddr: () => Promise<AdminAddrResponse>;
}
export class FactoryQueryClient implements FactoryReadOnlyInterface {
client: CosmWasmClient;
client: ICosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string) {
constructor(client: ICosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
this.wallets = this.wallets.bind(this);
Expand Down Expand Up @@ -151,10 +152,10 @@ export interface FactoryInterface {
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class FactoryClient implements FactoryInterface {
client: SigningCosmWasmClient;
client: ISigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
constructor(client: ISigningCosmWasmClient, sender: string, contractAddress: string) {
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { MsgExecuteContractEncodeObject } from "@cosmjs/cosmwasm-stargate";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { MsgExecuteContractEncodeObject } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { MsgExecuteContract } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@interchainjs/encoding";
import { AdminAddrResponse, CodeIdResponse, CodeIdType, Uint128, Binary, CreateWalletMsg, Guardians, MultiSig, Coin, Cw20Coin, ExecuteMsg, Addr, ProxyMigrationTxMsg, WalletAddr, CanonicalAddr, RelayTransaction, FeeResponse, GovecAddrResponse, InstantiateMsg, QueryMsg, WalletQueryPrefix, Duration, StakingOptions, WalletInfo, ContractVersion, WalletsOfResponse, WalletsResponse } from "./Factory.types";
export interface FactoryMsg {
contractAddress: string;
Expand Down
13 changes: 7 additions & 6 deletions __output__/builder/bundler_test/contracts/Minter.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { StdFee } from "@cosmjs/amino";
import { ICosmWasmClient, ISigningCosmWasmClient } from "./contractContextBase";
import { ExecuteResult } from "@interchainjs/cosmos/signing-client";
import { StdFee } from "@interchainjs/amino";
import { Addr, Timestamp, Uint64, Uint128, Config, Coin, ConfigResponse, ExecuteMsg, Decimal, InstantiateMsg, InstantiateMsg1, CollectionInfoForRoyaltyInfoResponse, RoyaltyInfoResponse, QueryMsg } from "./Minter.types";
export interface MinterReadOnlyInterface {
contractAddress: string;
Expand All @@ -20,9 +21,9 @@ export interface MinterReadOnlyInterface {
}) => Promise<MintCountResponse>;
}
export class MinterQueryClient implements MinterReadOnlyInterface {
client: CosmWasmClient;
client: ICosmWasmClient;
contractAddress: string;
constructor(client: CosmWasmClient, contractAddress: string) {
constructor(client: ICosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
this.config = this.config.bind(this);
Expand Down Expand Up @@ -93,10 +94,10 @@ export interface MinterInterface {
withdraw: (fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class MinterClient implements MinterInterface {
client: SigningCosmWasmClient;
client: ISigningCosmWasmClient;
sender: string;
contractAddress: string;
constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
constructor(client: ISigningCosmWasmClient, sender: string, contractAddress: string) {
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { MsgExecuteContractEncodeObject } from "@cosmjs/cosmwasm-stargate";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { MsgExecuteContractEncodeObject } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { MsgExecuteContract } from "@interchainjs/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@interchainjs/encoding";
import { Addr, Timestamp, Uint64, Uint128, Config, Coin, ConfigResponse, ExecuteMsg, Decimal, InstantiateMsg, InstantiateMsg1, CollectionInfoForRoyaltyInfoResponse, RoyaltyInfoResponse, QueryMsg } from "./Minter.types";
export interface MinterMsg {
contractAddress: string;
Expand Down
84 changes: 74 additions & 10 deletions __output__/builder/bundler_test/contracts/contractContextBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,80 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { StdFee } from '@interchainjs/amino';
import { SigningClient } from '@interchainjs/cosmos/signing-client';
import { createGetSmartContractState } from '@interchainjs/cosmwasm/wasm/v1/query.rpc.func';
import { createExecuteContract } from '@interchainjs/cosmwasm/wasm/v1/tx.rpc.func';
import { QuerySmartContractStateRequest } from '@interchainjs/cosmwasm/wasm/v1/query';
import { MsgExecuteContract } from '@interchainjs/cosmwasm/wasm/v1/tx';
import { fromUtf8, toUtf8 } from '@interchainjs/encoding';

// InterchainJS interfaces for CosmWasm clients
export interface ICosmWasmClient {
queryContractSmart(contractAddr: string, query: any): Promise<any>;
}

export interface ISigningCosmWasmClient {
execute(sender: string, contractAddress: string, msg: any, fee?: any, memo?: string, funds?: any[]): Promise<any>;
}

export interface ISigningClient {
signAndBroadcast(
signerAddress: string,
messages: any[],
fee: StdFee,
memo?: string
): Promise<any>;
}

// Helper functions to create InterchainJS clients
export function getCosmWasmClient(rpc: string): ICosmWasmClient {
// Create the query client using InterchainJS
const querySmartContractState = createGetSmartContractState();

return {
queryContractSmart: async (contractAddr: string, query: any) => {
// Create the request object
const request: QuerySmartContractStateRequest = {
address: contractAddr,
queryData: fromUtf8(JSON.stringify(query))
};

// Execute the query
const response = await querySmartContractState(request);

// Parse and return the result
return JSON.parse(toUtf8(response.data));
},
};
}

import {
CosmWasmClient,
SigningCosmWasmClient,
} from '@cosmjs/cosmwasm-stargate';
export function getSigningCosmWasmClient(client: ISigningClient): ISigningCosmWasmClient {
// Create the execute client using InterchainJS
const executeContract = createExecuteContract();

return {
execute: async (sender: string, contractAddress: string, msg: any, fee?: any, memo?: string, funds?: any[]) => {
// Create the message object
const message: MsgExecuteContract = {
sender,
contract: contractAddress,
msg: fromUtf8(JSON.stringify(msg)),
funds: funds || []
};

// Execute the transaction
const result = await executeContract(message);

return result;
},
};
}

export interface IContractConstructor {
address: string | undefined;
cosmWasmClient: CosmWasmClient | undefined;
signingCosmWasmClient: SigningCosmWasmClient | undefined;
cosmWasmClient: ICosmWasmClient | undefined;
signingCosmWasmClient: ISigningCosmWasmClient | undefined;
}

export const NO_SINGING_ERROR_MESSAGE = 'signingCosmWasmClient not connected';
Expand Down Expand Up @@ -55,15 +119,15 @@ export class ContractBase<
> {
constructor(
protected address: string | undefined,
protected cosmWasmClient: CosmWasmClient | undefined,
protected signingCosmWasmClient: SigningCosmWasmClient | undefined,
protected cosmWasmClient: ICosmWasmClient | undefined,
protected signingCosmWasmClient: ISigningCosmWasmClient | undefined,
private TSign?: new (
client: SigningCosmWasmClient,
client: ISigningCosmWasmClient,
sender: string,
contractAddress: string
) => TSign,
private TQuery?: new (
client: CosmWasmClient,
client: ICosmWasmClient,
contractAddress: string
) => TQuery,
private TMsgComposer?: new (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
* and run the @cosmwasm/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { IQueryClientProvider, ISigningClientProvider, IMessageComposerProvider } from "./contractContextBase";
import { ICosmWasmClient, ISigningCosmWasmClient, getCosmWasmClient, getSigningCosmWasmClient, IQueryClientProvider, ISigningClientProvider, IMessageComposerProvider } from "./contractContextBase";
import { FactoryQueryClient } from "./Factory.client";
import { FactoryClient } from "./Factory.client";
import { FactoryMsgComposer } from "./Factory.message-composer";
Expand Down
Loading
Loading