Skip to content

Commit

Permalink
Move ts files to src directory
Browse files Browse the repository at this point in the history
  • Loading branch information
MCozhusheck committed Aug 6, 2024
1 parent e1c94f1 commit 9797143
Show file tree
Hide file tree
Showing 12 changed files with 328 additions and 328 deletions.
44 changes: 21 additions & 23 deletions bindings/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,57 +3,55 @@

set -e

DIRECTORY_PATH="./src/types" # replace with your directory path
HELPERS_PATH="./src/helpers" # replace with your directory path
INDEX_FILE="./index.ts"
npx shx rm -rf $DIRECTORY_PATH/*
SOURCE_PATH="./src"
TYPES_DIR="types"
HELPERS_DIR="helpers"
INDEX_FILE="index.ts"
npx shx rm -rf $SOURCE_PATH/$TYPES_DIR
npx shx rm -rf $SOURCE_PATH/$INDEX_FILE

cargo test --workspace --exclude integration_tests export_bindings --features ts
npx shx mv ../dan_layer/bindings/src/types/* ./src/types/
npx shx rm -rf ../dan_layer/bindings/

# Remove the index file if it exists
if [ -f "$INDEX_FILE" ]; then
npx shx rm "$INDEX_FILE"
fi

# Add the license header
echo "// Copyright 2023 The Tari Project" >> $INDEX_FILE
echo "// SPDX-License-Identifier: BSD-3-Clause" >> $INDEX_FILE
echo "" >> $INDEX_FILE
echo "// Copyright 2023 The Tari Project" >> $SOURCE_PATH/$INDEX_FILE
echo "// SPDX-License-Identifier: BSD-3-Clause" >> $SOURCE_PATH/$INDEX_FILE
echo "" >> $SOURCE_PATH/$INDEX_FILE

cd ./src
# Generate the index file
for file in $(find $DIRECTORY_PATH -name "*.ts" -maxdepth 1 | sort); do
for file in $(find $TYPES_DIR -name "*.ts" -maxdepth 1 | sort); do
MODULE_NAME="${file%.*}"
echo "export * from '$MODULE_NAME';" >> $INDEX_FILE
echo "export * from './$MODULE_NAME';" >> $INDEX_FILE
done

for dir in $(find $DIRECTORY_PATH -mindepth 1 -maxdepth 1 -type d | sort); do
for dir in $(find $TYPES_DIR -mindepth 1 -maxdepth 1 -type d | sort); do
index_file="$(basename $dir).ts"
if [ -f "$index_file" ]; then
npx shx rm "$index_file"
fi
echo "// Copyright 2023 The Tari Project" >> $index_file
echo "// SPDX-License-Identifier: BSD-3-Clause" >> $index_file
echo "" >> $index_file
echo "// Copyright 2023 The Tari Project" >> "$index_file"
echo "// SPDX-License-Identifier: BSD-3-Clause" >> "$index_file"
echo "" >> "$index_file"
for file in $(find $dir -name "*.ts" -maxdepth 1); do
# FILE_NAME=$(basename $file)
MODULE_NAME="${file%.*}"
echo "export * from '$MODULE_NAME';" >> $index_file
echo "export * from './$MODULE_NAME';" >> "$index_file"
done
# echo "export * from './$(basename $dir)';" >> $INDEX_FILE // TODO: solve namespace conflict between validator-node-client and tari-indexer-client
done

# Add helpers
for file in $(find $HELPERS_PATH -name "*.ts" | sort); do
for file in $(find $HELPERS_DIR -name "*.ts" | sort); do
FILE_NAME=$(basename $file)
if [ "$FILE_NAME" != "index.ts" ]; then
MODULE_NAME="${FILE_NAME%.*}"
echo "export * from '$HELPERS_PATH/$MODULE_NAME';" >> $INDEX_FILE
echo "export * from './$HELPERS_DIR/$MODULE_NAME';" >> $INDEX_FILE
fi
done

# This is temporary solution to the problem of 'Commitment' not being exported, and we have to do manual types in the
# code for BTreeMap<Commitment, ConfidentialOutput>. Because of this the ConfidentialOutput type is not imported.
echo "import { ConfidentialOutput } from './ConfidentialOutput';" >> $DIRECTORY_PATH/ResourceContainer.ts
echo "import { ConfidentialOutput } from './ConfidentialOutput';" >> $TYPES_DIR/ResourceContainer.ts

npx prettier --write "./**/*.{ts,tsx,css,json}" --log-level=warn
116 changes: 0 additions & 116 deletions bindings/index.ts

