Skip to content

Commit

Permalink
1753 fix thorest package to point to v2 core sdk package (#1755)
Browse files Browse the repository at this point in the history
* fix: update sdk core package to v2

* fix: import new types from sdk package instead of locally

* fix: update thorest package version

* fix: fix test command

* fix: upgrade  undici nested dependency

* fix: fix import - first try
  • Loading branch information
saraantole authored Jan 30, 2025
1 parent 5851807 commit ff326dc
Show file tree
Hide file tree
Showing 21 changed files with 84 additions and 149 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"test:integration:solo": "(yarn start-thor-solo && yarn test:integration && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:examples": "turbo test:examples",
"test:examples:solo": "(yarn start-thor-solo && yarn test:examples && yarn stop-thor-solo) || yarn stop-thor-solo",
"test": "turbo test --force --filter='packages/core' --filter='packages/thorest' && yarn merge-coverage",
"test": "turbo test --force --filter='@vechain/sdk-core' --filter='@vechain/sdk-thorest-api' && yarn merge-coverage",
"test:browser": "turbo test:browser --force && yarn merge-coverage",
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:browser:solo": "(yarn start-thor-solo && yarn test:browser && yarn stop-thor-solo) || yarn stop-thor-solo",
Expand Down Expand Up @@ -89,7 +89,8 @@
"hardhat": "^2.22.15"
},
"resolutions": {
"cross-spawn": "^7.0.5"
"cross-spawn": "^7.0.5",
"undici": "^5.28.5"
},
"version": "1.22.22"
}
}
96 changes: 48 additions & 48 deletions packages/thorest/package.json
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
{
"name": "@vechain/sdk-thorest-api",
"version": "1.0.0-rc.6",
"description": "This module connects decentralized applications (dApps) with the Thorest API.",
"author": "VeChain Foundation",
"license": "MIT",
"homepage": "https://github.com/vechain/vechain-sdk-js",
"repository": {
"type": "git",
"url": "github:vechain/vechain-sdk-js"
},
"keywords": [
"VeChain"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist",
"src",
"package.json",
"README.md",
"LICENSE"
],
"scripts": {
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"check:circular-dependencies": "npx madge --json --circular --extensions ts src | jq '. | length' | awk '{if($1 > 15) exit 1}'",
"lint": "eslint",
"format": "prettier --write src/**/*.ts tests/**/*.ts solo-seeding/**/*.ts",
"start-thor-solo": "echo 'Starting thor solo node ...' && docker compose -f ../../docker-compose.thor.yml up -d --wait && echo '\nThor solo node started ...'",
"stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose -f ../../docker-compose.thor.yml down && echo 'Thor solo node stopped ...'",
"test:unit": "rm -rf ./coverageUnit && UNIT=true jest --coverage --coverageDirectory=coverageUnit --group=unit",
"test:integration": "rm -rf ./coverageIntegration && jest --coverage --coverageDirectory=coverageIntegration --group=integration",
"test:integration:solo": "(yarn start-thor-solo && yarn test:integration && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:browser": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit --config ./jest.config.browser.js",
"test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit",
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:browser:solo": "(yarn start-thor-solo && yarn test:browser && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@vechain/sdk-core": "1.0.0-rc.6",
"ws": "^8.18.0"
},
"devDependencies": {
"@types/ws": "^8.5.13",
"jest-fetch-mock": "^3.0.3",
"whatwg-fetch": "^3.6.20"
}
}
"name": "@vechain/sdk-thorest-api",
"version": "2.0.0-beta.1",
"description": "This module connects decentralized applications (dApps) with the Thorest API.",
"author": "VeChain Foundation",
"license": "MIT",
"homepage": "https://github.com/vechain/vechain-sdk-js",
"repository": {
"type": "git",
"url": "github:vechain/vechain-sdk-js"
},
"keywords": [
"VeChain"
],
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist",
"src",
"package.json",
"README.md",
"LICENSE"
],
"scripts": {
"build": "rm -rf ./dist && tsup-node src/index.ts --format cjs,esm --dts",
"check:circular-dependencies": "npx madge --json --circular --extensions ts src | jq '. | length' | awk '{if($1 > 15) exit 1}'",
"lint": "eslint",
"format": "prettier --write src/**/*.ts tests/**/*.ts solo-seeding/**/*.ts",
"start-thor-solo": "echo 'Starting thor solo node ...' && docker compose -f ../../docker-compose.thor.yml up -d --wait && echo '\nThor solo node started ...'",
"stop-thor-solo": "echo 'Stopping thor solo node ...' && docker compose -f ../../docker-compose.thor.yml down && echo 'Thor solo node stopped ...'",
"test:unit": "rm -rf ./coverageUnit && UNIT=true jest --coverage --coverageDirectory=coverageUnit --group=unit",
"test:integration": "rm -rf ./coverageIntegration && jest --coverage --coverageDirectory=coverageIntegration --group=integration",
"test:integration:solo": "(yarn start-thor-solo && yarn test:integration && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:browser": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit --config ./jest.config.browser.js",
"test": "rm -rf ./coverage && jest --coverage --coverageDirectory=coverage --group=integration --group=unit",
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo",
"test:browser:solo": "(yarn start-thor-solo && yarn test:browser && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@vechain/sdk-core": "2.0.0-beta.1",
"ws": "^8.18.0"
},
"devDependencies": {
"@types/ws": "^8.5.13",
"jest-fetch-mock": "^3.0.3",
"whatwg-fetch": "^3.6.20"
}
}
3 changes: 1 addition & 2 deletions packages/thorest/src/thor/accounts/ExecuteCodesRequest.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Clause, type ClauseJSON } from '../transactions';
import { UInt } from '../../../../core/src';
import { Address, BlockRef, Units, VTHO } from '@vechain/sdk-core';
import { Address, BlockRef, UInt, Units, VTHO } from '@vechain/sdk-core';

