Skip to content

Commit

Permalink
Add basic ts-codegen support for the frontend
Browse files Browse the repository at this point in the history
  • Loading branch information
JakeHartnell committed Dec 21, 2023
1 parent 25774f0 commit 7c1f00b
Show file tree
Hide file tree
Showing 7 changed files with 3,522 additions and 2 deletions.
129 changes: 127 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,24 +1,149 @@


# Generated by Cargo


# will have 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

# publish-scripts
# AUTOMATED DONT EDIT
/index.js
/VirtualStaking.types.js
/VirtualStaking.message-composer.js
/VirtualStaking.client.js
/Vault.types.js
/Vault.message-composer.js
/Vault.client.js
/SimplePriceFeed.types.js
/SimplePriceFeed.message-composer.js
/SimplePriceFeed.client.js
/RemotePriceFeed.types.js
/RemotePriceFeed.message-composer.js
/RemotePriceFeed.client.js
/NativeStakingProxy.types.js
/NativeStakingProxy.message-composer.js
/NativeStakingProxy.client.js
/NativeStaking.types.js
/NativeStaking.message-composer.js
/NativeStaking.client.js
/ExternalStaking.types.js
/ExternalStaking.message-composer.js
/ExternalStaking.client.js
/Converter.types.js
/Converter.message-composer.js
/Converter.client.js
/index.js.map
/VirtualStaking.types.js.map
/VirtualStaking.message-composer.js.map
/VirtualStaking.client.js.map
/Vault.types.js.map
/Vault.message-composer.js.map
/Vault.client.js.map
/SimplePriceFeed.types.js.map
/SimplePriceFeed.message-composer.js.map
/SimplePriceFeed.client.js.map
/RemotePriceFeed.types.js.map
/RemotePriceFeed.message-composer.js.map
/RemotePriceFeed.client.js.map
/NativeStakingProxy.types.js.map
/NativeStakingProxy.message-composer.js.map
/NativeStakingProxy.client.js.map
/NativeStaking.types.js.map
/NativeStaking.message-composer.js.map
/NativeStaking.client.js.map
/ExternalStaking.types.js.map
/ExternalStaking.message-composer.js.map
/ExternalStaking.client.js.map
/Converter.types.js.map
/Converter.message-composer.js.map
/Converter.client.js.map
/index.mjs
/VirtualStaking.types.mjs
/VirtualStaking.message-composer.mjs
/VirtualStaking.client.mjs
/Vault.types.mjs
/Vault.message-composer.mjs
/Vault.client.mjs
/SimplePriceFeed.types.mjs
/SimplePriceFeed.message-composer.mjs
/SimplePriceFeed.client.mjs
/RemotePriceFeed.types.mjs
/RemotePriceFeed.message-composer.mjs
/RemotePriceFeed.client.mjs
/NativeStakingProxy.types.mjs
/NativeStakingProxy.message-composer.mjs
/NativeStakingProxy.client.mjs
/NativeStaking.types.mjs
/NativeStaking.message-composer.mjs
/NativeStaking.client.mjs
/ExternalStaking.types.mjs
/ExternalStaking.message-composer.mjs
/ExternalStaking.client.mjs
/Converter.types.mjs
/Converter.message-composer.mjs
/Converter.client.mjs
/index.d.ts
/VirtualStaking.types.d.ts
/VirtualStaking.message-composer.d.ts
/VirtualStaking.client.d.ts
/Vault.types.d.ts
/Vault.message-composer.d.ts
/Vault.client.d.ts
/SimplePriceFeed.types.d.ts
/SimplePriceFeed.message-composer.d.ts
/SimplePriceFeed.client.d.ts
/RemotePriceFeed.types.d.ts
/RemotePriceFeed.message-composer.d.ts
/RemotePriceFeed.client.d.ts
/NativeStakingProxy.types.d.ts
/NativeStakingProxy.message-composer.d.ts
/NativeStakingProxy.client.d.ts
/NativeStaking.types.d.ts
/NativeStaking.message-composer.d.ts
/NativeStaking.client.d.ts
/ExternalStaking.types.d.ts
/ExternalStaking.message-composer.d.ts
/ExternalStaking.client.d.ts
/Converter.types.d.ts
/Converter.message-composer.d.ts
/Converter.client.d.ts

# END publish-scripts

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.1",
"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.31.0"
}
}
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 7c1f00b

Please sign in to comment.