Conversation
# Conflicts: # cadence/contracts/connectors/evm/UniswapV3SwapConnectors.cdc # cadence/tests/UniswapV3SwapConnectors_test.cdc
# Conflicts: # cadence/contracts/connectors/evm/UniswapV3SwapConnectors.cdc
| let full = wordToUInt(w) | ||
| if nBits >= 256 { return full } | ||
| let mask: UInt = (UInt(1) << UInt(nBits)) - UInt(1) | ||
| let mask = (1 as UInt << UInt(nBits)) - 1 |
There was a problem hiding this comment.
Wonder if it would make sense to make the nBits parameter UInt type, instead of Int. I don't really know where this wordToUIntN is used, so might depends on the use-cases.
If we could do that, then it's possible to just keep the type-annotation for the mask variable (LHS), and remove all the castings/conversions from the RHS of the assignment. e.g:
| let mask = (1 as UInt << UInt(nBits)) - 1 | |
| let mask: UInt = (1 << nBits) - 1 |
There was a problem hiding this comment.
Wonder if it would make sense to make the nBits parameter UInt type, instead of Int. I don't really know where this wordToUIntN is used, so might depends on the use-cases.
this code is inside the fun:
fun wordToUIntN(_ w: [UInt8], _ nBits: Int): UInt {
let full = wordToUInt(w)
if nBits >= 256 { return full }
let mask: UInt = (1 << UInt(nBits)) - 1
return full & mask
}
so it should return UInt
There was a problem hiding this comment.
Changing the parameter nBits: Int to nBits: UInt wouldn't impact the return type. It seems all call-sites to this function pass a number-literal (e.g: wordToUIntN(s0w[0], 160) and wordToUIntN(words(liqRes!.data)[0], 128)), so that change would be compatible with the call-sites too.
turbolent
left a comment
There was a problem hiding this comment.
Nice! Thanks for cleaning this up
cadence/contracts/connectors/evm/morpho/MorphoERC4626SinkConnectors.cdc
Outdated
Show resolved
Hide resolved
| @@ -15,7 +15,7 @@ transaction(victimAddress: Address, victimPublicPath: PublicPath, attackerStorag | |||
| self.victimConfig = victimAB.getRecurringConfig() ?? panic("Victim AutoBalancer does not have a recurring config") | |||
|
|
|||
| // get attacker's AutoBalancer | |||
| self.attackerAB = signer.storage.borrow<&DeFiActions.AutoBalancer>(from: attackerStoragePath) | |||
| self.attackerAB = signer.storage.borrow<auth(DeFiActions.Configure) &DeFiActions.AutoBalancer>(from: attackerStoragePath) | |||
There was a problem hiding this comment.
Why where the authorizations added here? These changes don't seem to be related to fixing linting errors, so maybe propose them in a separate PR
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.autoBalancer = signer.storage.borrow<auth(DeFiActions.Schedule) &DeFiActions.AutoBalancer>(from: storagePath) | ||
| self.autoBalancer = signer.storage.borrow<auth(DeFiActions.Configure) &DeFiActions.AutoBalancer>(from: storagePath) | ||
| ?? panic("AutoBalancer was not found in signer's storage at \(storagePath)") |
There was a problem hiding this comment.
Same here: Maybe propose these changes unrelated to fixing linter warnings in a separate PR
| let autoBalancer: auth(DeFiActions.Schedule) &DeFiActions.AutoBalancer | ||
|
|
||
| prepare(signer: auth(BorrowValue) &Account) { | ||
| self.autoBalancer = signer.storage.borrow<auth(DeFiActions.Auto) &DeFiActions.AutoBalancer>(from: storagePath) | ||
| self.autoBalancer = signer.storage.borrow<auth(DeFiActions.Schedule) &DeFiActions.AutoBalancer>(from: storagePath) |
There was a problem hiding this comment.
Same here: Maybe propose these changes unrelated to fixing linter warnings in a separate PR
flow cadence lint.Update: problem bellow was solved in onflow/cadence-tools#586 .
But some problems were left unresolved due to a bug with the linter:
Also, it's impossible to use a long string template across multiple lines, so in order to prevent long lines, it should be written like this:
But the linter suggests:
string concatenation can be replaced with string template