git.delta.rocks / unique-network / refs/commits / db14a78b0d76

difftreelog

feat add enum for AccessMode

Trubnikov Sergey2023-01-17parent: #214592d.patch.diff
in: master

12 files changed

modifiedpallets/common/src/erc.rsdiffbeforeafterboth
503 }503 }
504 /// Set the collection access method.504 /// Set the collection access method.
505 /// @param mode Access mode505 /// @param mode Access mode
506 /// 0 for Normal
507 /// 1 for AllowList
508 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)?;
510508
511 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>)
modifiedpallets/common/src/eth.rsdiffbeforeafterboth
414 }414 }
415}415}
416
417/// 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}
427
428impl 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}
436
437impl 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}
416445
modifiedpallets/fungible/src/stubs/UniqueFungible.rawdiffbeforeafterboth

binary blob — no preview

modifiedpallets/fungible/src/stubs/UniqueFungible.soldiffbeforeafterboth
274274
275 /// Set the collection access method.275 /// Set the collection access method.
276 /// @param mode Access mode276 /// @param mode Access mode
277 /// 0 for Normal
278 /// 1 for AllowList
279 /// @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}
443
444/// 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 AllowList
450}
445451
446/// 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 {
modifiedpallets/nonfungible/src/stubs/UniqueNFT.soldiffbeforeafterboth
416416
417 /// Set the collection access method.417 /// Set the collection access method.
418 /// @param mode Access mode418 /// @param mode Access mode
419 /// 0 for Normal
420 /// 1 for AllowList
421 /// @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}
585
586/// 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 AllowList
592}
587593
588/// 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 {
modifiedpallets/refungible/src/stubs/UniqueRefungible.soldiffbeforeafterboth
416416
417 /// Set the collection access method.417 /// Set the collection access method.
418 /// @param mode Access mode418 /// @param mode Access mode
419 /// 0 for Normal
420 /// 1 for AllowList
421 /// @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}
585
586/// 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 AllowList
592}
587593
588/// 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 {
modifiedtests/src/eth/abi/fungible.jsondiffbeforeafterboth
488 "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": [],
modifiedtests/src/eth/abi/nonFungible.jsondiffbeforeafterboth
650 "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": [],
modifiedtests/src/eth/abi/reFungible.jsondiffbeforeafterboth
632 "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": [],
modifiedtests/src/eth/api/UniqueFungible.soldiffbeforeafterboth
175175
176 /// Set the collection access method.176 /// Set the collection access method.
177 /// @param mode Access mode177 /// @param mode Access mode
178 /// 0 for Normal
179 /// 1 for AllowList
180 /// @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;
183181
184 /// 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}
285
286/// 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 AllowList
292}
287293
288/// 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 {
modifiedtests/src/eth/api/UniqueNFT.soldiffbeforeafterboth
275275
276 /// Set the collection access method.276 /// Set the collection access method.
277 /// @param mode Access mode277 /// @param mode Access mode
278 /// 0 for Normal
279 /// 1 for AllowList
280 /// @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;
283281
284 /// 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}
385
386/// 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 AllowList
392}
387393
388/// 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 {
modifiedtests/src/eth/api/UniqueRefungible.soldiffbeforeafterboth
275275
276 /// Set the collection access method.276 /// Set the collection access method.
277 /// @param mode Access mode277 /// @param mode Access mode
278 /// 0 for Normal
279 /// 1 for AllowList
280 /// @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;
283281
284 /// 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}
385
386/// 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 AllowList
392}
387393
388/// 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 {