Skip to content

Commit

Permalink
fix: adding dependencies per package correctly (#1513)
Browse files Browse the repository at this point in the history
* fix: first commit

* fix: first commit

* fix: more changes

* fix: more changes

* fix: more changes

* fix: more changes

* fix: more changes
  • Loading branch information
freemanzMrojo authored Nov 13, 2024
1 parent 9b9a807 commit 32a8bb2
Show file tree
Hide file tree
Showing 34 changed files with 42 additions and 111 deletions.
1 change: 1 addition & 0 deletions apps/sdk-vite-integration/src/const/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
// eslint-disable-next-line react-refresh/only-export-components
export * from './const';
18 changes: 12 additions & 6 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FlatCompat } from "@eslint/eslintrc";
import js from "@eslint/js";
import typescriptEslint from "@typescript-eslint/eslint-plugin";
import tsParser from "@typescript-eslint/parser";
import localRules from "eslint-plugin-local-rules";
import sonarjs from "eslint-plugin-sonarjs";
import globals from "globals";
import tsParser from "@typescript-eslint/parser";
import path from "node:path";
import { fileURLToPath } from "node:url";
import js from "@eslint/js";
import { FlatCompat } from "@eslint/eslintrc";

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
Expand All @@ -28,7 +28,7 @@ export default [{
"plugin:sonarjs/recommended-legacy",
"plugin:security/recommended-legacy",
), {
files: ["src/**/*.ts", "tests/**/*.ts"],
files: ["**/src/**/*.ts", "**/tests/**/*.ts"],
plugins: {
"@typescript-eslint": typescriptEslint,
"local-rules": localRules,
Expand Down Expand Up @@ -88,6 +88,12 @@ export default [{
"security/detect-unsafe-regex": "off",
"security/detect-non-literal-fs-filename": "off",
"sonarjs/sonar-no-unused-vars": "off",
"sonarjs/sonar-no-fallthrough": "off"
},
"sonarjs/sonar-no-fallthrough": "off",
"import/no-extraneous-dependencies": ["error", {"devDependencies": false, "optionalDependencies": false, "peerDependencies": false}]
}
}, {
files: ["**/tests/**/*.ts"],
rules: {
"import/no-extraneous-dependencies": "off",
}
}];
2 changes: 2 additions & 0 deletions packages/aws-kms-adapter/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
},
"dependencies": {
"@aws-sdk/client-kms": "^3.682.0",
"@noble/curves": "^1.6.0",
"@vechain/sdk-core": "1.0.0-rc.2",
"@vechain/sdk-errors": "1.0.0-rc.2",
"@vechain/sdk-network": "1.0.0-rc.2",
"asn1js": "^3.0.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ describe('KMSVeChainSigner - Thor Solo', () => {
[awsClientParameters, delegatorAwsClientParameters] = JSON.parse(
fs.readFileSync(awsCredentialsPath, 'utf8')
) as KMSClientParameters[];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.log('Loading test credentials');
const testAwsCredentialsPath = path.resolve(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ describe('KMSVeChainSigner - Testnet', () => {
[awsClientParameters] = JSON.parse(
fs.readFileSync(awsCredentialsPath, 'utf8')
) as KMSClientParameters[];
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (error) {
console.log('Loading test credentials');
const testAwsCredentialsPath = path.resolve(
Expand Down
3 changes: 3 additions & 0 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@
"dependencies": {
"@ethereumjs/rlp": "^5.0.2",
"@noble/ciphers": "^1.0.0",
"@noble/curves": "^1.6.0",
"@noble/hashes": "^1.5.0",
"@scure/base": "^1.1.9",
"@scure/bip32": "^1.4.0",
"@scure/bip39": "^1.4.0",
"@vechain/sdk-errors": "1.0.0-rc.2",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/hdkey/HDKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ class HDKey extends s_bip32.HDKey {
return s_bip32.HDKey.fromExtendedKey(
base58.encode(expandedPrivateKey)
) as HDKey;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
throw new InvalidSecp256k1PrivateKey(
'HDNode.fromPrivateKey',
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/keystore/cryptography/ethers/keystore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ async function decrypt(
stringifyData(keystore),
password
)) as KeystoreAccount;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
throw new InvalidKeystoreParams(
'keystore.decrypt()',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -560,7 +560,6 @@ function isValid(keystore: Keystore): boolean {
) {
return true;
}
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {} // Return false if parsing fails.
return false;
}
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/secp256k1/Secp256k1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ class Secp256k1 {
public static async generatePrivateKey(): Promise<Uint8Array> {
try {
return nc_secp256k1.utils.randomPrivateKey();
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
// Generate an ECDSA key pair
const cryptoKey = await global.crypto.subtle.generateKey(
Expand Down Expand Up @@ -203,7 +202,6 @@ class Secp256k1 {
public static randomBytes(bytesLength?: number): Uint8Array {
try {
return nh_randomBytes(bytesLength);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return global.crypto.getRandomValues(
new Uint8Array(bytesLength ?? 32)
Expand Down
2 changes: 0 additions & 2 deletions packages/core/src/vcdm/FixedPointNumber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ class FixedPointNumber implements VeChainDataModel<FixedPointNumber> {
public comparedTo(that: FixedPointNumber): null | number {
try {
return this.compareTo(that);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return null;
}
Expand Down Expand Up @@ -955,7 +954,6 @@ class FixedPointNumber implements VeChainDataModel<FixedPointNumber> {
this.fractionalDigits,
FixedPointNumber.sqr(this.scaledValue, this.fractionalDigits)
);
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return FixedPointNumber.NaN;
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/vcdm/Hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ class Hex implements VeChainDataModel<Hex> {
// The sign is part of the IEEE 754 representation hence no need to consider `this.sign` property.
return new DataView(this.bytes.buffer).getFloat64(0);
}
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
throw new InvalidOperation('Hex.n', 'not an IEEE 754 float 64 number', {
hex: this.toString()
});
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/vcdm/Txt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ class Txt extends String implements VeChainDataModel<Txt> {
try {
return BigInt(this.toString());
} catch (e) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-call
throw new InvalidOperation(
'Txt.bi()',
"Can't cast to big integer",
Expand Down
1 change: 0 additions & 1 deletion packages/core/src/vcdm/currency/Coin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ abstract class Coin implements Currency {
isEqual(that: Currency): boolean {
try {
return this.compareTo(that) === 0;
// eslint-disable-next-line @typescript-eslint/no-unused-vars
} catch (e) {
return false;
}
Expand Down
1 change: 0 additions & 1 deletion packages/core/tests/vcdm/hash/Blake2b256.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Blake2b256 class tests', () => {
});

test('Return hash for no content', () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const hash = Blake2b256.of(NO_CONTENT);
expect(hash.isEqual(NO_CONTENT_BLAKE2B256)).toBe(true);
});
Expand Down
1 change: 0 additions & 1 deletion packages/core/tests/vcdm/hash/Keccak256.unit.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ describe('Keccak256 class tests', () => {
});

test('Return hash for no content', () => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
const hash = Keccak256.of(NO_CONTENT);
expect(hash.isEqual(NO_CONTENT_KECCAK256)).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ describe('Hardhat factory adapter tests', () => {
const signer: Signer = new VoidSigner('0x');

signer.sendTransaction = jest.fn(async (_tx) => {
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return await ({} as unknown as Promise<TransactionResponse>);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ describe('Helpers tests', () => {

provider.thorClient.transactions.waitForTransaction = jest.fn(
async (_txID: string, _options?: WaitForTransactionOptions) => {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
return await Promise.resolve(null);
}
);
Expand Down
9 changes: 5 additions & 4 deletions packages/hardhat-plugin/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
"test:solo": "(yarn start-thor-solo && yarn test && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@vechain/sdk-core": "1.0.0-rc.2",
"@vechain/sdk-errors": "1.0.0-rc.2",
"@vechain/sdk-ethers-adapter": "1.0.0-rc.2",
"@vechain/sdk-logging": "1.0.0-rc.2",
"@vechain/sdk-network": "1.0.0-rc.2",
"ethers": "6.13.4"
},
"devDependencies": {
"@nomicfoundation/hardhat-ethers": "^3.0.8"
"ethers": "6.13.4",
"hardhat": "^2.22.15"
}
}
1 change: 1 addition & 0 deletions packages/network/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
"test:browser:solo": "(yarn start-thor-solo && yarn test:browser && yarn stop-thor-solo) || yarn stop-thor-solo"
},
"dependencies": {
"@noble/curves": "^1.6.0",
"@vechain/sdk-core": "1.0.0-rc.2",
"@vechain/sdk-errors": "1.0.0-rc.2",
"@vechain/sdk-logging": "1.0.0-rc.2",
Expand Down
1 change: 1 addition & 0 deletions packages/network/solo-seeding/thor-solo-seeding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ const txBody = {
*/
const txBodies = CLAUSES_VTHO.map((clause, index) => ({
...txBody,
// eslint-disable-next-line security/detect-object-injection
clauses: [clause, CLAUSES_VET[index]]
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ abstract class VeChainAbstractSigner implements VeChainSigner {
}

// Otherwise return a random number
// eslint-disable-next-line @typescript-eslint/no-unsafe-return,@typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
return Hex.random(6).toString();
}

Expand Down
6 changes: 1 addition & 5 deletions packages/network/src/thor-client/contracts/model/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,7 @@ class Contract<TAbi extends Abi> {
TAbi,
ExtractAbiFunctionNames<TAbi>
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
> = {} as ContractFunctionClause<
TAbi,
ExtractAbiFunctionNames<TAbi>
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
>;
> = {} as ContractFunctionClause<TAbi, ExtractAbiFunctionNames<TAbi>>;

public criteria: ContractFunctionCriteria<
TAbi,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,11 +329,9 @@ describe('Hardhat provider tests', () => {
expect(results[1].method).toBe('eth_subscription');

// @ts-expect-error - Asserting that log data is present
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(results[0].params.result.length).toBeGreaterThan(0);

// @ts-expect-error - Asserting that log data is present
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(results[1].params.result.length).toBeGreaterThan(0);
}, 30000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ describe('Hardhat provider tests - testnet', () => {
* Init thor client and provider before each test
*/
beforeEach(() => {
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
provider = new HardhatVeChainProvider(
new ProviderInternalBaseWallet([]),
TESTNET_URL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -337,11 +337,9 @@ describe('VeChain provider tests - solo', () => {
expect(results[1].method).toBe('eth_subscription');

// @ts-expect-error - Asserting that log data is present
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(results[0].params.result.length).toBeGreaterThan(0);

// @ts-expect-error - Asserting that log data is present
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
expect(results[1].params.result.length).toBeGreaterThan(0);
}, 30000);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,11 +241,10 @@ describe('VeChain base signer tests', () => {
const expectedErrorString = 'not an error instance';
jest.spyOn(Txt, 'of')
.mockImplementationOnce(() => {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw expectedErrorString;
})
.mockImplementationOnce(() => {
// eslint-disable-next-line @typescript-eslint/only-throw-error, sonarjs/no-throw-literal
// eslint-disable-next-line sonarjs/no-throw-literal
throw undefined;
});
await expect(
Expand Down Expand Up @@ -304,11 +303,10 @@ describe('VeChain base signer tests', () => {
const expectedErrorString = 'not an error instance';
jest.spyOn(Hex, 'of')
.mockImplementationOnce(() => {
// eslint-disable-next-line @typescript-eslint/only-throw-error
throw expectedErrorString;
})
.mockImplementationOnce(() => {
// eslint-disable-next-line @typescript-eslint/only-throw-error, sonarjs/no-throw-literal
// eslint-disable-next-line sonarjs/no-throw-literal
throw undefined;
});
await expect(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,9 @@ describe('ThorClient - ERC20 Contracts', () => {
]
];

expect(
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
eventsWithArgsArray.map((x) => x.decodedData)
).toEqual(expectedEvents);
expect(eventsWithArgsArray.map((x) => x.decodedData)).toEqual(
expectedEvents
);

// listen with an args object

Expand All @@ -106,10 +105,9 @@ describe('ThorClient - ERC20 Contracts', () => {
})
.get();

expect(
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
eventsWithAnArgsObject.map((x) => x.decodedData)
).toEqual(expectedEvents);
expect(eventsWithAnArgsObject.map((x) => x.decodedData)).toEqual(
expectedEvents
);
}, 10000); // Set a timeout of 10000ms for this test

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,6 @@ describe('DebugModule testnet tests', () => {
);
});

// eslint-disable-next-line prettier/prettier
describe('name = unigram, sender account index = 12', () => {
const senderAccountIndex = 12;
const tracerName = 'unigram';
Expand Down
1 change: 0 additions & 1 deletion packages/network/tests/thor-client/gas/gas.solo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ describe('ThorClient - Gas Module', () => {
thorSoloClient.gas.estimateGas(
clauses,
// Random address
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-argument,@typescript-eslint/no-unsafe-call
Hex.random(20).toString(),
options
)
Expand Down
Loading

1 comment on commit 32a8bb2

@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: 99%
98.99% (4343/4387) 97.53% (1387/1422) 99% (896/905)
Title Tests Skipped Failures Errors Time
core 827 0 πŸ’€ 0 ❌ 0 πŸ”₯ 2m 18s ⏱️
network 719 0 πŸ’€ 0 ❌ 0 πŸ”₯ 4m 47s ⏱️
errors 42 0 πŸ’€ 0 ❌ 0 πŸ”₯ 16.176s ⏱️
logging 3 0 πŸ’€ 0 ❌ 0 πŸ”₯ 18.065s ⏱️
hardhat-plugin 19 0 πŸ’€ 0 ❌ 0 πŸ”₯ 59.879s ⏱️
aws-kms-adapter 23 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 9s ⏱️
ethers-adapter 5 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 12s ⏱️
rpc-proxy 37 0 πŸ’€ 0 ❌ 0 πŸ”₯ 1m 1s ⏱️

Please sign in to comment.