Skip to content

Commit

Permalink
Feature/HOLO-642: Implement Super Cold Storage logic into protocol (#92)
Browse files Browse the repository at this point in the history
* clean

* implementing the super-cold-storage-signer

* cleanup
  • Loading branch information
ACC01ADE authored Dec 6, 2022
1 parent ab00833 commit ff5b4ee
Show file tree
Hide file tree
Showing 32 changed files with 2,540 additions and 167 deletions.
2 changes: 1 addition & 1 deletion contracts/enforcer/HolographRoyalties.sol
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ contract HolographRoyalties is Admin, Owner, Initializable {
}
setRoyalties(0, payable(address(this)), bp);
address payable[] memory addresses = new address payable[](1);
addresses[0] = payable(getOwner());
addresses[0] = payable(Owner(HolographerInterface(address(this)).getSourceContract()).owner());
uint256[] memory bps = new uint256[](1);
bps[0] = 10000;
_setPayoutAddresses(addresses);
Expand Down
51 changes: 37 additions & 14 deletions deploy/02_sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,26 @@ import {
} from '../scripts/utils/helpers';
import { HolographERC20Event, ConfigureEvents } from '../scripts/utils/events';
import { NetworkType, Network, networks } from '@holographxyz/networks';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const GWEI: BigNumber = BigNumber.from('1000000000');

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const { deployments, getNamedAccounts } = hre;
const accounts = await hre.ethers.getSigners();
const deployer: SignerWithAddress = accounts[0];
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const web3 = new Web3();

Expand Down Expand Up @@ -271,7 +283,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
);
} else {
hre.deployments.log('"Holograph" is already deployed. Checking configs.');
let holograph = (await hre.ethers.getContractAt('Holograph', futureHolographAddress)) as Holograph;
let holograph = (await hre.ethers.getContractAt('Holograph', futureHolographAddress, deployer)) as Holograph;
if ((await holograph.getBridge()) != futureBridgeProxyAddress) {
hre.deployments.log('Updating Bridge reference');
let tx = await holograph.setBridge(futureBridgeProxyAddress, {
Expand Down Expand Up @@ -365,11 +377,13 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('"HolographBridgeProxy" is already deployed. Checking configs.');
let holographBridgeProxy = (await hre.ethers.getContractAt(
'HolographBridgeProxy',
futureBridgeProxyAddress
futureBridgeProxyAddress,
deployer
)) as HolographBridgeProxy;
let holographBridge = (await hre.ethers.getContractAt(
'HolographBridge',
futureBridgeProxyAddress
futureBridgeProxyAddress,
deployer
)) as HolographBridge;
if ((await holographBridgeProxy.getBridge()) != futureBridgeAddress) {
hre.deployments.log('Updating Bridge reference');
Expand Down Expand Up @@ -450,11 +464,13 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('"HolographFactoryProxy" is already deployed. Checking configs.');
let holographFactoryProxy = (await hre.ethers.getContractAt(
'HolographFactoryProxy',
futureFactoryProxyAddress
futureFactoryProxyAddress,
deployer
)) as HolographFactoryProxy;
let holographFactory = (await hre.ethers.getContractAt(
'HolographFactory',
futureFactoryProxyAddress
futureFactoryProxyAddress,
deployer
)) as HolographFactory;
if ((await holographFactoryProxy.getFactory()) != futureFactoryAddress) {
hre.deployments.log('Updating Factory reference');
Expand Down Expand Up @@ -531,11 +547,13 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('"HolographOperatorProxy" is already deployed. Checking configs.');
let holographOperatorProxy = (await hre.ethers.getContractAt(
'HolographOperatorProxy',
futureOperatorProxyAddress
futureOperatorProxyAddress,
deployer
)) as HolographOperatorProxy;
let holographOperator = (await hre.ethers.getContractAt(
'HolographOperator',
futureOperatorProxyAddress
futureOperatorProxyAddress,
deployer
)) as HolographOperator;
if ((await holographOperatorProxy.getOperator()) != futureOperatorAddress) {
hre.deployments.log('Updating Operator reference');
Expand Down Expand Up @@ -639,7 +657,8 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
);
let holographRegistry = (await hre.ethers.getContractAt(
'HolographRegistry',
futureRegistryProxyAddress
futureRegistryProxyAddress,
deployer
)) as HolographRegistry;
if ((await holographRegistry.getUtilityToken()) != futureHlgAddress) {
hre.deployments.log('Updating UtilityToken reference');
Expand All @@ -652,11 +671,13 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('"HolographRegistryProxy" is already deployed. Checking configs.');
let holographRegistryProxy = (await hre.ethers.getContractAt(
'HolographRegistryProxy',
futureRegistryProxyAddress
futureRegistryProxyAddress,
deployer
)) as HolographRegistryProxy;
let holographRegistry = (await hre.ethers.getContractAt(
'HolographRegistry',
futureRegistryProxyAddress
futureRegistryProxyAddress,
deployer
)) as HolographRegistry;
if ((await holographRegistryProxy.getRegistry()) != futureRegistryAddress) {
hre.deployments.log('Updating Registry reference');
Expand Down Expand Up @@ -726,11 +747,13 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('"HolographTreasuryProxy" is already deployed. Checking configs.');
let holographTreasuryProxy = (await hre.ethers.getContractAt(
'HolographTreasuryProxy',
futureTreasuryProxyAddress
futureTreasuryProxyAddress,
deployer
)) as HolographTreasuryProxy;
let holographTreasury = (await hre.ethers.getContractAt(
'HolographTreasury',
futureTreasuryProxyAddress
futureTreasuryProxyAddress,
deployer
)) as HolographTreasury;
if ((await holographTreasuryProxy.getTreasury()) != futureTreasuryAddress) {
hre.deployments.log('Updating Treasury reference');
Expand Down
27 changes: 21 additions & 6 deletions deploy/03_interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
InitializableInterface,
HolographRoyaltiesInterface,
} from '../typechain-types';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const web3 = new Web3();

Expand Down Expand Up @@ -58,7 +59,20 @@ const XOR = function (hashes: string[]): string {

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const { deployer } = await hre.getNamedAccounts();
const accounts = await hre.ethers.getSigners();
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const salt = hre.deploymentSalt;

Expand All @@ -77,7 +91,8 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {

const holographInterfaces: HolographInterfaces = (await hre.ethers.getContractAt(
'HolographInterfaces',
futureHolographInterfacesAddress
futureHolographInterfacesAddress,
deployer
)) as HolographInterfaces;
const network: Network = networks[hre.networkName];
const networkType: NetworkType = network.type;
Expand Down Expand Up @@ -130,7 +145,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
toChainId.push(chainMap[3]);
}
let tx = await holographInterfaces.updateChainIdMaps(fromChainType, fromChainId, toChainType, toChainId, {
nonce: await hre.ethers.provider.getTransactionCount(deployer),
nonce: await hre.ethers.provider.getTransactionCount(deployer.address),
});
await tx.wait();
}
Expand Down Expand Up @@ -158,7 +173,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
prepends.push(prepend.prepend);
}
let tx = await holographInterfaces.updateUriPrepends(uriTypes, prepends, {
nonce: await hre.ethers.provider.getTransactionCount(deployer),
nonce: await hre.ethers.provider.getTransactionCount(deployer.address),
});
await tx.wait();
}
Expand Down Expand Up @@ -311,7 +326,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre.deployments.log('HolographInterfaces needs to have all supported interfaces configured');
for (let key of Object.keys(supportedInterfaces)) {
let tx = await holographInterfaces.updateInterfaces(parseInt(key), supportedInterfaces[key], true, {
nonce: await hre.ethers.provider.getTransactionCount(deployer),
nonce: await hre.ethers.provider.getTransactionCount(deployer.address),
});
await tx.wait();
}
Expand All @@ -331,7 +346,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
} else {
hre.deployments.log('Found missing interfaces in HolographInterfaces for InterfaceType[' + key + ']');
let tx = await holographInterfaces.updateInterfaces(parseInt(key), todo, true, {
nonce: await hre.ethers.provider.getTransactionCount(deployer),
nonce: await hre.ethers.provider.getTransactionCount(deployer.address),
});
await tx.wait();
}
Expand Down
15 changes: 15 additions & 0 deletions deploy/04_generic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,24 @@ import { HardhatRuntimeEnvironment } from 'hardhat/types';
import { DeployFunction } from '@holographxyz/hardhat-deploy-holographed/types';
import { hreSplit, genesisDeployHelper, genesisDeriveFutureAddress, generateInitCode } from '../scripts/utils/helpers';
import { ConfigureEvents } from '../scripts/utils/events';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const accounts = await hre.ethers.getSigners();
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const salt = hre.deploymentSalt;

Expand Down
15 changes: 15 additions & 0 deletions deploy/05_erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,24 @@ import {
generateInitCode,
} from '../scripts/utils/helpers';
import { HolographERC20Event, ConfigureEvents } from '../scripts/utils/events';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const accounts = await hre.ethers.getSigners();
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const salt = hre.deploymentSalt;

Expand Down
25 changes: 19 additions & 6 deletions deploy/06_erc721.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,24 @@ import {
zeroAddress,
} from '../scripts/utils/helpers';
import { HolographERC721Event, ConfigureEvents } from '../scripts/utils/events';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const { getNamedAccounts } = hre;
const { deployer } = await getNamedAccounts();
const accounts = await hre.ethers.getSigners();
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const salt = hre.deploymentSalt;

Expand All @@ -30,7 +43,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
1000, // contractBps == 0%
ConfigureEvents([]), // eventConfig
true, // skipInit
generateInitCode(['address'], [deployer]), // initCode
generateInitCode(['address'], [deployer.address]), // initCode
]
)
);
Expand All @@ -52,7 +65,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
1000, // contractBps == 0%
ConfigureEvents([]), // eventConfig
true, // skipInit
generateInitCode(['address'], [deployer]), // initCode
generateInitCode(['address'], [deployer.address]), // initCode
]
),
futureErc721Address
Expand All @@ -65,7 +78,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre,
salt,
'CxipERC721',
generateInitCode(['address'], [deployer])
generateInitCode(['address'], [deployer.address])
);
hre.deployments.log('the future "CxipERC721" address is', futureCxipErc721Address);

