diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml deleted file mode 100644 index 22e6b7bc6..000000000 --- a/.github/workflows/run-tests.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Run Tests - -on: - workflow_dispatch: - #push: - - pull_request: - types: [opened, reopened] - - workflow_dispatch: - -jobs: - run-tests: - runs-on: ubuntu-latest - steps: - - name: checkout 🛎️ - uses: actions/checkout@v2.3.1 - - name: node - uses: actions/setup-node@v3 - with: - node-version: 16.14.0 - - name: deps - run: yarn - - name: bootstrap - run: yarn bootstrap - - name: build - run: yarn build - - name: react - run: cd ./packages/react && yarn test \ No newline at end of file diff --git a/.prettierrc.yaml b/.prettierrc.yaml new file mode 100644 index 000000000..125ae1cb2 --- /dev/null +++ b/.prettierrc.yaml @@ -0,0 +1,2 @@ +# .prettierrc or .prettierrc.yaml +singleQuote: true diff --git a/.vscode/settings.json b/.vscode/settings.json index a63408665..b30cef7c7 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,19 +1,17 @@ { - "editor.formatOnSave": true, - "[javascriptreact]": { - "editor.formatOnSave": false - }, - "[javascript]": { - "editor.formatOnSave": false - }, - "editor.codeActionsOnSave": { - "source.fixAll.eslint": true - }, - "eslint.validate": [ - "javascript", - "javascriptreact" - ], - "files.exclude": { - ".yarn/*": true - }, -} \ No newline at end of file + "editor.formatOnSave": true, + "[javascriptreact]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": ["javascript", "javascriptreact"], + "files.exclude": { + ".yarn/*": true + }, + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/README.md b/README.md index 802b05358..0bf2347f9 100644 --- a/README.md +++ b/README.md @@ -1 +1,293 @@ -# create-cosmos-app \ No newline at end of file +# create-cosmos-app + +

+ +

+ +

+ + + +

+ +Set up a modern Cosmos app by running one command ⚛️ + +## Demo + +https://user-images.githubusercontent.com/545047/192061992-f0e1106d-f4b2-4879-ab0a-896f22ee4f49.mp4 + +## Overview + +``` +# install +npm install -g create-cosmos-app + +# run one command +create-cosmos-app + +> name: my-app +cd my-app +yarn && yarn dev + +# now your app is running on localhost:3000! +``` + +### Get Started Immediately + +You don’t need to install or configure cosmjs, keplr, nextjs, webpack or Babel. + +Everything is preconfigured, ready-to-go, so you can focus on your code! + +- ⚡️ Connect easily to 15+ wallets via [Cosmos Kit](https://github.com/cosmology-tech/cosmos-kit) — including Ledger, Keplr, Cosmostation, Leap, Trust Wallet, XDEFI, Exodus, Wallet Connect and more! +- ⚛️ Sign and broadcast with [cosmjs](https://github.com/cosmos/cosmjs) stargate + cosmwasm signers +- 🛠 Render pages with [next.js](https://nextjs.org/) hybrid static & server rendering +- 🎨 Build awesome UI with [Cosmos Kit UI](https://CosmosKit.com/explore) and [Chakra UI](https://chakra-ui.com/docs/components) +- 📝 Leverage [chain-registry](https://github.com/cosmology-tech/chain-registry) for Chain and Asset info for all Cosmos chains + +## Education & Resources + +🎥 [Checkout our videos](https://cosmology.tech/learn) to learn to learn more about `create-cosmos-app` and tooling for building frontends in the Cosmos! + +Checkout [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) for more docs as well as [cosmos-kit/react](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) for getting cosmjs stargate and cosmjs signers. + +## Creating an App + +To create a new app, you may choose one of the following methods: + +### global install + +```sh +npm install -g create-cosmos-app +``` + +Then run the command: + +```sh +create-cosmos-app +``` + +we also made an alias `cca` if you don't want to type `create-cosmos-app`: + +```sh +cca +``` + +### npx + +```sh +npx create-cosmos-app +``` + +### npm + +```sh +npm init cosmos-app +``` + +### Yarn + +```sh +yarn create cosmos-app +``` + +## Examples + +Explore examples! + +``` +cca --example +``` + +### Send Tokens + +

+ +

+ +``` +cca --name send-example --example --template send-tokens +``` + +### Stake Tokens + +

+ +

+ +``` +cca --name stake-example --example --template stake-tokens +``` + +### Vote Proposal + +

+ +

+ +``` +cca --name vote-example --example --template vote-proposal +``` + +### IBC Transfer + +

+ +

+ +``` +cca --name ibc-example --example --template ibc-transfer +``` + +### grpc-web and grpc-gateway + +

+ +

+ +``` +cca --name grpc-example --example --template grpc-web-grpc-gateway +``` + +### Osmosis + +

+ +

