Skip to content

Commit d870079

Browse files
committed
Deploy updated autocrat
1 parent 05424c4 commit d870079

8 files changed

Lines changed: 91 additions & 96 deletions

File tree

Anchor.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ seeds = false
55
skip-lint = false
66

77
[programs.localnet]
8-
autocrat_migrator = "8C4WEdr54tBPdtmeTPUBuZX5bgUMZw4XdvpNoNaQ6NwR"
9-
autocrat_v0 = "meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi"
8+
autocrat_migrator = "migkwAXrXFN34voCYQUhFQBXZJjHrWnpEXbSGTqZdB3"
9+
autocrat_v0 = "metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq"
1010
conditional_vault = "vaU1tVLj8RFk7mNj1BxqgAsMKKaL8UvEUHvU3tdbZPe"
1111

1212
[registry]

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ and what they do can be found at [themetadao.org](https://themetadao.org).
99

1010
| program | tag | program ID |
1111
| ----------------- | --- | ------------------------------------------- |
12+
| autocrat_v0 | v0.1| metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq |
13+
| autocrat_migrator | v0.1| migkwAXrXFN34voCYQUhFQBXZJjHrWnpEXbSGTqZdB3 |
1214
| autocrat_v0 | v0 | meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi |
1315
| conditional_vault | v0 | vaU1tVLj8RFk7mNj1BxqgAsMKKaL8UvEUHvU3tdbZPe |
1416

justfile

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,14 @@ build-verifiable PROGRAM_NAME:
66
solana-verify build --library-name {{ PROGRAM_NAME }} -b ellipsislabs/solana:1.16.10
77

88
deploy PROGRAM_NAME CLUSTER:
9-
solana program deploy -u {{ CLUSTER }} --program-id ./target/deploy/{{ PROGRAM_NAME }}-keypair.json ./target/deploy/{{ PROGRAM_NAME }}.so --final
9+
solana program deploy -u {{ CLUSTER }} --program-id ./target/deploy/{{ PROGRAM_NAME }}-keypair.json ./target/deploy/{{ PROGRAM_NAME }}.so --final && PROGRAM_ID=$(solana-keygen pubkey ./target/deploy/{{ PROGRAM_NAME }}-keypair.json) && anchor idl init --filepath ./target/idl/{{ PROGRAM_NAME }}.json $PROGRAM_ID --provider.cluster {{ CLUSTER }}
1010

1111
upgrade PROGRAM_NAME PROGRAM_ID CLUSTER:
1212
anchor upgrade ./target/deploy/{{ PROGRAM_NAME }}.so -p {{ PROGRAM_ID }} --provider.cluster {{ CLUSTER }}
1313

1414
upgrade-idl PROGRAM_NAME PROGRAM_ID CLUSTER:
1515
anchor idl upgrade --filepath ./target/idl/{{ PROGRAM_NAME }}.json {{ PROGRAM_ID }} --provider.cluster {{ CLUSTER }}
1616

17-
1817
bankrun:
1918
(find programs && find tests) | entr -csr 'anchor build -p autocrat_v0 && RUST_LOG= yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/autocratV0.ts'
2019

programs/autocrat_migrator/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use anchor_lang::prelude::*;
55
use anchor_spl::token::{transfer, Token, TokenAccount, Transfer};
66
use anchor_lang::solana_program;
77

8-
declare_id!("miqe4jQYw11JE9o5AbZGYXm1dsWYbCoiGqZSqkYK5sV");
8+
declare_id!("migkwAXrXFN34voCYQUhFQBXZJjHrWnpEXbSGTqZdB3");
99

1010
#[program]
1111
pub mod autocrat_migrator {

programs/autocrat_v0/src/lib.rs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ security_txt! {
2424
acknowledgements: "DCF = (CF1 / (1 + r)^1) + (CF2 / (1 + r)^2) + ... (CFn / (1 + r)^n)"
2525
}
2626

27-
declare_id!("meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi");
27+
declare_id!("metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq");
2828

2929
pub const SLOTS_PER_10_SECS: u64 = 25;
3030
pub const THREE_DAYS_IN_SLOTS: u64 = 5 * 24 * 60 * 6 * SLOTS_PER_10_SECS;
@@ -422,13 +422,6 @@ pub mod autocrat_v0 {
422422

423423
Ok(())
424424
}
425-
426-
pub fn transfer_to(ctx: Context<TransferTo>, lamports: u64) -> Result<()> {
427-
**ctx.accounts.dao_treasury.to_account_info().try_borrow_mut_lamports()? -= lamports;
428-
**ctx.accounts.lamport_receiver.to_account_info().try_borrow_mut_lamports()? += lamports;
429-
430-
Ok(())
431-
}
432425
}
433426

434427
#[derive(Accounts)]
@@ -535,15 +528,6 @@ pub struct UpdateDao<'info> {
535528
pub dao_treasury: Signer<'info>,
536529
}
537530