Expand All @@ -77,7 +90,7 @@ const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
hre,
salt,
'CxipERC721',
generateInitCode(['address'], [deployer]),
generateInitCode(['address'], [deployer.address]),
futureCxipErc721Address
);
} else {
Expand Down
15 changes: 15 additions & 0 deletions deploy/07_erc1155.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,24 @@ import {
generateInitCode,
} from '../scripts/utils/helpers';
import { HolographERC1155Event, ConfigureEvents } from '../scripts/utils/events';
import { SuperColdStorageSigner } from 'super-cold-storage-signer';

const func: DeployFunction = async function (hre1: HardhatRuntimeEnvironment) {
let { hre, hre2 } = await hreSplit(hre1, global.__companionNetwork);
const accounts = await hre.ethers.getSigners();
let deployer: SignerWithAddress | SuperColdStorageSigner = accounts[0];

if (global.__superColdStorage) {
// address, domain, authorization, ca
const coldStorage = global.__superColdStorage;
deployer = new SuperColdStorageSigner(
coldStorage.address,
'https://' + coldStorage.domain,
coldStorage.authorization,
deployer.provider,
coldStorage.ca
);
}

const salt = hre.deploymentSalt;

Expand Down
Loading

0 comments on commit ff5b4ee

Please sign in to comment.