hashgraph / hashgraph/stablecoin-studio

SDK cannot resolve @hashgraph/stablecoin-npm-contracts due to missing build artifacts

Open
#1,468 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
67
Forks
37
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
The root `build:contracts` script in `package.json` only runs `compile:force` for the contracts workspace. This compiles the Solidity contracts but fails to run the TypeScript build (`tsc`). Consequently, the `packages/contracts/build/` directory is never created, causing the SDK (which depends on that directory) to fail during its build process with `TS2307` module resolution errors.

The problem has been spotted when following the https://github.com/hashgraph/stablecoin-studio/blob/main/documentation/sdk/quick-start.md

**To Reproduce**
Steps to reproduce the behavior:
1. Ensure the `packages/contracts/build/` directory is missing (e.g., run `rm -rf packages/contracts/build`).
2. Run `npm run build:contracts` from the root directory.
3. Run `npm run build:sdk` from the root directory.
4. See error: `error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.`

Full error log:
```
stanislawkurzyp@ws112:~/Documents/hedera/stablecoin-studio$ npm run build:sdk

> @hashgraph/[hedera-stable-coin@4.2.0](mailto:hedera-stable-coin@4.2.0) build:sdk
> npm run build --workspace=packages/sdk

> @hashgraph/[stablecoin-npm-sdk@4.2.0](mailto:stablecoin-npm-sdk@4.2.0) prebuild
> npm run lint

> @hashgraph/[stablecoin-npm-sdk@4.2.0](mailto:stablecoin-npm-sdk@4.2.0) lint
> eslint . --ext .ts --ext .mts

/home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk/src/app/service/TransactionService.ts
326:66 warning Missing return type on function @typescript-eslint/explicit-function-return-type
328:20 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
330:49 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
330:56 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
335:66 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
341:69 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any

/home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk/src/app/usecase/command/network/connect/ConnectCommandHandler.ts
39:8 warning Forbidden non-null assertion @typescript-eslint/no-non-null-assertion

/home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk/src/port/in/StableCoin.ts
241:2 warning Missing return type on function @typescript-eslint/explicit-function-return-type

/home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk/src/port/out/hs/external/ExternalEVMTransactionAdapter.ts
64:35 warning '_offsetMinutes' is assigned a value but never used @typescript-eslint/no-unused-vars
70:3 warning '_transactionType' is defined but never used @typescript-eslint/no-unused-vars
71:3 warning '_startDate' is defined but never used @typescript-eslint/no-unused-vars

/home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk/src/port/out/hs/walletconnect/HederaWalletConnectTransactionAdapter.ts
148:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
152:29 warning Unexpected any. Specify a different type @typescript-eslint/no-explicit-any
667:37 warning Missing return type on function @typescript-eslint/explicit-function-return-type

✖ 14 problems (0 errors, 14 warnings)

> @hashgraph/[stablecoin-npm-sdk@4.2.0](mailto:stablecoin-npm-sdk@4.2.0) build
> rimraf build && npx tsc -p tsconfig.json && npx tsc -p tsconfig-cjs.json

__tests__/app/service/TransactionService.test.ts:69:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

69 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

__tests__/jest-setup-file.ts:42:49 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

42 import { StableCoinFactoryFacet__factory } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/HoldOperations.ts:28:46 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

28 import { HoldManagementFacet__factory } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/QueryOperations.ts:31:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

31 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/RescueOperations.ts:27:41 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

27 import { RescuableFacet__factory } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/ReserveOperations.ts:30:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

30 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/RoleOperations.ts:31:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

31 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/SupplierOperations.ts:28:45 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

28 import { SupplierAdminFacet__factory } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/TokenControlOperations.ts:45:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

45 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/TokenOperations.ts:53:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

53 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/hs/operations/UpdateOperations.ts:30:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

30 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/rpc/RPCQueryAdapter.ts:42:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

42 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

src/port/out/rpc/RPCQueryAdapter.ts:297:26 - error TS7006: Parameter 'id' implicitly has an 'any' type.

297 return holdsIdFor.map((id) => Number(id));
~~

src/port/out/rpc/RPCTransactionAdapter.ts:51:8 - error TS2307: Cannot find module '@hashgraph/stablecoin-npm-contracts' or its corresponding type declarations.

51 } from '@hashgraph/stablecoin-npm-contracts';
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 14 errors in 13 files.

Errors Files
1 __tests__/app/service/TransactionService.test.ts:69
1 __tests__/jest-setup-file.ts:42
1 src/port/out/hs/operations/HoldOperations.ts:28
1 src/port/out/hs/operations/QueryOperations.ts:31
1 src/port/out/hs/operations/RescueOperations.ts:27
1 src/port/out/hs/operations/ReserveOperations.ts:30
1 src/port/out/hs/operations/RoleOperations.ts:31
1 src/port/out/hs/operations/SupplierOperations.ts:28
1 src/port/out/hs/operations/TokenControlOperations.ts:45
1 src/port/out/hs/operations/TokenOperations.ts:53
1 src/port/out/hs/operations/UpdateOperations.ts:30
2 src/port/out/rpc/RPCQueryAdapter.ts:42
1 src/port/out/rpc/RPCTransactionAdapter.ts:51
npm error Lifecycle script `build` failed with error:
npm error code 2
npm error path /home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk
npm error workspace @hashgraph/[stablecoin-npm-sdk@4.2.0](mailto:stablecoin-npm-sdk@4.2.0)
npm error location /home/stanislawkurzyp/Documents/hedera/stablecoin-studio/packages/sdk
npm error command failed
npm error command sh -c rimraf build && npx tsc -p tsconfig.json && npx tsc -p tsconfig-cjs.json
```

**Expected behavior**
Running `npm run build:contracts` should perform a full build of the contracts package (compiling both Solidity and TypeScript), populating the `build/` directory so that downstream packages like the SDK can successfully resolve the dependency.

**Screenshots**
N/A

**Desktop:**
- OS: Linux
- Browser: N/A (Terminal/Node.js environment)
- Version: Node v22.22.2 (LTS)

**Smartphone (please complete the following information):**
- Device: N/A
- OS: N/A
- Browser: N/A
- Version: N/A

**Additional context**
The fix involves updating the root `package.json` script:
```diff
- "build:contracts": "npm run compile:force --workspace=packages/contracts",
+ "build:contracts": "npm run build --workspace=packages/contracts",
```
This ensures that the `packages/contracts/package.json` "build" script (which includes `tsc`) is executed.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.