-
Notifications
You must be signed in to change notification settings - Fork 6
refactor: upgrade metagame_extensions to v0.1.1 #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ Entry gating component for controlling access to contexts (tournaments, quests, | |
| - Three requirement types: Token, Allowlist, and Extension | ||
| - Token ownership requirement for NFT gating | ||
| - Allowlist-based access control | ||
| - External validator extension via `IEntryValidator` for custom logic | ||
| - External validator extension via `IEntryRequirementExtension` for custom logic | ||
| - Built-in `EntryValidatorComponent` for building custom validators | ||
| - SRC5 interface registration | ||
|
|
||
|
|
@@ -17,7 +17,7 @@ Entry gating component for controlling access to contexts (tournaments, quests, | |
| |------|-------------| | ||
| | `Token` | Requires caller to own a specific NFT (ERC721 balance check) | | ||
| | `Allowlist` | Requires caller's address to be on an approved list | | ||
| | `Extension` | Delegates validation to an external `IEntryValidator` contract | | ||
| | `Extension` | Delegates validation to an external `IEntryRequirementExtension` contract | | ||
|
|
||
| ## Interface | ||
|
|
||
|
|
@@ -28,12 +28,12 @@ Entry gating component for controlling access to contexts (tournaments, quests, | |
| | `get_entry_requirement(context_id)` | Get the requirement config for a context | | ||
| | `meets_entry_requirement(context_id, player)` | Check if player meets the requirement | | ||
|
|
||
| ### IEntryValidator (Extension Interface) | ||
| ### IEntryRequirementExtension (Extension Interface) | ||
|
|
||
| Custom validator contracts implement this: | ||
|
|
||
| ```cairo | ||
| trait IEntryValidator<TState> { | ||
| trait IEntryRequirementExtension<TState> { | ||
| fn validate_entry(self: @TState, context_id: u64, player: ContractAddress) -> bool; | ||
| } | ||
|
Comment on lines
+31
to
38
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🌐 Web query:
💡 Result: In tag v0.1.1, the Cairo trait
Sources: [1] (github.com) [2] (github.com) Citations:
Update the extension interface documentation to match The README documents 🤖 Prompt for AI Agents |
||
| ``` | ||
|
|
@@ -81,6 +81,6 @@ let allowed = self.entry_req.meets_entry_requirement(context_id, player); | |
|
|
||
| ## Dependencies | ||
|
|
||
| - `game_components_interfaces` - EntryRequirement types and IEntryValidator interface | ||
| - `game_components_interfaces` - EntryRequirement types and IEntryRequirementExtension interface | ||
| - `openzeppelin_interfaces` - ERC20/ERC721 interfaces | ||
| - `openzeppelin_introspection` - SRC5 interface registration | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,9 @@ | ||
| // SPDX-License-Identifier: BUSL-1.1 | ||
|
|
||
| use core::num::traits::Zero; | ||
| use interfaces::entry_requirement_extension::{ | ||
| IENTRY_REQUIREMENT_EXTENSION_ID, IEntryValidatorDispatcher, IEntryValidatorDispatcherTrait, | ||
| use metagame_extensions_interfaces::entry_requirement_extension::{ | ||
| IENTRY_REQUIREMENT_EXTENSION_ID, IEntryRequirementExtensionDispatcher, | ||
| IEntryRequirementExtensionDispatcherTrait, | ||
| }; | ||
| use openzeppelin_interfaces::erc721::{IERC721Dispatcher, IERC721DispatcherTrait, IERC721_ID}; | ||
| use openzeppelin_interfaces::introspection::{ISRC5Dispatcher, ISRC5DispatcherTrait}; | ||
|
|
@@ -158,14 +159,13 @@ pub impl EntryRequirementStoreImpl<T, +Store<T>, +Drop<T>> of EntryRequirementSt | |
| "EntryRequirement: Provided qualification proof is not of type 'Extension'", | ||
| ), | ||
| }; | ||
| let entry_validator_dispatcher = IEntryValidatorDispatcher { | ||
| let extension_dispatcher = IEntryRequirementExtensionDispatcher { | ||
| contract_address: extension_config.address, | ||
| }; | ||
| let caller_address = get_caller_address(); | ||
| let display_extension_address: felt252 = extension_config.address.into(); | ||
| assert!( | ||
| entry_validator_dispatcher | ||
| .valid_entry(context_id, caller_address, qualification), | ||
| extension_dispatcher.valid_entry(context_id, caller_address, qualification), | ||
| "EntryRequirement: Invalid entry according to extension {}", | ||
| display_extension_address, | ||
| ); | ||
|
|
@@ -196,7 +196,7 @@ pub impl EntryRequirementStoreImpl<T, +Store<T>, +Drop<T>> of EntryRequirementSt | |
| let display_address: felt252 = extension_address.into(); | ||
| assert!( | ||
| src5_dispatcher.supports_interface(IENTRY_REQUIREMENT_EXTENSION_ID), | ||
| "EntryRequirement: Extension address {} does not support IEntryValidator interface", | ||
| "EntryRequirement: Extension address {} does not support IEntryRequirementExtension interface", | ||
| display_address, | ||
| ); | ||
| }, | ||
|
|
@@ -212,7 +212,7 @@ pub impl EntryRequirementStoreImpl<T, +Store<T>, +Drop<T>> of EntryRequirementSt | |
| match entry_requirement.entry_requirement_type { | ||
| EntryRequirementType::extension(extension_config) => { | ||
| let extension_address = extension_config.address; | ||
| let entry_validator_dispatcher = IEntryValidatorDispatcher { | ||
| let extension_dispatcher = IEntryRequirementExtensionDispatcher { | ||
| contract_address: extension_address, | ||
| }; | ||
| let display_extension_address: felt252 = extension_address.into(); | ||
|
|
@@ -225,7 +225,7 @@ pub impl EntryRequirementStoreImpl<T, +Store<T>, +Drop<T>> of EntryRequirementSt | |
| ), | ||
| }; | ||
|
|
||
| let entries_left = entry_validator_dispatcher | ||
| let entries_left = extension_dispatcher | ||
| .entries_left(context_id, caller_address, qualification); | ||
|
Comment on lines
+228
to
229
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In After successfully validating that |
||
|
|
||
| match entries_left { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Document the new interface under the correct package.
Line 13 still says
game_components_interfacesprovidesIEntryRequirementExtension, but the code in this PR moves that interface tometagame_extensions_interfaces. Please split this into the actual packages used now, otherwise contributors will add the wrong dependency.Based on learnings "Applies to packages/metagame/src/entry_requirement/**/AGENTS.md : Document agent implementations and configurations in AGENTS.md".
🤖 Prompt for AI Agents