├── .gitattributes ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── actionlint-matcher.json ├── dependabot.yml └── workflows │ ├── actionlint.yml │ ├── prepare-release.yml │ ├── prepare-testing-release.yml │ ├── test-macros.yml │ ├── test.yml │ └── typos.yaml ├── .gitignore ├── .markdownlint.jsonc ├── CHANGELOG.md ├── CONTRIBUTING.md ├── DEVELOPMENT.md ├── LICENSE ├── PULL_REQUEST_TEMPLATE.md ├── README.md ├── RELEASING.md ├── SECURITY.md ├── Scarb.lock ├── Scarb.toml ├── _typos.toml ├── audits ├── 2025-01-v1.0.0.pdf └── README.md ├── codecov.yml ├── docs ├── antora.yml ├── modules │ └── ROOT │ │ ├── images │ │ ├── erc4626-attack-3a.png │ │ ├── erc4626-attack-3b.png │ │ ├── erc4626-attack-6.png │ │ ├── erc4626-attack.png │ │ ├── erc4626-deposit.png │ │ ├── erc4626-mint.png │ │ ├── erc4626-rate-linear.png │ │ ├── erc4626-rate-loglog.png │ │ └── erc4626-rate-loglogext.png │ │ ├── nav.adoc │ │ └── pages │ │ ├── access.adoc │ │ ├── accounts.adoc │ │ ├── api │ │ ├── access.adoc │ │ ├── account.adoc │ │ ├── erc1155.adoc │ │ ├── erc20.adoc │ │ ├── erc721.adoc │ │ ├── finance.adoc │ │ ├── governance.adoc │ │ ├── introspection.adoc │ │ ├── merkle-tree.adoc │ │ ├── security.adoc │ │ ├── testing.adoc │ │ ├── token_common.adoc │ │ ├── udc.adoc │ │ ├── upgrades.adoc │ │ └── utilities.adoc │ │ ├── backwards-compatibility.adoc │ │ ├── components.adoc │ │ ├── erc1155.adoc │ │ ├── erc20.adoc │ │ ├── erc4626.adoc │ │ ├── erc721.adoc │ │ ├── finance.adoc │ │ ├── governance │ │ ├── governor.adoc │ │ ├── multisig.adoc │ │ ├── timelock.adoc │ │ └── votes.adoc │ │ ├── guides │ │ ├── deployment.adoc │ │ ├── erc20-permit.adoc │ │ ├── erc20-supply.adoc │ │ ├── snip12.adoc │ │ └── src5-migration.adoc │ │ ├── index.adoc │ │ ├── interfaces.adoc │ │ ├── introspection.adoc │ │ ├── macros.adoc │ │ ├── macros │ │ ├── type_hash.adoc │ │ └── with_components.adoc │ │ ├── presets.adoc │ │ ├── security.adoc │ │ ├── udc.adoc │ │ ├── upgrades.adoc │ │ ├── utils │ │ ├── _class_hashes.adoc │ │ └── _common.adoc │ │ └── wizard.adoc ├── package-lock.json └── package.json ├── netlify.toml ├── packages ├── access │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── accesscontrol.cairo │ │ ├── accesscontrol │ │ ├── accesscontrol.cairo │ │ ├── account_role_info.cairo │ │ └── interface.cairo │ │ ├── lib.cairo │ │ ├── ownable.cairo │ │ ├── ownable │ │ ├── interface.cairo │ │ └── ownable.cairo │ │ ├── tests.cairo │ │ └── tests │ │ ├── test_accesscontrol.cairo │ │ ├── test_ownable.cairo │ │ └── test_ownable_twostep.cairo ├── account │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── account.cairo │ │ ├── eth_account.cairo │ │ ├── extensions.cairo │ │ ├── extensions │ │ ├── src9.cairo │ │ └── src9 │ │ │ ├── interface.cairo │ │ │ ├── snip12_utils.cairo │ │ │ └── src9.cairo │ │ ├── interface.cairo │ │ ├── lib.cairo │ │ ├── tests.cairo │ │ ├── tests │ │ ├── extensions.cairo │ │ ├── extensions │ │ │ ├── test_snip12_utils.cairo │ │ │ └── test_src9.cairo │ │ ├── test_account.cairo │ │ ├── test_eth_account.cairo │ │ ├── test_secp256_point.cairo │ │ └── test_signature.cairo │ │ ├── utils.cairo │ │ └── utils │ │ ├── secp256_point.cairo │ │ └── signature.cairo ├── finance │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── lib.cairo │ │ ├── tests.cairo │ │ ├── tests │ │ ├── common.cairo │ │ ├── test_vesting_linear.cairo │ │ └── test_vesting_steps.cairo │ │ ├── vesting.cairo │ │ └── vesting │ │ ├── interface.cairo │ │ └── vesting.cairo ├── governance │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── governor.cairo │ │ ├── governor │ │ ├── extensions.cairo │ │ ├── extensions │ │ │ ├── governor_core_execution.cairo │ │ │ ├── governor_counting_simple.cairo │ │ │ ├── governor_settings.cairo │ │ │ ├── governor_timelock_execution.cairo │ │ │ ├── governor_votes.cairo │ │ │ ├── governor_votes_quorum_fraction.cairo │ │ │ └── interface.cairo │ │ ├── governor.cairo │ │ ├── interface.cairo │ │ ├── proposal_core.cairo │ │ └── vote.cairo │ │ ├── lib.cairo │ │ ├── multisig.cairo │ │ ├── multisig │ │ ├── interface.cairo │ │ ├── multisig.cairo │ │ └── storage_utils.cairo │ │ ├── tests.cairo │ │ ├── tests │ │ ├── governor.cairo │ │ ├── governor │ │ │ ├── common.cairo │ │ │ ├── test_governor.cairo │ │ │ ├── test_governor_core_execution.cairo │ │ │ ├── test_governor_counting_simple.cairo │ │ │ ├── test_governor_settings.cairo │ │ │ ├── test_governor_timelock_execution.cairo │ │ │ ├── test_governor_votes.cairo │ │ │ └── test_governor_votes_quorum_fraction.cairo │ │ ├── test_fuzz_packing.cairo │ │ ├── test_multisig.cairo │ │ ├── test_timelock.cairo │ │ ├── test_utils.cairo │ │ └── test_votes.cairo │ │ ├── timelock.cairo │ │ ├── timelock │ │ ├── interface.cairo │ │ └── timelock_controller.cairo │ │ ├── utils.cairo │ │ ├── utils │ │ └── call_impls.cairo │ │ ├── votes.cairo │ │ └── votes │ │ ├── delegation.cairo │ │ ├── interface.cairo │ │ └── votes.cairo ├── introspection │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── interface.cairo │ │ ├── lib.cairo │ │ ├── src5.cairo │ │ ├── tests.cairo │ │ └── tests │ │ └── test_src5.cairo ├── macros │ ├── Cargo.lock │ ├── Cargo.toml │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── attribute │ │ ├── mod.rs │ │ ├── type_hash │ │ │ ├── definition.rs │ │ │ ├── diagnostics.rs │ │ │ ├── mod.rs │ │ │ ├── parser.rs │ │ │ └── types.rs │ │ └── with_components │ │ │ ├── components.rs │ │ │ ├── definition.rs │ │ │ ├── diagnostics.rs │ │ │ ├── mod.rs │ │ │ └── parser.rs │ │ ├── constants.rs │ │ ├── lib.rs │ │ ├── tests │ │ ├── common.rs │ │ ├── mod.rs │ │ ├── snapshots │ │ │ ├── openzeppelin_macros__tests__test_type_hash__basic_types.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__basic_types_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_enum_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_enum_with_collection_types.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_enum_with_collection_types_custom_names.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_struct_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_struct_with_collection_types.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__complex_struct_with_collection_types_custom_names.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__debug_attribute.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_1.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_2.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_3.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_4.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_5.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_6.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__doc_example_7.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__empty_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__empty_input.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__empty_struct.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__enum_without_explicit_variant_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__invalid_type_hash_attribute.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__merkletree_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__name_attribute.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__potential_duplicate_types.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__potential_duplicate_types_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__preset_types.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__preset_types_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__snip12_attribute_empty.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__starknet_domain.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_array.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_empty_tuple.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_empty_tuple_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_inner_custom_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_inner_starknet_domain.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_inner_u256_type.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_inner_u256_type_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_span.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_tuple.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_tuple_and_attribute.snap │ │ │ ├── openzeppelin_macros__tests__test_type_hash__with_tuple_enum.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_access_control.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_access_control_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_account.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_account_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc1155.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc1155_no_hooks_impl.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc1155_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc1155_receiver.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc1155_receiver_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc20.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc20_no_config.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc20_no_hooks_impl.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc20_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc2981.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc2981_no_config.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc2981_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc2981_no_initializer_no_config.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc4626.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_enumerable.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_enumerable_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_no_hooks_impl.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_receiver.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_erc721_receiver_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_eth_account.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_eth_account_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_event_struct.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_core_execution.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_counting_simple.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_integration.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_no_config.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_settings.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_settings_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_timelock_execution.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_timelock_execution_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_votes.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_votes_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_votes_quorum_fraction.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_governor_votes_quorum_fraction_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_initializable.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_initializable_no_initialize_call.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_invalid_component.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_multisig.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_multisig_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_no_body.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_no_components.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_no_contract_attribute.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_nonces.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_ownable.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_ownable_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_pausable.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_pausable_no_pause_call.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_pausable_no_pause_or_unpause_call.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_pausable_no_unpause_call.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_reentrancy_guard.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_src5.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_src9.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_src9_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_timelock_controller.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_timelock_controller_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_two_components.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_two_components_no_constructor.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_two_components_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_upgradeable.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_upgradeable_no_upgrade_call.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_vesting.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_vesting_no_initializer.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_vesting_no_schedule.snap │ │ │ ├── openzeppelin_macros__tests__test_with_components__with_votes.snap │ │ │ └── openzeppelin_macros__tests__test_with_components__with_votes_no_metadata.snap │ │ ├── test_type_hash.rs │ │ └── test_with_components.rs │ │ ├── utils.rs │ │ └── with_components.rs ├── merkle_tree │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── hashes.cairo │ │ ├── lib.cairo │ │ ├── merkle_proof.cairo │ │ ├── tests.cairo │ │ └── tests │ │ ├── merkle_proof.cairo │ │ ├── merkle_proof │ │ ├── common.cairo │ │ ├── test_with_pedersen.cairo │ │ └── test_with_poseidon.cairo │ │ └── test_hashes.cairo ├── presets │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── account.cairo │ │ ├── erc1155.cairo │ │ ├── erc20.cairo │ │ ├── erc721.cairo │ │ ├── eth_account.cairo │ │ ├── interfaces.cairo │ │ ├── interfaces │ │ ├── account.cairo │ │ ├── erc1155.cairo │ │ ├── erc20.cairo │ │ ├── erc721.cairo │ │ ├── eth_account.cairo │ │ └── vesting.cairo │ │ ├── lib.cairo │ │ ├── tests.cairo │ │ ├── tests │ │ ├── test_account.cairo │ │ ├── test_erc1155.cairo │ │ ├── test_erc20.cairo │ │ ├── test_erc721.cairo │ │ ├── test_eth_account.cairo │ │ ├── test_universal_deployer.cairo │ │ └── test_vesting.cairo │ │ ├── universal_deployer.cairo │ │ └── vesting.cairo ├── security │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── initializable.cairo │ │ ├── interface.cairo │ │ ├── lib.cairo │ │ ├── pausable.cairo │ │ ├── reentrancyguard.cairo │ │ ├── tests.cairo │ │ └── tests │ │ ├── test_initializable.cairo │ │ ├── test_pausable.cairo │ │ └── test_reentrancyguard.cairo ├── test_common │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── account.cairo │ │ ├── erc1155.cairo │ │ ├── erc20.cairo │ │ ├── erc721.cairo │ │ ├── eth_account.cairo │ │ ├── lib.cairo │ │ ├── math.cairo │ │ ├── mocks.cairo │ │ ├── mocks │ │ ├── access.cairo │ │ ├── account.cairo │ │ ├── checkpoint.cairo │ │ ├── erc1155.cairo │ │ ├── erc20.cairo │ │ ├── erc2981.cairo │ │ ├── erc4626.cairo │ │ ├── erc721.cairo │ │ ├── governor.cairo │ │ ├── multisig.cairo │ │ ├── non_implementing.cairo │ │ ├── nonces.cairo │ │ ├── security.cairo │ │ ├── simple.cairo │ │ ├── src5.cairo │ │ ├── src9.cairo │ │ ├── timelock.cairo │ │ ├── upgrades.cairo │ │ ├── vesting.cairo │ │ └── votes.cairo │ │ ├── ownable.cairo │ │ ├── upgrades.cairo │ │ └── vesting.cairo ├── testing │ ├── CHANGELOG.md │ ├── README.md │ ├── RELEASING.md │ ├── Scarb.toml │ ├── docs │ │ ├── SUMMARY.md │ │ ├── constants.md │ │ ├── free_functions.md │ │ ├── impls.md │ │ ├── modules.md │ │ ├── openzeppelin_testing-common-IntoBase16StringTrait.md │ │ ├── openzeppelin_testing-common-assert_entrypoint_not_found_error.md │ │ ├── openzeppelin_testing-common-panic_data_to_byte_array.md │ │ ├── openzeppelin_testing-common-to_base_16_string.md │ │ ├── openzeppelin_testing-common-to_base_16_string_no_padding.md │ │ ├── openzeppelin_testing-common.md │ │ ├── openzeppelin_testing-constants-ADMIN.md │ │ ├── openzeppelin_testing-constants-ALICE.md │ │ ├── openzeppelin_testing-constants-AUTHORIZED.md │ │ ├── openzeppelin_testing-constants-AsAddressImpl.md │ │ ├── openzeppelin_testing-constants-AsAddressTrait.md │ │ ├── openzeppelin_testing-constants-BASE_URI.md │ │ ├── openzeppelin_testing-constants-BASE_URI_2.md │ │ ├── openzeppelin_testing-constants-BLOCK_NUMBER.md │ │ ├── openzeppelin_testing-constants-BOB.md │ │ ├── openzeppelin_testing-constants-CALLER.md │ │ ├── openzeppelin_testing-constants-CHAIN_ID.md │ │ ├── openzeppelin_testing-constants-CHARLIE.md │ │ ├── openzeppelin_testing-constants-CLASS_HASH_ZERO.md │ │ ├── openzeppelin_testing-constants-DAPP_NAME.md │ │ ├── openzeppelin_testing-constants-DAPP_VERSION.md │ │ ├── openzeppelin_testing-constants-DATA.md │ │ ├── openzeppelin_testing-constants-DECIMALS.md │ │ ├── openzeppelin_testing-constants-DELEGATEE.md │ │ ├── openzeppelin_testing-constants-DELEGATOR.md │ │ ├── openzeppelin_testing-constants-EMPTY_DATA.md │ │ ├── openzeppelin_testing-constants-EthPublicKey.md │ │ ├── openzeppelin_testing-constants-FAILURE.md │ │ ├── openzeppelin_testing-constants-FELT_VALUE.md │ │ ├── openzeppelin_testing-constants-MIN_TRANSACTION_VERSION.md │ │ ├── openzeppelin_testing-constants-NAME.md │ │ ├── openzeppelin_testing-constants-NEW_OWNER.md │ │ ├── openzeppelin_testing-constants-NEW_PUBKEY.md │ │ ├── openzeppelin_testing-constants-OPERATOR.md │ │ ├── openzeppelin_testing-constants-OTHER.md │ │ ├── openzeppelin_testing-constants-OTHER_ADMIN.md │ │ ├── openzeppelin_testing-constants-OTHER_ROLE.md │ │ ├── openzeppelin_testing-constants-OWNER.md │ │ ├── openzeppelin_testing-constants-PUBKEY.md │ │ ├── openzeppelin_testing-constants-QUERY_OFFSET.md │ │ ├── openzeppelin_testing-constants-QUERY_VERSION.md │ │ ├── openzeppelin_testing-constants-RECIPIENT.md │ │ ├── openzeppelin_testing-constants-ROLE.md │ │ ├── openzeppelin_testing-constants-SALT.md │ │ ├── openzeppelin_testing-constants-SPENDER.md │ │ ├── openzeppelin_testing-constants-SUCCESS.md │ │ ├── openzeppelin_testing-constants-SUPPLY.md │ │ ├── openzeppelin_testing-constants-SYMBOL.md │ │ ├── openzeppelin_testing-constants-TIMELOCK.md │ │ ├── openzeppelin_testing-constants-TIMESTAMP.md │ │ ├── openzeppelin_testing-constants-TOKEN_ID.md │ │ ├── openzeppelin_testing-constants-TOKEN_ID_2.md │ │ ├── openzeppelin_testing-constants-TOKEN_VALUE.md │ │ ├── openzeppelin_testing-constants-TOKEN_VALUE_2.md │ │ ├── openzeppelin_testing-constants-TRANSACTION_HASH.md │ │ ├── openzeppelin_testing-constants-VALUE.md │ │ ├── openzeppelin_testing-constants-VOTES_TOKEN.md │ │ ├── openzeppelin_testing-constants-ZERO.md │ │ ├── openzeppelin_testing-constants-secp256k1-KEY_PAIR.md │ │ ├── openzeppelin_testing-constants-secp256k1-KEY_PAIR_2.md │ │ ├── openzeppelin_testing-constants-secp256k1.md │ │ ├── openzeppelin_testing-constants-secp256r1-KEY_PAIR.md │ │ ├── openzeppelin_testing-constants-secp256r1-KEY_PAIR_2.md │ │ ├── openzeppelin_testing-constants-secp256r1.md │ │ ├── openzeppelin_testing-constants-stark-KEY_PAIR.md │ │ ├── openzeppelin_testing-constants-stark-KEY_PAIR_2.md │ │ ├── openzeppelin_testing-constants-stark.md │ │ ├── openzeppelin_testing-constants.md │ │ ├── openzeppelin_testing-deployment-declare_and_deploy.md │ │ ├── openzeppelin_testing-deployment-declare_and_deploy_at.md │ │ ├── openzeppelin_testing-deployment-declare_class.md │ │ ├── openzeppelin_testing-deployment-deploy.md │ │ ├── openzeppelin_testing-deployment-deploy_another_at.md │ │ ├── openzeppelin_testing-deployment-deploy_at.md │ │ ├── openzeppelin_testing-deployment.md │ │ ├── openzeppelin_testing-events-EventSpyExt.md │ │ ├── openzeppelin_testing-events-EventSpyQueue.md │ │ ├── openzeppelin_testing-events-EventSpyQueueImpl.md │ │ ├── openzeppelin_testing-events-spy_events.md │ │ ├── openzeppelin_testing-events.md │ │ ├── openzeppelin_testing-signing-Secp256k1KeyPair.md │ │ ├── openzeppelin_testing-signing-Secp256k1SerializedSigning.md │ │ ├── openzeppelin_testing-signing-Secp256r1KeyPair.md │ │ ├── openzeppelin_testing-signing-Secp256r1SerializedSigning.md │ │ ├── openzeppelin_testing-signing-SerializedSigning.md │ │ ├── openzeppelin_testing-signing-StarkKeyPair.md │ │ ├── openzeppelin_testing-signing-StarkSerializedSigning.md │ │ ├── openzeppelin_testing-signing-get_secp256k1_keys_from.md │ │ ├── openzeppelin_testing-signing-get_secp256r1_keys_from.md │ │ ├── openzeppelin_testing-signing-get_stark_keys_from.md │ │ ├── openzeppelin_testing-signing.md │ │ ├── openzeppelin_testing.md │ │ ├── structs.md │ │ ├── traits.md │ │ └── type_aliases.md │ └── src │ │ ├── common.cairo │ │ ├── constants.cairo │ │ ├── deployment.cairo │ │ ├── events.cairo │ │ ├── lib.cairo │ │ └── signing.cairo ├── token │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── common.cairo │ │ ├── common │ │ ├── erc2981.cairo │ │ └── erc2981 │ │ │ ├── erc2981.cairo │ │ │ └── interface.cairo │ │ ├── erc1155.cairo │ │ ├── erc1155 │ │ ├── erc1155.cairo │ │ ├── erc1155_receiver.cairo │ │ └── interface.cairo │ │ ├── erc20.cairo │ │ ├── erc20 │ │ ├── erc20.cairo │ │ ├── extensions.cairo │ │ ├── extensions │ │ │ ├── erc4626.cairo │ │ │ └── erc4626 │ │ │ │ ├── erc4626.cairo │ │ │ │ └── interface.cairo │ │ ├── interface.cairo │ │ ├── snip12_utils.cairo │ │ └── snip12_utils │ │ │ └── permit.cairo │ │ ├── erc721.cairo │ │ ├── erc721 │ │ ├── erc721.cairo │ │ ├── erc721_receiver.cairo │ │ ├── extensions.cairo │ │ ├── extensions │ │ │ ├── erc721_enumerable.cairo │ │ │ └── erc721_enumerable │ │ │ │ ├── erc721_enumerable.cairo │ │ │ │ └── interface.cairo │ │ └── interface.cairo │ │ ├── lib.cairo │ │ ├── tests.cairo │ │ └── tests │ │ ├── erc1155.cairo │ │ ├── erc1155 │ │ ├── test_erc1155.cairo │ │ └── test_erc1155_receiver.cairo │ │ ├── erc20.cairo │ │ ├── erc20 │ │ ├── test_erc20.cairo │ │ ├── test_erc20_permit.cairo │ │ └── test_fuzz_erc20.cairo │ │ ├── erc2981.cairo │ │ ├── erc2981 │ │ ├── test_erc2981_accesscontrol.cairo │ │ ├── test_erc2981_internal.cairo │ │ └── test_erc2981_ownable.cairo │ │ ├── erc4626.cairo │ │ ├── erc4626 │ │ └── test_erc4626.cairo │ │ ├── erc721.cairo │ │ └── erc721 │ │ ├── test_erc721.cairo │ │ ├── test_erc721_enumerable.cairo │ │ ├── test_erc721_receiver.cairo │ │ └── test_fuzz_erc721_enumerable.cairo ├── upgrades │ ├── README.md │ ├── Scarb.toml │ └── src │ │ ├── interface.cairo │ │ ├── lib.cairo │ │ ├── tests.cairo │ │ ├── tests │ │ └── test_upgradeable.cairo │ │ └── upgradeable.cairo └── utils │ ├── README.md │ ├── Scarb.toml │ └── src │ ├── bytearray.cairo │ ├── cryptography.cairo │ ├── cryptography │ ├── interface.cairo │ ├── nonces.cairo │ └── snip12.cairo │ ├── deployments.cairo │ ├── deployments │ └── interface.cairo │ ├── interfaces.cairo │ ├── lib.cairo │ ├── math.cairo │ ├── serde.cairo │ ├── structs.cairo │ ├── structs │ └── checkpoint.cairo │ ├── tests.cairo │ └── tests │ ├── test_checkpoint.cairo │ ├── test_math.cairo │ ├── test_nonces.cairo │ └── test_snip12.cairo ├── scripts └── get_hashes_page.py ├── sncast_scripts ├── README.md ├── Scarb.lock ├── Scarb.toml └── src │ ├── declare_presets.cairo │ └── lib.cairo └── src └── lib.cairo /.gitattributes: -------------------------------------------------------------------------------- 1 | *.cairo linguist-language=rust 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | 11 | 12 | 13 | 14 | **📝 Details** 15 | 16 | 17 | 18 | **🔢 Code to reproduce bug** 19 | 20 | 21 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **🧐 Motivation** 11 | 12 | 13 | **📝 Details** 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/actionlint-matcher.json: -------------------------------------------------------------------------------- 1 | { 2 | "problemMatcher": [ 3 | { 4 | "owner": "actionlint", 5 | "pattern": [ 6 | { 7 | "regexp": "^(?:\\x1b\\[\\d+m)?(.+?)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*:(?:\\x1b\\[\\d+m)*(\\d+)(?:\\x1b\\[\\d+m)*: (?:\\x1b\\[\\d+m)*(.+?)(?:\\x1b\\[\\d+m)* \\[(.+?)\\]$", 8 | "file": 1, 9 | "line": 2, 10 | "column": 3, 11 | "message": 4, 12 | "code": 5 13 | } 14 | ] 15 | } 16 | ] 17 | } 18 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | # Allow Dependabot to open PRs for security issues and general version updates. 3 | # It checks github actions and npm packages (for docs). 4 | # Unfortunately, this is not yet possible for Scarb packages (https://github.com/software-mansion/scarb/issues/1083) 5 | updates: 6 | - package-ecosystem: github-actions 7 | directory: '/' 8 | schedule: 9 | interval: daily 10 | # npm packages for docs 11 | - package-ecosystem: 'npm' 12 | directory: '/docs' 13 | schedule: 14 | interval: 'daily' 15 | -------------------------------------------------------------------------------- /.github/workflows/actionlint.yml: -------------------------------------------------------------------------------- 1 | name: Lint workflows 2 | 3 | on: 4 | pull_request: 5 | paths: 6 | - '.github/**/*.ya?ml' 7 | 8 | jobs: 9 | lint: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v4 13 | - name: Add problem matchers 14 | run: echo "::add-matcher::.github/actionlint-matcher.json" 15 | - uses: docker://rhysd/actionlint:latest 16 | -------------------------------------------------------------------------------- /.github/workflows/test-macros.yml: -------------------------------------------------------------------------------- 1 | name: Lint and test macros 2 | 3 | on: 4 | pull_request: 5 | push: 6 | branches: 7 | - main 8 | 9 | jobs: 10 | test_macros: 11 | name: Lint and test macros 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | 16 | - uses: Swatinem/rust-cache@v2 17 | 18 | - name: Check formatting 19 | working-directory: ./packages/macros 20 | run: | 21 | cargo fmt --all --check 22 | 23 | - name: "Run linter (clippy)" 24 | working-directory: ./packages/macros 25 | run: | 26 | cargo clippy --all --all-targets 27 | 28 | - name: "Run tests" 29 | working-directory: ./packages/macros 30 | run: | 31 | cargo test 32 | -------------------------------------------------------------------------------- /.github/workflows/typos.yaml: -------------------------------------------------------------------------------- 1 | name: Check for typos 2 | 3 | on: [pull_request] 4 | 5 | jobs: 6 | check-for-typos: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - name: Checkout the repository 10 | uses: actions/checkout@v4 11 | 12 | - name: Check for typos 13 | uses: crate-ci/typos@b1ae8d918b6e85bd611117d3d9a3be4f903ee5e4 14 | -------------------------------------------------------------------------------- /.markdownlint.jsonc: -------------------------------------------------------------------------------- 1 | { 2 | // Disable line length check to enable paragraphs without internal line breaks. 3 | // See https://github.com/DavidAnson/markdownlint/blob/main/doc/Rules.md#md013---line-length 4 | "MD013": false 5 | } 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021-2025 Zeppelin Group Ltd 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Fixes #??? 7 | 8 | 9 | 10 | 11 | #### PR Checklist 12 | 13 | 14 | 15 | 16 | 17 | - [ ] Tests 18 | - [ ] Documentation 19 | - [ ] Added entry to CHANGELOG.md 20 | - [ ] Tried the feature on a public network 21 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security 2 | 3 | Security vulnerabilities should be disclosed to the project maintainers by email to . 4 | -------------------------------------------------------------------------------- /_typos.toml: -------------------------------------------------------------------------------- 1 | [default] 2 | extend-ignore-identifiers-re = [ 3 | "e288874ba", 4 | ] 5 | -------------------------------------------------------------------------------- /audits/2025-01-v1.0.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/audits/2025-01-v1.0.0.pdf -------------------------------------------------------------------------------- /audits/README.md: -------------------------------------------------------------------------------- 1 | # Audits 2 | 3 | | Date | Version | Commit | Auditor | Scope | Links | 4 | | ------------ | ------- | ------------------------------------------------------------------------- | ------- | -------------------------------------- | -------------------------- | 5 | | January 2025 | v1.0.0 | [`3fdef27`](https://github.com/OpenZeppelin/cairo-contracts/tree/3fdef27) | Zellic | Everything except `governance` package | [🔗](./2025-01-v1.0.0.pdf) | 6 | | January 2025 | v1.0.0 | [`79391c6`](https://github.com/OpenZeppelin/cairo-contracts/tree/79391c6) | Zellic | `governance` package | [🔗](./2025-01-v1.0.0.pdf) | 7 | -------------------------------------------------------------------------------- /codecov.yml: -------------------------------------------------------------------------------- 1 | comment: 2 | layout: "diff, files, header, footer" 3 | behavior: default 4 | 5 | coverage: 6 | # The value range where you want the value to be green 7 | # Hold ourselves to a high bar. 8 | # TMP 80 floor until cairo-coverage becomes more stable 9 | range: 80..100 10 | status: 11 | project: 12 | coverage: 13 | # Use the coverage from the base commit (pull request base) coverage to compare against. 14 | # Once we have a baseline we can be more strict. 15 | # TMP threshold until cairo-coverage becomes more stable 16 | target: auto 17 | threshold: 4% 18 | patch: 19 | default: 20 | # Require new code to have 80%+ coverage. 21 | # TMP target and threshold until cairo-coverage becomes more stable 22 | target: 80% 23 | threshold: 4% 24 | 25 | ignore: 26 | - "**/tests/**" 27 | - "docs/" 28 | - "scripts/" 29 | - "packages/test_common/" 30 | - "packages/testing/" 31 | 32 | github_checks: 33 | annotations: false 34 | -------------------------------------------------------------------------------- /docs/antora.yml: -------------------------------------------------------------------------------- 1 | name: contracts-cairo 2 | title: Contracts for Cairo 3 | version: 2.0.0-alpha.1 4 | nav: 5 | - modules/ROOT/nav.adoc 6 | asciidoc: 7 | attributes: 8 | page-sidebar-collapse-default: 'Access,Accounts,Finance,Governance,Introspection,Security,ERC20,ERC721,ERC1155,ERC4626,Upgrades,Universal Deployer Contract' 9 | -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-attack-3a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-attack-3a.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-attack-3b.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-attack-3b.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-attack-6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-attack-6.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-attack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-attack.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-deposit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-deposit.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-mint.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-mint.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-rate-linear.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-rate-linear.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-rate-loglog.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-rate-loglog.png -------------------------------------------------------------------------------- /docs/modules/ROOT/images/erc4626-rate-loglogext.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/OpenZeppelin/cairo-contracts/8aff30f092555ee372bff0a7faee2d7219378a4a/docs/modules/ROOT/images/erc4626-rate-loglogext.png -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/api/testing.adoc: -------------------------------------------------------------------------------- 1 | = Testing 2 | 3 | NOTE: The `openzeppelin_testing` package version is now decoupled from the `cairo-contracts` version. 4 | 5 | You can find the documentation for the `openzeppelin_testing` package in the README for the corresponding version in the 6 | https://scarbs.xyz/packages/openzeppelin_testing[scarb registry]. 7 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/macros.adoc: -------------------------------------------------------------------------------- 1 | :github-icon: pass:[] 2 | 3 | = Macros 4 | 5 | This crate provides a collection of macros that streamline and simplify development with the library. 6 | To use them, you need to add the `openzeppelin_macros` crate as a dependency in your `Scarb.toml` file: 7 | 8 | ```toml 9 | [dependencies] 10 | openzeppelin_macros = "2.0.0-alpha.1" 11 | ``` 12 | 13 | == Attribute macros 14 | 15 | - xref:macros/with_components.adoc[with_components] 16 | - xref:macros/type_hash.adoc[type_hash] 17 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/utils/_class_hashes.adoc: -------------------------------------------------------------------------------- 1 | // Version 2 | :class-hash-cairo-version: https://crates.io/crates/cairo-lang-compiler/2.11.4[cairo 2.11.4] 3 | 4 | // Class Hashes 5 | :ERC20Upgradeable-class-hash: 0x05ae0a6a994b2145a80c31fb3cd46f7150d984de8e104becdebe481d7724daf3 6 | :ERC721Upgradeable-class-hash: 0x0077dcbd0d9907cff8b84dcf0c3006ab07b27a7db1e1e4e12b272d6b1fcdad4c 7 | :ERC1155Upgradeable-class-hash: 0x019f291ac71b768cef21602a19bedbc2f45d38374bba086585cd434c2c0e28cd 8 | :AccountUpgradeable-class-hash: 0x07fa937960fd981bc9a7f54f02786cfa6c6f194fc66cb0c35c1588bd83448062 9 | :EthAccountUpgradeable-class-hash: 0x06c71d751a10084fa31758b50348bfaa7f0b8e4b1ce36c2ab5b159cb4c307f74 10 | :UniversalDeployer-class-hash: 0x025cc49fb4b211e46b3b91bfbdd4741202ca371cd25abe2806d1b5e1250e1759 11 | :VestingWallet-class-hash: 0x01865aa64d7cbc465ab675d87b493c4c58af82eef726e702d87ca8ca4f6040e2 12 | 13 | // Presets page 14 | :presets-page: xref:presets.adoc[Sierra class hash] 15 | 16 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/utils/_common.adoc: -------------------------------------------------------------------------------- 1 | // Notes 2 | :src5-component-required-note: Implementing xref:api/introspection.adoc#SRC5Component[SRC5Component] is a requirement for this component to be implemented. 3 | 4 | // Links 5 | :mixin-impls: xref:components.adoc#mixins[Embeddable Mixin Implementations] 6 | :immutable-config: xref:components.adoc#immutable_config[Immutable Component Config] 7 | -------------------------------------------------------------------------------- /docs/modules/ROOT/pages/wizard.adoc: -------------------------------------------------------------------------------- 1 | = Wizard for Cairo 2 | :page-notoc: 3 | 4 | Not sure where to start? Use the interactive generator below to bootstrap your 5 | contract and learn about the components offered in OpenZeppelin Contracts for Cairo. 6 | 7 | 8 | NOTE: We strongly recommend checking the xref:components.adoc[Components] section to understand how to extend from our library. 9 | 10 | ++++ 11 | 12 | 13 | 14 | ++++ 15 | -------------------------------------------------------------------------------- /docs/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "docs", 3 | "version": "0.0.1", 4 | "scripts": { 5 | "docs": "oz-docs -c .", 6 | "docs:watch": "npm run docs watch", 7 | "prepare-docs": "" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "devDependencies": { 13 | "@openzeppelin/docs-utils": "^0.1.2" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /netlify.toml: -------------------------------------------------------------------------------- 1 | [build] 2 | base = "docs/" 3 | command = "npm run docs" 4 | publish = "build/site" 5 | -------------------------------------------------------------------------------- /packages/access/README.md: -------------------------------------------------------------------------------- 1 | ## Access Control 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/access](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/access) 4 | 5 | This crate provides ways to restrict who can access the functions of a contract or when they can do it. 6 | 7 | - `Ownable` is a simple mechanism with a single "owner" role that can be assigned to a single contract (usually an 8 | account). This mechanism can be useful in simple scenarios, but fine-grained access needs are likely to outgrow it. 9 | 10 | - `AccessControl` provides a general role based access control mechanism. Multiple hierarchical roles can be created 11 | and assigned each to multiple accounts. 12 | 13 | ### Interfaces 14 | 15 | - [`IAccessControl`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/access#IAccessControl) 16 | 17 | ### Components 18 | 19 | - [`OwnableComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/access#OwnableComponent) 20 | - [`AccessControlComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/access#AccessControlComponent) 21 | -------------------------------------------------------------------------------- /packages/access/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_access" 3 | readme = "README.md" 4 | keywords = [ 5 | "openzeppelin", 6 | "starknet", 7 | "contracts", 8 | "standards", 9 | "access" 10 | ] 11 | version.workspace = true 12 | edition.workspace = true 13 | cairo-version.workspace = true 14 | scarb-version.workspace = true 15 | authors.workspace = true 16 | description.workspace = true 17 | documentation.workspace = true 18 | repository.workspace = true 19 | license-file.workspace = true 20 | 21 | [tool] 22 | fmt.workspace = true 23 | scarb.workspace = true 24 | 25 | [dependencies] 26 | starknet.workspace = true 27 | openzeppelin_introspection = { path = "../introspection" } 28 | 29 | [dev-dependencies] 30 | assert_macros.workspace = true 31 | snforge_std.workspace = true 32 | openzeppelin_testing = { path = "../testing" } 33 | openzeppelin_test_common = { path = "../test_common" } 34 | 35 | [lib] 36 | 37 | [[target.starknet-contract]] 38 | allowed-libfuncs-list.name = "experimental" 39 | sierra = true 40 | casm = false 41 | -------------------------------------------------------------------------------- /packages/access/src/accesscontrol.cairo: -------------------------------------------------------------------------------- 1 | pub mod accesscontrol; 2 | pub mod account_role_info; 3 | pub mod interface; 4 | 5 | pub use accesscontrol::AccessControlComponent; 6 | pub use accesscontrol::AccessControlComponent::DEFAULT_ADMIN_ROLE; 7 | -------------------------------------------------------------------------------- /packages/access/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod accesscontrol; 2 | pub mod ownable; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /packages/access/src/ownable.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod ownable; 3 | 4 | pub use ownable::OwnableComponent; 5 | -------------------------------------------------------------------------------- /packages/access/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_accesscontrol; 2 | mod test_ownable; 3 | mod test_ownable_twostep; 4 | -------------------------------------------------------------------------------- /packages/account/README.md: -------------------------------------------------------------------------------- 1 | ## Account 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account) 4 | 5 | This crate provides components to implement account contracts that can be used for interacting with the network. 6 | 7 | - `Account` validates transactions from signatures over the 8 | [STARK Curve](https://docs.starknet.io/architecture-and-concepts/cryptography/#the_stark_curve). 9 | 10 | - `EthAccount` validates transactions from signatures over the 11 | [Secp256k1 curve](https://en.bitcoin.it/wiki/Secp256k1). 12 | 13 | ### Interfaces 14 | 15 | - [`ISRC6`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account#ISRC6) 16 | - [`ISRC9_V2`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account#ISRC9_V2) 17 | 18 | ### Components 19 | 20 | - [`AccountComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account#AccountComponent) 21 | - [`EthAccountComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account#EthAccountComponent) 22 | - [`SRC9Component`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/account#SRC9Component) 23 | -------------------------------------------------------------------------------- /packages/account/src/extensions.cairo: -------------------------------------------------------------------------------- 1 | pub mod src9; 2 | 3 | pub use src9::SRC9Component; 4 | -------------------------------------------------------------------------------- /packages/account/src/extensions/src9.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod snip12_utils; 3 | pub mod src9; 4 | 5 | pub use interface::{ISRC9_V2, OutsideExecution}; 6 | pub use interface::{ISRC9_V2Dispatcher, ISRC9_V2DispatcherTrait}; 7 | pub use src9::SRC9Component; 8 | -------------------------------------------------------------------------------- /packages/account/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod eth_account; 3 | pub mod extensions; 4 | pub mod interface; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | pub mod utils; 9 | 10 | pub use account::AccountComponent; 11 | pub use eth_account::EthAccountComponent; 12 | -------------------------------------------------------------------------------- /packages/account/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod extensions; 2 | 3 | mod test_account; 4 | mod test_eth_account; 5 | mod test_secp256_point; 6 | mod test_signature; 7 | -------------------------------------------------------------------------------- /packages/account/src/tests/extensions.cairo: -------------------------------------------------------------------------------- 1 | mod test_snip12_utils; 2 | mod test_src9; 3 | -------------------------------------------------------------------------------- /packages/finance/README.md: -------------------------------------------------------------------------------- 1 | ## Finance 2 | 3 | > **NOTE:** Documentation will soon be added to [https://docs.openzeppelin.com/contracts-cairo](https://docs.openzeppelin.com/contracts-cairo) 4 | 5 | This crate includes primitives for financial systems. 6 | 7 | ### Interfaces 8 | 9 | - `IVesting` 10 | 11 | ### Components 12 | 13 | - `VestingComponent` 14 | -------------------------------------------------------------------------------- /packages/finance/src/lib.cairo: -------------------------------------------------------------------------------- 1 | #[cfg(test)] 2 | mod tests; 3 | 4 | pub mod vesting; 5 | -------------------------------------------------------------------------------- /packages/finance/src/tests.cairo: -------------------------------------------------------------------------------- 1 | pub(crate) mod common; 2 | 3 | mod test_vesting_linear; 4 | mod test_vesting_steps; 5 | -------------------------------------------------------------------------------- /packages/finance/src/vesting.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod vesting; 3 | 4 | pub use vesting::{LinearVestingSchedule, VestingComponent}; 5 | -------------------------------------------------------------------------------- /packages/governance/src/governor.cairo: -------------------------------------------------------------------------------- 1 | pub mod extensions; 2 | pub mod governor; 3 | pub mod interface; 4 | pub mod proposal_core; 5 | pub mod vote; 6 | 7 | pub use governor::{DefaultConfig, GovernorComponent}; 8 | pub use proposal_core::ProposalCore; 9 | -------------------------------------------------------------------------------- /packages/governance/src/governor/extensions.cairo: -------------------------------------------------------------------------------- 1 | pub mod governor_core_execution; 2 | pub mod governor_counting_simple; 3 | pub mod governor_settings; 4 | pub mod governor_timelock_execution; 5 | pub mod governor_votes; 6 | pub mod governor_votes_quorum_fraction; 7 | pub mod interface; 8 | 9 | pub use governor_core_execution::GovernorCoreExecutionComponent; 10 | pub use governor_counting_simple::GovernorCountingSimpleComponent; 11 | pub use governor_settings::GovernorSettingsComponent; 12 | pub use governor_timelock_execution::GovernorTimelockExecutionComponent; 13 | pub use governor_votes::GovernorVotesComponent; 14 | pub use governor_votes_quorum_fraction::GovernorVotesQuorumFractionComponent; 15 | -------------------------------------------------------------------------------- /packages/governance/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod governor; 2 | pub mod multisig; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | 7 | pub mod timelock; 8 | pub mod utils; 9 | pub mod votes; 10 | -------------------------------------------------------------------------------- /packages/governance/src/multisig.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod multisig; 3 | pub mod storage_utils; 4 | 5 | pub use interface::{TransactionID, TransactionState}; 6 | pub use multisig::MultisigComponent; 7 | -------------------------------------------------------------------------------- /packages/governance/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod governor; 2 | #[cfg(feature: 'fuzzing')] 3 | mod test_fuzz_packing; 4 | mod test_multisig; 5 | mod test_timelock; 6 | mod test_utils; 7 | mod test_votes; 8 | -------------------------------------------------------------------------------- /packages/governance/src/tests/governor.cairo: -------------------------------------------------------------------------------- 1 | mod common; 2 | mod test_governor; 3 | mod test_governor_core_execution; 4 | mod test_governor_counting_simple; 5 | mod test_governor_settings; 6 | mod test_governor_timelock_execution; 7 | mod test_governor_votes; 8 | mod test_governor_votes_quorum_fraction; 9 | -------------------------------------------------------------------------------- /packages/governance/src/timelock.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod timelock_controller; 3 | 4 | pub use interface::OperationState; 5 | pub use timelock_controller::TimelockControllerComponent; 6 | pub use timelock_controller::TimelockControllerComponent::{ 7 | CANCELLER_ROLE, EXECUTOR_ROLE, PROPOSER_ROLE, 8 | }; 9 | -------------------------------------------------------------------------------- /packages/governance/src/utils.cairo: -------------------------------------------------------------------------------- 1 | pub mod call_impls; 2 | -------------------------------------------------------------------------------- /packages/governance/src/votes.cairo: -------------------------------------------------------------------------------- 1 | pub mod delegation; 2 | pub mod interface; 3 | pub mod votes; 4 | 5 | pub use delegation::Delegation; 6 | pub use votes::VotesComponent; 7 | -------------------------------------------------------------------------------- /packages/governance/src/votes/delegation.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (governance/src/votes/delegation.cairo) 3 | 4 | use core::hash::{HashStateExTrait, HashStateTrait}; 5 | use core::poseidon::PoseidonTrait; 6 | use openzeppelin_utils::cryptography::snip12::StructHash; 7 | use starknet::ContractAddress; 8 | 9 | // sn_keccak( 10 | // "\"Delegation\"(\"verifying_contract\":\"ContractAddress\", 11 | // \"delegatee\":\"ContractAddress\",\"nonce\":\"felt\",\"expiry\":\"u128\")" 12 | // ) 13 | // 14 | // Since there's no u64 type in SNIP-12, we use u128 for `expiry` in the type hash generation. 15 | pub const DELEGATION_TYPE_HASH: felt252 = 16 | 0x29444c6b338056aafe1802658864510c2651f5cd23897cb7b7edafe5b126d4f; 17 | 18 | #[derive(Copy, Drop, Hash)] 19 | pub struct Delegation { 20 | pub verifying_contract: ContractAddress, 21 | pub delegatee: ContractAddress, 22 | pub nonce: felt252, 23 | pub expiry: u64, 24 | } 25 | 26 | impl StructHashImpl of StructHash { 27 | fn hash_struct(self: @Delegation) -> felt252 { 28 | let hash_state = PoseidonTrait::new(); 29 | hash_state.update_with(DELEGATION_TYPE_HASH).update_with(*self).finalize() 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /packages/introspection/README.md: -------------------------------------------------------------------------------- 1 | ## Introspection 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/introspection](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/introspection) 4 | 5 | This crate handles [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts. In other words, it examines which functions can be called on a given contract. This is referred to as the contract's interface. 6 | 7 | ### Interfaces 8 | 9 | - [`ISRC5`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/introspection#ISRC5) 10 | 11 | ### Components 12 | 13 | - [`SRC5Component`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/introspection#SRC5Component) 14 | -------------------------------------------------------------------------------- /packages/introspection/Scarb.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "openzeppelin_introspection" 4 | readme = "README.md" 5 | keywords = [ 6 | "openzeppelin", 7 | "starknet", 8 | "contracts", 9 | "standards", 10 | "introspection" 11 | ] 12 | version.workspace = true 13 | edition.workspace = true 14 | cairo-version.workspace = true 15 | scarb-version.workspace = true 16 | authors.workspace = true 17 | description.workspace = true 18 | documentation.workspace = true 19 | repository.workspace = true 20 | license-file.workspace = true 21 | 22 | [tool] 23 | fmt.workspace = true 24 | scarb.workspace = true 25 | 26 | [dependencies] 27 | starknet.workspace = true 28 | 29 | [dev-dependencies] 30 | assert_macros.workspace = true 31 | snforge_std.workspace = true 32 | openzeppelin_test_common = { path = "../test_common" } 33 | 34 | [lib] 35 | 36 | [[target.starknet-contract]] 37 | allowed-libfuncs-list.name = "experimental" 38 | sierra = true 39 | casm = false 40 | -------------------------------------------------------------------------------- /packages/introspection/src/interface.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (introspection/src/interface.cairo) 3 | 4 | pub const ISRC5_ID: felt252 = 0x3f918d17e5ee77373b56385708f855659a07f75997f365cf87748628532a055; 5 | 6 | #[starknet::interface] 7 | pub trait ISRC5 { 8 | fn supports_interface(self: @TState, interface_id: felt252) -> bool; 9 | } 10 | -------------------------------------------------------------------------------- /packages/introspection/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod src5; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /packages/introspection/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_src5; 2 | -------------------------------------------------------------------------------- /packages/macros/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_macros" 3 | version = "2.0.0-alpha.1" 4 | edition = "2021" 5 | 6 | [lib] 7 | crate-type = ["cdylib"] 8 | 9 | [dependencies] 10 | cairo-lang-macro = "0.1" 11 | cairo-lang-parser = "2.11" 12 | cairo-lang-plugins = "2.11" 13 | cairo-lang-syntax = "2.11" 14 | cairo-lang-defs = "2.11" 15 | cairo-lang-formatter = "2.11" 16 | cairo-lang-starknet-classes = "2.11" 17 | indoc = "2.0.5" 18 | regex = "1.11.1" 19 | insta = "1.42.0" 20 | convert_case = "0.8.0" 21 | fancy-regex = "0.14.0" 22 | -------------------------------------------------------------------------------- /packages/macros/README.md: -------------------------------------------------------------------------------- 1 | ## Macros 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/macros](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/macros) 4 | 5 | This crate provides a collection of macros that streamline and simplify development with the OpenZeppelin library. 6 | 7 | ### Attribute macros 8 | 9 | - [`with_components(..)`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/macros/with_components) 10 | - [`type_hash(..)`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/macros/type_hash) 11 | -------------------------------------------------------------------------------- /packages/macros/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_macros" 3 | readme = "README.md" 4 | keywords = [ 5 | "openzeppelin", 6 | "cairo", 7 | "macro", 8 | ] 9 | version.workspace = true 10 | edition.workspace = true 11 | cairo-version.workspace = true 12 | scarb-version.workspace = true 13 | authors.workspace = true 14 | description.workspace = true 15 | documentation.workspace = true 16 | repository.workspace = true 17 | license-file.workspace = true 18 | 19 | [cairo-plugin] 20 | 21 | [tool] 22 | fmt.workspace = true 23 | -------------------------------------------------------------------------------- /packages/macros/src/attribute/mod.rs: -------------------------------------------------------------------------------- 1 | //! OpenZeppelin attribute macros. 2 | 3 | pub mod type_hash; 4 | pub mod with_components; 5 | -------------------------------------------------------------------------------- /packages/macros/src/attribute/type_hash/diagnostics.rs: -------------------------------------------------------------------------------- 1 | //! List of errors and warnings for the type hash macro. 2 | 3 | pub mod errors { 4 | /// Error when the type hash macro is applied to a struct containing a custom type. 5 | pub const CUSTOM_TYPE_NOT_SUPPORTED: &str = "Inner custom types are not supported yet.\n"; 6 | /// Error when the type hash macro is applied to an empty block. 7 | pub const EMPTY_TYPE_FOUND: &str = "No valid type found in the input.\n"; 8 | /// Error when the type hash macro is applied to a non-struct/enum type. 9 | pub const NOT_VALID_TYPE_TO_DECORATE: &str = "Only structs and enums are supported.\n"; 10 | /// Error when the format of the type_hash attribute is invalid. 11 | pub const INVALID_TYPE_HASH_ATTRIBUTE_FORMAT: &str = 12 | "Invalid format for the type_hash attribute. The only valid arguments are: name, debug.\n"; 13 | /// Error when the format of the snip12 attribute is invalid. 14 | pub const INVALID_SNIP12_ATTRIBUTE_FORMAT: &str = 15 | "Invalid format for the snip12 attribute. The only valid arguments are: name, kind.\n"; 16 | /// Error when the string argument is invalid. 17 | pub const INVALID_STRING_ARGUMENT: &str = 18 | "Invalid string argument. Expected a non-empty string between double quotes.\n"; 19 | } 20 | -------------------------------------------------------------------------------- /packages/macros/src/attribute/type_hash/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod definition; 2 | pub mod diagnostics; 3 | pub mod parser; 4 | pub mod types; 5 | -------------------------------------------------------------------------------- /packages/macros/src/attribute/with_components/mod.rs: -------------------------------------------------------------------------------- 1 | pub mod components; 2 | pub mod definition; 3 | pub mod diagnostics; 4 | pub mod parser; 5 | -------------------------------------------------------------------------------- /packages/macros/src/constants.rs: -------------------------------------------------------------------------------- 1 | pub const TAB: &str = " "; 2 | 3 | pub const CONTRACT_ATTRIBUTE: &str = "starknet::contract"; 4 | pub const CONSTRUCTOR_ATTRIBUTE: &str = "constructor"; 5 | pub const STORAGE_STRUCT_NAME: &str = "Storage"; 6 | pub const EVENT_ENUM_NAME: &str = "Event"; 7 | pub const SUBSTORAGE_ATTRIBUTE: &str = "substorage(v0)"; 8 | pub const FLAT_ATTRIBUTE: &str = "flat"; 9 | -------------------------------------------------------------------------------- /packages/macros/src/lib.rs: -------------------------------------------------------------------------------- 1 | pub(crate) mod attribute; 2 | pub(crate) mod constants; 3 | pub(crate) mod utils; 4 | 5 | pub(crate) use attribute::type_hash; 6 | 7 | #[cfg(test)] 8 | mod tests; 9 | -------------------------------------------------------------------------------- /packages/macros/src/tests/common.rs: -------------------------------------------------------------------------------- 1 | use cairo_lang_macro::ProcMacroResult; 2 | use indoc::formatdoc; 3 | 4 | pub(crate) fn format_proc_macro_result(raw_result: ProcMacroResult) -> String { 5 | let none = "None"; 6 | 7 | let mut token_stream = raw_result.token_stream.to_string(); 8 | let mut diagnostics = String::new(); 9 | for d in raw_result.diagnostics { 10 | diagnostics += format!("====\n{:?}: {}====", d.severity, d.message).as_str(); 11 | } 12 | 13 | if token_stream.is_empty() { 14 | token_stream = none.to_string(); 15 | } 16 | if diagnostics.is_empty() { 17 | diagnostics = none.to_string(); 18 | } 19 | 20 | formatdoc! { 21 | " 22 | TokenStream: 23 | 24 | {} 25 | 26 | Diagnostics: 27 | 28 | {} 29 | 30 | AuxData: 31 | 32 | {:?} 33 | ", 34 | token_stream, diagnostics, raw_result.aux_data 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/macros/src/tests/mod.rs: -------------------------------------------------------------------------------- 1 | mod common; 2 | mod test_type_hash; 3 | mod test_with_components; 4 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__basic_types.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub name: felt252, 10 | #[snip12(kind: "shortstring")] 11 | pub version: felt252, 12 | pub class_hash: ClassHash, 13 | pub contract_address: ContractAddress, 14 | #[snip12(kind: "timestamp")] 15 | pub timestamp: u128, 16 | #[snip12(kind: "selector")] 17 | pub selector: felt252, 18 | pub u128_member: u128, 19 | pub i128_member: i128, 20 | } 21 | pub fn __MY_TYPE_encoded_type() { 22 | println!( 23 | "\"MyType\"(\"name\":\"felt\",\"version\":\"shortstring\",\"class_hash\":\"ClassHash\",\"contract_address\":\"ContractAddress\",\"timestamp\":\"timestamp\",\"selector\":\"selector\",\"u128_member\":\"u128\",\"i128_member\":\"i128\")", 24 | ); 25 | } 26 | pub const MY_TYPE_TYPE_HASH: felt252 = 27 | 0xee6e17b4685e207c84ad4d6c7f7f2bb2897be771a1c515223d9b565268fc67; 28 | 29 | 30 | 31 | Diagnostics: 32 | 33 | None 34 | 35 | AuxData: 36 | 37 | None 38 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__basic_types_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1: felt252, 10 | Variant2: ClassHash, 11 | Variant3: ContractAddress, 12 | Variant4: u128, 13 | Variant5: i128, 14 | #[snip12(kind: "shortstring")] 15 | Variant6: felt252, 16 | #[snip12(kind: "timestamp")] 17 | Variant7: u128, 18 | #[snip12(kind: "selector")] 19 | Variant8: felt252, 20 | } 21 | pub fn __MY_ENUM_encoded_type() { 22 | println!( 23 | "\"MyEnum\"(\"Variant1\"(\"felt\"),\"Variant2\"(\"ClassHash\"),\"Variant3\"(\"ContractAddress\"),\"Variant4\"(\"u128\"),\"Variant5\"(\"i128\"),\"Variant6\"(\"shortstring\"),\"Variant7\"(\"timestamp\"),\"Variant8\"(\"selector\"))", 24 | ); 25 | } 26 | pub const MY_ENUM_TYPE_HASH: felt252 = 27 | 0x20bdb2f120712368f7f1f5ae994dd6eeca74408fceaad716c369245c33a8897; 28 | 29 | 30 | 31 | Diagnostics: 32 | 33 | None 34 | 35 | AuxData: 36 | 37 | None 38 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__complex_enum_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1: TokenAmount, 10 | Variant2: TokenAmount, 11 | Variant3: u256, 12 | #[snip12(kind: "shortstring")] 13 | Variant4: felt252, 14 | Variant5: ClassHash, 15 | Variant6: ContractAddress, 16 | #[snip12(kind: "timestamp")] 17 | Variant7: u128, 18 | #[snip12(kind: "selector")] 19 | Variant8: felt252, 20 | Variant9: u128, 21 | Variant10: i128, 22 | } 23 | pub fn __MY_ENUM_encoded_type() { 24 | println!( 25 | "\"MyEnum\"(\"Variant1\"(\"TokenAmount\"),\"Variant2\"(\"TokenAmount\"),\"Variant3\"(\"u256\"),\"Variant4\"(\"shortstring\"),\"Variant5\"(\"ClassHash\"),\"Variant6\"(\"ContractAddress\"),\"Variant7\"(\"timestamp\"),\"Variant8\"(\"selector\"),\"Variant9\"(\"u128\"),\"Variant10\"(\"i128\"))\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 26 | ); 27 | } 28 | pub const MY_ENUM_TYPE_HASH: felt252 = 29 | 0x1a348acec53a1af88d5c5e2fb4e54e11d3f74ffd13a0a2fa27f079e6d3aa716; 30 | 31 | 32 | 33 | Diagnostics: 34 | 35 | None 36 | 37 | AuxData: 38 | 39 | None 40 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__debug_attribute.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub member: felt252, 10 | } 11 | pub fn __MY_TYPE_encoded_type() { 12 | println!("\"MyType\"(\"member\":\"felt\")"); 13 | } 14 | pub const MY_TYPE_TYPE_HASH: felt252 = 15 | 0xa2e507a4520268c0606297a54114f4a700a13964e7b5141dba25f148e5c21e; 16 | 17 | 18 | 19 | Diagnostics: 20 | 21 | None 22 | 23 | AuxData: 24 | 25 | None 26 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_1.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | struct MyStruct { 9 | #[snip12(name: "My Field")] 10 | my_field: felt252, 11 | } 12 | pub fn __MY_STRUCT_encoded_type() { 13 | println!("\"My Struct\"(\"My Field\":\"felt\")"); 14 | } 15 | pub const MY_STRUCT_TYPE_HASH: felt252 = 16 | 0x1735aa9819941b96c651b740b792a96c854565eaff089b7e293d996828b88a8; 17 | 18 | 19 | 20 | Diagnostics: 21 | 22 | None 23 | 24 | AuxData: 25 | 26 | None 27 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_2.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyStruct { 9 | #[snip12(name: "Simple Felt")] // Optional custom name 10 | pub simple_felt: felt252, 11 | #[snip12(name: "Class Hash")] 12 | pub class_hash: ClassHash, 13 | #[snip12(name: "Target Token")] 14 | pub target: ContractAddress, 15 | #[snip12(name: "Timestamp", kind: "timestamp")] 16 | pub timestamp: u128, 17 | #[snip12(name: "Selector", kind: "selector")] 18 | pub selector: felt252, 19 | } 20 | pub fn __MY_STRUCT_encoded_type() { 21 | println!( 22 | "\"My Struct\"(\"Simple Felt\":\"felt\",\"Class Hash\":\"ClassHash\",\"Target Token\":\"ContractAddress\",\"Timestamp\":\"timestamp\",\"Selector\":\"selector\")", 23 | ); 24 | } 25 | pub const MY_STRUCT_TYPE_HASH: felt252 = 26 | 0x522e0c3dc5e13b0978f4645760a436b1e119fd335842523fee8fbae6057b8c; 27 | 28 | 29 | 30 | Diagnostics: 31 | 32 | None 33 | 34 | AuxData: 35 | 36 | None 37 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_3.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | #[snip12(name: "Simple Felt")] 10 | SimpleFelt: felt252, 11 | #[snip12(name: "Class Hash")] 12 | ClassHash: ClassHash, 13 | #[snip12(name: "Target Token")] 14 | ContractAddress: ContractAddress, 15 | #[snip12(name: "Timestamp", kind: "timestamp")] 16 | Timestamp: u128, 17 | #[snip12(name: "Selector", kind: "selector")] 18 | Selector: felt252, 19 | } 20 | pub fn __MY_ENUM_encoded_type() { 21 | println!( 22 | "\"My Enum\"(\"Simple Felt\"(\"felt\"),\"Class Hash\"(\"ClassHash\"),\"Target Token\"(\"ContractAddress\"),\"Timestamp\"(\"timestamp\"),\"Selector\"(\"selector\"))", 23 | ); 24 | } 25 | pub const MY_ENUM_TYPE_HASH: felt252 = 26 | 0x3f30aaa6cda9f699d4131940b10602b78b986feb88f28a19f3b48567cb4b566; 27 | 28 | 29 | 30 | Diagnostics: 31 | 32 | None 33 | 34 | AuxData: 35 | 36 | None 37 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_4.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyStruct { 9 | #[snip12(name: "Member 1")] 10 | pub member1: Array, 11 | #[snip12(name: "Member 2")] 12 | pub member2: Span, 13 | #[snip12(name: "Timestamps", kind: "Array")] 14 | pub timestamps: Array, 15 | } 16 | pub fn __MY_STRUCT_encoded_type() { 17 | println!( 18 | "\"My Struct\"(\"Member 1\":\"felt*\",\"Member 2\":\"u128*\",\"Timestamps\":\"timestamp*\")", 19 | ); 20 | } 21 | pub const MY_STRUCT_TYPE_HASH: felt252 = 22 | 0x369cdec45d8c55e70986aed44da0e330375171ba6e25b58e741c0ce02fa8ac; 23 | 24 | 25 | 26 | Diagnostics: 27 | 28 | None 29 | 30 | AuxData: 31 | 32 | None 33 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | #[snip12(name: "Member 1")] 10 | Member1: Array, 11 | #[snip12(name: "Member 2")] 12 | Member2: Span, 13 | #[snip12(name: "Timestamps", kind: "Array")] 14 | Timestamps: Array, 15 | #[snip12(name: "Name and Last Name", kind: "(shortstring, shortstring)")] 16 | NameAndLastName: (felt252, felt252), 17 | } 18 | pub fn __MY_ENUM_encoded_type() { 19 | println!( 20 | "\"My Enum\"(\"Member 1\"(\"felt*\"),\"Member 2\"(\"u128*\"),\"Timestamps\"(\"timestamp*\"),\"Name and Last Name\"(\"shortstring\",\"shortstring\"))", 21 | ); 22 | } 23 | pub const MY_ENUM_TYPE_HASH: felt252 = 24 | 0x9e3e1ebad4448a8344b3318f9cfda5df237588fd8328e1c2968635f09c735d; 25 | 26 | 27 | 28 | Diagnostics: 29 | 30 | None 31 | 32 | AuxData: 33 | 34 | None 35 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_6.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyStruct { 9 | #[snip12(name: "Token Amount")] 10 | pub token_amount: TokenAmount, 11 | #[snip12(name: "NFT ID")] 12 | pub nft_id: NftId, 13 | #[snip12(name: "Number")] 14 | pub number: u256, 15 | } 16 | pub fn __MY_STRUCT_encoded_type() { 17 | println!( 18 | "\"My Struct\"(\"Token Amount\":\"TokenAmount\",\"NFT ID\":\"NftId\",\"Number\":\"u256\")\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 19 | ); 20 | } 21 | pub const MY_STRUCT_TYPE_HASH: felt252 = 22 | 0x19f63528d68c4f44b7d9003a5a6b7793f5bb6ffc8a22bdec82b413ddf4f9412; 23 | 24 | 25 | 26 | Diagnostics: 27 | 28 | None 29 | 30 | AuxData: 31 | 32 | None 33 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__doc_example_7.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | #[snip12(name: "Token Amount")] 10 | TokenAmount: TokenAmount, 11 | #[snip12(name: "NFT ID")] 12 | NftId: NftId, 13 | #[snip12(name: "Number")] 14 | Number: u256, 15 | } 16 | pub fn __MY_ENUM_encoded_type() { 17 | println!( 18 | "\"My Enum\"(\"Token Amount\"(\"TokenAmount\"),\"NFT ID\"(\"NftId\"),\"Number\"(\"u256\"))\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 19 | ); 20 | } 21 | pub const MY_ENUM_TYPE_HASH: felt252 = 22 | 0x39dd19c7e5c5f89e084b78a26200b712c6ae3265f2bae774471c588858421b7; 23 | 24 | 25 | 26 | Diagnostics: 27 | 28 | None 29 | 30 | AuxData: 31 | 32 | None 33 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__empty_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum {} 9 | pub fn __MY_ENUM_encoded_type() { 10 | println!("\"MyEnum\"()"); 11 | } 12 | pub const MY_ENUM_TYPE_HASH: felt252 = 13 | 0x1897c604dd5f60f31b69644ae79f0d5c7d00f619821e23bdb2aa1af500b2b2b; 14 | 15 | 16 | 17 | Diagnostics: 18 | 19 | None 20 | 21 | AuxData: 22 | 23 | None 24 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__empty_input.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | 9 | 10 | Diagnostics: 11 | 12 | ==== 13 | Error: No valid type found in the input. 14 | ==== 15 | 16 | AuxData: 17 | 18 | None 19 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__empty_struct.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType {} 9 | pub fn __MY_TYPE_encoded_type() { 10 | println!("\"MyType\"()"); 11 | } 12 | pub const MY_TYPE_TYPE_HASH: felt252 = 13 | 0x327757ec2f6cb159186c625a16564f2d4646453cedd039435a740f37b4ada76; 14 | 15 | 16 | 17 | Diagnostics: 18 | 19 | None 20 | 21 | AuxData: 22 | 23 | None 24 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__enum_without_explicit_variant_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1, 10 | Variant2, 11 | } 12 | pub fn __MY_ENUM_encoded_type() { 13 | println!("\"MyEnum\"(\"Variant1\"(),\"Variant2\"())"); 14 | } 15 | pub const MY_ENUM_TYPE_HASH: felt252 = 16 | 0x36c48631c34b2494d85a853680b75cdba63491190aaec1cac404f77998d799d; 17 | 18 | 19 | 20 | Diagnostics: 21 | 22 | None 23 | 24 | AuxData: 25 | 26 | None 27 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__invalid_type_hash_attribute.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | None 9 | 10 | Diagnostics: 11 | 12 | ==== 13 | Error: Invalid format for the type_hash attribute. The only valid arguments are: name, debug. 14 | ==== 15 | 16 | AuxData: 17 | 18 | None 19 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__merkletree_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | #[snip12(kind: "merkletree")] 10 | pub member: felt252, 11 | } 12 | pub fn __MY_TYPE_encoded_type() { 13 | println!("\"MyType\"(\"member\":\"merkletree\")"); 14 | } 15 | pub const MY_TYPE_TYPE_HASH: felt252 = 16 | 0x186d7d11e58c4c3b13da8a9b81ec72cf8c82a32106917255cf8801e61f9039e; 17 | 18 | 19 | 20 | Diagnostics: 21 | 22 | None 23 | 24 | AuxData: 25 | 26 | None 27 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__name_attribute.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | #[snip12(name: "Variant 1")] 10 | Variant1: (felt252, felt252, ClassHash, NftId), 11 | #[snip12(name: "Variant 2")] 12 | Variant2: Array, 13 | #[snip12(name: "Variant 3")] 14 | Variant3: Span, 15 | #[snip12(name: "Variant 4")] 16 | Variant4: (ContractAddress, TokenAmount), 17 | #[snip12(name: "Variant 5")] 18 | Variant5: Array, 19 | } 20 | pub const MY_ENUM_TYPE_HASH: felt252 = 21 | 0x3c7d0abfeb251d79dfafa4f0249bcd5f6d8c28dc3a75c25fefa455af910915; 22 | 23 | 24 | 25 | Diagnostics: 26 | 27 | None 28 | 29 | AuxData: 30 | 31 | None 32 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__potential_duplicate_types.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | // TokenAmount type contains u256, which should be resolved 10 | // and appended to the final type hash. 11 | pub token_amount: TokenAmount, 12 | pub token_amount_2: TokenAmount, 13 | pub number: u256, 14 | } 15 | pub fn __MY_TYPE_encoded_type() { 16 | println!( 17 | "\"MyType\"(\"token_amount\":\"TokenAmount\",\"token_amount_2\":\"TokenAmount\",\"number\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 18 | ); 19 | } 20 | pub const MY_TYPE_TYPE_HASH: felt252 = 21 | 0xe875ac1b5bfbe52aac3f89c302a4410a945700aca4dc2da513da7b1f2e1f00; 22 | 23 | 24 | 25 | Diagnostics: 26 | 27 | None 28 | 29 | AuxData: 30 | 31 | None 32 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__potential_duplicate_types_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | // TokenAmount type contains u256, which should be resolved 10 | // and appended to the final type hash. 11 | Variant1: TokenAmount, 12 | Variant2: TokenAmount, 13 | Variant3: u256, 14 | } 15 | pub fn __MY_ENUM_encoded_type() { 16 | println!( 17 | "\"MyEnum\"(\"Variant1\"(\"TokenAmount\"),\"Variant2\"(\"TokenAmount\"),\"Variant3\"(\"u256\"))\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 18 | ); 19 | } 20 | pub const MY_ENUM_TYPE_HASH: felt252 = 21 | 0x580e19038ec80a1955c372ce97d510e3d6cbd227c40ed680b16b7bb2a17286; 22 | 23 | 24 | 25 | Diagnostics: 26 | 27 | None 28 | 29 | AuxData: 30 | 31 | None 32 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__preset_types.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub token_amount: TokenAmount, 10 | pub nft_id: NftId, 11 | pub u256: u256, 12 | } 13 | pub fn __MY_TYPE_encoded_type() { 14 | println!( 15 | "\"MyType\"(\"token_amount\":\"TokenAmount\",\"nft_id\":\"NftId\",\"u256\":\"u256\")\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 16 | ); 17 | } 18 | pub const MY_TYPE_TYPE_HASH: felt252 = 19 | 0x270376e5e39650aab056d468f8528719f2223c64bb6bcf032f97540c474c050; 20 | 21 | 22 | 23 | Diagnostics: 24 | 25 | None 26 | 27 | AuxData: 28 | 29 | None 30 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__preset_types_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1: TokenAmount, 10 | Variant2: NftId, 11 | Variant3: u256, 12 | } 13 | pub fn __MY_ENUM_encoded_type() { 14 | println!( 15 | "\"MyEnum\"(\"Variant1\"(\"TokenAmount\"),\"Variant2\"(\"NftId\"),\"Variant3\"(\"u256\"))\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 16 | ); 17 | } 18 | pub const MY_ENUM_TYPE_HASH: felt252 = 19 | 0x3f357bdfbd3bf793be39571939399423a9396d2d28a8efcc6d8b9ca6e762651; 20 | 21 | 22 | 23 | Diagnostics: 24 | 25 | None 26 | 27 | AuxData: 28 | 29 | None 30 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__snip12_attribute_empty.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | #[snip12()] 10 | pub name: felt252, 11 | } 12 | pub fn __MY_TYPE_encoded_type() { 13 | println!("\"MyType\"(\"name\":\"felt\")"); 14 | } 15 | pub const MY_TYPE_TYPE_HASH: felt252 = 16 | 0x1c4049af415d731aa5a71e9e2807b93cc65416ba2097d6c03522132966fcfd7; 17 | 18 | 19 | 20 | Diagnostics: 21 | 22 | None 23 | 24 | AuxData: 25 | 26 | None 27 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__starknet_domain.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct StarknetDomain { 9 | #[snip12(kind: "shortstring")] 10 | pub name: felt252, 11 | #[snip12(kind: "shortstring")] 12 | pub version: felt252, 13 | #[snip12(kind: "shortstring")] 14 | pub chainId: felt252, 15 | #[snip12(kind: "shortstring")] 16 | pub revision: felt252, 17 | } 18 | pub fn __STARKNET_DOMAIN_encoded_type() { 19 | println!( 20 | "\"StarknetDomain\"(\"name\":\"shortstring\",\"version\":\"shortstring\",\"chainId\":\"shortstring\",\"revision\":\"shortstring\")", 21 | ); 22 | } 23 | pub const STARKNET_DOMAIN_TYPE_HASH: felt252 = 24 | 0x1ff2f602e42168014d405a94f75e8a93d640751d71d16311266e140d8b0a210; 25 | 26 | 27 | 28 | Diagnostics: 29 | 30 | None 31 | 32 | AuxData: 33 | 34 | None 35 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_array.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub member1: Array, 10 | pub member2: Array, 11 | pub member3: Array, 12 | pub member4: Array, 13 | pub member5: Array, 14 | pub member6: Array, 15 | } 16 | pub fn __MY_TYPE_encoded_type() { 17 | println!( 18 | "\"MyType\"(\"member1\":\"felt*\",\"member2\":\"TokenAmount*\",\"member3\":\"ClassHash*\",\"member4\":\"ContractAddress*\",\"member5\":\"u128*\",\"member6\":\"i128*\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 19 | ); 20 | } 21 | pub const MY_TYPE_TYPE_HASH: felt252 = 22 | 0x30fa88806049cfd082251e0819a2409264b2897bf51b151884cbfa52cafcb7c; 23 | 24 | 25 | 26 | Diagnostics: 27 | 28 | None 29 | 30 | AuxData: 31 | 32 | None 33 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_empty_tuple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub member: (), 10 | } 11 | pub fn __MY_TYPE_encoded_type() { 12 | println!("\"MyType\"(\"member\":\"()\")"); 13 | } 14 | pub const MY_TYPE_TYPE_HASH: felt252 = 15 | 0x27dc67214e5fe45b79bb74947d1d899cff84e58851eeba422efe5e70cbdf0cc; 16 | 17 | 18 | 19 | Diagnostics: 20 | 21 | None 22 | 23 | AuxData: 24 | 25 | None 26 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_empty_tuple_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1: TokenAmount, 10 | Variant2: (), 11 | } 12 | pub fn __MY_ENUM_encoded_type() { 13 | println!( 14 | "\"MyEnum\"(\"Variant1\"(\"TokenAmount\"),\"Variant2\"())\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 15 | ); 16 | } 17 | pub const MY_ENUM_TYPE_HASH: felt252 = 18 | 0x2c99e0ed586af347aabc3d1db03bf4fbb670934be05f0565c8a588a2997af9d; 19 | 20 | 21 | 22 | Diagnostics: 23 | 24 | None 25 | 26 | AuxData: 27 | 28 | None 29 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_inner_custom_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub name: felt252, 10 | pub version: felt252, 11 | pub chain_id: felt252, 12 | pub revision: felt252, 13 | pub member: InnerCustomType, 14 | } 15 | 16 | 17 | Diagnostics: 18 | 19 | ==== 20 | Error: Inner custom types are not supported yet. 21 | ==== 22 | 23 | AuxData: 24 | 25 | None 26 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_inner_starknet_domain.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub starknet_domain: StarknetDomain, 10 | } 11 | pub fn __MY_TYPE_encoded_type() { 12 | println!( 13 | "\"MyType\"(\"starknet_domain\":\"StarknetDomain\")\"StarknetDomain\"(\"name\":\"shortstring\",\"version\":\"shortstring\",\"chainId\":\"shortstring\",\"revision\":\"shortstring\")", 14 | ); 15 | } 16 | pub const MY_TYPE_TYPE_HASH: felt252 = 17 | 0x4e8c31d893ad8a47bfb12367edb6b0970c83ec63f8cb08dbd3be1ce792e794; 18 | 19 | 20 | 21 | Diagnostics: 22 | 23 | None 24 | 25 | AuxData: 26 | 27 | None 28 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_inner_u256_type.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | // TokenAmount type contains u256, which should be resolved 10 | // and appended to the final type hash. 11 | pub token_amount: TokenAmount, 12 | } 13 | pub fn __MY_TYPE_encoded_type() { 14 | println!( 15 | "\"MyType\"(\"token_amount\":\"TokenAmount\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 16 | ); 17 | } 18 | pub const MY_TYPE_TYPE_HASH: felt252 = 19 | 0x1248ca8b0575139b58bf84ac03ea3c6c60525abc22d2525869f395b08986987; 20 | 21 | 22 | 23 | Diagnostics: 24 | 25 | None 26 | 27 | AuxData: 28 | 29 | None 30 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_inner_u256_type_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | // TokenAmount type contains u256, which should be resolved 10 | // and appended to the final type hash. 11 | Variant1: TokenAmount, 12 | } 13 | pub fn __MY_ENUM_encoded_type() { 14 | println!( 15 | "\"MyEnum\"(\"Variant1\"(\"TokenAmount\"))\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 16 | ); 17 | } 18 | pub const MY_ENUM_TYPE_HASH: felt252 = 19 | 0x201d3284c9c6ce70ed7004c44aca1428c630a2cf4f9994f3fceb11e48fdba66; 20 | 21 | 22 | 23 | Diagnostics: 24 | 25 | None 26 | 27 | AuxData: 28 | 29 | None 30 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_span.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub member1: Span, 10 | pub member2: Span, 11 | pub member3: Span, 12 | pub member4: Span, 13 | pub member5: Span, 14 | pub member6: Span, 15 | } 16 | pub fn __MY_TYPE_encoded_type() { 17 | println!( 18 | "\"MyType\"(\"member1\":\"felt*\",\"member2\":\"TokenAmount*\",\"member3\":\"ClassHash*\",\"member4\":\"ContractAddress*\",\"member5\":\"u128*\",\"member6\":\"i128*\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 19 | ); 20 | } 21 | pub const MY_TYPE_TYPE_HASH: felt252 = 22 | 0x30fa88806049cfd082251e0819a2409264b2897bf51b151884cbfa52cafcb7c; 23 | 24 | 25 | 26 | Diagnostics: 27 | 28 | None 29 | 30 | AuxData: 31 | 32 | None 33 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_tuple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | pub member: (felt252, felt252, ClassHash, NftId), 10 | } 11 | pub fn __MY_TYPE_encoded_type() { 12 | println!( 13 | "\"MyType\"(\"member\":\"(felt,felt,ClassHash,NftId)\")\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 14 | ); 15 | } 16 | pub const MY_TYPE_TYPE_HASH: felt252 = 17 | 0x32b623f35bc25f0f97eee3433f4e5f3308f726efbb37b7b0ce8e3a74a0aa5a4; 18 | 19 | 20 | 21 | Diagnostics: 22 | 23 | None 24 | 25 | AuxData: 26 | 27 | None 28 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_tuple_and_attribute.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub struct MyType { 9 | #[snip12(kind: "(shortstring, felt252, ClassHash, NftId)")] 10 | pub member: (felt252, felt252, ClassHash, NftId), 11 | } 12 | pub fn __MY_TYPE_encoded_type() { 13 | println!( 14 | "\"MyType\"(\"member\":\"(shortstring,felt,ClassHash,NftId)\")\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 15 | ); 16 | } 17 | pub const MY_TYPE_TYPE_HASH: felt252 = 18 | 0x1f21a98e964603cd3fc7965e01b244816345e1b5bc757218fa49c62e436b12b; 19 | 20 | 21 | 22 | Diagnostics: 23 | 24 | None 25 | 26 | AuxData: 27 | 28 | None 29 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_type_hash__with_tuple_enum.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_type_hash.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | pub enum MyEnum { 9 | Variant1: (felt252, felt252, ClassHash, NftId), 10 | Variant2: TokenAmount, 11 | Variant3: (ContractAddress,), 12 | } 13 | pub fn __MY_ENUM_encoded_type() { 14 | println!( 15 | "\"MyEnum\"(\"Variant1\"(\"felt\",\"felt\",\"ClassHash\",\"NftId\"),\"Variant2\"(\"TokenAmount\"),\"Variant3\"(\"ContractAddress\"))\"NftId\"(\"collection_address\":\"ContractAddress\",\"token_id\":\"u256\")\"TokenAmount\"(\"token_address\":\"ContractAddress\",\"amount\":\"u256\")\"u256\"(\"low\":\"u128\",\"high\":\"u128\")", 16 | ); 17 | } 18 | pub const MY_ENUM_TYPE_HASH: felt252 = 19 | 0x3ee411b33d3a414d1256c0804501e31291dd678ee15b25127994dc5dd5a4dd7; 20 | 21 | 22 | 23 | Diagnostics: 24 | 25 | None 26 | 27 | AuxData: 28 | 29 | None 30 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_access_control.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod Contract { 10 | use openzeppelin_access::accesscontrol::DEFAULT_ADMIN_ROLE; 11 | use starknet::ContractAddress; 12 | 13 | #[storage] 14 | pub struct Storage { 15 | #[substorage(v0)] 16 | pub access_control: AccessControlComponent::Storage, 17 | } 18 | 19 | #[constructor] 20 | fn constructor(ref self: ContractState, default_admin: ContractAddress) { 21 | self.access_control.initializer(); 22 | 23 | self.access_control._grant_role(DEFAULT_ADMIN_ROLE, default_admin); 24 | } 25 | use openzeppelin_access::accesscontrol::AccessControlComponent; 26 | 27 | component!(path: AccessControlComponent, storage: access_control, event: AccessControlEvent); 28 | 29 | impl AccessControlInternalImpl = AccessControlComponent::InternalImpl; 30 | 31 | #[event] 32 | #[derive(Drop, starknet::Event)] 33 | enum Event { 34 | #[flat] 35 | AccessControlEvent: AccessControlComponent::Event, 36 | } 37 | } 38 | 39 | 40 | Diagnostics: 41 | 42 | None 43 | 44 | AuxData: 45 | 46 | None 47 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_account.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract(account)] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub account: AccountComponent::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState, public_key: felt252) { 18 | self.account.initializer(public_key); 19 | } 20 | use openzeppelin_account::AccountComponent; 21 | 22 | component!(path: AccountComponent, storage: account, event: AccountEvent); 23 | 24 | impl AccountInternalImpl = AccountComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | AccountEvent: AccountComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | None 38 | 39 | AuxData: 40 | 41 | None 42 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_account_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub account: AccountComponent::Storage, 14 | } 15 | use openzeppelin_account::AccountComponent; 16 | 17 | component!(path: AccountComponent, storage: account, event: AccountEvent); 18 | 19 | impl AccountInternalImpl = AccountComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | AccountEvent: AccountComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the initializers for the following components are missing: 34 | 35 | Account 36 | 37 | This may lead to unexpected behavior. 38 | We recommend adding the corresponding initializer calls to the constructor. 39 | ==== 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc1155.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::erc1155::ERC1155HooksEmptyImpl; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub erc1155: ERC1155Component::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState) { 20 | self.erc1155.initializer(""); 21 | } 22 | use openzeppelin_token::erc1155::ERC1155Component; 23 | 24 | component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event); 25 | 26 | impl ERC1155InternalImpl = ERC1155Component::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | ERC1155Event: ERC1155Component::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc1155_no_hooks_impl.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc1155: ERC1155Component::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.erc1155.initializer(""); 19 | } 20 | use openzeppelin_token::erc1155::ERC1155Component; 21 | 22 | component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event); 23 | 24 | impl ERC1155InternalImpl = ERC1155Component::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | ERC1155Event: ERC1155Component::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: The ERC1155 component requires an implementation of the ERC1155HooksTrait in scope and 39 | it looks like it is missing. 40 | 41 | You can use the ERC1155HooksEmptyImpl implementation by importing it: 42 | 43 | `use openzeppelin_token::erc1155::ERC1155HooksEmptyImpl;` 44 | ==== 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc1155_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::erc1155::ERC1155HooksEmptyImpl; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub erc1155: ERC1155Component::Storage, 16 | } 17 | use openzeppelin_token::erc1155::ERC1155Component; 18 | 19 | component!(path: ERC1155Component, storage: erc1155, event: ERC1155Event); 20 | 21 | impl ERC1155InternalImpl = ERC1155Component::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ERC1155Event: ERC1155Component::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | ==== 35 | Warning: It looks like the initializers for the following components are missing: 36 | 37 | ERC1155 38 | 39 | This may lead to unexpected behavior. 40 | We recommend adding the corresponding initializer calls to the constructor. 41 | ==== 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc1155_receiver.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc1155_receiver: ERC1155ReceiverComponent::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.erc1155_receiver.initializer(); 19 | } 20 | use openzeppelin_token::erc1155::ERC1155ReceiverComponent; 21 | 22 | component!( 23 | path: ERC1155ReceiverComponent, storage: erc1155_receiver, event: ERC1155ReceiverEvent, 24 | ); 25 | 26 | impl ERC1155ReceiverInternalImpl = ERC1155ReceiverComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | ERC1155ReceiverEvent: ERC1155ReceiverComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc1155_receiver_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc1155_receiver: ERC1155ReceiverComponent::Storage, 14 | } 15 | use openzeppelin_token::erc1155::ERC1155ReceiverComponent; 16 | 17 | component!( 18 | path: ERC1155ReceiverComponent, storage: erc1155_receiver, event: ERC1155ReceiverEvent, 19 | ); 20 | 21 | impl ERC1155ReceiverInternalImpl = ERC1155ReceiverComponent::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ERC1155ReceiverEvent: ERC1155ReceiverComponent::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | ==== 35 | Warning: It looks like the initializers for the following components are missing: 36 | 37 | ERC1155Receiver 38 | 39 | This may lead to unexpected behavior. 40 | We recommend adding the corresponding initializer calls to the constructor. 41 | ==== 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc20.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyToken { 10 | use openzeppelin_token::erc20::{DefaultConfig, ERC20HooksEmptyImpl}; 11 | use starknet::ContractAddress; 12 | 13 | #[storage] 14 | pub struct Storage { 15 | #[substorage(v0)] 16 | pub erc20: ERC20Component::Storage, 17 | } 18 | 19 | #[constructor] 20 | fn constructor(ref self: ContractState) { 21 | self.erc20.initializer("MyToken", "MTK"); 22 | } 23 | use openzeppelin_token::erc20::ERC20Component; 24 | 25 | component!(path: ERC20Component, storage: erc20, event: ERC20Event); 26 | 27 | impl ERC20InternalImpl = ERC20Component::InternalImpl; 28 | 29 | #[event] 30 | #[derive(Drop, starknet::Event)] 31 | enum Event { 32 | #[flat] 33 | ERC20Event: ERC20Component::Event, 34 | } 35 | } 36 | 37 | 38 | Diagnostics: 39 | 40 | None 41 | 42 | AuxData: 43 | 44 | None 45 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc20_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyToken { 10 | use openzeppelin_token::erc20::{DefaultConfig, ERC20HooksEmptyImpl}; 11 | use starknet::ContractAddress; 12 | 13 | #[storage] 14 | pub struct Storage { 15 | #[substorage(v0)] 16 | pub erc20: ERC20Component::Storage, 17 | } 18 | 19 | #[constructor] 20 | fn constructor(ref self: ContractState) {} 21 | use openzeppelin_token::erc20::ERC20Component; 22 | 23 | component!(path: ERC20Component, storage: erc20, event: ERC20Event); 24 | 25 | impl ERC20InternalImpl = ERC20Component::InternalImpl; 26 | 27 | #[event] 28 | #[derive(Drop, starknet::Event)] 29 | enum Event { 30 | #[flat] 31 | ERC20Event: ERC20Component::Event, 32 | } 33 | } 34 | 35 | 36 | Diagnostics: 37 | 38 | ==== 39 | Warning: It looks like the initializers for the following components are missing: 40 | 41 | ERC20 42 | 43 | This may lead to unexpected behavior. 44 | We recommend adding the corresponding initializer calls to the constructor. 45 | ==== 46 | 47 | AuxData: 48 | 49 | None 50 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc2981.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::common::erc2981::DefaultConfig; 11 | use starknet::ContractAddress; 12 | 13 | #[storage] 14 | pub struct Storage { 15 | #[substorage(v0)] 16 | pub erc2981: ERC2981Component::Storage, 17 | } 18 | 19 | #[constructor] 20 | fn constructor(ref self: ContractState, default_royalty_receiver: ContractAddress) { 21 | self.erc2981.initializer(default_royalty_receiver, 0); 22 | } 23 | use openzeppelin_token::common::erc2981::ERC2981Component; 24 | 25 | component!(path: ERC2981Component, storage: erc2981, event: ERC2981Event); 26 | 27 | impl ERC2981InternalImpl = ERC2981Component::InternalImpl; 28 | 29 | #[event] 30 | #[derive(Drop, starknet::Event)] 31 | enum Event { 32 | #[flat] 33 | ERC2981Event: ERC2981Component::Event, 34 | } 35 | } 36 | 37 | 38 | Diagnostics: 39 | 40 | None 41 | 42 | AuxData: 43 | 44 | None 45 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc2981_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::common::erc2981::DefaultConfig; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub erc2981: ERC2981Component::Storage, 16 | } 17 | use openzeppelin_token::common::erc2981::ERC2981Component; 18 | 19 | component!(path: ERC2981Component, storage: erc2981, event: ERC2981Event); 20 | 21 | impl ERC2981InternalImpl = ERC2981Component::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ERC2981Event: ERC2981Component::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | ==== 35 | Warning: It looks like the initializers for the following components are missing: 36 | 37 | ERC2981 38 | 39 | This may lead to unexpected behavior. 40 | We recommend adding the corresponding initializer calls to the constructor. 41 | ==== 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::erc721::ERC721HooksEmptyImpl; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub erc721: ERC721Component::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState) { 20 | self.erc721.initializer("MyToken", "MTK", ""); 21 | } 22 | use openzeppelin_token::erc721::ERC721Component; 23 | 24 | component!(path: ERC721Component, storage: erc721, event: ERC721Event); 25 | 26 | impl ERC721InternalImpl = ERC721Component::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | ERC721Event: ERC721Component::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_enumerable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc721_enumerable: ERC721EnumerableComponent::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.erc721_enumerable.initializer(); 19 | } 20 | use openzeppelin_token::erc721::extensions::ERC721EnumerableComponent; 21 | 22 | component!( 23 | path: ERC721EnumerableComponent, storage: erc721_enumerable, event: ERC721EnumerableEvent, 24 | ); 25 | 26 | impl ERC721EnumerableInternalImpl = ERC721EnumerableComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | ERC721EnumerableEvent: ERC721EnumerableComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_enumerable_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc721_enumerable: ERC721EnumerableComponent::Storage, 14 | } 15 | use openzeppelin_token::erc721::extensions::ERC721EnumerableComponent; 16 | 17 | component!( 18 | path: ERC721EnumerableComponent, storage: erc721_enumerable, event: ERC721EnumerableEvent, 19 | ); 20 | 21 | impl ERC721EnumerableInternalImpl = ERC721EnumerableComponent::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ERC721EnumerableEvent: ERC721EnumerableComponent::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | ==== 35 | Warning: It looks like the initializers for the following components are missing: 36 | 37 | ERC721Enumerable 38 | 39 | This may lead to unexpected behavior. 40 | We recommend adding the corresponding initializer calls to the constructor. 41 | ==== 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_no_hooks_impl.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc721: ERC721Component::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.erc721.initializer("MyToken", "MTK", ""); 19 | } 20 | use openzeppelin_token::erc721::ERC721Component; 21 | 22 | component!(path: ERC721Component, storage: erc721, event: ERC721Event); 23 | 24 | impl ERC721InternalImpl = ERC721Component::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | ERC721Event: ERC721Component::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: The ERC721 component requires an implementation of the ERC721HooksTrait in scope and 39 | it looks like it is missing. 40 | 41 | You can use the ERC721HooksEmptyImpl implementation by importing it: 42 | 43 | `use openzeppelin_token::erc721::ERC721HooksEmptyImpl;` 44 | ==== 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_token::erc721::ERC721HooksEmptyImpl; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub erc721: ERC721Component::Storage, 16 | } 17 | use openzeppelin_token::erc721::ERC721Component; 18 | 19 | component!(path: ERC721Component, storage: erc721, event: ERC721Event); 20 | 21 | impl ERC721InternalImpl = ERC721Component::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ERC721Event: ERC721Component::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | ==== 35 | Warning: It looks like the initializers for the following components are missing: 36 | 37 | ERC721 38 | 39 | This may lead to unexpected behavior. 40 | We recommend adding the corresponding initializer calls to the constructor. 41 | ==== 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_receiver.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc721_receiver: ERC721ReceiverComponent::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.erc721_receiver.initializer(); 19 | } 20 | use openzeppelin_token::erc721::ERC721ReceiverComponent; 21 | 22 | component!(path: ERC721ReceiverComponent, storage: erc721_receiver, event: ERC721ReceiverEvent); 23 | 24 | impl ERC721ReceiverInternalImpl = ERC721ReceiverComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | ERC721ReceiverEvent: ERC721ReceiverComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | None 38 | 39 | AuxData: 40 | 41 | None 42 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_erc721_receiver_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub erc721_receiver: ERC721ReceiverComponent::Storage, 14 | } 15 | use openzeppelin_token::erc721::ERC721ReceiverComponent; 16 | 17 | component!(path: ERC721ReceiverComponent, storage: erc721_receiver, event: ERC721ReceiverEvent); 18 | 19 | impl ERC721ReceiverInternalImpl = ERC721ReceiverComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | ERC721ReceiverEvent: ERC721ReceiverComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the initializers for the following components are missing: 34 | 35 | ERC721Receiver 36 | 37 | This may lead to unexpected behavior. 38 | We recommend adding the corresponding initializer calls to the constructor. 39 | ==== 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_eth_account.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract(account)] 9 | pub mod MyContract { 10 | use openzeppelin_account::interface::EthPublicKey; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub eth_account: EthAccountComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState, public_key: EthPublicKey) { 20 | self.eth_account.initializer(public_key); 21 | } 22 | use openzeppelin_account::EthAccountComponent; 23 | 24 | component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent); 25 | 26 | impl EthAccountInternalImpl = EthAccountComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | EthAccountEvent: EthAccountComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_eth_account_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract(account)] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub eth_account: EthAccountComponent::Storage, 14 | } 15 | use openzeppelin_account::EthAccountComponent; 16 | 17 | component!(path: EthAccountComponent, storage: eth_account, event: EthAccountEvent); 18 | 19 | impl EthAccountInternalImpl = EthAccountComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | EthAccountEvent: EthAccountComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the initializers for the following components are missing: 34 | 35 | EthAccount 36 | 37 | This may lead to unexpected behavior. 38 | We recommend adding the corresponding initializer calls to the constructor. 39 | ==== 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_governance::governor::DefaultConfig; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub governor: GovernorComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState) { 20 | self.governor.initializer(); 21 | } 22 | use openzeppelin_governance::governor::GovernorComponent; 23 | 24 | component!(path: GovernorComponent, storage: governor, event: GovernorEvent); 25 | 26 | impl GovernorInternalImpl = GovernorComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | GovernorEvent: GovernorComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_core_execution.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub governor_core_execution: GovernorCoreExecutionComponent::Storage, 14 | } 15 | use openzeppelin_governance::governor::extensions::GovernorCoreExecutionComponent; 16 | 17 | component!( 18 | path: GovernorCoreExecutionComponent, 19 | storage: governor_core_execution, 20 | event: GovernorCoreExecutionEvent, 21 | ); 22 | 23 | impl GovernorCoreExecutionGovernorExecution = 24 | GovernorCoreExecutionComponent::GovernorExecution; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | GovernorCoreExecutionEvent: GovernorCoreExecutionComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | None 38 | 39 | AuxData: 40 | 41 | None 42 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_counting_simple.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub governor_counting_simple: GovernorCountingSimpleComponent::Storage, 14 | } 15 | use openzeppelin_governance::governor::extensions::GovernorCountingSimpleComponent; 16 | 17 | component!( 18 | path: GovernorCountingSimpleComponent, 19 | storage: governor_counting_simple, 20 | event: GovernorCountingSimpleEvent, 21 | ); 22 | 23 | impl GovernorCountingSimpleGovernorCounting = 24 | GovernorCountingSimpleComponent::GovernorCounting; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | GovernorCountingSimpleEvent: GovernorCountingSimpleComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | None 38 | 39 | AuxData: 40 | 41 | None 42 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_no_config.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub governor: GovernorComponent::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.governor.initializer(); 19 | } 20 | use openzeppelin_governance::governor::GovernorComponent; 21 | 22 | component!(path: GovernorComponent, storage: governor, event: GovernorEvent); 23 | 24 | impl GovernorInternalImpl = GovernorComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | GovernorEvent: GovernorComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: The Governor component requires an ImmutableConfig implementation in scope and 39 | it looks like it is missing. 40 | 41 | You can use the default implementation by importing it: 42 | 43 | `use openzeppelin_governance::governor::DefaultConfig;` 44 | ==== 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_governance::governor::DefaultConfig; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub governor: GovernorComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState) {} 20 | use openzeppelin_governance::governor::GovernorComponent; 21 | 22 | component!(path: GovernorComponent, storage: governor, event: GovernorEvent); 23 | 24 | impl GovernorInternalImpl = GovernorComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | GovernorEvent: GovernorComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: It looks like the initializers for the following components are missing: 39 | 40 | Governor 41 | 42 | This may lead to unexpected behavior. 43 | We recommend adding the corresponding initializer calls to the constructor. 44 | ==== 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_votes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use starknet::ContractAddress; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub governor_votes: GovernorVotesComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState, votes_token: ContractAddress) { 20 | self.governor_votes.initializer(votes_token); 21 | } 22 | use openzeppelin_governance::governor::extensions::GovernorVotesComponent; 23 | 24 | component!(path: GovernorVotesComponent, storage: governor_votes, event: GovernorVotesEvent); 25 | 26 | impl GovernorVotesInternalImpl = GovernorVotesComponent::InternalImpl; 27 | impl GovernorVotesGovernorVotes = GovernorVotesComponent::GovernorVotes; 28 | 29 | #[event] 30 | #[derive(Drop, starknet::Event)] 31 | enum Event { 32 | #[flat] 33 | GovernorVotesEvent: GovernorVotesComponent::Event, 34 | } 35 | } 36 | 37 | 38 | Diagnostics: 39 | 40 | None 41 | 42 | AuxData: 43 | 44 | None 45 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_governor_votes_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub governor_votes: GovernorVotesComponent::Storage, 14 | } 15 | use openzeppelin_governance::governor::extensions::GovernorVotesComponent; 16 | 17 | component!(path: GovernorVotesComponent, storage: governor_votes, event: GovernorVotesEvent); 18 | 19 | impl GovernorVotesInternalImpl = GovernorVotesComponent::InternalImpl; 20 | impl GovernorVotesGovernorVotes = GovernorVotesComponent::GovernorVotes; 21 | 22 | #[event] 23 | #[derive(Drop, starknet::Event)] 24 | enum Event { 25 | #[flat] 26 | GovernorVotesEvent: GovernorVotesComponent::Event, 27 | } 28 | } 29 | 30 | 31 | Diagnostics: 32 | 33 | ==== 34 | Warning: It looks like the initializers for the following components are missing: 35 | 36 | GovernorVotes 37 | 38 | This may lead to unexpected behavior. 39 | We recommend adding the corresponding initializer calls to the constructor. 40 | ==== 41 | 42 | AuxData: 43 | 44 | None 45 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_initializable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub initializable: InitializableComponent::Storage, 14 | } 15 | 16 | #[generate_trait] 17 | #[abi(per_item)] 18 | impl ExternalImpl of ExternalTrait { 19 | #[external(v0)] 20 | fn initialize(ref self: ContractState) { 21 | self.initializable.initialize(); 22 | } 23 | } 24 | use openzeppelin_security::InitializableComponent; 25 | 26 | component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); 27 | 28 | impl InitializableInternalImpl = InitializableComponent::InternalImpl; 29 | 30 | #[event] 31 | #[derive(Drop, starknet::Event)] 32 | enum Event { 33 | #[flat] 34 | InitializableEvent: InitializableComponent::Event, 35 | } 36 | } 37 | 38 | 39 | Diagnostics: 40 | 41 | None 42 | 43 | AuxData: 44 | 45 | None 46 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_initializable_no_initialize_call.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub initializable: InitializableComponent::Storage, 14 | } 15 | use openzeppelin_security::InitializableComponent; 16 | 17 | component!(path: InitializableComponent, storage: initializable, event: InitializableEvent); 18 | 19 | impl InitializableInternalImpl = InitializableComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | InitializableEvent: InitializableComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the `self.initializable.initialize()` function is not used in the contract. If 34 | this is intentional, you may consider removing the Initializable component. 35 | ==== 36 | 37 | AuxData: 38 | 39 | None 40 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_invalid_component.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | None 9 | 10 | Diagnostics: 11 | 12 | ==== 13 | Error: ERC6000 is not in the list of allowed components. 14 | ==== 15 | 16 | AuxData: 17 | 18 | None 19 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_multisig.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use starknet::ContractAddress; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub multisig: MultisigComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState, quorum: u32, signers: Span) { 20 | self.multisig.initializer(quorum, signers); 21 | } 22 | use openzeppelin_governance::multisig::MultisigComponent; 23 | 24 | component!(path: MultisigComponent, storage: multisig, event: MultisigEvent); 25 | 26 | impl MultisigInternalImpl = MultisigComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | MultisigEvent: MultisigComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_multisig_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub multisig: MultisigComponent::Storage, 14 | } 15 | use openzeppelin_governance::multisig::MultisigComponent; 16 | 17 | component!(path: MultisigComponent, storage: multisig, event: MultisigEvent); 18 | 19 | impl MultisigInternalImpl = MultisigComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | MultisigEvent: MultisigComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the initializers for the following components are missing: 34 | 35 | Multisig 36 | 37 | This may lead to unexpected behavior. 38 | We recommend adding the corresponding initializer calls to the constructor. 39 | ==== 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_no_body.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | None 9 | 10 | Diagnostics: 11 | 12 | ==== 13 | Error: Contract module must have a body. 14 | ==== 15 | 16 | AuxData: 17 | 18 | None 19 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_no_components.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage {} 12 | 13 | 14 | #[event] 15 | #[derive(Drop, starknet::Event)] 16 | enum Event {} 17 | } 18 | 19 | 20 | Diagnostics: 21 | 22 | None 23 | 24 | AuxData: 25 | 26 | None 27 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_no_contract_attribute.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | None 9 | 10 | Diagnostics: 11 | 12 | ==== 13 | Error: Contract module must have the `#[starknet::contract]` attribute. 14 | ==== 15 | 16 | AuxData: 17 | 18 | None 19 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_nonces.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub nonces: NoncesComponent::Storage, 14 | } 15 | use openzeppelin_utils::nonces::NoncesComponent; 16 | 17 | component!(path: NoncesComponent, storage: nonces, event: NoncesEvent); 18 | 19 | impl NoncesInternalImpl = NoncesComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | NoncesEvent: NoncesComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | None 33 | 34 | AuxData: 35 | 36 | None 37 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_ownable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod Owned { 10 | use starknet::ContractAddress; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub ownable: OwnableComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState, owner: ContractAddress) { 20 | self.ownable.initializer(owner); 21 | } 22 | use openzeppelin_access::ownable::OwnableComponent; 23 | 24 | component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); 25 | 26 | impl OwnableInternalImpl = OwnableComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | OwnableEvent: OwnableComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_ownable_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod Owned { 10 | use starknet::ContractAddress; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub ownable: OwnableComponent::Storage, 16 | } 17 | 18 | #[constructor] 19 | fn constructor(ref self: ContractState) {} 20 | use openzeppelin_access::ownable::OwnableComponent; 21 | 22 | component!(path: OwnableComponent, storage: ownable, event: OwnableEvent); 23 | 24 | impl OwnableInternalImpl = OwnableComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | OwnableEvent: OwnableComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: It looks like the initializers for the following components are missing: 39 | 40 | Ownable 41 | 42 | This may lead to unexpected behavior. 43 | We recommend adding the corresponding initializer calls to the constructor. 44 | ==== 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_pausable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub pausable: PausableComponent::Storage, 14 | } 15 | 16 | #[generate_trait] 17 | #[abi(per_item)] 18 | impl ExternalImpl of ExternalTrait { 19 | #[external(v0)] 20 | fn pause(ref self: ContractState) { 21 | self.pausable.pause(); 22 | } 23 | 24 | #[external(v0)] 25 | fn unpause(ref self: ContractState) { 26 | self.pausable.unpause(); 27 | } 28 | } 29 | use openzeppelin_security::PausableComponent; 30 | 31 | component!(path: PausableComponent, storage: pausable, event: PausableEvent); 32 | 33 | impl PausableInternalImpl = PausableComponent::InternalImpl; 34 | 35 | #[event] 36 | #[derive(Drop, starknet::Event)] 37 | enum Event { 38 | #[flat] 39 | PausableEvent: PausableComponent::Event, 40 | } 41 | } 42 | 43 | 44 | Diagnostics: 45 | 46 | None 47 | 48 | AuxData: 49 | 50 | None 51 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_pausable_no_pause_or_unpause_call.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub pausable: PausableComponent::Storage, 14 | } 15 | use openzeppelin_security::PausableComponent; 16 | 17 | component!(path: PausableComponent, storage: pausable, event: PausableEvent); 18 | 19 | impl PausableInternalImpl = PausableComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | PausableEvent: PausableComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the `self.pausable.pause()` and `self.pausable.unpause()` functions are not used in the contract. If 34 | this is intentional, you may consider removing the Pausable component. 35 | ==== 36 | 37 | AuxData: 38 | 39 | None 40 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_reentrancy_guard.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub reentrancy_guard: ReentrancyGuardComponent::Storage, 14 | } 15 | use openzeppelin_security::ReentrancyGuardComponent; 16 | 17 | component!( 18 | path: ReentrancyGuardComponent, storage: reentrancy_guard, event: ReentrancyGuardEvent, 19 | ); 20 | 21 | impl ReentrancyGuardInternalImpl = ReentrancyGuardComponent::InternalImpl; 22 | 23 | #[event] 24 | #[derive(Drop, starknet::Event)] 25 | enum Event { 26 | #[flat] 27 | ReentrancyGuardEvent: ReentrancyGuardComponent::Event, 28 | } 29 | } 30 | 31 | 32 | Diagnostics: 33 | 34 | None 35 | 36 | AuxData: 37 | 38 | None 39 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_src5.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub src5: SRC5Component::Storage, 14 | } 15 | use openzeppelin_introspection::src5::SRC5Component; 16 | 17 | component!(path: SRC5Component, storage: src5, event: SRC5Event); 18 | 19 | impl SRC5InternalImpl = SRC5Component::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | SRC5Event: SRC5Component::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | None 33 | 34 | AuxData: 35 | 36 | None 37 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_src9.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract(src9)] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub src9: SRC9Component::Storage, 14 | } 15 | 16 | #[constructor] 17 | fn constructor(ref self: ContractState) { 18 | self.src9.initializer(); 19 | } 20 | use openzeppelin_account::extensions::SRC9Component; 21 | 22 | component!(path: SRC9Component, storage: src9, event: SRC9Event); 23 | 24 | impl SRC9InternalImpl = SRC9Component::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | SRC9Event: SRC9Component::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | None 38 | 39 | AuxData: 40 | 41 | None 42 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_src9_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub src9: SRC9Component::Storage, 14 | } 15 | use openzeppelin_account::extensions::SRC9Component; 16 | 17 | component!(path: SRC9Component, storage: src9, event: SRC9Event); 18 | 19 | impl SRC9InternalImpl = SRC9Component::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | SRC9Event: SRC9Component::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: It looks like the initializers for the following components are missing: 34 | 35 | SRC9 36 | 37 | This may lead to unexpected behavior. 38 | We recommend adding the corresponding initializer calls to the constructor. 39 | ==== 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_timelock_controller_no_initializer.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub timelock_controller: TimelockControllerComponent::Storage, 14 | } 15 | use openzeppelin_governance::timelock::TimelockControllerComponent; 16 | 17 | component!( 18 | path: TimelockControllerComponent, 19 | storage: timelock_controller, 20 | event: TimelockControllerEvent, 21 | ); 22 | 23 | impl TimelockControllerInternalImpl = TimelockControllerComponent::InternalImpl; 24 | 25 | #[event] 26 | #[derive(Drop, starknet::Event)] 27 | enum Event { 28 | #[flat] 29 | TimelockControllerEvent: TimelockControllerComponent::Event, 30 | } 31 | } 32 | 33 | 34 | Diagnostics: 35 | 36 | ==== 37 | Warning: It looks like the initializers for the following components are missing: 38 | 39 | TimelockController 40 | 41 | This may lead to unexpected behavior. 42 | We recommend adding the corresponding initializer calls to the constructor. 43 | ==== 44 | 45 | AuxData: 46 | 47 | None 48 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_upgradeable.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub upgradeable: UpgradeableComponent::Storage, 14 | } 15 | 16 | #[abi(embed_v0)] 17 | impl UpgradeableImpl of IUpgradeable { 18 | fn upgrade(ref self: ContractState, new_class_hash: ClassHash) { 19 | self.upgradeable.upgrade(new_class_hash); 20 | } 21 | } 22 | use openzeppelin_upgrades::UpgradeableComponent; 23 | 24 | component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent); 25 | 26 | impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl; 27 | 28 | #[event] 29 | #[derive(Drop, starknet::Event)] 30 | enum Event { 31 | #[flat] 32 | UpgradeableEvent: UpgradeableComponent::Event, 33 | } 34 | } 35 | 36 | 37 | Diagnostics: 38 | 39 | None 40 | 41 | AuxData: 42 | 43 | None 44 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_upgradeable_no_upgrade_call.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub upgradeable: UpgradeableComponent::Storage, 14 | } 15 | 16 | #[abi(embed_v0)] 17 | impl UpgradeableImpl of IUpgradeable { 18 | fn upgrade(ref self: ContractState, new_class_hash: ClassHash) {} 19 | } 20 | use openzeppelin_upgrades::UpgradeableComponent; 21 | 22 | component!(path: UpgradeableComponent, storage: upgradeable, event: UpgradeableEvent); 23 | 24 | impl UpgradeableInternalImpl = UpgradeableComponent::InternalImpl; 25 | 26 | #[event] 27 | #[derive(Drop, starknet::Event)] 28 | enum Event { 29 | #[flat] 30 | UpgradeableEvent: UpgradeableComponent::Event, 31 | } 32 | } 33 | 34 | 35 | Diagnostics: 36 | 37 | ==== 38 | Warning: It looks like the `self.upgradeable.upgrade(new_class_hash)` function is not used in the contract. If 39 | this is intentional, you may consider removing the Upgradeable component. 40 | ==== 41 | 42 | AuxData: 43 | 44 | None 45 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_votes.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | use openzeppelin_utils::cryptography::snip12::SNIP12Metadata; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | #[substorage(v0)] 15 | pub votes: VotesComponent::Storage, 16 | } 17 | 18 | /// Required for hash computation. 19 | pub impl SNIP12MetadataImpl of SNIP12Metadata { 20 | fn name() -> felt252 { 21 | 'DAPP_NAME' 22 | } 23 | fn version() -> felt252 { 24 | 'DAPP_VERSION' 25 | } 26 | } 27 | use openzeppelin_governance::votes::VotesComponent; 28 | 29 | component!(path: VotesComponent, storage: votes, event: VotesEvent); 30 | 31 | impl VotesInternalImpl = VotesComponent::InternalImpl; 32 | 33 | #[event] 34 | #[derive(Drop, starknet::Event)] 35 | enum Event { 36 | #[flat] 37 | VotesEvent: VotesComponent::Event, 38 | } 39 | } 40 | 41 | 42 | Diagnostics: 43 | 44 | None 45 | 46 | AuxData: 47 | 48 | None 49 | -------------------------------------------------------------------------------- /packages/macros/src/tests/snapshots/openzeppelin_macros__tests__test_with_components__with_votes_no_metadata.snap: -------------------------------------------------------------------------------- 1 | --- 2 | source: src/tests/test_with_components.rs 3 | expression: result 4 | snapshot_kind: text 5 | --- 6 | TokenStream: 7 | 8 | #[starknet::contract] 9 | pub mod MyContract { 10 | #[storage] 11 | pub struct Storage { 12 | #[substorage(v0)] 13 | pub votes: VotesComponent::Storage, 14 | } 15 | use openzeppelin_governance::votes::VotesComponent; 16 | 17 | component!(path: VotesComponent, storage: votes, event: VotesEvent); 18 | 19 | impl VotesInternalImpl = VotesComponent::InternalImpl; 20 | 21 | #[event] 22 | #[derive(Drop, starknet::Event)] 23 | enum Event { 24 | #[flat] 25 | VotesEvent: VotesComponent::Event, 26 | } 27 | } 28 | 29 | 30 | Diagnostics: 31 | 32 | ==== 33 | Warning: The Votes component requires an implementation of the SNIP12Metadata trait in scope and 34 | it looks like it is missing. 35 | ==== 36 | 37 | AuxData: 38 | 39 | None 40 | -------------------------------------------------------------------------------- /packages/macros/src/utils.rs: -------------------------------------------------------------------------------- 1 | use crate::constants::TAB; 2 | 3 | /// Generates a string with `n` tabs. 4 | pub fn tabs(n: usize) -> String { 5 | TAB.repeat(n) 6 | } 7 | -------------------------------------------------------------------------------- /packages/merkle_tree/README.md: -------------------------------------------------------------------------------- 1 | ## Merkle Tree 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/merkle-tree](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/merkle-tree) 4 | 5 | This crate provides a set of utilities for verifying Merkle Tree proofs on-chain. The tree and the proofs can be 6 | generated using this [JavaScript library](https://github.com/ericnordelo/strk-merkle-tree) both for Pedersen and Poseidon 7 | hashing algorithms. 8 | -------------------------------------------------------------------------------- /packages/merkle_tree/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_merkle_tree" 3 | readme = "README.md" 4 | keywords = [ 5 | "openzeppelin", 6 | "cairo", 7 | "merkle_tree", 8 | ] 9 | version.workspace = true 10 | edition.workspace = true 11 | cairo-version.workspace = true 12 | scarb-version.workspace = true 13 | authors.workspace = true 14 | description.workspace = true 15 | documentation.workspace = true 16 | repository.workspace = true 17 | license-file.workspace = true 18 | 19 | [tool] 20 | fmt.workspace = true 21 | scarb.workspace = true 22 | 23 | [dev-dependencies] 24 | assert_macros.workspace = true 25 | starknet.workspace = true 26 | snforge_std.workspace = true 27 | openzeppelin_testing = { path = "../testing" } 28 | -------------------------------------------------------------------------------- /packages/merkle_tree/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod hashes; 2 | pub mod merkle_proof; 3 | 4 | #[cfg(test)] 5 | mod tests; 6 | -------------------------------------------------------------------------------- /packages/merkle_tree/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod merkle_proof; 2 | mod test_hashes; 3 | -------------------------------------------------------------------------------- /packages/merkle_tree/src/tests/merkle_proof.cairo: -------------------------------------------------------------------------------- 1 | pub(crate) mod common; 2 | 3 | mod test_with_pedersen; 4 | mod test_with_poseidon; 5 | -------------------------------------------------------------------------------- /packages/merkle_tree/src/tests/merkle_proof/common.cairo: -------------------------------------------------------------------------------- 1 | use openzeppelin_testing::AsAddressTrait; 2 | use starknet::ContractAddress; 3 | 4 | #[derive(Serde, Copy, Drop, Hash)] 5 | pub(crate) struct Leaf { 6 | pub address: ContractAddress, 7 | pub amount: u128, 8 | } 9 | 10 | pub(crate) fn LEAVES() -> Span { 11 | [ 12 | Leaf { 13 | address: 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8.as_address(), 14 | amount: 0xfc104e31d098d1ab488fc1acaeb0269, 15 | }, 16 | Leaf { 17 | address: 0x7ffffffffffffffffffffffffffffffffffffffffffffffffffffc66ca5c000.as_address(), 18 | amount: 0xfc104e31d098d1ab488fc1acaeb0269, 19 | }, 20 | Leaf { 21 | address: 0x6a1f098854799debccf2d3c4059ff0f02dbfef6673dc1fcbfffffffffffffc8.as_address(), 22 | amount: 0xfc104e31d098d1ab488fc1acaeb0269, 23 | }, 24 | Leaf { 25 | address: 0xfa6541b7909bfb5e8585f1222fcf272eea352c7e0e8ed38c988bd1e2a85e82.as_address(), 26 | amount: 0xaa8565d732c2c9fa5f6c001d89d5c219, 27 | }, 28 | ] 29 | .span() 30 | } 31 | -------------------------------------------------------------------------------- /packages/merkle_tree/src/tests/test_hashes.cairo: -------------------------------------------------------------------------------- 1 | use core::hash::HashStateTrait; 2 | use core::pedersen::PedersenTrait; 3 | use core::poseidon::poseidon_hash_span; 4 | use crate::hashes::{PedersenCHasher, PoseidonCHasher}; 5 | 6 | #[test] 7 | fn test_pedersen_commutative_hash_is_commutative() { 8 | let a = 'a'; 9 | let b = 'b'; 10 | let hash = PedersenCHasher::commutative_hash(a, b); 11 | assert_eq!(hash, PedersenCHasher::commutative_hash(b, a)); 12 | } 13 | 14 | #[test] 15 | fn test_pedersen_commutative_hash_smaller_first() { 16 | let a = 'a'; 17 | let b = 'b'; 18 | 19 | let hash_state = PedersenTrait::new(0); 20 | let expected = hash_state.update(a).update(b).update(2).finalize(); 21 | 22 | let hash = PedersenCHasher::commutative_hash(b, a); 23 | assert_eq!(hash, expected); 24 | } 25 | 26 | #[test] 27 | fn test_poseidon_commutative_hash_is_commutative() { 28 | let a = 'a'; 29 | let b = 'b'; 30 | let hash = PoseidonCHasher::commutative_hash(a, b); 31 | assert_eq!(hash, PoseidonCHasher::commutative_hash(b, a)); 32 | } 33 | 34 | 35 | #[test] 36 | fn test_poseidon_commutative_hash_smaller_first() { 37 | let a = 'a'; 38 | let b = 'b'; 39 | 40 | let hash = PoseidonCHasher::commutative_hash(b, a); 41 | assert_eq!(hash, poseidon_hash_span([a, b].span())); 42 | } 43 | -------------------------------------------------------------------------------- /packages/presets/src/interfaces.cairo: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod erc1155; 3 | pub mod erc20; 4 | pub mod erc721; 5 | pub mod eth_account; 6 | pub mod vesting; 7 | 8 | pub use account::AccountUpgradeableABI; 9 | pub use account::{AccountUpgradeableABIDispatcher, AccountUpgradeableABIDispatcherTrait}; 10 | pub use erc1155::{ 11 | ERC1155UpgradeableABI, ERC1155UpgradeableABIDispatcher, ERC1155UpgradeableABIDispatcherTrait, 12 | }; 13 | pub use erc20::{ 14 | ERC20UpgradeableABI, ERC20UpgradeableABIDispatcher, ERC20UpgradeableABIDispatcherTrait, 15 | }; 16 | pub use erc721::{ 17 | ERC721UpgradeableABI, ERC721UpgradeableABIDispatcher, ERC721UpgradeableABIDispatcherTrait, 18 | }; 19 | pub use eth_account::{ 20 | EthAccountUpgradeableABI, EthAccountUpgradeableABIDispatcher, 21 | EthAccountUpgradeableABIDispatcherTrait, 22 | }; 23 | pub use vesting::{VestingWalletABI, VestingWalletABIDispatcher, VestingWalletABIDispatcherTrait}; 24 | -------------------------------------------------------------------------------- /packages/presets/src/interfaces/vesting.cairo: -------------------------------------------------------------------------------- 1 | use starknet::ContractAddress; 2 | 3 | #[starknet::interface] 4 | pub trait VestingWalletABI { 5 | // IVesting 6 | fn start(self: @TState) -> u64; 7 | fn cliff(self: @TState) -> u64; 8 | fn duration(self: @TState) -> u64; 9 | fn end(self: @TState) -> u64; 10 | fn released(self: @TState, token: ContractAddress) -> u256; 11 | fn releasable(self: @TState, token: ContractAddress) -> u256; 12 | fn vested_amount(self: @TState, token: ContractAddress, timestamp: u64) -> u256; 13 | fn release(ref self: TState, token: ContractAddress) -> u256; 14 | 15 | // IOwnable 16 | fn owner(self: @TState) -> ContractAddress; 17 | fn transfer_ownership(ref self: TState, new_owner: ContractAddress); 18 | fn renounce_ownership(ref self: TState); 19 | 20 | // IOwnableCamelOnly 21 | fn transferOwnership(ref self: TState, newOwner: ContractAddress); 22 | fn renounceOwnership(ref self: TState); 23 | } 24 | -------------------------------------------------------------------------------- /packages/presets/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod erc1155; 3 | pub mod erc20; 4 | pub mod erc721; 5 | pub mod eth_account; 6 | pub mod interfaces; 7 | 8 | #[cfg(test)] 9 | mod tests; 10 | 11 | pub mod universal_deployer; 12 | pub mod vesting; 13 | 14 | pub use account::AccountUpgradeable; 15 | pub use erc1155::ERC1155Upgradeable; 16 | pub use erc20::ERC20Upgradeable; 17 | pub use erc721::ERC721Upgradeable; 18 | pub use eth_account::EthAccountUpgradeable; 19 | pub use universal_deployer::UniversalDeployer; 20 | pub use vesting::VestingWallet; 21 | -------------------------------------------------------------------------------- /packages/presets/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_account; 2 | mod test_erc1155; 3 | mod test_erc20; 4 | mod test_erc721; 5 | mod test_eth_account; 6 | mod test_universal_deployer; 7 | mod test_vesting; 8 | -------------------------------------------------------------------------------- /packages/security/README.md: -------------------------------------------------------------------------------- 1 | ## Security 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/security](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/security) 4 | 5 | This crate provides components to handle common security-related tasks such as pausing a contract. 6 | 7 | ### Components 8 | 9 | - [`InitializableComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/security#InitializableComponent) 10 | - [`PausableComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/security#PausableComponent) 11 | - [`ReentrancyGuardComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/security#ReentrancyGuardComponent) 12 | -------------------------------------------------------------------------------- /packages/security/Scarb.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "openzeppelin_security" 4 | readme = "README.md" 5 | keywords = [ 6 | "openzeppelin", 7 | "starknet", 8 | "contracts", 9 | "security" 10 | ] 11 | version.workspace = true 12 | edition.workspace = true 13 | cairo-version.workspace = true 14 | scarb-version.workspace = true 15 | authors.workspace = true 16 | description.workspace = true 17 | documentation.workspace = true 18 | repository.workspace = true 19 | license-file.workspace = true 20 | 21 | [tool] 22 | fmt.workspace = true 23 | scarb.workspace = true 24 | 25 | [dependencies] 26 | starknet.workspace = true 27 | 28 | [dev-dependencies] 29 | assert_macros.workspace = true 30 | snforge_std.workspace = true 31 | openzeppelin_testing = { path = "../testing" } 32 | openzeppelin_test_common = { path = "../test_common" } 33 | 34 | [lib] 35 | 36 | [[target.starknet-contract]] 37 | allowed-libfuncs-list.name = "experimental" 38 | sierra = true 39 | casm = false 40 | 41 | [[test]] 42 | name = "openzeppelin_security_unittest" 43 | build-external-contracts = [ 44 | "openzeppelin_test_common::mocks::security::ReentrancyMock", 45 | "openzeppelin_test_common::mocks::security::Attacker", 46 | ] 47 | -------------------------------------------------------------------------------- /packages/security/src/interface.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (security/src/interface.cairo) 3 | 4 | #[starknet::interface] 5 | pub trait IInitializable { 6 | fn is_initialized(self: @TState) -> bool; 7 | } 8 | 9 | #[starknet::interface] 10 | pub trait IPausable { 11 | fn is_paused(self: @TState) -> bool; 12 | } 13 | -------------------------------------------------------------------------------- /packages/security/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod initializable; 2 | pub mod interface; 3 | pub mod pausable; 4 | pub mod reentrancyguard; 5 | 6 | #[cfg(test)] 7 | mod tests; 8 | 9 | pub use initializable::InitializableComponent; 10 | pub use pausable::PausableComponent; 11 | pub use reentrancyguard::ReentrancyGuardComponent; 12 | -------------------------------------------------------------------------------- /packages/security/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_initializable; 2 | mod test_pausable; 3 | mod test_reentrancyguard; 4 | -------------------------------------------------------------------------------- /packages/security/src/tests/test_initializable.cairo: -------------------------------------------------------------------------------- 1 | use openzeppelin_test_common::mocks::security::InitializableMock; 2 | use crate::InitializableComponent; 3 | use crate::InitializableComponent::{InitializableImpl, InternalImpl}; 4 | 5 | type ComponentState = InitializableComponent::ComponentState; 6 | 7 | fn COMPONENT_STATE() -> ComponentState { 8 | InitializableComponent::component_state_for_testing() 9 | } 10 | 11 | #[test] 12 | fn test_initialize() { 13 | let mut state = COMPONENT_STATE(); 14 | assert!(!state.is_initialized()); 15 | state.initialize(); 16 | assert!(state.is_initialized()); 17 | } 18 | 19 | #[test] 20 | #[should_panic(expected: 'Initializable: is initialized')] 21 | fn test_initialize_when_initialized() { 22 | let mut state = COMPONENT_STATE(); 23 | state.initialize(); 24 | state.initialize(); 25 | } 26 | -------------------------------------------------------------------------------- /packages/test_common/README.md: -------------------------------------------------------------------------------- 1 | ## Test Common 2 | 3 | This is an internal crate to centralize helpers and common modules used when testing different packages. 4 | -------------------------------------------------------------------------------- /packages/test_common/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_test_common" 3 | readme = "README.md" 4 | version.workspace = true 5 | edition.workspace = true 6 | cairo-version.workspace = true 7 | scarb-version.workspace = true 8 | authors.workspace = true 9 | description.workspace = true 10 | documentation.workspace = true 11 | repository.workspace = true 12 | license-file.workspace = true 13 | keywords.workspace = true 14 | 15 | [tool] 16 | fmt.workspace = true 17 | scarb.workspace = true 18 | 19 | [dependencies] 20 | starknet.workspace = true 21 | snforge_std.workspace = true 22 | openzeppelin_access = { path = "../access" } 23 | openzeppelin_account = { path = "../account" } 24 | openzeppelin_finance = { path = "../finance" } 25 | openzeppelin_governance = { path = "../governance" } 26 | openzeppelin_introspection = { path = "../introspection" } 27 | openzeppelin_macros = { path = "../macros" } 28 | openzeppelin_security = { path = "../security" } 29 | openzeppelin_token = { path = "../token" } 30 | openzeppelin_testing = { path = "../testing" } 31 | openzeppelin_upgrades = { path = "../upgrades" } 32 | openzeppelin_utils = { path = "../utils" } 33 | 34 | [lib] 35 | 36 | [[target.starknet-contract]] 37 | allowed-libfuncs-list.name = "experimental" 38 | sierra = true 39 | casm = false 40 | -------------------------------------------------------------------------------- /packages/test_common/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod account; 2 | pub mod erc1155; 3 | pub mod erc20; 4 | pub mod erc721; 5 | pub mod eth_account; 6 | pub mod math; 7 | pub mod mocks; 8 | pub mod ownable; 9 | pub mod upgrades; 10 | pub mod vesting; 11 | -------------------------------------------------------------------------------- /packages/test_common/src/math.cairo: -------------------------------------------------------------------------------- 1 | use core::num::traits::ops::overflowing::{OverflowingAdd, OverflowingMul, OverflowingSub}; 2 | 3 | pub fn is_overflow_add, +Drop>(x: T, y: T) -> bool { 4 | let (_, does_overflow) = x.overflowing_add(y); 5 | does_overflow 6 | } 7 | 8 | pub fn is_overflow_mul, +Drop>(x: T, y: T) -> bool { 9 | let (_, does_overflow) = x.overflowing_mul(y); 10 | does_overflow 11 | } 12 | 13 | pub fn is_overflow_sub, +Drop>(x: T, y: T) -> bool { 14 | let (_, does_overflow) = x.overflowing_sub(y); 15 | does_overflow 16 | } 17 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks.cairo: -------------------------------------------------------------------------------- 1 | pub mod access; 2 | pub mod account; 3 | pub mod checkpoint; 4 | pub mod erc1155; 5 | pub mod erc20; 6 | pub mod erc2981; 7 | pub mod erc4626; 8 | pub mod erc721; 9 | pub mod governor; 10 | pub mod multisig; 11 | pub mod non_implementing; 12 | pub mod nonces; 13 | pub mod security; 14 | pub mod simple; 15 | pub mod src5; 16 | pub mod src9; 17 | pub mod timelock; 18 | pub mod upgrades; 19 | pub mod vesting; 20 | pub mod votes; 21 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks/checkpoint.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | pub trait IMockTrace { 3 | fn push_checkpoint(ref self: TContractState, key: u64, value: u256) -> (u256, u256); 4 | fn get_latest(self: @TContractState) -> u256; 5 | fn get_at_key(self: @TContractState, key: u64) -> u256; 6 | fn get_length(self: @TContractState) -> u64; 7 | } 8 | 9 | #[starknet::contract] 10 | pub mod MockTrace { 11 | use openzeppelin_utils::structs::checkpoint::{Trace, TraceTrait}; 12 | 13 | #[storage] 14 | struct Storage { 15 | trace: Trace, 16 | } 17 | 18 | #[abi(embed_v0)] 19 | impl MockTraceImpl of super::IMockTrace { 20 | fn push_checkpoint(ref self: ContractState, key: u64, value: u256) -> (u256, u256) { 21 | self.trace.deref().push(key, value) 22 | } 23 | 24 | fn get_latest(self: @ContractState) -> u256 { 25 | self.trace.deref().latest() 26 | } 27 | 28 | fn get_at_key(self: @ContractState, key: u64) -> u256 { 29 | self.trace.deref().upper_lookup(key) 30 | } 31 | 32 | fn get_length(self: @ContractState) -> u64 { 33 | self.trace.deref().length() 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks/non_implementing.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | pub mod NonImplementingMock { 3 | #[storage] 4 | pub struct Storage {} 5 | 6 | #[external(v0)] 7 | fn nope(self: @ContractState) -> bool { 8 | false 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks/nonces.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | #[with_components(Nonces)] 3 | pub mod NoncesMock { 4 | #[abi(embed_v0)] 5 | impl NoncesImpl = NoncesComponent::NoncesImpl; 6 | 7 | #[storage] 8 | pub struct Storage {} 9 | } 10 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks/simple.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::interface] 2 | pub trait ISimpleMock { 3 | fn increase_balance(ref self: TContractState, amount: felt252) -> bool; 4 | fn set_balance(ref self: TContractState, value: felt252, panic: bool); 5 | fn get_balance(self: @TContractState) -> felt252; 6 | } 7 | 8 | #[starknet::contract] 9 | pub mod SimpleMock { 10 | use starknet::storage::{StoragePointerReadAccess, StoragePointerWriteAccess}; 11 | 12 | #[storage] 13 | pub struct Storage { 14 | pub balance: felt252, 15 | } 16 | 17 | #[abi(embed_v0)] 18 | impl SimpleMockImpl of super::ISimpleMock { 19 | fn increase_balance(ref self: ContractState, amount: felt252) -> bool { 20 | self.balance.write(self.balance.read() + amount); 21 | true 22 | } 23 | 24 | fn set_balance(ref self: ContractState, value: felt252, panic: bool) { 25 | if panic { 26 | #[allow(panic)] 27 | panic!("Some error"); 28 | } 29 | self.balance.write(value); 30 | } 31 | 32 | fn get_balance(self: @ContractState) -> felt252 { 33 | self.balance.read() 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /packages/test_common/src/mocks/src5.cairo: -------------------------------------------------------------------------------- 1 | #[starknet::contract] 2 | #[with_components(SRC5)] 3 | pub mod SRC5Mock { 4 | #[abi(embed_v0)] 5 | impl SRC5Impl = SRC5Component::SRC5Impl; 6 | 7 | #[storage] 8 | pub struct Storage {} 9 | } 10 | -------------------------------------------------------------------------------- /packages/test_common/src/ownable.cairo: -------------------------------------------------------------------------------- 1 | use openzeppelin_access::ownable::OwnableComponent; 2 | use openzeppelin_access::ownable::OwnableComponent::OwnershipTransferred; 3 | use openzeppelin_testing::{EventSpyExt, EventSpyQueue as EventSpy}; 4 | use starknet::ContractAddress; 5 | 6 | #[generate_trait] 7 | pub impl OwnableSpyHelpersImpl of OwnableSpyHelpers { 8 | fn assert_only_event_ownership_transferred( 9 | ref self: EventSpy, 10 | contract: ContractAddress, 11 | previous_owner: ContractAddress, 12 | new_owner: ContractAddress, 13 | ) { 14 | self.assert_event_ownership_transferred(contract, previous_owner, new_owner); 15 | self.assert_no_events_left_from(contract); 16 | } 17 | 18 | fn assert_event_ownership_transferred( 19 | ref self: EventSpy, 20 | contract: ContractAddress, 21 | previous_owner: ContractAddress, 22 | new_owner: ContractAddress, 23 | ) { 24 | let expected = OwnableComponent::Event::OwnershipTransferred( 25 | OwnershipTransferred { previous_owner, new_owner }, 26 | ); 27 | self.assert_emitted_single(contract, expected); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /packages/test_common/src/upgrades.cairo: -------------------------------------------------------------------------------- 1 | use openzeppelin_testing::{EventSpyExt, EventSpyQueue as EventSpy}; 2 | use openzeppelin_upgrades::UpgradeableComponent; 3 | use openzeppelin_upgrades::UpgradeableComponent::Upgraded; 4 | use starknet::{ClassHash, ContractAddress}; 5 | 6 | #[generate_trait] 7 | pub impl UpgradeableSpyHelpersImpl of UpgradeableSpyHelpers { 8 | fn assert_event_upgraded(ref self: EventSpy, contract: ContractAddress, class_hash: ClassHash) { 9 | let expected = UpgradeableComponent::Event::Upgraded(Upgraded { class_hash }); 10 | self.assert_emitted_single(contract, expected); 11 | } 12 | 13 | fn assert_only_event_upgraded( 14 | ref self: EventSpy, contract: ContractAddress, class_hash: ClassHash, 15 | ) { 16 | self.assert_event_upgraded(contract, class_hash); 17 | self.assert_no_events_left_from(contract); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /packages/test_common/src/vesting.cairo: -------------------------------------------------------------------------------- 1 | use openzeppelin_finance::vesting::VestingComponent; 2 | use openzeppelin_finance::vesting::VestingComponent::AmountReleased; 3 | use openzeppelin_testing::{EventSpyExt, EventSpyQueue as EventSpy}; 4 | use starknet::ContractAddress; 5 | 6 | #[generate_trait] 7 | pub impl VestingSpyHelpersImpl of VestingSpyHelpers { 8 | fn assert_only_event_amount_released( 9 | ref self: EventSpy, contract: ContractAddress, token: ContractAddress, amount: u256, 10 | ) { 11 | let expected = VestingComponent::Event::AmountReleased(AmountReleased { token, amount }); 12 | self.assert_only_event(contract, expected); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /packages/testing/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Changelog 4 | 5 | All notable changes to this project will be documented in this file. 6 | 7 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), 8 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 9 | 10 | ## 4.1.0 (2025-05-29) 11 | 12 | ### Changed 13 | 14 | - Bump snforge to v0.44.0 (#1439) 15 | 16 | ## 4.0.1 (2025-05-26) 17 | 18 | ### Changed 19 | 20 | - Bump snforge to v0.43.1 (#1436) 21 | 22 | ## 4.0.0 (2025-05-08) 23 | 24 | ### Changed (Breaking) 25 | 26 | - Bump snforge to v0.42.0 (#1429) 27 | 28 | ## 3.0.0 (2025-04-11) 29 | 30 | ### Changed (Breaking) 31 | 32 | - Bump snforge to v0.41.0 (#1409) 33 | - Bump snforge to v0.40.0 (#1407) 34 | 35 | ## 2.0.0 (2025-03-11) 36 | 37 | ### Changed (Breaking) 38 | 39 | - Bump snforge to v0.38.3 (#1366) 40 | - Update `openzeppelin_testing::events` logic (#1358) 41 | - Add EventSpyQueue extension to EventSpyExt 42 | - Update EventSpyExt implementation to use EventSpyQueue 43 | - Update functions to simulate constant contract addresses into values (#1373) 44 | -------------------------------------------------------------------------------- /packages/testing/README.md: -------------------------------------------------------------------------------- 1 | ## Testing 2 | 3 | > **NOTE:** This package is intended to be used only as a dev dependency. For this reason it is not included as part of the 4 | `openzeppelin` main package, and it has its own versioning not pegged to the version of the library. 5 | 6 | This crate provides various helper functions for declaring, deploying, 7 | and testing smart contracts using the `snforge` toolchain from Starknet Foundry. 8 | 9 | ### Usage 10 | 11 | The module isn’t part of the openzeppelin main package and to be accessible has to be added as a 12 | separate dependency in the Scarb.toml file: 13 | 14 | ```cairo 15 | [dev-dependencies] 16 | openzeppelin_testing = "4.1.0" 17 | ``` 18 | 19 | Then it can be imported into tests: 20 | 21 | ```cairo 22 | use openzeppelin_testing; 23 | ``` 24 | 25 | ### API documentation 26 | 27 | - [Index](https://github.com/OpenZeppelin/cairo-contracts/blob/openzeppelin_testing-v4.1.0/packages/testing/docs/openzeppelin_testing.md) 28 | - [Summary](https://github.com/OpenZeppelin/cairo-contracts/blob/openzeppelin_testing-v4.1.0/packages/testing/docs/SUMMARY.md) 29 | -------------------------------------------------------------------------------- /packages/testing/RELEASING.md: -------------------------------------------------------------------------------- 1 | # Releasing 2 | 3 | (1) Checkout the branch to be released. This will usually be `main` except in the event of a hotfix. For hotfixes, checkout the release branch you want to fix. 4 | 5 | (2) Create a new release branch (`openzeppelin_testing-v*.*.*`). 6 | 7 | ```sh 8 | git checkout -b openzeppelin_testing-v1.0.0 9 | ``` 10 | 11 | (3) Create the release entry in [the changelog](./CHANGELOG.md) with the contents of the _Unreleased_ section, which should be left empty. 12 | 13 | (4) Push and open a PR targeting `main` to carefully review the release changes. This will trigger a Github workflow that automatically bumps the version number of the package and update the docs. 14 | 15 | ```sh 16 | git push openzeppelin_testing-v1.0.0 17 | ``` 18 | 19 | (5) After getting the PR merged, the release is completed. Make sure not to delete the branch, since there's no extra 20 | tag pegged to the release. 21 | -------------------------------------------------------------------------------- /packages/testing/Scarb.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "openzeppelin_testing" 3 | readme = "README.md" 4 | keywords = [ 5 | "openzeppelin", 6 | "starknet", 7 | "testing", 8 | "utils" 9 | ] 10 | version = "4.1.0" 11 | edition.workspace = true 12 | cairo-version.workspace = true 13 | scarb-version.workspace = true 14 | authors.workspace = true 15 | description.workspace = true 16 | documentation = "https://github.com/openzeppelin/cairo-contracts/blob/openzeppelin_testing-v4.1.0/packages/testing/docs/openzeppelin_testing.md" 17 | repository.workspace = true 18 | license-file.workspace = true 19 | 20 | [tool] 21 | fmt.workspace = true 22 | scarb.workspace = true 23 | 24 | [dependencies] 25 | assert_macros.workspace = true 26 | starknet.workspace = true 27 | snforge_std.workspace = true 28 | -------------------------------------------------------------------------------- /packages/testing/docs/impls.md: -------------------------------------------------------------------------------- 1 | # Impls 2 | 3 | - [AsAddressImpl](./openzeppelin_testing-constants-AsAddressImpl.md) 4 | 5 | - [EventSpyQueueImpl](./openzeppelin_testing-events-EventSpyQueueImpl.md) 6 | 7 | - [StarkSerializedSigning](./openzeppelin_testing-signing-StarkSerializedSigning.md) 8 | 9 | - [Secp256k1SerializedSigning](./openzeppelin_testing-signing-Secp256k1SerializedSigning.md) 10 | 11 | - [Secp256r1SerializedSigning](./openzeppelin_testing-signing-Secp256r1SerializedSigning.md) 12 | 13 | -------------------------------------------------------------------------------- /packages/testing/docs/modules.md: -------------------------------------------------------------------------------- 1 | # Modules 2 | 3 | - [openzeppelin_testing](./openzeppelin_testing.md) 4 | 5 | - [common](./openzeppelin_testing-common.md) 6 | 7 | - [constants](./openzeppelin_testing-constants.md) 8 | 9 | - [deployment](./openzeppelin_testing-deployment.md) 10 | 11 | - [events](./openzeppelin_testing-events.md) 12 | 13 | - [signing](./openzeppelin_testing-signing.md) 14 | 15 | - [stark](./openzeppelin_testing-constants-stark.md) 16 | 17 | - [secp256k1](./openzeppelin_testing-constants-secp256k1.md) 18 | 19 | - [secp256r1](./openzeppelin_testing-constants-secp256r1.md) 20 | 21 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common-IntoBase16StringTrait.md: -------------------------------------------------------------------------------- 1 | # IntoBase16StringTrait 2 | 3 | Fully qualified path: `openzeppelin_testing::common::IntoBase16StringTrait` 4 | 5 |
pub trait IntoBase16StringTrait<T, +Into<T, felt252>>
6 | 7 | ## Trait functions 8 | 9 | ### into_base_16_string 10 | 11 | Fully qualified path: `openzeppelin_testing::common::IntoBase16StringTrait::into_base_16_string` 12 | 13 |
fn into_base_16_string(self: T) -> ByteArray
14 | 15 | 16 | ### into_base_16_string_no_padding 17 | 18 | Fully qualified path: `openzeppelin_testing::common::IntoBase16StringTrait::into_base_16_string_no_padding` 19 | 20 |
fn into_base_16_string_no_padding(self: T) -> ByteArray
21 | 22 | 23 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common-assert_entrypoint_not_found_error.md: -------------------------------------------------------------------------------- 1 | # assert_entrypoint_not_found_error 2 | 3 | Asserts that the syscall result of a call failed with an "Entrypoint not found" error, following the Starknet Foundry emitted error format. 4 | 5 | Fully qualified path: `openzeppelin_testing::common::assert_entrypoint_not_found_error` 6 | 7 |
pub fn assert_entrypoint_not_found_error<T, +Drop<T>>(
 8 |     result: SyscallResult<T>, selector: felt252, contract_address: ContractAddress,
 9 | )
