From e40d306e9379b6a67ffacbf8a7b495cf0dd5a4c8 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:26:03 +0100 Subject: [PATCH 1/6] chore(pnetwork-v4): add `husky` --- .husky/pre-commit | 1 + package.json | 8 ++++++-- yarn.lock | 10 ++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) create mode 100644 .husky/pre-commit diff --git a/.husky/pre-commit b/.husky/pre-commit new file mode 100644 index 00000000..39abe4df --- /dev/null +++ b/.husky/pre-commit @@ -0,0 +1 @@ +yarn lint diff --git a/package.json b/package.json index cf0ca481..888a75ec 100644 --- a/package.json +++ b/package.json @@ -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", @@ -29,5 +30,8 @@ "typescript": "4.7.4", "typescript-eslint": "^7.13.1" }, - "packageManager": "yarn@4.3.1" + "packageManager": "yarn@4.3.1", + "dependencies": { + "husky": "^9.1.6" + } } diff --git a/yarn.lock b/yarn.lock index fa9909ce..aec406bb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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" @@ -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" From f29860a895fd54550e19ab12850bd5c34739eeb2 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:28:45 +0100 Subject: [PATCH 2/6] chore(cpp): refine lint script --- cpp/package.json | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cpp/package.json b/cpp/package.json index 33054072..1e5a84e2 100644 --- a/cpp/package.json +++ b/cpp/package.json @@ -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", From 76a4c32c7b25bf6d4c7f1ce3af065415f4de281e Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:29:08 +0100 Subject: [PATCH 3/6] fix(test): apply linting --- cpp/test/feesmanager.test.js | 296 +++++++++++++++++------------- cpp/test/lockbox.test.js | 12 +- cpp/test/utils/get-event-bytes.js | 2 +- cpp/test/utils/precision-utils.js | 6 +- cpp/test/utils/wharfkit-ext.js | 3 +- 5 files changed, 186 insertions(+), 133 deletions(-) diff --git a/cpp/test/feesmanager.test.js b/cpp/test/feesmanager.test.js index 8b55502b..b71337f1 100644 --- a/cpp/test/feesmanager.test.js +++ b/cpp/test/feesmanager.test.js @@ -45,9 +45,24 @@ describe('Feesmanager testing', () => { beforeEach(async () => { const blockchain = new Blockchain() - blockchain.createAccounts(user, evil, issuer, node1, recipient, securitycouncil) - feesmanager.contract = deploy(blockchain, feesmanager.account, 'contracts/build/feesmanager') - token.contract = deploy(blockchain, token.account, 'contracts/build/eosio.token') + blockchain.createAccounts( + user, + evil, + issuer, + node1, + recipient, + securitycouncil, + ) + feesmanager.contract = deploy( + blockchain, + feesmanager.account, + 'contracts/build/feesmanager', + ) + token.contract = deploy( + blockchain, + token.account, + 'contracts/build/eosio.token', + ) xerc20.contract = deploy( blockchain, xerc20.account, @@ -57,7 +72,7 @@ describe('Feesmanager testing', () => { describe('feesmanager::setallowance', () => { it('Should reject if not authorized', async () => { - const allowanceValue = "100.0000 TKN" + const allowanceValue = '100.0000 TKN' const action = feesmanager.contract.actions .setallowance([node1, token.account, allowanceValue]) .send(active(evil)) @@ -66,14 +81,16 @@ describe('Feesmanager testing', () => { }) it('Should reject if allowance set is bigger than feesmanager balance', async () => { - const allowanceValue = "200.0000 TKN" - const feesmanagerBalance = "100.0000 TKN" - const assetSymbol = Asset.from(feesmanagerBalance).symbol.code.value.toString() + const allowanceValue = '200.0000 TKN' + const feesmanagerBalance = '100.0000 TKN' + const assetSymbol = + Asset.from(feesmanagerBalance).symbol.code.value.toString() - await token.contract.actions - .create([issuer, token.maxSupply]).send() + await token.contract.actions.create([issuer, token.maxSupply]).send() - const balanceBefore = token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRow(assetSymbol) + const balanceBefore = token.contract.tables + .accounts(getAccountCodeRaw(feesmanager.account)) + .getTableRow(assetSymbol) expect(balanceBefore).to.equal(undefined) await token.contract.actions @@ -83,7 +100,9 @@ describe('Feesmanager testing', () => { .transfer([issuer, feesmanager.account, feesmanagerBalance, '']) .send(active(issuer)) - const balance = token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRow(assetSymbol) + const balance = token.contract.tables + .accounts(getAccountCodeRaw(feesmanager.account)) + .getTableRow(assetSymbol) expect(balance).to.be.deep.equal({ balance: feesmanagerBalance, }) @@ -96,11 +115,10 @@ describe('Feesmanager testing', () => { }) it('Should set the correct allowance', async () => { - const allowanceValue = "100.0000 TKN" - const feesmanagerBalance = "100.0000 TKN" + const allowanceValue = '100.0000 TKN' + const feesmanagerBalance = '100.0000 TKN' - await token.contract.actions - .create([issuer, token.maxSupply]).send() + await token.contract.actions.create([issuer, token.maxSupply]).send() await token.contract.actions .issue([issuer, feesmanagerBalance, '']) .send(active(issuer)) @@ -111,8 +129,11 @@ describe('Feesmanager testing', () => { .setallowance([node1, token.account, allowanceValue]) .send(active(feesmanager.account)) - const assetSymbol = Asset.from(allowanceValue).symbol.code.value.toString() - const allowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) + const assetSymbol = + Asset.from(allowanceValue).symbol.code.value.toString() + const allowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbol) expect(allowance).to.be.deep.equal({ node_allowance: allowanceValue, token: token.account, @@ -121,10 +142,9 @@ describe('Feesmanager testing', () => { it('Should update the correct allowance', async () => { const allowanceValue = '100.0000 TKN' - const feesmanagerBalance = "400.0000 TKN" + const feesmanagerBalance = '400.0000 TKN' - await token.contract.actions - .create([issuer, token.maxSupply]).send() + await token.contract.actions.create([issuer, token.maxSupply]).send() await token.contract.actions .issue([issuer, feesmanagerBalance, '']) .send(active(issuer)) @@ -135,19 +155,24 @@ describe('Feesmanager testing', () => { .setallowance([node1, token.account, allowanceValue]) .send(active(feesmanager.account)) - const assetSymbol = Asset.from(allowanceValue).symbol.code.value.toString() - const allowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) + const assetSymbol = + Asset.from(allowanceValue).symbol.code.value.toString() + const allowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbol) expect(allowance).to.be.deep.equal({ node_allowance: allowanceValue, token: token.account, }) - const updatedAllowanceValue = "300.0000 TKN" + const updatedAllowanceValue = '300.0000 TKN' await feesmanager.contract.actions - .setallowance([node1, token.account, updatedAllowanceValue]) + .setallowance([node1, token.account, updatedAllowanceValue]) .send(active(feesmanager.account)) - const updatedAllowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) + const updatedAllowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbol) expect(updatedAllowance).to.be.deep.equal({ node_allowance: updatedAllowanceValue, token: token.account, @@ -157,7 +182,7 @@ describe('Feesmanager testing', () => { describe('feesmanager::incallowance', () => { it('Should reject if not authorized', async () => { - const allowanceValue = "100.0000 TKN" + const allowanceValue = '100.0000 TKN' const action = feesmanager.contract.actions .incallowance([node1, token.account, allowanceValue]) .send(active(evil)) @@ -166,12 +191,12 @@ describe('Feesmanager testing', () => { }) it('Should reject if allowance plus inc value is bigger than feesmanager balance', async () => { - const allowanceValue = "100.0000 TKN" - const feesmanagerBalance = "100.0000 TKN" - const assetSymbol = Asset.from(feesmanagerBalance).symbol.code.value.toString() + const allowanceValue = '100.0000 TKN' + const feesmanagerBalance = '100.0000 TKN' + const assetSymbol = + Asset.from(feesmanagerBalance).symbol.code.value.toString() - await token.contract.actions - .create([issuer, token.maxSupply]).send() + await token.contract.actions.create([issuer, token.maxSupply]).send() await token.contract.actions .issue([issuer, feesmanagerBalance, '']) .send(active(issuer)) @@ -183,12 +208,14 @@ describe('Feesmanager testing', () => { .setallowance([node1, token.account, allowanceValue]) .send(active(feesmanager.account)) - const balance = token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRow(assetSymbol) + const balance = token.contract.tables + .accounts(getAccountCodeRaw(feesmanager.account)) + .getTableRow(assetSymbol) expect(balance).to.be.deep.equal({ balance: feesmanagerBalance, }) - const updatedAllowanceValue = "1.0000 TKN" + const updatedAllowanceValue = '1.0000 TKN' const action = feesmanager.contract.actions .incallowance([node1, token.account, updatedAllowanceValue]) .send(active(feesmanager.account)) @@ -197,11 +224,10 @@ describe('Feesmanager testing', () => { }) it('Should increase the allowance', async () => { - const allowanceValue = "100.0000 TKN" - const feesmanagerBalance = "400.0000 TKN" + const allowanceValue = '100.0000 TKN' + const feesmanagerBalance = '400.0000 TKN' - await token.contract.actions - .create([issuer, token.maxSupply]).send() + await token.contract.actions.create([issuer, token.maxSupply]).send() await token.contract.actions .issue([issuer, feesmanagerBalance, '']) .send(active(issuer)) @@ -212,20 +238,25 @@ describe('Feesmanager testing', () => { .setallowance([node1, token.account, allowanceValue]) .send(active(feesmanager.account)) - const assetSymbol = Asset.from(allowanceValue).symbol.code.value.toString() - const allowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) + const assetSymbol = + Asset.from(allowanceValue).symbol.code.value.toString() + const allowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbol) expect(allowance).to.be.deep.equal({ node_allowance: allowanceValue, token: token.account, }) - const updatedAllowanceValue = "300.0000 TKN" + const updatedAllowanceValue = '300.0000 TKN' await feesmanager.contract.actions .incallowance([node1, token.account, updatedAllowanceValue]) .send(active(feesmanager.account)) - - const updatedAllowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) - const expectedAllowanceValue = "400.0000 TKN" + + const updatedAllowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbol) + const expectedAllowanceValue = '400.0000 TKN' expect(updatedAllowance).to.be.deep.equal({ node_allowance: expectedAllowanceValue, token: token.account, @@ -244,9 +275,8 @@ describe('Feesmanager testing', () => { }) it('Should withdraw to the node', async () => { - const feesmanagerBalance = "100.0000 TKN" - await token.contract.actions - .create([issuer, token.maxSupply]).send() + const feesmanagerBalance = '100.0000 TKN' + await token.contract.actions.create([issuer, token.maxSupply]).send() await token.contract.actions .issue([issuer, feesmanagerBalance, '']) .send(active(issuer)) @@ -254,22 +284,30 @@ describe('Feesmanager testing', () => { .transfer([issuer, feesmanager.account, feesmanagerBalance, '']) .send(active(issuer)) - const allowanceValue = "100.0000 TKN" + const allowanceValue = '100.0000 TKN' await feesmanager.contract.actions .setallowance([node1, token.account, allowanceValue]) .send(active(feesmanager.account)) const assetSymbol = Asset.from(allowanceValue).symbol const assetSymbolCode = assetSymbol.code.value.toString() - const allowance = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbolCode) + const allowance = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbolCode) expect(allowance).to.be.deep.equal({ node_allowance: allowanceValue, token: token.account, }) - const feesmanagerBalanceBefore = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() - const nodeBalanceBefore = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() - const allowanceBefore = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbolCode) + const feesmanagerBalanceBefore = await token.contract.tables + .accounts(getAccountCodeRaw(feesmanager.account)) + .getTableRows() + const nodeBalanceBefore = await token.contract.tables + .accounts(getAccountCodeRaw(node1)) + .getTableRows() + const allowanceBefore = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbolCode) expect(feesmanagerBalanceBefore[0]).to.be.deep.equal({ balance: feesmanagerBalance, }) @@ -278,95 +316,101 @@ describe('Feesmanager testing', () => { node_allowance: allowanceValue, token: token.account, }) - + await feesmanager.contract.actions .withdrawto([node1, token.account, assetSymbol]) .send(active(feesmanager.account)) - const feesmanagerBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() - const nodeBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() - const allowanceAfter = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbolCode) + const feesmanagerBalanceAfter = await token.contract.tables + .accounts(getAccountCodeRaw(feesmanager.account)) + .getTableRows() + const nodeBalanceAfter = await token.contract.tables + .accounts(getAccountCodeRaw(node1)) + .getTableRows() + const allowanceAfter = feesmanager.contract.tables + .allowances(getAccountCodeRaw(node1)) + .getTableRow(assetSymbolCode) expect(feesmanagerBalanceAfter[0]).to.be.deep.equal({ - balance: "0.0000 TKN", + balance: '0.0000 TKN', }) expect(nodeBalanceAfter[0]).to.be.deep.equal({ balance: feesmanagerBalance, }) expect(allowanceAfter).to.be.deep.equal({ - node_allowance: "0.0000 TKN", + node_allowance: '0.0000 TKN', token: token.account, }) }) }) - + // describe('feesmanager::withdrawtomultiple', () => { - // it('Should withdraw to the nodes', async () => { - // const feesmanagerBalance = "100.0000 TKN" - // await token.contract.actions - // .create([issuer, token.maxSupply]).send() - // await token.contract.actions - // .issue([issuer, feesmanagerBalance, '']) - // .send(active(issuer)) - // await token.contract.actions - // .transfer([issuer, feesmanager.account, feesmanagerBalance, '']) - // .send(active(issuer)) - - // const allowanceValue1 = "50.0000 TKN" - // await feesmanager.contract.actions - // .setallowance([node1, token.account, allowanceValue1]) - // .send(active(feesmanager.account)) - - // const allowanceValue2 = "50.0000 TKN" - // await feesmanager.contract.actions - // .setallowance([node2, token.account, allowanceValue2]) - // .send(active(feesmanager.account)) - - // const assetSymbol1 = Asset.from(allowanceValue1).symbol - // const assetSymbol1Code = assetSymbol1.code.value.toString() - // const allowance1 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol1Code) - // expect(allowance1).to.be.deep.equal({ - // node_allowance: allowanceValue1, - // token: token.account, - // }) - - // const assetSymbol2 = Asset.from(allowanceValue2).symbol - // const assetSymbol2Code = assetSymbol2.code.value.toString() - // const allowance2 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol2Code) - // expect(allowance2).to.be.deep.equal({ - // node_allowance: allowanceValue1, - // token: token.account, - // }) - - // const feesmanagerBalanceBefore = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() - // const nodeBalanceBefore1 = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() - // const allowanceBefore1 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol1Code) - // expect(feesmanagerBalanceBefore[0]).to.be.deep.equal({ - // balance: feesmanagerBalance, - // }) - // expect(nodeBalanceBefore1[0]).to.be.deep.equal(undefined) - // expect(allowanceBefore1).to.be.deep.equal({ - // node_allowance: allowanceValue1, - // token: token.account, - // }) - - // await feesmanager.contract.actions - // .withdrawto([node1, [token.account, token.account], [assetSymbol1, assetSymbol2]]) - // .send(active(feesmanager.account)) - - // console.log(feesmanager.contract.bc.console) - // const feesmanagerBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() - // const nodeBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() - // const allowanceAfter = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) - // expect(feesmanagerBalanceAfter[0]).to.be.deep.equal({ - // balance: "0.0000 TKN", - // }) - // expect(nodeBalanceAfter[0]).to.be.deep.equal({ - // balance: feesmanagerBalance, - // }) - // expect(allowanceAfter).to.be.deep.equal({ - // node_allowance: "0.0000 TKN", - // token: token.account, - // }) - // }) + // it('Should withdraw to the nodes', async () => { + // const feesmanagerBalance = "100.0000 TKN" + // await token.contract.actions + // .create([issuer, token.maxSupply]).send() + // await token.contract.actions + // .issue([issuer, feesmanagerBalance, '']) + // .send(active(issuer)) + // await token.contract.actions + // .transfer([issuer, feesmanager.account, feesmanagerBalance, '']) + // .send(active(issuer)) + + // const allowanceValue1 = "50.0000 TKN" + // await feesmanager.contract.actions + // .setallowance([node1, token.account, allowanceValue1]) + // .send(active(feesmanager.account)) + + // const allowanceValue2 = "50.0000 TKN" + // await feesmanager.contract.actions + // .setallowance([node2, token.account, allowanceValue2]) + // .send(active(feesmanager.account)) + + // const assetSymbol1 = Asset.from(allowanceValue1).symbol + // const assetSymbol1Code = assetSymbol1.code.value.toString() + // const allowance1 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol1Code) + // expect(allowance1).to.be.deep.equal({ + // node_allowance: allowanceValue1, + // token: token.account, + // }) + + // const assetSymbol2 = Asset.from(allowanceValue2).symbol + // const assetSymbol2Code = assetSymbol2.code.value.toString() + // const allowance2 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol2Code) + // expect(allowance2).to.be.deep.equal({ + // node_allowance: allowanceValue1, + // token: token.account, + // }) + + // const feesmanagerBalanceBefore = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() + // const nodeBalanceBefore1 = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() + // const allowanceBefore1 = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol1Code) + // expect(feesmanagerBalanceBefore[0]).to.be.deep.equal({ + // balance: feesmanagerBalance, + // }) + // expect(nodeBalanceBefore1[0]).to.be.deep.equal(undefined) + // expect(allowanceBefore1).to.be.deep.equal({ + // node_allowance: allowanceValue1, + // token: token.account, + // }) + + // await feesmanager.contract.actions + // .withdrawto([node1, [token.account, token.account], [assetSymbol1, assetSymbol2]]) + // .send(active(feesmanager.account)) + + // console.log(feesmanager.contract.bc.console) + // const feesmanagerBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(feesmanager.account)).getTableRows() + // const nodeBalanceAfter = await token.contract.tables.accounts(getAccountCodeRaw(node1)).getTableRows() + // const allowanceAfter = feesmanager.contract.tables.allowances(getAccountCodeRaw(node1)).getTableRow(assetSymbol) + // expect(feesmanagerBalanceAfter[0]).to.be.deep.equal({ + // balance: "0.0000 TKN", + // }) + // expect(nodeBalanceAfter[0]).to.be.deep.equal({ + // balance: feesmanagerBalance, + // }) + // expect(allowanceAfter).to.be.deep.equal({ + // node_allowance: "0.0000 TKN", + // token: token.account, + // }) + // }) // }) }) diff --git a/cpp/test/lockbox.test.js b/cpp/test/lockbox.test.js index de4e2219..e0671d2b 100644 --- a/cpp/test/lockbox.test.js +++ b/cpp/test/lockbox.test.js @@ -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, diff --git a/cpp/test/utils/get-event-bytes.js b/cpp/test/utils/get-event-bytes.js index 5874239b..66caf9bb 100644 --- a/cpp/test/utils/get-event-bytes.js +++ b/cpp/test/utils/get-event-bytes.js @@ -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) -} \ No newline at end of file +} diff --git a/cpp/test/utils/precision-utils.js b/cpp/test/utils/precision-utils.js index f1d16457..758c8231 100644 --- a/cpp/test/utils/precision-utils.js +++ b/cpp/test/utils/precision-utils.js @@ -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, } diff --git a/cpp/test/utils/wharfkit-ext.js b/cpp/test/utils/wharfkit-ext.js index 11c6f02e..800b665c 100644 --- a/cpp/test/utils/wharfkit-ext.js +++ b/cpp/test/utils/wharfkit-ext.js @@ -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) From 84965c272ca3214f76144ef397a19232262870c5 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:36:37 +0100 Subject: [PATCH 4/6] chore(package.json): add prettier scripts --- solidity/package.json | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/solidity/package.json b/solidity/package.json index 9a2870f6..89dfa52a 100644 --- a/solidity/package.json +++ b/solidity/package.json @@ -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": { From 88e0109f113be379bf34e551dbe24ac9ba46a0f2 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:37:15 +0100 Subject: [PATCH 5/6] chore(solidity): run prettier --- solidity/src/interfaces/IAdapter.sol | 4 ++-- solidity/test/hardhat/utils/get-swap-event.js | 5 +++-- solidity/test/hardhat/utils/validate-upgrade.js | 10 ++++++---- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/solidity/src/interfaces/IAdapter.sol b/solidity/src/interfaces/IAdapter.sol index bcc7d6f6..d7924455 100644 --- a/solidity/src/interfaces/IAdapter.sol +++ b/solidity/src/interfaces/IAdapter.sol @@ -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); @@ -90,4 +90,4 @@ interface IAdapter { * @param amount The amount from which the fees will be calculated */ function calculateFee(uint256 amount) external returns (uint256); -} \ No newline at end of file +} diff --git a/solidity/test/hardhat/utils/get-swap-event.js b/solidity/test/hardhat/utils/get-swap-event.js index 67398c91..40ac3223 100644 --- a/solidity/test/hardhat/utils/get-swap-event.js +++ b/solidity/test/hardhat/utils/get-swap-event.js @@ -1,6 +1,7 @@ const R = require('ramda') -const SWAP_TOPIC = '0x66756e6473206172652073616675207361667520736166752073616675202e2e' +const SWAP_TOPIC = + '0x66756e6473206172652073616675207361667520736166752073616675202e2e' const getSwapEvent = _tx => _tx @@ -11,4 +12,4 @@ const getSwapEvent = _tx => module.exports = { SWAP_TOPIC, getSwapEvent, -} \ No newline at end of file +} diff --git a/solidity/test/hardhat/utils/validate-upgrade.js b/solidity/test/hardhat/utils/validate-upgrade.js index 14a5e3d3..6f516e43 100644 --- a/solidity/test/hardhat/utils/validate-upgrade.js +++ b/solidity/test/hardhat/utils/validate-upgrade.js @@ -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)), ) From 4857eded03933b79a1c9321691247af66fef3c18 Mon Sep 17 00:00:00 2001 From: Mauro Piazza Date: Wed, 6 Nov 2024 22:39:11 +0100 Subject: [PATCH 6/6] chore(package.json): refine lint script --- javascript/event-attestator/package.json | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/javascript/event-attestator/package.json b/javascript/event-attestator/package.json index 1f6dcdd7..c897927f 100644 --- a/javascript/event-attestator/package.json +++ b/javascript/event-attestator/package.json @@ -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",