This file was deleted.

5 changes: 3 additions & 2 deletions bindings/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"name": "@tari-project/typescript-bindings",
"version": "1.0.4",
"version": "1.0.5",
"description": "",
"main": "index.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

export * from "./src/types/base-node-client/BaseLayerValidatorNode";
export * from "./types/base-node-client/BaseLayerValidatorNode";
116 changes: 116 additions & 0 deletions bindings/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

export * from "./types/AccessRule";
export * from "./types/Account";
export * from "./types/Amount";
export * from "./types/ArgDef";
export * from "./types/Arg";
export * from "./types/AuthHook";
export * from "./types/Block";
export * from "./types/BucketId";
export * from "./types/Claims";
export * from "./types/Command";
export * from "./types/CommitteeInfo";
export * from "./types/CommitteeShardInfo";
export * from "./types/Committee";
export * from "./types/ComponentAccessRules";
export * from "./types/ComponentAddress";
export * from "./types/ComponentBody";
export * from "./types/ComponentHeader";
export * from "./types/ComponentKey";
export * from "./types/ConfidentialClaim";
export * from "./types/ConfidentialOutputStatement";
export * from "./types/ConfidentialOutput";
export * from "./types/ConfidentialStatement";
export * from "./types/ConfidentialTransferInputSelection";
export * from "./types/ConfidentialWithdrawProof";
export * from "./types/Decision";
export * from "./types/ElgamalVerifiableBalance";
export * from "./types/EntityId";
export * from "./types/Epoch";
export * from "./types/Event";
export * from "./types/Evidence";
export * from "./types/ExecutedTransaction";
export * from "./types/ExecuteResult";
export * from "./types/FeeBreakdown";
export * from "./types/FeeClaimAddress";
export * from "./types/FeeClaim";
export * from "./types/FeeCostBreakdown";
export * from "./types/FeeReceipt";
export * from "./types/FeeSource";
export * from "./types/FinalizeResult";
export * from "./types/ForeignProposalState";
export * from "./types/ForeignProposal";
export * from "./types/FunctionDef";
export * from "./types/IndexedValue";
export * from "./types/IndexedWellKnownTypes";
export * from "./types/InstructionResult";
export * from "./types/Instruction";
export * from "./types/JrpcPermissions";
export * from "./types/JrpcPermission";
export * from "./types/LeaderFee";
export * from "./types/LockFlag";
export * from "./types/LogEntry";
export * from "./types/LogLevel";
export * from "./types/Metadata";
export * from "./types/NetworkCommitteeInfo";
export * from "./types/NodeHeight";
export * from "./types/NonFungibleAddressContents";
export * from "./types/NonFungibleAddress";
export * from "./types/NonFungibleContainer";
export * from "./types/NonFungibleId";
export * from "./types/NonFungibleIndexAddress";
export * from "./types/NonFungibleIndex";
export * from "./types/NonFungibleToken";
export * from "./types/NonFungible";
export * from "./types/NumPreshards";
export * from "./types/Ordering";
export * from "./types/OwnerRule";
export * from "./types/PeerAddress";
export * from "./types/ProofId";
export * from "./types/QuorumCertificate";
export * from "./types/QuorumDecision";
export * from "./types/RejectReason";
export * from "./types/RequireRule";
export * from "./types/ResourceAccessRules";
export * from "./types/ResourceAddress";
export * from "./types/ResourceContainer";
export * from "./types/Resource";
export * from "./types/ResourceType";
export * from "./types/RestrictedAccessRule";
export * from "./types/RuleRequirement";
export * from "./types/ShardEvidence";
export * from "./types/ShardGroup";
export * from "./types/Shard";
export * from "./types/SubstateAddress";
export * from "./types/SubstateDestroyed";
export * from "./types/SubstateDiff";
export * from "./types/SubstateId";
export * from "./types/SubstateLockFlag";
export * from "./types/SubstateRecord";
export * from "./types/SubstateRequirement";
export * from "./types/Substate";
export * from "./types/SubstateType";
export * from "./types/SubstateValue";
export * from "./types/TemplateDef";
export * from "./types/TemplateDefV1";
export * from "./types/TransactionAtom";
export * from "./types/TransactionPoolRecord";
export * from "./types/TransactionPoolStage";
export * from "./types/TransactionReceiptAddress";
export * from "./types/TransactionReceipt";
export * from "./types/TransactionResult";
export * from "./types/TransactionSignature";
export * from "./types/TransactionStatus";
export * from "./types/Transaction";
export * from "./types/Type";
export * from "./types/UnclaimedConfidentialOutput";
export * from "./types/UnsignedTransaction";
export * from "./types/ValidatorSignature";
export * from "./types/VaultId";
export * from "./types/Vault";
export * from "./types/VersionedSubstateIdLockIntent";
export * from "./types/VersionedSubstateId";
export * from "./types/ViewableBalanceProof";
export * from "./helpers/helpers";
37 changes: 37 additions & 0 deletions bindings/src/tari-indexer-client.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause

export * from "./types/tari-indexer-client/GetAllVnsRequest";
export * from "./types/tari-indexer-client/GetSubstateRequest";
export * from "./types/tari-indexer-client/Connection";
export * from "./types/tari-indexer-client/GetTemplateDefinitionResponse";
export * from "./types/tari-indexer-client/GetNonFungibleCountRequest";
export * from "./types/tari-indexer-client/GetSubstateResponse";
export * from "./types/tari-indexer-client/GetNonFungiblesResponse";
export * from "./types/tari-indexer-client/GetAllVnsResponse";
export * from "./types/tari-indexer-client/InspectSubstateRequest";
export * from "./types/tari-indexer-client/ListSubstateItem";
export * from "./types/tari-indexer-client/ListSubstatesResponse";
export * from "./types/tari-indexer-client/GetTransactionResultRequest";
export * from "./types/tari-indexer-client/SubmitTransactionRequest";
export * from "./types/tari-indexer-client/GetNonFungiblesRequest";
export * from "./types/tari-indexer-client/GetTransactionResultResponse";
export * from "./types/tari-indexer-client/ListSubstatesRequest";
export * from "./types/tari-indexer-client/GetIdentityResponse";
export * from "./types/tari-indexer-client/GetRelatedTransactionsResponse";
export * from "./types/tari-indexer-client/SubmitTransactionResponse";
export * from "./types/tari-indexer-client/GetEpochManagerStatsResponse";
export * from "./types/tari-indexer-client/GetRelatedTransactionsRequest";
export * from "./types/tari-indexer-client/ConnectionDirection";
export * from "./types/tari-indexer-client/InspectSubstateResponse";
export * from "./types/tari-indexer-client/AddPeerRequest";
export * from "./types/tari-indexer-client/NonFungibleSubstate";
export * from "./types/tari-indexer-client/GetNonFungibleCountResponse";
export * from "./types/tari-indexer-client/GetCommsStatsResponse";
export * from "./types/tari-indexer-client/GetTemplateDefinitionRequest";
export * from "./types/tari-indexer-client/ListTemplatesResponse";
export * from "./types/tari-indexer-client/IndexerTransactionFinalizedResult";
export * from "./types/tari-indexer-client/ListTemplatesRequest";
export * from "./types/tari-indexer-client/GetNonFungibleCollectionsResponse";
export * from "./types/tari-indexer-client/AddPeerResponse";
export * from "./types/tari-indexer-client/GetConnectionsResponse";
Loading

0 comments on commit 9797143

Please sign in to comment.