10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common-panic_data_to_byte_array.md: -------------------------------------------------------------------------------- 1 | # panic_data_to_byte_array 2 | 3 | Converts panic data into a string (ByteArray).`panic_data` is expected to be a valid serialized byte array with an extra felt252 at the beginning, which is the BYTE_ARRAY_MAGIC. 4 | 5 | Fully qualified path: `openzeppelin_testing::common::panic_data_to_byte_array` 6 | 7 |
pub fn panic_data_to_byte_array(panic_data: Array<felt252>) -> ByteArray
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common-to_base_16_string.md: -------------------------------------------------------------------------------- 1 | # to_base_16_string 2 | 3 | Converts a `felt252` to a `base16` string padded to 66 characters including the `0x` prefix. 4 | 5 | Fully qualified path: `openzeppelin_testing::common::to_base_16_string` 6 | 7 |
pub fn to_base_16_string(value: felt252) -> ByteArray
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common-to_base_16_string_no_padding.md: -------------------------------------------------------------------------------- 1 | # to_base_16_string_no_padding 2 | 3 | Converts a `felt252` to a `base16` (hexadecimal) string without padding, but including the `0x` prefix. We need this because Starknet Foundry has a way of representing addresses and selectors that does not include 0's after `0x`. 4 | 5 | Fully qualified path: `openzeppelin_testing::common::to_base_16_string_no_padding` 6 | 7 |
pub fn to_base_16_string_no_padding(value: felt252) -> ByteArray
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-common.md: -------------------------------------------------------------------------------- 1 | # common 2 | 3 | Fully qualified path: `openzeppelin_testing::common` 4 | 5 | ## Free functions 6 | 7 | - [panic_data_to_byte_array](./openzeppelin_testing-common-panic_data_to_byte_array.md) 8 | 9 | - [to_base_16_string](./openzeppelin_testing-common-to_base_16_string.md) 10 | 11 | - [to_base_16_string_no_padding](./openzeppelin_testing-common-to_base_16_string_no_padding.md) 12 | 13 | - [assert_entrypoint_not_found_error](./openzeppelin_testing-common-assert_entrypoint_not_found_error.md) 14 | 15 | ## Traits 16 | 17 | - [IntoBase16StringTrait](./openzeppelin_testing-common-IntoBase16StringTrait.md) 18 | 19 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-ADMIN.md: -------------------------------------------------------------------------------- 1 | # ADMIN 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::ADMIN` 4 | 5 |
pub const ADMIN: ContractAddress = 'ADMIN'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-ALICE.md: -------------------------------------------------------------------------------- 1 | # ALICE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::ALICE` 4 | 5 |
pub const ALICE: ContractAddress = 'ALICE'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-AUTHORIZED.md: -------------------------------------------------------------------------------- 1 | # AUTHORIZED 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::AUTHORIZED` 4 | 5 |
pub const AUTHORIZED: ContractAddress = 'AUTHORIZED'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-AsAddressImpl.md: -------------------------------------------------------------------------------- 1 | # AsAddressImpl 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::AsAddressImpl` 4 | 5 |
pub impl AsAddressImpl of AsAddressTrait
6 | 7 | ## Impl functions 8 | 9 | ### as_address 10 | 11 | Converts a felt252 to a ContractAddress as a constant function.Requirements:`value` must be a valid contract address. 12 | 13 | Fully qualified path: `openzeppelin_testing::constants::AsAddressImpl::as_address` 14 | 15 |
const fn as_address(self: felt252) -> ContractAddress
16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-AsAddressTrait.md: -------------------------------------------------------------------------------- 1 | # AsAddressTrait 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::AsAddressTrait` 4 | 5 |
pub trait AsAddressTrait
6 | 7 | ## Trait functions 8 | 9 | ### as_address 10 | 11 | Converts a felt252 to a ContractAddress as a constant function.Requirements:`value` must be a valid contract address. 12 | 13 | Fully qualified path: `openzeppelin_testing::constants::AsAddressTrait::as_address` 14 | 15 |
const fn as_address(self: felt252) -> ContractAddress
16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-BASE_URI.md: -------------------------------------------------------------------------------- 1 | # BASE_URI 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::BASE_URI` 4 | 5 |
pub fn BASE_URI() -> ByteArray
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-BASE_URI_2.md: -------------------------------------------------------------------------------- 1 | # BASE_URI_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::BASE_URI_2` 4 | 5 |
pub fn BASE_URI_2() -> ByteArray
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-BLOCK_NUMBER.md: -------------------------------------------------------------------------------- 1 | # BLOCK_NUMBER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::BLOCK_NUMBER` 4 | 5 |
pub const BLOCK_NUMBER: u64 = 1234567;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-BOB.md: -------------------------------------------------------------------------------- 1 | # BOB 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::BOB` 4 | 5 |
pub const BOB: ContractAddress = 'BOB'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-CALLER.md: -------------------------------------------------------------------------------- 1 | # CALLER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::CALLER` 4 | 5 |
pub const CALLER: ContractAddress = 'CALLER'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-CHAIN_ID.md: -------------------------------------------------------------------------------- 1 | # CHAIN_ID 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::CHAIN_ID` 4 | 5 |
pub const CHAIN_ID: felt252 = 'CHAIN_ID';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-CHARLIE.md: -------------------------------------------------------------------------------- 1 | # CHARLIE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::CHARLIE` 4 | 5 |
pub const CHARLIE: ContractAddress = 'CHARLIE'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-CLASS_HASH_ZERO.md: -------------------------------------------------------------------------------- 1 | # CLASS_HASH_ZERO 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::CLASS_HASH_ZERO` 4 | 5 |
pub const CLASS_HASH_ZERO: ClassHash = 0.try_into().unwrap();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DAPP_NAME.md: -------------------------------------------------------------------------------- 1 | # DAPP_NAME 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DAPP_NAME` 4 | 5 |
pub const DAPP_NAME: felt252 = 'DAPP_NAME';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DAPP_VERSION.md: -------------------------------------------------------------------------------- 1 | # DAPP_VERSION 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DAPP_VERSION` 4 | 5 |
pub const DAPP_VERSION: felt252 = 'DAPP_VERSION';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DATA.md: -------------------------------------------------------------------------------- 1 | # DATA 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DATA` 4 | 5 |
pub fn DATA(success: bool) -> Span<felt252>
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DECIMALS.md: -------------------------------------------------------------------------------- 1 | # DECIMALS 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DECIMALS` 4 | 5 |
pub const DECIMALS: u8 = 18;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DELEGATEE.md: -------------------------------------------------------------------------------- 1 | # DELEGATEE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DELEGATEE` 4 | 5 |
pub const DELEGATEE: ContractAddress = 'DELEGATEE'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-DELEGATOR.md: -------------------------------------------------------------------------------- 1 | # DELEGATOR 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::DELEGATOR` 4 | 5 |
pub const DELEGATOR: ContractAddress = 'DELEGATOR'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-EMPTY_DATA.md: -------------------------------------------------------------------------------- 1 | # EMPTY_DATA 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::EMPTY_DATA` 4 | 5 |
pub fn EMPTY_DATA() -> Span<felt252>
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-EthPublicKey.md: -------------------------------------------------------------------------------- 1 | # EthPublicKey 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::EthPublicKey` 4 | 5 |
pub type EthPublicKey = starknet::secp256k1::Secp256k1Point;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-FAILURE.md: -------------------------------------------------------------------------------- 1 | # FAILURE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::FAILURE` 4 | 5 |
pub const FAILURE: felt252 = 'FAILURE';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-FELT_VALUE.md: -------------------------------------------------------------------------------- 1 | # FELT_VALUE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::FELT_VALUE` 4 | 5 |
pub const FELT_VALUE: felt252 = 'FELT_VALUE';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-MIN_TRANSACTION_VERSION.md: -------------------------------------------------------------------------------- 1 | # MIN_TRANSACTION_VERSION 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::MIN_TRANSACTION_VERSION` 4 | 5 |
pub const MIN_TRANSACTION_VERSION: felt252 = 1;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-NAME.md: -------------------------------------------------------------------------------- 1 | # NAME 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::NAME` 4 | 5 |
pub fn NAME() -> ByteArray
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-NEW_OWNER.md: -------------------------------------------------------------------------------- 1 | # NEW_OWNER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::NEW_OWNER` 4 | 5 |
pub const NEW_OWNER: ContractAddress = 'NEW_OWNER'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-NEW_PUBKEY.md: -------------------------------------------------------------------------------- 1 | # NEW_PUBKEY 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::NEW_PUBKEY` 4 | 5 |
pub const NEW_PUBKEY: felt252 = 0x26da8d11938b76025862be14fdb8b28438827f73e75e86f7bfa38b196951fa7;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-OPERATOR.md: -------------------------------------------------------------------------------- 1 | # OPERATOR 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::OPERATOR` 4 | 5 |
pub const OPERATOR: ContractAddress = 'OPERATOR'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-OTHER.md: -------------------------------------------------------------------------------- 1 | # OTHER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::OTHER` 4 | 5 |
pub const OTHER: ContractAddress = 'OTHER'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-OTHER_ADMIN.md: -------------------------------------------------------------------------------- 1 | # OTHER_ADMIN 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::OTHER_ADMIN` 4 | 5 |
pub const OTHER_ADMIN: ContractAddress = 'OTHER_ADMIN'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-OTHER_ROLE.md: -------------------------------------------------------------------------------- 1 | # OTHER_ROLE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::OTHER_ROLE` 4 | 5 |
pub const OTHER_ROLE: felt252 = 'OTHER_ROLE';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-OWNER.md: -------------------------------------------------------------------------------- 1 | # OWNER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::OWNER` 4 | 5 |
pub const OWNER: ContractAddress = 'OWNER'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-PUBKEY.md: -------------------------------------------------------------------------------- 1 | # PUBKEY 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::PUBKEY` 4 | 5 |
pub const PUBKEY: felt252 = 'PUBKEY';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-QUERY_OFFSET.md: -------------------------------------------------------------------------------- 1 | # QUERY_OFFSET 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::QUERY_OFFSET` 4 | 5 |
pub const QUERY_OFFSET: felt252 = 0x100000000000000000000000000000000;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-QUERY_VERSION.md: -------------------------------------------------------------------------------- 1 | # QUERY_VERSION 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::QUERY_VERSION` 4 | 5 |
pub const QUERY_VERSION: felt252 = 0x100000000000000000000000000000001;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-RECIPIENT.md: -------------------------------------------------------------------------------- 1 | # RECIPIENT 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::RECIPIENT` 4 | 5 |
pub const RECIPIENT: ContractAddress = 'RECIPIENT'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-ROLE.md: -------------------------------------------------------------------------------- 1 | # ROLE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::ROLE` 4 | 5 |
pub const ROLE: felt252 = 'ROLE';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-SALT.md: -------------------------------------------------------------------------------- 1 | # SALT 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::SALT` 4 | 5 |
pub const SALT: felt252 = 'SALT';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-SPENDER.md: -------------------------------------------------------------------------------- 1 | # SPENDER 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::SPENDER` 4 | 5 |
pub const SPENDER: ContractAddress = 'SPENDER'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-SUCCESS.md: -------------------------------------------------------------------------------- 1 | # SUCCESS 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::SUCCESS` 4 | 5 |
pub const SUCCESS: felt252 = 'SUCCESS';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-SUPPLY.md: -------------------------------------------------------------------------------- 1 | # SUPPLY 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::SUPPLY` 4 | 5 |
pub const SUPPLY: u256 = 2_000;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-SYMBOL.md: -------------------------------------------------------------------------------- 1 | # SYMBOL 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::SYMBOL` 4 | 5 |
pub fn SYMBOL() -> ByteArray
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TIMELOCK.md: -------------------------------------------------------------------------------- 1 | # TIMELOCK 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TIMELOCK` 4 | 5 |
pub const TIMELOCK: ContractAddress = 'TIMELOCK'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TIMESTAMP.md: -------------------------------------------------------------------------------- 1 | # TIMESTAMP 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TIMESTAMP` 4 | 5 |
pub const TIMESTAMP: u64 = 1704067200;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TOKEN_ID.md: -------------------------------------------------------------------------------- 1 | # TOKEN_ID 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TOKEN_ID` 4 | 5 |
pub const TOKEN_ID: u256 = 21;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TOKEN_ID_2.md: -------------------------------------------------------------------------------- 1 | # TOKEN_ID_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TOKEN_ID_2` 4 | 5 |
pub const TOKEN_ID_2: u256 = 121;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TOKEN_VALUE.md: -------------------------------------------------------------------------------- 1 | # TOKEN_VALUE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TOKEN_VALUE` 4 | 5 |
pub const TOKEN_VALUE: u256 = 42;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TOKEN_VALUE_2.md: -------------------------------------------------------------------------------- 1 | # TOKEN_VALUE_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TOKEN_VALUE_2` 4 | 5 |
pub const TOKEN_VALUE_2: u256 = 142;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-TRANSACTION_HASH.md: -------------------------------------------------------------------------------- 1 | # TRANSACTION_HASH 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::TRANSACTION_HASH` 4 | 5 |
pub const TRANSACTION_HASH: felt252 = 'TRANSACTION_HASH';
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-VALUE.md: -------------------------------------------------------------------------------- 1 | # VALUE 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::VALUE` 4 | 5 |
pub const VALUE: u256 = 300;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-VOTES_TOKEN.md: -------------------------------------------------------------------------------- 1 | # VOTES_TOKEN 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::VOTES_TOKEN` 4 | 5 |
pub const VOTES_TOKEN: ContractAddress = 'VOTES_TOKEN'.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-ZERO.md: -------------------------------------------------------------------------------- 1 | # ZERO 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::ZERO` 4 | 5 |
pub const ZERO: ContractAddress = 0.as_address();
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256k1-KEY_PAIR.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256k1::KEY_PAIR` 4 | 5 |
pub fn KEY_PAIR() -> Secp256k1KeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256k1-KEY_PAIR_2.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256k1::KEY_PAIR_2` 4 | 5 |
pub fn KEY_PAIR_2() -> Secp256k1KeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256k1.md: -------------------------------------------------------------------------------- 1 | # secp256k1 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256k1` 4 | 5 | ## Free functions 6 | 7 | - [KEY_PAIR](./openzeppelin_testing-constants-secp256k1-KEY_PAIR.md) 8 | 9 | - [KEY_PAIR_2](./openzeppelin_testing-constants-secp256k1-KEY_PAIR_2.md) 10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256r1-KEY_PAIR.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256r1::KEY_PAIR` 4 | 5 |
pub fn KEY_PAIR() -> Secp256r1KeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256r1-KEY_PAIR_2.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256r1::KEY_PAIR_2` 4 | 5 |
pub fn KEY_PAIR_2() -> Secp256r1KeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-secp256r1.md: -------------------------------------------------------------------------------- 1 | # secp256r1 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::secp256r1` 4 | 5 | ## Free functions 6 | 7 | - [KEY_PAIR](./openzeppelin_testing-constants-secp256r1-KEY_PAIR.md) 8 | 9 | - [KEY_PAIR_2](./openzeppelin_testing-constants-secp256r1-KEY_PAIR_2.md) 10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-stark-KEY_PAIR.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::stark::KEY_PAIR` 4 | 5 |
pub fn KEY_PAIR() -> StarkKeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-stark-KEY_PAIR_2.md: -------------------------------------------------------------------------------- 1 | # KEY_PAIR_2 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::stark::KEY_PAIR_2` 4 | 5 |
pub fn KEY_PAIR_2() -> StarkKeyPair
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-constants-stark.md: -------------------------------------------------------------------------------- 1 | # stark 2 | 3 | Fully qualified path: `openzeppelin_testing::constants::stark` 4 | 5 | ## Free functions 6 | 7 | - [KEY_PAIR](./openzeppelin_testing-constants-stark-KEY_PAIR.md) 8 | 9 | - [KEY_PAIR_2](./openzeppelin_testing-constants-stark-KEY_PAIR_2.md) 10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-declare_and_deploy.md: -------------------------------------------------------------------------------- 1 | # declare_and_deploy 2 | 3 | Combines the declaration of a class and the deployment of a contract into one function call. This function will skip declaration if the contract is already declared (the result of `snforge_std::declare` call is of type `DeclareResult::AlreadyDeclared`) 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::declare_and_deploy` 6 | 7 |
pub fn declare_and_deploy(contract_name: ByteArray, calldata: Array<felt252>) -> ContractAddress
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-declare_and_deploy_at.md: -------------------------------------------------------------------------------- 1 | # declare_and_deploy_at 2 | 3 | Combines the declaration of a class and the deployment of a contract at the given address into one function call. This function will skip declaration if the contract is already declared (the result of `snforge_std::declare` call is of type `DeclareResult::AlreadyDeclared`) 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::declare_and_deploy_at` 6 | 7 |
pub fn declare_and_deploy_at(
 8 |     contract_name: ByteArray, target_address: ContractAddress, calldata: Array<felt252>,
 9 | )
