difftreelog
feat add enum for AccessMode
in: master
12 files changed
pallets/common/src/erc.rsdiffbeforeafterboth503 }503 }504 /// Set the collection access method.504 /// Set the collection access method.505 /// @param mode Access mode505 /// @param mode Access mode506 /// 0 for Normal507 /// 1 for AllowList508 fn set_collection_access(&mut self, caller: caller, mode: u8) -> Result<()> {506 fn set_collection_access(&mut self, caller: caller, mode: eth::AccessMode) -> Result<()> {509 self.consume_store_reads_and_writes(1, 1)?;507 self.consume_store_reads_and_writes(1, 1)?;510508511 let caller = T::CrossAccountId::from_eth(caller);509 let caller = T::CrossAccountId::from_eth(caller);512 let permissions = CollectionPermissions {510 let permissions = CollectionPermissions {513 access: Some(match mode {511 access: Some(mode.into()),514 0 => AccessMode::Normal,515 1 => AccessMode::AllowList,516 _ => return Err("not supported access mode".into()),517 }),518 ..Default::default()512 ..Default::default()519 };513 };520 <Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)514 <Pallet<T>>::update_permissions(&caller, self, permissions).map_err(dispatch_to_evm::<T>)pallets/common/src/eth.rsdiffbeforeafterboth414 }414 }415}415}416417/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).418#[derive(AbiCoder, Copy, Clone, Default, Debug)]419#[repr(u8)]420pub enum AccessMode {421 /// Access grant for owner and admins. Used as default.422 #[default]423 Normal,424 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.425 AllowList,426}427428impl From<up_data_structs::AccessMode> for AccessMode {429 fn from(value: up_data_structs::AccessMode) -> Self {430 match value {431 up_data_structs::AccessMode::Normal => AccessMode::Normal,432 up_data_structs::AccessMode::AllowList => AccessMode::AllowList,433 }434 }435}436437impl Into<up_data_structs::AccessMode> for AccessMode {438 fn into(self) -> up_data_structs::AccessMode {439 match self {440 AccessMode::Normal => up_data_structs::AccessMode::Normal,441 AccessMode::AllowList => up_data_structs::AccessMode::AllowList,442 }443 }444}416445pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth274274275 /// Set the collection access method.275 /// Set the collection access method.276 /// @param mode Access mode276 /// @param mode Access mode277 /// 0 for Normal278 /// 1 for AllowList279 /// @dev EVM selector for this function is: 0x41835d4c,277 /// @dev EVM selector for this function is: 0x41835d4c,280 /// or in textual repr: setCollectionAccess(uint8)278 /// or in textual repr: setCollectionAccess(uint8)281 function setCollectionAccess(uint8 mode) public {279 function setCollectionAccess(AccessMode mode) public {282 require(false, stub_error);280 require(false, stub_error);283 mode;281 mode;284 dummy = 0;282 dummy = 0;443 uint256 sub;441 uint256 sub;444}442}443444/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).445enum AccessMode {446 /// Access grant for owner and admins. Used as default.447 Normal,448 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.449 AllowList450}445451446/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.452/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.447struct CollectionNestingPermission {453struct CollectionNestingPermission {pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth416416417 /// Set the collection access method.417 /// Set the collection access method.418 /// @param mode Access mode418 /// @param mode Access mode419 /// 0 for Normal420 /// 1 for AllowList421 /// @dev EVM selector for this function is: 0x41835d4c,419 /// @dev EVM selector for this function is: 0x41835d4c,422 /// or in textual repr: setCollectionAccess(uint8)420 /// or in textual repr: setCollectionAccess(uint8)423 function setCollectionAccess(uint8 mode) public {421 function setCollectionAccess(AccessMode mode) public {424 require(false, stub_error);422 require(false, stub_error);425 mode;423 mode;426 dummy = 0;424 dummy = 0;585 uint256 sub;583 uint256 sub;586}584}585586/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).587enum AccessMode {588 /// Access grant for owner and admins. Used as default.589 Normal,590 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.591 AllowList592}587593588/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.594/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.589struct CollectionNestingPermission {595struct CollectionNestingPermission {pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth416416417 /// Set the collection access method.417 /// Set the collection access method.418 /// @param mode Access mode418 /// @param mode Access mode419 /// 0 for Normal420 /// 1 for AllowList421 /// @dev EVM selector for this function is: 0x41835d4c,419 /// @dev EVM selector for this function is: 0x41835d4c,422 /// or in textual repr: setCollectionAccess(uint8)420 /// or in textual repr: setCollectionAccess(uint8)423 function setCollectionAccess(uint8 mode) public {421 function setCollectionAccess(AccessMode mode) public {424 require(false, stub_error);422 require(false, stub_error);425 mode;423 mode;426 dummy = 0;424 dummy = 0;585 uint256 sub;583 uint256 sub;586}584}585586/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).587enum AccessMode {588 /// Access grant for owner and admins. Used as default.589 Normal,590 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.591 AllowList592}587593588/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.594/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.589struct CollectionNestingPermission {595struct CollectionNestingPermission {tests/src/eth/abi/fungible.jsondiffbeforeafterboth488 "type": "function"488 "type": "function"489 },489 },490 {490 {491 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],491 "inputs": [492 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }493 ],492 "name": "setCollectionAccess",494 "name": "setCollectionAccess",493 "outputs": [],495 "outputs": [],tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth650 "type": "function"650 "type": "function"651 },651 },652 {652 {653 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],653 "inputs": [654 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }655 ],654 "name": "setCollectionAccess",656 "name": "setCollectionAccess",655 "outputs": [],657 "outputs": [],tests/src/eth/abi/reFungible.jsondiffbeforeafterboth632 "type": "function"632 "type": "function"633 },633 },634 {634 {635 "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],635 "inputs": [636 { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }637 ],636 "name": "setCollectionAccess",638 "name": "setCollectionAccess",637 "outputs": [],639 "outputs": [],tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth175175176 /// Set the collection access method.176 /// Set the collection access method.177 /// @param mode Access mode177 /// @param mode Access mode178 /// 0 for Normal179 /// 1 for AllowList180 /// @dev EVM selector for this function is: 0x41835d4c,178 /// @dev EVM selector for this function is: 0x41835d4c,181 /// or in textual repr: setCollectionAccess(uint8)179 /// or in textual repr: setCollectionAccess(uint8)182 function setCollectionAccess(uint8 mode) external;180 function setCollectionAccess(AccessMode mode) external;183181184 /// Checks that user allowed to operate with collection.182 /// Checks that user allowed to operate with collection.185 ///183 ///285 uint256 sub;283 uint256 sub;286}284}285286/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).287enum AccessMode {288 /// Access grant for owner and admins. Used as default.289 Normal,290 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.291 AllowList292}287293288/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.294/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.289struct CollectionNestingPermission {295struct CollectionNestingPermission {tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth275275276 /// Set the collection access method.276 /// Set the collection access method.277 /// @param mode Access mode277 /// @param mode Access mode278 /// 0 for Normal279 /// 1 for AllowList280 /// @dev EVM selector for this function is: 0x41835d4c,278 /// @dev EVM selector for this function is: 0x41835d4c,281 /// or in textual repr: setCollectionAccess(uint8)279 /// or in textual repr: setCollectionAccess(uint8)282 function setCollectionAccess(uint8 mode) external;280 function setCollectionAccess(AccessMode mode) external;283281284 /// Checks that user allowed to operate with collection.282 /// Checks that user allowed to operate with collection.285 ///283 ///385 uint256 sub;383 uint256 sub;386}384}385386/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).387enum AccessMode {388 /// Access grant for owner and admins. Used as default.389 Normal,390 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.391 AllowList392}387393388/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.394/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.389struct CollectionNestingPermission {395struct CollectionNestingPermission {tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth275275276 /// Set the collection access method.276 /// Set the collection access method.277 /// @param mode Access mode277 /// @param mode Access mode278 /// 0 for Normal279 /// 1 for AllowList280 /// @dev EVM selector for this function is: 0x41835d4c,278 /// @dev EVM selector for this function is: 0x41835d4c,281 /// or in textual repr: setCollectionAccess(uint8)279 /// or in textual repr: setCollectionAccess(uint8)282 function setCollectionAccess(uint8 mode) external;280 function setCollectionAccess(AccessMode mode) external;283281284 /// Checks that user allowed to operate with collection.282 /// Checks that user allowed to operate with collection.285 ///283 ///385 uint256 sub;383 uint256 sub;386}384}385386/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).387enum AccessMode {388 /// Access grant for owner and admins. Used as default.389 Normal,390 /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.391 AllowList392}387393388/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.394/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.389struct CollectionNestingPermission {395struct CollectionNestingPermission {