Skip to content

Commit

Permalink
Merge pull request #60 from vechain/update_sdk_and_add_rlp_test
Browse files Browse the repository at this point in the history
Update sdk and add RLP test
  • Loading branch information
leszek-vechain authored Dec 11, 2024
2 parents 369041e + 8d1b05b commit 956b34b
Show file tree
Hide file tree
Showing 45 changed files with 2,730 additions and 2,093 deletions.
23 changes: 0 additions & 23 deletions .eslintrc.js

This file was deleted.

1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn format
18 changes: 9 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

### Prerequisites

- [Docker](https://docs.docker.com/install/)
- [Yarn](https://yarnpkg.com/en/docs/install)
- [Node.js](https://nodejs.org/en/download/)
- [Docker](https://docs.docker.com/install/)
- [Yarn](https://yarnpkg.com/en/docs/install)
- [Node.js](https://nodejs.org/en/download/)

### Running the tests

Expand All @@ -25,8 +25,8 @@ yarn test -t 'GET /accounts/{address}/storage'

### Custom Docker Image

- You can specify a custom docker image by running the following in the [vechain/thor](https://github.com/vechain/thor)
repo:
- You can specify a custom docker image by running the following in the [vechain/thor](https://github.com/vechain/thor)
repo:

```bash
docker build -t vechain/thor:custom .
Expand Down Expand Up @@ -56,7 +56,7 @@ We need to keep same genesis for now.

### Generate Open API Specification

- These scripts will output the Open API Spec to `./src/open-api-types.ts`
- These scripts will output the Open API Spec to `./src/open-api-types.ts`

#### **Option 1** - By local file:

Expand All @@ -78,9 +78,9 @@ Tests are executed using a custom private thor blockchain. The genesis of this b
This file contains accounts that are created with defined VET/VTHO balance for testing purposes. These accounts are used
as a faucet. Please refer to:

- `./src/wallet.ts` to generate new accounts/ private keys
- `./src/account-faucet.ts` to fund your accounts with VET/VTHO
- `./src/wallet.ts` to generate new accounts/ private keys
- `./src/account-faucet.ts` to fund your accounts with VET/VTHO

### Types of tests

- thorest-api --> Tests that validate the swagger contract definition of the Thorest api
- thorest-api --> Tests that validate the swagger contract definition of the Thorest api
43 changes: 43 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import pluginJest from 'eslint-plugin-jest'
import eslintConfigPrettier from 'eslint-config-prettier'
import jestExtended from 'eslint-plugin-jest-extended'
// import js from "@eslint/js";

export default [
// js.configs.recommended,
jestExtended.configs['flat/all'],
{
plugins: { jest: pluginJest },
languageOptions: {
globals: pluginJest.environments.globals.globals,
parserOptions: {
sourceType: 'module',
ecmaVersion: 2024,
},
},
files: ['**/*.spec.js', '**/*.test.js'],
ignores: [
'.yarn/*',
'*config.js',
'**/node_modules/',
'.git/*',
'artifacts/',
'cache/',
'typechain-types/',
'jest-html-reporters-attach/',
'coverage/',
],
rules: {
indent: ['error', 2],
'jest/prefer-expect-assertions': 'warn',
'jest/no-disabled-tests': 'warn',
'jest/no-focused-tests': 'error',
'jest/no-identical-title': 'error',
'jest/prefer-to-have-length': 'warn',
'jest/valid-expect': ['error', { minArgs: 1, maxArgs: 2 }],
'jest-extended/prefer-to-be-true': 'warn',
'jest-extended/prefer-to-be-false': 'error',
},
},
eslintConfigPrettier,
]
2 changes: 1 addition & 1 deletion hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import '@nomicfoundation/hardhat-ethers'
import '@nomicfoundation/hardhat-chai-matchers'
import '@nomicfoundation/hardhat-toolbox'

const config: HardhatUserConfig = {
const config: HardhatUserConfig = {
solidity: {
compilers: [
{
Expand Down
73 changes: 39 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,70 +16,75 @@
"generate:openapi": "yarn openapi-typescript -o ./src/open-api-types.ts",
"generate:accounts": "ts-node scripts/generate-genesis-accounts.ts",
"format": "prettier . --write",
"lint": "eslint . "
"lint": "eslint . ",
"prepare": "husky"
},
"devDependencies": {
"@babel/preset-env": "^7.23.8",
"@babel/preset-typescript": "^7.23.3",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@eslint/js": "^9.16.0",
"@typechain/ethers-v6": "^0.5.1",
"@typechain/hardhat": "^9.1.0",
"@types/babel__core": "^7",
"@types/jest": "^29.5.11",
"@types/jest": "^29.5.14",
"@types/node": ">=16.0.0",
"@types/ws": "^8.5.10",
"@typescript-eslint/eslint-plugin": "^6.19.0",
"@typescript-eslint/parser": "^6.19.0",
"eslint": "^8.56.0",
"@types/ws": "^8.5.13",
"@typescript-eslint/eslint-plugin": "^8.18.0",
"@typescript-eslint/parser": "^8.18.0",
"eslint": "^9.16.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"ethers": "^6.4.0",
"eslint-plugin-jest": "^28.9.0",
"eslint-plugin-jest-extended": "^2.4.0",
"eslint-plugin-prettier": "^5.2.1",
"ethers": "^6.13.4",
"hardhat": "^2.14.0",
"hardhat-gas-reporter": "^1.0.8",
"hardhat-jest": "^1.0.8",
"husky": "^9.1.7",
"jest": "^29.7.0",
"jest-expect-message": "^1.1.3",
"jest-html-reporters": "^3.1.7",
"jest-json-result": "^1.0.0",
"jest-junit": "^16.0.0",
"node-dir": "^0.1.17",
"openapi-typescript": "^6.7.3",
"prettier": "^3.2.2",
"prettier-eslint": "^16.2.0",
"solidity-coverage": "^0.8.0",
"openapi-typescript": "^7.4.4",
"prettier": "^3.4.2",
"prettier-eslint": "^16.3.0",
"solidity-coverage": "^0.8.14",
"ts-node": "^10.9.2",
"typechain": "^8.3.2",
"typescript": "^5.3.3",
"yarn": "^1.22.21"
"typescript": "^5.7.2",
"yarn": "^1.22.22"
},
"dependencies": {
"@babel/core": "^7.24.5",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.6",
"@nomicfoundation/hardhat-ethers": "^3.0.6",
"@nomicfoundation/hardhat-ignition": "^0.15.4",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.4",
"@nomicfoundation/hardhat-network-helpers": "^1.0.10",
"@babel/core": "^7.26.0",
"@nomicfoundation/hardhat-chai-matchers": "^2.0.8",
"@nomicfoundation/hardhat-ethers": "^3.0.8",
"@nomicfoundation/hardhat-ignition": "^0.15.8",
"@nomicfoundation/hardhat-ignition-ethers": "^0.15.8",
"@nomicfoundation/hardhat-network-helpers": "^1.0.12",
"@nomicfoundation/hardhat-toolbox": "^5.0.0",
"@nomicfoundation/hardhat-verify": "^2.0.7",
"@nomicfoundation/ignition-core": "^0.15.4",
"@openzeppelin/contracts": "^5.0.2",
"@nomicfoundation/hardhat-verify": "^2.0.12",
"@nomicfoundation/ignition-core": "^0.15.8",
"@openzeppelin/contracts": "^5.1.0",
"@types/chai": "^4.3.16",
"@types/proper-lockfile": "^4.1.4",
"@vechain/sdk-core": "1.0.0-beta.24",
"@vechain/sdk-logging": "1.0.0-beta.24",
"@vechain/sdk-network": "1.0.0-beta.24",
"async-mutex": "^0.4.0",
"axios": "^1.6.5",
"@vechain/sdk-core": "1.0.0-rc.5",
"@vechain/sdk-logging": "1.0.0-rc.5",
"@vechain/sdk-network": "1.0.0-rc.5",
"async-mutex": "^0.5.0",
"axios": "^1.7.9",
"bignumber.js": "^9.1.2",
"chai": "4.2.0",
"dotenv": "^16.4.5",
"dotenv": "^16.4.7",
"hardhat-ethers": "^1.0.1",
"jest-docblock": "^29.7.0",
"jest-extended": "^4.0.2",
"jest-runner": "^29.7.0",
"jest-runner-groups": "^2.2.0",
"prettier-plugin-solidity": "^1.3.1",
"prettier-plugin-solidity": "^1.4.1",
"proper-lockfile": "^4.1.2",
"web3": "4.6.1-dev.f943944.0",
"ws": "^8.16.0"
"web3": "4.16.0",
"ws": "^8.18.0"
}
}
8 changes: 4 additions & 4 deletions src/account-faucet.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { contractAddresses } from './contracts/addresses'
import { interfaces } from './contracts/hardhat'
import { secp256k1, Transaction } from '@vechain/sdk-core'
import { Secp256k1, Transaction } from '@vechain/sdk-core'
import { testEnv } from './test-env'
import { ThorWallet } from './wallet'

Expand Down Expand Up @@ -104,10 +104,10 @@ export const delegateTx = (txBody, senderAddress) => {

const fundingAccount = randomFunder()

const encoded = transaction.getSignatureHash(senderAddress)
const encoded = transaction.getTransactionHash(senderAddress)

const signature = secp256k1.sign(
encoded,
const signature = Secp256k1.sign(
encoded.bytes,
Buffer.from(fundingAccount, 'hex'),
)

Expand Down
5 changes: 1 addition & 4 deletions src/logs/write-logs.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ const writeTransfers = async () => {

await pollReceipt(txId)

const receipt =
await Client.sdk.transactions.waitForTransaction(txId)

return receipt
return await Client.sdk.transactions.waitForTransaction(txId)
}),
)

Expand Down
4 changes: 2 additions & 2 deletions src/test-env.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { HDNode } from '@vechain/sdk-core'
import { HDKey } from '@vechain/sdk-core'
import { ThorClient } from '@vechain/sdk-network'
import { genesis } from './constants'

Expand All @@ -18,7 +18,7 @@ export const testEnv = {
if (!mnemonic) {
throw new Error('No mnemonic provided')
}
const hdNode = HDNode.fromMnemonic(mnemonic.split(' '))
const hdNode = HDKey.fromMnemonic(mnemonic.split(' '))
const keys = []
for (let i = 0; i < 10; i++) {
const child = hdNode.deriveChild(i)
Expand Down
Loading

0 comments on commit 956b34b

Please sign in to comment.