From ee9c4e6f6963ef469f9b431239492144a356ea94 Mon Sep 17 00:00:00 2001 From: Miguel Naveira <47919901+mrnaveira@users.noreply.github.com> Date: Thu, 8 Aug 2024 08:49:07 +0100 Subject: [PATCH] fix: broken npm build (#32) Description --- * Fixed all build problems * Added new CI job to automatically run `npm run build` on new PRs Motivation and Context --- The library build is currently broken. This PR fixes all building problems and adds a new CI job to run `npm run build` on new PRs, so we can avoid merging broken code into the `main` branch. How Has This Been Tested? --- Running `npm run build` What process can a PR reviewer use to test or verify this change? --- See previous section Breaking Changes --- - [x] None - [ ] Requires data directory on base node to be deleted - [ ] Requires hard fork - [ ] Other - Please specify --- .github/workflows/ci.yml | 25 +++++++++++++++++++++++ src/builders/helpers/submitTransaction.ts | 2 +- src/builders/types/FinalizeResult.ts | 2 +- src/builders/types/Instruction.ts | 2 +- src/builders/types/SubstateDiff.ts | 2 +- src/builders/types/SubstateRequirement.ts | 2 +- src/builders/types/Transaction.ts | 2 +- src/builders/types/VersionedSubstateId.ts | 2 +- src/providers/types.ts | 2 +- src/templates/Account.ts | 2 +- tsconfig.json | 3 ++- 11 files changed, 36 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..abd2f9a --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +--- +name: CI + +'on': + pull_request: + types: + - opened + - reopened + - synchronize + +concurrency: + # https://docs.github.com/en/actions/examples/using-concurrency-expressions-and-a-test-matrix + group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' + cancel-in-progress: ${{ !startsWith(github.ref, 'refs/tags/v') || github.ref != 'refs/heads/main' }} + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "20" + - run: npm ci + - run: npm run build \ No newline at end of file diff --git a/src/builders/helpers/submitTransaction.ts b/src/builders/helpers/submitTransaction.ts index cd78b64..0878284 100644 --- a/src/builders/helpers/submitTransaction.ts +++ b/src/builders/helpers/submitTransaction.ts @@ -41,7 +41,7 @@ export async function submitAndWaitForTransaction( result, }; } catch (e) { - throw new Error("Transaction failed:", e); + throw new Error(`Transaction failed: ${e}`); } } diff --git a/src/builders/types/FinalizeResult.ts b/src/builders/types/FinalizeResult.ts index 4bf945a..e5c17bd 100644 --- a/src/builders/types/FinalizeResult.ts +++ b/src/builders/types/FinalizeResult.ts @@ -1,4 +1,4 @@ -import { FeeReceipt, InstructionResult, LogEntry, RejectReason } from "@tariproject/typescript-bindings"; +import { FeeReceipt, InstructionResult, LogEntry, RejectReason } from "@tari-project/typescript-bindings"; import { SubstateDiff } from "./SubstateDiff"; export type TxResultAccept = { Accept: SubstateDiff }; diff --git a/src/builders/types/Instruction.ts b/src/builders/types/Instruction.ts index e0e754f..cdb9048 100644 --- a/src/builders/types/Instruction.ts +++ b/src/builders/types/Instruction.ts @@ -1,4 +1,4 @@ -import { ComponentAddress, LogLevel } from "@tariproject/typescript-bindings"; +import { ComponentAddress, LogLevel } from "@tari-project/typescript-bindings"; import { Arg } from "./Arg"; import { ConfidentialClaim } from "./ConfidentialClaim"; import { Amount } from "./Amount"; diff --git a/src/builders/types/SubstateDiff.ts b/src/builders/types/SubstateDiff.ts index 57450a5..00e5358 100644 --- a/src/builders/types/SubstateDiff.ts +++ b/src/builders/types/SubstateDiff.ts @@ -1,4 +1,4 @@ -import { Substate, SubstateId } from "@tariproject/typescript-bindings"; +import { Substate, SubstateId } from "@tari-project/typescript-bindings"; export type UpSubstates = Array<[SubstateId, Substate]>; export type DownSubstates = Array<[SubstateId, number]>; diff --git a/src/builders/types/SubstateRequirement.ts b/src/builders/types/SubstateRequirement.ts index 4b243db..b4f0e7b 100644 --- a/src/builders/types/SubstateRequirement.ts +++ b/src/builders/types/SubstateRequirement.ts @@ -1,4 +1,4 @@ -import { SubstateId } from "@tariproject/typescript-bindings"; +import { SubstateId } from "@tari-project/typescript-bindings"; export interface SubstateRequirement { substateId: SubstateId; diff --git a/src/builders/types/Transaction.ts b/src/builders/types/Transaction.ts index 253a3ec..e994069 100644 --- a/src/builders/types/Transaction.ts +++ b/src/builders/types/Transaction.ts @@ -1,4 +1,4 @@ -import { TransactionSignature } from "@tariproject/typescript-bindings"; +import { TransactionSignature } from "@tari-project/typescript-bindings"; import { Instruction } from "./Instruction"; import { SubstateRequirement } from "./SubstateRequirement"; import { Epoch } from "./Epoch"; diff --git a/src/builders/types/VersionedSubstateId.ts b/src/builders/types/VersionedSubstateId.ts index e0fd7f3..890aa8a 100644 --- a/src/builders/types/VersionedSubstateId.ts +++ b/src/builders/types/VersionedSubstateId.ts @@ -1,4 +1,4 @@ -import { SubstateId } from "@tariproject/typescript-bindings"; +import { SubstateId } from "@tari-project/typescript-bindings"; export interface VersionedSubstateId { substateId: SubstateId; diff --git a/src/providers/types.ts b/src/providers/types.ts index 1864ef0..907a1e5 100644 --- a/src/providers/types.ts +++ b/src/providers/types.ts @@ -1,4 +1,4 @@ -import { FinalizeResult } from "@tariproject/typescript-bindings"; +import { FinalizeResult } from "@tari-project/typescript-bindings"; export type SubstateMetadata = { substate_id: string; diff --git a/src/templates/Account.ts b/src/templates/Account.ts index c4e1efd..70d9cdf 100644 --- a/src/templates/Account.ts +++ b/src/templates/Account.ts @@ -1,4 +1,4 @@ -import { ConfidentialWithdrawProof, NonFungibleId, ResourceAddress } from "@tariproject/typescript-bindings"; +import { ConfidentialWithdrawProof, NonFungibleId, ResourceAddress } from "@tari-project/typescript-bindings"; import { Amount } from "../builders/types/Amount"; import { TariMethodDefinition, WorkspaceArg } from "../builders/types"; import { TemplateFactory } from "./TemplateFactory"; diff --git a/tsconfig.json b/tsconfig.json index 86efd55..9795f18 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,6 +7,7 @@ "moduleResolution": "bundler", "allowSyntheticDefaultImports": true, "strict": true, - "noEmit": true + "noEmit": true, + "strictPropertyInitialization": false, } } \ No newline at end of file