Skip to content

Commit d71f8f1

Browse files
committed
format
1 parent e9d199e commit d71f8f1

File tree

5 files changed

+67
-23
lines changed

5 files changed

+67
-23
lines changed

src/Blueprint.sol

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ contract Blueprint is Initializable, OwnableUpgradeable, BlueprintCore {
128128
emit CreditReward(userAddress, amount);
129129
}
130130
// 6 %。= 6 / 100 means fee =6 and baseFactor = 100
131-
function setGlobalPlatformFee(uint256 fee,uint256 baseFactor) public isAdmin {
131+
132+
function setGlobalPlatformFee(uint256 fee, uint256 baseFactor) public isAdmin {
132133
// base factor should be greater or equal than 10
133134
require(baseFactor >= 10, "Base factor should be greater than or equal to 10");
134135
require(fee <= baseFactor, "Fee cannot be greater than factor");

src/BlueprintCore.sol

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ contract BlueprintCore is Initializable, EIP712, Payment {
446446
requestID = createAgent(signerAddr, projectId, base64Proposal, privateWorkerAddress, serverURL, 0, tokenAddress);
447447
}
448448

449-
450449
function resetDeployment(
451450
address userAddress,
452451
bytes32 projectId,
@@ -675,11 +674,7 @@ contract BlueprintCore is Initializable, EIP712, Payment {
675674
}
676675

677676
// set copy agent fee, this can be called by owner only
678-
function setCopyAgentFee(
679-
bytes32 agentRequestID,
680-
address tokenAddress,
681-
uint256 fee
682-
) public payable {
677+
function setCopyAgentFee(bytes32 agentRequestID, address tokenAddress, uint256 fee) public payable {
683678
require(fee > 0, "Fee must be greater than 0");
684679
require(paymentAddressEnableMp[tokenAddress], "Invalid token address");
685680
// check if it owner of requestID
@@ -710,20 +705,10 @@ contract BlueprintCore is Initializable, EIP712, Payment {
710705
uint256 creatorFee = fee - platformCopyAgentFee;
711706

712707
// platform fee
713-
payWithERC20(
714-
tokenAddress,
715-
collectionWalletFee,
716-
msg.sender,
717-
feeCollectionWalletAddress
718-
);
708+
payWithERC20(tokenAddress, collectionWalletFee, msg.sender, feeCollectionWalletAddress);
719709

720710
// creator fee
721-
payWithERC20(
722-
tokenAddress,
723-
creatorFee,
724-
msg.sender,
725-
deploymentOwners[originalAgentRequestID]
726-
);
711+
payWithERC20(tokenAddress, creatorFee, msg.sender, deploymentOwners[originalAgentRequestID]);
727712

728713
emit CopyAgentRequest(copyID, originalAgentRequestID, msg.sender);
729714
}

src/BlueprintV7.sol

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
77
import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
88
import "./Blueprint.sol";
99

10-
contract BlueprintV6 is Initializable, UUPSUpgradeable, OwnableUpgradeable, Blueprint {
10+
contract BlueprintV7 is Initializable, UUPSUpgradeable, OwnableUpgradeable, Blueprint {
1111
string public constant SIGNING_DOMAIN = "nation.fun";
1212

1313
/// @custom:oz-upgrades-validate-as-initializer

test/BlueprintV6.t.sol

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -242,11 +242,9 @@ contract BlueprintTest is Test {
242242
// set zero cost for create agents, use any number less than 0
243243
blueprint.setUpdateCreateAgentTokenCost(address(mockToken), 0);
244244

245-
bytes32 updateHash =
246-
keccak256(abi.encodePacked(block.timestamp, address(this), requestId, base64Proposal, block.chainid));
247245
// Expect the UpdateDeploymentConfig event
248246
vm.expectEmit(true, true, true, true);
249-
emit BlueprintCore.UpdateDeploymentConfigs(projectId, requestId, workerAddress, updateHash, base64Proposal);
247+
emit BlueprintCore.UpdateDeploymentConfig(projectId, requestId, workerAddress, base64Proposal);
250248

251249
// update agent deployment config
252250
blueprint.updateWorkerDeploymentConfig(address(mockToken), projectId, requestId, base64Proposal);

test/BlueprintV7.t.sol

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
pragma solidity ^0.8.26;
2+
3+
import {Test, console} from "forge-std/Test.sol";
4+
import {Vm} from "forge-std/Vm.sol";
5+
import {BlueprintV7} from "../src/BlueprintV7.sol";
6+
import {BlueprintCore} from "../src/BlueprintCore.sol";
7+
import {Blueprint} from "../src/Blueprint.sol";
8+
import {stdError} from "forge-std/StdError.sol";
9+
import {MockERC20} from "./MockERC20.sol";
10+
11+
contract BlueprintTest is Test {
12+
BlueprintV7 public blueprint;
13+
MockERC20 public mockToken;
14+
bytes32 public projectId;
15+
address public workerAddress;
16+
address public dummyAddress;
17+
uint256 signerPrivateKey;
18+
19+
function setUp() public {
20+
blueprint = new BlueprintV7();
21+
blueprint.initialize(); // mimic upgradeable contract deploy behavior
22+
23+
mockToken = new MockERC20();
24+
25+
// set crestal wallet address
26+
blueprint.setFeeCollectionWalletAddress(address(0x7D8be0Dd8915E3511fFDDABDD631812be824f578));
27+
28+
projectId = bytes32(0x2723a34e38d0f0aa09ce626f00aa23c0464b52c75516cf3203cc4c9afeaf2980);
29+
workerAddress = address(0x4d6585D89F889F29f77fd7Dd71864269BA1B31df);
30+
dummyAddress = address(0);
31+
signerPrivateKey = 0xA11CE;
32+
}
33+
34+
function test_updateWorkerDeploymentConfig() public {
35+
string memory base64Proposal = "test base64 proposal";
36+
string memory serverURL = "app.crestal.network";
37+
38+
// Add the payment address
39+
blueprint.addPaymentAddress(address(mockToken));
40+
41+
// set zero cost for create agents, use any number less than 0
42+
blueprint.setCreateAgentTokenCost(address(mockToken), 0);
43+
44+
// Create agent with token
45+
bytes32 requestId =
46+
blueprint.createAgentWithToken(projectId, base64Proposal, workerAddress, serverURL, address(mockToken));
47+
48+
// set zero cost for create agents, use any number less than 0
49+
blueprint.setUpdateCreateAgentTokenCost(address(mockToken), 0);
50+
51+
bytes32 updateHash =
52+
keccak256(abi.encodePacked(block.timestamp, address(this), requestId, base64Proposal, block.chainid));
53+
// Expect the UpdateDeploymentConfig event
54+
vm.expectEmit(true, true, true, true);
55+
emit BlueprintCore.DeploymentConfigUpdate(projectId, requestId, workerAddress, updateHash, base64Proposal);
56+
57+
// update agent deployment config
58+
blueprint.updateWorkerDeploymentConfig(address(mockToken), projectId, requestId, base64Proposal);
59+
}
60+
}

0 commit comments

Comments
 (0)