Skip to content

Commit

Permalink
Merge pull request #59 from pnetwork-association/feat/add-husky
Browse files Browse the repository at this point in the history
Add husky
  • Loading branch information
gitmp01 authored Nov 6, 2024
2 parents bee3383 + 4857ede commit 04c3817
Show file tree
Hide file tree
Showing 14 changed files with 226 additions and 148 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarn lint
4 changes: 3 additions & 1 deletion cpp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"build": "make all",
"clean": "make clean",
"test": "yarn build && mocha",
"lint": "./lint scripts/*.sh"
"lint": "./lint scripts/*.sh && npx prettier --check test/",
"prettier:fix": "npx prettier --check --write test/",
"prettier": "npx prettier --cache --check --ignore-path ../.prettierignore --config ../.prettierrc ./src ./test"
},
"devDependencies": {
"@eosnetwork/vert": "^1.0.0",
Expand Down
296 changes: 170 additions & 126 deletions cpp/test/feesmanager.test.js

Large diffs are not rendered by default.

12 changes: 10 additions & 2 deletions cpp/test/lockbox.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,16 @@ describe('Lockbox testing', () => {

before(async () => {
blockchain.createAccounts(user, evil, issuer, bridge, recipient)
lockbox.contract = deploy(blockchain, lockbox.account, 'contracts/build/lockbox')
token.contract = deploy(blockchain, token.account, 'contracts/build/eosio.token')
lockbox.contract = deploy(
blockchain,
lockbox.account,
'contracts/build/lockbox',
)
token.contract = deploy(
blockchain,
token.account,
'contracts/build/eosio.token',
)
xerc20.contract = deploy(
blockchain,
xerc20.account,
Expand Down
2 changes: 1 addition & 1 deletion cpp/test/utils/get-event-bytes.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ module.exports.getEventBytes = _contract => {
const match = re.exec(_contract.bc.console)
const extract = R.compose(R.prop(1), R.split(':'), R.prop(0))
return extract(match)
}
}
6 changes: 4 additions & 2 deletions cpp/test/utils/precision-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@ const adjustPrecision = (amount, precision) => {
}

const [integerPart, decimalPart] = amount.split('.')
const trimmedDecimals = (decimalPart || '').slice(0, precision).padEnd(precision, '0')
const trimmedDecimals = (decimalPart || '')
.slice(0, precision)
.padEnd(precision, '0')

return precision > 0 ? `${integerPart}.${trimmedDecimals}` : integerPart
}

module.exports = {
adjustPrecision
adjustPrecision,
}
3 changes: 1 addition & 2 deletions cpp/test/utils/wharfkit-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ const assetOperation = R.curry((_fn, _op1, _op2) => {

return Asset.from(
_fn === R.sum ? _fn([op1.value, op2.value]) : _fn(op1.value)(op2.value),
op1.symbol
op1.symbol,
)

})

const substract = assetOperation(R.subtract)
Expand Down
7 changes: 5 additions & 2 deletions javascript/event-attestator/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@
"license": "MIT",
"scripts": {
"test": "jest",
"lint": "npx eslint .",
"lint:fix": "npx eslint --fix ."
"eslint": "npx eslint .",
"eslint:fix": "yarn eslint --fix",
"prettier:fix": "yarn prettier --write",
"lint": "yarn prettier",
"prettier": "npx prettier --cache --check --ignore-path ../../.prettierignore --config ../../.prettierrc ./src ./test"
},
"devDependencies": {
"eslint": "^9.13.0",
Expand Down
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"test": "yarn workspaces foreach --all --parallel --no-private run test",
"lint": "yarn workspaces foreach --all --parallel --no-private run lint",
"build": "yarn workspaces foreach --all --parallel --no-private run build",
"prettier": "yarn workspaces foreach --all --parallel --no-private run prettier"
"prettier": "yarn workspaces foreach --all --parallel --no-private run prettier",
"prepare": "husky"
},
"devDependencies": {
"@eslint/js": "^9.5.0",
Expand All @@ -29,5 +30,8 @@
"typescript": "4.7.4",
"typescript-eslint": "^7.13.1"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"dependencies": {
"husky": "^9.1.6"
}
}
6 changes: 4 additions & 2 deletions solidity/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@
"test:forge": "forge test",
"test:hh": "hardhat clean && FORK=1 hardhat test",
"test:hh-no-fork": "hardhat test",
"lint": "npx solhint src/**/*.sol",
"prettier": "prettier --write ./src ./test",
"solhint": "npx solhint src/**/*.sol",
"prettier": "npx prettier --cache --check --ignore-path ../.prettierignore --config ../.prettierrc ./src ./test",
"lint": "yarn solhint && yarn prettier",
"prettier:fix": "yarn prettier --write",
"coverage": "./coverage.sh"
},
"devDependencies": {
Expand Down
4 changes: 2 additions & 2 deletions solidity/src/interfaces/IAdapter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface IAdapter {
event Settled(bytes32 indexed eventId);
event FeesManagerChanged(address newAddress);
// Low level event
// Swap(bytes)
// Swap(bytes)
// topic: 0x66756E6473206172652073616675207361667520736166752073616675202E2E

error NotAContract(address addr);
Expand Down Expand Up @@ -90,4 +90,4 @@ interface IAdapter {
* @param amount The amount from which the fees will be calculated
*/
function calculateFee(uint256 amount) external returns (uint256);
}
}
5 changes: 3 additions & 2 deletions solidity/test/hardhat/utils/get-swap-event.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const R = require('ramda')

const SWAP_TOPIC = '0x66756e6473206172652073616675207361667520736166752073616675202e2e'
const SWAP_TOPIC =
'0x66756e6473206172652073616675207361667520736166752073616675202e2e'

const getSwapEvent = _tx =>
_tx
Expand All @@ -11,4 +12,4 @@ const getSwapEvent = _tx =>
module.exports = {
SWAP_TOPIC,
getSwapEvent,
}
}
10 changes: 6 additions & 4 deletions solidity/test/hardhat/utils/validate-upgrade.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
const R = require('ramda')

module.exports.validateUpgrade = R.curry((_hre, _contractName, _proxy) =>
_hre.ethers.getContractFactory(_contractName)
.then(_contractFactory => _hre.upgrades.validateUpgrade(_proxy, _contractFactory))
.catch(_err => Promise.reject(_err))

_hre.ethers
.getContractFactory(_contractName)
.then(_contractFactory =>
_hre.upgrades.validateUpgrade(_proxy, _contractFactory),
)
.catch(_err => Promise.reject(_err)),
)
10 changes: 10 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5916,6 +5916,15 @@ __metadata:
languageName: node
linkType: hard

"husky@npm:^9.1.6":
version: 9.1.6
resolution: "husky@npm:9.1.6"
bin:
husky: bin.js
checksum: 10c0/705673db4a247c1febd9c5df5f6a3519106cf0335845027bb50a15fba9b1f542cb2610932ede96fd08008f6d9f49db0f15560509861808b0031cdc0e7c798bac
languageName: node
linkType: hard

"iconv-lite@npm:0.4.24":
version: 0.4.24
resolution: "iconv-lite@npm:0.4.24"
Expand Down Expand Up @@ -8000,6 +8009,7 @@ __metadata:
"@types/eslint__js": "npm:^8.42.3"
eslint: "npm:8.57.0"
eslint-config-prettier: "npm:^9.1.0"
husky: "npm:^9.1.6"
prettier: "npm:3.3.2"
prettier-plugin-solidity: "npm:^1.3.1"
solhint: "npm:^5.0.1"
Expand Down

0 comments on commit 04c3817

Please sign in to comment.