Skip to content

feat : Implement timelock contract#16

Open
0xTitan wants to merge 8 commits intodevfrom
Timelock
Open

feat : Implement timelock contract#16
0xTitan wants to merge 8 commits intodevfrom
Timelock

Conversation

@0xTitan
Copy link
Copy Markdown
Contributor

@0xTitan 0xTitan commented Dec 10, 2023

Pull Request type

Please add the labels corresponding to the type of changes your PR introduces:

  • Bugfix
  • Feature
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Build-related changes
  • Documentation content changes
  • Testing
  • Other (please describe):

What is the current behavior?

Implement timelock

Resolves: #6

What is the new behavior?

  • added functionality to queue ,cancel and execute transaction
  • added set delay
  • added accept admin
  • added set pending admin
  • added hash

Does this introduce a breaking change?

No

Other information

@0xTitan 0xTitan changed the base branch from main to dev December 10, 2023 10:20
@0xTitan 0xTitan changed the title Timelock Draft : Timelock Dec 10, 2023
@0xTitan 0xTitan force-pushed the Timelock branch 2 times, most recently from 12a7abb to 8f80758 Compare December 11, 2023 12:06
@0xTitan 0xTitan changed the title Draft : Timelock Implement timelock contract Dec 11, 2023
@0xTitan 0xTitan changed the title Implement timelock contract feat : Implement timelock contract Dec 11, 2023
Comment on lines +47 to +54
use core::traits::Into;
use core::zeroable::Zeroable;
use core::array::ArrayTrait;
use core::starknet::event::EventEmitter;
use core::option::OptionTrait;
use core::serde::Serde;
use core::traits::TryInto;
use core::box::BoxTrait;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Think you can safely remove all the core imports, those are in the prelude (there are few a bit further too)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done ! Some core import still needed for hash functionnality.

@@ -0,0 +1,25 @@
use hash::{LegacyHash, HashStateTrait, HashStateExTrait};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More gas opti to use poseidon

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines +10 to +12
let mut call_data_state = LegacyHash::hash(0, *self);
call_data_state = LegacyHash::hash(call_data_state, (*self).len());
call_data_state
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better using:

PedersenTrait::new(0);
state = state.update_with(x);
state = state.update_with(y);
state.finalize()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@FabienCoutant FabienCoutant force-pushed the dev branch 2 times, most recently from 062ca69 to 0b63cda Compare December 24, 2023 15:18
Comment on lines +86 to +88
old_admin: ContractAddress,
#[key]
new_admin: ContractAddress
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
old_admin: ContractAddress,
#[key]
new_admin: ContractAddress
#[key]
new_admin: ContractAddress
old_admin: ContractAddress,

impl InternalFunctions of InternalFunctionsTrait {
fn _is_valid_delay(_delay: u256) {}
fn _admin_only() {}
fn is_valid_delay(self: @ContractState, delay: u256) {
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be inlined, but no big deal

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done for is_valid_delay and admin_only

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 this pull request may close these issues.

feat: Implement timelock contract

3 participants