Skip to content
Merged
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
986 changes: 986 additions & 0 deletions __fixtures__/abstract/apps/ibcmail/client.json

Large diffs are not rendered by default.

10 changes: 8 additions & 2 deletions __output__/abstract/apps/autocompounder/Autocompounder.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
import { StdFee, Coin } from "@cosmjs/amino";
import { Decimal, AssetEntry, BondingPeriodSelector, Duration, InstantiateMsg, ExecuteMsg, Uint128, AnsAsset, QueryMsg, MigrateMsg, Expiration, Timestamp, Uint64, ArrayOfTupleOfStringAndArrayOfClaim, Claim, ArrayOfClaim, Addr, PoolAddressBaseForAddr, AssetInfoBaseForAddr, PoolType, Config, PoolMetadata } from "./Autocompounder.types";
import { AutocompounderQueryMsgBuilder, AutocompounderExecuteMsgBuilder } from "./Autocompounder.message-builder";
Expand Down Expand Up @@ -97,7 +97,13 @@ export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClie
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);

if (address === null) {
throw new Error(`Module ${this.moduleId} not installed`);
}

this._moduleAddress = address;
}

return this._moduleAddress!;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function useAutocompounderBalanceQuery<TData = Uint128>({
args,
options
}: AutocompounderBalanceQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client.moduleId, args), () => client.balance({
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client._moduleAddress, args), () => client.balance({
address: args.address
}), options);
}
Expand All @@ -148,14 +148,14 @@ export function useAutocompounderTotalLpPositionQuery<TData = Uint128>({
client,
options
}: AutocompounderTotalLpPositionQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client.moduleId), () => client.totalLpPosition(), options);
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client._moduleAddress), () => client.totalLpPosition(), options);
}
export interface AutocompounderLatestUnbondingQuery<TData> extends AutocompounderReactQuery<Expiration, TData> {}
export function useAutocompounderLatestUnbondingQuery<TData = Expiration>({
client,
options
}: AutocompounderLatestUnbondingQuery<TData>) {
return useQuery<Expiration, Error, TData>(autocompounderQueryKeys.latestUnbonding(client.moduleId), () => client.latestUnbonding(), options);
return useQuery<Expiration, Error, TData>(autocompounderQueryKeys.latestUnbonding(client._moduleAddress), () => client.latestUnbonding(), options);
}
export interface AutocompounderAllClaimsQuery<TData> extends AutocompounderReactQuery<ArrayOfTupleOfStringAndArrayOfClaim, TData> {
args: {
Expand All @@ -168,7 +168,7 @@ export function useAutocompounderAllClaimsQuery<TData = ArrayOfTupleOfStringAndA
args,
options
}: AutocompounderAllClaimsQuery<TData>) {
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client.moduleId, args), () => client.allClaims({
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client._moduleAddress, args), () => client.allClaims({
limit: args.limit,
startAfter: args.startAfter
}), options);
Expand All @@ -183,7 +183,7 @@ export function useAutocompounderClaimsQuery<TData = ArrayOfClaim>({
args,
options
}: AutocompounderClaimsQuery<TData>) {
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client.moduleId, args), () => client.claims({
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client._moduleAddress, args), () => client.claims({
address: args.address
}), options);
}
Expand All @@ -197,7 +197,7 @@ export function useAutocompounderPendingClaimsQuery<TData = Uint128>({
args,
options
}: AutocompounderPendingClaimsQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client.moduleId, args), () => client.pendingClaims({
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client._moduleAddress, args), () => client.pendingClaims({
address: args.address
}), options);
}
Expand All @@ -206,7 +206,7 @@ export function useAutocompounderConfigQuery<TData = Config>({
client,
options
}: AutocompounderConfigQuery<TData>) {
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client.moduleId), () => client.config(), options);
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client._moduleAddress), () => client.config(), options);
}
export interface AutocompounderBatchUnbondMutation {
client: AutocompounderAppClient;
Expand Down
10 changes: 8 additions & 2 deletions __output__/abstract/apps/etf-prefix/Etf.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
import { StdFee, Coin } from "@cosmjs/amino";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
Expand Down Expand Up @@ -51,7 +51,13 @@ export class EtfTestQueryClient implements IEtfTestQueryClient {
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);

if (address === null) {
throw new Error(`Module ${this.moduleId} not installed`);
}

this._moduleAddress = address;
}

