-
Notifications
You must be signed in to change notification settings - Fork 110
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: generate typescript bindings (#825)
* feat: generate typescript bindigns * remove _pb * add index.d.ts * package.json * make typescript --------- Co-authored-by: Lucas Bertrand <[email protected]>
- Loading branch information
Showing
51 changed files
with
8,420 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
version: v1 | ||
managed: | ||
enabled: true | ||
plugins: | ||
- plugin: buf.build/bufbuild/es:v1.3.0 | ||
out: ../typescript | ||
opt: target=dts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#!/usr/bin/env bash | ||
|
||
DIR="typescript" | ||
|
||
rm -rf $DIR | ||
|
||
(cd proto && buf generate --template buf.ts.yaml) | ||
|
||
cat <<EOL > $DIR/package.json | ||
{ | ||
"name": "@zetachain/blockchain-types", | ||
"version": "0.0.0-set-on-publish", | ||
"description": "", | ||
"main": "", | ||
"keywords": [], | ||
"author": "ZetaChain", | ||
"license": "MIT" | ||
} | ||
EOL | ||
|
||
# Loop through all directories recursively | ||
find "$DIR" -type d | while read -r dir; do | ||
# Check if there are any .d.ts files in the directory | ||
if ls "$dir"/*.d.ts &> /dev/null; then | ||
# Create or clear index.d.ts in the directory | ||
> "$dir/index.d.ts" | ||
|
||
# Loop through all .d.ts files in the directory | ||
for file in "$dir"/*.d.ts; do | ||
# Extract the base filename without the .d.ts extension | ||
base_name=$(basename "$file" .d.ts) | ||
# If the base name is not 'index', append the export line to index.d.ts | ||
if [ "$base_name" != "index" ]; then | ||
echo "export * from \"./$base_name\";" >> "$dir/index.d.ts" | ||
fi | ||
done | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// @generated by protoc-gen-es v1.3.0 with parameter "target=dts" | ||
// @generated from file common/bitcoin/bitcoin.proto (package bitcoin, syntax proto3) | ||
/* eslint-disable */ | ||
// @ts-nocheck | ||
|
||
import type { BinaryReadOptions, FieldList, JsonReadOptions, JsonValue, PartialMessage, PlainMessage } from "@bufbuild/protobuf"; | ||
import { Message, proto3 } from "@bufbuild/protobuf"; | ||
|
||
/** | ||
* @generated from message bitcoin.Proof | ||
*/ | ||
export declare class Proof extends Message<Proof> { | ||
/** | ||
* @generated from field: bytes tx_bytes = 1; | ||
*/ | ||
txBytes: Uint8Array; | ||
|
||
/** | ||
* @generated from field: bytes path = 2; | ||
*/ | ||
path: Uint8Array; | ||
|
||
/** | ||
* @generated from field: uint32 index = 3; | ||
*/ | ||
index: number; | ||
|
||
constructor(data?: PartialMessage<Proof>); | ||
|
||
static readonly runtime: typeof proto3; | ||
static readonly typeName = "bitcoin.Proof"; | ||
static readonly fields: FieldList; | ||
|
||
static fromBinary(bytes: Uint8Array, options?: Partial<BinaryReadOptions>): Proof; | ||
|
||
static fromJson(jsonValue: JsonValue, options?: Partial<JsonReadOptions>): Proof; | ||
|
||
static fromJsonString(jsonString: string, options?: Partial<JsonReadOptions>): Proof; | ||
|
||
static equals(a: Proof | PlainMessage<Proof> | undefined, b: Proof | PlainMessage<Proof> | undefined): boolean; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./bitcoin_pb"; |
Oops, something went wrong.