Skip to content

Commit

Permalink
it works on my machine ok
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronmgdr committed Jan 24, 2024
1 parent 434b4ed commit 767eeb1
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 21 deletions.
10 changes: 5 additions & 5 deletions packages/celotool/src/cmds/bots/auto-vote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,11 +175,11 @@ async function castVote(
return tx.sendAndWaitForReceipt({ from: botAccount })
})
const group = normalizeAddressWith0x(vote.group)
const oldCapacity = groupCapacities.get(group)!
const oldCapacity = groupCapacities.get(group)
groupCapacities.set(group, oldCapacity.plus(vote.pending.plus(vote.active)))
}

const groupCapacity = groupCapacities.get(voteForGroup)!
const groupCapacity = groupCapacities.get(voteForGroup)
const voteAmount = BigNumber.minimum(lockedGoldAmount, groupCapacity)
const voteTx = await election.vote(voteForGroup, BigNumber.minimum(voteAmount))
await voteTx.sendAndWaitForReceipt({ from: botAccount })
Expand Down Expand Up @@ -218,7 +218,7 @@ async function calculateGroupScores(kit: ContractKit): Promise<Map<string, BigNu
).filter((v) => !!v.affiliation) // Skip unaffiliated

const validatorsByGroup = groupBy(validatorAccounts, (validator) =>
normalizeAddressWith0x(validator.affiliation!)
normalizeAddressWith0x(validator.affiliation)
)

