Add code generation to @cosmjs/stargate
This commit is contained in:
parent
d293905964
commit
fb35426ae7
@ -35,7 +35,12 @@
|
||||
"test-chrome": "yarn pack-web && karma start --single-run --browsers ChromeHeadless",
|
||||
"test": "yarn build-or-skip && yarn test-node",
|
||||
"coverage": "nyc --reporter=text --reporter=lcov yarn test --quiet",
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js"
|
||||
"pack-web": "yarn build-or-skip && webpack --mode development --config webpack.web.config.js",
|
||||
"preget-proto": "rm -rf proto",
|
||||
"get-proto": "REF=master ./scripts/get-proto.sh",
|
||||
"predefine-proto": "./scripts/predefine-proto.sh",
|
||||
"define-proto": "./scripts/define-proto.sh",
|
||||
"postdefine-proto": "prettier --write \"src/generated/codecimpl.*\""
|
||||
},
|
||||
"dependencies": {
|
||||
"@cosmjs/encoding": "^0.22.0",
|
||||
@ -43,6 +48,7 @@
|
||||
"@cosmjs/math": "^0.22.0",
|
||||
"@cosmjs/proto-signing": "^0.22.0",
|
||||
"@cosmjs/tendermint-rpc": "^0.22.0",
|
||||
"@cosmjs/utils": "^0.22.0"
|
||||
"@cosmjs/utils": "^0.22.0",
|
||||
"protobufjs": "~6.10.0"
|
||||
}
|
||||
}
|
||||
|
||||
14
packages/stargate/scripts/define-proto.sh
Executable file
14
packages/stargate/scripts/define-proto.sh
Executable file
@ -0,0 +1,14 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck > /dev/null && shellcheck "$0"
|
||||
|
||||
TMP_DIR="./tmp"
|
||||
JS_SOURCE_FILE="$TMP_DIR/codecimpl.js"
|
||||
DEFINITIONS_FILE="$TMP_DIR/codecimpl.d.ts"
|
||||
OUTPUT_DIR="./src/generated/"
|
||||
|
||||
|
||||
yarn pbts "$JS_SOURCE_FILE" -o "$DEFINITIONS_FILE"
|
||||
yarn tsc --removeComments --outDir "$OUTPUT_DIR" --allowJs "$JS_SOURCE_FILE"
|
||||
cp "$DEFINITIONS_FILE" "$OUTPUT_DIR"
|
||||
rm "$DEFINITIONS_FILE" "$JS_SOURCE_FILE"
|
||||
19
packages/stargate/scripts/get-proto.sh
Executable file
19
packages/stargate/scripts/get-proto.sh
Executable file
@ -0,0 +1,19 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck > /dev/null && shellcheck "$0"
|
||||
|
||||
PROTO_DIR="./proto"
|
||||
COSMOS_DIR="$PROTO_DIR/cosmos"
|
||||
COSMOS_SDK_DIR="$COSMOS_DIR/cosmos-sdk"
|
||||
ZIP_FILE="$COSMOS_DIR/tmp.zip"
|
||||
REF=${REF:-"master"}
|
||||
SUFFIX=${REF}
|
||||
|
||||
[[ $SUFFIX =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] && SUFFIX=${SUFFIX#v}
|
||||
|
||||
mkdir -p "$COSMOS_DIR"
|
||||
|
||||
wget -qO "$ZIP_FILE" "https://github.com/cosmos/cosmos-sdk/archive/$REF.zip" \
|
||||
&& unzip "$ZIP_FILE" "*.proto" -d "$COSMOS_DIR" \
|
||||
&& mv "$COSMOS_SDK_DIR-$SUFFIX" "$COSMOS_SDK_DIR" \
|
||||
&& rm "$ZIP_FILE"
|
||||
30
packages/stargate/scripts/predefine-proto.sh
Executable file
30
packages/stargate/scripts/predefine-proto.sh
Executable file
@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
set -o errexit -o nounset -o pipefail
|
||||
command -v shellcheck > /dev/null && shellcheck "$0"
|
||||
|
||||
GENERATED_DIR="./tmp"
|
||||
ROOT_PROTO_DIR="./proto/cosmos/cosmos-sdk"
|
||||
COSMOS_PROTO_DIR="$ROOT_PROTO_DIR/proto/cosmos"
|
||||
TENDERMINT_PROTO_DIR="$ROOT_PROTO_DIR/third_party/proto/tendermint"
|
||||
GOOGLE_PROTO_DIR="$ROOT_PROTO_DIR/third_party/proto/google"
|
||||
|
||||
mkdir -p "$GENERATED_DIR"
|
||||
yarn pbjs \
|
||||
-t static-module \
|
||||
--es6 \
|
||||
-w commonjs \
|
||||
-o "$GENERATED_DIR/codecimpl.js" \
|
||||
--sparse \
|
||||
--no-beautify \
|
||||
--no-delimited \
|
||||
--no-verify \
|
||||
--no-convert \
|
||||
"$COSMOS_PROTO_DIR/cosmos.proto" \
|
||||
"$COSMOS_PROTO_DIR/bank/bank.proto" \
|
||||
"$COSMOS_PROTO_DIR/crypto/crypto.proto" \
|
||||
"$COSMOS_PROTO_DIR/tx/tx.proto" \
|
||||
"$COSMOS_PROTO_DIR/tx/signing/signing.proto" \
|
||||
"$TENDERMINT_PROTO_DIR/abci/types/types.proto" \
|
||||
"$TENDERMINT_PROTO_DIR/crypto/merkle/merkle.proto" \
|
||||
"$TENDERMINT_PROTO_DIR/libs/kv/types.proto" \
|
||||
"$GOOGLE_PROTO_DIR/protobuf/any.proto"
|
||||
5470
packages/stargate/src/generated/codecimpl.d.ts
vendored
Normal file
5470
packages/stargate/src/generated/codecimpl.d.ts
vendored
Normal file
File diff suppressed because it is too large
Load Diff
4437
packages/stargate/src/generated/codecimpl.js
Normal file
4437
packages/stargate/src/generated/codecimpl.js
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user