+ +uses [osmojs](https://github.com/osmosis-labs/osmojs) + +``` +cca --name osmo-example --example --template osmosis +``` + +or the cosmwasm example: + +``` +cca --name osmowasm-example --example --template osmosis-cosmwasm +``` + +### Swap Tokens + +

+ +

+ +uses [osmojs](https://github.com/osmosis-labs/osmojs) to swap tokens + +``` +cca --name swap-example --example --template swap-tokens +``` + +### Provide Liquidity + +

+ +

+ +uses [osmojs](https://github.com/osmosis-labs/osmojs) to provide liquidity + +``` +cca --name liquidity-example --example --template provide-liquidity +``` + +### Asset List + +

+ +

+ +``` +cca --name asset-list-example --example --template asset-list +``` + +### Juno + +

+ +

+ +uses [juno-network](https://github.com/CosmosContracts/typescript) + +``` +cca --name juno-example --example --template juno +``` + +### Stargaze + +

+ +

+ +uses [stargazejs](https://github.com/cosmology-tech/stargazejs) + +``` +cca --name stargaze-example --example --template stargaze +``` + +### NFT + +

+ +

+ +uses [stargazejs](https://github.com/cosmology-tech/stargazejs) + +``` +cca --name nft-example --example --template nft +``` + +### CosmWasm + +

+ +

+ +``` +cca --name cosmwasm-example --example --template cosmwasm +``` + +### Tailwind + +``` +cca --name tailwind-example --example --template tailwindcss +``` + +## Development + +Because the nature of how template boilerplates are generated, we generate `yarn.lock` files inside of nested packages so we can fix versions to avoid non-deterministic installations. + +When adding packages, yarn workspaces will use the root `yarn.lock`. It could be ideal to remove it while adding packages, and when publishing or pushing new changes, generating the nested lock files. + +In the root, to remove all nested lock files: + +``` +yarn locks:remove +``` + +When you need to remove/generate locks for all nested packages, simply run `yarn locks` in the root: + +``` +yarn locks +``` + +## Related + +Checkout these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [chain-registry](https://github.com/cosmology-tech/chain-registry) an npm module for the official Cosmos chain-registry. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️ +* [create-cosmos-app](https://github.com/cosmology-tech/create-cosmos-app) set up a modern Cosmos app by running one command. +* [starship](https://github.com/cosmology-tech/starship) a k8s-based unified development environment for Cosmos Ecosystem + +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + + +## Disclaimer + +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. + +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or CLI, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. diff --git a/templates/placeholder-connect-chain/.editorconfig b/boilerplates/node-typescript/.editorconfig similarity index 100% rename from templates/placeholder-connect-chain/.editorconfig rename to boilerplates/node-typescript/.editorconfig diff --git a/templates/placeholder-connect-chain/.eslintignore b/boilerplates/node-typescript/.eslintignore similarity index 100% rename from templates/placeholder-connect-chain/.eslintignore rename to boilerplates/node-typescript/.eslintignore diff --git a/templates/placeholder-connect-chain/.eslintrc.js b/boilerplates/node-typescript/.eslintrc.js similarity index 100% rename from templates/placeholder-connect-chain/.eslintrc.js rename to boilerplates/node-typescript/.eslintrc.js diff --git a/templates/placeholder-connect-chain/.gitignore b/boilerplates/node-typescript/.gitignore similarity index 98% rename from templates/placeholder-connect-chain/.gitignore rename to boilerplates/node-typescript/.gitignore index d93985ec4..9cd5f4164 100644 --- a/templates/placeholder-connect-chain/.gitignore +++ b/boilerplates/node-typescript/.gitignore @@ -9,6 +9,8 @@ pids *.seed # dist +dist +mjs main module diff --git a/templates/placeholder-connect-chain/.npmignore b/boilerplates/node-typescript/.npmignore similarity index 100% rename from templates/placeholder-connect-chain/.npmignore rename to boilerplates/node-typescript/.npmignore diff --git a/templates/placeholder-connect-chain/.npmrc b/boilerplates/node-typescript/.npmrc similarity index 100% rename from templates/placeholder-connect-chain/.npmrc rename to boilerplates/node-typescript/.npmrc diff --git a/boilerplates/node-typescript/.questions.json b/boilerplates/node-typescript/.questions.json new file mode 100644 index 000000000..c1549e7cc --- /dev/null +++ b/boilerplates/node-typescript/.questions.json @@ -0,0 +1,37 @@ +[ + { + "name": "__USERFULLNAME__", + "message": "Enter author full name", + "required": true + }, + { + "name": "__USEREMAIL__", + "message": "Enter author email", + "required": true + }, + { + "name": "__MODULENAME__", + "message": "Enter the module name", + "required": true + }, + { + "name": "__MODULEDESC__", + "message": "Enter the module description", + "required": true + }, + { + "name": "__USERNAME__", + "message": "Enter your github username", + "required": true + }, + { + "name": "__ACCESS__", + "message": "Module access?", + "choices": [ + "public", + "restricted" + ], + "type": "list", + "required": true + } +] \ No newline at end of file diff --git a/boilerplates/node-typescript/.vscode/settings.json b/boilerplates/node-typescript/.vscode/settings.json new file mode 100644 index 000000000..55c8b9bba --- /dev/null +++ b/boilerplates/node-typescript/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "editor.formatOnSave": true, + "[javascriptreact]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": [ + "javascript", + "javascriptreact" + ] + } \ No newline at end of file diff --git a/templates/placeholder-connect-chain/LICENSE b/boilerplates/node-typescript/LICENSE similarity index 95% rename from templates/placeholder-connect-chain/LICENSE rename to boilerplates/node-typescript/LICENSE index b0b3013a6..78191bf06 100644 --- a/templates/placeholder-connect-chain/LICENSE +++ b/boilerplates/node-typescript/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Dan Lynch +Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/boilerplates/node-typescript/README.md b/boilerplates/node-typescript/README.md new file mode 100644 index 000000000..16ad51fd7 --- /dev/null +++ b/boilerplates/node-typescript/README.md @@ -0,0 +1,60 @@ +# __MODULENAME__ + +

+
+ __MODULEDESC__ +

+ +## install + +```sh +npm install __MODULENAME__ +``` +## Table of contents + +- [__MODULENAME__](#__MODULENAME__) + - [Install](#install) + - [Table of contents](#table-of-contents) +- [Developing](#developing) +- [Credits](#credits) + +## Developing + +When first cloning the repo: + +``` +yarn +yarn build +``` + +### Codegen + +Contract schemas live in `./contracts`. Look inside of `scripts/codegen.js` and configure the settings for bundling your SDK and contracts into `__MODULENAME__`: + +``` +yarn codegen +``` + +### Publishing + +Build the types and then publish: + +``` +yarn build +yarn publish +``` +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + +Code built with the help of these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️ + +## Disclaimer + +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. + +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. diff --git a/boilerplates/node-typescript/__tests__/contract.test.ts b/boilerplates/node-typescript/__tests__/contract.test.ts new file mode 100644 index 000000000..3f7425dd7 --- /dev/null +++ b/boilerplates/node-typescript/__tests__/contract.test.ts @@ -0,0 +1,3 @@ +it('it works', () => { + console.log('it works!') +}); \ No newline at end of file diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/LICENSE b/boilerplates/node-typescript/contracts/stargaze-minter/LICENSE new file mode 100644 index 000000000..edc7db470 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Public Awesome LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/README.md b/boilerplates/node-typescript/contracts/stargaze-minter/README.md new file mode 100644 index 000000000..da81535ac --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/README.md @@ -0,0 +1 @@ +# Stargaze minter \ No newline at end of file diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/package.json b/boilerplates/node-typescript/contracts/stargaze-minter/package.json new file mode 100644 index 000000000..52a2c328a --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/package.json @@ -0,0 +1,21 @@ +{ + "name": "@cosmjson/stargaze-minter", + "chain": "stargaze", + "contract": "minter", + "version": "0.0.7", + "description": "stargaze", + "author": "Dan Lynch ", + "homepage": "https://github.com/cosmology-tech/cosmjson/tree/master/packages/stargaze#readme", + "license": "SEE LICENSE IN LICENSE", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/cosmology-tech/cosmjson" + }, + "bugs": { + "url": "https://github.com/cosmology-tech/cosmjson/issues" + }, + "gitHead": "2d1a7b9aa6c3ac7596dbea4211180fd5c7235513" +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/config.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/config.json new file mode 100644 index 000000000..e64ef338f --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/config.json @@ -0,0 +1,90 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Config", + "type": "object", + "required": [ + "admin", + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_code_id", + "start_time", + "unit_price" + ], + "properties": { + "admin": { + "$ref": "#/definitions/Addr" + }, + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "anyOf": [ + { + "$ref": "#/definitions/Addr" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/config_response.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/config_response.json new file mode 100644 index 000000000..b400751e2 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/config_response.json @@ -0,0 +1,86 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ConfigResponse", + "type": "object", + "required": [ + "admin", + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_address", + "sg721_code_id", + "start_time", + "unit_price" + ], + "properties": { + "admin": { + "type": "string" + }, + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_address": { + "type": "string" + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/execute_msg.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/execute_msg.json new file mode 100644 index 000000000..e0763c569 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/execute_msg.json @@ -0,0 +1,144 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "set_whitelist" + ], + "properties": { + "set_whitelist": { + "type": "object", + "required": [ + "whitelist" + ], + "properties": { + "whitelist": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "update_start_time" + ], + "properties": { + "update_start_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "update_per_address_limit" + ], + "properties": { + "update_per_address_limit": { + "type": "object", + "required": [ + "per_address_limit" + ], + "properties": { + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_to" + ], + "properties": { + "mint_to": { + "type": "object", + "required": [ + "recipient" + ], + "properties": { + "recipient": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_for" + ], + "properties": { + "mint_for": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw" + ], + "properties": { + "withdraw": { + "type": "object" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/instantiate_msg.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/instantiate_msg.json new file mode 100644 index 000000000..a618033d4 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/instantiate_msg.json @@ -0,0 +1,159 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_code_id", + "sg721_instantiate_msg", + "start_time", + "unit_price" + ], + "properties": { + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "sg721_instantiate_msg": { + "$ref": "#/definitions/InstantiateMsg" + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CollectionInfo_for_RoyaltyInfoResponse": { + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + } + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "InstantiateMsg": { + "type": "object", + "required": [ + "collection_info", + "minter", + "name", + "symbol" + ], + "properties": { + "collection_info": { + "$ref": "#/definitions/CollectionInfo_for_RoyaltyInfoResponse" + }, + "minter": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_count_response.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_count_response.json new file mode 100644 index 000000000..dd7edbe67 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_count_response.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintCountResponse", + "type": "object", + "required": [ + "address", + "count" + ], + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_price_response.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_price_response.json new file mode 100644 index 000000000..628d25e44 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mint_price_response.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintPriceResponse", + "type": "object", + "required": [ + "current_price", + "public_price" + ], + "properties": { + "current_price": { + "$ref": "#/definitions/Coin" + }, + "public_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist_price": { + "anyOf": [ + { + "$ref": "#/definitions/Coin" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/mintable_num_tokens_response.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mintable_num_tokens_response.json new file mode 100644 index 000000000..05a378f15 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/mintable_num_tokens_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintableNumTokensResponse", + "type": "object", + "required": [ + "count" + ], + "properties": { + "count": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/query_msg.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/query_msg.json new file mode 100644 index 000000000..c97025f73 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/query_msg.json @@ -0,0 +1,74 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "config" + ], + "properties": { + "config": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mintable_num_tokens" + ], + "properties": { + "mintable_num_tokens": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "start_time" + ], + "properties": { + "start_time": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_price" + ], + "properties": { + "mint_price": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_count" + ], + "properties": { + "mint_count": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/boilerplates/node-typescript/contracts/stargaze-minter/schema/start_time_response.json b/boilerplates/node-typescript/contracts/stargaze-minter/schema/start_time_response.json new file mode 100644 index 000000000..3dd3fe89f --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-minter/schema/start_time_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StartTimeResponse", + "type": "object", + "required": [ + "start_time" + ], + "properties": { + "start_time": { + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/LICENSE b/boilerplates/node-typescript/contracts/stargaze-sg721/LICENSE new file mode 100644 index 000000000..edc7db470 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Public Awesome LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/README.md b/boilerplates/node-typescript/contracts/stargaze-sg721/README.md new file mode 100644 index 000000000..872489dfb --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/README.md @@ -0,0 +1 @@ +# Stargaze sg721 \ No newline at end of file diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/package.json b/boilerplates/node-typescript/contracts/stargaze-sg721/package.json new file mode 100644 index 000000000..8a8165d3c --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/package.json @@ -0,0 +1,21 @@ +{ + "name": "@cosmjson/stargaze-sg721", + "chain": "stargaze", + "contract": "sg721", + "version": "0.0.7", + "description": "stargaze", + "author": "Dan Lynch ", + "homepage": "https://github.com/cosmology-tech/cosmjson/tree/master/packages/stargaze#readme", + "license": "SEE LICENSE IN LICENSE", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/cosmology-tech/cosmjson" + }, + "bugs": { + "url": "https://github.com/cosmology-tech/cosmjson/issues" + }, + "gitHead": "2d1a7b9aa6c3ac7596dbea4211180fd5c7235513" +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_nft_info_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_nft_info_response.json new file mode 100644 index 000000000..930dadd44 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_nft_info_response.json @@ -0,0 +1,155 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllNftInfoResponse", + "type": "object", + "required": [ + "access", + "info" + ], + "properties": { + "access": { + "description": "Who can transfer the token", + "allOf": [ + { + "$ref": "#/definitions/OwnerOfResponse" + } + ] + }, + "info": { + "description": "Data on the token itself,", + "allOf": [ + { + "$ref": "#/definitions/NftInfoResponse_for_Empty" + } + ] + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "NftInfoResponse_for_Empty": { + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "OwnerOfResponse": { + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_operators_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_operators_response.json new file mode 100644 index 000000000..9d4d7bd7d --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_operators_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllOperatorsResponse", + "type": "object", + "required": [ + "operators" + ], + "properties": { + "operators": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_tokens_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_tokens_response.json new file mode 100644 index 000000000..22bf5bfd3 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/all_tokens_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllTokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approval_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approval_response.json new file mode 100644 index 000000000..4f45b42e9 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approval_response.json @@ -0,0 +1,94 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalResponse", + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "$ref": "#/definitions/Approval" + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approvals_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approvals_response.json new file mode 100644 index 000000000..8d8e39ea0 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/approvals_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalsResponse", + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/binary.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/binary.json new file mode 100644 index 000000000..10b45584f --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/binary.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/collection_info_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/collection_info_response.json new file mode 100644 index 000000000..d285d1113 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/collection_info_response.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CollectionInfoResponse", + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/contract_info_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/contract_info_response.json new file mode 100644 index 000000000..a16712589 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/contract_info_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ContractInfoResponse", + "type": "object", + "required": [ + "name", + "symbol" + ], + "properties": { + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/execute_msg_for__empty.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/execute_msg_for__empty.json new file mode 100644 index 000000000..de12218ad --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/execute_msg_for__empty.json @@ -0,0 +1,308 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg_for_Empty", + "description": "This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this.", + "oneOf": [ + { + "description": "Transfer is a base message to move a token to another account without triggering actions", + "type": "object", + "required": [ + "transfer_nft" + ], + "properties": { + "transfer_nft": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Send is a base message to transfer a token to a contract and trigger an action on the receiving contract.", + "type": "object", + "required": [ + "send_nft" + ], + "properties": { + "send_nft": { + "type": "object", + "required": [ + "contract", + "msg", + "token_id" + ], + "properties": { + "contract": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve" + ], + "properties": { + "approve": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted Approval", + "type": "object", + "required": [ + "revoke" + ], + "properties": { + "revoke": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve_all" + ], + "properties": { + "approve_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted ApproveAll permission", + "type": "object", + "required": [ + "revoke_all" + ], + "properties": { + "revoke_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Mint a new NFT, can only be called by the contract minter", + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "$ref": "#/definitions/MintMsg_for_Empty" + } + }, + "additionalProperties": false + }, + { + "description": "Burn an NFT the sender has access to", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "MintMsg_for_Empty": { + "type": "object", + "required": [ + "extension", + "owner", + "token_id" + ], + "properties": { + "extension": { + "description": "Any custom extension used by this contract", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "owner": { + "description": "The owner of the newly minter NFT", + "type": "string" + }, + "token_id": { + "description": "Unique ID of the NFT", + "type": "string" + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/instantiate_msg.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/instantiate_msg.json new file mode 100644 index 000000000..fb28071b6 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/instantiate_msg.json @@ -0,0 +1,81 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "collection_info", + "minter", + "name", + "symbol" + ], + "properties": { + "collection_info": { + "$ref": "#/definitions/CollectionInfo_for_RoyaltyInfoResponse" + }, + "minter": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "definitions": { + "CollectionInfo_for_RoyaltyInfoResponse": { + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + } + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/minter_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/minter_response.json new file mode 100644 index 000000000..a20e0d767 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/minter_response.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MinterResponse", + "description": "Shows who can mint these tokens", + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/nft_info_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/nft_info_response.json new file mode 100644 index 000000000..dbfef6713 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/nft_info_response.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NftInfoResponse", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/num_tokens_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/num_tokens_response.json new file mode 100644 index 000000000..4647c23aa --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/num_tokens_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NumTokensResponse", + "type": "object", + "required": [ + "count" + ], + "properties": { + "count": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/operators_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/operators_response.json new file mode 100644 index 000000000..53703072c --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/operators_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OperatorsResponse", + "type": "object", + "required": [ + "operators" + ], + "properties": { + "operators": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/owner_of_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/owner_of_response.json new file mode 100644 index 000000000..1258d671f --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/owner_of_response.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OwnerOfResponse", + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/query_msg.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/query_msg.json new file mode 100644 index 000000000..3cb271651 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/query_msg.json @@ -0,0 +1,284 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "owner_of" + ], + "properties": { + "owner_of": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_operators" + ], + "properties": { + "all_operators": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "num_tokens" + ], + "properties": { + "num_tokens": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "contract_info" + ], + "properties": { + "contract_info": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "nft_info" + ], + "properties": { + "nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_nft_info" + ], + "properties": { + "all_nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_tokens" + ], + "properties": { + "all_tokens": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "collection_info" + ], + "properties": { + "collection_info": { + "type": "object" + } + }, + "additionalProperties": false + } + ] +} diff --git a/boilerplates/node-typescript/contracts/stargaze-sg721/schema/tokens_response.json b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/tokens_response.json new file mode 100644 index 000000000..b8e3d75b5 --- /dev/null +++ b/boilerplates/node-typescript/contracts/stargaze-sg721/schema/tokens_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "TokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/boilerplates/node-typescript/jest.config.cjs b/boilerplates/node-typescript/jest.config.cjs new file mode 100644 index 000000000..a58c252f8 --- /dev/null +++ b/boilerplates/node-typescript/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node' +}; diff --git a/boilerplates/node-typescript/package.json b/boilerplates/node-typescript/package.json new file mode 100644 index 000000000..a0bbb508e --- /dev/null +++ b/boilerplates/node-typescript/package.json @@ -0,0 +1,70 @@ +{ + "name": "__PACKAGE_IDENTIFIER__", + "version": "0.0.1", + "description": "__MODULEDESC__", + "author": "__USERFULLNAME__ <__USEREMAIL__>", + "homepage": "https://github.com/__USERNAME__/__MODULENAME__#readme", + "license": "SEE LICENSE IN LICENSE", + "type": "module", + "main": "dist/index.js", + "module": "dist/index.mjs", + "typings": "dist/index.d.ts", + "directories": { + "lib": "src" + }, + "files": [ + "dist", + "!CHANGELOG.md" + ], + "nodemonConfig": { + "ext": "js,json,ts,tsx" + }, + "scripts": { + "build:cjs": "yarn tsc -p tsconfig.json --outDir dist --module commonjs || true", + "build:mjs": "yarn tsc -p tsconfig.json --outDir mjs --module es2022 --declaration false || true", + "clean:mjs": "rimraf mjs", + "clean:dist": "rimraf dist", + "clean": "npm run clean:mjs && npm run clean:dist", + "build:rename": "publish-scripts --cmd rename --srcDir mjs --outDir dist --findExt js --replaceExt mjs --no-rmDir", + "build": "npm run clean && npm run build:cjs && npm run build:mjs && npm run build:rename", + "codegen": "node scripts/codegen.cjs", + "prepare": "npm run build", + "dev": "ts-node-esm ./src/index.ts", + "watch": "nodemon --exec \"yarn dev\"", + "lint": "eslint src --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:debug": "node --inspect node_modules/.bin/jest --runInBand" + }, + "publishConfig": { + "access": "__ACCESS__" + }, + "repository": { + "type": "git", + "url": "https://github.com/__USERNAME__/__MODULENAME__" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/__USERNAME__/__MODULENAME__/issues" + }, + "devDependencies": { + "@types/jest": "^29.5.3", + "@cosmwasm/ts-codegen": "^0.31.6", + "eslint": "8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.6.1", + "jest-in-case": "^1.0.2", + "nodemon": "^3.0.1", + "prettier": "^3.0.0", + "publish-scripts": "0.1.0", + "rimraf": "^5.0.0", + "ts-jest": "^29.1.0", + "ts-node": "^10.9.1", + "ts-node-dev": "^2.0.0", + "typescript": "^5.0.4" + }, + "dependencies": { + "@cosmjs/cosmwasm-stargate": "^0.31.0" + } +} \ No newline at end of file diff --git a/boilerplates/node-typescript/scripts/codegen.cjs b/boilerplates/node-typescript/scripts/codegen.cjs new file mode 100644 index 000000000..af72c3f68 --- /dev/null +++ b/boilerplates/node-typescript/scripts/codegen.cjs @@ -0,0 +1,29 @@ +const codegen = require('@cosmwasm/ts-codegen').default; + +codegen({ + contracts: [ + { + name: 'SG721', + dir: './contracts/stargaze-sg721/schema' + }, + { + name: 'Minter', + dir: './contracts/stargaze-minter/schema' + } + ], + outPath: './src/', + options: { + bundle: { + bundleFile: 'index.ts', + scope: 'contracts' + }, + messageComposer: { + enabled: true + }, + useContractsHooks: { + enabled: false // if you enable this, add react! + } + } +}).then(() => { + console.log('✨ all done!'); +}); diff --git a/boilerplates/node-typescript/src/index.ts b/boilerplates/node-typescript/src/index.ts new file mode 100644 index 000000000..619fbdd60 --- /dev/null +++ b/boilerplates/node-typescript/src/index.ts @@ -0,0 +1 @@ +export { }; \ No newline at end of file diff --git a/boilerplates/node-typescript/tsconfig.json b/boilerplates/node-typescript/tsconfig.json new file mode 100644 index 000000000..6dd3cb22e --- /dev/null +++ b/boilerplates/node-typescript/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "skipLibCheck": true, + "emitDeclarationOnly": false, + "declaration": true, + "esModuleInterop": true, + "target": "es2022", + "module": "es2022", + "lib": [ + "es2022", + "DOM" + ], + "sourceMap": true, + "isolatedModules": true, + "allowJs": true, + "downlevelIteration": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "jsx": "react" + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/templates/placeholder-connect-multi-chain/.editorconfig b/boilerplates/telescope-npm-module/.editorconfig similarity index 100% rename from templates/placeholder-connect-multi-chain/.editorconfig rename to boilerplates/telescope-npm-module/.editorconfig diff --git a/templates/placeholder-connect-multi-chain/.eslintignore b/boilerplates/telescope-npm-module/.eslintignore similarity index 100% rename from templates/placeholder-connect-multi-chain/.eslintignore rename to boilerplates/telescope-npm-module/.eslintignore diff --git a/templates/placeholder-connect-multi-chain/.eslintrc.js b/boilerplates/telescope-npm-module/.eslintrc.js similarity index 100% rename from templates/placeholder-connect-multi-chain/.eslintrc.js rename to boilerplates/telescope-npm-module/.eslintrc.js diff --git a/boilerplates/telescope-npm-module/.gitignore b/boilerplates/telescope-npm-module/.gitignore new file mode 100644 index 000000000..7bba65cc8 --- /dev/null +++ b/boilerplates/telescope-npm-module/.gitignore @@ -0,0 +1,50 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# out +dist +mjs +main +module + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# Editors +.idea + +# Lib +lib + +# npm package lock +package-lock.json +yarn.lock + +# others +.DS_Store \ No newline at end of file diff --git a/templates/placeholder-connect-multi-chain/.npmignore b/boilerplates/telescope-npm-module/.npmignore similarity index 100% rename from templates/placeholder-connect-multi-chain/.npmignore rename to boilerplates/telescope-npm-module/.npmignore diff --git a/templates/placeholder-connect-multi-chain/.npmrc b/boilerplates/telescope-npm-module/.npmrc similarity index 100% rename from templates/placeholder-connect-multi-chain/.npmrc rename to boilerplates/telescope-npm-module/.npmrc diff --git a/boilerplates/telescope-npm-module/.questions.json b/boilerplates/telescope-npm-module/.questions.json new file mode 100644 index 000000000..97662fb62 --- /dev/null +++ b/boilerplates/telescope-npm-module/.questions.json @@ -0,0 +1,42 @@ +[ + { + "name": "__CHAINNAME__", + "message": "Enter chain name in all lowercase, e.g. osmosis", + "required": true + }, + { + "name": "__USERFULLNAME__", + "message": "Enter author full name", + "required": true + }, + { + "name": "__USEREMAIL__", + "message": "Enter author email", + "required": true + }, + { + "name": "__MODULENAME__", + "message": "Enter the module name", + "required": true + }, + { + "name": "__MODULEDESC__", + "message": "Enter the module description", + "required": true + }, + { + "name": "__USERNAME__", + "message": "Enter your github username", + "required": true + }, + { + "name": "__ACCESS__", + "message": "Module access?", + "choices": [ + "public", + "restricted" + ], + "type": "list", + "required": true + } +] \ No newline at end of file diff --git a/boilerplates/telescope-npm-module/.vscode/settings.json b/boilerplates/telescope-npm-module/.vscode/settings.json new file mode 100644 index 000000000..55c8b9bba --- /dev/null +++ b/boilerplates/telescope-npm-module/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "editor.formatOnSave": true, + "[javascriptreact]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": [ + "javascript", + "javascriptreact" + ] + } \ No newline at end of file diff --git a/templates/placeholder-connect-multi-chain/LICENSE b/boilerplates/telescope-npm-module/LICENSE similarity index 95% rename from templates/placeholder-connect-multi-chain/LICENSE rename to boilerplates/telescope-npm-module/LICENSE index b0b3013a6..78191bf06 100644 --- a/templates/placeholder-connect-multi-chain/LICENSE +++ b/boilerplates/telescope-npm-module/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2022 Dan Lynch +Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/boilerplates/telescope-npm-module/README.md b/boilerplates/telescope-npm-module/README.md new file mode 100644 index 000000000..0f4186ce6 --- /dev/null +++ b/boilerplates/telescope-npm-module/README.md @@ -0,0 +1,290 @@ +# __MODULENAME__ + +

+
+ __MODULEDESC__ +

+ + +## install + +```sh +npm install __MODULENAME__ +``` +## Table of contents + +- [__MODULENAME__](#__MODULENAME__) + - [Install](#install) + - [Table of contents](#table-of-contents) +- [Usage](#usage) + - [RPC Clients](#rpc-clients) + - [Composing Messages](#composing-messages) + - Cosmos, CosmWasm, and IBC + - [CosmWasm](#cosmwasm-messages) + - [IBC](#ibc-messages) + - [Cosmos](#cosmos-messages) +- [Wallets and Signers](#connecting-with-wallets-and-signing-messages) + - [Stargate Client](#initializing-the-stargate-client) + - [Creating Signers](#creating-signers) + - [Broadcasting Messages](#broadcasting-messages) +- [Advanced Usage](#advanced-usage) +- [Developing](#developing) +- [Credits](#credits) + +## Usage +### RPC Clients + +```js +import { __CHAINNAME__ } from '__MODULENAME__'; + +const { createRPCQueryClient } = __CHAINNAME__.ClientFactory; +const client = await createRPCQueryClient({ rpcEndpoint: RPC_ENDPOINT }); + +// now you can query the cosmos modules +const balance = await client.cosmos.bank.v1beta1 + .allBalances({ address: '__CHAINNAME__1addresshere' }); + +// you can also query the __CHAINNAME__ modules +const balances = await client.__CHAINNAME__.exchange.v1beta1 + .exchangeBalances() +``` + +### Composing Messages + +Import the `__CHAINNAME__` object from `__MODULENAME__`. + +```js +import { __CHAINNAME__ } from '__MODULENAME__'; + +const { + createSpotLimitOrder, + createSpotMarketOrder, + deposit +} = __CHAINNAME__.exchange.v1beta1.MessageComposer.withTypeUrl; +``` + +#### CosmWasm Messages + +```js +import { cosmwasm } from "__MODULENAME__"; + +const { + clearAdmin, + executeContract, + instantiateContract, + migrateContract, + storeCode, + updateAdmin +} = cosmwasm.wasm.v1.MessageComposer.withTypeUrl; +``` + +#### IBC Messages + +```js +import { ibc } from '__MODULENAME__'; + +const { + transfer +} = ibc.applications.transfer.v1.MessageComposer.withTypeUrl +``` + +#### Cosmos Messages + +```js +import { cosmos } from '__MODULENAME__'; + +const { + fundCommunityPool, + setWithdrawAddress, + withdrawDelegatorReward, + withdrawValidatorCommission +} = cosmos.distribution.v1beta1.MessageComposer.fromPartial; + +const { + multiSend, + send +} = cosmos.bank.v1beta1.MessageComposer.fromPartial; + +const { + beginRedelegate, + createValidator, + delegate, + editValidator, + undelegate +} = cosmos.staking.v1beta1.MessageComposer.fromPartial; + +const { + deposit, + submitProposal, + vote, + voteWeighted +} = cosmos.gov.v1beta1.MessageComposer.fromPartial; +``` + +## Connecting with Wallets and Signing Messages + +⚡️ For web interfaces, we recommend using [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit). Continue below to see how to manually construct signers and clients. + +Here are the docs on [creating signers](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) in cosmos-kit that can be used with Keplr and other wallets. + +### Initializing the Stargate Client + +Use `getSigning__CHAINNAME__Client` to get your `SigningStargateClient`, with the proto/amino messages full-loaded. No need to manually add amino types, just require and initialize the client: + +```js +import { getSigning__CHAINNAME__Client } from '__MODULENAME__'; + +const stargateClient = await getSigning__CHAINNAME__Client({ + rpcEndpoint, + signer // OfflineSigner +}); +``` +### Creating Signers + +To broadcast messages, you can create signers with a variety of options: + +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit/tree/main/packages/react#signing-clients) (recommended) +* [keplr](https://docs.keplr.app/api/cosmjs.html) +* [cosmjs](https://gist.github.com/webmaster128/8444d42a7eceeda2544c8a59fbd7e1d9) +### Amino Signer + +Likely you'll want to use the Amino, so unless you need proto, you should use this one: + +```js +import { getOfflineSignerAmino as getOfflineSigner } from 'cosmjs-utils'; +``` +### Proto Signer + +```js +import { getOfflineSignerProto as getOfflineSigner } from 'cosmjs-utils'; +``` + +WARNING: NOT RECOMMENDED TO USE PLAIN-TEXT MNEMONICS. Please take care of your security and use best practices such as AES encryption and/or methods from 12factor applications. + +```js +import { chains } from 'chain-registry'; + +const mnemonic = + 'unfold client turtle either pilot stock floor glow toward bullet car science'; + const chain = chains.find(({ chain_name }) => chain_name === '__CHAINNAME__'); + const signer = await getOfflineSigner({ + mnemonic, + chain + }); +``` +### Broadcasting Messages + +Now that you have your `stargateClient`, you can broadcast messages: + +```js +const { send } = cosmos.bank.v1beta1.MessageComposer.withTypeUrl; + +const msg = send({ + amount: [ + { + denom: 'coin', + amount: '1000' + } + ], + toAddress: address, + fromAddress: address +}); + +const fee: StdFee = { + amount: [ + { + denom: 'coin', + amount: '864' + } + ], + gas: '86364' +}; +const response = await stargateClient.signAndBroadcast(address, [msg], fee); +``` + +## Advanced Usage + + +If you want to manually construct a stargate client + +```js +import { OfflineSigner, GeneratedType, Registry } from "@cosmjs/proto-signing"; +import { AminoTypes, SigningStargateClient } from "@cosmjs/stargate"; + +import { + cosmosAminoConverters, + cosmosProtoRegistry, + cosmwasmAminoConverters, + cosmwasmProtoRegistry, + ibcProtoRegistry, + ibcAminoConverters, + __CHAINNAME__AminoConverters, + __CHAINNAME__ProtoRegistry +} from '__MODULENAME__'; + +const signer: OfflineSigner = /* create your signer (see above) */ +const rpcEndpint = 'https://rpc.cosmos.directory/__CHAINNAME__'; // or another URL + +const protoRegistry: ReadonlyArray<[string, GeneratedType]> = [ + ...cosmosProtoRegistry, + ...cosmwasmProtoRegistry, + ...ibcProtoRegistry, + ...__CHAINNAME__ProtoRegistry +]; + +const aminoConverters = { + ...cosmosAminoConverters, + ...cosmwasmAminoConverters, + ...ibcAminoConverters, + ...__CHAINNAME__AminoConverters +}; + +const registry = new Registry(protoRegistry); +const aminoTypes = new AminoTypes(aminoConverters); + +const stargateClient = await SigningStargateClient.connectWithSigner(rpcEndpoint, signer, { + registry, + aminoTypes +}); +``` + +## Developing + +When first cloning the repo: + +``` +yarn +yarn build +``` + +### Codegen + +Contract schemas live in `./contracts`, and protos in `./proto`. Look inside of `scripts/codegen.js` and configure the settings for bundling your SDK and contracts into `__MODULENAME__`: + +``` +yarn codegen +``` + +### Publishing + +Build the types and then publish: + +``` +yarn build +yarn publish +``` +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + +Code built with the help of these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️ + +## Disclaimer + +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. + +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. diff --git a/boilerplates/telescope-npm-module/__tests__/messages.test.ts b/boilerplates/telescope-npm-module/__tests__/messages.test.ts new file mode 100644 index 000000000..52f8a3c61 --- /dev/null +++ b/boilerplates/telescope-npm-module/__tests__/messages.test.ts @@ -0,0 +1,3 @@ +it('it works', () => { + console.log('it works!'); +}); diff --git a/boilerplates/telescope-npm-module/jest.config.cjs b/boilerplates/telescope-npm-module/jest.config.cjs new file mode 100644 index 000000000..a58c252f8 --- /dev/null +++ b/boilerplates/telescope-npm-module/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node' +}; diff --git a/boilerplates/telescope-npm-module/package.json b/boilerplates/telescope-npm-module/package.json new file mode 100644 index 000000000..c0eddefa0 --- /dev/null +++ b/boilerplates/telescope-npm-module/package.json @@ -0,0 +1,63 @@ +{ + "name": "__PACKAGE_IDENTIFIER__", + "version": "0.0.1", + "description": "__MODULEDESC__", + "author": "__USERFULLNAME__ <__USEREMAIL__>", + "homepage": "https://github.com/__USERNAME__/__MODULENAME__#readme", + "license": "SEE LICENSE IN LICENSE", + "main": "dist/index.js", + "module": "dist/index.mjs", + "typings": "dist/index.d.ts", + "directories": { + "lib": "src" + }, + "files": [ + "dist", + "!CHANGELOG.md" + ], + "scripts": { + "build:cjs": "yarn tsc -p tsconfig.json --outDir dist --module commonjs || true", + "build:mjs": "yarn tsc -p tsconfig.json --outDir mjs --module es2022 --declaration false || true", + "clean:mjs": "rimraf mjs", + "clean:dist": "rimraf dist", + "clean": "npm run clean:mjs && npm run clean:dist", + "build:rename": "publish-scripts --cmd rename --srcDir mjs --outDir dist --findExt js --replaceExt mjs --no-rmDir", + "build": "npm run clean && npm run build:cjs && npm run build:mjs && npm run build:rename", + "codegen": "node scripts/codegen.js", + "prepare": "npm run build", + "lint": "eslint src --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:debug": "node --inspect node_modules/.bin/jest --runInBand" + }, + "publishConfig": { + "access": "__ACCESS__" + }, + "repository": { + "type": "git", + "url": "https://github.com/__USERNAME__/__MODULENAME__" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/__USERNAME__/__MODULENAME__/issues" + }, + "devDependencies": { + "@cosmology/telescope": "^0.102.0", + "@types/jest": "^29.5.0", + "eslint": "8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^4.2.1", + "jest": "^29.5.0", + "prettier": "^2.8.7", + "publish-scripts": "0.1.0", + "rimraf": "^5.0.0", + "ts-jest": "^29.1.0", + "typescript": "^5.0.4" + }, + "dependencies": { + "@cosmjs/amino": "0.29.4", + "@cosmjs/proto-signing": "0.29.4", + "@cosmjs/stargate": "0.29.4", + "@cosmjs/tendermint-rpc": "^0.29.4" + } +} \ No newline at end of file diff --git a/boilerplates/telescope-npm-module/scripts/aminos.js b/boilerplates/telescope-npm-module/scripts/aminos.js new file mode 100644 index 000000000..fe7aee16c --- /dev/null +++ b/boilerplates/telescope-npm-module/scripts/aminos.js @@ -0,0 +1,29 @@ +module.exports.AMINO_MAP = { + // PUT YOUR AMINO names here... + // Staking + // '/cosmos.staking.v1beta1.MsgCreateValidator': { + // aminoType: 'cosmos-sdk/MsgCreateValidator' + // }, + // '/cosmos.staking.v1beta1.MsgEditValidator': { + // aminoType: 'cosmos-sdk/MsgEditValidator' + // }, + // '/cosmos.staking.v1beta1.MsgDelegate': { + // aminoType: 'cosmos-sdk/MsgDelegate' + // }, + // '/cosmos.staking.v1beta1.MsgUndelegate': { + // aminoType: 'cosmos-sdk/MsgUndelegate' + // }, + // '/cosmos.staking.v1beta1.MsgBeginRedelegate': { + // aminoType: 'cosmos-sdk/MsgBeginRedelegate' + // }, + // '/cosmos.staking.v1beta1.MsgCancelUnbondingDelegation': { + // aminoType: 'cosmos-sdk/MsgCancelUnbondingDelegation' + // }, + // '/cosmos.staking.v1beta1.MsgUpdateParams': { + // aminoType: 'cosmos-sdk/x/staking/MsgUpdateParams' + // }, + // // IBC + // '/ibc.applications.transfer.v1.MsgTransfer': { + // aminoType: 'cosmos-sdk/MsgTransfer' + // } +}; diff --git a/boilerplates/telescope-npm-module/scripts/codegen.js b/boilerplates/telescope-npm-module/scripts/codegen.js new file mode 100644 index 000000000..3b3fa31b8 --- /dev/null +++ b/boilerplates/telescope-npm-module/scripts/codegen.js @@ -0,0 +1,107 @@ +const { join } = require('path'); +const telescope = require('@cosmology/telescope').default; +const rimraf = require('rimraf').rimrafSync; +const { AMINO_MAP } = require('./aminos'); + +const protoDirs = [join(__dirname, '/../proto')]; +const outPath = join(__dirname, '../src/codegen'); +rimraf(outPath); + +telescope({ + protoDirs, + outPath, + options: { + tsDisable: { + files: [ + 'cosmos/authz/v1beta1/tx.amino.ts', + 'cosmos/staking/v1beta1/tx.amino.ts' + ], + patterns: ['**/*amino.ts', '**/*registry.ts'] + }, + prototypes: { + includePackageVar: false, + removeUnusedImports: true, + experimentalGlobalProtoNamespace: true, + interfaces: { + enabled: true, + useUnionTypes: false + }, + excluded: { + packages: [ + // 'ibc.applications.fee.v1', + + 'cosmos.app.v1alpha1', + 'cosmos.app.v1beta1', + 'cosmos.autocli.v1', + 'cosmos.base.kv.v1beta1', + 'cosmos.base.reflection.v1beta1', + 'cosmos.base.snapshots.v1beta1', + 'cosmos.base.store.v1beta1', + 'cosmos.base.tendermint.v1beta1', + 'cosmos.capability.v1beta1', + 'cosmos.crisis.v1beta1', + 'cosmos.evidence.v1beta1', + 'cosmos.feegrant.v1beta1', + 'cosmos.genutil.v1beta1', + 'cosmos.gov.v1', + 'cosmos.group.v1', + 'cosmos.group.v1beta1', + 'cosmos.mint.v1beta1', + 'cosmos.msg.v1', + 'cosmos.nft.v1beta1', + 'cosmos.orm.v1', + 'cosmos.orm.v1alpha1', + 'cosmos.params.v1beta1', + 'cosmos.slashing.v1beta1', + 'cosmos.vesting.v1beta1', + // 'google.api', + 'ibc.core.port.v1', + 'ibc.core.types.v1' + ] + }, + methods: { + fromJSON: false, + toJSON: false, + encode: true, + decode: true, + fromPartial: true, + toAmino: true, + fromAmino: true, + fromProto: true, + toProto: true + }, + parser: { + keepCase: false + } + }, + typingsFormat: { + duration: 'duration', + timestamp: 'date', + useExact: false, + useDeepPartial: false, + num64: 'bigint', + customTypes: { + useCosmosSDKDec: true + } + }, + aminoEncoding: { + enabled: true, + exceptions: AMINO_MAP, + useRecursiveV2encoding: true + }, + lcdClients: { + enabled: false + }, + rpcClients: { + enabled: true, + camelCase: true + } + } +}) + .then(() => { + console.log('✨ all done!'); + }) + .catch((e) => { + console.error(e); + process.exit(1); + }); diff --git a/boilerplates/telescope-npm-module/src/index.ts b/boilerplates/telescope-npm-module/src/index.ts new file mode 100644 index 000000000..646541b59 --- /dev/null +++ b/boilerplates/telescope-npm-module/src/index.ts @@ -0,0 +1 @@ +export * from './codegen'; diff --git a/boilerplates/telescope-npm-module/tsconfig.json b/boilerplates/telescope-npm-module/tsconfig.json new file mode 100644 index 000000000..38eee4ccf --- /dev/null +++ b/boilerplates/telescope-npm-module/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "skipLibCheck": true, + "emitDeclarationOnly": false, + "declaration": true, + "esModuleInterop": true, + "target": "es2022", + "module": "es2022", + "lib": [ + "es2022", + "DOM" + ], + "sourceMap": true, + "isolatedModules": true, + "allowJs": true, + "downlevelIteration": true, + "moduleResolution": "node", + "resolveJsonModule": true + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/.editorconfig b/boilerplates/ts-codegen-npm-module/.editorconfig new file mode 100644 index 000000000..4a7ea3036 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/boilerplates/ts-codegen-npm-module/.eslintignore b/boilerplates/ts-codegen-npm-module/.eslintignore new file mode 100644 index 000000000..38ba48499 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.eslintignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +main/ +module/ +coverage/ \ No newline at end of file diff --git a/.eslintrc.js b/boilerplates/ts-codegen-npm-module/.eslintrc.js similarity index 91% rename from .eslintrc.js rename to boilerplates/ts-codegen-npm-module/.eslintrc.js index c11d7e022..2718e8bc4 100644 --- a/.eslintrc.js +++ b/boilerplates/ts-codegen-npm-module/.eslintrc.js @@ -1,9 +1,10 @@ module.exports = { plugins: ['prettier'], extends: ['eslint:recommended', 'prettier'], - parser: 'babel-eslint', + parser: '@babel/eslint-parser', parserOptions: { ecmaVersion: 11, + requireConfigFile: false, sourceType: 'module', ecmaFeatures: { jsx: true @@ -31,7 +32,7 @@ module.exports = { 0, { ignoreSiblings: true, - argsIgnorePattern: 'res|next|^_' + argsIgnorePattern: 'React|res|next|^_' } ], 'prefer-const': [ diff --git a/templates/placeholder-connect-multi-chain/.gitignore b/boilerplates/ts-codegen-npm-module/.gitignore similarity index 98% rename from templates/placeholder-connect-multi-chain/.gitignore rename to boilerplates/ts-codegen-npm-module/.gitignore index d93985ec4..9cd5f4164 100644 --- a/templates/placeholder-connect-multi-chain/.gitignore +++ b/boilerplates/ts-codegen-npm-module/.gitignore @@ -9,6 +9,8 @@ pids *.seed # dist +dist +mjs main module diff --git a/boilerplates/ts-codegen-npm-module/.npmignore b/boilerplates/ts-codegen-npm-module/.npmignore new file mode 100644 index 000000000..cc2605fa8 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.npmignore @@ -0,0 +1,32 @@ +*.log +npm-debug.log* + +# Coverage directory used by tools like istanbul +coverage +.nyc_output + +# Dependency directories +node_modules + +# npm package lock +package-lock.json +yarn.lock + +# project files +__fixtures__ +__tests__ +.babelrc +.babelrc.js +.editorconfig +.eslintignore +.eslintrc +.eslintrc.js +.gitignore +.travis.yml +.vscode +CHANGELOG.md +examples +jest.config.js +package.json +src +test \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/.npmrc b/boilerplates/ts-codegen-npm-module/.npmrc new file mode 100644 index 000000000..a21347f1b --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.npmrc @@ -0,0 +1 @@ +scripts-prepend-node-path=true \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/.questions.json b/boilerplates/ts-codegen-npm-module/.questions.json new file mode 100644 index 000000000..c1549e7cc --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.questions.json @@ -0,0 +1,37 @@ +[ + { + "name": "__USERFULLNAME__", + "message": "Enter author full name", + "required": true + }, + { + "name": "__USEREMAIL__", + "message": "Enter author email", + "required": true + }, + { + "name": "__MODULENAME__", + "message": "Enter the module name", + "required": true + }, + { + "name": "__MODULEDESC__", + "message": "Enter the module description", + "required": true + }, + { + "name": "__USERNAME__", + "message": "Enter your github username", + "required": true + }, + { + "name": "__ACCESS__", + "message": "Module access?", + "choices": [ + "public", + "restricted" + ], + "type": "list", + "required": true + } +] \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/.vscode/settings.json b/boilerplates/ts-codegen-npm-module/.vscode/settings.json new file mode 100644 index 000000000..55c8b9bba --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "editor.formatOnSave": true, + "[javascriptreact]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": [ + "javascript", + "javascriptreact" + ] + } \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/LICENSE b/boilerplates/ts-codegen-npm-module/LICENSE new file mode 100644 index 000000000..78191bf06 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/boilerplates/ts-codegen-npm-module/README.md b/boilerplates/ts-codegen-npm-module/README.md new file mode 100644 index 000000000..16ad51fd7 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/README.md @@ -0,0 +1,60 @@ +# __MODULENAME__ + +

+
+ __MODULEDESC__ +

+ +## install + +```sh +npm install __MODULENAME__ +``` +## Table of contents + +- [__MODULENAME__](#__MODULENAME__) + - [Install](#install) + - [Table of contents](#table-of-contents) +- [Developing](#developing) +- [Credits](#credits) + +## Developing + +When first cloning the repo: + +``` +yarn +yarn build +``` + +### Codegen + +Contract schemas live in `./contracts`. Look inside of `scripts/codegen.js` and configure the settings for bundling your SDK and contracts into `__MODULENAME__`: + +``` +yarn codegen +``` + +### Publishing + +Build the types and then publish: + +``` +yarn build +yarn publish +``` +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + +Code built with the help of these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️ + +## Disclaimer + +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. + +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. diff --git a/boilerplates/ts-codegen-npm-module/__tests__/example.test.ts b/boilerplates/ts-codegen-npm-module/__tests__/example.test.ts new file mode 100644 index 000000000..3f7425dd7 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/__tests__/example.test.ts @@ -0,0 +1,3 @@ +it('it works', () => { + console.log('it works!') +}); \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/LICENSE b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/LICENSE new file mode 100644 index 000000000..edc7db470 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Public Awesome LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/README.md b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/README.md new file mode 100644 index 000000000..da81535ac --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/README.md @@ -0,0 +1 @@ +# Stargaze minter \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/package.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/package.json new file mode 100644 index 000000000..52a2c328a --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/package.json @@ -0,0 +1,21 @@ +{ + "name": "@cosmjson/stargaze-minter", + "chain": "stargaze", + "contract": "minter", + "version": "0.0.7", + "description": "stargaze", + "author": "Dan Lynch ", + "homepage": "https://github.com/cosmology-tech/cosmjson/tree/master/packages/stargaze#readme", + "license": "SEE LICENSE IN LICENSE", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/cosmology-tech/cosmjson" + }, + "bugs": { + "url": "https://github.com/cosmology-tech/cosmjson/issues" + }, + "gitHead": "2d1a7b9aa6c3ac7596dbea4211180fd5c7235513" +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config.json new file mode 100644 index 000000000..e64ef338f --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config.json @@ -0,0 +1,90 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Config", + "type": "object", + "required": [ + "admin", + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_code_id", + "start_time", + "unit_price" + ], + "properties": { + "admin": { + "$ref": "#/definitions/Addr" + }, + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "anyOf": [ + { + "$ref": "#/definitions/Addr" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Addr": { + "description": "A human readable address.\n\nIn Cosmos, this is typically bech32 encoded. But for multi-chain smart contracts no assumptions should be made other than being UTF-8 encoded and of reasonable length.\n\nThis type represents a validated address. It can be created in the following ways 1. Use `Addr::unchecked(input)` 2. Use `let checked: Addr = deps.api.addr_validate(input)?` 3. Use `let checked: Addr = deps.api.addr_humanize(canonical_addr)?` 4. Deserialize from JSON. This must only be done from JSON that was validated before such as a contract's state. `Addr` must not be used in messages sent by the user because this would result in unvalidated instances.\n\nThis type is immutable. If you really need to mutate it (Really? Are you sure?), create a mutable copy using `let mut mutable = Addr::to_string()` and operate on that `String` instance.", + "type": "string" + }, + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config_response.json new file mode 100644 index 000000000..b400751e2 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/config_response.json @@ -0,0 +1,86 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ConfigResponse", + "type": "object", + "required": [ + "admin", + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_address", + "sg721_code_id", + "start_time", + "unit_price" + ], + "properties": { + "admin": { + "type": "string" + }, + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_address": { + "type": "string" + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/execute_msg.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/execute_msg.json new file mode 100644 index 000000000..e0763c569 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/execute_msg.json @@ -0,0 +1,144 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "set_whitelist" + ], + "properties": { + "set_whitelist": { + "type": "object", + "required": [ + "whitelist" + ], + "properties": { + "whitelist": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "update_start_time" + ], + "properties": { + "update_start_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "update_per_address_limit" + ], + "properties": { + "update_per_address_limit": { + "type": "object", + "required": [ + "per_address_limit" + ], + "properties": { + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_to" + ], + "properties": { + "mint_to": { + "type": "object", + "required": [ + "recipient" + ], + "properties": { + "recipient": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_for" + ], + "properties": { + "mint_for": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "withdraw" + ], + "properties": { + "withdraw": { + "type": "object" + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/instantiate_msg.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/instantiate_msg.json new file mode 100644 index 000000000..a618033d4 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/instantiate_msg.json @@ -0,0 +1,159 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "base_token_uri", + "num_tokens", + "per_address_limit", + "sg721_code_id", + "sg721_instantiate_msg", + "start_time", + "unit_price" + ], + "properties": { + "base_token_uri": { + "type": "string" + }, + "num_tokens": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "per_address_limit": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + }, + "sg721_code_id": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + }, + "sg721_instantiate_msg": { + "$ref": "#/definitions/InstantiateMsg" + }, + "start_time": { + "$ref": "#/definitions/Timestamp" + }, + "unit_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist": { + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "CollectionInfo_for_RoyaltyInfoResponse": { + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + } + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "InstantiateMsg": { + "type": "object", + "required": [ + "collection_info", + "minter", + "name", + "symbol" + ], + "properties": { + "collection_info": { + "$ref": "#/definitions/CollectionInfo_for_RoyaltyInfoResponse" + }, + "minter": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_count_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_count_response.json new file mode 100644 index 000000000..dd7edbe67 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_count_response.json @@ -0,0 +1,19 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintCountResponse", + "type": "object", + "required": [ + "address", + "count" + ], + "properties": { + "address": { + "type": "string" + }, + "count": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_price_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_price_response.json new file mode 100644 index 000000000..628d25e44 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mint_price_response.json @@ -0,0 +1,48 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintPriceResponse", + "type": "object", + "required": [ + "current_price", + "public_price" + ], + "properties": { + "current_price": { + "$ref": "#/definitions/Coin" + }, + "public_price": { + "$ref": "#/definitions/Coin" + }, + "whitelist_price": { + "anyOf": [ + { + "$ref": "#/definitions/Coin" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Coin": { + "type": "object", + "required": [ + "amount", + "denom" + ], + "properties": { + "amount": { + "$ref": "#/definitions/Uint128" + }, + "denom": { + "type": "string" + } + } + }, + "Uint128": { + "description": "A thin wrapper around u128 that is using strings for JSON encoding/decoding, such that the full u128 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u128` to get the value out:\n\n``` # use cosmwasm_std::Uint128; let a = Uint128::from(123u128); assert_eq!(a.u128(), 123);\n\nlet b = Uint128::from(42u64); assert_eq!(b.u128(), 42);\n\nlet c = Uint128::from(70u32); assert_eq!(c.u128(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mintable_num_tokens_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mintable_num_tokens_response.json new file mode 100644 index 000000000..05a378f15 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/mintable_num_tokens_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MintableNumTokensResponse", + "type": "object", + "required": [ + "count" + ], + "properties": { + "count": { + "type": "integer", + "format": "uint32", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/query_msg.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/query_msg.json new file mode 100644 index 000000000..c97025f73 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/query_msg.json @@ -0,0 +1,74 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "config" + ], + "properties": { + "config": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mintable_num_tokens" + ], + "properties": { + "mintable_num_tokens": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "start_time" + ], + "properties": { + "start_time": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_price" + ], + "properties": { + "mint_price": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "mint_count" + ], + "properties": { + "mint_count": { + "type": "object", + "required": [ + "address" + ], + "properties": { + "address": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ] +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/start_time_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/start_time_response.json new file mode 100644 index 000000000..3dd3fe89f --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-minter/schema/start_time_response.json @@ -0,0 +1,13 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "StartTimeResponse", + "type": "object", + "required": [ + "start_time" + ], + "properties": { + "start_time": { + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/LICENSE b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/LICENSE new file mode 100644 index 000000000..edc7db470 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright 2022 Public Awesome LLC + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/README.md b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/README.md new file mode 100644 index 000000000..872489dfb --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/README.md @@ -0,0 +1 @@ +# Stargaze sg721 \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/package.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/package.json new file mode 100644 index 000000000..8a8165d3c --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/package.json @@ -0,0 +1,21 @@ +{ + "name": "@cosmjson/stargaze-sg721", + "chain": "stargaze", + "contract": "sg721", + "version": "0.0.7", + "description": "stargaze", + "author": "Dan Lynch ", + "homepage": "https://github.com/cosmology-tech/cosmjson/tree/master/packages/stargaze#readme", + "license": "SEE LICENSE IN LICENSE", + "publishConfig": { + "access": "public" + }, + "repository": { + "type": "git", + "url": "https://github.com/cosmology-tech/cosmjson" + }, + "bugs": { + "url": "https://github.com/cosmology-tech/cosmjson/issues" + }, + "gitHead": "2d1a7b9aa6c3ac7596dbea4211180fd5c7235513" +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_nft_info_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_nft_info_response.json new file mode 100644 index 000000000..930dadd44 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_nft_info_response.json @@ -0,0 +1,155 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllNftInfoResponse", + "type": "object", + "required": [ + "access", + "info" + ], + "properties": { + "access": { + "description": "Who can transfer the token", + "allOf": [ + { + "$ref": "#/definitions/OwnerOfResponse" + } + ] + }, + "info": { + "description": "Data on the token itself,", + "allOf": [ + { + "$ref": "#/definitions/NftInfoResponse_for_Empty" + } + ] + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "NftInfoResponse_for_Empty": { + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "OwnerOfResponse": { + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_operators_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_operators_response.json new file mode 100644 index 000000000..9d4d7bd7d --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_operators_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllOperatorsResponse", + "type": "object", + "required": [ + "operators" + ], + "properties": { + "operators": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_tokens_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_tokens_response.json new file mode 100644 index 000000000..22bf5bfd3 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/all_tokens_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "AllTokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approval_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approval_response.json new file mode 100644 index 000000000..4f45b42e9 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approval_response.json @@ -0,0 +1,94 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalResponse", + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "$ref": "#/definitions/Approval" + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approvals_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approvals_response.json new file mode 100644 index 000000000..8d8e39ea0 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/approvals_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ApprovalsResponse", + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/binary.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/binary.json new file mode 100644 index 000000000..10b45584f --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/binary.json @@ -0,0 +1,6 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "Binary", + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/collection_info_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/collection_info_response.json new file mode 100644 index 000000000..d285d1113 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/collection_info_response.json @@ -0,0 +1,58 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "CollectionInfoResponse", + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + }, + "definitions": { + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/contract_info_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/contract_info_response.json new file mode 100644 index 000000000..a16712589 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/contract_info_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ContractInfoResponse", + "type": "object", + "required": [ + "name", + "symbol" + ], + "properties": { + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/execute_msg_for__empty.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/execute_msg_for__empty.json new file mode 100644 index 000000000..de12218ad --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/execute_msg_for__empty.json @@ -0,0 +1,308 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "ExecuteMsg_for_Empty", + "description": "This is like Cw721ExecuteMsg but we add a Mint command for an owner to make this stand-alone. You will likely want to remove mint and use other control logic in any contract that inherits this.", + "oneOf": [ + { + "description": "Transfer is a base message to move a token to another account without triggering actions", + "type": "object", + "required": [ + "transfer_nft" + ], + "properties": { + "transfer_nft": { + "type": "object", + "required": [ + "recipient", + "token_id" + ], + "properties": { + "recipient": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Send is a base message to transfer a token to a contract and trigger an action on the receiving contract.", + "type": "object", + "required": [ + "send_nft" + ], + "properties": { + "send_nft": { + "type": "object", + "required": [ + "contract", + "msg", + "token_id" + ], + "properties": { + "contract": { + "type": "string" + }, + "msg": { + "$ref": "#/definitions/Binary" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send the token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve" + ], + "properties": { + "approve": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted Approval", + "type": "object", + "required": [ + "revoke" + ], + "properties": { + "revoke": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Allows operator to transfer / send any token from the owner's account. If expiration is set, then this allowance has a time/height limit", + "type": "object", + "required": [ + "approve_all" + ], + "properties": { + "approve_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "expires": { + "anyOf": [ + { + "$ref": "#/definitions/Expiration" + }, + { + "type": "null" + } + ] + }, + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Remove previously granted ApproveAll permission", + "type": "object", + "required": [ + "revoke_all" + ], + "properties": { + "revoke_all": { + "type": "object", + "required": [ + "operator" + ], + "properties": { + "operator": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "description": "Mint a new NFT, can only be called by the contract minter", + "type": "object", + "required": [ + "mint" + ], + "properties": { + "mint": { + "$ref": "#/definitions/MintMsg_for_Empty" + } + }, + "additionalProperties": false + }, + { + "description": "Burn an NFT the sender has access to", + "type": "object", + "required": [ + "burn" + ], + "properties": { + "burn": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + } + ], + "definitions": { + "Binary": { + "description": "Binary is a wrapper around Vec to add base64 de/serialization with serde. It also adds some helper methods to help encode inline.\n\nThis is only needed as serde-json-{core,wasm} has a horrible encoding for Vec", + "type": "string" + }, + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "MintMsg_for_Empty": { + "type": "object", + "required": [ + "extension", + "owner", + "token_id" + ], + "properties": { + "extension": { + "description": "Any custom extension used by this contract", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "owner": { + "description": "The owner of the newly minter NFT", + "type": "string" + }, + "token_id": { + "description": "Unique ID of the NFT", + "type": "string" + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + } + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/instantiate_msg.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/instantiate_msg.json new file mode 100644 index 000000000..fb28071b6 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/instantiate_msg.json @@ -0,0 +1,81 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "InstantiateMsg", + "type": "object", + "required": [ + "collection_info", + "minter", + "name", + "symbol" + ], + "properties": { + "collection_info": { + "$ref": "#/definitions/CollectionInfo_for_RoyaltyInfoResponse" + }, + "minter": { + "type": "string" + }, + "name": { + "type": "string" + }, + "symbol": { + "type": "string" + } + }, + "definitions": { + "CollectionInfo_for_RoyaltyInfoResponse": { + "type": "object", + "required": [ + "creator", + "description", + "image" + ], + "properties": { + "creator": { + "type": "string" + }, + "description": { + "type": "string" + }, + "external_link": { + "type": [ + "string", + "null" + ] + }, + "image": { + "type": "string" + }, + "royalty_info": { + "anyOf": [ + { + "$ref": "#/definitions/RoyaltyInfoResponse" + }, + { + "type": "null" + } + ] + } + } + }, + "Decimal": { + "description": "A fixed-point decimal value with 18 fractional digits, i.e. Decimal(1_000_000_000_000_000_000) == 1.0\n\nThe greatest possible value that can be represented is 340282366920938463463.374607431768211455 (which is (2^128 - 1) / 10^18)", + "type": "string" + }, + "RoyaltyInfoResponse": { + "type": "object", + "required": [ + "payment_address", + "share" + ], + "properties": { + "payment_address": { + "type": "string" + }, + "share": { + "$ref": "#/definitions/Decimal" + } + } + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/minter_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/minter_response.json new file mode 100644 index 000000000..a20e0d767 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/minter_response.json @@ -0,0 +1,14 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "MinterResponse", + "description": "Shows who can mint these tokens", + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/nft_info_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/nft_info_response.json new file mode 100644 index 000000000..dbfef6713 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/nft_info_response.json @@ -0,0 +1,31 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NftInfoResponse", + "type": "object", + "required": [ + "extension" + ], + "properties": { + "extension": { + "description": "You can add any custom metadata here when you extend cw721-base", + "allOf": [ + { + "$ref": "#/definitions/Empty" + } + ] + }, + "token_uri": { + "description": "Universal resource identifier for this NFT Should point to a JSON file that conforms to the ERC721 Metadata JSON Schema", + "type": [ + "string", + "null" + ] + } + }, + "definitions": { + "Empty": { + "description": "An empty struct that serves as a placeholder in different places, such as contracts that don't set a custom message.\n\nIt is designed to be expressable in correct JSON and JSON Schema but contains no meaningful data. Previously we used enums without cases, but those cannot represented as valid JSON Schema (https://github.com/CosmWasm/cosmwasm/issues/451)", + "type": "object" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/num_tokens_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/num_tokens_response.json new file mode 100644 index 000000000..4647c23aa --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/num_tokens_response.json @@ -0,0 +1,15 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "NumTokensResponse", + "type": "object", + "required": [ + "count" + ], + "properties": { + "count": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/operators_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/operators_response.json new file mode 100644 index 000000000..53703072c --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/operators_response.json @@ -0,0 +1,97 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OperatorsResponse", + "type": "object", + "required": [ + "operators" + ], + "properties": { + "operators": { + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/owner_of_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/owner_of_response.json new file mode 100644 index 000000000..1258d671f --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/owner_of_response.json @@ -0,0 +1,103 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "OwnerOfResponse", + "type": "object", + "required": [ + "approvals", + "owner" + ], + "properties": { + "approvals": { + "description": "If set this address is approved to transfer/send the token as well", + "type": "array", + "items": { + "$ref": "#/definitions/Approval" + } + }, + "owner": { + "description": "Owner of the token", + "type": "string" + } + }, + "definitions": { + "Approval": { + "type": "object", + "required": [ + "expires", + "spender" + ], + "properties": { + "expires": { + "description": "When the Approval expires (maybe Expiration::never)", + "allOf": [ + { + "$ref": "#/definitions/Expiration" + } + ] + }, + "spender": { + "description": "Account that can transfer/send the token", + "type": "string" + } + } + }, + "Expiration": { + "description": "Expiration represents a point in time when some event happens. It can compare with a BlockInfo and will return is_expired() == true once the condition is hit (and for every block in the future)", + "oneOf": [ + { + "description": "AtHeight will expire when `env.block.height` >= height", + "type": "object", + "required": [ + "at_height" + ], + "properties": { + "at_height": { + "type": "integer", + "format": "uint64", + "minimum": 0.0 + } + }, + "additionalProperties": false + }, + { + "description": "AtTime will expire when `env.block.time` >= time", + "type": "object", + "required": [ + "at_time" + ], + "properties": { + "at_time": { + "$ref": "#/definitions/Timestamp" + } + }, + "additionalProperties": false + }, + { + "description": "Never will never expire. Used to express the empty variant", + "type": "object", + "required": [ + "never" + ], + "properties": { + "never": { + "type": "object" + } + }, + "additionalProperties": false + } + ] + }, + "Timestamp": { + "description": "A point in time in nanosecond precision.\n\nThis type can represent times from 1970-01-01T00:00:00Z to 2554-07-21T23:34:33Z.\n\n## Examples\n\n``` # use cosmwasm_std::Timestamp; let ts = Timestamp::from_nanos(1_000_000_202); assert_eq!(ts.nanos(), 1_000_000_202); assert_eq!(ts.seconds(), 1); assert_eq!(ts.subsec_nanos(), 202);\n\nlet ts = ts.plus_seconds(2); assert_eq!(ts.nanos(), 3_000_000_202); assert_eq!(ts.seconds(), 3); assert_eq!(ts.subsec_nanos(), 202); ```", + "allOf": [ + { + "$ref": "#/definitions/Uint64" + } + ] + }, + "Uint64": { + "description": "A thin wrapper around u64 that is using strings for JSON encoding/decoding, such that the full u64 range can be used for clients that convert JSON numbers to floats, like JavaScript and jq.\n\n# Examples\n\nUse `from` to create instances of this and `u64` to get the value out:\n\n``` # use cosmwasm_std::Uint64; let a = Uint64::from(42u64); assert_eq!(a.u64(), 42);\n\nlet b = Uint64::from(70u32); assert_eq!(b.u64(), 70); ```", + "type": "string" + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/query_msg.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/query_msg.json new file mode 100644 index 000000000..3cb271651 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/query_msg.json @@ -0,0 +1,284 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "QueryMsg", + "oneOf": [ + { + "type": "object", + "required": [ + "owner_of" + ], + "properties": { + "owner_of": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "approval" + ], + "properties": { + "approval": { + "type": "object", + "required": [ + "spender", + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "spender": { + "type": "string" + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "approvals" + ], + "properties": { + "approvals": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_operators" + ], + "properties": { + "all_operators": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "num_tokens" + ], + "properties": { + "num_tokens": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "contract_info" + ], + "properties": { + "contract_info": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "nft_info" + ], + "properties": { + "nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_nft_info" + ], + "properties": { + "all_nft_info": { + "type": "object", + "required": [ + "token_id" + ], + "properties": { + "include_expired": { + "type": [ + "boolean", + "null" + ] + }, + "token_id": { + "type": "string" + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "type": "object", + "required": [ + "owner" + ], + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "owner": { + "type": "string" + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "all_tokens" + ], + "properties": { + "all_tokens": { + "type": "object", + "properties": { + "limit": { + "type": [ + "integer", + "null" + ], + "format": "uint32", + "minimum": 0.0 + }, + "start_after": { + "type": [ + "string", + "null" + ] + } + } + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "minter" + ], + "properties": { + "minter": { + "type": "object" + } + }, + "additionalProperties": false + }, + { + "type": "object", + "required": [ + "collection_info" + ], + "properties": { + "collection_info": { + "type": "object" + } + }, + "additionalProperties": false + } + ] +} diff --git a/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/tokens_response.json b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/tokens_response.json new file mode 100644 index 000000000..b8e3d75b5 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/contracts/stargaze-sg721/schema/tokens_response.json @@ -0,0 +1,17 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "TokensResponse", + "type": "object", + "required": [ + "tokens" + ], + "properties": { + "tokens": { + "description": "Contains all token_ids in lexicographical ordering If there are more than `limit`, use `start_from` in future queries to achieve pagination.", + "type": "array", + "items": { + "type": "string" + } + } + } +} diff --git a/boilerplates/ts-codegen-npm-module/jest.config.cjs b/boilerplates/ts-codegen-npm-module/jest.config.cjs new file mode 100644 index 000000000..a58c252f8 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node' +}; diff --git a/boilerplates/ts-codegen-npm-module/package.json b/boilerplates/ts-codegen-npm-module/package.json new file mode 100644 index 000000000..be06c2630 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/package.json @@ -0,0 +1,61 @@ +{ + "name": "__PACKAGE_IDENTIFIER__", + "version": "0.0.1", + "description": "__MODULEDESC__", + "author": "__USERFULLNAME__ <__USEREMAIL__>", + "homepage": "https://github.com/__USERNAME__/__MODULENAME__#readme", + "license": "SEE LICENSE IN LICENSE", + "main": "dist/index.js", + "module": "dist/index.mjs", + "typings": "dist/index.d.ts", + "directories": { + "lib": "src" + }, + "files": [ + "dist", + "!CHANGELOG.md" + ], + "scripts": { + "build:cjs": "yarn tsc -p tsconfig.json --outDir dist --module commonjs || true", + "build:mjs": "yarn tsc -p tsconfig.json --outDir mjs --module es2022 --declaration false || true", + "clean:mjs": "rimraf mjs", + "clean:dist": "rimraf dist", + "clean": "npm run clean:mjs && npm run clean:dist", + "build:rename": "publish-scripts --cmd rename --srcDir mjs --outDir dist --findExt js --replaceExt mjs --no-rmDir", + "build": "npm run clean && npm run build:cjs && npm run build:mjs && npm run build:rename", + "codegen": "node scripts/codegen.js", + "prepare": "npm run build", + "lint": "eslint src --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:debug": "node --inspect node_modules/.bin/jest --runInBand" + }, + "publishConfig": { + "access": "__ACCESS__" + }, + "repository": { + "type": "git", + "url": "https://github.com/__USERNAME__/__MODULENAME__" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/__USERNAME__/__MODULENAME__/issues" + }, + "devDependencies": { + "@types/jest": "^29.5.3", + "eslint": "8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.6.1", + "jest-in-case": "^1.0.2", + "prettier": "^3.0.0", + "publish-scripts": "0.1.0", + "rimraf": "^5.0.0", + "ts-jest": "^29.1.0", + "typescript": "^5.0.4" + }, + "dependencies": { + "@cosmjs/cosmwasm-stargate": "^0.31.0", + "@cosmwasm/ts-codegen": "^0.31.6" + } +} \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/scripts/codegen.js b/boilerplates/ts-codegen-npm-module/scripts/codegen.js new file mode 100644 index 000000000..af72c3f68 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/scripts/codegen.js @@ -0,0 +1,29 @@ +const codegen = require('@cosmwasm/ts-codegen').default; + +codegen({ + contracts: [ + { + name: 'SG721', + dir: './contracts/stargaze-sg721/schema' + }, + { + name: 'Minter', + dir: './contracts/stargaze-minter/schema' + } + ], + outPath: './src/', + options: { + bundle: { + bundleFile: 'index.ts', + scope: 'contracts' + }, + messageComposer: { + enabled: true + }, + useContractsHooks: { + enabled: false // if you enable this, add react! + } + } +}).then(() => { + console.log('✨ all done!'); +}); diff --git a/boilerplates/ts-codegen-npm-module/src/index.ts b/boilerplates/ts-codegen-npm-module/src/index.ts new file mode 100644 index 000000000..619fbdd60 --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/src/index.ts @@ -0,0 +1 @@ +export { }; \ No newline at end of file diff --git a/boilerplates/ts-codegen-npm-module/tsconfig.json b/boilerplates/ts-codegen-npm-module/tsconfig.json new file mode 100644 index 000000000..6dd3cb22e --- /dev/null +++ b/boilerplates/ts-codegen-npm-module/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "skipLibCheck": true, + "emitDeclarationOnly": false, + "declaration": true, + "esModuleInterop": true, + "target": "es2022", + "module": "es2022", + "lib": [ + "es2022", + "DOM" + ], + "sourceMap": true, + "isolatedModules": true, + "allowJs": true, + "downlevelIteration": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "jsx": "react" + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.editorconfig b/boilerplates/typescript-npm-module/.editorconfig new file mode 100644 index 000000000..4a7ea3036 --- /dev/null +++ b/boilerplates/typescript-npm-module/.editorconfig @@ -0,0 +1,12 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +end_of_line = lf +charset = utf-8 +trim_trailing_whitespace = true +insert_final_newline = true + +[*.md] +trim_trailing_whitespace = false diff --git a/boilerplates/typescript-npm-module/.eslintignore b/boilerplates/typescript-npm-module/.eslintignore new file mode 100644 index 000000000..38ba48499 --- /dev/null +++ b/boilerplates/typescript-npm-module/.eslintignore @@ -0,0 +1,5 @@ +node_modules/ +dist/ +main/ +module/ +coverage/ \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.eslintrc.js b/boilerplates/typescript-npm-module/.eslintrc.js new file mode 100644 index 000000000..2718e8bc4 --- /dev/null +++ b/boilerplates/typescript-npm-module/.eslintrc.js @@ -0,0 +1,71 @@ +module.exports = { + plugins: ['prettier'], + extends: ['eslint:recommended', 'prettier'], + parser: '@babel/eslint-parser', + parserOptions: { + ecmaVersion: 11, + requireConfigFile: false, + sourceType: 'module', + ecmaFeatures: { + jsx: true + } + }, + env: { + es6: true, + browser: true, + node: true, + jest: true + }, + rules: { + 'no-debugger': 2, + 'no-alert': 2, + 'no-await-in-loop': 0, + 'no-prototype-builtins': 0, + 'no-return-assign': ['error', 'except-parens'], + 'no-restricted-syntax': [ + 2, + 'ForInStatement', + 'LabeledStatement', + 'WithStatement' + ], + 'no-unused-vars': [ + 0, + { + ignoreSiblings: true, + argsIgnorePattern: 'React|res|next|^_' + } + ], + 'prefer-const': [ + 'error', + { + destructuring: 'all' + } + ], + 'no-unused-expressions': [ + 2, + { + allowTaggedTemplates: true + } + ], + 'no-console': 1, + 'comma-dangle': 2, + 'jsx-quotes': [2, 'prefer-double'], + 'linebreak-style': ['error', 'unix'], + quotes: [ + 2, + 'single', + { + avoidEscape: true, + allowTemplateLiterals: true + } + ], + 'prettier/prettier': [ + 'error', + { + trailingComma: 'none', + singleQuote: true, + printWidth: 80 + } + ] + } +}; diff --git a/boilerplates/typescript-npm-module/.gitignore b/boilerplates/typescript-npm-module/.gitignore new file mode 100644 index 000000000..9cd5f4164 --- /dev/null +++ b/boilerplates/typescript-npm-module/.gitignore @@ -0,0 +1,50 @@ +# Logs +logs +*.log +npm-debug.log* + +# Runtime data +pids +*.pid +*.seed + +# dist +dist +mjs +main +module + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Compiled binary addons (http://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules +jspm_packages + +# Optional npm cache directory +.npm + +# Optional REPL history +.node_repl_history + +# Editors +.idea + +# Lib +lib + +# npm package lock +package-lock.json +yarn.lock + +# others +.DS_Store \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.npmignore b/boilerplates/typescript-npm-module/.npmignore new file mode 100644 index 000000000..cc2605fa8 --- /dev/null +++ b/boilerplates/typescript-npm-module/.npmignore @@ -0,0 +1,32 @@ +*.log +npm-debug.log* + +# Coverage directory used by tools like istanbul +coverage +.nyc_output + +# Dependency directories +node_modules + +# npm package lock +package-lock.json +yarn.lock + +# project files +__fixtures__ +__tests__ +.babelrc +.babelrc.js +.editorconfig +.eslintignore +.eslintrc +.eslintrc.js +.gitignore +.travis.yml +.vscode +CHANGELOG.md +examples +jest.config.js +package.json +src +test \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.npmrc b/boilerplates/typescript-npm-module/.npmrc new file mode 100644 index 000000000..a21347f1b --- /dev/null +++ b/boilerplates/typescript-npm-module/.npmrc @@ -0,0 +1 @@ +scripts-prepend-node-path=true \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.questions.json b/boilerplates/typescript-npm-module/.questions.json new file mode 100644 index 000000000..c1549e7cc --- /dev/null +++ b/boilerplates/typescript-npm-module/.questions.json @@ -0,0 +1,37 @@ +[ + { + "name": "__USERFULLNAME__", + "message": "Enter author full name", + "required": true + }, + { + "name": "__USEREMAIL__", + "message": "Enter author email", + "required": true + }, + { + "name": "__MODULENAME__", + "message": "Enter the module name", + "required": true + }, + { + "name": "__MODULEDESC__", + "message": "Enter the module description", + "required": true + }, + { + "name": "__USERNAME__", + "message": "Enter your github username", + "required": true + }, + { + "name": "__ACCESS__", + "message": "Module access?", + "choices": [ + "public", + "restricted" + ], + "type": "list", + "required": true + } +] \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/.vscode/settings.json b/boilerplates/typescript-npm-module/.vscode/settings.json new file mode 100644 index 000000000..55c8b9bba --- /dev/null +++ b/boilerplates/typescript-npm-module/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "editor.formatOnSave": true, + "[javascriptreact]": { + "editor.formatOnSave": false + }, + "[javascript]": { + "editor.formatOnSave": false + }, + "editor.codeActionsOnSave": { + "source.fixAll.eslint": true + }, + "eslint.validate": [ + "javascript", + "javascriptreact" + ] + } \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/LICENSE b/boilerplates/typescript-npm-module/LICENSE new file mode 100644 index 000000000..78191bf06 --- /dev/null +++ b/boilerplates/typescript-npm-module/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2023 __USERFULLNAME__ <__USEREMAIL__> + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/boilerplates/typescript-npm-module/README.md b/boilerplates/typescript-npm-module/README.md new file mode 100644 index 000000000..16ad51fd7 --- /dev/null +++ b/boilerplates/typescript-npm-module/README.md @@ -0,0 +1,60 @@ +# __MODULENAME__ + +

+
+ __MODULEDESC__ +

+ +## install + +```sh +npm install __MODULENAME__ +``` +## Table of contents + +- [__MODULENAME__](#__MODULENAME__) + - [Install](#install) + - [Table of contents](#table-of-contents) +- [Developing](#developing) +- [Credits](#credits) + +## Developing + +When first cloning the repo: + +``` +yarn +yarn build +``` + +### Codegen + +Contract schemas live in `./contracts`. Look inside of `scripts/codegen.js` and configure the settings for bundling your SDK and contracts into `__MODULENAME__`: + +``` +yarn codegen +``` + +### Publishing + +Build the types and then publish: + +``` +yarn build +yarn publish +``` +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + +Code built with the help of these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos ⚛️ + +## Disclaimer + +AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED “AS IS”, AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND. + +No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code or software using the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value. diff --git a/boilerplates/typescript-npm-module/__tests__/example.test.ts b/boilerplates/typescript-npm-module/__tests__/example.test.ts new file mode 100644 index 000000000..3f7425dd7 --- /dev/null +++ b/boilerplates/typescript-npm-module/__tests__/example.test.ts @@ -0,0 +1,3 @@ +it('it works', () => { + console.log('it works!') +}); \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/jest.config.cjs b/boilerplates/typescript-npm-module/jest.config.cjs new file mode 100644 index 000000000..a58c252f8 --- /dev/null +++ b/boilerplates/typescript-npm-module/jest.config.cjs @@ -0,0 +1,5 @@ +/** @type {import('ts-jest').JestConfigWithTsJest} */ +module.exports = { + preset: 'ts-jest', + testEnvironment: 'node' +}; diff --git a/boilerplates/typescript-npm-module/package.json b/boilerplates/typescript-npm-module/package.json new file mode 100644 index 000000000..a0bbb508e --- /dev/null +++ b/boilerplates/typescript-npm-module/package.json @@ -0,0 +1,70 @@ +{ + "name": "__PACKAGE_IDENTIFIER__", + "version": "0.0.1", + "description": "__MODULEDESC__", + "author": "__USERFULLNAME__ <__USEREMAIL__>", + "homepage": "https://github.com/__USERNAME__/__MODULENAME__#readme", + "license": "SEE LICENSE IN LICENSE", + "type": "module", + "main": "dist/index.js", + "module": "dist/index.mjs", + "typings": "dist/index.d.ts", + "directories": { + "lib": "src" + }, + "files": [ + "dist", + "!CHANGELOG.md" + ], + "nodemonConfig": { + "ext": "js,json,ts,tsx" + }, + "scripts": { + "build:cjs": "yarn tsc -p tsconfig.json --outDir dist --module commonjs || true", + "build:mjs": "yarn tsc -p tsconfig.json --outDir mjs --module es2022 --declaration false || true", + "clean:mjs": "rimraf mjs", + "clean:dist": "rimraf dist", + "clean": "npm run clean:mjs && npm run clean:dist", + "build:rename": "publish-scripts --cmd rename --srcDir mjs --outDir dist --findExt js --replaceExt mjs --no-rmDir", + "build": "npm run clean && npm run build:cjs && npm run build:mjs && npm run build:rename", + "codegen": "node scripts/codegen.cjs", + "prepare": "npm run build", + "dev": "ts-node-esm ./src/index.ts", + "watch": "nodemon --exec \"yarn dev\"", + "lint": "eslint src --fix", + "test": "jest", + "test:watch": "jest --watch", + "test:debug": "node --inspect node_modules/.bin/jest --runInBand" + }, + "publishConfig": { + "access": "__ACCESS__" + }, + "repository": { + "type": "git", + "url": "https://github.com/__USERNAME__/__MODULENAME__" + }, + "keywords": [], + "bugs": { + "url": "https://github.com/__USERNAME__/__MODULENAME__/issues" + }, + "devDependencies": { + "@types/jest": "^29.5.3", + "@cosmwasm/ts-codegen": "^0.31.6", + "eslint": "8.45.0", + "eslint-config-prettier": "^8.8.0", + "eslint-plugin-prettier": "^5.0.0", + "jest": "^29.6.1", + "jest-in-case": "^1.0.2", + "nodemon": "^3.0.1", + "prettier": "^3.0.0", + "publish-scripts": "0.1.0", + "rimraf": "^5.0.0", + "ts-jest": "^29.1.0", + "ts-node": "^10.9.1", + "ts-node-dev": "^2.0.0", + "typescript": "^5.0.4" + }, + "dependencies": { + "@cosmjs/cosmwasm-stargate": "^0.31.0" + } +} \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/src/index.ts b/boilerplates/typescript-npm-module/src/index.ts new file mode 100644 index 000000000..619fbdd60 --- /dev/null +++ b/boilerplates/typescript-npm-module/src/index.ts @@ -0,0 +1 @@ +export { }; \ No newline at end of file diff --git a/boilerplates/typescript-npm-module/tsconfig.json b/boilerplates/typescript-npm-module/tsconfig.json new file mode 100644 index 000000000..6dd3cb22e --- /dev/null +++ b/boilerplates/typescript-npm-module/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "rootDir": "src", + "skipLibCheck": true, + "emitDeclarationOnly": false, + "declaration": true, + "esModuleInterop": true, + "target": "es2022", + "module": "es2022", + "lib": [ + "es2022", + "DOM" + ], + "sourceMap": true, + "isolatedModules": true, + "allowJs": true, + "downlevelIteration": true, + "moduleResolution": "node", + "resolveJsonModule": true, + "jsx": "react" + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "node_modules" + ] +} \ No newline at end of file diff --git a/templates/connect-multi-chain/.eslintrc copy.json b/examples/asset-list/.eslintrc.json similarity index 100% rename from templates/connect-multi-chain/.eslintrc copy.json rename to examples/asset-list/.eslintrc.json diff --git a/examples/asset-list/.gitignore b/examples/asset-list/.gitignore new file mode 100644 index 000000000..c87c9b392 --- /dev/null +++ b/examples/asset-list/.gitignore @@ -0,0 +1,36 @@ +# See https://help.github.com/articles/ignoring-files/ for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# next.js +/.next/ +/out/ + +# production +/build + +# misc +.DS_Store +*.pem + +# debug +npm-debug.log* +yarn-debug.log* +yarn-error.log* +.pnpm-debug.log* + +# local env files +.env*.local + +# vercel +.vercel + +# typescript +*.tsbuildinfo +next-env.d.ts diff --git a/examples/asset-list/CHANGELOG.md b/examples/asset-list/CHANGELOG.md new file mode 100644 index 000000000..500d86ff5 --- /dev/null +++ b/examples/asset-list/CHANGELOG.md @@ -0,0 +1,390 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +## [0.2.5](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/asset-list@0.2.4...@cosmology/asset-list@0.2.5) (2023-09-27) + +**Note:** Version bump only for package @cosmology/asset-list + + + + + +## [0.2.4](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/asset-list@0.2.3...@cosmology/asset-list@0.2.4) (2023-09-27) + +**Note:** Version bump only for package @cosmology/asset-list + + + + + +## [0.2.3](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/asset-list@0.2.2...@cosmology/asset-list@0.2.3) (2023-07-30) + +**Note:** Version bump only for package @cosmology/asset-list + + + + + +## [0.2.2](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/asset-list@0.2.1...@cosmology/asset-list@0.2.2) (2023-07-14) + +**Note:** Version bump only for package @cosmology/asset-list + + + + + +## [0.2.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/asset-list@0.2.0...@cosmology/asset-list@0.2.1) (2023-06-28) + +**Note:** Version bump only for package @cosmology/asset-list + + + + + +# 0.2.0 (2023-04-12) + + +### Bug Fixes + +* add missing deps ([b24c3c7](https://github.com/cosmology-tech/create-cosmos-app/commit/b24c3c7c882a0211abc5f01095ff247e5f663d02)) +* pool data error ([0739e1b](https://github.com/cosmology-tech/create-cosmos-app/commit/0739e1b28a4d6219ecf65678fe5f170103a48f8d)) + + +### Features + +* add dark mode ([9de3ec0](https://github.com/cosmology-tech/create-cosmos-app/commit/9de3ec001b801328ff2bbb24740cfa977ffb64be)) +* add multi-chain page ([776605f](https://github.com/cosmology-tech/create-cosmos-app/commit/776605f338a71230c062efe2da4d433329c2a640)) +* assets list deposit and withdraw ([c028a6a](https://github.com/cosmology-tech/create-cosmos-app/commit/c028a6aefd9cc67a0a1d0824ee9ee3c0985e65ea)) +* display total on osmosis ([297e70d](https://github.com/cosmology-tech/create-cosmos-app/commit/297e70dd558a80ea15bc2a623fc4109502899b59)) +* dropdown deposit and withdraw ([9d74b57](https://github.com/cosmology-tech/create-cosmos-app/commit/9d74b571c856f9600dcd3e54cbf278c14c804792)) +* finish the style ([cc2baab](https://github.com/cosmology-tech/create-cosmos-app/commit/cc2baab2db3a6b5c501ac3ddc32238977cf5bfa0)) + + + + + +## [1.7.2](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.7.1...@cosmology/osmosis@1.7.2) (2023-02-15) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.7.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.7.0...@cosmology/osmosis@1.7.1) (2023-01-11) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.7.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.6.4...@cosmology/osmosis@1.7.0) (2022-12-17) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.6.4](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.6.3...@cosmology/osmosis@1.6.4) (2022-12-15) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.6.3](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.6.2...@cosmology/osmosis@1.6.3) (2022-11-25) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.6.2](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.6.1...@cosmology/osmosis@1.6.2) (2022-11-21) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.6.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.6.0...@cosmology/osmosis@1.6.1) (2022-11-17) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.6.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.5.0...@cosmology/osmosis@1.6.0) (2022-11-15) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.5.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.4.0...@cosmology/osmosis@1.5.0) (2022-11-14) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.4.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.3.0...@cosmology/osmosis@1.4.0) (2022-11-10) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.3.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.2.0...@cosmology/osmosis@1.3.0) (2022-11-09) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +# [1.2.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.1.5...@cosmology/osmosis@1.2.0) (2022-11-08) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.1.5](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.1.4...@cosmology/osmosis@1.1.5) (2022-11-05) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.1.4](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.1.3...@cosmology/osmosis@1.1.4) (2022-11-05) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.1.3](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmology/osmosis@1.1.2...@cosmology/osmosis@1.1.3) (2022-11-05) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## 1.1.2 (2022-11-01) + +**Note:** Version bump only for package @cosmology/osmosis + + + + + +## [1.1.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@1.1.0...@cosmonauts/osmosis@1.1.1) (2022-10-27) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +# [1.1.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@1.0.3...@cosmonauts/osmosis@1.1.0) (2022-10-26) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +## [1.0.3](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@1.0.2...@cosmonauts/osmosis@1.0.3) (2022-10-24) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +## [1.0.2](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@1.0.1...@cosmonauts/osmosis@1.0.2) (2022-10-15) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +## [1.0.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@1.0.0...@cosmonauts/osmosis@1.0.1) (2022-10-03) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +# [1.0.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@0.8.0...@cosmonauts/osmosis@1.0.0) (2022-10-01) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +# [0.8.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@0.7.1...@cosmonauts/osmosis@0.8.0) (2022-09-30) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +## [0.7.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@0.7.0...@cosmonauts/osmosis@0.7.1) (2022-09-25) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +# [0.7.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/osmosis@0.6.0...@cosmonauts/osmosis@0.7.0) (2022-09-25) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +# 0.6.0 (2022-09-25) + +**Note:** Version bump only for package @cosmonauts/osmosis + + + + + +## [0.5.1](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.5.0...@cosmonauts/connect-chain@0.5.1) (2022-09-23) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +# [0.5.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.4.0...@cosmonauts/connect-chain@0.5.0) (2022-09-23) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +# [0.4.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.3.0...@cosmonauts/connect-chain@0.4.0) (2022-09-22) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +# [0.3.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.2.0...@cosmonauts/connect-chain@0.3.0) (2022-09-22) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +# [0.2.0](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.10...@cosmonauts/connect-chain@0.2.0) (2022-09-22) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.10](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.9...@cosmonauts/connect-chain@0.1.10) (2022-09-11) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.9](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.8...@cosmonauts/connect-chain@0.1.9) (2022-09-08) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.8](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.7...@cosmonauts/connect-chain@0.1.8) (2022-09-02) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.7](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.6...@cosmonauts/connect-chain@0.1.7) (2022-08-30) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.6](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.5...@cosmonauts/connect-chain@0.1.6) (2022-08-27) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.5](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.4...@cosmonauts/connect-chain@0.1.5) (2022-08-27) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.4](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.3...@cosmonauts/connect-chain@0.1.4) (2022-08-27) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## [0.1.3](https://github.com/cosmology-tech/create-cosmos-app/compare/@cosmonauts/connect-chain@0.1.2...@cosmonauts/connect-chain@0.1.3) (2022-08-25) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## 0.1.2 (2022-08-25) + +**Note:** Version bump only for package @cosmonauts/connect-chain + + + + + +## 0.1.1 (2022-08-24) + +**Note:** Version bump only for package @cosmos-app/connect-chain diff --git a/examples/asset-list/README.md b/examples/asset-list/README.md new file mode 100644 index 000000000..de89ca917 --- /dev/null +++ b/examples/asset-list/README.md @@ -0,0 +1,76 @@ +This is a Cosmos App project bootstrapped with [`create-cosmos-app`](https://github.com/cosmology-tech/create-cosmos-app). + +## Getting Started + +First, install the packages and run the development server: + +```bash +yarn && yarn dev +``` + +Open [http://localhost:3000](http://localhost:3000) with your browser to see the result. + +You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file. + +## Learn More + +### Chain Registry + +The npm package for the Official Cosmos chain registry. Get chain and token data for you application. + +* https://github.com/cosmology-tech/chain-registry + +### Cosmology Videos + +Checkout more videos for how to use various frontend tooling in the Cosmos! + +* https://cosmology.tech/learn + +### Cosmos Kit + +A wallet connector for the Cosmos ⚛️ + +* https://github.com/cosmology-tech/cosmos-kit + +### Telescope + +A "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. Telescope is used to generate libraries for Cosmos blockchains. Simply point to your protobuffer files and create developer-friendly Typescript libraries for teams to build on your blockchain. + +* https://github.com/cosmology-tech/telescope + +🎥 [Checkout the Telescope video playlist](https://www.youtube.com/watch?v=n82MsLe82mk&list=PL-lMkVv7GZwyQaK6bp6kMdOS5mzosxytC) to learn how to use `telescope`! + +### CosmWasm TS Codegen + +The quickest and easiest way to interact with CosmWasm Contracts. @cosmwasm/ts-codegen converts your CosmWasm smart contracts into dev-friendly TypeScript classes so you can focus on shipping code. + +* https://github.com/CosmWasm/ts-codegen + +🎥 [Checkout the CosmWasm/ts-codegne video playlist](https://www.youtube.com/watch?v=D_A5V2PfNLA&list=PL-lMkVv7GZwz1KO3jANwr5W4MoziruXwK) to learn how to use `ts-codegen`! + + +## Learn More about Next.js + +To learn more about Next.js, take a look at the following resources: + +- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API. +- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial. + +You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome! + +## Deploy on Vercel + +The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js. + +Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details. + +## Credits + +🛠 Built by Cosmology — if you like our tools, please consider delegating to [our validator ⚛️](https://cosmology.tech/validator) + +Code built with the help of these related projects: + +* [@cosmwasm/ts-codegen](https://github.com/CosmWasm/ts-codegen) for generated CosmWasm contract Typescript classes +* [@cosmology/telescope](https://github.com/cosmology-tech/telescope) a "babel for the Cosmos", Telescope is a TypeScript Transpiler for Cosmos Protobufs. +* [chain-registry](https://github.com/cosmology-tech/chain-registry) Cosmos chain registry and chain info. +* [cosmos-kit](https://github.com/cosmology-tech/cosmos-kit) A wallet connector for the Cosmos. diff --git a/examples/asset-list/components/asset-list/AmountInput.tsx b/examples/asset-list/components/asset-list/AmountInput.tsx new file mode 100644 index 000000000..2fb85837e --- /dev/null +++ b/examples/asset-list/components/asset-list/AmountInput.tsx @@ -0,0 +1,209 @@ +import { + Flex, + Text, + Box, + Center, + NumberInput, + NumberInputField, + useColorModeValue, + Skeleton, +} from '@chakra-ui/react'; +import { ChainName } from '@cosmos-kit/core'; +import BigNumber from 'bignumber.js'; +import React, { useMemo } from 'react'; +import { useBalance, useChainUtils } from '../../hooks'; +import { PriceHash, Transfer, TransferInfo } from './types'; +import { ChainLogo } from './ChainAssetsList'; + +const ratioLabels = [ + { label: 'Max', divisor: 1 }, + { label: '1/2', divisor: 2 }, + { label: '1/3', divisor: 3 }, +]; + +interface IProps { + prices: PriceHash; + transferInfo: TransferInfo; + inputState: { inputValue: string; setInputValue: (val: string) => void }; + selectedChainName: ChainName; +} + +const AmountInput: React.FC = ({ + prices, + inputState, + transferInfo, + selectedChainName, +}) => { + const { inputValue, setInputValue } = inputState; + const { convRawToDispAmount, symbolToDenom } = + useChainUtils(selectedChainName); + + const { + type: transferType, + token: transferToken, + sourceChainName, + } = transferInfo; + + const isDeposit = transferType === Transfer.Deposit; + const { balance, isLoading } = useBalance(sourceChainName, isDeposit); + + const ZERO_AMOUNT = '0'; + + const availableAmount = useMemo(() => { + if (!isDeposit) return transferToken.displayAmount; + if (isLoading) return ZERO_AMOUNT; + + return convRawToDispAmount( + transferToken.symbol, + balance?.amount || ZERO_AMOUNT + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isDeposit, isLoading, transferToken]); + + const dollarValue = new BigNumber(inputValue) + .multipliedBy(prices[symbolToDenom(transferToken.symbol)]) + .decimalPlaces(2) + .toString(); + + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + const bgColor = useColorModeValue('#EEF2F8', '#1D2024'); + const borderColor = useColorModeValue('#D1D6DD', '#434B55'); + const symbolColor = useColorModeValue('#2C3137', '#A7B4C2'); + + return ( + + + + Select amount + + + Available  + {isLoading && isDeposit ? ( + + ) : ( + {availableAmount}  + )} + {transferToken.symbol} + + + + +
+ +
+ + { + if (new BigNumber(val).gt(availableAmount)) { + setInputValue(availableAmount); + return; + } + setInputValue(val); + }} + > + + + +
+ + + {transferToken.symbol} + + {new BigNumber(inputValue).gt(0) && ( + + {new BigNumber(dollarValue).lt(0.01) + ? '< $0.01' + : `≈ $${dollarValue}`} + + )} + +
+
+ + + {ratioLabels.map(({ label, divisor }) => ( + { + if (isLoading && isDeposit) return; + const inputVal = new BigNumber(availableAmount) + .div(divisor) + .decimalPlaces(9) + .toString(); + setInputValue(inputVal); + }} + /> + ))} + +
+ ); +}; + +const RatioLabel = ({ + label, + onClick, +}: { + label: string; + onClick: () => void; +}) => { + const bgColor = useColorModeValue('#EEF2F8', '#434B55'); + const titleColor = useColorModeValue('#697584', '#EEF2F8'); + + return ( +
+ + {label} + +
+ ); +}; + +export default AmountInput; diff --git a/examples/asset-list/components/asset-list/AssetListSection.tsx b/examples/asset-list/components/asset-list/AssetListSection.tsx new file mode 100644 index 000000000..3e586975a --- /dev/null +++ b/examples/asset-list/components/asset-list/AssetListSection.tsx @@ -0,0 +1,89 @@ +import React from 'react'; +import { + Box, + Center, + Spinner, + Text, + useColorModeValue, +} from '@chakra-ui/react'; +import AssetsOverview from './AssetsOverview'; +import ChainAssetsList from './ChainAssetsList'; +import { useChain } from '@cosmos-kit/react'; +import { useAssets } from '../../hooks'; +import { ChainName } from '@cosmos-kit/core'; + +interface IProps { + chainName: ChainName; +} + +export const AssetListSection: React.FC = ({ chainName }) => { + const { isWalletConnected, chain } = useChain(chainName); + const { data, isLoading, refetch } = useAssets(chainName); + + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + + if (!isWalletConnected) { + return ( + + +
+ + Connect the wallet to see the assets + +
+
+ ); + } + + return ( + + + + + On {chain.pretty_name} + + {isLoading || !data ? ( + + ) : ( + + )} + + ); +}; + +const SectionTitle = () => { + const textColor = useColorModeValue('#2C3137', '#EEF2F8'); + return ( + + My Assets + + ); +}; + +const Loader = () => { + return ( +
+ +
+ ); +}; diff --git a/examples/asset-list/components/asset-list/AssetsOverview.tsx b/examples/asset-list/components/asset-list/AssetsOverview.tsx new file mode 100644 index 000000000..9baf7f2c7 --- /dev/null +++ b/examples/asset-list/components/asset-list/AssetsOverview.tsx @@ -0,0 +1,140 @@ +import React, { useMemo, useState } from 'react'; +import { + Box, + Flex, + HStack, + Skeleton, + Text, + useColorModeValue, + useDisclosure, +} from '@chakra-ui/react'; +import { NormalButton } from './Buttons'; +import DropdownTransferModal from './DropdownTransferModal'; +import { PrettyAsset, Transfer, TransferInfo } from './types'; +import { useChainUtils, useTotalAssets } from '../../hooks'; +import { useChain } from '@cosmos-kit/react'; +import BigNumber from 'bignumber.js'; +import { ChainName } from '@cosmos-kit/core'; + +interface IProps { + assets: PrettyAsset[]; + selectedChainName: ChainName; +} + +const AssetsOverview: React.FC = ({ assets, selectedChainName }) => { + const [transferInfo, setTransferInfo] = useState(); + const { chain } = useChain(selectedChainName); + + const { data, isLoading, refetch } = useTotalAssets(selectedChainName); + const { getChainName, getNativeDenom, isNativeAsset } = + useChainUtils(selectedChainName); + + const modalControl = useDisclosure(); + + const ibcAssets = useMemo( + () => assets.filter((asset) => !isNativeAsset(asset)), + // eslint-disable-next-line react-hooks/exhaustive-deps + [assets] + ); + + const hasBalance = useMemo( + () => ibcAssets.some((asset) => new BigNumber(asset.amount).gt(0)), + [ibcAssets] + ); + + const ZERO_AMOUNT = '0'; + + const bgColor = useColorModeValue('#F5F7FB', '#1D2024'); + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + + return ( + + + + + Total on {chain.pretty_name} + + {isLoading || !data ? ( + + ) : ( + + $ + {data.total} + + )} + + + {!isLoading && ( + + {hasBalance && ( + { + const destChainName = getChainName(ibcAssets[0].denom); + setTransferInfo({ + sourceChainName: selectedChainName, + type: Transfer.Withdraw, + destChainName, + token: ibcAssets[0], + }); + modalControl.onOpen(); + }} + /> + )} + {ibcAssets.length > 0 && ( + { + const sourceChainName = getChainName(ibcAssets[0].denom); + const sourceChainAssetDenom = getNativeDenom(sourceChainName); + setTransferInfo({ + sourceChainName, + type: Transfer.Deposit, + destChainName: selectedChainName, + token: { + ...ibcAssets[0], + displayAmount: ZERO_AMOUNT, + dollarValue: ZERO_AMOUNT, + amount: ZERO_AMOUNT, + denom: sourceChainAssetDenom, + }, + }); + modalControl.onOpen(); + }} + /> + )} + + )} + + + {data && transferInfo && ( + + )} + + ); +}; + +export default AssetsOverview; diff --git a/examples/asset-list/components/asset-list/Buttons.tsx b/examples/asset-list/components/asset-list/Buttons.tsx new file mode 100644 index 000000000..24a4f881f --- /dev/null +++ b/examples/asset-list/components/asset-list/Buttons.tsx @@ -0,0 +1,145 @@ +import { useColorModeValue, Button } from '@chakra-ui/react'; +import { ReactNode } from 'react'; + +export const SimpleButton = ({ + onClick, + text, + visible = true, + mr, +}: { + onClick: () => void; + text: string; + visible?: boolean; + mr?: string; +}) => { + const bgColor = useColorModeValue('#EEF2F8', '#1D2024'); + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + + return ( + + ); +}; + +export const NormalButton = ({ + type, + size, + onClick, + text, + mr, + disabled, + isLoading = false, +}: { + type: 'solid' | 'outline'; + size: { w: string; h: string }; + onClick: () => void; + text: string; + mr?: string; + disabled?: boolean; + isLoading?: boolean; +}) => { + const baseStyle = { + solid: { + color: useColorModeValue('#FFF', '#1D2024'), + backgroundColor: useColorModeValue('#2C3137', '#EEF2F8'), + }, + outline: { + color: useColorModeValue('#2C3137', '#EEF2F8'), + border: `2px solid ${useColorModeValue('#2C3137', '#EEF2F8')}`, + backgroundColor: 'transparent', + }, + }; + + const isDisabledState = isLoading || disabled; + + return ( + + ); +}; + +export const LargeButton = ({ + width, + btnText, + isLoading, + handleClick, + disabled, + btnContent, +}: { + width: string; + btnText?: string; + btnContent?: ReactNode; + isLoading: boolean; + handleClick: () => void; + disabled?: boolean; +}) => { + return ( + + ); +}; diff --git a/examples/asset-list/components/asset-list/ChainAssetsList.tsx b/examples/asset-list/components/asset-list/ChainAssetsList.tsx new file mode 100644 index 000000000..e51417a5d --- /dev/null +++ b/examples/asset-list/components/asset-list/ChainAssetsList.tsx @@ -0,0 +1,255 @@ +import { ChevronUpIcon, ChevronDownIcon } from '@chakra-ui/icons'; +import { + Text, + Center, + Image, + SimpleGrid, + HStack, + Flex, + useColorMode, + Box, + useDisclosure, + useColorModeValue, +} from '@chakra-ui/react'; +import BigNumber from 'bignumber.js'; +import React, { useMemo, useState } from 'react'; +import { PrettyAsset, PriceHash, Transfer, TransferInfo } from './types'; +import { SimpleButton } from './Buttons'; +import TransferModal from './TransferModal'; +import { ChainName } from '@cosmos-kit/core'; +import { useChainUtils } from '../../hooks'; +import { truncDecimals, formatDollarValue } from '@/utils'; + +interface IProps { + assets: PrettyAsset[]; + prices: PriceHash; + updateData: () => void; + selectedChainName: ChainName; +} + +const ChainAssetsList: React.FC = ({ + assets, + prices, + updateData, + selectedChainName, +}) => { + const [showAll, setShowAll] = useState(false); + const [transferInfo, setTransferInfo] = useState(); + + const { colorMode } = useColorMode(); + const transferModalControl = useDisclosure(); + const { getChainName, isNativeAsset, getNativeDenom } = + useChainUtils(selectedChainName); + + const assetsToShow = useMemo( + () => (showAll ? assets : assets.slice(0, 6)), + [assets, showAll] + ); + + const ZERO_AMOUNT = '0'; + + if (assets.length === 0) { + return ( +
+ + No assets on this chain + +
+ ); + } + + return ( + + +
+
+ + + {assetsToShow.map((asset) => { + return ( + + + +
+ +
+
+ + + + + + {!isNativeAsset(asset) && ( + + { + const sourceChainName = getChainName(asset.denom); + const sourceChainNativeDenom = + getNativeDenom(sourceChainName); + setTransferInfo({ + sourceChainName, + type: Transfer.Deposit, + destChainName: selectedChainName, + token: { + ...asset, + displayAmount: ZERO_AMOUNT, + dollarValue: ZERO_AMOUNT, + amount: ZERO_AMOUNT, + denom: sourceChainNativeDenom, + }, + }); + transferModalControl.onOpen(); + }} + text={Transfer.Deposit} + mr="12px" + /> + { + const destChainName = getChainName(asset.denom); + setTransferInfo({ + sourceChainName: selectedChainName, + type: Transfer.Withdraw, + destChainName, + token: asset, + }); + transferModalControl.onOpen(); + }} + visible={new BigNumber(asset.amount).gt(0)} + text={Transfer.Withdraw} + /> + + )} +
+ ); + })} + + + setShowAll(!showAll)} + > + {`Show ${showAll ? 'less' : 'more'}`} + {showAll ? ( + + ) : ( + + )} + + + + {transferInfo && ( + + )} + + ); +}; + +const DataDisplay = ({ + value, + helpText, +}: { + value: string; + helpText: string; +}) => { + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + + return ( + + + {value} + + + {helpText} + + + ); +}; + +export const ChainLogo = ({ + logoWidth, + url, +}: { + logoWidth: string; + url: string | undefined; +}) => { + if (!url) + return ( +
+ ? +
+ ); + return ( + + ); +}; + +const Header = ({ text, ml }: { text: string; ml?: string }) => { + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + + return ( + + {text} + + ); +}; + +export default ChainAssetsList; diff --git a/examples/asset-list/components/asset-list/DropdownInput.tsx b/examples/asset-list/components/asset-list/DropdownInput.tsx new file mode 100644 index 000000000..c8adcec9a --- /dev/null +++ b/examples/asset-list/components/asset-list/DropdownInput.tsx @@ -0,0 +1,273 @@ +import React, { useMemo } from 'react'; +import { ChevronDownIcon } from '@chakra-ui/icons'; +import { + Flex, + Center, + Text, + Box, + useColorModeValue, + NumberInput, + NumberInputField, + useDisclosure, + Skeleton, +} from '@chakra-ui/react'; +import { ChainLogo } from './ChainAssetsList'; +import { SwapDropdown } from '@cosmology-ui/react'; +import { + PrettyAsset, + PrettyAssetOption, + PriceHash, + Transfer, + TransferInfo, +} from './types'; +import BigNumber from 'bignumber.js'; +import { useBalance, useChainUtils } from '../../hooks'; +import { ChainName } from '@cosmos-kit/core'; +import { truncDecimals } from '@/utils'; + +interface IProps { + prices: PriceHash; + assets: PrettyAsset[]; + transferInfo: TransferInfo; + setTransferInfo: React.Dispatch< + React.SetStateAction + >; + selectedChainName: ChainName; + inputState: { + inputValue: string; + setInputValue: React.Dispatch>; + }; +} + +const DropdownInput: React.FC = ({ + assets, + prices, + inputState, + transferInfo, + setTransferInfo, + selectedChainName, +}) => { + const { inputValue, setInputValue } = inputState; + const { convRawToDispAmount, symbolToDenom, getChainName, getNativeDenom } = + useChainUtils(selectedChainName); + + const { + type: transferType, + token: transferToken, + sourceChainName, + } = transferInfo; + + const isDeposit = transferType === Transfer.Deposit; + const { balance, isLoading } = useBalance(sourceChainName, isDeposit); + const { isOpen, onOpen, onClose } = useDisclosure(); + + const ZERO_AMOUNT = '0'; + + const availableAmount = useMemo(() => { + if (!isDeposit) return transferToken.displayAmount; + if (isLoading) return ZERO_AMOUNT; + + return convRawToDispAmount( + transferToken.symbol, + balance?.amount || ZERO_AMOUNT + ); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [isDeposit, isLoading, transferToken]); + + const dollarValue = new BigNumber(inputValue) + .multipliedBy(prices[symbolToDenom(transferToken.symbol)]) + .decimalPlaces(2) + .toString(); + + const handleOnChange = (assetOption: PrettyAssetOption) => { + setInputValue(''); + setTransferInfo((prev) => { + if (!prev) return; + + if (transferType === Transfer.Withdraw) { + const destChainName = getChainName(assetOption.denom); + return { ...prev, destChainName, token: assetOption }; + } + + const sourceChainName = getChainName(assetOption.denom); + const sourceChainAssetDenom = getNativeDenom(sourceChainName); + return { + ...prev, + sourceChainName, + token: { + ...assetOption, + displayAmount: ZERO_AMOUNT, + dollarValue: ZERO_AMOUNT, + amount: ZERO_AMOUNT, + denom: sourceChainAssetDenom, + }, + }; + }); + }; + + const assetOptions: PrettyAssetOption[] = useMemo(() => { + return assets + .filter((asset) => { + if (isDeposit) return true; + return new BigNumber(asset.amount).gt(0); + }) + .filter((asset) => { + return asset.symbol !== transferToken.symbol; + }) + .map((asset) => ({ + ...asset, + value: asset.prettyChainName, + icon: { png: asset.logoUrl }, + amount: asset.displayAmount, + dollarValue: '$' + truncDecimals(asset.dollarValue, 2), + })); + }, [assets, isDeposit, transferToken]); + + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + const bgColor = useColorModeValue('#EEF2F8', '#1D2024'); + const labelBgColor = useColorModeValue('#A2AEBB', '#434B55'); + + return ( + + + + Available   + {isLoading && isDeposit ? ( + + ) : ( + {availableAmount} + )} + +
setInputValue(availableAmount)} + cursor="pointer" + > + + Max + +
+
+ + + + + + + + {transferToken.symbol} + + + + + {transferToken.prettyChainName} + + + + + + { + if (new BigNumber(val).gt(availableAmount)) { + setInputValue(availableAmount); + return; + } + setInputValue(val); + }} + > + + {!inputValue && ( + + 0 + + )} + + + + {new BigNumber(dollarValue).lt(0.01) + ? '< $0.01' + : `~ $${dollarValue}`} + + + + + + + +
+ ); +}; + +export default DropdownInput; diff --git a/examples/asset-list/components/asset-list/DropdownTransferModal.tsx b/examples/asset-list/components/asset-list/DropdownTransferModal.tsx new file mode 100644 index 000000000..6a8992dd9 --- /dev/null +++ b/examples/asset-list/components/asset-list/DropdownTransferModal.tsx @@ -0,0 +1,239 @@ +import { ArrowForwardIcon } from '@chakra-ui/icons'; +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalCloseButton, + ModalBody, + ModalFooter, + UseDisclosureReturn, + Text, + Flex, + Center, + Icon, + useColorModeValue, +} from '@chakra-ui/react'; +import React, { useEffect, useState } from 'react'; +import { ChainLogo } from './ChainAssetsList'; +import { HiOutlineClock } from 'react-icons/hi'; +import { LargeButton } from './Buttons'; +import DropdownInput from './DropdownInput'; +import { PrettyAsset, PriceHash, TransferInfo } from './types'; +import { useChainWallet, useManager } from '@cosmos-kit/react'; +import BigNumber from 'bignumber.js'; +import { StdFee, coins } from '@cosmjs/amino'; +import { useChainUtils, useTx } from '../../hooks'; +import { ChainName } from '@cosmos-kit/core'; +import { KeplrWalletName } from '@/config'; +import { ibc } from 'osmo-query'; + +const { transfer } = ibc.applications.transfer.v1.MessageComposer.withTypeUrl; + +interface IProps { + prices: PriceHash; + assets: PrettyAsset[]; + modalControl: UseDisclosureReturn; + updateData: () => void; + transferInfoState: { + transferInfo: TransferInfo; + setTransferInfo: React.Dispatch< + React.SetStateAction + >; + }; + selectedChainName: ChainName; +} + +const DropdownTransferModal: React.FC = ({ + assets, + prices, + modalControl, + transferInfoState, + updateData, + selectedChainName, +}) => { + const [inputValue, setInputValue] = useState(''); + const [isLoading, setIsLoading] = useState(false); + + const { symbolToDenom, getExponentByDenom, getIbcInfo } = + useChainUtils(selectedChainName); + + const { transferInfo, setTransferInfo } = transferInfoState; + + const { + type: transferType, + token: transferToken, + destChainName, + sourceChainName, + } = transferInfo; + + const { address: sourceAddress, connect: connectSourceChain } = + useChainWallet(sourceChainName, KeplrWalletName); + + const { address: destAddress, connect: connectDestChain } = useChainWallet( + destChainName, + KeplrWalletName + ); + + const { getChainLogo } = useManager(); + const { tx } = useTx(sourceChainName); + + useEffect(() => { + if (!modalControl.isOpen) return; + if (!sourceAddress) connectSourceChain(); + if (!destAddress) connectDestChain(); + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [destAddress, sourceAddress, modalControl]); + + const closeModal = () => { + modalControl.onClose(); + setInputValue(''); + setIsLoading(false); + }; + + const handleClick = async () => { + if (!sourceAddress || !destAddress) return; + setIsLoading(true); + + const transferAmount = new BigNumber(inputValue) + .shiftedBy(getExponentByDenom(symbolToDenom(transferToken.symbol))) + .toString(); + + const { sourcePort, sourceChannel } = getIbcInfo( + sourceChainName, + destChainName + ); + + const fee: StdFee = { + amount: coins('1000', transferToken.denom), + gas: '250000', + }; + + const token = { + denom: transferToken.denom, + amount: transferAmount, + }; + + const stamp = Date.now(); + const timeoutInNanos = (stamp + 1.2e6) * 1e6; + + const msg = transfer({ + sourcePort, + sourceChannel, + sender: sourceAddress, + receiver: destAddress, + token, + // @ts-ignore + timeoutHeight: undefined, + timeoutTimestamp: BigInt(timeoutInNanos), + }); + + await tx([msg], { + fee, + onSuccess: () => { + updateData(); + closeModal(); + }, + }); + + setIsLoading(false); + }; + + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + const arrowColor = useColorModeValue('#4A5568', '#A7B4C2'); + const cancelColor = useColorModeValue('#697584', '#EEF2F8'); + + return ( + + + + + {transferType} + + + + {transferInfo && ( + + )} +
+ {transferInfo && ( + + +
+ +
+ +
+ )} +
+
+ + + } + handleClick={handleClick} + isLoading={isLoading} + width="100%" + disabled={ + !inputValue || + new BigNumber(inputValue).isEqualTo(0) || + isNaN(Number(inputValue)) + } + /> + + Cancel + + +
+
+ ); +}; + +const BtnContent = () => ( + + + Transfer + + + + ≈ 20 seconds + + +); + +export default DropdownTransferModal; diff --git a/examples/asset-list/components/asset-list/TransferModal.tsx b/examples/asset-list/components/asset-list/TransferModal.tsx new file mode 100644 index 000000000..b59cf1d36 --- /dev/null +++ b/examples/asset-list/components/asset-list/TransferModal.tsx @@ -0,0 +1,278 @@ +import { ArrowForwardIcon } from '@chakra-ui/icons'; +import { + Modal, + ModalOverlay, + ModalContent, + ModalHeader, + ModalCloseButton, + ModalBody, + ModalFooter, + UseDisclosureReturn, + Box, + Text, + Flex, + Center, + Icon, + useColorModeValue, +} from '@chakra-ui/react'; +import React, { useEffect, useState } from 'react'; +import AmountInput from './AmountInput'; +import { ChainLogo } from './ChainAssetsList'; +import { HiOutlineClock } from 'react-icons/hi'; +import { LargeButton } from './Buttons'; +import { PriceHash, TransferInfo } from './types'; +import { useChainWallet, useManager } from '@cosmos-kit/react'; +import BigNumber from 'bignumber.js'; +import { ChainName } from '@cosmos-kit/core'; +import { coins, StdFee } from '@cosmjs/amino'; +import { useChainUtils, useTx } from '../../hooks'; +import { KeplrWalletName } from '@/config'; +import { ibc } from 'osmo-query'; +import { shortenAddress } from '@/utils'; + +const { transfer } = ibc.applications.transfer.v1.MessageComposer.withTypeUrl; + +interface IProps { + prices: PriceHash; + transferInfo: TransferInfo; + modalControl: UseDisclosureReturn; + updateData: () => void; + selectedChainName: ChainName; +} + +const TransferModal: React.FC = ({ + prices, + modalControl, + transferInfo, + updateData, + selectedChainName, +}) => { + const [inputValue, setInputValue] = useState(''); + const [isLoading, setIsLoading] = useState(false); + + const { getIbcInfo, symbolToDenom, getExponentByDenom } = + useChainUtils(selectedChainName); + + const { + type: transferType, + token: transferToken, + destChainName, + sourceChainName, + } = transferInfo; + + const { + address: sourceAddress, + connect: connectSourceChain, + chain: sourceChainInfo, + } = useChainWallet(sourceChainName, KeplrWalletName); + + const { + address: destAddress, + connect: connectDestChain, + chain: destChainInfo, + } = useChainWallet(destChainName, KeplrWalletName); + + const { getChainLogo } = useManager(); + const { tx } = useTx(sourceChainName); + + useEffect(() => { + if (!modalControl.isOpen) return; + if (!sourceAddress) connectSourceChain(); + if (!destAddress) connectDestChain(); + + // eslint-disable-next-line react-hooks/exhaustive-deps + }, [modalControl.isOpen]); + + const closeModal = () => { + modalControl.onClose(); + setInputValue(''); + }; + + const handleClick = async () => { + if (!sourceAddress || !destAddress) return; + setIsLoading(true); + + const transferAmount = new BigNumber(inputValue) + .shiftedBy(getExponentByDenom(symbolToDenom(transferToken.symbol))) + .toString(); + + const { sourcePort, sourceChannel } = getIbcInfo( + sourceChainName, + destChainName + ); + + const fee: StdFee = { + amount: coins('1000', transferToken.denom), + gas: '250000', + }; + + const token = { + denom: transferToken.denom, + amount: transferAmount, + }; + + const stamp = Date.now(); + const timeoutInNanos = (stamp + 1.2e6) * 1e6; + + const msg = transfer({ + sourcePort, + sourceChannel, + sender: sourceAddress, + receiver: destAddress, + token, + // @ts-ignore + timeoutHeight: undefined, + timeoutTimestamp: BigInt(timeoutInNanos), + }); + + await tx([msg], { + fee, + onSuccess: () => { + updateData(); + closeModal(); + }, + }); + + setIsLoading(false); + }; + + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const statColor = useColorModeValue('#2C3137', '#EEF2F8'); + const arrowColor = useColorModeValue('#4A5568', '#A7B4C2'); + const bgColor = useColorModeValue('#EEF2F8', '#1D2024'); + const cancelColor = useColorModeValue('#697584', '#EEF2F8'); + + return ( + + + + + {transferType}  + {transferToken.symbol} + + + + + +
+ +
+ +
+ + + + + + + Estimated time:  + 20 seconds + + +
+ + + + + Cancel + + +
+
+ ); +}; + +const ChainAddress = ({ + type, + chainName, + logoUrl, + address, +}: { + type: 'sourceChain' | 'destChain'; + chainName: string; + logoUrl: string | undefined; + address: string | undefined; +}) => { + const titleColor = useColorModeValue('#697584', '#A7B4C2'); + const bgColor = useColorModeValue('#EEF2F8', '#1D2024'); + + return ( + + + {type === 'sourceChain' ? 'From' : 'To'} {chainName} + + + + + {address && shortenAddress(address)} + + + + ); +}; + +export default TransferModal; diff --git a/examples/asset-list/components/asset-list/index.ts b/examples/asset-list/components/asset-list/index.ts new file mode 100644 index 000000000..8a7f6313c --- /dev/null +++ b/examples/asset-list/components/asset-list/index.ts @@ -0,0 +1,2 @@ +export * from './types'; +export * from './AssetListSection'; diff --git a/examples/asset-list/components/asset-list/types.tsx b/examples/asset-list/components/asset-list/types.tsx new file mode 100644 index 000000000..8978bf1f4 --- /dev/null +++ b/examples/asset-list/components/asset-list/types.tsx @@ -0,0 +1,48 @@ +export type PrettyAsset = { + logoUrl: string | undefined; + symbol: string; + prettyChainName: string; + displayAmount: string; + dollarValue: string; + amount: string; + denom: string; +}; + +export type Token = { + price: number; + denom: string; + symbol: string; + liquidity: number; + volume_24h: number; + volume_24h_change: number; + name: string; + price_24h_change: number; + price_7d_change: number; + exponent: number; + display: string; +}; + +export type PriceHash = { + [key: string]: number; +}; + +export const Transfer = { + Deposit: 'Deposit', + Withdraw: 'Withdraw', +} as const; + +export type TransferValues = typeof Transfer[keyof typeof Transfer]; + +export type TransferInfo = { + type: TransferValues; + sourceChainName: string; + destChainName: string; + token: PrettyAsset; +}; + +export type AssetOption = { + value: string; + icon: { png: string | undefined }; +}; + +export type PrettyAssetOption = PrettyAsset & AssetOption; diff --git a/examples/asset-list/components/common/Footer.tsx b/examples/asset-list/components/common/Footer.tsx new file mode 100644 index 000000000..de05359f2 --- /dev/null +++ b/examples/asset-list/components/common/Footer.tsx @@ -0,0 +1,92 @@ +import { + Box, + Divider, + Grid, + Heading, + Text, + Stack, + Link, + Icon, + useColorModeValue, +} from '@chakra-ui/react'; +import { dependencies, products, Project } from '../../config'; +import { LinkIcon } from '@chakra-ui/icons'; + +function Product({ name, desc, link }: Project) { + return ( + + + {name} → + {desc} + + + ); +}; + +function Dependency({ name, desc, link }: Project) { + return ( + + + + + + + + {name} + + + {desc} + + + + + ); +}; + +export function Footer() { + return ( + <> + + {products.map((product) => ( + + ))} + + + {dependencies.map((dependency) => ( + + ))} + + + + + + Built with + + Cosmology + + + + ); +}; diff --git a/examples/asset-list/components/common/Header.tsx b/examples/asset-list/components/common/Header.tsx new file mode 100644 index 000000000..0bc251177 --- /dev/null +++ b/examples/asset-list/components/common/Header.tsx @@ -0,0 +1,46 @@ +import { + Box, + Heading, + Text, + Button, + Flex, + Icon, + useColorMode, + useColorModeValue, + Link, +} from '@chakra-ui/react'; +import { BsFillMoonStarsFill, BsFillSunFill } from 'react-icons/bs'; +import { dependencies } from '@/config'; + +const stacks = ['CosmosKit', 'Next.js']; + +const osmojs = dependencies[0]; + +export function Header() { + const { colorMode, toggleColorMode } = useColorMode(); + + return ( + <> + + + + + + Create Cosmos App + + + Welcome to  + + {stacks.join(' + ')} + {' + '} + + {osmojs.name} + + + + + + ); +}; diff --git a/examples/asset-list/components/common/Layout.tsx b/examples/asset-list/components/common/Layout.tsx new file mode 100644 index 000000000..c25860dc7 --- /dev/null +++ b/examples/asset-list/components/common/Layout.tsx @@ -0,0 +1,19 @@ +import Head from 'next/head'; +import { Container } from '@chakra-ui/react'; +import { Header } from './Header'; +import { Footer } from './Footer'; + +export const Layout = ({ children }: { children: React.ReactNode }) => { + return ( + + + Create Cosmos App + + + +
+ {children} +