-
Notifications
You must be signed in to change notification settings - Fork 0
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
Adding createDao() method #8
Conversation
4b5a369
to
9ed5e70
Compare
const daoName = `dao ${randomName}`; | ||
|
||
const someDao = await client.createDao( | ||
{ |
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 know it's draft but I don't want to forget this:
- It would be nice if the method
createDao
uses the connection inthis
(we pass it over in the constructor), so that we always use the same connection in every call. - Program ID could be a default value, same as the program version
- We can set the user wallet with a setter after the user connects their wallet or pass it in the constructor if we have it
- If we pass
userWallet
, we can inferuserWallet.publicKey
in the method
packages/solana-dao-sdk/src/index.ts
Outdated
@@ -23,12 +26,63 @@ export type Dao = { | |||
votingProposalCount: number; | |||
}; | |||
|
|||
export class TestWallet { |
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 definitely see this TestWallet
being reused in other test cases, should we move it to the test directory?
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.
also, is it implementing some other wallet interface? it would be good to annotate with "extends" or "implements" in that case
const tokenAmount = 1; | ||
|
||
export async function createMultisigRealm1( | ||
connection: Connection, |
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.
to avoid passing the connection, wallet, programId and program version everywhere, we could migrate the method createMultisigRealm
as a public method in an internal object/class like DAORepository
or DAOStorage
, or something that indicates input/output, and pass the parameters I mentioned in the constructor. Then createMint
, and all creations can be private methods in the same object.
); | ||
|
||
if (communityMint.signers.length > 0) { | ||
communityMintTx.partialSign(...communityMint.signers); |
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.
what does communityMint.signers
contain in this context? just wallet.publicKey
or some new public keys?
feePayer: wallet.publicKey, | ||
}); | ||
|
||
const councilsMintTx = new Transaction({ |
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.
to improve readibility, lets move this down to line ~92 right before we need it
walletPk | ||
); | ||
|
||
// transaction signatures here for now |
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.
to improve readability, let's move this comment to line 102, right where it's relevant
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.
Also, do you have any thoughts about what could be a better place for the signatures? If yes, I'd transform this comment either in a ticket or a TODO saying what to do. If not, I'd just remove the comment as we won't do anything with it in the near future and for now
will be forever
:D
|
||
// signature.toString('base64') | ||
|
||
const recentBlockhash1 = await connection.getLatestBlockhash(); |
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.
why another blockchash? could we not use just one?
} else { | ||
// Let's throw for now if the current wallet isn't in the team | ||
// TODO: To fix it we would have to make it temp. as part of the team and then remove after the realm is created | ||
throw new Error("Current wallet must be in the team"); |
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 what happens if we reach this line? I'm guessing the DAO is partially created as we already signed and sent a few transactions, but others below this line were never executed.
Is it possible for us to fail fast? i.e. do this check before even signing a transaction
|
||
realmInstructions.forEach((instruction) => realmRelatedTx.add(instruction)); | ||
|
||
const signedTxs3 = await wallet.signAllTransactions([realmRelatedTx]); |
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.
have you tried signing and sending all transactions at the same time? i.e. generating all the instructions first and then packing them all (in the right order) in the same transaction
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 some reason I'm still having issues with that. If I cannot fix it quite fast, I'll do it in a following PR
packages/solana-dao-sdk/src/internal/sdk/splToken/withCreateAssociatedTokenAccount.ts
Outdated
Show resolved
Hide resolved
this could be simplified to
as the connection is in the client already ( Even further:
|
f6e2bc2
to
01b6529
Compare
This is ready for another review. @arielsegura |
## Moving to react-app-rewired | ||
|
||
Due to a couple of issues we started using create-app-rewired. | ||
This is because CRA doesn't handle .cjs files and inside the spl-governance dependecy tree we have a few of them when compiled. |
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 is because CRA doesn't handle .cjs files and inside the spl-governance dependecy tree we have a few of them when compiled. | |
This is because CRA doesn't handle .cjs files and inside the spl-governance dependency tree we have a few of them when compiled. |
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.
It looks really really good, good job!
I left some non blocking comments (nit) that we can discuss later or fix in other PRs, some other comments would be nice to address them now, but we can also discuss that :D
🎉
return ( | ||
<DaoContext.Provider value={new SolanaDao()}> | ||
<DaoContext.Provider value={new SolanaDao(devnetConnection)}> |
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.
if you are changing this because of the too many requests problem, devnet can have the same problem. I think it would be good to use mainnet by default, even on the example. Devnet is usually very unstable.
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 rendering DAOs yeah, we could use prod, yes. But now that we have the createDao() would you want to spend real SOL for trying out things?
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.
Also, we can have a query parameter like most products do to indicate which network tu use
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 rendering DAOs yeah, we could use prod, yes. But now that we have the createDao() would you want to spend real SOL for trying out things?
ideally, we should integrate with a wallet that would enable the user to make this decision. I'm suggesting mainnet-beta because the first interaction that "testers" will have is reading, not writing. If this first interaction fails (because devnet is unstable), I really doubt they will try writing
|
||
export const governanceProgramVersion = 2; | ||
export const governancePk = new PublicKey( | ||
"GovER5Lthms3bLBqWub97yVrMmEogzX7xNjdXpPPCVZw" |
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 governancePk
is the same as the constant in index.ts
. Let's have it in only one place
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 is only one now 🤔
); | ||
|
||
// So we can check on the Explorer how it looks. |
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.
nit: what exactly do you look for in the explorer? I wonder if we can call getDao
to make a few assertions instead?
Description
Adding the createDao() method.
Basically, doing the same steps that are done across several repositories in one place.
In Nation, Oyster UI, Governance UI, Marinade and probably other places there are lots of duplicated code in order to create a simple MultiSig wallet.
With this PR, any project should be able to do just:
Also:
Things still to do: