import * as anchor from "@coral-xyz/anchor";
import { Program } from "@coral-xyz/anchor";
import { TsumoriCredibleAccountPoc } from "../target/types/tsumori_credible_account_poc";
import { generateFundedKeypair } from "./util";
const SQUADS_PROGRAM_ID = new anchor.web3.PublicKey(
"SQDS4ep65T869zMMBKyuUq6aD6EgTu8psMjkvj52pCf"
);
function toUtfBytes(str: string): Uint8Array {
return new TextEncoder().encode(str);
}
const SEED_PREFIX = toUtfBytes("multisig");
const SEED_MULTISIG = toUtfBytes("multisig");
const SEED_PROGRAM_CONFIG = toUtfBytes("program_config");
const getProgramConfigPda = () => {
return anchor.web3.PublicKey.findProgramAddressSync(
[SEED_PREFIX, SEED_PROGRAM_CONFIG],
SQUADS_PROGRAM_ID
);
};
const getMultisigPDA = (createKey: anchor.web3.PublicKey) => {
return anchor.web3.PublicKey.findProgramAddressSync(
[SEED_PREFIX, SEED_MULTISIG, createKey.toBytes()],
SQUADS_PROGRAM_ID
);
};
describe("tsumori-credible-account-poc", () => {
const createKey = anchor.web3.Keypair.generate();
const [multisigPda] = getMultisigPDA(createKey.publicKey);
const [programConfig] = getProgramConfigPda();
anchor.setProvider(anchor.AnchorProvider.env());
const program = anchor.workspace
.TsumoriCredibleAccountPoc as Program<TsumoriCredibleAccountPoc>;
it("create multisig", async () => {
const creator = await generateFundedKeypair(
anchor.getProvider().connection
);
const wallet = new anchor.Wallet(creator);
const tx = await program.methods
.createMultisig()
.accounts({
signer: creator.publicKey,
createKey: createKey.publicKey,
multisig: multisigPda,
systemProgram: anchor.web3.SystemProgram.programId,
programConfig,
sqaudsProgramTreasury: anchor.web3.SystemProgram.programId,
squadsMultisigProgram: SQUADS_PROGRAM_ID,
})
.signers([wallet.payer, createKey])
.rpc();
console.log("Your transaction signature", tx);
});
});
I get this error:
AnchorError caused by account: multisig. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.