diff --git a/apps/sdk-cloudflare-integration/tsconfig.json b/apps/sdk-cloudflare-integration/tsconfig.json index f6206be7a..9caec8099 100644 --- a/apps/sdk-cloudflare-integration/tsconfig.json +++ b/apps/sdk-cloudflare-integration/tsconfig.json @@ -1,12 +1,12 @@ { "compilerOptions": { "strict": true, - "module": "esnext", - "target": "esnext", + "module": "Node16", + "target": "ES2023", "lib": [ "esnext" ], - "moduleResolution": "bundler", + "moduleResolution": "Node16", "noEmit": true, "skipLibCheck": true, "allowSyntheticDefaultImports": true, @@ -18,4 +18,4 @@ "./**/*.ts" ] } -} \ No newline at end of file +} diff --git a/apps/sdk-nextjs-integration/tsconfig.json b/apps/sdk-nextjs-integration/tsconfig.json index 99281f9cd..8de2262a8 100644 --- a/apps/sdk-nextjs-integration/tsconfig.json +++ b/apps/sdk-nextjs-integration/tsconfig.json @@ -8,8 +8,8 @@ "forceConsistentCasingInFileNames": true, "noEmit": true, "esModuleInterop": true, - "module": "esnext", - "moduleResolution": "bundler", + "module": "Node16", + "moduleResolution": "Node16", "resolveJsonModule": true, "isolatedModules": true, "jsx": "preserve", @@ -30,7 +30,7 @@ "**/*.ts", "**/*.tsx", "types.d.ts", - ".next/types/**/*.ts", + ".next/types/**/*.ts", "jest.config.js" ], "exclude": ["node_modules"] } diff --git a/apps/sdk-vite-integration/src/App.tsx b/apps/sdk-vite-integration/src/App.tsx index f4ea4028a..7af41d740 100644 --- a/apps/sdk-vite-integration/src/App.tsx +++ b/apps/sdk-vite-integration/src/App.tsx @@ -2,9 +2,9 @@ import { BrowserRouter as Router, Route, Routes, Link } from 'react-router-dom'; import reactLogo from './assets/react.svg'; import viteLogo from '/vite.svg'; import './App.css'; -import Hash from './components/Hash'; -import TransferLogs from './components/TransferLogs'; -import GetLastBlock from './components/GetLastBlock'; +import Hash from './components/Hash.tsx'; +import TransferLogs from './components/TransferLogs.tsx'; +import GetLastBlock from './components/GetLastBlock.tsx'; function App() { return ( diff --git a/apps/sdk-vite-integration/src/components/GetLastBlock.tsx b/apps/sdk-vite-integration/src/components/GetLastBlock.tsx index 7a7f240ec..8ad53c441 100644 --- a/apps/sdk-vite-integration/src/components/GetLastBlock.tsx +++ b/apps/sdk-vite-integration/src/components/GetLastBlock.tsx @@ -1,15 +1,10 @@ -import { type CompressedBlockDetail, ThorClient } from "@vechain/sdk-network"; +import { type CompressedBlockDetail } from "@vechain/sdk-network"; import { useState } from "react"; +import { thorClient } from '../const/index.tsx'; const GetLastBlock = () => { const [block, setBlock] = useState(null); - // URL of the VeChain mainnet - const mainnetUrl = 'https://mainnet.vechain.org'; - - // Thor client instance - const thorClient = ThorClient.fromUrl(mainnetUrl); - // Function to fetch the last block const fetchLastBlock = async () => { try { @@ -22,13 +17,13 @@ const GetLastBlock = () => { return (
- {block && (

Last Block Details:

-
{JSON.stringify(block, null, 2)}
+
{JSON.stringify(block, null, 2)}
)}
diff --git a/apps/sdk-vite-integration/src/components/Hash.tsx b/apps/sdk-vite-integration/src/components/Hash.tsx index 5ce4a73e9..a764aa6f0 100644 --- a/apps/sdk-vite-integration/src/components/Hash.tsx +++ b/apps/sdk-vite-integration/src/components/Hash.tsx @@ -1,6 +1,6 @@ import { Blake2b256, Keccak256, Sha256, Txt } from '@vechain/sdk-core'; import { useEffect, useState } from 'react'; -import { HashedContent } from '../types'; +import { HashedContent } from '../types/index.tsx'; const Hash = () => { // State of content to hash diff --git a/apps/sdk-vite-integration/src/components/TransferLogs.tsx b/apps/sdk-vite-integration/src/components/TransferLogs.tsx index ad5a2fdee..af83c3790 100644 --- a/apps/sdk-vite-integration/src/components/TransferLogs.tsx +++ b/apps/sdk-vite-integration/src/components/TransferLogs.tsx @@ -5,8 +5,8 @@ import { FilterTransferLogsOptions } from '@vechain/sdk-network'; import { Link } from 'react-router-dom'; -import { Transfer } from "../types"; -import { explorerUrl, thorClient } from "../const"; +import { Transfer } from "../types/index.tsx"; +import { explorerUrl, thorClient } from "../const/index.tsx"; /** * Reduce the size of a hex string diff --git a/apps/sdk-vite-integration/src/const/index.tsx b/apps/sdk-vite-integration/src/const/index.tsx index f56fb0c46..4f2f44285 100644 --- a/apps/sdk-vite-integration/src/const/index.tsx +++ b/apps/sdk-vite-integration/src/const/index.tsx @@ -1,2 +1,2 @@ // eslint-disable-next-line react-refresh/only-export-components -export * from './const'; +export * from '../const/const.tsx'; diff --git a/apps/sdk-vite-integration/src/main.tsx b/apps/sdk-vite-integration/src/main.tsx index db032b748..bef5202a3 100644 --- a/apps/sdk-vite-integration/src/main.tsx +++ b/apps/sdk-vite-integration/src/main.tsx @@ -1,7 +1,7 @@ import { StrictMode } from 'react' import { createRoot } from 'react-dom/client' import './index.css' -import App from './App' +import App from './App.tsx' createRoot(document.getElementById('root')!).render( diff --git a/apps/sdk-vite-integration/src/types/index.tsx b/apps/sdk-vite-integration/src/types/index.tsx index 8b2ee98ba..85656badb 100644 --- a/apps/sdk-vite-integration/src/types/index.tsx +++ b/apps/sdk-vite-integration/src/types/index.tsx @@ -1 +1 @@ -export type * from './types.d'; +export type * from './types.d.tsx'; diff --git a/apps/sdk-vite-integration/tests/Hash.spec.tsx b/apps/sdk-vite-integration/tests/Hash.spec.tsx index 01b1f6864..809a4c9f4 100644 --- a/apps/sdk-vite-integration/tests/Hash.spec.tsx +++ b/apps/sdk-vite-integration/tests/Hash.spec.tsx @@ -1,9 +1,9 @@ import { expect, test } from 'vitest' import { render } from 'vitest-browser-react' -import Hash from '../src/components/Hash' +import Hash from '../src/components/Hash.js' test('renders name', async () => { const { getByText } = render() await expect.element(getByText('0xbf56c0728fd4e9cf64bfaf6dabab81554103298cdee5cc4d580433aa25e98b00')).toBeInTheDocument() -}) \ No newline at end of file +}) diff --git a/apps/sdk-vite-integration/tsconfig.app.json b/apps/sdk-vite-integration/tsconfig.app.json index 5a2def4b7..414016bec 100644 --- a/apps/sdk-vite-integration/tsconfig.app.json +++ b/apps/sdk-vite-integration/tsconfig.app.json @@ -3,11 +3,11 @@ "target": "ES2020", "useDefineForClassFields": true, "lib": ["ES2020", "DOM", "DOM.Iterable"], - "module": "ESNext", + "module": "Node16", "skipLibCheck": true, /* Bundler mode */ - "moduleResolution": "Bundler", + "moduleResolution": "Node16", "allowImportingTsExtensions": true, "isolatedModules": true, "moduleDetection": "force", diff --git a/apps/sdk-vite-integration/tsconfig.json b/apps/sdk-vite-integration/tsconfig.json index a1c490262..a80e93b92 100644 --- a/apps/sdk-vite-integration/tsconfig.json +++ b/apps/sdk-vite-integration/tsconfig.json @@ -1,15 +1,16 @@ { "compilerOptions": { - "target": "ESNext", - "lib": ["esnext", "dom"], - "module": "ESNext", - "moduleResolution": "Bundler", - "jsx": "react-jsx", - "types": ["@vitest/browser/providers/playwright"], - "strict": true, + "allowImportingTsExtensions": true, "declaration": true, - "noEmit": true, "esModuleInterop": true, - "skipLibCheck": true + "jsx": "react-jsx", + "lib": ["esnext", "dom"], + "module": "Node16", + "moduleResolution": "Node16", + "noEmit": true, + "skipLibCheck": true, + "strict": true, + "target": "ES2023", + "types": ["@vitest/browser/providers/playwright"] } -} \ No newline at end of file +} diff --git a/apps/sdk-vite-integration/tsconfig.node.json b/apps/sdk-vite-integration/tsconfig.node.json index 9dad70185..d01017db5 100644 --- a/apps/sdk-vite-integration/tsconfig.node.json +++ b/apps/sdk-vite-integration/tsconfig.node.json @@ -2,11 +2,11 @@ "compilerOptions": { "target": "ES2022", "lib": ["ES2023"], - "module": "ESNext", + "module": "Node16", "skipLibCheck": true, /* Bundler mode */ - "moduleResolution": "Bundler", + "moduleResolution": "Node16", "allowImportingTsExtensions": true, "isolatedModules": true, "moduleDetection": "force", diff --git a/docs/tsconfig.json b/docs/tsconfig.json index 1a83e52c0..de70fb4e2 100644 --- a/docs/tsconfig.json +++ b/docs/tsconfig.json @@ -1,17 +1,17 @@ { "compilerOptions": { - "target": "ESNext", - "module": "ESNext", - "moduleResolution": "Node", + "target": "ES2023", + "module": "Node16", + "moduleResolution": "Node16", "allowSyntheticDefaultImports": true, }, "ts-node": { "compilerOptions": { "esModuleInterop": true, - "module": "ESNext", - "target": "ESNext", - "moduleResolution": "Node", + "module": "Node16", + "target": "ES2023", + "moduleResolution": "Node16", }, "esm": true } -} \ No newline at end of file +} diff --git a/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts b/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts index 6833f896c..462a27168 100644 --- a/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts +++ b/packages/aws-kms-adapter/tests/KMSVeChainSigner.solo.test.ts @@ -303,7 +303,22 @@ describe('KMSVeChainSigner - Thor Solo', () => { ); expect(signature).toBeDefined(); // 64-bytes hex string - expect(signature.length).toBe(132); + expect(signature).toMatch(/^0x[A-Fa-f0-9]{130}$/); + + const signatureWithoutPrimaryType = await signer.signTypedData( + typedData.domain, + typedData.types, + typedData.data + ); + expect(signatureWithoutPrimaryType).toBeDefined(); + // 64-bytes hex string + expect(signatureWithoutPrimaryType).toMatch(/^0x[A-Fa-f0-9]{130}$/); + + // Not checking directly the signatures since there is an issue in LocalStack: + // https://github.com/localstack/localstack/issues/11678 + // Looks like, regardless the configuration, a new SECP256r1 key is generated + // meaning that the signature will be different every time. + // However both hashes have been checked and they match, + tests in the other implementation. }); }); }); diff --git a/packages/network/src/thor-client/blocks/blocks-module.ts b/packages/network/src/thor-client/blocks/blocks-module.ts index b43ae1962..e5fa65779 100644 --- a/packages/network/src/thor-client/blocks/blocks-module.ts +++ b/packages/network/src/thor-client/blocks/blocks-module.ts @@ -33,7 +33,7 @@ class BlocksModule { /** * Initializes a new instance of the `Thor` class. - * @param thor - The Thor instance used to interact with the VeChain blockchain API. + * @param httpClient - The Thor instance used to interact with the VeChain blockchain API. * @param options - (Optional) Other optional parameters for polling and error handling. */ constructor( @@ -306,7 +306,6 @@ class BlocksModule { addresses.add(clause.to); } }); - addresses.add(transaction.delegator); addresses.add(transaction.gasPayer); addresses.add(transaction.origin); transaction.outputs.forEach((output) => { diff --git a/packages/network/src/thor-client/blocks/types.d.ts b/packages/network/src/thor-client/blocks/types.d.ts index 5e729acbb..10eb341cc 100644 --- a/packages/network/src/thor-client/blocks/types.d.ts +++ b/packages/network/src/thor-client/blocks/types.d.ts @@ -211,11 +211,6 @@ interface TransactionsExpandedBlockDetail { */ origin: string; - /** - * Delegator associated with the transaction. - */ - delegator: string; - /** * Nonce value for preventing replay attacks. */ diff --git a/packages/network/tests/provider/formatter/fixture.ts b/packages/network/tests/provider/formatter/fixture.ts index ed9a51633..1995c9e42 100644 --- a/packages/network/tests/provider/formatter/fixture.ts +++ b/packages/network/tests/provider/formatter/fixture.ts @@ -171,7 +171,6 @@ const blockFixtures = [ gasPriceCoef: 64, gas: 29750, origin: '0x7487d912d03ab9de786278f679592b3730bdd540', - delegator: 'null', nonce: '0xb8314776ce0bf5df', dependsOn: 'null', size: 191, @@ -208,7 +207,6 @@ const blockFixtures = [ gasPriceCoef: 64, gas: 48432, origin: '0x7487d912d03ab9de786278f679592b3730bdd540', - delegator: 'null', nonce: '0x176bbcbf79a3a672', dependsOn: 'null', size: 219, diff --git a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.unit.test.ts b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.unit.test.ts index 65f8a65a2..b07b9a31c 100644 --- a/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.unit.test.ts +++ b/packages/network/tests/signer/signers/vechain-private-key-signer/vechain-private-key-signer.unit.test.ts @@ -7,7 +7,7 @@ import { test } from '@jest/globals'; import { Address, Hex, HexUInt, Secp256k1, Txt } from '@vechain/sdk-core'; -import { Wallet } from 'ethers'; +import { type TypedDataDomain, Wallet } from 'ethers'; import { TESTNET_URL, ThorClient, @@ -253,7 +253,7 @@ describe('VeChain base signer tests', () => { await expect( signer.signMessage(EIP191_MESSAGE) - ).rejects.toThrowError('Error while signing the message'); + ).rejects.toThrowError(); }); test('signMessage - ethers compatible - string', async () => { @@ -292,7 +292,7 @@ describe('VeChain base signer tests', () => { eip712TestCases.invalid.types, eip712TestCases.invalid.data ) - ).rejects.toThrowError(TypeError); + ).rejects.toThrowError(); }); test('signTypedData - exception when parsing to hex', async () => { @@ -323,7 +323,7 @@ describe('VeChain base signer tests', () => { eip712TestCases.valid.types, eip712TestCases.valid.data ) - ).rejects.toThrowError('Error while signing typed data'); + ).rejects.toThrowError(); }); test('signTypedData - ethers compatible', async () => { @@ -335,15 +335,57 @@ describe('VeChain base signer tests', () => { eip712TestCases.valid.data ); expect(expected).toBe(eip712TestCases.valid.signature); - const actual = await new VeChainPrivateKeySigner( + const privateKeySigner = new VeChainPrivateKeySigner( Hex.of(eip712TestCases.valid.privateKey).bytes, provider - ).signTypedData( + ); + const actual = await privateKeySigner.signTypedData( eip712TestCases.valid.domain, eip712TestCases.valid.types, eip712TestCases.valid.data ); expect(actual).toBe(expected); + const actualWithoutPrimaryType = + await privateKeySigner.signTypedData( + eip712TestCases.valid.domain, + eip712TestCases.valid.types, + eip712TestCases.valid.data + ); + expect(actualWithoutPrimaryType).toBe(expected); + + // Using VeChain chainId as string and bigint + const vechainChainId = + '1176455790972829965191905223412607679856028701100105089447013101863'; + const expectedVeChain = await new Wallet( + eip712TestCases.valid.privateKey + ).signTypedData( + { + ...eip712TestCases.valid.domain, + chainId: vechainChainId + }, + eip712TestCases.valid.types, + eip712TestCases.valid.data + ); + const actualWithStringChainId = + await privateKeySigner.signTypedData( + { + ...eip712TestCases.valid.domain, + chainId: vechainChainId + }, + eip712TestCases.valid.types, + eip712TestCases.valid.data + ); + expect(actualWithStringChainId).toBe(expectedVeChain); + const actualWithBigintChainId = + await privateKeySigner.signTypedData( + { + ...(eip712TestCases.valid.domain as TypedDataDomain), + chainId: BigInt(vechainChainId) + }, + eip712TestCases.valid.types, + eip712TestCases.valid.data + ); + expect(actualWithBigintChainId).toBe(expectedVeChain); }); }); }); diff --git a/packages/network/tests/thor-client/blocks/fixture.ts b/packages/network/tests/thor-client/blocks/fixture.ts index 3be0a5f87..e543340ee 100644 --- a/packages/network/tests/thor-client/blocks/fixture.ts +++ b/packages/network/tests/thor-client/blocks/fixture.ts @@ -287,7 +287,6 @@ const expandedBlockDetailFixture: ExpandedBlockDetail = { gasPriceCoef: 255, gas: 253631, origin: '0xa416bdda32b00e218f08ace220bab512c863ff2f', - delegator: '', nonce: '0x2603c69707b46b55', dependsOn: '', size: 365, @@ -380,7 +379,6 @@ const expandedBlockDetailFixture: ExpandedBlockDetail = { gasPriceCoef: 128, gas: 29000, origin: '0xbeae4bef0121f11d269aedf6adb227259d4314ad', - delegator: '0xbeae4bef0121f11d269aedf6adb227259d4314ad', nonce: '0x33f2b93', dependsOn: '', size: 200, @@ -419,7 +417,6 @@ const expandedBlockDetailFixture: ExpandedBlockDetail = { gasPriceCoef: 10, gas: 31990, origin: '0x95fe74d1ae072ee45bdb09879a157364e5341565', - delegator: '', nonce: '0x4b129bf90751676e', dependsOn: '', size: 193, @@ -445,7 +442,6 @@ const expandedBlockDetailFixture: ExpandedBlockDetail = { gasPriceCoef: 0, gas: 21000, origin: '0x9a107a75cff525b033a3e53cadafe3d193b570ec', - delegator: '', nonce: '0x7bced3146d8fb8fc', dependsOn: '', size: 131, diff --git a/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts b/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts index c40f25a66..a7b26c9c7 100644 --- a/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts +++ b/packages/network/tests/thor-client/contracts/contract.event.solo.test.ts @@ -1,5 +1,5 @@ import { beforeEach, describe, expect, test } from '@jest/globals'; -import { ERC20_ABI, HexUInt } from '@vechain/sdk-core'; +import { Address, ERC20_ABI, HexUInt } from '@vechain/sdk-core'; import { InvalidAbiItem } from '@vechain/sdk-errors'; import { THOR_SOLO_URL, @@ -101,7 +101,7 @@ describe('ThorClient - ERC20 Contracts', () => { const eventsWithAnArgsObject = await contract.filters .Transfer({ from: undefined, - to: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address + to: `0x${Address.of(TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address).digits}` }) .get(); @@ -476,7 +476,7 @@ describe('ThorClient - ERC20 Contracts', () => { await (await contractEventExample.transact.setValue(3000n)).wait(); const transferCriteria = contractERC20.criteria.Transfer({ - to: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address + to: `0x${Address.of(TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address).digits}` }); const valueCriteria = contractEventExample.criteria.ValueSet(); @@ -537,7 +537,7 @@ describe('ThorClient - ERC20 Contracts', () => { await (await contractEventExample.transact.setValue(3000n)).wait(); const transferCriteria = contractERC20.criteria.Transfer({ - to: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address + to: `0x${Address.of(TEST_ACCOUNTS.TRANSACTION.TRANSACTION_RECEIVER.address).digits}` }); const valueCriteria = contractEventExample.criteria.ValueSet(); diff --git a/packages/network/tests/thor-client/contracts/contract.solo.test.ts b/packages/network/tests/thor-client/contracts/contract.solo.test.ts index 4bfdd67f2..357e03ca8 100644 --- a/packages/network/tests/thor-client/contracts/contract.solo.test.ts +++ b/packages/network/tests/thor-client/contracts/contract.solo.test.ts @@ -647,7 +647,7 @@ describe('ThorClient - Contracts', () => { .StateChanged({ newValue: undefined, oldValue: undefined, - sender: TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER.address + sender: `0x${Address.of(TEST_ACCOUNTS.TRANSACTION.TRANSACTION_SENDER.address).digits}` }) .get(); diff --git a/packages/rpc-proxy/tsconfig.json b/packages/rpc-proxy/tsconfig.json index 98e4070be..9fccba33f 100644 --- a/packages/rpc-proxy/tsconfig.json +++ b/packages/rpc-proxy/tsconfig.json @@ -4,15 +4,15 @@ "rootDir": "./src", "outDir": "./dist", "strict": true, - "target": "es2020", - "module": "commonjs", + "target": "es2023", + "module": "Node16", "sourceMap": true, "esModuleInterop": true, "resolveJsonModule": true, - "moduleResolution": "node" + "moduleResolution": "Node16" }, "include": [ "./src/**/*.ts", "./tests/**/*.ts" ] -} \ No newline at end of file +} diff --git a/tsconfig.json b/tsconfig.json index 0c3dd000b..e578283b2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -5,12 +5,12 @@ "declaration": true, "declarationMap": true, "esModuleInterop": true, - "module": "ESNext", - "target": "ESNext", + "module": "Node16", + "target": "ES2023", "forceConsistentCasingInFileNames": true, "inlineSources": false, "isolatedModules": true, - "moduleResolution": "node", + "moduleResolution": "Node16", "noUnusedLocals": false, "noUnusedParameters": false, "preserveWatchOutput": true, @@ -22,7 +22,7 @@ "ts-node": { // these options are overrides used only by ts-node "compilerOptions": { - "module": "commonjs" + "module": "Node16" } }, -} \ No newline at end of file +}