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.rsdiffbeforeafterboth--- a/pallets/common/src/eth.rs
+++ b/pallets/common/src/eth.rs
@@ -413,3 +413,32 @@
Self { field, value }
}
}
+
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+#[derive(AbiCoder, Copy, Clone, Default, Debug)]
+#[repr(u8)]
+pub enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ #[default]
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList,
+}
+
+impl From<up_data_structs::AccessMode> for AccessMode {
+ fn from(value: up_data_structs::AccessMode) -> Self {
+ match value {
+ up_data_structs::AccessMode::Normal => AccessMode::Normal,
+ up_data_structs::AccessMode::AllowList => AccessMode::AllowList,
+ }
+ }
+}
+
+impl Into<up_data_structs::AccessMode> for AccessMode {
+ fn into(self) -> up_data_structs::AccessMode {
+ match self {
+ AccessMode::Normal => up_data_structs::AccessMode::Normal,
+ AccessMode::AllowList => up_data_structs::AccessMode::AllowList,
+ }
+ }
+}
pallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterbothbinary blob — no preview
pallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth--- a/pallets/fungible/src/stubs/UniqueFungible.sol
+++ b/pallets/fungible/src/stubs/UniqueFungible.sol
@@ -274,11 +274,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) public {
+ function setCollectionAccess(AccessMode mode) public {
require(false, stub_error);
mode;
dummy = 0;
@@ -443,6 +441,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
pallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth--- a/pallets/nonfungible/src/stubs/UniqueNFT.sol
+++ b/pallets/nonfungible/src/stubs/UniqueNFT.sol
@@ -416,11 +416,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) public {
+ function setCollectionAccess(AccessMode mode) public {
require(false, stub_error);
mode;
dummy = 0;
@@ -585,6 +583,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
pallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth--- a/pallets/refungible/src/stubs/UniqueRefungible.sol
+++ b/pallets/refungible/src/stubs/UniqueRefungible.sol
@@ -416,11 +416,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) public {
+ function setCollectionAccess(AccessMode mode) public {
require(false, stub_error);
mode;
dummy = 0;
@@ -585,6 +583,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
tests/src/eth/abi/fungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/fungible.json
+++ b/tests/src/eth/abi/fungible.json
@@ -488,7 +488,9 @@
"type": "function"
},
{
- "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],
+ "inputs": [
+ { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }
+ ],
"name": "setCollectionAccess",
"outputs": [],
"stateMutability": "nonpayable",
tests/src/eth/abi/nonFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/nonFungible.json
+++ b/tests/src/eth/abi/nonFungible.json
@@ -650,7 +650,9 @@
"type": "function"
},
{
- "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],
+ "inputs": [
+ { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }
+ ],
"name": "setCollectionAccess",
"outputs": [],
"stateMutability": "nonpayable",
tests/src/eth/abi/reFungible.jsondiffbeforeafterboth--- a/tests/src/eth/abi/reFungible.json
+++ b/tests/src/eth/abi/reFungible.json
@@ -632,7 +632,9 @@
"type": "function"
},
{
- "inputs": [{ "internalType": "uint8", "name": "mode", "type": "uint8" }],
+ "inputs": [
+ { "internalType": "enum AccessMode", "name": "mode", "type": "uint8" }
+ ],
"name": "setCollectionAccess",
"outputs": [],
"stateMutability": "nonpayable",
tests/src/eth/api/UniqueFungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueFungible.sol
+++ b/tests/src/eth/api/UniqueFungible.sol
@@ -175,11 +175,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) external;
+ function setCollectionAccess(AccessMode mode) external;
/// Checks that user allowed to operate with collection.
///
@@ -285,6 +283,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
tests/src/eth/api/UniqueNFT.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueNFT.sol
+++ b/tests/src/eth/api/UniqueNFT.sol
@@ -275,11 +275,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) external;
+ function setCollectionAccess(AccessMode mode) external;
/// Checks that user allowed to operate with collection.
///
@@ -385,6 +383,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;
tests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth--- a/tests/src/eth/api/UniqueRefungible.sol
+++ b/tests/src/eth/api/UniqueRefungible.sol
@@ -275,11 +275,9 @@
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
/// @dev EVM selector for this function is: 0x41835d4c,
/// or in textual repr: setCollectionAccess(uint8)
- function setCollectionAccess(uint8 mode) external;
+ function setCollectionAccess(AccessMode mode) external;
/// Checks that user allowed to operate with collection.
///
@@ -385,6 +383,14 @@
uint256 sub;
}
+/// Ethereum representation of `AccessMode` (see [`up_data_structs::AccessMode`]).
+enum AccessMode {
+ /// Access grant for owner and admins. Used as default.
+ Normal,
+ /// Like a [`Normal`](AccessMode::Normal) but also users in allow list.
+ AllowList
+}
+
/// Ethereum representation of `NestingPermissions` (see [`up_data_structs::NestingPermissions`]) field.
struct CollectionNestingPermission {
CollectionPermissionField field;