class ExecuteCodesRequest {
readonly provedWork?: string;
Expand Down
3 changes: 1 addition & 2 deletions packages/thorest/src/thor/blocks/RegularBlockResponse..ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Address, ThorId, Units, VTHO } from '@vechain/sdk-core';
import { UInt } from '../../../../core/src';
import { Address, ThorId, UInt, Units, VTHO } from '@vechain/sdk-core';

class RegularBlockResponse {
readonly number: UInt;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import {
Address,
type BlockRef,
HexUInt,
UInt,
Units,
VET,
VTHO
} from '@vechain/sdk-core';
import { UInt } from '../../../../core/src';

class PostDebugTracerCallRequest {
readonly name?: TracerName;
Expand Down
3 changes: 1 addition & 2 deletions packages/thorest/src/thor/debug/StorageRangeOption.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Address, ThorId } from '@vechain/sdk-core';
import { UInt } from '../../../../core/src';
import { Address, ThorId, UInt } from '@vechain/sdk-core';

class StorageRangeOption {
readonly address: Address;
Expand Down
4 changes: 1 addition & 3 deletions packages/thorest/src/thor/explorer/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { FetchHttpClient } from '../../http';
import { ThorNetworks } from '../ThorNetworks';
import { RetrieveBlock, RetrieveBlockPath } from '../blocks';
import { Revision } from '@vechain/sdk-core';
import { Revision, TxId } from '@vechain/sdk-core';
import { RetrieveTransactionByID } from '../transactions';

import { TxId } from '../../../../core/src/vcdm/BlockId';

async function getBestBlockNumber(
httpClient: FetchHttpClient
): Promise<number> {
Expand Down
2 changes: 1 addition & 1 deletion packages/thorest/src/thor/logs/FilterOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UInt } from '../../../../core/src';
import { UInt } from '@vechain/sdk-core';

class FilterOptions {
readonly limit?: UInt;
Expand Down
2 changes: 1 addition & 1 deletion packages/thorest/src/thor/logs/FilterRange.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { UInt } from '../../../../core/src';
import { UInt } from '@vechain/sdk-core';

class FilterRange {
readonly unit?: FilterRangeUnits;
Expand Down
3 changes: 1 addition & 2 deletions packages/thorest/src/thor/logs/LogMeta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Address, BlockId } from '@vechain/sdk-core';
import { TxId, UInt } from '../../../../core/src/vcdm';
import { Address, BlockId, TxId, UInt } from '@vechain/sdk-core';

class LogMeta {
readonly blockID: BlockId;
Expand Down
4 changes: 1 addition & 3 deletions packages/thorest/src/thor/node/PeerStat.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { BlockId } from '@vechain/sdk-core';

import { UInt } from '../../../../core/src/vcdm/UInt';
import { BlockId, UInt } from '@vechain/sdk-core';

class PeerStat {
readonly name: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { BlockId, HexUInt, Units, VTHO } from '@vechain/sdk-core';
import { UInt } from '../../../../core';
import { BlockId, HexUInt, UInt, Units, VTHO } from '@vechain/sdk-core';

class SubscriptionBeat2Response {
readonly gasLimit: VTHO;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { UInt, type TxId } from '../../../../core';
import { Address, BlockId, ThorId, Units, VTHO } from '@vechain/sdk-core';
import {
Address,
BlockId,
ThorId,
type TxId,
UInt,
Units,
VTHO
} from '@vechain/sdk-core';

class SubscriptionBlockResponse {
readonly number: UInt;
Expand Down
6 changes: 1 addition & 5 deletions packages/thorest/src/thor/transactions/GetTxResponse.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { Clause, type ClauseJSON } from './Clause';
import { TxMeta, type TxMetaJSON } from './TxMeta';
import { Address, BlockId, VTHO } from '@vechain/sdk-core';
import { UInt } from '../../../../core/src';

import { Nonce } from '../../../../core/src/vcdm/Nonce';
import { TxId } from '../../../../core/src/vcdm/BlockId';
import { Address, BlockId, Nonce, TxId, UInt, VTHO } from '@vechain/sdk-core';

class GetTxResponse {
readonly id: TxId;
Expand Down
4 changes: 1 addition & 3 deletions packages/thorest/src/thor/transactions/ReceiptMeta.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { TxMeta, type TxMetaJSON } from './TxMeta';
import { Address } from '@vechain/sdk-core';

import { TxId } from '../../../../core/src/vcdm/BlockId';
import { Address, TxId } from '@vechain/sdk-core';

class ReceiptMeta extends TxMeta {
readonly txID: TxId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ import {
GetRawTxResponse,
type GetRawTxResponseJSON
} from './GetRawTxResponse';
import { type BlockId } from '@vechain/sdk-core';
import { type TxId, type BlockId } from '@vechain/sdk-core';
import { type HttpClient } from '../../http';
import { type ThorRequest } from '../ThorRequest';
import { type ThorResponse } from '../ThorResponse';

import { type TxId } from '../../../../core/src/vcdm/BlockId';

class RetrieveRawTransactionByID
implements ThorRequest<RetrieveRawTransactionByID, GetRawTxResponse>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { type BlockId } from '@vechain/sdk-core';
import { type TxId, type BlockId } from '@vechain/sdk-core';
import { type HttpClient, type HttpPath, type HttpQuery } from '../../http';
import { GetTxResponse, type GetTxResponseJSON } from './GetTxResponse';
import { type ThorRequest } from '../ThorRequest';
import { type ThorResponse } from '../ThorResponse';

import { type TxId } from '../../../../core/src/vcdm/BlockId';

class RetrieveTransactionByID
implements ThorRequest<RetrieveTransactionByID, GetTxResponse>
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
import { type BlockId } from '@vechain/sdk-core';
import { type TxId, type BlockId } from '@vechain/sdk-core';
import { type HttpClient, type HttpPath, type HttpQuery } from '../../http';
import {
GetTxReceiptResponse,
type GetTxReceiptResponseJSON
} from './GetTxReceiptResponse';
import { type ThorRequest } from '../ThorRequest';
import { type ThorResponse } from '../ThorResponse';

import { type TxId } from '../../../../core/src/vcdm/BlockId';

class RetrieveTransactionReceipt
implements ThorRequest<RetrieveTransactionReceipt, GetTxReceiptResponse>
{
Expand Down
4 changes: 1 addition & 3 deletions packages/thorest/src/thor/transactions/TxMeta.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
import { BlockId } from '@vechain/sdk-core';

import { UInt } from '../../../../core/src/vcdm/UInt';
import { BlockId, UInt } from '@vechain/sdk-core';

class TxMeta {
readonly blockID: BlockId;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, test } from '@jest/globals';

import { THOR_SOLO_URL, ThorClient } from '../../../../network/';
import { THOR_SOLO_URL, ThorClient } from '../../../../network/src';
import {
transfer1VTHOClause,
transferTransactionBody
Expand Down
Loading

1 comment on commit ff326dc

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test Coverage

Summary

Lines Statements Branches Functions
Coverage: 86%
86.34% (1708/1978) 85.42% (586/686) 71.82% (339/472)
Title Tests Skipped Failures Errors Time
core 836 0 💤 0 ❌ 0 🔥 42.736s ⏱️

Please sign in to comment.