return this._moduleAddress!;
Expand Down
10 changes: 8 additions & 2 deletions __output__/abstract/apps/etf/Etf.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient } from "@abstract-money/abstract.js";
import { AbstractQueryClient, AbstractAccountQueryClient, AbstractAccountClient, AppExecuteMsg, AppExecuteMsgFactory, AbstractClient, AbstractAccountId } from "@abstract-money/abstract.js";
import { StdFee, Coin } from "@cosmjs/amino";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
Expand Down Expand Up @@ -51,7 +51,13 @@ export class EtfAppQueryClient implements IEtfAppQueryClient {
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
this._moduleAddress = await this.accountQueryClient.getModuleAddress(this.moduleId);
const address = await this.accountQueryClient.getModuleAddress(this.moduleId);

if (address === null) {
throw new Error(`Module ${this.moduleId} not installed`);
}

this._moduleAddress = address;
}

return this._moduleAddress!;
Expand Down
2 changes: 1 addition & 1 deletion __output__/abstract/apps/etf/Etf.react-query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export function useEtfStateQuery<TData = StateResponse>({
client,
options
}: EtfStateQuery<TData>) {
return useQuery<StateResponse, Error, TData>(etfQueryKeys.state(client.moduleId), () => client.state(), options);
return useQuery<StateResponse, Error, TData>(etfQueryKeys.state(client._moduleAddress), () => client.state(), options);
}
export interface EtfSetFeeMutation {
client: EtfAppClient;
Expand Down
4 changes: 2 additions & 2 deletions packages/ts-codegen/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/ts-codegen",
"version": "0.35.4",
"version": "0.35.5",
"description": "@cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code.",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/cosmwasm/ts-codegen",
Expand Down Expand Up @@ -101,6 +101,6 @@
"parse-package-name": "1.0.0",
"rimraf": "3.0.2",
"shelljs": "0.8.5",
"wasm-ast-types": "npm:@abstract-money/wasm-ast-types@0.26.3"
"wasm-ast-types": "npm:@abstract-money/wasm-ast-types@0.26.4"
}
}
2 changes: 1 addition & 1 deletion packages/wasm-ast-types/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@abstract-money/wasm-ast-types",
"version": "0.26.3",
"version": "0.26.4",
"description": "CosmWasm TypeScript AST generation",
"author": "Dan Lynch <pyramation@gmail.com>",
"homepage": "https://github.com/pyramation/cosmwasm-typescript-gen/tree/master/packages/wasm-ast-types#readme",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,51 @@ exports[`IAutocompounderAppQueryClient 1`] = `
getAddress: () => Promise<string>;
}"
`;

