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

check for Proposal status is broken #17

Open
nazreen opened this issue Dec 18, 2024 · 1 comment · May be fixed by #18
Open

check for Proposal status is broken #17

nazreen opened this issue Dec 18, 2024 · 1 comment · May be fixed by #18

Comments

@nazreen
Copy link

nazreen commented Dec 18, 2024

This is for devnet. To reproduce, use the SDK to call multisig.rpc.vaultTransactionCreate

Then, on the UI, attempt to click Approve. Wallet will show a warning saying the transaction will fail.
Proceed anyway, and view the resulting error. It will state in the logs:

> Program log: Instruction: ProposalApprove
> Program log: AnchorError caused by account: proposal. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.
> Program[ Squads Program ID V4 ](https://solscan.io/account/SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf?cluster=devnet)consumed 5109 of 199700 compute units
> Program returned error: custom program error: 0xbc4

So it seems that clicking Approve for a transaction whose Proposal Account has not yet been created does not trigger a Proposal Create instruction as it should be.

While code exists that should prevent this, it seems to not be working as expected.

@nazreen
Copy link
Author

nazreen commented Dec 18, 2024

proposalStatus is the value used by the ApproveButton component to decide whether to include a ProposalCreate transaction or not

if (proposalStatus === "None") {
const createProposalInstruction = multisig.instructions.proposalCreate({
multisigPda: new PublicKey(multisigPda),
creator: wallet.publicKey,
isDraft: false,
transactionIndex: bigIntTransactionIndex,
rentPayer: wallet.publicKey,
programId: programId ? new PublicKey(programId) : multisig.PROGRAM_ID,
});
transaction.add(createProposalInstruction);
}
if (proposalStatus == "Draft") {
const activateProposalInstruction =
multisig.instructions.proposalActivate({
multisigPda: new PublicKey(multisigPda),
member: wallet.publicKey,
transactionIndex: bigIntTransactionIndex,
programId: programId ? new PublicKey(programId) : multisig.PROGRAM_ID,
});
transaction.add(activateProposalInstruction);
}

The value for proposalStatus is evaluated in

{transaction.proposal?.status.__kind || "Active"} (this evaluation is problematic as it assumes that if .status__kind does not exist on the proposal object, then it's status is "Active")

When we log the transactions array in the component, they have the following structure:

[
  {
    transactionPda: '3GYiwuKUMJ3bUTxoRW3LdvZfs45JDHATNuSDZsbYa',
    proposal: _Proposal {
      multisig: [PublicKey [PublicKey(59jdDuB6khBf9nwwyJfwGXPEF2mxTMbQusNXGAXjff)]],
      transactionIndex: <BN: 2>,
      status: { __kind: 'Executed', timestamp: <BN: 676047b6> },
      bump: 254,
      approved: [Array],
      rejected: [],
      cancelled: []
    },
    index: 2n
  },
  {
    transactionPda: 'HcbW1nfebCAspzGQyrsDALkntECQHuRGxnVDQAcNqN',
    proposal: null,
    index: 1n
  }]

As you can see, when the Proposal Account does not yet exist, it will be evaluated to Active, which obviously is incorrect.

The fix is to update the line that evaluates the status from

{transaction.proposal?.status.__kind || "Active"}

to

{transaction.proposal?.status.__kind || "None"}

@nazreen nazreen linked a pull request Dec 18, 2024 that will close this issue
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 a pull request may close this issue.

1 participant