Skip to content

Commit

Permalink
Rename methods to better match the Terra equivalents
Browse files Browse the repository at this point in the history
  • Loading branch information
archseer committed Feb 11, 2022
1 parent 1ebf355 commit 997a8b2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
2 changes: 1 addition & 1 deletion contracts/programs/ocr2/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub struct CloseProposal<'info> {
}

#[derive(Accounts)]
pub struct SetConfig<'info> {
pub struct ProposeConfig<'info> {
#[account(mut)]
pub proposal: AccountLoader<'info, Proposal>,
pub authority: Signer<'info>,
Expand Down
22 changes: 11 additions & 11 deletions contracts/programs/ocr2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ pub mod ocr2 {
Ok(())
}

pub fn create_config_proposal(
pub fn create_proposal(
ctx: Context<CreateProposal>,
offchain_config_version: u64,
) -> ProgramResult {
Expand All @@ -99,7 +99,7 @@ pub mod ocr2 {

#[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))]
pub fn write_offchain_config(
ctx: Context<SetConfig>,
ctx: Context<ProposeConfig>,
offchain_config: Vec<u8>,
) -> ProgramResult {
let mut proposal = ctx.accounts.proposal.load_mut()?;
Expand All @@ -114,7 +114,7 @@ pub mod ocr2 {
}

#[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))]
pub fn commit_config_proposal(ctx: Context<SetConfig>) -> ProgramResult {
pub fn finalize_proposal(ctx: Context<ProposeConfig>) -> ProgramResult {
let mut proposal = ctx.accounts.proposal.load_mut()?;
require!(proposal.state != Proposal::FINALIZED, InvalidInput);

Expand All @@ -138,13 +138,13 @@ pub mod ocr2 {
}

#[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))]
pub fn close_config_proposal(ctx: Context<CloseProposal>) -> ProgramResult {
pub fn close_proposal(ctx: Context<CloseProposal>) -> ProgramResult {
// NOTE: Close is handled by anchor on exit due to the `close` attribute
Ok(())
}

#[access_control(owner(&ctx.accounts.state, &ctx.accounts.authority))]
pub fn accept_config_proposal<'info>(
pub fn accept_proposal<'info>(
ctx: Context<'_, '_, '_, 'info, AcceptProposal<'info>>,
) -> ProgramResult {
let mut state = ctx.accounts.state.load_mut()?;
Expand All @@ -159,7 +159,7 @@ pub mod ocr2 {
let latest_round_id = state.config.latest_aggregator_round_id;
let billing = state.config.billing;

// NOTE: if multisig supported multi instruction transactions, this could be [pay_oracles, accept_config_proposal]
// NOTE: if multisig supported multi instruction transactions, this could be [pay_oracles, accept_proposal]
let payments: Vec<(u64, CpiContext<'_, '_, '_, 'info, token::Transfer<'info>>)> = state
.oracles
.iter_mut()
Expand Down Expand Up @@ -268,8 +268,8 @@ pub mod ocr2 {
}

#[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))]
pub fn set_config(
ctx: Context<SetConfig>,
pub fn propose_config(
ctx: Context<ProposeConfig>,
new_oracles: Vec<NewOracle>,
f: u8,
) -> ProgramResult {
Expand All @@ -280,7 +280,7 @@ pub mod ocr2 {

let mut proposal = ctx.accounts.proposal.load_mut()?;
require!(proposal.state != Proposal::FINALIZED, InvalidInput);
// begin_config_proposal must be called first
// begin_proposal must be called first
require!(proposal.offchain_config.version != 0, InvalidInput);

// Clear out old oracles
Expand Down Expand Up @@ -321,8 +321,8 @@ pub mod ocr2 {
}

#[access_control(proposal_owner(&ctx.accounts.proposal, &ctx.accounts.authority))]
pub fn set_payees(
ctx: Context<SetConfig>,
pub fn propose_payees(
ctx: Context<ProposeConfig>,
token_mint: Pubkey,
payees: Vec<Pubkey>,
) -> ProgramResult {
Expand Down
34 changes: 17 additions & 17 deletions contracts/tests/ocr2.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ describe("ocr2", async () => {

let oracles = [];
const f = 6;
// NOTE: 17 is the most we can fit into one setConfig if we use a different payer
// NOTE: 17 is the most we can fit into one proposeConfig if we use a different payer
// if the owner == payer then we can fit 19
const n = 19; // min: 3 * f + 1;

Expand Down Expand Up @@ -496,8 +496,8 @@ describe("ocr2", async () => {
// TODO: listen for SetConfig event
let proposal = Keypair.generate();

console.log("createConfigProposal");
await program.rpc.createConfigProposal(new BN(offchain_config_version), {
console.log("createProposal");
await program.rpc.createProposal(new BN(offchain_config_version), {
accounts: {
proposal: proposal.publicKey,
authority: owner.publicKey,
Expand All @@ -507,8 +507,8 @@ describe("ocr2", async () => {
await program.account.proposal.createInstruction(proposal),
],
});
console.log("setConfig");
await program.rpc.setConfig(
console.log("proposeConfig");
await program.rpc.proposeConfig(
oracles.map((oracle) => ({
signer: ethereumAddress(Buffer.from(oracle.signer.publicKey)),
transmitter: oracle.transmitter.publicKey,
Expand Down Expand Up @@ -537,8 +537,8 @@ describe("ocr2", async () => {
},
});

console.log("setPayees");
await program.rpc.setPayees(
console.log("proposePayees");
await program.rpc.proposePayees(
token.publicKey,
oracles.map((oracle) => oracle.payee.address),
{
Expand All @@ -549,8 +549,8 @@ describe("ocr2", async () => {
}
);

console.log("commitConfigProposal");
await program.rpc.commitConfigProposal({
console.log("finalizeProposal");
await program.rpc.finalizeProposal({
accounts: {
proposal: proposal.publicKey,
authority: owner.publicKey,
Expand All @@ -563,8 +563,8 @@ describe("ocr2", async () => {
return { pubkey: oracle.payee, isWritable: true, isSigner: false };
});

console.log("approveConfigProposal");
await program.rpc.acceptConfigProposal({
console.log("approveProposal");
await program.rpc.acceptProposal({
accounts: {
state: state.publicKey,
proposal: proposal.publicKey,
Expand All @@ -586,9 +586,9 @@ describe("ocr2", async () => {
[4, 5, 6, 4, 5, 6]
);

// Proposal already closed by acceptConfigProposal
// console.log("closeConfigProposal");
// await program.rpc.closeConfigProposal(
// Proposal already closed by acceptProposal
// console.log("closeProposal");
// await program.rpc.closeProposal(
// {
// accounts: {
// proposal: proposal.publicKey,
Expand Down Expand Up @@ -622,7 +622,7 @@ describe("ocr2", async () => {

it("Can't begin config proposal if version is 0", async () => {
try {
await program.rpc.createConfigProposal(new BN(0), {
await program.rpc.createProposal(new BN(0), {
accounts: {
proposal: proposal.publicKey,
authority: owner.publicKey,
Expand All @@ -632,7 +632,7 @@ describe("ocr2", async () => {
// createOffchainConfig should fail
return;
}
assert.fail("createConfigProposal shouldn't have succeeded!");
assert.fail("createProposal shouldn't have succeeded!");
});

it("Can't write offchain config if begin has not been called", async () => {
Expand All @@ -653,7 +653,7 @@ describe("ocr2", async () => {

// it("ResetPendingOffchainConfig clears pending state", async () => {

// await program.rpc.createConfigProposal(
// await program.rpc.createProposal(
// new BN(2),
// {
// accounts: {
Expand Down

0 comments on commit 997a8b2

Please sign in to comment.