diff --git a/packages/celotool/package.json b/packages/celotool/package.json index 8a8c9c31a34..360970f6634 100644 --- a/packages/celotool/package.json +++ b/packages/celotool/package.json @@ -44,7 +44,7 @@ "tiny-secp256k1": "2.2.1", "chai": "^4.3.7", "mocha": "^10.2.0", - "web3": "1.10.0", + "web3": "1.10.4", "web3-eth-admin": "1.0.0-beta.55", "yargs": "17.7.2" }, diff --git a/packages/celotool/src/cmds/deploy/upgrade/hotfix.ts b/packages/celotool/src/cmds/deploy/upgrade/hotfix.ts index 0554873625d..62c7554176a 100644 --- a/packages/celotool/src/cmds/deploy/upgrade/hotfix.ts +++ b/packages/celotool/src/cmds/deploy/upgrade/hotfix.ts @@ -1,6 +1,7 @@ // This is a more unusual Celotool command. It basically helps you to execute Hotfixes on testnets. Because constructing proposals is difficult to do via a CLI, you should define them here in code. There are two examples below that you can start from. import { newKitFromWeb3 } from '@celo/contractkit' +import { L1HotfixRecord } from '@celo/contractkit/lib/wrappers/Governance' import { hotfixToHash, ProposalBuilder, proposalToJSON } from '@celo/governance' import { privateKeyToAddress } from '@celo/utils/lib/address' import { concurrentMap } from '@celo/utils/lib/async' @@ -121,7 +122,9 @@ export const handler = async (argv: EthstatsArgv) => { hotfixRecord = await governance.getHotfixRecord(proposalHash) console.info('\nHotfix Record: ', hotfixRecord) - if (hotfixRecord.preparedEpoch.toNumber() === 0) { + // if this is actually used we need to handle the L2 case but that is out of scope for just upgrading ck + + if ((hotfixRecord as L1HotfixRecord).preparedEpoch?.toNumber() === 0) { console.error('Hotfix could not be prepared') throw new Error() } diff --git a/packages/celotool/src/cmds/generate/faucet-load-test.ts b/packages/celotool/src/cmds/generate/faucet-load-test.ts index 2fae45c3eb9..4a048682437 100644 --- a/packages/celotool/src/cmds/generate/faucet-load-test.ts +++ b/packages/celotool/src/cmds/generate/faucet-load-test.ts @@ -1,3 +1,4 @@ +import { StrongAddress } from '@celo/base' import { newKit } from '@celo/contractkit' import { switchToClusterFromEnv } from 'src/lib/cluster' import { convertToContractDecimals } from 'src/lib/contract-utils' @@ -65,7 +66,7 @@ export const handler = async (argv: CeloEnvArgv & FaucetLoadTest) => { const kit = newKit('http://localhost:8545') const account = (await kit.web3.eth.getAccounts())[0] console.info(`Using account: ${account}`) - kit.defaultAccount = account + kit.defaultAccount = account as StrongAddress const [goldToken, stableToken] = await Promise.all([ kit.contracts.getGoldToken(), diff --git a/packages/celotool/src/e2e-tests/cip35_tests.ts b/packages/celotool/src/e2e-tests/cip35_tests.ts index b31e8f93aae..deae95d25e3 100644 --- a/packages/celotool/src/e2e-tests/cip35_tests.ts +++ b/packages/celotool/src/e2e-tests/cip35_tests.ts @@ -1,3 +1,4 @@ +import { StrongAddress } from '@celo/base' import { CeloTx } from '@celo/connect' import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' import { privateKeyToAddress } from '@celo/utils/lib/address' @@ -26,7 +27,6 @@ const validatorPrivateKey = generatePrivateKey(mnemonic, AccountType.VALIDATOR, const validatorAddress = privateKeyToAddress(validatorPrivateKey) // Arbitrary addresses to use in the transactions const toAddress = '0x8c36775E95A5f7FEf6894Ba658628352Ac58605B' -const gatewayFeeRecipientAddress = '0xc77538d1e30C0e4ec44B0DcaD97FD3dc63fcaCC4' // Simple contract with a single constant const bytecode = @@ -47,8 +47,6 @@ const devFilter: Filter = { ethCompatible: undefined, contractCreation: undefined, useFeeCurrency: undefined, - useGatewayFee: undefined, - useGatewayFeeRecipient: undefined, sendRawTransaction: undefined, } /// //////////////////////////////////////////////////////////////////////////////////////////// @@ -65,8 +63,6 @@ interface TestCase { ethCompatible: boolean contractCreation: boolean useFeeCurrency: boolean - useGatewayFee: boolean - useGatewayFeeRecipient: boolean sendRawTransaction: boolean // whether to use eth_sendRawTransaction ot eth_sendTransaction errorString: string | null errorReason: string | null @@ -88,38 +84,32 @@ function generateTestCases(cipIsActivated: boolean) { for (const ethCompatible of getValues(devFilter.ethCompatible)) { for (const contractCreation of getValues(devFilter.contractCreation)) { for (const useFeeCurrency of getValues(devFilter.useFeeCurrency)) { - for (const useGatewayFee of getValues(devFilter.useGatewayFee)) { - for (const useGatewayFeeRecipient of getValues(devFilter.useGatewayFeeRecipient)) { - for (const sendRawTransaction of getValues(devFilter.sendRawTransaction)) { - let errorString: string | null = null - let errorReason: string | null = null - const hasCeloFields = useFeeCurrency || useGatewayFee || useGatewayFeeRecipient - if (ethCompatible && hasCeloFields) { - errorString = notCompatibleError - errorReason = 'transaction has celo-only fields' - } else if (ethCompatible && !cipIsActivated) { - errorString = notYetActivatedError - errorReason = 'Donut is not activated' - } - if (sendRawTransaction && ethCompatible && hasCeloFields) { - // Such scenarios don't make sense, since eth-compatible transactions in RLP can't have - // these fields. So skip these cases. - continue - } - cases.push({ - cipIsActivated, - lightNode, - ethCompatible, - contractCreation, - useFeeCurrency, - useGatewayFee, - useGatewayFeeRecipient, - sendRawTransaction, - errorString, - errorReason, - }) - } + for (const sendRawTransaction of getValues(devFilter.sendRawTransaction)) { + let errorString: string | null = null + let errorReason: string | null = null + const hasCeloFields = useFeeCurrency + if (ethCompatible && hasCeloFields) { + errorString = notCompatibleError + errorReason = 'transaction has celo-only fields' + } else if (ethCompatible && !cipIsActivated) { + errorString = notYetActivatedError + errorReason = 'Donut is not activated' } + if (sendRawTransaction && ethCompatible && hasCeloFields) { + // Such scenarios don't make sense, since eth-compatible transactions in RLP can't have + // these fields. So skip these cases. + continue + } + cases.push({ + cipIsActivated, + lightNode, + ethCompatible, + contractCreation, + useFeeCurrency, + sendRawTransaction, + errorString, + errorReason, + }) } } } @@ -344,13 +334,7 @@ class TestEnv { nonce: await this.kit.connection.nonce(validatorAddress), } if (testCase.useFeeCurrency) { - tx.feeCurrency = this.stableTokenAddr - } - if (testCase.useGatewayFee) { - tx.gatewayFee = '0x25' - } - if (testCase.useGatewayFeeRecipient) { - tx.gatewayFeeRecipient = gatewayFeeRecipientAddress + tx.feeCurrency = this.stableTokenAddr as StrongAddress } if (testCase.contractCreation) { diff --git a/packages/celotool/src/e2e-tests/transfer_tests.ts b/packages/celotool/src/e2e-tests/transfer_tests.ts index 2de49034b2e..311154b2e4e 100644 --- a/packages/celotool/src/e2e-tests/transfer_tests.ts +++ b/packages/celotool/src/e2e-tests/transfer_tests.ts @@ -1,8 +1,8 @@ +import { StrongAddress } from '@celo/base' import { CeloTxPending, CeloTxReceipt, TransactionResult } from '@celo/connect' import { ContractKit, newKitFromWeb3 } from '@celo/contractkit' import { CeloTokenType, EachCeloToken, StableToken, Token } from '@celo/contractkit/lib/celo-tokens' import { eqAddress, toChecksumAddress } from '@celo/utils/lib/address' -import { toFixed } from '@celo/utils/lib/fixidity' import BigNumber from 'bignumber.js' import { assert } from 'chai' import Web3 from 'web3' @@ -13,67 +13,6 @@ import { getHooks, initAndSyncGethWithRetry, killInstance, sleep } from './utils const TMP_PATH = '/tmp/e2e' const verbose = false -/** - * Helper Class to change StableToken Inflation in tests - */ -class InflationManager { - private kit: ContractKit - private readonly minUpdateDelay = 10 - - constructor( - readonly validatorUri: string, - readonly validatorAddress: string, - readonly token: StableToken - ) { - this.kit = newKitFromWeb3(new Web3(validatorUri)) - this.kit.connection.defaultAccount = validatorAddress - } - - now = async (): Promise => { - return Number((await this.kit.connection.getBlock('pending')).timestamp) - } - - getNextUpdateRate = async (): Promise => { - const stableToken = await this.getStableToken() - // Compute necessary `updateRate` so inflationFactor adjusment takes place on next operation - const { factorLastUpdated } = await stableToken.getInflationParameters() - - // Wait until the minimum update delay has passed so we can set a rate that gives us some - // buffer time to make the transaction in the next availiable update window. - let timeSinceLastUpdated = (await this.now()) - factorLastUpdated.toNumber() - while (timeSinceLastUpdated < this.minUpdateDelay) { - await sleep(this.minUpdateDelay - timeSinceLastUpdated) - timeSinceLastUpdated = (await this.now()) - factorLastUpdated.toNumber() - } - - return timeSinceLastUpdated - } - - getParameters = async () => { - const stableToken = await this.getStableToken() - return stableToken.getInflationParameters() - } - - setInflationRateForNextTransfer = async (rate: BigNumber) => { - // Possibly update the inflation factor and ensure it won't update again. - await this.setInflationParameters(new BigNumber(1), Number.MAX_SAFE_INTEGER) - - const updateRate = await this.getNextUpdateRate() - await this.setInflationParameters(rate, updateRate) - } - - setInflationParameters = async (rate: BigNumber, updatePeriod: number) => { - const stableToken = await this.getStableToken() - await stableToken - .setInflationParameters(toFixed(rate).toFixed(), updatePeriod.toFixed()) - .sendAndWaitForReceipt({ from: this.validatorAddress }) - } - - getStableToken = async () => { - return this.kit.celoTokens.getWrapper(this.token) - } -} - const setIntrinsicGas = async (validatorUri: string, validatorAddress: string, gasCost: number) => { const kit = newKitFromWeb3(new Web3(validatorUri)) const parameters = await kit.contracts.getBlockchainParameters() @@ -205,7 +144,7 @@ describe('Transfer tests', function (this: any) { // Arbitrary addresses. const txFeeRecipientAddress = '0x5555555555555555555555555555555555555555' const ToAddress = '0xbBae99F0E1EE565404465638d40827b54D343638' - const gatewayFeeRecipientAddress = '0x4f5f8a3f45d179553e7b95119ce296010f50f6f1' + const someOtherAddress = '0x4f5f8a3f45d179553e7b95119ce296010f50f6f1' const syncModes = ['full', 'fast', 'light', 'lightest'] const gethConfig: GethRunConfig = { @@ -250,13 +189,12 @@ describe('Transfer tests', function (this: any) { validating: false, syncmode: 'full', lightserv: true, - gatewayFee: new BigNumber(10000), port: 30305, rpcport: 8547, // We need to set an etherbase here so that the full node will accept transactions from // light clients. - minerValidator: gatewayFeeRecipientAddress, - txFeeRecipient: gatewayFeeRecipientAddress, + minerValidator: someOtherAddress, + txFeeRecipient: someOtherAddress, } const restartWithCleanNodes = async () => { @@ -311,8 +249,6 @@ describe('Transfer tests', function (this: any) { port: 30307, rpcport: 8549, lightserv: !light, - // TODO(nategraf): Remove this when light clients can query for gateway fee. - gatewayFee: light ? new BigNumber(10000) : undefined, privateKey: DEF_FROM_PK, } @@ -346,9 +282,7 @@ describe('Transfer tests', function (this: any) { txOptions: { gas?: number gasPrice?: string - feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string + feeCurrency?: StrongAddress } = {} ) => { const res = await kit.connection.sendTransaction({ @@ -367,9 +301,7 @@ describe('Transfer tests', function (this: any) { txOptions: { gas?: number gasPrice?: string - feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string + feeCurrency?: StrongAddress } = {} ) => { const kitStableToken = await kit.contracts.getStableToken() @@ -394,7 +326,6 @@ describe('Transfer tests', function (this: any) { total: BigNumber tip: BigNumber base: BigNumber - gateway: BigNumber } interface GasUsage { @@ -465,17 +396,11 @@ describe('Transfer tests', function (this: any) { const txFee = new BigNumber(gasVal).times(tx.gasPrice) const txFeeBase = new BigNumber(gasVal).times(minGasPrice) const txFeeTip = txFee.minus(txFeeBase) - const gatewayFee = new BigNumber(tx.gatewayFee || 0) - assert.equal( - tx.gatewayFeeRecipient === null || tx.gatewayFeeRecipient === undefined, - gatewayFee.eq(0) - ) const fees: Fees = { - total: txFee.plus(gatewayFee), + total: txFee, base: txFeeBase, tip: txFeeTip, - gateway: gatewayFee, } const gas: GasUsage = { used: receipt && receipt.gasUsed, @@ -528,8 +453,6 @@ describe('Transfer tests', function (this: any) { expectSuccess?: boolean txOptions?: { gas?: number - gatewayFeeRecipient?: string - gatewayFee?: string } fromAddress?: string toAddress?: string @@ -562,8 +485,6 @@ describe('Transfer tests', function (this: any) { expectSuccess?: boolean txOptions?: { gas?: number - gatewayFeeRecipient?: string - gatewayFee?: string } fromAddress?: string toAddress?: string @@ -578,7 +499,7 @@ describe('Transfer tests', function (this: any) { fromAddress, toAddress, txFeeRecipientAddress, - gatewayFeeRecipientAddress, + someOtherAddress, governanceAddress, ] balances = await newBalanceWatcher(kit, accounts) @@ -648,9 +569,6 @@ describe('Transfer tests', function (this: any) { } } - it(`should increment the gateway fee recipient's ${feeToken} balance by the gateway fee`, () => - assertEqualBN(balances.delta(gatewayFeeRecipientAddress, feeToken), txRes.fees.gateway)) - it(`should increment the infrastructure fund's ${feeToken} balance by the base portion of the gas fee`, () => assertEqualBN(balances.delta(governanceAddress, feeToken), txRes.fees.base)) @@ -667,73 +585,11 @@ describe('Transfer tests', function (this: any) { describe('Transfer CeloGold >', () => { describe('with feeCurrency = CeloGold >', () => { - if (syncMode === 'light' || syncMode === 'lightest') { - describe('when running in light/lightest sync mode', () => { - const recipient = (choice: string) => { - switch (choice) { - case 'peer': - return gatewayFeeRecipientAddress - case 'random': - return Web3.utils.randomHex(20) - default: - // unset - return undefined - } - } - const feeValue = (choice: string) => { - switch (choice) { - case 'sufficient': - return '0x10000' - case 'insufficient': - return '0x1' - default: - // unset - return undefined - } - } - for (const recipientChoice of ['peer', 'random', 'unset']) { - describe(`when the gateway fee recipient is ${recipientChoice}`, () => { - for (const feeValueChoice of ['sufficient', 'insufficient', 'unset']) { - describe(`when the gateway fee value is ${feeValueChoice}`, () => { - const txOptions = { - gatewayFeeRecipient: recipient(recipientChoice), - gatewayFee: feeValue(feeValueChoice), - } - if (recipientChoice === 'random' || feeValueChoice === 'insufficient') { - it('should get rejected by the sending node before being added to the tx pool', async () => { - try { - const res = await transferCeloGold( - FromAddress, - ToAddress, - TransferAmount, - txOptions - ) - await res.waitReceipt() - assert.fail('no error was thrown') - } catch (error: any) { - assert.include(error.toString(), `Error: no suitable peers available`) - } - }) - } else { - testTransferToken({ - expectedGas: INTRINSIC_TX_GAS_COST, - transferToken: Token.CELO, - feeToken: Token.CELO, - txOptions, - }) - } - }) - } - }) - } - }) - } else { - testTransferToken({ - expectedGas: INTRINSIC_TX_GAS_COST, - transferToken: Token.CELO, - feeToken: Token.CELO, - }) - } + testTransferToken({ + expectedGas: INTRINSIC_TX_GAS_COST, + transferToken: Token.CELO, + feeToken: Token.CELO, + }) }) describe('feeCurrency = CeloDollars >', () => { @@ -851,92 +707,4 @@ describe('Transfer tests', function (this: any) { }) } }) - - describe('Transfer with Demurrage >', () => { - for (const syncMode of syncModes) { - describe(`${syncMode} Node >`, () => { - let inflationManager: InflationManager - before(`start geth on sync: ${syncMode}`, async () => { - await restartWithCleanNodes() - inflationManager = new InflationManager( - 'http://localhost:8545', - validatorAddress, - StableToken.cUSD - ) - await startSyncNode(syncMode) - }) - - describe('when there is demurrage of 50% applied', () => { - describe('when setting a gas amount greater than the amount of gas necessary', () => { - let balances: BalanceWatcher - let expectedFees: Fees - let txRes: TestTxResults - - before(async () => { - balances = await newBalanceWatcher(kit, [ - FromAddress, - ToAddress, - gatewayFeeRecipientAddress, - governanceAddress, - ]) - - await inflationManager.setInflationRateForNextTransfer(new BigNumber(2)) - const feeCurrency = await kit.celoTokens.getFeeCurrencyAddress(StableToken.cUSD) - txRes = await runTestTransaction( - await transferCeloGold(FromAddress, ToAddress, TransferAmount, { - feeCurrency, - }), - INTRINSIC_TX_GAS_COST + ADDITIONAL_INTRINSIC_TX_GAS_COST, - feeCurrency - ) - - await balances.update() - expectedFees = txRes.fees - }) - - it('should succeed', () => assert.isTrue(txRes.ok)) - - it('should use the expected amount of gas', () => - assert.equal(txRes.gas.used, txRes.gas.expected)) - - it("should decrement the sender's Celo Gold balance by the transfer amount", () => { - assertEqualBN(balances.delta(FromAddress, Token.CELO).negated(), TransferAmount) - }) - - it("should increment the receiver's Celo Gold balance by the transfer amount", () => { - assertEqualBN(balances.delta(ToAddress, Token.CELO), TransferAmount) - }) - - it("should halve the sender's Celo Dollar balance due to demurrage and decrement it by the total fees", () => { - assertEqualBN( - balances - .initial(FromAddress, StableToken.cUSD) - .idiv(2) - .minus(balances.current(FromAddress, StableToken.cUSD)), - expectedFees.total - ) - }) - - it("should halve the gateway fee recipient's Celo Dollar balance then increase it by the gateway fee", () => { - assertEqualBN( - balances - .current(gatewayFeeRecipientAddress, StableToken.cUSD) - .minus(balances.initial(gatewayFeeRecipientAddress, StableToken.cUSD).idiv(2)), - expectedFees.gateway - ) - }) - - it("should halve the infrastructure fund's Celo Dollar balance then increment it by the base portion of the gas fees", () => { - assertEqualBN( - balances - .current(governanceAddress, StableToken.cUSD) - .minus(balances.initial(governanceAddress, StableToken.cUSD).idiv(2)), - expectedFees.base - ) - }) - }) - }) - }) - } - }) }) diff --git a/packages/celotool/src/lib/generate_utils.ts b/packages/celotool/src/lib/generate_utils.ts index 312e35b9283..97abef839a9 100644 --- a/packages/celotool/src/lib/generate_utils.ts +++ b/packages/celotool/src/lib/generate_utils.ts @@ -1,4 +1,4 @@ -// @ts-ignore +import { StrongAddress } from '@celo/base' import * as bls12377js from '@celo/bls12377js' import { blsPrivateKeyToProcessedPrivateKey } from '@celo/cryptographic-utils/lib/bls' import BigNumber from 'bignumber.js' @@ -145,8 +145,7 @@ export const privateKeyToPublicKey = (privateKey: string): string => { } export const privateKeyToAddress = (privateKey: string) => { - // @ts-ignore - return new Web3.modules.Eth().accounts.privateKeyToAccount(ensure0x(privateKey)).address + return new Web3().eth.accounts.privateKeyToAccount(ensure0x(privateKey)).address as StrongAddress } export const privateKeyToStrippedAddress = (privateKey: string) => diff --git a/packages/celotool/src/lib/geth.ts b/packages/celotool/src/lib/geth.ts index 8c7da6d364d..cf21f5810c3 100644 --- a/packages/celotool/src/lib/geth.ts +++ b/packages/celotool/src/lib/geth.ts @@ -1,4 +1,5 @@ /* eslint-disable no-console */ +import { StrongAddress } from '@celo/base' import { CeloTxReceipt, TransactionResult } from '@celo/connect' import { CeloContract, ContractKit, newKitFromWeb3 } from '@celo/contractkit' import { GoldTokenWrapper } from '@celo/contractkit/lib/wrappers/GoldTokenWrapper' @@ -452,9 +453,7 @@ export const transferCalldata = async ( chainId?: number gas?: number gasPrice?: string - feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string + feeCurrency?: StrongAddress nonce?: number } = {} ) => { @@ -466,8 +465,6 @@ export const transferCalldata = async ( data: dataStr, gas: txOptions.gas, gasPrice: txOptions.gasPrice, - gatewayFeeRecipient: txOptions.gatewayFeeRecipient, - gatewayFee: txOptions.gatewayFee, nonce: txOptions.nonce, }) } @@ -484,8 +481,6 @@ export const transferOrdinals = async ( gas?: number gasPrice?: string feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string nonce?: number } = {} ) => { @@ -514,9 +509,7 @@ export const transferCeloGold = async ( chainId?: number gas?: number gasPrice?: string - feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string + feeCurrency?: StrongAddress nonce?: number } = {} ) => { @@ -527,8 +520,6 @@ export const transferCeloGold = async ( gas: txOptions.gas, gasPrice: txOptions.gasPrice, feeCurrency: txOptions.feeCurrency || undefined, - gatewayFeeRecipient: txOptions.gatewayFeeRecipient, - gatewayFee: txOptions.gatewayFee, nonce: txOptions.nonce, }) } @@ -543,9 +534,7 @@ export const transferCeloDollars = async ( chainId?: number gas?: number gasPrice?: string - feeCurrency?: string - gatewayFeeRecipient?: string - gatewayFee?: string + feeCurrency?: StrongAddress nonce?: number } = {} ) => { @@ -556,8 +545,6 @@ export const transferCeloDollars = async ( gas: txOptions.gas, gasPrice: txOptions.gasPrice, feeCurrency: txOptions.feeCurrency || undefined, - gatewayFeeRecipient: txOptions.gatewayFeeRecipient, - gatewayFee: txOptions.gatewayFee, nonce: txOptions.nonce, }) } @@ -1238,7 +1225,6 @@ export async function startGeth( isProxied, proxyport, ethstats, - gatewayFee, } = instance const privateKey = instance.privateKey || '' @@ -1309,10 +1295,6 @@ export async function startGeth( instance.args.push(`--nodekeyhex=${privateKey}`) } - if (gatewayFee) { - instance.args.push(`--light.gatewayfee=${gatewayFee.toString()}`) - } - if (validating) { instance.args.push('--mine') diff --git a/packages/celotool/src/lib/interfaces/geth-instance-config.ts b/packages/celotool/src/lib/interfaces/geth-instance-config.ts index bb72e7c13ba..e620f9ad566 100644 --- a/packages/celotool/src/lib/interfaces/geth-instance-config.ts +++ b/packages/celotool/src/lib/interfaces/geth-instance-config.ts @@ -1,5 +1,3 @@ -import BigNumber from 'bignumber.js' - export interface GethInstanceConfig { name: string validating?: boolean @@ -11,7 +9,6 @@ export interface GethInstanceConfig { rpcport?: number wsport?: number lightserv?: boolean - gatewayFee?: BigNumber privateKey?: string minerValidator?: string txFeeRecipient?: string diff --git a/packages/env-tests/src/monorepoRun.ts b/packages/env-tests/src/monorepoRun.ts index 81362a33c64..f0b04337233 100644 --- a/packages/env-tests/src/monorepoRun.ts +++ b/packages/env-tests/src/monorepoRun.ts @@ -17,6 +17,8 @@ function runTests() { if (!process.env.MNEMONIC) { throw new Error('No MNEMONIC was set, envName was parsed as ' + envName) } + // eslint-disable-next-line @typescript-eslint/ban-ts-comment + // @ts-expect-error const kit = newKitFromWeb3(new Web3(process.env.CELO_PROVIDER || 'http://localhost:8545')) const mnemonic: string = process.env.MNEMONIC const reserveSpenderMultiSigAddress = process.env.RESERVE_SPENDER_MULTISIG_ADDRESS diff --git a/packages/env-tests/src/tests/oracle.ts b/packages/env-tests/src/tests/oracle.ts index 6e18bc9cfe1..106d3d7dc3f 100644 --- a/packages/env-tests/src/tests/oracle.ts +++ b/packages/env-tests/src/tests/oracle.ts @@ -1,5 +1,6 @@ +/* eslint-disable import/no-extraneous-dependencies */ +import { StrongAddress } from '@celo/base' import { CeloContract } from '@celo/contractkit' -// eslint-disable-next-line import/no-extraneous-dependencies import { describe, expect, test } from '@jest/globals' import BigNumber from 'bignumber.js' import { EnvTestContext } from '../context' @@ -16,7 +17,7 @@ export function runOracleTest(context: EnvTestContext) { test('report a rate', async () => { const from = await getKey(context.mnemonic, TestAccounts.Oracle) context.kit.connection.addAccount(from.privateKey) - context.kit.defaultAccount = from.address + context.kit.defaultAccount = from.address as StrongAddress const stableToken = await context.kit.contracts.getStableToken() context.kit.defaultFeeCurrency = stableToken.address diff --git a/packages/env-tests/src/tests/reserve.ts b/packages/env-tests/src/tests/reserve.ts index f3a8cafd4d6..e794991e742 100644 --- a/packages/env-tests/src/tests/reserve.ts +++ b/packages/env-tests/src/tests/reserve.ts @@ -36,7 +36,7 @@ export function runReserveTest(context: EnvTestContext) { expect(custodians).toContain(custodian.address) const spenderMultiSig = await context.kit.contracts.getMultiSig(spenderMultiSigAddress) - const isOwner = await spenderMultiSig.isowner(spender.address) + const isOwner = await spenderMultiSig.isOwner(spender.address) expect(isOwner).toBeTruthy() const reserveValue = await reserve.getReserveGoldBalance() diff --git a/packages/metadata-crawler/src/crawler.ts b/packages/metadata-crawler/src/crawler.ts index bc6f8d1d132..e787be988b2 100644 --- a/packages/metadata-crawler/src/crawler.ts +++ b/packages/metadata-crawler/src/crawler.ts @@ -14,12 +14,12 @@ import { dataLogger, logger, operationalLogger } from './logger' const CONCURRENCY = 10 -const PGUSER = process.env['PGUSER'] || 'postgres' -const PGPASSWORD = process.env['PGPASSWORD'] || '' -const PGHOST = process.env['PGHOST'] || '127.0.0.1' -const PGPORT = process.env['PGPORT'] || '5432' -const PGDATABASE = process.env['PGDATABASE'] || 'blockscout' -const PROVIDER_URL = process.env['PROVIDER_URL'] || 'http://localhost:8545' +const PGUSER = process.env.PGUSER || 'postgres' +const PGPASSWORD = process.env.PGPASSWORD || '' +const PGHOST = process.env.PGHOST || '127.0.0.1' +const PGPORT = process.env.PGPORT || '5432' +const PGDATABASE = process.env.PGDATABASE || 'blockscout' +const PROVIDER_URL = process.env.PROVIDER_URL || 'http://localhost:8545' const client = new Client({ user: PGUSER, @@ -28,11 +28,13 @@ const client = new Client({ port: Number(PGPORT), database: PGDATABASE, }) - +// eslint-disable-next-line @typescript-eslint/ban-ts-comment +// @ts-expect-error const kit = newKitFromWeb3(new Web3(PROVIDER_URL)) async function jsonQuery(query: string) { - let res = await client.query(`SELECT json_agg(t) FROM (${query}) t`) + const res = await client.query(`SELECT json_agg(t) FROM (${query}) t`) + // eslint-disable-next-line @typescript-eslint/no-unsafe-return return res.rows[0].json_agg } @@ -40,7 +42,7 @@ async function createVerificationClaims( address: string, domain: string, verified: boolean, - accounts: Array
+ accounts: Address[] ) { await addDatabaseVerificationClaims(address, domain, verified) await concurrentMap(CONCURRENCY, accounts, (account) => @@ -84,20 +86,20 @@ async function getVerifiedAccounts(metadata: IdentityMetadataWrapper, address: A async function getVerifiedDomains( metadata: IdentityMetadataWrapper, address: Address, - logger: Logger + loggerParam: Logger ) { const unverifiedDomains = metadata.filterClaims(ClaimTypes.DOMAIN) const domainVerification = await concurrentMap(CONCURRENCY, unverifiedDomains, async (claim) => { try { const verificationStatus = await verifyDomainRecord(kit, claim, address) - logger.debug({ claim, verificationStatus }, `verified_domain`) + loggerParam.debug({ claim, verificationStatus }, `verified_domain`) return { claim, verified: verificationStatus === undefined, } } catch (err) { - logger.error({ err, claim }) + loggerParam.error({ err, claim }) return { claim, verified: false, diff --git a/packages/protocol/package.json b/packages/protocol/package.json index 7c260f0e3f9..930827d8681 100644 --- a/packages/protocol/package.json +++ b/packages/protocol/package.json @@ -109,11 +109,11 @@ "truffle": "5.9.0", "truffle-security": "^1.7.3", "weak-map": "^1.0.5", - "web3": "1.10.0", - "web3-core": "1.10.0", + "web3": "1.10.4", + "web3-core": "1.10.4", "web3-core-helpers": "1.10.0", "web3-provider-engine": "^16.0.5", - "web3-utils": "1.10.0", + "web3-utils": "1.10.4", "truffle-plugin-verify": "^0.6.5" }, "devDependencies": {