538-
#[derive(Accounts)]
539-
pub struct TransferTo<'info> {
540-
#[account(mut)]
541-
pub dao_treasury: Signer<'info>,
542-
/// CHECK: no r/w, just lamport add
543-
#[account(mut)]
544-
pub lamport_receiver: UncheckedAccount<'info>,
545-
}
546-
547531
impl From<&ProposalInstruction> for Instruction {
548532
fn from(ix: &ProposalInstruction) -> Self {
549533
Self {

scripts/main.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const AutocratIDL: AutocratV0 = require("../target/idl/autocrat_v0.json");
2424
const OpenbookTwapIDL: OpenbookTwap = require("../tests/fixtures/openbook_twap.json");
2525

2626
const AUTOCRAT_PROGRAM_ID = new PublicKey(
27-
"meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi"
27+
"metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq"
2828
);
2929
const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey(
3030
"vaU1tVLj8RFk7mNj1BxqgAsMKKaL8UvEUHvU3tdbZPe"

tests/autocratV0.ts

Lines changed: 82 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ import { open } from "fs";
6868

6969
// this test file isn't 'clean' or DRY or whatever; sorry!
7070
const AUTOCRAT_PROGRAM_ID = new PublicKey(
71-
"meta3cxKzFBmWYgCVozmvCQAS3y9b3fGxrG9HkHL7Wi"
71+
"metaX99LHn3A7Gr7VAcCfXhpfocvpMpqQ3eyp3PGUUq"
7272
);
7373

7474
const CONDITIONAL_VAULT_PROGRAM_ID = new PublicKey(
@@ -84,7 +84,7 @@ const OPENBOOK_PROGRAM_ID = new PublicKey(
8484
);
8585

8686
const AUTOCRAT_MIGRATOR_PROGRAM_ID = new PublicKey(
87-
"8C4WEdr54tBPdtmeTPUBuZX5bgUMZw4XdvpNoNaQ6NwR"
87+
"migkwAXrXFN34voCYQUhFQBXZJjHrWnpEXbSGTqZdB3"
8888
);
8989

9090
describe("autocrat_v0", async function () {
@@ -295,69 +295,83 @@ describe("autocrat_v0", async function () {
295295

296296
beforeEach(async function () {
297297
// just uncomment this and replace with another instruction that you wish to test
298-
const accounts = [
299-
{
300-
pubkey: dao,
301-
isSigner: false,
302-
isWritable: true,
303-
},
304-
{
305-
pubkey: daoTreasury,
306-
isSigner: true,
307-
isWritable: false,
308-
},
309-
];
310-
newPassThresholdBps = Math.floor(Math.random() * 1000);
311-
const data = autocrat.coder.instruction.encode("update_dao", {
312-
daoParams: {
313-
passThresholdBps: newPassThresholdBps,
314-
baseBurnLamports: null,
315-
burnDecayPerSlotLamports: null,
316-
slotsPerProposal: null,
317-
marketTakerFee: null,
318-
twapExpectedValue: null,
319-
}
320-
});
321-
instruction = {
322-
programId: autocrat.programId,
323-
accounts,
324-
data,
325-
};
326-
327-
// await mintToOverride(context, treasuryMetaAccount, 1_000_000_000n);
328-
// await mintToOverride(context, treasuryUsdcAccount, 1_000_000n);
329-
330-
// let receiver = Keypair.generate();
331-
// let to0 = await createAccount(
332-
// banksClient,
333-
// payer,
334-
// META,
335-
// receiver.publicKey
336-
// );
337-
// let to1 = await createAccount(
338-
// banksClient,
339-
// payer,
340-
// USDC,
341-
// receiver.publicKey
342-
// );
343-
344-
// const ix = await migrator.methods
345-
// .multiTransfer2()
346-
// .accounts({
347-
// authority: daoTreasury,
348-
// from0: treasuryMetaAccount,
349-
// to0,
350-
// from1: treasuryUsdcAccount,
351-
// to1,
352-
// })
353-
// .instruction();
354-
298+
// const accounts = [
299+
// {
300+
// pubkey: dao,
301+
// isSigner: false,
302+
// isWritable: true,
303+
// },
304+
// {
305+
// pubkey: daoTreasury,
306+
// isSigner: true,
307+
// isWritable: false,
308+
// },
309+
// ];
310+
// newPassThresholdBps = Math.floor(Math.random() * 1000);
311+
// const data = autocrat.coder.instruction.encode("update_dao", {
312+
// daoParams: {
313+
// passThresholdBps: newPassThresholdBps,
314+
// baseBurnLamports: null,
315+
// burnDecayPerSlotLamports: null,
316+
// slotsPerProposal: null,
317+
// marketTakerFee: null,
318+
// twapExpectedValue: null,
319+
// }
320+
// });
321+
// instruction = {
322+
// programId: autocrat.programId,
323+
// accounts,
324+
// data,
325+
// };
326+
// let lamportReceiver = Keypair.generate();
327+
328+
// let ix = anchor.web3.SystemProgram.transfer({
329+
// fromPubkey: daoTreasury,
330+
// toPubkey: lamportReceiver.publicKey,
331+
// lamports: 1_000_000,
332+
// });
333+
355334
// instruction = {
356335
// programId: ix.programId,
357336
// accounts: ix.keys,
358337
// data: ix.data,
359338
// };
360339

340+
await mintToOverride(context, treasuryMetaAccount, 1_000_000_000n);
341+
await mintToOverride(context, treasuryUsdcAccount, 1_000_000n);
342+
343+
let receiver = Keypair.generate();
344+
let to0 = await createAccount(
345+
banksClient,
346+
payer,
347+
META,
348+
receiver.publicKey
349+
);
350+
let to1 = await createAccount(
351+
banksClient,
352+
payer,
353+
USDC,
354+
receiver.publicKey
355+
);
356+
357+
const ix = await migrator.methods
358+
.multiTransfer2()
359+
.accounts({
360+
authority: daoTreasury,
361+
from0: treasuryMetaAccount,
362+
to0,
363+
from1: treasuryUsdcAccount,
364+
to1,
365+
lamportReceiver: receiver.publicKey,
366+
})
367+
.instruction();
368+
369+
instruction = {
370+
programId: ix.programId,
371+
accounts: ix.keys,
372+
data: ix.data,
373+
};
374+
361375
proposal = await initializeProposal(
362376
autocrat,
363377
instruction,
@@ -411,6 +425,11 @@ describe("autocrat_v0", async function () {
411425
lamports: 1_000_000_000n,
412426
toPubkey: alice.publicKey,
413427
}),
428+
anchor.web3.SystemProgram.transfer({
429+
fromPubkey: payer.publicKey,
430+
lamports: 1_000_000_000n,
431+
toPubkey: daoTreasury,
432+
}),
414433
];
415434
let tx = new anchor.web3.Transaction().add(...ixs);
416435
[tx.recentBlockhash] = await banksClient.getLatestBlockhash();
@@ -790,16 +809,6 @@ describe("autocrat_v0", async function () {
790809
daoTreasury,
791810
})
792811
.remainingAccounts(
793-
// autocrat.instruction.setPassThresholdBps
794-
// .accounts({
795-
// dao,
796-
// daoTreasury,
797-
// })
798-
// .concat({
799-
// pubkey: autocrat.programId,
800-
// isWritable: false,
801-
// isSigner: false,
802-
// })
803812
instruction.accounts
804813
.concat({
805814
pubkey: instruction.programId,
@@ -812,7 +821,6 @@ describe("autocrat_v0", async function () {
812821
: meta
813822
)
814823
)
815-
// .transaction();
816824
.rpc();
817825

818826
let storedBaseVault = await vaultProgram.account.conditionalVault.fetch(
@@ -831,8 +839,10 @@ describe("autocrat_v0", async function () {
831839
assert((await getAccount(banksClient, treasuryMetaAccount)).amount == 0n);
832840
assert((await getAccount(banksClient, treasuryUsdcAccount)).amount == 0n);
833841

834-
const storedDao = await autocrat.account.dao.fetch(dao);
835-
assert.equal(storedDao.passThresholdBps, newPassThresholdBps);
842+
// console.log(await banksClient.getAccount(daoTreasury));
843+
844+
// const storedDao = await autocrat.account.dao.fetch(dao);
845+
// assert.equal(storedDao.passThresholdBps, newPassThresholdBps);
836846

837847
await redeemConditionalTokens(
838848
vaultProgram,

tests/migrator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import { assert } from "chai";
1010
import { startAnchor } from "solana-bankrun";
1111

1212
const AUTOCRAT_MIGRATOR_PROGRAM_ID = new PublicKey(
13-
"miqe4jQYw11JE9o5AbZGYXm1dsWYbCoiGqZSqkYK5sV"
13+
"migkwAXrXFN34voCYQUhFQBXZJjHrWnpEXbSGTqZdB3"
1414
);
1515

1616
import { AutocratMigrator } from "../target/types/autocrat_migrator";

0 commit comments

Comments
 (0)