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 of contracts #493

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,32 @@ To measure and benchmark memory it is best to use external tools such as Valgrin

### Updating OpenZeppelin contracts

Tests in devnet require an erc20 contract with the `Mintable` feature, keep in mind that before the compilation process of [cairo-contracts](https://github.com/OpenZeppelin/cairo-contracts/) you need to mark the `Mintable` check box in this [wizard](https://wizard.openzeppelin.com/cairo) and copy this implementation to `/src/presets/erc20.cairo`.
#### ERC20

To update ERC20 OpenZeppelin contract please follow steps below:

1. Create new project with scarb.
```
scarb new contract_update
```

2. Go to [wizard](https://wizard.openzeppelin.com/cairo) and select ERC20 contract with the `Mintable` feature, and copy code to `contract_update/src/lib.cairo`

3. Make sure that you will set target `sierra` for true:

```
[[target.starknet-contract]]
sierra = true
```

3. Build with scarb
```
scarb build
```

#### Account & Universal Deployer (UDC)

To update Account and Universal Deployer (UDC) OpenZeppelin contracts compile [cairo-contracts](https://github.com/OpenZeppelin/cairo-contracts) project and use compiled [acccount](https://github.com/OpenZeppelin/cairo-contracts/blob/main/src/account/account.cairo) and UDC contracts.

If smart contract constructor logic has changed, Devnet's predeployment logic needs to be changed, e.g. `simulate_constructor` in `crates/starknet-devnet-core/src/account.rs`.

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions crates/starknet-devnet-core/src/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,23 @@ pub const CAIRO_0_ACCOUNT_CONTRACT_HASH: &str =
/// only used in tests; if artifact needed in production, use CAIRO_1_ACCOUNT_CONTRACT_SIERRA
pub const CAIRO_1_ACCOUNT_CONTRACT_SIERRA_PATH: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/accounts_artifacts/OpenZeppelin/0.8.1/Account.cairo/Account.sierra"
"/accounts_artifacts/OpenZeppelin/0.13.0/Account.cairo/Account.sierra"
);

pub const CAIRO_1_ACCOUNT_CONTRACT_SIERRA: &str =
include_str!("../accounts_artifacts/OpenZeppelin/0.8.1/Account.cairo/Account.sierra");
include_str!("../accounts_artifacts/OpenZeppelin/0.13.0/Account.cairo/Account.sierra");

pub const CAIRO_1_ACCOUNT_CONTRACT_SIERRA_HASH: &str =
"0x061dac032f228abef9c6626f995015233097ae253a7f72d68552db02f2971b8f";
"0x00e2eb8f5672af4e6a4e8a8f1b44989685e668489b0a25437733756c5a34a1d6";

pub const CAIRO_1_ERC20_CONTRACT: &str =
include_str!("../accounts_artifacts/ERC20_Mintable_OZ_0.8.1.json");
include_str!("../accounts_artifacts/ERC20_Mintable_OZ_0.13.0.json");

/// ERC20 class hash is hardcoded to be the same as OZ class hash ERC20.cairo although it should be
/// different, due to commented key attributes in struct Approval (owner and spender), and add of
/// mintable feature: https://docs.openzeppelin.com/contracts-cairo/0.8.1/presets
/// mintable feature: https://docs.openzeppelin.com/contracts-cairo/0.13.0/presets
pub const CAIRO_1_ERC20_CONTRACT_CLASS_HASH: &str =
"0x046ded64ae2dead6448e247234bab192a9c483644395b66f2155f2614e5804b0";
"0x040b9e69e14ddc34a98ec8133c80807c144b818bc6cbf5a119d8f62535258142";

/// only used in tests; if artifact needed in production, add a new constant that uses include_str!
pub const CAIRO_0_ERC20_CONTRACT_PATH: &str =
Expand Down
2 changes: 1 addition & 1 deletion crates/starknet-devnet/tests/general_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ mod general_integration_tests {
let mut expected_config = json!({
"seed": 1,
"total_accounts": 2,
"account_contract_class_hash": "0x61dac032f228abef9c6626f995015233097ae253a7f72d68552db02f2971b8f",
"account_contract_class_hash": "0xe2eb8f5672af4e6a4e8a8f1b44989685e668489b0a25437733756c5a34a1d6",
"predeployed_accounts_initial_balance": "3",
"start_time": 4,
"gas_price_wei": 5,
Expand Down