Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove erc20claim typechain #1665

Merged
merged 4 commits into from
May 15, 2024

Conversation

adamgall
Copy link
Member

@adamgall adamgall commented May 7, 2024

Please review and merge #1664 first.

@adamgall adamgall self-assigned this May 7, 2024
Copy link

netlify bot commented May 7, 2024

Deploy Preview for fractal-dev ready!

Name Link
🔨 Latest commit 699148d
🔍 Latest deploy log https://app.netlify.com/sites/fractal-dev/deploys/6644d38ca72d990008f4cc5d
😎 Deploy Preview https://deploy-preview-1665.app.dev.fractalframework.xyz
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link
Contributor

@Da-Colon Da-Colon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@adamgall adamgall force-pushed the remove-LockRelease-typechain branch from 3b73b12 to 69cf3cf Compare May 7, 2024 23:28
@adamgall adamgall force-pushed the remove-erc20claim-typechain branch from 1c0f337 to ea82775 Compare May 7, 2024 23:28
@adamgall adamgall force-pushed the remove-LockRelease-typechain branch from 69cf3cf to c2491d5 Compare May 8, 2024 20:09
@adamgall adamgall force-pushed the remove-erc20claim-typechain branch from ea82775 to a61be02 Compare May 8, 2024 20:10
@adamgall adamgall force-pushed the remove-LockRelease-typechain branch from c2491d5 to e0c8802 Compare May 14, 2024 13:50
@adamgall adamgall force-pushed the remove-erc20claim-typechain branch from a61be02 to 8468002 Compare May 14, 2024 13:50
Base automatically changed from remove-LockRelease-typechain to root/remove-typechain May 15, 2024 09:49
Copy link
Contributor

@mudrila mudrila left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple minor comments/questions/rumbling, but generally looks good

return;
}
// action to governance
action.dispatch({
type: FractalGovernanceAction.SET_CLAIMING_CONTRACT,
payload: possibleTokenClaimContract,
payload: getAddress(approvals[0].args.spender),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getAddress(approvals[0].args.spender used twice - let's put that into variable

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, we don't need the getAddress wrap here anyway! approvals[0].args.spender is already Address type.

.queryFilter(tokenClaimFilter)
const possibleTokenClaimContract = getContract({
abi: ERC20ClaimAbi,
address: getAddress(approvals[0].args.spender),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here another usage

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same: can just remove that completely!

@@ -78,6 +80,7 @@ export class AzoriusTxBuilder extends BaseTxBuilder {
votesERC20MasterCopyAddress: string,
moduleProxyFactoryAddress: Address,
multiSendCallOnlyAddress: Address,
erc20ClaimMasterCopyAddress: Address,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I'm looking into this - the more I feel like we don't need this whole drilling and we can just create some helper function that will return these addresses for the given chain ID.
And then we just need to pass chainId down here. But yeah - not a point for this specific PR

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Totally agree. All of this code in these sets of PRs just incrementally transition from one way of doing things to another. After these PRs are complete, I'm going to do another set of "clean up" PRs to deal with refactoring and DRYing up all of the shit that was introduced as we switched from one system to another.

@@ -178,6 +181,7 @@ export class TxBuilderFactory extends BaseTxBuilder {
this.votesERC20MasterCopyAddress,
getAddress(this.moduleProxyFactoryAddress),
getAddress(this.multiSendCallOnlyAddress),
getAddress(this.erc20ClaimMasterCopyAddress),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like we kinda relying on getAddress to throw here and thus type-casting this.erc20ClaimMasterCopyAddress to Address.
I'd rather prefer more explicit approach -

if (!isAddress(this.erc20ClaimMasterCopyAddress)) { 
  throw new Error('Fuck you, some shit is not address, but we expect that to be. Go cry or smthng, we don't care');
}

But ideally we should be displaying proper error fallback to the user - so we should be catching the error before.
I also assume it might be the case that after bunch of PRs these addresses would actually arrive here as Address type validated - so feel free to ignore all this text if that's the intent and this is just temporary solution 😄

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, your assumption is correct. After all of these PRs are finished, the intention is that these addresses are typed correctly as Address at the source, and I'll be able to comb through the codebase removing all of these getAddress() calls.

So, leaving for now, with the understanding that this will be cleaned up later.

For your reference, I have a text doc with a list of shit I will need to go back and clean up after these PRs are finished. It currently is:

cleanup:
- buildContractCallViem
- contractCallViem
- all the getAddress usages
- TX Builder dependency injection wrangling
- standardize contract names in networkconfig

@adamgall adamgall marked this pull request as ready for review May 15, 2024 15:14
@adamgall adamgall force-pushed the remove-erc20claim-typechain branch from 8468002 to 699148d Compare May 15, 2024 15:23
@adamgall adamgall merged commit d14af79 into root/remove-typechain May 15, 2024
7 checks passed
@adamgall adamgall deleted the remove-erc20claim-typechain branch May 15, 2024 15:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants