Skip to content

Commit

Permalink
fix(bindings): remove dist from gitignore to expose build project (#1115
Browse files Browse the repository at this point in the history
)

Description
---
Last PR broke last
[@tari-project/typescript-bindings](https://www.npmjs.com/package/@tari-project/typescript-bindings?activeTab=readme)
version. package.json points entrypoint as `./dist/index.js` but since
CI doesn't builds project every run (as it is costly) the package
doesn't have `dist` folder and effectively we don't export anything.

Motivation and Context
---
Fix package for other projects like tari.js which relies on
typescript-bindings.

How Has This Been Tested?
---
Imported locally build typescript-bindings with dist folder present.
Also imported the tari.js to the [Tari
Universe](https://github.com/tari-project/tari-universe) and to the
[faucet tapplet](https://github.com/MCozhusheck/faucet-tapplet) to check
if project depending also on tari.js would work.

What process can a PR reviewer use to test or verify this change?
---
Eg. change typescript-bindings dependency for tari.js to local (in my
case it's `"@tari-project/typescript-bindings":
"file:../tari-dan/bindings",`) and check if it's working


Breaking Changes
---

- [x] None
- [ ] Requires data directory to be deleted
- [ ] Other - Please specify
  • Loading branch information
MCozhusheck authored Aug 12, 2024
1 parent 3db6653 commit 7b914ce
Show file tree
Hide file tree
Showing 667 changed files with 3,351 additions and 2 deletions.
1 change: 0 additions & 1 deletion bindings/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
dist/
node_modules/
1 change: 1 addition & 0 deletions bindings/dist/base-node-client.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./types/base-node-client/BaseLayerValidatorNode";
3 changes: 3 additions & 0 deletions bindings/dist/base-node-client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
export * from "./types/base-node-client/BaseLayerValidatorNode";
11 changes: 11 additions & 0 deletions bindings/dist/helpers/helpers.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { JrpcPermission } from "../types/JrpcPermission";
import { RejectReason } from "../types/RejectReason";
import { SubstateDiff } from "../types/SubstateDiff";
import { SubstateId } from "../types/SubstateId";
import { TransactionResult } from "../types/TransactionResult";
export declare function substateIdToString(substateId: SubstateId | null): string;
export declare function stringToSubstateId(substateId: string): SubstateId;
export declare function rejectReasonToString(reason: RejectReason | null): string;
export declare function getSubstateDiffFromTransactionResult(result: TransactionResult): SubstateDiff | null;
export declare function getRejectReasonFromTransactionResult(result: TransactionResult): RejectReason | null;
export declare function jrpcPermissionToString(jrpcPermission: JrpcPermission): string;
129 changes: 129 additions & 0 deletions bindings/dist/helpers/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
// Copyright 2023 The Tari Project
// SPDX-License-Identifier: BSD-3-Clause
export function substateIdToString(substateId) {
if (substateId === null) {
return "";
}
if ("Component" in substateId) {
return substateId.Component;
}
if ("Resource" in substateId) {
return substateId.Resource;
}
if ("Vault" in substateId) {
return substateId.Vault;
}
if ("UnclaimedConfidentialOutput" in substateId) {
return substateId.UnclaimedConfidentialOutput;
}
if ("NonFungible" in substateId) {
return substateId.NonFungible;
}
if ("NonFungibleIndex" in substateId) {
return `${substateId.NonFungibleIndex.resource_address}:${substateId.NonFungibleIndex.index}`;
}
if ("TransactionReceipt" in substateId) {
return substateId.TransactionReceipt;
}
if ("FeeClaim" in substateId) {
return substateId.FeeClaim;
}
console.error("Unknown substate id", substateId);
return "Unknown";
}
export function stringToSubstateId(substateId) {
const parts = splitOnce(substateId, "_");
if (!parts) {
throw new Error(`Invalid substate id: ${substateId}`);
}
switch (parts[0]) {
case "component":
return { Component: parts[1] };
case "resource":
if (parts[1].includes(" nft_")) {
return { NonFungible: parts[1] };
}
return { Resource: parts[1] };
case "vault":
return { Vault: parts[1] };
case "commitment":
return { UnclaimedConfidentialOutput: parts[1] };
case "txreceipt":
return { TransactionReceipt: parts[1] };
case "feeclaim":
return { FeeClaim: parts[1] };
default:
throw new Error(`Unknown substate id: ${substateId}`);
}
}
export function rejectReasonToString(reason) {
if (reason === null) {
return "";
}
if (typeof reason === "string") {
return reason;
}
if ("ShardsNotPledged" in reason) {
return `ShardsNotPledged(${reason.ShardsNotPledged})`;
}
if ("ExecutionFailure" in reason) {
return `ExecutionFailure(${reason.ExecutionFailure})`;
}
if ("ShardPledgedToAnotherPayload" in reason) {
return `ShardPledgedToAnotherPayload(${reason.ShardPledgedToAnotherPayload})`;
}
if ("ShardRejected" in reason) {
return `ShardRejected(${reason.ShardRejected})`;
}
if ("FeesNotPaid" in reason) {
return `FeesNotPaid(${reason.FeesNotPaid})`;
}
console.error("Unknown reason", reason);
return "Unknown";
}
export function getSubstateDiffFromTransactionResult(result) {
if ("Accept" in result) {
return result.Accept;
}
if ("AcceptFeeRejectRest" in result) {
return result.AcceptFeeRejectRest[0];
}
return null;
}
export function getRejectReasonFromTransactionResult(result) {
if ("Reject" in result) {
return result.Reject;
}
if ("AcceptFeeRejectRest" in result) {
return result.AcceptFeeRejectRest[1];
}
return null;
}
export function jrpcPermissionToString(jrpcPermission) {
if (typeof jrpcPermission === "string") {
return jrpcPermission;
}
if ("NftGetOwnershipProof" in jrpcPermission) {
return `NftGetOwnershipProof(${jrpcPermission.NftGetOwnershipProof})`;
}
if ("AccountBalance" in jrpcPermission) {
return `AccountBalance(${substateIdToString(jrpcPermission.AccountBalance)})`;
}
if ("AccountList" in jrpcPermission) {
return `AccountList(${jrpcPermission.AccountList})`;
}
if ("TransactionSend" in jrpcPermission) {
return `TransactionSend(${jrpcPermission.TransactionSend})`;
}
if ("GetNft" in jrpcPermission) {
return `GetNft(${substateIdToString(jrpcPermission.GetNft[0])}, ${jrpcPermission.GetNft[1]})`;
}
return "Unknown";
}
function splitOnce(str, separator) {
const index = str.indexOf(separator);
if (index === -1) {
return null;
}
return [str.slice(0, index), str.slice(index + 1)];
}
234 changes: 234 additions & 0 deletions bindings/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
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 "./base-node-client";
export * from "./tari-indexer-client";
export * from "./validator-node-client";
export * from "./wallet-daemon-client";
export * from "./helpers/helpers";
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 "./base-node-client";
export * from "./tari-indexer-client";
export * from "./validator-node-client";
export * from "./wallet-daemon-client";
export * from "./helpers/helpers";
Loading

0 comments on commit 7b914ce

Please sign in to comment.