Skip to content

Commit

Permalink
💄 Rename storage for consistency
Browse files Browse the repository at this point in the history
  • Loading branch information
bal7hazar committed Aug 29, 2023
1 parent 6d2be2c commit 3350da5
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions src/extensions/slotenumerable/module.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ mod ERC3525SlotEnumerable {

#[storage]
struct Storage {
enumerable_slots_len: u256,
enumerable_slots: LegacyMap<u256, u256>,
enumerable_slots_index: LegacyMap<u256, u256>,
_slot_enumerables_len: u256,
_slot_enumerables: LegacyMap<u256, u256>,
_slot_enumerables_index: LegacyMap<u256, u256>,
_slot_tokens_len: LegacyMap<u256, u256>,
_slot_tokens: LegacyMap<(u256, u256), u256>,
_slot_tokens_index: LegacyMap<(u256, u256), u256>,
Expand All @@ -25,14 +25,14 @@ mod ERC3525SlotEnumerable {
#[external(v0)]
impl ERC3525SlotEnumerableImpl of IERC3525SlotEnumerable<ContractState> {
fn slot_count(self: @ContractState) -> u256 {
self.enumerable_slots_len.read()
self._slot_enumerables_len.read()
}

fn slot_by_index(self: @ContractState, index: u256) -> u256 {
// [Check] Index is in range
let count = self.enumerable_slots_len.read();
let count = self._slot_enumerables_len.read();
assert(index < count, 'ERC3525: index out of bounds');
self.enumerable_slots.read(index)
self._slot_enumerables.read(index)
}
fn token_supply_in_slot(self: @ContractState, slot: u256) -> u256 {
self._slot_tokens_len.read(slot)
Expand All @@ -54,8 +54,8 @@ mod ERC3525SlotEnumerable {
}

fn _slot_exists(self: @ContractState, slot: u256) -> bool {
let index = self.enumerable_slots_index.read(slot);
self.enumerable_slots.read(index) == slot && slot != 0
let index = self._slot_enumerables_index.read(slot);
self._slot_enumerables.read(index) == slot && slot != 0
}

fn _token_exists(self: @ContractState, slot: u256, token_id: u256) -> bool {
Expand Down Expand Up @@ -122,10 +122,10 @@ mod ERC3525SlotEnumerable {

fn _add_slot_to_slots_enumeration(ref self: ContractState, slot: u256) {
// [Effect] Store new slot
let index = self.enumerable_slots_len.read();
self.enumerable_slots_len.write(index + 1);
self.enumerable_slots.write(index, slot);
self.enumerable_slots_index.write(slot, index);
let index = self._slot_enumerables_len.read();
self._slot_enumerables_len.write(index + 1);
self._slot_enumerables.write(index, slot);
self._slot_enumerables_index.write(slot, index);
}

fn _add_token_to_slot_enumeration(ref self: ContractState, slot: u256, token_id: u256) {
Expand Down

0 comments on commit 3350da5

Please sign in to comment.