-
Notifications
You must be signed in to change notification settings - Fork 7
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 azorius typechain #1671
Remove azorius typechain #1671
Conversation
✅ Deploy Preview for fractal-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
abd45a7
to
81f64b9
Compare
40f67e7
to
8806167
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔥
81f64b9
to
f8f3761
Compare
8806167
to
77fbc09
Compare
f8f3761
to
558837e
Compare
77fbc09
to
05f97e2
Compare
558837e
to
61cf1c2
Compare
05f97e2
to
175f1ef
Compare
61cf1c2
to
713fa33
Compare
175f1ef
to
25dcfd5
Compare
713fa33
to
4196474
Compare
25dcfd5
to
88d1a1f
Compare
4196474
to
e292d84
Compare
88d1a1f
to
44286f6
Compare
e292d84
to
f93caf5
Compare
44286f6
to
bcc20e3
Compare
f93caf5
to
8d04e30
Compare
bcc20e3
to
97594c2
Compare
8d04e30
to
6810626
Compare
97594c2
to
8a5e7f1
Compare
8a5e7f1
to
00fd68f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lots of comments, but should be good to go afterwards
@@ -62,7 +62,7 @@ export function useProposalCountdown(proposal: FractalProposal) { | |||
(async () => { | |||
try { | |||
if (dao?.isAzorius) { | |||
await updateProposalState(BigInt(proposal.proposalId)); | |||
await updateProposalState(Number(proposal.proposalId)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we even need casting here? Why can't we just pass number?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
proposal.proposalId
is a string
type here
log.args.proposer, | ||
azoriusContract, | ||
provider, | ||
Promise.resolve(undefined), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't really like this. Can we adjust mapper so that it's not expecting always promise?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should adjust mapper to expect array instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
proposalCreatedEvent.args.proposalId.toBigInt(), | ||
proposalCreatedEvent.args.proposer, | ||
Number(proposalCreatedEvent.args.proposalId), | ||
proposalCreatedEvent.args.proposer || '', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This feels wrong - proposer can't be empty string I think as it comes from message sender
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed. For some reason which I haven't figured out yet, the viem arg properties on events all are optionally undefined, even if the solidity ABI indicates that they will definitely be there. Regardless, I've updated the code here to just early exity if (for some very unlikely reason in practice) the proposer is undefined.
// @dev assumes the first strategy is the voting contract | ||
const votingContractAddress = ( | ||
await azoriusContract.getStrategies(SENTINEL_ADDRESS, 0) | ||
await azoriusContract.read.getStrategies([SENTINEL_ADDRESS, 0n]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mudrila ?
@@ -16,6 +16,7 @@ export function useMasterCopy() { | |||
linearVotingMasterCopy, | |||
linearVotingERC721MasterCopy, | |||
fractalModuleMasterCopy, | |||
fractalAzoriusMasterCopy, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rename to azoriusMasterCopy
pls
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will later sir not here though
masterCopyAddress === baseContracts?.fractalAzoriusMasterCopyContract.asProvider.address, | ||
[baseContracts], | ||
(masterCopyAddress: Address) => masterCopyAddress === fractalAzoriusMasterCopy, | ||
[fractalAzoriusMasterCopy], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i will but not in this PR sir
this.predictedAzoriusAddress!, | ||
this.signerOrProvider, | ||
); | ||
this.azoriusAddress = this.predictedAzoriusAddress; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't we just use this.predictedAzoriusAddress
instead of adding this.azoriusAddress
field?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes we can!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
well actually, i don't know if that's safe to do. this.azoriusAddress
comes from some inherited class, it might be being used in other files. i'm going to leave as is until i get a chance to refactor this whole transaction builder process, if that ever becomes a priority.
moduleContract: | ||
| Azorius | ||
| GetContractReturnType<typeof FractalModuleAbi, PublicClient> | ||
| undefined; | ||
moduleAddress: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Guess we can simplify those fields to just address
and type
, but not a big deal to keep them as is
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you mean the field names?
rename moduleAddress
to address
rename moduleType
to type
?
00fd68f
to
f99de9c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bunch of more changes requested, but we're almost there sir
await azoriusContract.read.getStrategies([SENTINEL_ADDRESS, 0n]) | ||
)[1]; | ||
|
||
const masterCopyData = await getZodiacModuleProxyMasterCopyData( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So instead of doing
const masterCopyData = await getZodiacModuleProxyMasterCopyData(
getAddress(votingStrategyAddress),
);
const isOzLinearVoting = masterCopyData.isOzLinearVoting;
const isOzLinearVotingERC721 = masterCopyData.isOzLinearVotingERC721;
We can do
const { isOzLinearVoting, isOzLinearVotingERC721 } = await getZodiacModuleProxyMasterCopyData(
getAddress(votingStrategyAddress),
);
@@ -20,105 +19,106 @@ export const useGovernanceContracts = () => { | |||
const { getZodiacModuleProxyMasterCopyData } = useMasterCopy(); | |||
const publicClient = usePublicClient(); | |||
|
|||
const votingStrategyAddress = useVotingStrategyAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's what I'm talking about, so much red
Let it burn baby 🔥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This voting strategy address should really be part of state though, huh
const { data: walletClient } = useWalletClient(); | ||
const publicClient = usePublicClient(); | ||
|
||
const votingContractAddress = useVotingStrategyAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Optional - you can rename this to votingStrategyAddress
and then use prop shorthand. Also hook is called useVotingStrategyAddress
so I'd expect rather votingStrategyAddress
variable name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I left this as votingContractAddress
is because votingStrategyAddress
is already being used as a variable name elsewhere in this file, and I get yelled at about same name on different scopes. I'll change this to votingStrategyContractAddress
to meet in the middle.
azoriusContract: azoriusModule.moduleContract as Azorius, | ||
votingStrategyAddress, | ||
azoriusAddress: getAddress(azoriusModule.moduleAddress), | ||
votingStrategyAddress: votingContractAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So if you'd rename votingContractAddress
- you will be able to use prop shorthand and instead of votingStrategyAddress: votingContractAddress,
it will be just votingStrategyAddress,
const safeAPI = useSafeAPI(); | ||
const publicClient = usePublicClient(); | ||
|
||
const votingContractAddress = useVotingStrategyAddress(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again - why naming it votingContractAddress
and not votingStrategyAddress
? Feel like that's a bit confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For this one, it was a clean rename 👍
const safeModules = await lookupModules(safeInfo.modules); | ||
const azoriusModule = getAzoriusModuleFromModules(safeModules); | ||
|
||
if (azoriusModule && azoriusModule.moduleContract) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think here we still wanna figure this out "on fly" so we probably will need to transform that hook so that we can get votingContractAddress
for any safe by address, and not just the one from "global context"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is used to figure out whether you can create subSafe, execute clawback and child safes from the "Organization" page, as far as I remember it right 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, exactly the kind of feedback I was hoping for. Thanks for your suggestions on how to clean up the hook I created to support this usecase
const { node } = useFractal(); | ||
const publicClient = usePublicClient(); | ||
|
||
useEffect(() => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using useEffect
and useState
- I'd suggest transforming this into a function, that will be called "on demand" - this will preserve existing functionality
So then it will be something like
const useVotingStrategyAddress = () => {
const getVotingStrategyAddress = useCallback((safeAddress?: Address) => {
... blah blah all the logic of getting strategy address depending on whether safe address is provided.
If it is - we're getting data for specific safe using safeAPI, otherwise - we're falling back to global context blah blah ...
},
[publicClient, node, whateverElseGoesInDependencies]
);
return { getVotingStrategyAddress }
}
Most crucial part here is to have this helper function, but you can keep useEffect
and useState
as well if you wanna avoid calling getVotingStrategyAddress
when it's not necessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok ok i got u
@mudrila addressed your changes, plz review again! |
7fd770c
to
984dc15
Compare
984dc15
to
db4b339
Compare
✅ Deploy Preview for decent-interface-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing 2 linting warnings about zeroAddress is defined but never used
Apart of this and 2 other minor comments - looks good to go, so leaving my approval
@@ -89,7 +79,7 @@ export function useCanUserCreateProposal() { | |||
}, | |||
[ | |||
erc721LinearVotingContractAddress, | |||
lookupModules, | |||
getVotingStrategyAddress, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're putting it into dependencies array but not wrapping the function itself into useCallback
- this might cause performance issues, barely noticeable I think but might lead to minor problems on "Organizations" page. I'd suggest wrapping getVotingStrategyAddress
into useCallback
@mudrila fixed both of your latest comments and pushed |
Please review and merge #1670 first.