Skip to content

Commit

Permalink
use upgradeable interface for multisig
Browse files Browse the repository at this point in the history
  • Loading branch information
augustbleeds committed Oct 3, 2023
1 parent 7928e2f commit ea71a8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
16 changes: 9 additions & 7 deletions contracts/src/multisig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ trait IMultisig<TContractState> {
fn is_executed(self: @TContractState, nonce: u128) -> bool;
fn get_transaction(self: @TContractState, nonce: u128) -> (Transaction, Array::<felt252>);
fn type_and_version(self: @TContractState) -> felt252;
fn upgrade(ref self: TContractState, new_impl: ClassHash);
fn submit_transaction(
ref self: TContractState,
to: ContractAddress,
Expand Down Expand Up @@ -93,7 +92,7 @@ mod Multisig {
use starknet::storage_write_syscall;
use starknet::class_hash::ClassHash;

use chainlink::libraries::upgradeable::Upgradeable;
use chainlink::libraries::upgradeable::{Upgradeable, IUpgradeable};

#[event]
#[derive(Drop, starknet::Event)]
Expand Down Expand Up @@ -162,6 +161,14 @@ mod Multisig {
self._set_threshold(threshold);
}

#[external(v0)]
impl UpgradeableImpl of IUpgradeable<ContractState> {
fn upgrade(ref self: ContractState, new_impl: ClassHash) {
self._require_multisig();
Upgradeable::upgrade(new_impl)
}
}

#[external(v0)]
impl MultisigImpl of super::IMultisig<ContractState> {
/// Views
Expand Down Expand Up @@ -214,11 +221,6 @@ mod Multisig {

/// Externals
fn upgrade(ref self: ContractState, new_impl: ClassHash) {
self._require_multisig();
Upgradeable::upgrade(new_impl)
}

fn submit_transaction(
ref self: ContractState,
to: ContractAddress,
Expand Down
4 changes: 2 additions & 2 deletions contracts/src/tests/test_multisig.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use traits::TryInto;

use chainlink::multisig::assert_unique_values;
use chainlink::multisig::Multisig;
use chainlink::multisig::Multisig::MultisigImpl;
use chainlink::multisig::Multisig::{MultisigImpl, UpgradeableImpl};

#[starknet::contract]
mod MultisigTest {
Expand Down Expand Up @@ -288,7 +288,7 @@ fn test_upgrade_not_multisig() {
let account = contract_address_const::<777>();
set_caller_address(account);

MultisigImpl::upgrade(ref state, class_hash_const::<1>())
UpgradeableImpl::upgrade(ref state, class_hash_const::<1>())
}

#[test]
Expand Down

0 comments on commit ea71a8d

Please sign in to comment.