-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
102 additions
and
146 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
import {AgentMech} from "./AgentMech.sol"; | ||
|
||
/// @title Mech Factory Basic - Periphery smart contract for managing basic mech creation | ||
contract MechFactoryBasic { | ||
event CreateBasicMech(address indexed mech, uint256 indexed serviceId, uint256 indexed price); | ||
|
||
// Agent factory version number | ||
string public constant VERSION = "0.1.0"; | ||
|
||
/// @dev Registers service as a mech. | ||
/// @param mechMarketplace Mech marketplace address. | ||
/// @param serviceRegistry Service registry address. | ||
/// @param serviceId Service id. | ||
/// @param payload Mech creation payload. | ||
/// @return mech The created mech instance address. | ||
function createMech( | ||
address mechMarketplace, | ||
address serviceRegistry, | ||
uint256 serviceId, | ||
bytes memory payload | ||
) external returns (address mech) { | ||
// Check payload length | ||
if (payload.length != 32) { | ||
revert(); | ||
} | ||
|
||
// Decode price | ||
uint256 price = abi.decode(payload, (uint256)); | ||
|
||
// Get salt | ||
bytes32 salt = keccak256(abi.encode(block.timestamp, msg.sender, serviceId)); | ||
|
||
// Service multisig is isOperator() for the mech | ||
mech = address((new AgentMech){salt: salt}(serviceRegistry, serviceId, price, mechMarketplace)); | ||
|
||
emit CreateBasicMech(mech, serviceId, price); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
contracts/integrations/nevermined/AgentFactorySubscription.sol
This file was deleted.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
contracts/integrations/nevermined/MechFactorySubscription.sol
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.28; | ||
|
||
import {AgentMechSubscription} from "./AgentMechSubscription.sol"; | ||
|
||
/// @title Mech Factory Subscription - Periphery smart contract for managing subscription mech creation | ||
contract MechFactorySubscription { | ||
event CreateSubscriptionMech(address indexed mech, uint256 indexed serviceId, uint256 minCreditsPerRequest, | ||
address indexed subscriptionNFT, uint256 subscriptionTokenId); | ||
|
||
// Agent factory version number | ||
string public constant VERSION = "0.1.0"; | ||
|
||
/// @dev Registers service as a mech. | ||
/// @param mechMarketplace Mech marketplace address. | ||
/// @param serviceRegistry Service registry address. | ||
/// @param serviceId Service id. | ||
/// @param payload Mech creation payload. | ||
/// @return mech The created mech instance address. | ||
function createMech( | ||
address mechMarketplace, | ||
address serviceRegistry, | ||
uint256 serviceId, | ||
bytes memory payload | ||
) external returns (address mech) { | ||
// Check payload length | ||
if (payload.length != 32) { | ||
revert(); | ||
} | ||
|
||
// Decode subscription parameters | ||
(uint256 minCreditsPerRequest, address subscriptionNFT, uint256 subscriptionTokenId) = | ||
abi.decode(payload, (uint256, address, uint256)); | ||
|
||
// Get salt | ||
bytes32 salt = keccak256(abi.encode(block.timestamp, msg.sender, serviceId)); | ||
|
||
// Service multisig is isOperator() for the mech | ||
mech = address((new AgentMechSubscription){salt: salt}(serviceRegistry, serviceId, minCreditsPerRequest, | ||
subscriptionNFT, subscriptionTokenId, mechMarketplace)); | ||
|
||
emit CreateSubscriptionMech(mech, serviceId, minCreditsPerRequest, subscriptionNFT, subscriptionTokenId); | ||
} | ||
} |