difftreelog
feat add enum for AccessMode
in: master
12 files changed
pallets/common/src/erc.rsdiffbeforeafterboth--- a/pallets/common/src/erc.rs
+++ b/pallets/common/src/erc.rs
@@ -503,18 +503,12 @@
}
/// Set the collection access method.
/// @param mode Access mode
- /// 0 for Normal
- /// 1 for AllowList
- fn set_collection_access(&mut self, caller: caller, mode: u8) -> Result<()> {
+ fn set_collection_access(&mut self, caller: caller, mode: eth::AccessMode) -> Result<()> {
self.consume_store_reads_and_writes(1, 1)?;
let caller = T::CrossAccountId::from_eth(caller);
let permissions = CollectionPermissions {
- access: Some(match mode {
- 0 => AccessMode::Normal,
- 1 => AccessMode::AllowList,
- _ => return Err("not supported access mode".into()),
- }),
+ access: Some(mode.into()),
..Default::default()
};
<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.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 {