exports[`IbcMailClientAppClient 1`] = `
"export class IbcMailClientAppClient extends IbcMailClientAppQueryClient implements IIbcMailClientAppClient {
accountClient: AbstractAccountClient;

constructor({
abstractClient,
accountId,
managerAddress,
proxyAddress,
moduleId
}: {
abstractClient: AbstractClient;
accountId: AbstractAccountId;
managerAddress: string;
proxyAddress: string;
moduleId: string;
}) {
super({
abstractQueryClient: abstractClient,
accountId,
managerAddress,
proxyAddress,
moduleId
});
this.accountClient = AbstractAccountClient.fromQueryClient(this.accountQueryClient, abstractClient);
this.sendMessage = this.sendMessage.bind(this);
this.receiveMessage = this.receiveMessage.bind(this);
this.updateConfig = this.updateConfig.bind(this);
}

sendMessage = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
send_message: unknown;
}>[\\"send_message\\"]>, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(IbcMailClientExecuteMsgBuilder.sendMessage(params), fee, memo, _funds);
};
receiveMessage = async (message: Message, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(IbcMailClientExecuteMsgBuilder.receiveMessage(message), fee, memo, _funds);
};
updateConfig = async (fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(IbcMailClientExecuteMsgBuilder.updateConfig(), fee, memo, _funds);
};
_execute = async (msg: ExecuteMsg, fee: number | StdFee | \\"auto\\" = \\"auto\\", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return await this.accountClient.abstract.client.execute(this.accountClient.sender, await this.getAddress(), moduleMsg, fee, memo, _funds);
};
}"
`;
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,33 @@ exports[`etf 1`] = `
});"
`;

exports[`ibcmailClientQueryMsg 1`] = `
"export const ibcMailClientQueries = createQueryKeys(\\"IbcMailClient\\", {
listMessages: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {
list_messages: unknown;
}>[\\"list_messages\\"]>) => ({
queryKey: [{
address: queryClient.contractAddress
}, params],
queryFn: ctx => queryClient.listMessages(params)
}),
messages: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {
messages: unknown;
}>[\\"messages\\"]>) => ({
queryKey: [{
address: queryClient.contractAddress
}, params],
queryFn: ctx => queryClient.messages(params)
}),
config: (queryClient: AutocompounderQueryClient) => ({
queryKey: [{
address: queryClient.contractAddress
}],
queryFn: ctx => queryClient.config()
})
});"
`;

exports[`queryMsg 1`] = `
"export const contractQueries = createQueryKeys(\\"Contract\\", {
ownerOf: (queryClient: AutocompounderQueryClient, params: CamelCasedProperties<Extract<QueryMsg, {
Expand Down
24 changes: 20 additions & 4 deletions packages/wasm-ast-types/src/abstract-app/abstract-app.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import autocompounder_schema from '../../../../__fixtures__/abstract/apps/autocompounder.json';
import ibcmailclient_schema from '../../../../__fixtures__/abstract/apps/ibcmail/client.json';
import { expectCode, makeContext } from '../../test-utils';
import {
createAppExecuteClass,
Expand All @@ -8,7 +9,7 @@ import {
} from './abstract-app';

it('IAutocompounderAppQueryClient', () => {
const ctx = makeContext(autocompounder_schema);
const ctx = makeContext(autocompounder_schema.query);

expectCode(
createAppQueryInterface(
Expand All @@ -21,7 +22,7 @@ it('IAutocompounderAppQueryClient', () => {
});

it('AutocompounderAppQueryClient', () => {
const ctx = makeContext(autocompounder_schema);
const ctx = makeContext(autocompounder_schema.query);

expectCode(
createAppQueryClass(
Expand All @@ -35,7 +36,7 @@ it('AutocompounderAppQueryClient', () => {
});

it('IAutocompounderAppClient', () => {
const ctx = makeContext(autocompounder_schema);
const ctx = makeContext(autocompounder_schema.execute);

expectCode(
createAppExecuteInterface(
Expand All @@ -49,7 +50,7 @@ it('IAutocompounderAppClient', () => {
});

it('AutocompounderAppClient', () => {
const ctx = makeContext(autocompounder_schema);
const ctx = makeContext(autocompounder_schema.execute);

expectCode(
createAppExecuteClass(
Expand All @@ -62,3 +63,18 @@ it('AutocompounderAppClient', () => {
)
);
});

it('IbcMailClientAppClient', () => {
const ctx = makeContext(ibcmailclient_schema.execute);

expectCode(
createAppExecuteClass(
ctx,
'IbcMailClient',
'IbcMailClientAppClient',
'IIbcMailClientAppClient',
'IbcMailClientAppQueryClient',
ibcmailclient_schema.execute
)
);
});
Loading