Skip to content

Commit

Permalink
Re-add typescript logic to template (#95)
Browse files Browse the repository at this point in the history
* fix state path

* add local state to gitignore

* update abstract

* update documentation in deploy script

* update readme

* use new account id query

* add comment

* add wasm just action

* commit wasms

* fix adapter wasming

* bump versions

* re-compile wasms

* rename template message generation

* update app template to 0.17

* update wasms

* formatting

* wasms

* Fix publish-schemas

* formatting

* recompile all

* clean up testing logic

* Publish to proper schemas dir

* Publish 0.17.1

* Bump to 0.17.2

* osmosis cw-staking fix

* bump to 0.18

* rebuild wasms

* Update wasms

* bump cw-orch to 0.15

* formatting

* undo cw-orch bump to template

* rebuilt wasms new weird error

* Apps schema updates (#20)

* bump version

* updated schemas

* fix publish-schema script

* rebuild wasms

* fix docs

* aftermerge fixes

* update wasms

* Update optimizer and add wasms to gitattributes (#56)

* update optimizer version

* add wasms to top-level git attributes as binaries.

* update the wasms

* remove template_app wasm

* Add/circle ci (#62)

* add circe-ci config

* run tickle on push for testing

* add remote docker setup

* add wasm-all-ci

* add scripts to volume

* commit lock file

* Update WASM artifacts [skip ci]

* try copy content of artifacts folder

* remove all artifacts and re-run

* Update WASM artifacts [skip ci]

* add comments on tickle job

* remove use of `just` and wasm modules as well

* attempt to fix modules build

* Update WASM artifacts for $GHA_Event [skip ci]

* use pwd dirname for cp command

* fix typo

* add integrations and framework mounts

* Update WASM artifacts for $GHA_Event [skip ci]

* add debugging

* remove container before mounting to ensure its fresh

* restructure container mounting

* print root dir

* fix

* cp to root of container

* Update WASM artifacts for $GHA_Event [skip ci]

* re-enable framework builds

* allow manual trigger of wasm builds

* update name of ci job

* add coverage build for modules

* formatting

* do changes in modules dir

* update coverage trigger

* update equal statement

* update url for coverage trigger

* use gh-action meta instead of event

* add gha_meta parameter

* add gha_meta to wasm build command

* make build manual for now

* formatting

* update actions

* fix typo

* fix typo

* use gh
action

* fix typo

* test new project

* comment out meta comparison

* test now

* add github parameters

* make coverage run conditional

* test wasm builder

* comment out if-else

* update branch

* set branch

* only run for PRs that merge to main

* add pass to give green CI

* remove use of action trigger

* concat url

* add echa

* update json format

* cleanup

* ignore cargo lock files

* remove them from git

* update to try out codecov

* allow execution of modules cov script

* add docker setup step

* remove docker steps

* add go install

* Use on-liner for go install

* don't install go in different terminal

* test

* update go install

* test

* try other syntax

* try with source

* touch bash.rs file

* update go install

* echo bashrc

* bashrc -> bash_profile

* add llvm-cov install

* add install of build essentials

* attempt with sudo

* test

* install libclang-dev

* do one job to test thesis

* try with larger runner

* trigger ci

* remove all-features flag from coverage run

* uncomment all install commands

---------

Co-authored-by: CircleCI <circleci@example.com>

* Add version control to abstract app in instantiation (#63)

* update version_control

* small test

* fix integrations

* changelog update

* fix clippy

* fix clippy

* rebuilt wasms

* renames

* rm all wasms

---------

Co-authored-by: cyberhoward <cyberhoward@protonmail.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>

* ABS-166: Create accountability module (#47)

* create initial structure

* create initial state

* create handlers and msg

* create execute handler

* update names update state

* update handlers

* add vote handler logic

* fix handler compiler errors

* refactor, cleanup

* update execute msg, more refactors

* create wasm test update toml

* create wasm test and setup for e2e

* create integration tests

* add more tests

* add friend test cases

* add vote cases

* updates

* integrate adairrr feedback

* update charge_penalty logic

* rebuilt wasms

* rebuilt wasms

* fix tests and cleanup

* clippy

* integrate PR feedback

* add impl methods on Vote and Friend

* update tests

* fix tests, refactor, cleanup

* integrate Buckram feedback

* add admin strike functionality and add challenge status

* update charge_penalty logic

* fix failing tests

* fix flaxy test, add remainder attribute

* update to Timestamp use EndKind enum for user input

* add Timestamp to Checkin and vote_status

* update contract logic

* remodel state, fix new ownership errors

* update charge penalty math and state

* fix tests intergrate feedback

* update composite key and field names

* update test after composite keys change

* remove redundant

* update comments

* update responses

* add transfer msg

* clippy

* clippy more

* run release_build

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>

* integrate buckram feedback

* generate schema

* bump osmosis-test-tube

* integrate buckram123 feedback

* bump chrono

* bump chrono again

* chrono to 0.4.23

* chrono to 0.4.27

* chrono to 0.4.23

* croncat version bump

---------

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>
Co-authored-by: Buckram <buckram123@gmail.com>

* Multiple stake targets for cw-staking adapter (#70)

* astroport

* kujira

* osmosis progress

* osmosis

* wyndex progress

* wyndex

* fix error

* deps fixes

* fix tests

* typos

* fix compile

* trait fixes

* tests fix

* rebuild wasms fix tests

* update changelog

* updated versions

* update justfile

* fix errors

* update .gitignore

* juno-local setup

* Update template to a new version (#87)

* fix state path

* add local state to gitignore

* update abstract

* update documentation in deploy script

* update readme

* use new account id query

* add comment

* add wasm just action

* commit wasms

* fix adapter wasming

* bump versions

* re-compile wasms

* rename template message generation

* update app template to 0.17

* update wasms

* formatting

* wasms

* Fix publish-schemas

* formatting

* recompile all

* clean up testing logic

* Publish to proper schemas dir

* Publish 0.17.1

* Bump to 0.17.2

* osmosis cw-staking fix

* bump to 0.18

* rebuild wasms

* Update wasms

* bump cw-orch to 0.15

* formatting

* undo cw-orch bump to template

* rebuilt wasms new weird error

* Apps schema updates (#20)

* bump version

* updated schemas

* fix publish-schema script

* rebuild wasms

* fix docs

* aftermerge fixes

* update wasms

* Update optimizer and add wasms to gitattributes (#56)

* update optimizer version

* add wasms to top-level git attributes as binaries.

* update the wasms

* remove template_app wasm

* Add/circle ci (#62)

* add circe-ci config

* run tickle on push for testing

* add remote docker setup

* add wasm-all-ci

* add scripts to volume

* commit lock file

* Update WASM artifacts [skip ci]

* try copy content of artifacts folder

* remove all artifacts and re-run

* Update WASM artifacts [skip ci]

* add comments on tickle job

* remove use of `just` and wasm modules as well

* attempt to fix modules build

* Update WASM artifacts for $GHA_Event [skip ci]

* use pwd dirname for cp command

* fix typo

* add integrations and framework mounts

* Update WASM artifacts for $GHA_Event [skip ci]

* add debugging

* remove container before mounting to ensure its fresh

* restructure container mounting

* print root dir

* fix

* cp to root of container

* Update WASM artifacts for $GHA_Event [skip ci]

* re-enable framework builds

* allow manual trigger of wasm builds

* update name of ci job

* add coverage build for modules

* formatting

* do changes in modules dir

* update coverage trigger

* update equal statement

* update url for coverage trigger

* use gh-action meta instead of event

* add gha_meta parameter

* add gha_meta to wasm build command

* make build manual for now

* formatting

* update actions

* fix typo

* fix typo

* use gh
action

* fix typo

* test new project

* comment out meta comparison

* test now

* add github parameters

* make coverage run conditional

* test wasm builder

* comment out if-else

* update branch

* set branch

* only run for PRs that merge to main

* add pass to give green CI

* remove use of action trigger

* concat url

* add echa

* update json format

* cleanup

* ignore cargo lock files

* remove them from git

* update to try out codecov

* allow execution of modules cov script

* add docker setup step

* remove docker steps

* add go install

* Use on-liner for go install

* don't install go in different terminal

* test

* update go install

* test

* try other syntax

* try with source

* touch bash.rs file

* update go install

* echo bashrc

* bashrc -> bash_profile

* add llvm-cov install

* add install of build essentials

* attempt with sudo

* test

* install libclang-dev

* do one job to test thesis

* try with larger runner

* trigger ci

* remove all-features flag from coverage run

* uncomment all install commands

---------

Co-authored-by: CircleCI <circleci@example.com>

* Add version control to abstract app in instantiation (#63)

* update version_control

* small test

* fix integrations

* changelog update

* fix clippy

* fix clippy

* rebuilt wasms

* renames

* rm all wasms

---------

Co-authored-by: cyberhoward <cyberhoward@protonmail.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>

* ABS-166: Create accountability module (#47)

* create initial structure

* create initial state

* create handlers and msg

* create execute handler

* update names update state

* update handlers

* add vote handler logic

* fix handler compiler errors

* refactor, cleanup

* update execute msg, more refactors

* create wasm test update toml

* create wasm test and setup for e2e

* create integration tests

* add more tests

* add friend test cases

* add vote cases

* updates

* integrate adairrr feedback

* update charge_penalty logic

* rebuilt wasms

* rebuilt wasms

* fix tests and cleanup

* clippy

* integrate PR feedback

* add impl methods on Vote and Friend

* update tests

* fix tests, refactor, cleanup

* integrate Buckram feedback

* add admin strike functionality and add challenge status

* update charge_penalty logic

* fix failing tests

* fix flaxy test, add remainder attribute

* update to Timestamp use EndKind enum for user input

* add Timestamp to Checkin and vote_status

* update contract logic

* remodel state, fix new ownership errors

* update charge penalty math and state

* fix tests intergrate feedback

* update composite key and field names

* update test after composite keys change

* remove redundant

* update comments

* update responses

* add transfer msg

* clippy

* clippy more

* run release_build

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>

* Update modules/contracts/apps/challenge/src/handlers/execute.rs

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>

* integrate buckram feedback

* generate schema

* bump osmosis-test-tube

* integrate buckram123 feedback

* bump chrono

* bump chrono again

* chrono to 0.4.23

* chrono to 0.4.27

* chrono to 0.4.23

* croncat version bump

---------

Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>
Co-authored-by: Buckram <buckram123@gmail.com>

* Multiple stake targets for cw-staking adapter (#70)

* astroport

* kujira

* osmosis progress

* osmosis

* wyndex progress

* wyndex

* fix error

* deps fixes

* fix tests

* typos

* fix compile

* trait fixes

* tests fix

* rebuild wasms fix tests

* update changelog

* updated versions

* updated versions

* update justfile

* update justfile

* update just push

* fix errors

* update .gitignore

* juno-local setup

* Update app-template/example.env

Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>

* Update app-template/examples/test-local.rs

Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>

---------

Co-authored-by: cyberhoward <cyberhoward@protonmail.com>
Co-authored-by: adairrr <32375605+adairrr@users.noreply.github.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
Co-authored-by: CircleCI <circleci@example.com>
Co-authored-by: 0xmovses <35300528+0xmovses@users.noreply.github.com>

* modified typescript code generation directory path

* patch thiserror because of broken release

* updated

* Release v0.19.0 (#85)

* Changed account id structure

* Corrected tests

* formatting

* Cleanup and test

* Changelog

* Corrected imports

* Fixed tests

* improve ChainName construction strictness

* fix tests

* Cleanup and storage key shortening

* fix test

* clippy fix

* remove osmosis remenant

* bump cw-orch

* Hot fix for cw-orch 0.16.0

* Moved from_str to trait

* bump cw-orch

* fix tests

* formatting

* bump version to 0.19

* formatting

* Update deploy_all bin (#75)

* ping url, write json log

* clippy

* Changed account id structure (#58)

* Changed account id structure

* Corrected tests

* formatting

* Cleanup and test

* Changelog

* Corrected imports

* Fixed tests

* improve ChainName construction strictness

* fix tests

* Cleanup and storage key shortening

* fix test

* clippy fix

* remove osmosis remenant

* bump cw-orch

* Hot fix for cw-orch 0.16.0

* Moved from_str to trait

* bump cw-orch

* fix tests

* formatting

* rm unused import

---------

Co-authored-by: cyberhoward <cyberhoward@protonmail.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>

* Update WASM artifacts [skip ci]

---------

Co-authored-by: Kayanski <44806566+Kayanski@users.noreply.github.com>
Co-authored-by: cyberhoward <cyberhoward@protonmail.com>
Co-authored-by: CyberHoward <88450409+CyberHoward@users.noreply.github.com>
Co-authored-by: CircleCI <circleci@example.com>

* add release

* update yml

* add job

* add new release action

* updates circleci

* update config

* add when, add deploy circle ci req

* edit ci config

* remove graph png

* test release branch match

* update deploy branch match

* poll circleci api status

* Update WASM artifacts [skip ci]

* fetch workflow_id

* check endpoint get workflow id for status

* force wasm diff commit with comment

* fix parse response bug

* check for null values on parse, log if any

* add more logs for parse

* add wait incase of propogation delay

* update config ci

* handle all status cases from ci api res

* Revert "update config ci"

This reverts commit 72e777e.

* update status handle

* update config ci after revert

* add logs

* change item to check on response

* use pipeline id for prev pipeline qry

* will update checksum, force rebuild wasm

* update bin to force wasm write

* force wasm commit

* add arbitary to force wasm diff

* add post on success

* remove syntax bash error

* Revert "force wasm commit"

This reverts commit 8f9990a.

* remove polling logic

* edit release run command

* update config ci

* add new release workflow

* change metadata req

* update req

* typo config

* testing ci

* curl

* log response

* fetch branch name

* remove binaries

* remove binaries

* Update WASM artifacts [skip ci]

* add artifcats dir

* remove bins (#84)

* Update WASM artifacts [skip ci]

* merge main

* update gitignore

* Update WASM artifacts [skip ci]

* skip build, add path

* update config

* update config

* add requries back

* update param namespace

* Update WASM artifacts [skip ci]

* add artifacts folder inside framework/

* remove binaries

* skip build step

* set log level

* will trigger build

* Update WASM artifacts [skip ci]

* set env var for container

* skip build

* add log var

* echo container vars

* log env

* set var in docker

* fix typo in set command

* echo env var

* remove override

* decode base64 env var

* decode base64

* combine commands to persist env state

* log

* remove log

* add commit deploy file step

* Update deploy deploy file [skip ci]

* streamline publishing process

* formatting

* commit push cw-orch state file

* remove binaries for commit

* add build step back

* Update WASM artifacts [skip ci]

* Revert "formatting"

This reverts commit 2cabfc1.

* add check for wasms, skip if no diff

* skip build for now

* format yml

* remove first deploy

* remove check

* add manual wasm build action

* remove redundant comment

* formatting

* update changelog

* use branch parameter for build

* update manual build

* formatting

* use branch env var

* Update WASM binaries [skip ci]

* deploy abstract

* formatting

* fix clippy

---------

Co-authored-by: Kayanski <kowalski.kowalskin@gmail.com>
Co-authored-by: 0xmovses <35300528+0xmovses@users.noreply.github.com>
Co-authored-by: Kayanski <44806566+Kayanski@users.noreply.github.com>
Co-authored-by: CircleCI <circleci@example.com>
Co-authored-by: 0xmovses <r.v.melkonian@gmail.com>

* update template gitignore and justfile

* update template gitignore and justfile

* run just ts-codegen

* run just ts-codegen

* remove broken script commands

* remove broken script commands

---------

Co-authored-by: adairrr <32375605+adairrr@users.noreply.github.com>
Co-authored-by: Buckram <buckram123@gmail.com>
Co-authored-by: Mykhailo Donchenko <91957742+Buckram123@users.noreply.github.com>
Co-authored-by: CircleCI <circleci@example.com>
Co-authored-by: 0xmovses <35300528+0xmovses@users.noreply.github.com>
Co-authored-by: Lawal Abubakar Babatunde <utility4all@gmail.com>
Co-authored-by: Kayanski <kowalski.kowalskin@gmail.com>
Co-authored-by: Kayanski <44806566+Kayanski@users.noreply.github.com>
Co-authored-by: 0xmovses <r.v.melkonian@gmail.com>
  • Loading branch information
10 people committed Sep 29, 2023
1 parent 89e7fbd commit 9726c56
Show file tree
Hide file tree
Showing 17 changed files with 494 additions and 215 deletions.
4 changes: 3 additions & 1 deletion app-template/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@ Cargo.lock
.vscode
.idea

state.json
state.json

typescript/node_modules
4 changes: 2 additions & 2 deletions app-template/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ You can see the full list of tasks available by running `just --list`.

You can test the module using the different provided methods.

1. **Integration testing:** We provide an integration testing setup [here](./tests/integration.rs). You should use this to set up your environment and test the different execution and query entry-points of your module. Once you are satisfied with the results you can try deploying it to a real chain.
1. **Integration testing:** We provide an integration testing setup [here](./tests/integration.rs). You should use this to set up your environment and test the different execution and query entry-points of your module. Once you are satisfied with the results you can try deploying it to a real chain.
2. **Local Daemon:** Once you have confirmed that your module works as expected you can spin up a local node and deploy Abstract + your app onto the chain. You can do this by running the [test-local](./examples/test-local.rs) example, which uses a locally running juno daemon to deploy to. You can setup local juno using `just juno-local` command. At this point you can also test your front-end with the contracts.

Once testing is done you can attempt an actual deployment on test and mainnet.
Expand All @@ -71,7 +71,7 @@ You can now use `just deploy {{chain-id}}` to run the [`examples/deploy.rs`](./e
Before proceeding you need to install the required dependencies for the typescript client code generation.

```bash
cd typescript
cd packages/typescript
npm install
```

Expand Down
28 changes: 15 additions & 13 deletions app-template/justfile
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Install the tools that are used in this justfile
install-tools:
cargo install cargo-nextest --locked
cargo install taplo-cli --locked
cargo install cargo-watch
cargo install cargo-limit
cargo install cargo-nextest --locked || true
cargo install taplo-cli --locked || true
cargo install cargo-watch || true
cargo install cargo-limit || true

## Development Helpers ##

Expand Down Expand Up @@ -69,6 +69,16 @@ wasm:
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
${image}:0.14.0

## Frontend Helpers ##

# Generate the typescript client for the app contract
ts-codegen: schema
(cd packages/typescript && npm install && npm run codegen)

# Publish the typescript sdk
ts-publish: ts-codegen
(cd packages/typescript && npm publish --access public)

# Generate the schemas for the app contract
schema:
cargo schema
Expand Down Expand Up @@ -122,12 +132,4 @@ run-script script +CHAINS:

deploy +CHAINS:
just run-script deploy {{CHAINS}}

create-account +CHAINS:
just run-script create-account {{CHAINS}}

claim-namespace +CHAINS:
just run-script claim-namespace {{CHAINS}}

install-module +CHAINS:
just run-script install-module {{CHAINS}}

38 changes: 9 additions & 29 deletions app-template/packages/typescript/src/contracts/Template.client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@ 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 { StdFee, Coin } from "@cosmjs/amino";
import { AdminResponse, Addr, ConfigResponse, ExecuteMsg, BaseExecuteMsg, AppExecuteMsg, StdAck, Binary, IbcResponseMsg, Empty, InstantiateMsg, BaseInstantiateMsg, AppInstantiateMsg, AppMigrateMsg, MigrateMsg, BaseMigrateMsg, QueryMsg, BaseQueryMsg, AppQueryMsg } from "./Template.types";
import { InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, ConfigResponse } from "./Template.types";
import { TemplateQueryMsgBuilder, TemplateExecuteMsgBuilder } from "./Template.msg-builder";
export interface ITemplateQueryClient {
moduleId: string;
accountQueryClient: AbstractAccountQueryClient;
_moduleAddress: string | undefined;
base: () => Promise<BaseResponse>;
module: () => Promise<ModuleResponse>;
config: () => Promise<ConfigResponse>;
connectSigningClient: (signingClient: SigningCosmWasmClient, address: string) => TemplateClient;
getAddress: () => Promise<string>;
}
Expand Down Expand Up @@ -44,15 +43,11 @@ export class TemplateQueryClient implements ITemplateQueryClient {
proxyAddress
});
this.moduleId = moduleId;
this.base = this.base.bind(this);
this.module = this.module.bind(this);
this.config = this.config.bind(this);
}

base = async (): Promise<BaseResponse> => {
return this._query(TemplateQueryMsgBuilder.base());
};
module = async (): Promise<ModuleResponse> => {
return this._query(TemplateQueryMsgBuilder.module());
config = async (): Promise<ConfigResponse> => {
return this._query(TemplateQueryMsgBuilder.config());
};
getAddress = async (): Promise<string> => {
if (!this._moduleAddress) {
Expand Down Expand Up @@ -80,10 +75,7 @@ export class TemplateQueryClient implements ITemplateQueryClient {
}
export interface ITemplateClient extends ITemplateQueryClient {
accountClient: AbstractAccountClient;
base: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
module: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
ibcCallback: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
receive: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
updateConfig: (fee?: number | StdFee | "auto", memo?: string, _funds?: Coin[]) => Promise<ExecuteResult>;
}
export class TemplateClient extends TemplateQueryClient implements ITemplateClient {
accountClient: AbstractAccountClient;
Expand All @@ -109,23 +101,11 @@ export class TemplateClient extends TemplateQueryClient implements ITemplateClie
moduleId
});
this.accountClient = AbstractAccountClient.fromQueryClient(this.accountQueryClient, abstractClient);
this.base = this.base.bind(this);
this.module = this.module.bind(this);
this.ibcCallback = this.ibcCallback.bind(this);
this.receive = this.receive.bind(this);
this.updateConfig = this.updateConfig.bind(this);
}

base = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(TemplateExecuteMsgBuilder.base(), fee, memo, _funds);
};
module = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(TemplateExecuteMsgBuilder.module(), fee, memo, _funds);
};
ibcCallback = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(TemplateExecuteMsgBuilder.ibcCallback(), fee, memo, _funds);
};
receive = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(TemplateExecuteMsgBuilder.receive(), fee, memo, _funds);
updateConfig = async (fee: number | StdFee | "auto" = "auto", memo?: string, _funds?: Coin[]): Promise<ExecuteResult> => {
return this._execute(TemplateExecuteMsgBuilder.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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,11 @@ import { MsgExecuteContractEncodeObject } from "cosmwasm";
import { MsgExecuteContract } from "cosmjs-types/cosmwasm/wasm/v1/tx";
import { toUtf8 } from "@cosmjs/encoding";
import { AppExecuteMsg, AppExecuteMsgFactory } from "@abstract-money/abstract.js";
import { AdminResponse, Addr, ConfigResponse, ExecuteMsg, BaseExecuteMsg, AppExecuteMsg, StdAck, Binary, IbcResponseMsg, Empty, InstantiateMsg, BaseInstantiateMsg, AppInstantiateMsg, AppMigrateMsg, MigrateMsg, BaseMigrateMsg, QueryMsg, BaseQueryMsg, AppQueryMsg } from "./Template.types";
import { InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, ConfigResponse } from "./Template.types";
export interface TemplateMessage {
contractAddress: string;
sender: string;
base: (baseExecuteMsg: BaseExecuteMsg, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
module: (appExecuteMsg: AppExecuteMsg, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
ibcCallback: ({
id,
msg
}: {
id: string;
msg: StdAck;
}, _funds?: Coin[]) => MsgExecuteContractEncodeObject;
receive: (_funds?: Coin[]) => MsgExecuteContractEncodeObject;
updateConfig: (_funds?: Coin[]) => MsgExecuteContractEncodeObject;
}
export class TemplateMessageComposer implements TemplateMessage {
sender: string;
Expand All @@ -31,69 +22,12 @@ export class TemplateMessageComposer implements TemplateMessage {
constructor(sender: string, contractAddress: string) {
this.sender = sender;
this.contractAddress = contractAddress;
this.base = this.base.bind(this);
this.module = this.module.bind(this);
this.ibcCallback = this.ibcCallback.bind(this);
this.receive = this.receive.bind(this);
this.updateConfig = this.updateConfig.bind(this);
}

base = (baseExecuteMsg: BaseExecuteMsg, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
updateConfig = (_funds?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
base: {}
};
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return {
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
value: MsgExecuteContract.fromPartial({
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
})
};
};
module = (appExecuteMsg: AppExecuteMsg, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
module: {}
};
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return {
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
value: MsgExecuteContract.fromPartial({
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
})
};
};
ibcCallback = ({
id,
msg
}: {
id: string;
msg: StdAck;
}, _funds?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
ibc_callback: {
id,
msg
}
};
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return {
typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract",
value: MsgExecuteContract.fromPartial({
sender: this.sender,
contract: this.contractAddress,
msg: toUtf8(JSON.stringify(moduleMsg)),
funds: _funds
})
};
};
receive = (_funds?: Coin[]): MsgExecuteContractEncodeObject => {
const msg = {
receive: {}
update_config: {}
};
const moduleMsg: AppExecuteMsg<ExecuteMsg> = AppExecuteMsgFactory.executeApp(msg);
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,47 +4,19 @@
* and run the @abstract-money/ts-codegen generate command to regenerate this file.
*/

import { AdminResponse, Addr, ConfigResponse, ExecuteMsg, BaseExecuteMsg, AppExecuteMsg, StdAck, Binary, IbcResponseMsg, Empty, InstantiateMsg, BaseInstantiateMsg, AppInstantiateMsg, AppMigrateMsg, MigrateMsg, BaseMigrateMsg, QueryMsg, BaseQueryMsg, AppQueryMsg } from "./Template.types";
import { InstantiateMsg, ExecuteMsg, QueryMsg, MigrateMsg, ConfigResponse } from "./Template.types";
import { CamelCasedProperties } from "type-fest";
export abstract class TemplateExecuteMsgBuilder {
static base = (baseExecuteMsg: BaseExecuteMsg): ExecuteMsg => {
static updateConfig = (): ExecuteMsg => {
return {
base: baseExecuteMsg
};
};
static module = (appExecuteMsg: AppExecuteMsg): ExecuteMsg => {
return {
module: appExecuteMsg
};
};
static ibcCallback = ({
id,
msg
}: CamelCasedProperties<Extract<ExecuteMsg, {
ibc_callback: unknown;
}>["ibc_callback"]>): ExecuteMsg => {
return {
ibc_callback: ({
id,
msg
} as const)
};
};
static receive = (): ExecuteMsg => {
return {
receive: ({} as const)
update_config: ({} as const)
};
};
}
export abstract class TemplateQueryMsgBuilder {
static base = (baseQueryMsg: BaseQueryMsg): QueryMsg => {
return {
base: baseQueryMsg
};
};
static module = (appQueryMsg: AppQueryMsg): QueryMsg => {
static config = (): QueryMsg => {
return {
module: appQueryMsg
config: ({} as const)
};
};
}
63 changes: 3 additions & 60 deletions app-template/packages/typescript/src/contracts/Template.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,70 +4,13 @@
* and run the @abstract-money/ts-codegen generate command to regenerate this file.
*/

export interface AdminResponse {
admin?: string | null;
}
export type Addr = string;
export interface ConfigResponse {
ans_host_address: Addr;
manager_address: Addr;
proxy_address: Addr;
}
export interface InstantiateMsg {}
export type ExecuteMsg = {
base: BaseExecuteMsg;
} | {
module: AppExecuteMsg;
} | {
ibc_callback: IbcResponseMsg;
} | {
receive: Empty;
};
export type BaseExecuteMsg = {
update_config: {
ans_host_address?: string | null;
};
};
export type AppExecuteMsg = {
update_config: {};
};
export type StdAck = {
result: Binary;
} | {
error: string;
};
export type Binary = string;
export interface IbcResponseMsg {
id: string;
msg: StdAck;
}
export interface Empty {
[k: string]: unknown;
}
export interface InstantiateMsg {
base: BaseInstantiateMsg;
module: AppInstantiateMsg;
}
export interface BaseInstantiateMsg {
ans_host_address: string;
}
export interface AppInstantiateMsg {}
export type AppMigrateMsg = string;
export interface MigrateMsg {
base: BaseMigrateMsg;
module: AppMigrateMsg;
}
export interface BaseMigrateMsg {}
export type QueryMsg = {
base: BaseQueryMsg;
} | {
module: AppQueryMsg;
};
export type BaseQueryMsg = {
config: {};
} | {
admin: {};
};
export type AppQueryMsg = {
config: {};
};
export type MigrateMsg = string;
export interface ConfigResponse {}
export type TemplateExecuteMsg = ExecuteMsg;
3 changes: 2 additions & 1 deletion app-template/schema/module-schema.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions app-template/schema/raw/query.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "QueryMsg",
"description": "App query messages",
"oneOf": [
{
"type": "object",
Expand Down
Loading

0 comments on commit 9726c56

Please sign in to comment.