const validatorGroupScores = mapValues(validatorsByGroup, (vals) => {
Expand Down Expand Up @@ -258,7 +258,7 @@ function getWeightedRandomChoice(
const sortedGroupKeys = [...groupWeights.keys()]
.filter((k) => groupsToConsider.includes(k))
.sort((a, b) => {
return groupWeights.get(b)!.comparedTo(groupWeights.get(a)!)
return groupWeights.get(b).comparedTo(groupWeights.get(a))
})

let weightTotal = new BigNumber(0)
Expand All @@ -270,7 +270,7 @@ function getWeightedRandomChoice(
let totalSoFar = new BigNumber(0)

for (const key of sortedGroupKeys) {
totalSoFar = totalSoFar.plus(groupWeights.get(key)!)
totalSoFar = totalSoFar.plus(groupWeights.get(key))
if (totalSoFar.isGreaterThanOrEqualTo(choice)) {
return key
}
Expand Down
3 changes: 1 addition & 2 deletions packages/celotool/src/cmds/geth/start.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/* tslint:disable: no-console */
import { readFileSync } from 'fs'
import { addCeloGethMiddleware } from 'src/lib/utils'
import yargs from 'yargs'
Expand Down Expand Up @@ -261,7 +260,7 @@ export const handler = async (argv: StartArgv) => {
node.isProxied = true
node.proxyAllowPrivateIp = true
node.proxies = [
getEnodeAddress(privateKeyToPublicKey(proxyPrivateKeys[x]), '127.0.0.1', proxy.proxyport!),
getEnodeAddress(privateKeyToPublicKey(proxyPrivateKeys[x]), '127.0.0.1', proxy.proxyport),
getEnodeAddress(privateKeyToPublicKey(validatorPrivateKeys[x]), '127.0.0.1', node.port),
]
}
Expand Down
2 changes: 1 addition & 1 deletion packages/celotool/src/cmds/transactions/describe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const handler = async (argv: DescribeArgv) => {
to: transaction.to ? transaction.to : undefined,
from: transaction.from,
},
transaction.blockNumber!
transaction.blockNumber
)

if (called.startsWith('0x08c379a')) {
Expand Down
10 changes: 5 additions & 5 deletions packages/celotool/src/e2e-tests/cip35_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ class TestEnv {
if (ethCompatible && !this.cipIsActivated) {
it('fails due to being ethereum-compatible', () => {
assert.isNull(minedTx, 'Transaction succeeded when it should have failed')
assert.equal(error!, notYetActivatedError)
assert.equal(error, notYetActivatedError)
})
} else if (this.cipIsActivated) {
if (this.replayProtectionIsNotMandatory) {
Expand All @@ -310,7 +310,7 @@ class TestEnv {
// Replay protection is mandatory, so the transaction should fail
it('fails due to replay protection being mandatory', () => {
assert.isNull(minedTx, 'Transaction succeeded when it should have failed')
assert.equal(error!, noReplayProtectionError)
assert.equal(error, noReplayProtectionError)
})
}
} else {
Expand Down Expand Up @@ -375,7 +375,7 @@ class TestEnv {
const signed = await w3.eth.accounts.signTransaction(tx, validatorPrivateKey)
raw = signed.rawTransaction!
} else {
const signed = await kLocal.connection.wallet!.signTransaction(tx)
const signed = await kLocal.connection.wallet.signTransaction(tx)
raw = signed.raw
}
// Once the transaction is signed and encoded, it doesn't matter whether we send it with web3 or contractkit
Expand Down Expand Up @@ -406,8 +406,8 @@ class TestEnv {
it(`fails with the expected error (${testCase.errorReason})`, () => {
assert.notEqual(error, null, "Expected an error but didn't get one")
assert.match(
error!,
new RegExp(testCase.errorString!, 'i'),
error,
new RegExp(testCase.errorString, 'i'),
`Got "${error}", expected "${testCase.errorString}"`
)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/celotool/src/e2e-tests/replica_tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ describe('replica swap tests', () => {

await restart()

const proxyPubKey = privateKeyToPublicKey(gethConfig.instances[1].nodekey!)
const proxyPubKey = privateKeyToPublicKey(gethConfig.instances[1].nodekey)
const replica: GethInstanceConfig = {
name: 'validator0-replica0',
replica: true,
Expand All @@ -142,7 +142,7 @@ describe('replica swap tests', () => {
port: 30315,
rpcport: 8555,
privateKey: gethConfig.instances[0].privateKey,
minerValidator: privateKeyToAddress(gethConfig.instances[0].privateKey!),
minerValidator: privateKeyToAddress(gethConfig.instances[0].privateKey),
proxy: 'validator0-proxy0',
isProxied: true,
proxyport: 30304,
Expand Down
8 changes: 4 additions & 4 deletions packages/celotool/src/e2e-tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose
const proxyNodeKeys = getPrivateKeysFor(AccountType.PROXY, mnemonic, numProxies)
const proxyEnodes = proxyNodeKeys.map((x: string, i: number) => [
proxyInstances[i].name,
getEnodeAddress(privateKeyToPublicKey(x), '127.0.0.1', proxyInstances[i].proxyport!),
getEnodeAddress(privateKeyToPublicKey(x), '127.0.0.1', proxyInstances[i].proxyport),
getEnodeAddress(privateKeyToPublicKey(x), '127.0.0.1', proxyInstances[i].port),
])

Expand Down Expand Up @@ -298,7 +298,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose
}

if (!instance.minerValidator && (instance.validating || instance.isProxied)) {
instance.minerValidator = privateKeyToAddress(instance.privateKey!)
instance.minerValidator = privateKeyToAddress(instance.privateKey)
}
}

Expand All @@ -313,7 +313,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose
throw new Error('proxied validator must have exactly one proxy')
}

instance.proxiedValidatorAddress = privateKeyToAddress(proxiedValidator[0].privateKey!)
instance.proxiedValidatorAddress = privateKeyToAddress(proxiedValidator[0].privateKey)
}
}

Expand Down Expand Up @@ -389,7 +389,7 @@ export function getContext(gethConfig: GethRunConfig, verbose: boolean = verbose
}

if (!instance.minerValidator && (instance.validating || instance.isProxied)) {
instance.minerValidator = privateKeyToAddress(instance.privateKey!)
instance.minerValidator = privateKeyToAddress(instance.privateKey)
}

await startGeth(gethConfig, gethBinaryPath, instance, verbose)
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-utils/src/ganache-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const NetworkConfig = migrationOverride
export function jsonRpcCall<O>(web3: Web3, method: string, params: any[]): Promise<O> {
return new Promise<O>((resolve, reject) => {
if (web3.currentProvider && typeof web3.currentProvider !== 'string') {
web3.currentProvider.send!(
web3.currentProvider.send(
{
id: new Date().getTime(),
jsonrpc: '2.0',
Expand Down
2 changes: 1 addition & 1 deletion packages/dev-utils/src/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async function execCmd(cmd: string, args: string[], options?: SpawnOptions & { s
const process = spawn(cmd, args, { ...spawnOptions, stdio: silent ? 'ignore' : 'inherit' })
process.on('close', (code) => {
try {
resolve(code as number)
resolve(code)
} catch (error) {
reject(error)
}
Expand Down

0 comments on commit 767eeb1

Please sign in to comment.