Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update contracts and tests for cairo 2.5.x #363

Merged
merged 7 commits into from
Feb 27, 2024
Merged

update contracts and tests for cairo 2.5.x #363

merged 7 commits into from
Feb 27, 2024

Conversation

augustbleeds
Copy link
Collaborator

@augustbleeds augustbleeds commented Feb 23, 2024

Used cairo 2.5.4, the last version of 2.5.x

Changes include

  • using abi_embed(v0) macro. All public functions must be inside of an implementation of a trait with the said macro.
  • using OwnableTwoStepImpl instead of our own. Only difference between the two is pending_owner is used instead of proposed_owner and there is no 0 address check during a pending_owner proposal. This is fine because there will be never anyone who can confirm the ownership (no one will be 0 address) so the original owner will still be the owner and can try again.
  • fixed some of the tests that were broken.
  • got rid of most compiler warnings
  • changed loop {} to while {} where appropriate

Copy link
Collaborator

@archseer archseer left a comment

Choose a reason for hiding this comment

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

Some small nits, great work otherwise!

@@ -1,57 +1,233 @@
// copied from https://github.com/OpenZeppelin/cairo-contracts/blob/v0.8.1/src/presets/account.cairo
// copied from https://github.com/OpenZeppelin/cairo-contracts/blob/release-v0.9.0/src/access/ownable/ownable.cairo
Copy link
Collaborator

Choose a reason for hiding this comment

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

Let's use a sha since tags can change

contracts/src/libraries.cairo Outdated Show resolved Hide resolved
@@ -107,6 +107,9 @@ trait Billing<TContractState> {
fn link_available_for_payment(
self: @TContractState
) -> (bool, u128); // (is negative, absolute difference)
fn set_link_token(
Copy link
Collaborator

Choose a reason for hiding this comment

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

good catch 👍🏻

set_contract_address(s1);
multisig.confirm_transaction(0);

// Signer 2 confirms the transaction
set_caller_address(s2);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm was this API removed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

nah, it wasn't removed. we weren't using it the correct way. set_contract_address should only be used if the test contract is deployed in the testing suite. Otherwise we should use set_caller_address.

I noticed when testing that there is some undefined behavior if you do both

contracts/src/libraries.cairo Outdated Show resolved Hide resolved
@@ -102,7 +103,7 @@ mod LinkToken {
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

There's a TODO to expose the minter method a couple lines above, can we take care of that here too?

Copy link
Collaborator

@archseer archseer left a comment

Choose a reason for hiding this comment

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

Lints and tests still fail. I'll quickly resolve


/// # Account Preset
/// # Ownable Component
Copy link
Collaborator

Choose a reason for hiding this comment

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

You seem to have replaced the account contract with the ownable contract?

@archseer archseer merged commit 0e7c67b into develop Feb 27, 2024
13 of 18 checks passed
@archseer archseer deleted the cairo2.5.x branch February 27, 2024 01:35
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.

3 participants