Skip to content

Commit

Permalink
Merge pull request #181 from osmosis-labs/codegen
Browse files Browse the repository at this point in the history
Adds basic `ts-codegen` support for the frontend
  • Loading branch information
JakeHartnell authored Apr 28, 2024
2 parents c170596 + b78f3a4 commit f8a1e91
Show file tree
Hide file tree
Showing 7 changed files with 3,455 additions and 3 deletions.
23 changes: 20 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,41 @@
# Generated by Cargo
# will have compiled files and executables


# Compiled files and executables
/target/
artifacts/
internal/


# Code coverage
codecov.json


# These are backup files generated by rustfmt
**/*.rs.bk
.idea


# These files should not be commited
*.log

schema/
schemas/

.DS_Store
.vscode
.idea


# node.js
dist
mjs
main
module
node_modules


# Codegen builds in src
src


# Optional npm cache directory
.npm
56 changes: 56 additions & 0 deletions codegen/codegen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const codegen = require('@cosmwasm/ts-codegen').default;

codegen({
contracts: [
{
name: 'Vault',
dir: './contracts/provider/vault/schema'
},
{
name: 'ExternalStaking',
dir: './contracts/provider/external-staking/schema'
},
{
name: 'NativeStaking',
dir: './contracts/provider/native-staking/schema'
},
{
name: 'NativeStakingProxy',
dir: './contracts/provider/native-staking-proxy/schema'
},
{
name: 'Converter',
dir: './contracts/consumer/converter/schema'
},
{
name: 'RemotePriceFeed',
dir: './contracts/consumer/remote-price-feed/schema'
},
{
name: 'SimplePriceFeed',
dir: './contracts/consumer/simple-price-feed/schema'
},
{
name: 'VirtualStaking',
dir: './contracts/consumer/virtual-staking/schema'
},
],
outPath: './src/',
options: {
bundle: {
bundleFile: 'index.ts',
scope: 'contracts'
},
messageComposer: {
enabled: true
},
useContractsHooks: {
enabled: false // if you enable this, add react!
},
client: {
enabled: true
},
}
}).then(() => {
console.log('✨ all done!');
});
45 changes: 45 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "@mesh-security/types",
"version": "0.4.2",
"description": "",
"author": "Jake Hartnell <[email protected]>",
"homepage": "https://github.com/osmosis-labs/mesh-security",
"license": "MIT",
"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",
"build:rename": "publish-scripts --cmd rename --srcDir mjs --outDir dist --findExt js --replaceExt mjs",
"build": "npm run clean && npm run build:cjs && npm run build:mjs && npm run build:rename && rimraf mjs",
"clean:mjs": "rimraf mjs",
"clean:dist": "rimraf dist",
"clean": "npm run build:clean && npm run clean:mjs && npm run clean:dist",
"codegen": "node codegen/codegen.js"
},
"repository": {
"type": "git",
"url": "https://github.com/osmosis-labs/mesh-security"
},
"keywords": [],
"bugs": {
"url": "https://github.com/osmosis-labs/mesh-security/issues"
},
"devDependencies": {
"@cosmwasm/ts-codegen": "^0.33.0",
"publish-scripts": "1.9.0",
"rimraf": "^5.0.0",
"typescript": "^5.0.4"
},
"dependencies": {
"@cosmjs/cosmwasm-stargate": "^0.32.1"
}
}
File renamed without changes.
File renamed without changes.
29 changes: 29 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
]
}
Loading

0 comments on commit f8a1e91

Please sign in to comment.