10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-declare_class.md: -------------------------------------------------------------------------------- 1 | # declare_class 2 | 3 | Declares a contract with a `snforge_std::declare` call and unwraps the result. This function will skip declaration and just return the `ContractClass` if the contract is already declared (the result of `snforge_std::declare` call is of type `DeclareResult::AlreadyDeclared`) 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::declare_class` 6 | 7 |
pub fn declare_class(contract_name: ByteArray) -> ContractClass
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-deploy.md: -------------------------------------------------------------------------------- 1 | # deploy 2 | 3 | Deploys an instance of a contract and unwraps the result. 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::deploy` 6 | 7 |
pub fn deploy(contract_class: ContractClass, calldata: Array<felt252>) -> ContractAddress
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-deploy_another_at.md: -------------------------------------------------------------------------------- 1 | # deploy_another_at 2 | 3 | Deploys a contract using the class hash from another already-deployed contract. 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::deploy_another_at` 6 | 7 |
pub fn deploy_another_at(
 8 |     existing: ContractAddress, target_address: ContractAddress, calldata: Array<felt252>,
 9 | )
10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment-deploy_at.md: -------------------------------------------------------------------------------- 1 | # deploy_at 2 | 3 | Deploys a contract at the given address and unwraps the result. 4 | 5 | Fully qualified path: `openzeppelin_testing::deployment::deploy_at` 6 | 7 |
pub fn deploy_at(
 8 |     contract_class: ContractClass, target_address: ContractAddress, calldata: Array<felt252>,
 9 | )
10 | 11 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-deployment.md: -------------------------------------------------------------------------------- 1 | # deployment 2 | 3 | Fully qualified path: `openzeppelin_testing::deployment` 4 | 5 | ## Free functions 6 | 7 | - [declare_class](./openzeppelin_testing-deployment-declare_class.md) 8 | 9 | - [deploy](./openzeppelin_testing-deployment-deploy.md) 10 | 11 | - [deploy_at](./openzeppelin_testing-deployment-deploy_at.md) 12 | 13 | - [deploy_another_at](./openzeppelin_testing-deployment-deploy_another_at.md) 14 | 15 | - [declare_and_deploy](./openzeppelin_testing-deployment-declare_and_deploy.md) 16 | 17 | - [declare_and_deploy_at](./openzeppelin_testing-deployment-declare_and_deploy_at.md) 18 | 19 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-events-EventSpyQueue.md: -------------------------------------------------------------------------------- 1 | # EventSpyQueue 2 | 3 | A wrapper around the `EventSpy` structure to allow treating the events as a queue. 4 | 5 | Fully qualified path: `openzeppelin_testing::events::EventSpyQueue` 6 | 7 |
#[derive(Drop, Serde)]
 8 | pub struct EventSpyQueue {
 9 |     event_offset: usize,
10 |     event_spy: EventSpy,
11 | }
12 | 13 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-events-spy_events.md: -------------------------------------------------------------------------------- 1 | # spy_events 2 | 3 | Creates a new `EventSpyQueue` instance. 4 | 5 | Fully qualified path: `openzeppelin_testing::events::spy_events` 6 | 7 |
pub fn spy_events() -> EventSpyQueue
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-events.md: -------------------------------------------------------------------------------- 1 | # events 2 | 3 | Fully qualified path: `openzeppelin_testing::events` 4 | 5 | ## Free functions 6 | 7 | - [spy_events](./openzeppelin_testing-events-spy_events.md) 8 | 9 | ## Structs 10 | 11 | - [EventSpyQueue](./openzeppelin_testing-events-EventSpyQueue.md) 12 | 13 | ## Traits 14 | 15 | - [EventSpyExt](./openzeppelin_testing-events-EventSpyExt.md) 16 | 17 | ## Impls 18 | 19 | - [EventSpyQueueImpl](./openzeppelin_testing-events-EventSpyQueueImpl.md) 20 | 21 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-Secp256k1KeyPair.md: -------------------------------------------------------------------------------- 1 | # Secp256k1KeyPair 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::Secp256k1KeyPair` 4 | 5 |
pub type Secp256k1KeyPair = KeyPair<u256, Secp256k1Point>;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-Secp256k1SerializedSigning.md: -------------------------------------------------------------------------------- 1 | # Secp256k1SerializedSigning 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::Secp256k1SerializedSigning` 4 | 5 |
pub impl Secp256k1SerializedSigning of SerializedSigning<Secp256k1KeyPair, u256>
6 | 7 | ## Impl functions 8 | 9 | ### serialized_sign 10 | 11 | Fully qualified path: `openzeppelin_testing::signing::Secp256k1SerializedSigning::serialized_sign` 12 | 13 |
fn serialized_sign(self: Secp256k1KeyPair, msg: u256) -> Array<felt252>
14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-Secp256r1KeyPair.md: -------------------------------------------------------------------------------- 1 | # Secp256r1KeyPair 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::Secp256r1KeyPair` 4 | 5 |
pub type Secp256r1KeyPair = KeyPair<u256, Secp256r1Point>;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-Secp256r1SerializedSigning.md: -------------------------------------------------------------------------------- 1 | # Secp256r1SerializedSigning 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::Secp256r1SerializedSigning` 4 | 5 |
pub impl Secp256r1SerializedSigning of SerializedSigning<Secp256r1KeyPair, u256>
6 | 7 | ## Impl functions 8 | 9 | ### serialized_sign 10 | 11 | Fully qualified path: `openzeppelin_testing::signing::Secp256r1SerializedSigning::serialized_sign` 12 | 13 |
fn serialized_sign(self: Secp256r1KeyPair, msg: u256) -> Array<felt252>
14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-SerializedSigning.md: -------------------------------------------------------------------------------- 1 | # SerializedSigning 2 | 3 | A helper trait that facilitates converting a signature into a serialized format. 4 | 5 | Fully qualified path: `openzeppelin_testing::signing::SerializedSigning` 6 | 7 |
pub trait SerializedSigning<KP, M>
8 | 9 | ## Trait functions 10 | 11 | ### serialized_sign 12 | 13 | Fully qualified path: `openzeppelin_testing::signing::SerializedSigning::serialized_sign` 14 | 15 |
fn serialized_sign(self: KP, msg: M) -> Array<felt252>
16 | 17 | 18 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-StarkKeyPair.md: -------------------------------------------------------------------------------- 1 | # StarkKeyPair 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::StarkKeyPair` 4 | 5 |
pub type StarkKeyPair = KeyPair<felt252, felt252>;
6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-StarkSerializedSigning.md: -------------------------------------------------------------------------------- 1 | # StarkSerializedSigning 2 | 3 | Fully qualified path: `openzeppelin_testing::signing::StarkSerializedSigning` 4 | 5 |
pub impl StarkSerializedSigning of SerializedSigning<StarkKeyPair, felt252>
6 | 7 | ## Impl functions 8 | 9 | ### serialized_sign 10 | 11 | Fully qualified path: `openzeppelin_testing::signing::StarkSerializedSigning::serialized_sign` 12 | 13 |
fn serialized_sign(self: StarkKeyPair, msg: felt252) -> Array<felt252>
14 | 15 | 16 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-get_secp256k1_keys_from.md: -------------------------------------------------------------------------------- 1 | # get_secp256k1_keys_from 2 | 3 | Builds a Secp256k1 Key Pair from a private key represented by a `u256` value. 4 | 5 | Fully qualified path: `openzeppelin_testing::signing::get_secp256k1_keys_from` 6 | 7 |
pub fn get_secp256k1_keys_from(private_key: u256) -> Secp256k1KeyPair
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-get_secp256r1_keys_from.md: -------------------------------------------------------------------------------- 1 | # get_secp256r1_keys_from 2 | 3 | Builds a Secp256r1 Key Pair from a private key represented by a `u256` value. 4 | 5 | Fully qualified path: `openzeppelin_testing::signing::get_secp256r1_keys_from` 6 | 7 |
pub fn get_secp256r1_keys_from(private_key: u256) -> Secp256r1KeyPair
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing-get_stark_keys_from.md: -------------------------------------------------------------------------------- 1 | # get_stark_keys_from 2 | 3 | Builds a Stark Key Pair from a private key represented by a `felt252` value. 4 | 5 | Fully qualified path: `openzeppelin_testing::signing::get_stark_keys_from` 6 | 7 |
pub fn get_stark_keys_from(private_key: felt252) -> StarkKeyPair
8 | 9 | -------------------------------------------------------------------------------- /packages/testing/docs/openzeppelin_testing-signing.md: -------------------------------------------------------------------------------- 1 | # signing 2 | 3 | Fully qualified path: `openzeppelin_testing::signing` 4 | 5 | ## Free functions 6 | 7 | - [get_stark_keys_from](./openzeppelin_testing-signing-get_stark_keys_from.md) 8 | 9 | - [get_secp256k1_keys_from](./openzeppelin_testing-signing-get_secp256k1_keys_from.md) 10 | 11 | - [get_secp256r1_keys_from](./openzeppelin_testing-signing-get_secp256r1_keys_from.md) 12 | 13 | ## Type aliases 14 | 15 | - [StarkKeyPair](./openzeppelin_testing-signing-StarkKeyPair.md) 16 | 17 | - [Secp256k1KeyPair](./openzeppelin_testing-signing-Secp256k1KeyPair.md) 18 | 19 | - [Secp256r1KeyPair](./openzeppelin_testing-signing-Secp256r1KeyPair.md) 20 | 21 | ## Traits 22 | 23 | - [SerializedSigning](./openzeppelin_testing-signing-SerializedSigning.md) 24 | 25 | ## Impls 26 | 27 | - [StarkSerializedSigning](./openzeppelin_testing-signing-StarkSerializedSigning.md) 28 | 29 | - [Secp256k1SerializedSigning](./openzeppelin_testing-signing-Secp256k1SerializedSigning.md) 30 | 31 | - [Secp256r1SerializedSigning](./openzeppelin_testing-signing-Secp256r1SerializedSigning.md) 32 | 33 | -------------------------------------------------------------------------------- /packages/testing/docs/structs.md: -------------------------------------------------------------------------------- 1 | # Structs 2 | 3 | - [events::EventSpyQueue](./openzeppelin_testing-events-EventSpyQueue.md) 4 | 5 | - [events::EventSpyQueue](./openzeppelin_testing-events-EventSpyQueue.md) 6 | 7 | -------------------------------------------------------------------------------- /packages/testing/docs/traits.md: -------------------------------------------------------------------------------- 1 | # Traits 2 | 3 | - [common::IntoBase16StringTrait](./openzeppelin_testing-common-IntoBase16StringTrait.md) 4 | 5 | - [constants::AsAddressTrait](./openzeppelin_testing-constants-AsAddressTrait.md) 6 | 7 | - [events::EventSpyExt](./openzeppelin_testing-events-EventSpyExt.md) 8 | 9 | - [common::IntoBase16StringTrait](./openzeppelin_testing-common-IntoBase16StringTrait.md) 10 | 11 | - [constants::AsAddressTrait](./openzeppelin_testing-constants-AsAddressTrait.md) 12 | 13 | - [events::EventSpyExt](./openzeppelin_testing-events-EventSpyExt.md) 14 | 15 | - [SerializedSigning](./openzeppelin_testing-signing-SerializedSigning.md) 16 | 17 | -------------------------------------------------------------------------------- /packages/testing/docs/type_aliases.md: -------------------------------------------------------------------------------- 1 | # Type aliases 2 | 3 | - [EthPublicKey](./openzeppelin_testing-constants-EthPublicKey.md) 4 | 5 | - [StarkKeyPair](./openzeppelin_testing-signing-StarkKeyPair.md) 6 | 7 | - [Secp256k1KeyPair](./openzeppelin_testing-signing-Secp256k1KeyPair.md) 8 | 9 | - [Secp256r1KeyPair](./openzeppelin_testing-signing-Secp256r1KeyPair.md) 10 | 11 | -------------------------------------------------------------------------------- /packages/testing/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod common; 2 | pub mod constants; 3 | pub mod deployment; 4 | pub mod events; 5 | pub mod signing; 6 | 7 | pub use common::{ 8 | IntoBase16StringTrait, assert_entrypoint_not_found_error, panic_data_to_byte_array, 9 | to_base_16_string, 10 | }; 11 | pub use constants::AsAddressTrait; 12 | pub use deployment::{ 13 | declare_and_deploy, declare_and_deploy_at, declare_class, deploy, deploy_another_at, deploy_at, 14 | }; 15 | 16 | pub use events::{EventSpyExt, EventSpyQueue, spy_events}; 17 | -------------------------------------------------------------------------------- /packages/token/src/common.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc2981; 2 | -------------------------------------------------------------------------------- /packages/token/src/common/erc2981.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc2981; 2 | pub mod interface; 3 | 4 | pub use erc2981::{DefaultConfig, ERC2981Component}; 5 | pub use interface::{IERC2981Dispatcher, IERC2981DispatcherTrait}; 6 | -------------------------------------------------------------------------------- /packages/token/src/erc1155.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc1155; 2 | pub mod erc1155_receiver; 3 | pub mod interface; 4 | 5 | pub use erc1155::{ERC1155Component, ERC1155HooksEmptyImpl}; 6 | pub use erc1155_receiver::ERC1155ReceiverComponent; 7 | -------------------------------------------------------------------------------- /packages/token/src/erc20.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc20; 2 | pub mod extensions; 3 | pub mod interface; 4 | pub mod snip12_utils; 5 | 6 | pub use erc20::{DefaultConfig, ERC20Component, ERC20HooksEmptyImpl}; 7 | pub use interface::{ERC20ABIDispatcher, ERC20ABIDispatcherTrait}; 8 | -------------------------------------------------------------------------------- /packages/token/src/erc20/extensions.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc4626; 2 | -------------------------------------------------------------------------------- /packages/token/src/erc20/extensions/erc4626.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc4626; 2 | pub mod interface; 3 | 4 | pub use erc4626::DefaultConfig; 5 | pub use erc4626::{ 6 | ERC4626Component, ERC4626DefaultLimits, ERC4626DefaultNoFees, ERC4626HooksEmptyImpl, 7 | }; 8 | pub use interface::IERC4626; 9 | -------------------------------------------------------------------------------- /packages/token/src/erc20/snip12_utils.cairo: -------------------------------------------------------------------------------- 1 | pub mod permit; 2 | -------------------------------------------------------------------------------- /packages/token/src/erc721.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc721; 2 | pub mod erc721_receiver; 3 | pub mod extensions; 4 | pub mod interface; 5 | 6 | pub use erc721::{ERC721Component, ERC721HooksEmptyImpl}; 7 | pub use erc721_receiver::ERC721ReceiverComponent; 8 | pub use interface::{ERC721ABIDispatcher, ERC721ABIDispatcherTrait}; 9 | -------------------------------------------------------------------------------- /packages/token/src/erc721/extensions.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc721_enumerable; 2 | 3 | pub use erc721_enumerable::ERC721EnumerableComponent; 4 | -------------------------------------------------------------------------------- /packages/token/src/erc721/extensions/erc721_enumerable.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc721_enumerable; 2 | pub mod interface; 3 | 4 | pub use erc721_enumerable::ERC721EnumerableComponent; 5 | -------------------------------------------------------------------------------- /packages/token/src/erc721/extensions/erc721_enumerable/interface.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 3 | // (token/src/erc721/extensions/erc721_enumerable/interface.cairo) 4 | 5 | use starknet::ContractAddress; 6 | 7 | pub const IERC721ENUMERABLE_ID: felt252 = 8 | 0x16bc0f502eeaf65ce0b3acb5eea656e2f26979ce6750e8502a82f377e538c87; 9 | 10 | #[starknet::interface] 11 | pub trait IERC721Enumerable { 12 | fn total_supply(self: @TState) -> u256; 13 | fn token_by_index(self: @TState, index: u256) -> u256; 14 | fn token_of_owner_by_index(self: @TState, owner: ContractAddress, index: u256) -> u256; 15 | } 16 | 17 | #[starknet::interface] 18 | pub trait ERC721EnumerableABI { 19 | fn total_supply(self: @TState) -> u256; 20 | fn token_by_index(self: @TState, index: u256) -> u256; 21 | fn token_of_owner_by_index(self: @TState, owner: ContractAddress, index: u256) -> u256; 22 | fn all_tokens_of_owner(self: @TState, owner: ContractAddress) -> Span; 23 | } 24 | -------------------------------------------------------------------------------- /packages/token/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod common; 2 | pub mod erc1155; 3 | pub mod erc20; 4 | pub mod erc721; 5 | 6 | #[cfg(test)] 7 | pub mod tests; 8 | -------------------------------------------------------------------------------- /packages/token/src/tests.cairo: -------------------------------------------------------------------------------- 1 | pub mod erc1155; 2 | pub mod erc20; 3 | pub mod erc2981; 4 | pub mod erc4626; 5 | pub mod erc721; 6 | -------------------------------------------------------------------------------- /packages/token/src/tests/erc1155.cairo: -------------------------------------------------------------------------------- 1 | mod test_erc1155; 2 | mod test_erc1155_receiver; 3 | -------------------------------------------------------------------------------- /packages/token/src/tests/erc20.cairo: -------------------------------------------------------------------------------- 1 | mod test_erc20; 2 | mod test_erc20_permit; 3 | 4 | #[cfg(feature: 'fuzzing')] 5 | mod test_fuzz_erc20; 6 | -------------------------------------------------------------------------------- /packages/token/src/tests/erc2981.cairo: -------------------------------------------------------------------------------- 1 | mod test_erc2981_accesscontrol; 2 | mod test_erc2981_internal; 3 | mod test_erc2981_ownable; 4 | -------------------------------------------------------------------------------- /packages/token/src/tests/erc4626.cairo: -------------------------------------------------------------------------------- 1 | mod test_erc4626; 2 | -------------------------------------------------------------------------------- /packages/token/src/tests/erc721.cairo: -------------------------------------------------------------------------------- 1 | mod test_erc721; 2 | mod test_erc721_enumerable; 3 | mod test_erc721_receiver; 4 | 5 | #[cfg(feature: 'fuzzing')] 6 | mod test_fuzz_erc721_enumerable; 7 | -------------------------------------------------------------------------------- /packages/upgrades/README.md: -------------------------------------------------------------------------------- 1 | ## Upgrades 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/upgrades](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/upgrades) 4 | 5 | This crate provides an interface and component used for upgradeability. 6 | 7 | ### Interfaces 8 | 9 | - [`IUpgradeable`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/upgrades#IUpgradeable) 10 | - [`IUpgradeAndCall`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/upgrades#IUpgradeAndCall) 11 | 12 | ### Components 13 | 14 | - [`UpgradeableComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/upgrades#UpgradeableComponent) 15 | -------------------------------------------------------------------------------- /packages/upgrades/Scarb.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "openzeppelin_upgrades" 4 | readme = "README.md" 5 | keywords = [ 6 | "openzeppelin", 7 | "starknet", 8 | "contracts", 9 | "upgrades" 10 | ] 11 | version.workspace = true 12 | edition.workspace = true 13 | cairo-version.workspace = true 14 | scarb-version.workspace = true 15 | authors.workspace = true 16 | description.workspace = true 17 | documentation.workspace = true 18 | repository.workspace = true 19 | license-file.workspace = true 20 | 21 | [tool] 22 | fmt.workspace = true 23 | scarb.workspace = true 24 | 25 | [dependencies] 26 | starknet.workspace = true 27 | 28 | [dev-dependencies] 29 | assert_macros.workspace = true 30 | snforge_std.workspace = true 31 | openzeppelin_testing = { path = "../testing" } 32 | openzeppelin_test_common = { path = "../test_common" } 33 | 34 | [lib] 35 | 36 | [[target.starknet-contract]] 37 | allowed-libfuncs-list.name = "experimental" 38 | sierra = true 39 | casm = false 40 | 41 | [[test]] 42 | name = "openzeppelin_upgrades_unittest" 43 | build-external-contracts = [ 44 | "openzeppelin_test_common::mocks::upgrades::UpgradesV1", 45 | "openzeppelin_test_common::mocks::upgrades::UpgradesV2", 46 | ] 47 | -------------------------------------------------------------------------------- /packages/upgrades/src/interface.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (upgrades/src/interface.cairo) 3 | 4 | use starknet::ClassHash; 5 | 6 | #[starknet::interface] 7 | pub trait IUpgradeable { 8 | fn upgrade(ref self: TState, new_class_hash: ClassHash); 9 | } 10 | 11 | #[starknet::interface] 12 | pub trait IUpgradeAndCall { 13 | fn upgrade_and_call( 14 | ref self: TState, new_class_hash: ClassHash, selector: felt252, calldata: Span, 15 | ) -> Span; 16 | } 17 | -------------------------------------------------------------------------------- /packages/upgrades/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | 3 | #[cfg(test)] 4 | pub mod tests; 5 | pub mod upgradeable; 6 | 7 | pub use upgradeable::UpgradeableComponent; 8 | -------------------------------------------------------------------------------- /packages/upgrades/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_upgradeable; 2 | -------------------------------------------------------------------------------- /packages/utils/README.md: -------------------------------------------------------------------------------- 1 | ## Utils 2 | 3 | > **NOTE:** This document is better viewed at [https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities) 4 | 5 | This crate provides components and libraries containing miscellaneous utilities. 6 | 7 | ### Core utilities 8 | 9 | - [`utils`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#utils) 10 | - [`cryptography`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#cryptography) 11 | - [`deployments`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#deployments) 12 | - [`math`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#math) 13 | - [`serde`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#serde) 14 | 15 | ### Cryptography 16 | 17 | - [`NoncesComponent`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#NoncesComponent) 18 | - [`snip12`](https://docs.openzeppelin.com/contracts-cairo/2.0.0-alpha.1/api/utilities#snip12) 19 | -------------------------------------------------------------------------------- /packages/utils/Scarb.toml: -------------------------------------------------------------------------------- 1 | 2 | [package] 3 | name = "openzeppelin_utils" 4 | readme = "README.md" 5 | keywords = [ 6 | "openzeppelin", 7 | "starknet", 8 | "contracts", 9 | "standards", 10 | "utils" 11 | ] 12 | version.workspace = true 13 | edition.workspace = true 14 | cairo-version.workspace = true 15 | scarb-version.workspace = true 16 | authors.workspace = true 17 | description.workspace = true 18 | documentation.workspace = true 19 | repository.workspace = true 20 | license-file.workspace = true 21 | 22 | [tool] 23 | fmt.workspace = true 24 | scarb.workspace = true 25 | 26 | [dependencies] 27 | starknet.workspace = true 28 | 29 | [dev-dependencies] 30 | assert_macros.workspace = true 31 | snforge_std.workspace = true 32 | openzeppelin_testing = { path = "../testing" } 33 | openzeppelin_test_common = { path = "../test_common" } 34 | 35 | [features] 36 | fuzzing = [] 37 | 38 | [lib] 39 | 40 | [[target.starknet-contract]] 41 | allowed-libfuncs-list.name = "experimental" 42 | sierra = true 43 | casm = false 44 | -------------------------------------------------------------------------------- /packages/utils/src/cryptography.cairo: -------------------------------------------------------------------------------- 1 | pub mod interface; 2 | pub mod nonces; 3 | pub mod snip12; 4 | -------------------------------------------------------------------------------- /packages/utils/src/cryptography/interface.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (utils/src/cryptography/interface.cairo) 3 | 4 | use starknet::ContractAddress; 5 | 6 | #[starknet::interface] 7 | pub trait INonces { 8 | fn nonces(self: @TState, owner: ContractAddress) -> felt252; 9 | } 10 | 11 | #[starknet::interface] 12 | pub trait ISNIP12Metadata { 13 | fn snip12_metadata(self: @TState) -> (felt252, felt252); 14 | } 15 | -------------------------------------------------------------------------------- /packages/utils/src/interfaces.cairo: -------------------------------------------------------------------------------- 1 | pub use crate::cryptography::interface::{INonces, INoncesDispatcher, INoncesDispatcherTrait}; 2 | pub use crate::deployments::interface::{ 3 | IUniversalDeployer, IUniversalDeployerDispatcher, IUniversalDeployerDispatcherTrait, 4 | UniversalDeployerABI, UniversalDeployerABIDispatcher, UniversalDeployerABIDispatcherTrait, 5 | }; 6 | -------------------------------------------------------------------------------- /packages/utils/src/lib.cairo: -------------------------------------------------------------------------------- 1 | pub mod bytearray; 2 | pub mod cryptography; 3 | pub mod deployments; 4 | pub mod interfaces; 5 | pub mod math; 6 | pub mod serde; 7 | pub mod structs; 8 | 9 | #[cfg(test)] 10 | mod tests; 11 | 12 | pub use cryptography::{nonces, snip12}; 13 | -------------------------------------------------------------------------------- /packages/utils/src/serde.cairo: -------------------------------------------------------------------------------- 1 | // SPDX-License-Identifier: MIT 2 | // OpenZeppelin Contracts for Cairo v2.0.0-alpha.1 (utils/src/serde.cairo) 3 | 4 | pub trait SerializedAppend { 5 | fn append_serde(ref self: Array, value: T); 6 | } 7 | 8 | impl SerializedAppendImpl, impl TDrop: Drop> of SerializedAppend { 9 | fn append_serde(ref self: Array, value: T) { 10 | value.serialize(ref self); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /packages/utils/src/structs.cairo: -------------------------------------------------------------------------------- 1 | pub mod checkpoint; 2 | 3 | pub use checkpoint::{Checkpoint, Trace}; 4 | -------------------------------------------------------------------------------- /packages/utils/src/tests.cairo: -------------------------------------------------------------------------------- 1 | mod test_checkpoint; 2 | mod test_math; 3 | mod test_nonces; 4 | mod test_snip12; 5 | -------------------------------------------------------------------------------- /sncast_scripts/README.md: -------------------------------------------------------------------------------- 1 | # Starknet Foundry Cast Scripts 2 | 3 | This crate provides scripts using Starknet Foundry's Cast package. 4 | 5 | ## Prerequisites 6 | 7 | Running these scripts will likely require an already-deployed account with funds to execute. 8 | This crate can also be tested with [starknet-devnet](https://github.com/0xSpaceShard/starknet-devnet-rs). 9 | 10 | ## Usage 11 | 12 | `cd` into the `sncast_scripts/` directory. 13 | Run the command: 14 | 15 | ```bash 16 | sncast script run