Skip to content

Commit

Permalink
update version and deployment script
Browse files Browse the repository at this point in the history
  • Loading branch information
malteish committed Jan 3, 2024
1 parent eada1e8 commit 557f823
Show file tree
Hide file tree
Showing 3 changed files with 87 additions and 83 deletions.
2 changes: 1 addition & 1 deletion contracts/Token.sol
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ contract Token is
requirements = _requirements;

// set version (can be updated in proxy storage by later implementation contracts)
version = "1.0.0";
version = "1";

__ERC20Permit_init(_name);
__ERC20Snapshot_init();
Expand Down
160 changes: 82 additions & 78 deletions script/DeployPlatform.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -46,102 +46,106 @@ contract DeployPlatform is Script {

// Sepolia
address trustedForwarder = 0x274ca5f21Cdde06B6E4Fe063f5087EB6Cf3eAe55;
address[] memory trustedCurrencies = new address[](2);
trustedCurrencies[0] = address(0x30627856Ef668F0A6a1ca9145C9538f7d5b42BDE); // tEUROC
trustedCurrencies[1] = address(0x86f488C7CC923d987b246994a0E5e20B3364fd92); // tUSDC
//TokenProxyFactory tokenProxyFactory = TokenProxyFactory(0x2e9Ffd03c9334789199d0b172a57F215f8426a42);
FeeSettings feeSettings = FeeSettings(0x86195b076cd59Fc8fE8C076dBc86374a96E0eAda);
AllowList allowList = AllowList(0xF64bd9d1b65daf7a57Bd1C2ab84ACBcf3C6B5438);

// address[] memory trustedCurrencies = new address[](2);
// trustedCurrencies[0] = address(0x30627856Ef668F0A6a1ca9145C9538f7d5b42BDE); // tEUROC
// trustedCurrencies[1] = address(0x86f488C7CC923d987b246994a0E5e20B3364fd92); // tUSDC

/*
* execution
*/
console.log("Deployer address: ", deployerAddress);
vm.startBroadcast(deployerPrivateKey);

console.log("Deploying FeeSettingsCloneFactory contract...");
FeeSettings feeSettingsLogicContract = new FeeSettings(trustedForwarder);
FeeSettingsCloneFactory feeSettingsCloneFactory = new FeeSettingsCloneFactory(
address(feeSettingsLogicContract)
);
console.log("FeeSettingsCloneFactory deployed at: ", address(feeSettingsCloneFactory));

console.log("Deploying FeeSettings contract...");
Fees memory fees = Fees(200, 600, 200, 0);
FeeSettings feeSettings = FeeSettings(
feeSettingsCloneFactory.createFeeSettingsClone(
bytes32(0),
trustedForwarder,
platformColdWallet,
fees,
platformColdWallet,
platformColdWallet,
platformColdWallet
)
);
console.log("FeeSettings deployed at: ", address(feeSettings));

console.log("Deploying AllowListCloneFactory contract...");
AllowList allowListLogicContract = new AllowList(trustedForwarder);
AllowListCloneFactory allowListCloneFactory = new AllowListCloneFactory(address(allowListLogicContract));
console.log("AllowListCloneFactory deployed at: ", address(allowListCloneFactory));

console.log("Deploying AllowList contract...");

uint256[] memory attributes = new uint256[](trustedCurrencies.length);
for (uint256 i = 0; i < trustedCurrencies.length; i++) {
attributes[i] = TRUSTED_CURRENCY;
}
AllowList allowList = AllowList(
allowListCloneFactory.createAllowListClone(
bytes32(0),
trustedForwarder,
platformColdWallet,
trustedCurrencies,
attributes
)
);
console.log("Allowlist deployed at: ", address(allowList));

console.log("Deploying VestingCloneFactory contract...");
Vesting vestingImplementation = new Vesting(trustedForwarder);
VestingCloneFactory vestingCloneFactory = new VestingCloneFactory(address(vestingImplementation));
console.log("VestingCloneFactory deployed at: ", address(vestingCloneFactory));

console.log("Deploying PrivateOfferFactory contract...");
PrivateOfferFactory privateOfferFactory = new PrivateOfferFactory(vestingCloneFactory);
console.log("PrivateOfferFactory deployed at: ", address(privateOfferFactory));

console.log("Deploying TokenProxyFactory contract...");
Token tokenImplementation = new Token(trustedForwarder);
TokenProxyFactory tokenProxyFactory = new TokenProxyFactory(address(tokenImplementation));
console.log("TokenProxyFactory deployed at: ", address(tokenProxyFactory));
// console.log("Deploying FeeSettingsCloneFactory contract...");
// FeeSettings feeSettingsLogicContract = new FeeSettings(trustedForwarder);
// FeeSettingsCloneFactory feeSettingsCloneFactory = new FeeSettingsCloneFactory(
// address(feeSettingsLogicContract)
// );
// console.log("FeeSettingsCloneFactory deployed at: ", address(feeSettingsCloneFactory));

// console.log("Deploying Tokens to use as currrency on testnet...");
// Token tUSDC = Token(
// tokenProxyFactory.createTokenProxy(
// console.log("Deploying FeeSettings contract...");
// Fees memory fees = Fees(200, 600, 200, 0);
// FeeSettings feeSettings = FeeSettings(
// feeSettingsCloneFactory.createFeeSettingsClone(
// bytes32(0),
// trustedForwarder,
// feeSettings,
// platformColdWallet,
// allowList,
// 0,
// "tokenize.it_USDC",
// "tUSDC"
// fees,
// platformColdWallet,
// platformColdWallet,
// platformColdWallet
// )
// );
// console.log("tUSDC deployed at: ", address(tUSDC));
// Token tEUROC = Token(
// tokenProxyFactory.createTokenProxy(
// console.log("FeeSettings deployed at: ", address(feeSettings));

// console.log("Deploying AllowListCloneFactory contract...");
// AllowList allowListLogicContract = new AllowList(trustedForwarder);
// AllowListCloneFactory allowListCloneFactory = new AllowListCloneFactory(address(allowListLogicContract));
// console.log("AllowListCloneFactory deployed at: ", address(allowListCloneFactory));

// console.log("Deploying AllowList contract...");

// uint256[] memory attributes = new uint256[](trustedCurrencies.length);
// for (uint256 i = 0; i < trustedCurrencies.length; i++) {
// attributes[i] = TRUSTED_CURRENCY;
// }
// AllowList allowList = AllowList(
// allowListCloneFactory.createAllowListClone(
// bytes32(0),
// trustedForwarder,
// feeSettings,
// platformColdWallet,
// allowList,
// 0,
// "tokenize.it_EUROC",
// "tEUROC"
// trustedCurrencies,
// attributes
// )
// );
// console.log("tEUROC deployed at: ", address(tEUROC));
// console.log("Remember to add the tokens to the AllowList with attribute TRUSTED_CURRENCY: ", TRUSTED_CURRENCY);
// console.log("Allowlist deployed at: ", address(allowList));

// console.log("Deploying VestingCloneFactory contract...");
// Vesting vestingImplementation = new Vesting(trustedForwarder);
// VestingCloneFactory vestingCloneFactory = new VestingCloneFactory(address(vestingImplementation));
// console.log("VestingCloneFactory deployed at: ", address(vestingCloneFactory));

// console.log("Deploying PrivateOfferFactory contract...");
// PrivateOfferFactory privateOfferFactory = new PrivateOfferFactory(vestingCloneFactory);
// console.log("PrivateOfferFactory deployed at: ", address(privateOfferFactory));

console.log("Deploying TokenProxyFactory contract...");
Token tokenImplementation = new Token(trustedForwarder);
TokenProxyFactory tokenProxyFactory = new TokenProxyFactory(address(tokenImplementation));
console.log("TokenProxyFactory deployed at: ", address(tokenProxyFactory));

console.log("Deploying Tokens to use as currrency on testnet...");
Token tUSDC = Token(
tokenProxyFactory.createTokenProxy(
bytes32(1),
trustedForwarder,
feeSettings,
platformColdWallet,
allowList,
0,
"tokenize.it_USDC",
"tUSDC"
)
);
console.log("tUSDC deployed at: ", address(tUSDC));
Token tEUROC = Token(
tokenProxyFactory.createTokenProxy(
bytes32(1),
trustedForwarder,
feeSettings,
platformColdWallet,
allowList,
0,
"tokenize.it_EUROC",
"tEUROC"
)
);
console.log("tEUROC deployed at: ", address(tEUROC));
console.log("Remember to add the tokens to the AllowList with attribute TRUSTED_CURRENCY: ", TRUSTED_CURRENCY);

vm.stopBroadcast();
}
Expand Down
8 changes: 4 additions & 4 deletions test/TokenProxyUpgrade.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ contract TokenV2 is Token {
constructor(address _trustedForwarder) Token(_trustedForwarder) {}

function initializeV2() public reinitializer(2) {
version = 2;
version = "2";
}

function makeMeRich() public {
Expand Down Expand Up @@ -69,7 +69,7 @@ contract tokenProxyUpgradeTest is Test {
factory.createTokenProxy(0, trustedForwarder, feeSettings, companyAdmin, allowList, 0, someName, "TOK")
);

assertEq(token.version(), 1);
assertEq(token.version(), "1");
assertEq(token.name(), someName);

TokenV2 implementationV2 = new TokenV2(anotherTrustedForwarder);
Expand All @@ -84,11 +84,11 @@ contract tokenProxyUpgradeTest is Test {
assertEq(token.balanceOf(address(this)), 1e50);

// v2 is not initialized yet, so version should still be 1
assertEq(token.version(), 1);
assertEq(token.version(), "1");

// initialize v2
tokenV2.initializeV2();
assertEq(token.version(), 2);
assertEq(token.version(), "2");

// initializing again is not possible
vm.expectRevert("Initializable: contract is already initialized");
Expand Down

0 comments on commit 557f823

Please sign in to comment.