Skip to content
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

for preview #149

Draft
wants to merge 45 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
28335f3
Initial abstract-app class
adairrr Apr 14, 2023
1b9cf55
Abstract App query interface
adairrr Apr 15, 2023
e380fee
Add query factory to abstract app
adairrr Apr 16, 2023
8f87074
Abstract app types
adairrr Apr 16, 2023
e7eaf04
Abstract app query clients
adairrr May 21, 2023
c926307
AppExecuteInterface
adairrr May 21, 2023
fe66c65
Missing extends in IAppClient
adairrr May 21, 2023
cbb72b9
Abstract app execute client
adairrr May 21, 2023
17557cb
App execute client
adairrr May 21, 2023
6ebed01
Lint the message composer
adairrr May 21, 2023
97d5ab0
Update message builder with abstract
adairrr May 21, 2023
67195cb
Merge 'main'
adairrr May 21, 2023
3777a4b
Clean up abstract app client
adairrr May 21, 2023
3172021
Merge branch 'underscoreFunds' into feature/abstractApp
adairrr May 21, 2023
a3a62aa
Merge branch 'underscoreFunds' into feature/abstractApp
adairrr May 21, 2023
c04b24c
Update react query generation with abstract app
adairrr May 21, 2023
22a40f1
Rely on msg builder for abstract-app
adairrr May 21, 2023
9880c32
Abstract app readme
adairrr May 21, 2023
814b353
Extract from execute msg in appclient
adairrr May 21, 2023
9d3e56b
Update ts-codegen tests
adairrr May 21, 2023
2898bf5
Union _moduleAddress with undefined
adairrr May 21, 2023
2d1640b
Add clientPrefix option to abstractApp
adairrr May 30, 2023
3dd3d78
Merge branch 'main' into feature/abstractApp
NoahSaso Jul 10, 2023
338bbed
Changed wasm-ast-types package name back to npm.
NoahSaso Jul 10, 2023
ea8122e
number to AbstractAccountId and update tests
adairrr Oct 11, 2023
7842b1d
Bump
adairrr Nov 11, 2023
d5d397f
Merge branch 'main' into feature/abstractAppNov
adairrr Nov 11, 2023
6423b12
Check module addresses
adairrr Nov 11, 2023
ca52b30
gst
adairrr May 20, 2024
5fd7a04
Ensure that parameters account for tuple variants
adairrr May 20, 2024
7cdde3a
Bump version
adairrr May 20, 2024
60c4f3b
Merge pull request #1 from AbstractSDK/adair/fixAppTuples
adairrr May 22, 2024
54e0933
Generate for adapters
adairrr May 29, 2024
737b7d2
Ensure factory
adairrr May 30, 2024
49ba363
Suffix fee, memo, and funds with underscores
adairrr Aug 15, 2024
24ceb85
Make beta
adairrr Aug 15, 2024
a8d89f7
Merge pull request #3 from AbstractSDK/adair/memoFix
adairrr Oct 7, 2024
bd631f1
Merge pull request #2 from AbstractSDK/adair/generateForAdapters
adairrr Oct 7, 2024
7655135
Merge pull request #4 from AbstractSDK/adair/memoFix
adairrr Oct 7, 2024
3b8730c
Abstract 2.0 generation
adairrr Oct 11, 2024
692671d
Update specs
adairrr Oct 11, 2024
740649c
Update ts-codegen snaps
adairrr Oct 11, 2024
2062d7f
Match ts-codegen version
adairrr Oct 11, 2024
4cecf93
Publish
adairrr Oct 11, 2024
a47bc0f
Merge pull request #5 from AbstractSDK/adair/abstract2.0
adairrr Oct 11, 2024
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
Prev Previous commit
Next Next commit
Update ts-codegen snaps
adairrr committed Oct 11, 2024
commit 740649c4f2255bb937ed8f7bcfc9505e92c7dc5e
258 changes: 115 additions & 143 deletions __output__/abstract/apps/autocompounder/Autocompounder.client.ts
Original file line number Diff line number Diff line change
@@ -4,44 +4,47 @@
* and run the @abstract-money/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AccountPublicClient, AccountWalletClient, AppExecuteMsg, AppExecuteMsgFactory, AdapterExecuteMsg, AdapterExecuteMsgFactory } from "@abstract-money/core";
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";
export interface AutocompounderReadOnlyInterface {
contractAddress: string;
import { AutocompounderQueryMsgBuilder, AutocompounderExecuteMsgBuilder } from "./Autocompounder.message-builder";
export interface IAutocompounderAppQueryClient {
moduleId: string;
accountPublicClient: AccountPublicClient;
_moduleAddress: string | undefined;
config: () => Promise<Config>;
pendingClaims: ({
address
}: {
address: string;
}) => Promise<Uint128>;
claims: ({
address
}: {
address: string;
}) => Promise<ArrayOfClaim>;
allClaims: ({
limit,
startAfter
}: {
limit?: number;
startAfter?: string;
}) => Promise<ArrayOfTupleOfStringAndArrayOfClaim>;
pendingClaims: (params: CamelCasedProperties<Extract<QueryMsg, {
pending_claims: unknown;
}>["pending_claims"]>) => Promise<Uint128>;
claims: (params: CamelCasedProperties<Extract<QueryMsg, {
claims: unknown;
}>["claims"]>) => Promise<ArrayOfClaim>;
allClaims: (params: CamelCasedProperties<Extract<QueryMsg, {
all_claims: unknown;
}>["all_claims"]>) => Promise<ArrayOfTupleOfStringAndArrayOfClaim>;
latestUnbonding: () => Promise<Expiration>;
totalLpPosition: () => Promise<Uint128>;
balance: ({
address
}: {
address: string;
}) => Promise<Uint128>;
balance: (params: CamelCasedProperties<Extract<QueryMsg, {
balance: unknown;
}>["balance"]>) => Promise<Uint128>;
getAddress: () => Promise<string>;
}
export class AutocompounderQueryClient implements AutocompounderReadOnlyInterface {
client: CosmWasmClient;
contractAddress: string;
export class AutocompounderAppQueryClient implements IAutocompounderAppQueryClient {
accountPublicClient: AccountPublicClient;
moduleId: string;
_moduleAddress: string | undefined;

constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
moduleId: string;
}) {
this.accountPublicClient = accountPublicClient;
this.moduleId = moduleId;
this.config = this.config.bind(this);
this.pendingClaims = this.pendingClaims.bind(this);
this.claims = this.claims.bind(this);
@@ -52,147 +55,116 @@ export class AutocompounderQueryClient implements AutocompounderReadOnlyInterfac
}

config = async (): Promise<Config> => {
return this.client.queryContractSmart(this.contractAddress, {
config: {}
});
return this._query(AutocompounderQueryMsgBuilder.config());
};
pendingClaims = async ({
address
}: {
address: string;
}): Promise<Uint128> => {
return this.client.queryContractSmart(this.contractAddress, {
pending_claims: {
address
}
});
pendingClaims = async (params: CamelCasedProperties<Extract<QueryMsg, {
pending_claims: unknown;
}>["pending_claims"]>): Promise<Uint128> => {
return this._query(AutocompounderQueryMsgBuilder.pendingClaims(params));
};
claims = async ({
address
}: {
address: string;
}): Promise<ArrayOfClaim> => {
return this.client.queryContractSmart(this.contractAddress, {
claims: {
address
}
});
claims = async (params: CamelCasedProperties<Extract<QueryMsg, {
claims: unknown;
}>["claims"]>): Promise<ArrayOfClaim> => {
return this._query(AutocompounderQueryMsgBuilder.claims(params));
};
allClaims = async ({
limit,
startAfter
}: {
limit?: number;
startAfter?: string;
}): Promise<ArrayOfTupleOfStringAndArrayOfClaim> => {
return this.client.queryContractSmart(this.contractAddress, {
all_claims: {
limit,
start_after: startAfter
}
});
allClaims = async (params: CamelCasedProperties<Extract<QueryMsg, {
all_claims: unknown;
}>["all_claims"]>): Promise<ArrayOfTupleOfStringAndArrayOfClaim> => {
return this._query(AutocompounderQueryMsgBuilder.allClaims(params));
};
latestUnbonding = async (): Promise<Expiration> => {
return this.client.queryContractSmart(this.contractAddress, {
latest_unbonding: {}
});
return this._query(AutocompounderQueryMsgBuilder.latestUnbonding());
};
totalLpPosition = async (): Promise<Uint128> => {
return this.client.queryContractSmart(this.contractAddress, {
total_lp_position: {}
});
return this._query(AutocompounderQueryMsgBuilder.totalLpPosition());
};
balance = async ({
address
}: {
address: string;
}): Promise<Uint128> => {
return this.client.queryContractSmart(this.contractAddress, {
balance: {
address
balance = async (params: CamelCasedProperties<Extract<QueryMsg, {
balance: unknown;
}>["balance"]>): Promise<Uint128> => {
return this._query(AutocompounderQueryMsgBuilder.balance(params));
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
const address = await this.accountPublicClient.getModuleAddress({
id: this.moduleId
});

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

this._moduleAddress = address;
}

return this._moduleAddress!;
};
_query = async (queryMsg: QueryMsg): Promise<any> => {
return this.accountPublicClient.queryModule({
moduleId: this.moduleId,
moduleType: "app",
queryMsg
});
};
}
export interface AutocompounderInterface extends AutocompounderReadOnlyInterface {
contractAddress: string;
sender: string;
updateFeeConfig: ({
deposit,
performance,
withdrawal
}: {
deposit?: Decimal;
performance?: Decimal;
withdrawal?: Decimal;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
deposit: ({
funds
}: {
funds: AnsAsset[];
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
export interface IAutocompounderAppClient extends IAutocompounderAppQueryClient {
accountWalletClient: AccountWalletClient;
updateFeeConfig: (params: CamelCasedProperties<Extract<ExecuteMsg, {
update_fee_config: unknown;
}>["update_fee_config"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
deposit: (params: CamelCasedProperties<Extract<ExecuteMsg, {
deposit: unknown;
}>["deposit"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
withdraw: (fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
compound: (fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
batchUnbond: (fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class AutocompounderClient extends AutocompounderQueryClient implements AutocompounderInterface {
client: SigningCosmWasmClient;
sender: string;
contractAddress: string;
export class AutocompounderAppClient extends AutocompounderAppQueryClient implements IAutocompounderAppClient {
accountWalletClient: AccountWalletClient;

constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
super(client, contractAddress);
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
accountWalletClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
accountWalletClient: AccountWalletClient;
moduleId: string;
}) {
super({
accountPublicClient,
moduleId
});
this.accountWalletClient = accountWalletClient;
this.updateFeeConfig = this.updateFeeConfig.bind(this);
this.deposit = this.deposit.bind(this);
this.withdraw = this.withdraw.bind(this);
this.compound = this.compound.bind(this);
this.batchUnbond = this.batchUnbond.bind(this);
}

updateFeeConfig = async ({
deposit,
performance,
withdrawal
}: {
deposit?: Decimal;
performance?: Decimal;
withdrawal?: Decimal;
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
update_fee_config: {
deposit,
performance,
withdrawal
}
}, fee_, memo_, funds_);
updateFeeConfig = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
update_fee_config: unknown;
}>["update_fee_config"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(AutocompounderExecuteMsgBuilder.updateFeeConfig(params), fee_, memo_, funds_);
};
deposit = async ({
funds
}: {
funds: AnsAsset[];
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
deposit: {
funds
}
}, fee_, memo_, funds_);
deposit = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
deposit: unknown;
}>["deposit"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(AutocompounderExecuteMsgBuilder.deposit(params), fee_, memo_, funds_);
};
withdraw = async (fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
withdraw: {}
}, fee_, memo_, funds_);
return this._execute(AutocompounderExecuteMsgBuilder.withdraw(), fee_, memo_, funds_);
};
compound = async (fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
compound: {}
}, fee_, memo_, funds_);
return this._execute(AutocompounderExecuteMsgBuilder.compound(), fee_, memo_, funds_);
};
batchUnbond = async (fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
batch_unbond: {}
}, fee_, memo_, funds_);
return this._execute(AutocompounderExecuteMsgBuilder.batchUnbond(), fee_, memo_, funds_);
};
_execute = async (msg: ExecuteMsg, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
const signingCwClient = await this.accountWalletClient.getSigningCosmWasmClient();
const sender = await this.accountWalletClient.getSenderAddress();
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return await signingCwClient.execute(sender, await this.getAddress(), moduleMsg, fee_, memo_, funds_);
};
}
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ 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 { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/abstract.js";
import { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/core";
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";
export interface AutocompounderMsg {
contractAddress: string;
@@ -21,15 +21,15 @@ export interface AutocompounderMsg {
deposit?: Decimal;
performance?: Decimal;
withdrawal?: Decimal;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
deposit: ({
funds
}: {
funds: AnsAsset[];
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
withdraw: (_funds?: Coin[]) => MsgExecuteContractEncodeObject;
compound: (_funds?: Coin[]) => MsgExecuteContractEncodeObject;
batchUnbond: (_funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
withdraw: (funds_?: Coin[]) => MsgExecuteContractEncodeObject;
compound: (funds_?: Coin[]) => MsgExecuteContractEncodeObject;
batchUnbond: (funds_?: Coin[]) => MsgExecuteContractEncodeObject;
}
export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: string;
@@ -53,7 +53,7 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
deposit?: Decimal;
performance?: Decimal;
withdrawal?: Decimal;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
update_fee_config: {
deposit,
@@ -68,15 +68,15 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
deposit = ({
funds
}: {
funds: AnsAsset[];
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
deposit: {
funds
@@ -89,11 +89,11 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
withdraw = (_funds?: Coin[]): MsgExecuteContractEncodeObject => {
withdraw = (funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
withdraw: {}
};
@@ -104,11 +104,11 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
compound = (_funds?: Coin[]): MsgExecuteContractEncodeObject => {
compound = (funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
compound: {}
};
@@ -119,11 +119,11 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
batchUnbond = (_funds?: Coin[]): MsgExecuteContractEncodeObject => {
batchUnbond = (funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
batch_unbond: {}
};
@@ -134,7 +134,7 @@ export class AutocompounderMsgComposer implements AutocompounderMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
137 changes: 83 additions & 54 deletions __output__/abstract/apps/etf-prefix/Etf.client.ts
Original file line number Diff line number Diff line change
@@ -4,77 +4,106 @@
* and run the @abstract-money/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AccountPublicClient, AccountWalletClient, AppExecuteMsg, AppExecuteMsgFactory, AdapterExecuteMsg, AdapterExecuteMsgFactory } from "@abstract-money/core";
import { StdFee, Coin } from "@cosmjs/amino";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
export interface EtfReadOnlyInterface {
contractAddress: string;
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
export interface IEtfTestQueryClient {
moduleId: string;
accountPublicClient: AccountPublicClient;
_moduleAddress: string | undefined;
state: () => Promise<StateResponse>;
getAddress: () => Promise<string>;
}
export class EtfQueryClient implements EtfReadOnlyInterface {
client: CosmWasmClient;
contractAddress: string;
export class EtfTestQueryClient implements IEtfTestQueryClient {
accountPublicClient: AccountPublicClient;
moduleId: string;
_moduleAddress: string | undefined;

constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
moduleId: string;
}) {
this.accountPublicClient = accountPublicClient;
this.moduleId = moduleId;
this.state = this.state.bind(this);
}

state = async (): Promise<StateResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
state: {}
return this._query(EtfQueryMsgBuilder.state());
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
const address = await this.accountPublicClient.getModuleAddress({
id: this.moduleId
});

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

this._moduleAddress = address;
}

return this._moduleAddress!;
};
_query = async (queryMsg: QueryMsg): Promise<any> => {
return this.accountPublicClient.queryModule({
moduleId: this.moduleId,
moduleType: "app",
queryMsg
});
};
}
export interface EtfInterface extends EtfReadOnlyInterface {
contractAddress: string;
sender: string;
provideLiquidity: ({
asset
}: {
asset: AssetBaseForString;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
setFee: ({
fee
}: {
fee: Decimal;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
export interface IEtfTestClient extends IEtfTestQueryClient {
accountWalletClient: AccountWalletClient;
provideLiquidity: (params: CamelCasedProperties<Extract<ExecuteMsg, {
provide_liquidity: unknown;
}>["provide_liquidity"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
setFee: (params: CamelCasedProperties<Extract<ExecuteMsg, {
set_fee: unknown;
}>["set_fee"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class EtfClient extends EtfQueryClient implements EtfInterface {
client: SigningCosmWasmClient;
sender: string;
contractAddress: string;
export class EtfTestClient extends EtfTestQueryClient implements IEtfTestClient {
accountWalletClient: AccountWalletClient;

constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
super(client, contractAddress);
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
accountWalletClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
accountWalletClient: AccountWalletClient;
moduleId: string;
}) {
super({
accountPublicClient,
moduleId
});
this.accountWalletClient = accountWalletClient;
this.provideLiquidity = this.provideLiquidity.bind(this);
this.setFee = this.setFee.bind(this);
}

provideLiquidity = async ({
asset
}: {
asset: AssetBaseForString;
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
provide_liquidity: {
asset
}
}, fee_, memo_, funds_);
provideLiquidity = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
provide_liquidity: unknown;
}>["provide_liquidity"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(EtfExecuteMsgBuilder.provideLiquidity(params), fee_, memo_, funds_);
};
setFee = async ({
fee
}: {
fee: Decimal;
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
set_fee: {
fee
}
}, fee_, memo_, funds_);
setFee = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
set_fee: unknown;
}>["set_fee"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(EtfExecuteMsgBuilder.setFee(params), fee_, memo_, funds_);
};
_execute = async (msg: ExecuteMsg, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
const signingCwClient = await this.accountWalletClient.getSigningCosmWasmClient();
const sender = await this.accountWalletClient.getSenderAddress();
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return await signingCwClient.execute(sender, await this.getAddress(), moduleMsg, fee_, memo_, funds_);
};
}
14 changes: 7 additions & 7 deletions __output__/abstract/apps/etf-prefix/Etf.message-composer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ 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 { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/abstract.js";
import { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/core";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
export interface EtfMsg {
contractAddress: string;
@@ -17,12 +17,12 @@ export interface EtfMsg {
asset
}: {
asset: AssetBaseForString;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
setFee: ({
fee
}: {
fee: Decimal;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
}
export class EtfMsgComposer implements EtfMsg {
sender: string;
@@ -39,7 +39,7 @@ export class EtfMsgComposer implements EtfMsg {
asset
}: {
asset: AssetBaseForString;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
provide_liquidity: {
asset
@@ -52,15 +52,15 @@ export class EtfMsgComposer implements EtfMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
setFee = ({
fee
}: {
fee: Decimal;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
set_fee: {
fee
@@ -73,7 +73,7 @@ export class EtfMsgComposer implements EtfMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
137 changes: 83 additions & 54 deletions __output__/abstract/apps/etf/Etf.client.ts
Original file line number Diff line number Diff line change
@@ -4,77 +4,106 @@
* and run the @abstract-money/ts-codegen generate command to regenerate this file.
*/

import { CosmWasmClient, SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { Coin, StdFee } from "@cosmjs/amino";
import { CamelCasedProperties } from "type-fest";
import { SigningCosmWasmClient, ExecuteResult } from "@cosmjs/cosmwasm-stargate";
import { AccountPublicClient, AccountWalletClient, AppExecuteMsg, AppExecuteMsgFactory, AdapterExecuteMsg, AdapterExecuteMsgFactory } from "@abstract-money/core";
import { StdFee, Coin } from "@cosmjs/amino";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
export interface EtfReadOnlyInterface {
contractAddress: string;
import { EtfQueryMsgBuilder, EtfExecuteMsgBuilder } from "./Etf.message-builder";
export interface IEtfAppQueryClient {
moduleId: string;
accountPublicClient: AccountPublicClient;
_moduleAddress: string | undefined;
state: () => Promise<StateResponse>;
getAddress: () => Promise<string>;
}
export class EtfQueryClient implements EtfReadOnlyInterface {
client: CosmWasmClient;
contractAddress: string;
export class EtfAppQueryClient implements IEtfAppQueryClient {
accountPublicClient: AccountPublicClient;
moduleId: string;
_moduleAddress: string | undefined;

constructor(client: CosmWasmClient, contractAddress: string) {
this.client = client;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
moduleId: string;
}) {
this.accountPublicClient = accountPublicClient;
this.moduleId = moduleId;
this.state = this.state.bind(this);
}

state = async (): Promise<StateResponse> => {
return this.client.queryContractSmart(this.contractAddress, {
state: {}
return this._query(EtfQueryMsgBuilder.state());
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
const address = await this.accountPublicClient.getModuleAddress({
id: this.moduleId
});

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

this._moduleAddress = address;
}

return this._moduleAddress!;
};
_query = async (queryMsg: QueryMsg): Promise<any> => {
return this.accountPublicClient.queryModule({
moduleId: this.moduleId,
moduleType: "app",
queryMsg
});
};
}
export interface EtfInterface extends EtfReadOnlyInterface {
contractAddress: string;
sender: string;
provideLiquidity: ({
asset
}: {
asset: AssetBaseForString;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
setFee: ({
fee
}: {
fee: Decimal;
}, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
export interface IEtfAppClient extends IEtfAppQueryClient {
accountWalletClient: AccountWalletClient;
provideLiquidity: (params: CamelCasedProperties<Extract<ExecuteMsg, {
provide_liquidity: unknown;
}>["provide_liquidity"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
setFee: (params: CamelCasedProperties<Extract<ExecuteMsg, {
set_fee: unknown;
}>["set_fee"]>, fee_?: number | StdFee | "auto", memo_?: string, funds_?: Coin[]) => Promise<ExecuteResult>;
}
export class EtfClient extends EtfQueryClient implements EtfInterface {
client: SigningCosmWasmClient;
sender: string;
contractAddress: string;
export class EtfAppClient extends EtfAppQueryClient implements IEtfAppClient {
accountWalletClient: AccountWalletClient;

constructor(client: SigningCosmWasmClient, sender: string, contractAddress: string) {
super(client, contractAddress);
this.client = client;
this.sender = sender;
this.contractAddress = contractAddress;
constructor({
accountPublicClient,
accountWalletClient,
moduleId
}: {
accountPublicClient: AccountPublicClient;
accountWalletClient: AccountWalletClient;
moduleId: string;
}) {
super({
accountPublicClient,
moduleId
});
this.accountWalletClient = accountWalletClient;
this.provideLiquidity = this.provideLiquidity.bind(this);
this.setFee = this.setFee.bind(this);
}

provideLiquidity = async ({
asset
}: {
asset: AssetBaseForString;
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
provide_liquidity: {
asset
}
}, fee_, memo_, funds_);
provideLiquidity = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
provide_liquidity: unknown;
}>["provide_liquidity"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(EtfExecuteMsgBuilder.provideLiquidity(params), fee_, memo_, funds_);
};
setFee = async ({
fee
}: {
fee: Decimal;
}, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return await this.client.execute(this.sender, this.contractAddress, {
set_fee: {
fee
}
}, fee_, memo_, funds_);
setFee = async (params: CamelCasedProperties<Extract<ExecuteMsg, {
set_fee: unknown;
}>["set_fee"]>, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
return this._execute(EtfExecuteMsgBuilder.setFee(params), fee_, memo_, funds_);
};
_execute = async (msg: ExecuteMsg, fee_: number | StdFee | "auto" = "auto", memo_?: string, funds_?: Coin[]): Promise<ExecuteResult> => {
const signingCwClient = await this.accountWalletClient.getSigningCosmWasmClient();
const sender = await this.accountWalletClient.getSenderAddress();
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return await signingCwClient.execute(sender, await this.getAddress(), moduleMsg, fee_, memo_, funds_);
};
}
14 changes: 7 additions & 7 deletions __output__/abstract/apps/etf/Etf.message-composer.ts
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ 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 { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/abstract.js";
import { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/core";
import { Decimal, InstantiateMsg, ExecuteMsg, Uint128, AssetInfoBaseForString, AssetBaseForString, QueryMsg, MigrateMsg, StateResponse } from "./Etf.types";
export interface EtfMsg {
contractAddress: string;
@@ -17,12 +17,12 @@ export interface EtfMsg {
asset
}: {
asset: AssetBaseForString;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
setFee: ({
fee
}: {
fee: Decimal;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
}, funds_?: Coin[]) => MsgExecuteContractEncodeObject;
}
export class EtfMsgComposer implements EtfMsg {
sender: string;
@@ -39,7 +39,7 @@ export class EtfMsgComposer implements EtfMsg {
asset
}: {
asset: AssetBaseForString;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
provide_liquidity: {
asset
@@ -52,15 +52,15 @@ export class EtfMsgComposer implements EtfMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
setFee = ({
fee
}: {
fee: Decimal;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
}, funds_?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
set_fee: {
fee
@@ -73,7 +73,7 @@ export class EtfMsgComposer implements EtfMsg {
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
funds: funds_
})
};
};
18 changes: 18 additions & 0 deletions packages/ts-codegen/__tests__/__snapshots__/builder.test.ts.snap
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -52,6 +53,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -95,6 +97,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -138,6 +141,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -181,6 +185,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -224,6 +229,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -267,6 +273,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -312,6 +319,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -355,6 +363,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -410,6 +419,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -452,6 +462,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -495,6 +506,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -538,6 +550,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -581,6 +594,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -624,6 +638,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -667,6 +682,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -712,6 +728,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
@@ -755,6 +772,7 @@ TSBuilder {
"abstractApp": Object {
"clientPrefix": "App",
"enabled": false,
"moduleType": "app",
},
"bundle": Object {
"bundleFile": "bundle.ts",
2 changes: 1 addition & 1 deletion packages/ts-codegen/package.json
Original file line number Diff line number Diff line change
@@ -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.28.0-beta-2"
"wasm-ast-types": "file:../wasm-ast-types"
}
}