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

Abstract App Module Plugin #112

Draft
wants to merge 25 commits into
base: main
Choose a base branch
from
Draft
Changes from 1 commit
Commits
Show all changes
25 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
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 react query generation with abstract app
adairrr committed May 21, 2023
commit c04b24c93953262043c3476f6ea21c6af46b9bf1
Original file line number Diff line number Diff line change
@@ -11,7 +11,6 @@ import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
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 { AutocompounderQueryClient, AutocompounderClient } from "./Autocompounder.client";
import { AutocompounderQueryMsgBuilder, AutocompounderExecuteMsgBuilder } from "./Autocompounder.msg-builder";
export interface IAutocompounderAppQueryClient {
moduleId: string;
Original file line number Diff line number Diff line change
@@ -8,7 +8,7 @@ import { UseQueryOptions, useQuery, useMutation, UseMutationOptions } from "@tan
import { ExecuteResult } from "@cosmjs/cosmwasm-stargate";
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 { AutocompounderQueryClient, AutocompounderClient } from "./Autocompounder.client";
import { AutocompounderAppQueryClient, AutocompounderAppClient } from "./Autocompounder.app-client";
export const autocompounderQueryKeys = {
contract: ([{
contract: "autocompounder"
@@ -50,7 +50,7 @@ export const autocompounderQueries = {
client,
options
}: AutocompounderConfigQuery<TData>): UseQueryOptions<Config, Error, TData> => ({
queryKey: autocompounderQueryKeys.config(client?.contractAddress),
queryKey: autocompounderQueryKeys.config(client?.moduleId),
queryFn: () => client.config(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
@@ -60,7 +60,7 @@ export const autocompounderQueries = {
args,
options
}: AutocompounderPendingClaimsQuery<TData>): UseQueryOptions<Uint128, Error, TData> => ({
queryKey: autocompounderQueryKeys.pendingClaims(client?.contractAddress, args),
queryKey: autocompounderQueryKeys.pendingClaims(client?.moduleId, args),
queryFn: () => client.pendingClaims({
address: args.address
}),
@@ -72,7 +72,7 @@ export const autocompounderQueries = {
args,
options
}: AutocompounderClaimsQuery<TData>): UseQueryOptions<ArrayOfClaim, Error, TData> => ({
queryKey: autocompounderQueryKeys.claims(client?.contractAddress, args),
queryKey: autocompounderQueryKeys.claims(client?.moduleId, args),
queryFn: () => client.claims({
address: args.address
}),
@@ -84,7 +84,7 @@ export const autocompounderQueries = {
args,
options
}: AutocompounderAllClaimsQuery<TData>): UseQueryOptions<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData> => ({
queryKey: autocompounderQueryKeys.allClaims(client?.contractAddress, args),
queryKey: autocompounderQueryKeys.allClaims(client?.moduleId, args),
queryFn: () => client.allClaims({
limit: args.limit,
startAfter: args.startAfter
@@ -96,7 +96,7 @@ export const autocompounderQueries = {
client,
options
}: AutocompounderLatestUnbondingQuery<TData>): UseQueryOptions<Expiration, Error, TData> => ({
queryKey: autocompounderQueryKeys.latestUnbonding(client?.contractAddress),
queryKey: autocompounderQueryKeys.latestUnbonding(client?.moduleId),
queryFn: () => client.latestUnbonding(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
@@ -105,7 +105,7 @@ export const autocompounderQueries = {
client,
options
}: AutocompounderTotalLpPositionQuery<TData>): UseQueryOptions<Uint128, Error, TData> => ({
queryKey: autocompounderQueryKeys.totalLpPosition(client?.contractAddress),
queryKey: autocompounderQueryKeys.totalLpPosition(client?.moduleId),
queryFn: () => client.totalLpPosition(),
...options,
enabled: !!client && (options?.enabled != undefined ? options.enabled : true)
@@ -115,7 +115,7 @@ export const autocompounderQueries = {
args,
options
}: AutocompounderBalanceQuery<TData>): UseQueryOptions<Uint128, Error, TData> => ({
queryKey: autocompounderQueryKeys.balance(client?.contractAddress, args),
queryKey: autocompounderQueryKeys.balance(client?.moduleId, args),
queryFn: () => client.balance({
address: args.address
}),
@@ -124,7 +124,7 @@ export const autocompounderQueries = {
})
};
export interface AutocompounderReactQuery<TResponse, TData = TResponse> {
client: AutocompounderQueryClient;
client: AutocompounderAppQueryClient;
options?: Omit<UseQueryOptions<TResponse, Error, TData>, "'queryKey' | 'queryFn' | 'initialData'"> & {
initialData?: undefined;
};
@@ -139,7 +139,7 @@ export function useAutocompounderBalanceQuery<TData = Uint128>({
args,
options
}: AutocompounderBalanceQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client.contractAddress, args), () => client.balance({
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.balance(client.moduleId, args), () => client.balance({
address: args.address
}), options);
}
@@ -148,14 +148,14 @@ export function useAutocompounderTotalLpPositionQuery<TData = Uint128>({
client,
options
}: AutocompounderTotalLpPositionQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client.contractAddress), () => client.totalLpPosition(), options);
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.totalLpPosition(client.moduleId), () => 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.contractAddress), () => client.latestUnbonding(), options);
return useQuery<Expiration, Error, TData>(autocompounderQueryKeys.latestUnbonding(client.moduleId), () => client.latestUnbonding(), options);
}
export interface AutocompounderAllClaimsQuery<TData> extends AutocompounderReactQuery<ArrayOfTupleOfStringAndArrayOfClaim, TData> {
args: {
@@ -168,7 +168,7 @@ export function useAutocompounderAllClaimsQuery<TData = ArrayOfTupleOfStringAndA
args,
options
}: AutocompounderAllClaimsQuery<TData>) {
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client.contractAddress, args), () => client.allClaims({
return useQuery<ArrayOfTupleOfStringAndArrayOfClaim, Error, TData>(autocompounderQueryKeys.allClaims(client.moduleId, args), () => client.allClaims({
limit: args.limit,
startAfter: args.startAfter
}), options);
@@ -183,7 +183,7 @@ export function useAutocompounderClaimsQuery<TData = ArrayOfClaim>({
args,
options
}: AutocompounderClaimsQuery<TData>) {
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client.contractAddress, args), () => client.claims({
return useQuery<ArrayOfClaim, Error, TData>(autocompounderQueryKeys.claims(client.moduleId, args), () => client.claims({
address: args.address
}), options);
}
@@ -197,7 +197,7 @@ export function useAutocompounderPendingClaimsQuery<TData = Uint128>({
args,
options
}: AutocompounderPendingClaimsQuery<TData>) {
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client.contractAddress, args), () => client.pendingClaims({
return useQuery<Uint128, Error, TData>(autocompounderQueryKeys.pendingClaims(client.moduleId, args), () => client.pendingClaims({
address: args.address
}), options);
}
@@ -206,10 +206,10 @@ export function useAutocompounderConfigQuery<TData = Config>({
client,
options
}: AutocompounderConfigQuery<TData>) {
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client.contractAddress), () => client.config(), options);
return useQuery<Config, Error, TData>(autocompounderQueryKeys.config(client.moduleId), () => client.config(), options);
}
export interface AutocompounderBatchUnbondMutation {
client: AutocompounderClient;
client: AutocompounderAppClient;
args?: {
fee?: number | StdFee | "auto";
memo?: string;
@@ -222,12 +222,12 @@ export function useAutocompounderBatchUnbondMutation(options?: Omit<UseMutationO
args: {
fee,
memo,
_funds
funds
} = {}
}) => client.batchUnbond(fee, memo, _funds), options);
}) => client.batchUnbond(fee, memo, funds), options);
}
export interface AutocompounderCompoundMutation {
client: AutocompounderClient;
client: AutocompounderAppClient;
args?: {
fee?: number | StdFee | "auto";
memo?: string;
@@ -240,12 +240,12 @@ export function useAutocompounderCompoundMutation(options?: Omit<UseMutationOpti
args: {
fee,
memo,
_funds
funds
} = {}
}) => client.compound(fee, memo, _funds), options);
}) => client.compound(fee, memo, funds), options);
}
export interface AutocompounderWithdrawMutation {
client: AutocompounderClient;
client: AutocompounderAppClient;
args?: {
fee?: number | StdFee | "auto";
memo?: string;
@@ -258,12 +258,12 @@ export function useAutocompounderWithdrawMutation(options?: Omit<UseMutationOpti
args: {
fee,
memo,
_funds
funds
} = {}
}) => client.withdraw(fee, memo, _funds), options);
}) => client.withdraw(fee, memo, funds), options);
}
export interface AutocompounderDepositMutation {
client: AutocompounderClient;
client: AutocompounderAppClient;
msg: {
funds: AnsAsset[];
};
@@ -280,12 +280,12 @@ export function useAutocompounderDepositMutation(options?: Omit<UseMutationOptio
args: {
fee,
memo,
_funds
funds
} = {}
}) => client.deposit(msg, fee, memo, _funds), options);
}) => client.deposit(msg, fee, memo, funds), options);
}
export interface AutocompounderUpdateFeeConfigMutation {
client: AutocompounderClient;
client: AutocompounderAppClient;
msg: {
deposit?: Decimal;
performance?: Decimal;
@@ -304,7 +304,7 @@ export function useAutocompounderUpdateFeeConfigMutation(options?: Omit<UseMutat
args: {
fee,
memo,
_funds
funds
} = {}
}) => client.updateFeeConfig(msg, fee, memo, _funds), options);
}) => client.updateFeeConfig(msg, fee, memo, funds), options);
}
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -14,6 +14,8 @@
"test": "lerna run test --stream"
},
"devDependencies": {
"@tanstack/react-query": "4.19.1",
"type-fest": "^3.11.0",
"@babel/cli": "7.18.10",
"@babel/core": "7.18.10",
"@babel/eslint-parser": "^7.18.9",
3 changes: 0 additions & 3 deletions packages/ts-codegen/__tests__/ts-codegen.test.ts
Original file line number Diff line number Diff line change
@@ -314,9 +314,6 @@ it('abstract-app/autocompounder', async () => {
queryKeys: true,
mutations: true,
},
client: {
enabled: true
},
messageComposer: {
enabled: true
},
12 changes: 6 additions & 6 deletions packages/ts-codegen/src/commands/generate.ts
Original file line number Diff line number Diff line change
@@ -32,7 +32,9 @@ export default async (argv) => {
'client',
'recoil',
'react-query',
'message-composer'
'message-composer',
'msg-builder',
'abstract-app'
]
},
{
@@ -98,7 +100,7 @@ export default async (argv) => {
{
type: 'confirm',
name: 'queryFactory',
message: 'queryFactory? ',
message: 'queryFactory?',
default: false
}
])
@@ -135,8 +137,8 @@ export default async (argv) => {
enabled:
plugin.includes('client') ||
plugin.includes('recoil') ||
plugin.includes('react-query') ||
plugin.includes('abstract-app')
// react-query either uses client or abstract-app
(plugin.includes('react-query') && !plugin.includes('abstract-app'))
},
reactQuery: {
enabled: plugin.includes('react-query'),
@@ -162,8 +164,6 @@ export default async (argv) => {
},
abstractApp: {
enabled: plugin.includes('abstract-app'),
// TODO - add this to the questions
queryFactory: true
}
};

2 changes: 0 additions & 2 deletions packages/ts-codegen/src/generators/abstract-app.ts
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ export default async (
const options = context.options.abstractApp;

const localname = pascal(`${contractName}`) + '.app-client.ts';
const ContractFile = pascal(`${contractName}`) + '.client';
const MsgBuilderFile = pascal(`${contractName}`) + '.msg-builder';
const TypesFile = pascal(`${contractName}`) + '.types';

@@ -64,7 +63,6 @@ export default async (
body.push(w.importStmt(Object.keys(typeHash), `./${TypesFile}`));

// client imports
body.push(w.importStmt(clientImports, `./${ContractFile}`));
body.push(w.importStmt(msgBuilderImports, `./${MsgBuilderFile}`));
context.addUtil('CamelCasedProperties');

Loading